From f0eaf10a262f6c95011cd362d67559827e95149e Mon Sep 17 00:00:00 2001 From: Geoff Hickey Date: Thu, 16 Nov 2017 15:49:40 -0500 Subject: [PATCH] Review comments --- internal/lvgen/constants.tmpl | 4 +- internal/lvgen/gen/main.go | 4 +- internal/lvgen/lv-gen.go | 9 ++-- internal/lvgen/lvlexer.go | 1 - libvirt.go | 82 ----------------------------------- 5 files changed, 8 insertions(+), 92 deletions(-) diff --git a/internal/lvgen/constants.tmpl b/internal/lvgen/constants.tmpl index 3d7425f..6677409 100644 --- a/internal/lvgen/constants.tmpl +++ b/internal/lvgen/constants.tmpl @@ -4,10 +4,10 @@ * To regenerate, run 'go generate' in internal/lvgen. */ +// Package constants contains libvirt procedure identifiers and other enums and +// constants. package constants -// libvirt procedure identifiers and other enums -// // These are libvirt procedure numbers which correspond to each respective // API call between remote_internal driver and libvirtd. Each procedure is // identified by a unique number which *may change in any future libvirt diff --git a/internal/lvgen/gen/main.go b/internal/lvgen/gen/main.go index c36a6d4..c91910b 100644 --- a/internal/lvgen/gen/main.go +++ b/internal/lvgen/gen/main.go @@ -17,7 +17,7 @@ package main import ( "fmt" "os" - "path" + "path/filepath" "github.com/digitalocean/go-libvirt/internal/lvgen" ) @@ -30,7 +30,7 @@ func main() { fmt.Println("set $LIBVIRT_SOURCE to point to the root of the libvirt sources and retry") os.Exit(1) } - lvFile := path.Join(lvPath, protoPath) + lvFile := filepath.Join(lvPath, protoPath) rdr, err := os.Open(lvFile) if err != nil { fmt.Printf("failed to open protocol file at %v: %v\n", lvFile, err) diff --git a/internal/lvgen/lv-gen.go b/internal/lvgen/lv-gen.go index c622f74..5b8af82 100644 --- a/internal/lvgen/lv-gen.go +++ b/internal/lvgen/lv-gen.go @@ -1,9 +1,8 @@ -package lvgen - -// This file contains the instructions for regenerating the libvirt bindings. -// We do this by parsing the remote_protocol.x file included in the libvirt -// sources. Bindings will be generated if you run `go generate` in this +// Package lvgen contains the instructions for regenerating the libvirt +// bindings. We do this by parsing the remote_protocol.x file included in the +// libvirt sources. Bindings will be generated if you run `go generate` in this // directory. +package lvgen // Before running `go generate`: // 1) Make sure goyacc is installed from golang.org/x/tools (you can use this diff --git a/internal/lvgen/lvlexer.go b/internal/lvgen/lvlexer.go index 06341a2..40dcbed 100644 --- a/internal/lvgen/lvlexer.go +++ b/internal/lvgen/lvlexer.go @@ -124,7 +124,6 @@ func (l *Lexer) Lex(st *yySymType) int { s := <-l.items l.lastItem = s st.val = s.val - // fmt.Println("Lex returning", s) return int(s.typ) } diff --git a/libvirt.go b/libvirt.go index 280a2a7..37c6546 100644 --- a/libvirt.go +++ b/libvirt.go @@ -96,88 +96,6 @@ const ( FlagTypedParamStringOkay ) -// Consts relating to TypedParams: -const ( - // TypeParamInt is a C int. - TypeParamInt = iota + 1 - // TypeParamUInt is a C unsigned int. - TypeParamUInt - // TypeParamLLong is a C long long int. - TypeParamLLong - // TypeParamULLong is a C unsigned long long int. - TypeParamULLong - // TypeParamDouble is a C double. - TypeParamDouble - // TypeParamBoolean is a C char. - TypeParamBoolean - // TypeParamString is a C char*. - TypeParamString - - // TypeParamLast is just an end-of-enum marker. - TypeParamLast -) - -// TypedParamULongLong contains a 64-bit unsigned integer. -type TypedParamULongLong struct { - Fld string - PType int32 - Val uint64 -} - -// Field returns the field name, a string name for the parameter. -func (tp *TypedParamULongLong) Field() string { - return tp.Fld -} - -// Value returns the value for the typed parameter, as an empty interface. -func (tp *TypedParamULongLong) Value() interface{} { - return tp.Val -} - -// NewTypedParamULongLong returns a TypedParam encoding for an unsigned long long. -func NewTypedParamULongLong(name string, v uint64) *TypedParamULongLong { - // Truncate the field name if it's longer than the limit. - if len(name) > constants.TypedParamFieldLength { - name = name[:constants.TypedParamFieldLength] - } - tp := TypedParamULongLong{ - Fld: name, - PType: TypeParamULLong, - Val: v, - } - return &tp -} - -// TypedParamString contains a string parameter. -type TypedParamString struct { - Fld string - PType int - Val string -} - -// Field returns the field name, a string name for the parameter. -func (tp *TypedParamString) Field() string { - return tp.Fld -} - -// Value returns the value for the typed parameter, as an empty interface. -func (tp *TypedParamString) Value() interface{} { - return tp.Val -} - -// NewTypedParamString returns a typed parameter containing the passed string. -// func NewTypedParamString(name string, v string) TypedParam { -// if len(name) > constants.TypedParamFieldLength { -// name = name[:constants.TypedParamFieldLength] -// } -// tp := TypedParamString{ -// Fld: name, -// PType: TypeParamString, -// Val: v, -// } -// return &tp -// } - const ( // DomainXMLFlagSecure dumps XML with sensitive information included. DomainXMLFlagSecure DomainXMLFlags = 1 << iota