Review comments

This commit is contained in:
Geoff Hickey 2017-11-16 15:49:40 -05:00
parent 96763e5316
commit f0eaf10a26
5 changed files with 8 additions and 92 deletions

View File

@ -4,10 +4,10 @@
* To regenerate, run 'go generate' in internal/lvgen. * To regenerate, run 'go generate' in internal/lvgen.
*/ */
// Package constants contains libvirt procedure identifiers and other enums and
// constants.
package constants package constants
// libvirt procedure identifiers and other enums
//
// These are libvirt procedure numbers which correspond to each respective // These are libvirt procedure numbers which correspond to each respective
// API call between remote_internal driver and libvirtd. Each procedure is // API call between remote_internal driver and libvirtd. Each procedure is
// identified by a unique number which *may change in any future libvirt // identified by a unique number which *may change in any future libvirt

View File

@ -17,7 +17,7 @@ package main
import ( import (
"fmt" "fmt"
"os" "os"
"path" "path/filepath"
"github.com/digitalocean/go-libvirt/internal/lvgen" "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") fmt.Println("set $LIBVIRT_SOURCE to point to the root of the libvirt sources and retry")
os.Exit(1) os.Exit(1)
} }
lvFile := path.Join(lvPath, protoPath) lvFile := filepath.Join(lvPath, protoPath)
rdr, err := os.Open(lvFile) rdr, err := os.Open(lvFile)
if err != nil { if err != nil {
fmt.Printf("failed to open protocol file at %v: %v\n", lvFile, err) fmt.Printf("failed to open protocol file at %v: %v\n", lvFile, err)

View File

@ -1,9 +1,8 @@
package lvgen // Package lvgen contains the instructions for regenerating the libvirt
// bindings. We do this by parsing the remote_protocol.x file included in the
// This file contains the instructions for regenerating the libvirt bindings. // libvirt sources. Bindings will be generated if you run `go generate` in this
// 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. // directory.
package lvgen
// Before running `go generate`: // Before running `go generate`:
// 1) Make sure goyacc is installed from golang.org/x/tools (you can use this // 1) Make sure goyacc is installed from golang.org/x/tools (you can use this

View File

@ -124,7 +124,6 @@ func (l *Lexer) Lex(st *yySymType) int {
s := <-l.items s := <-l.items
l.lastItem = s l.lastItem = s
st.val = s.val st.val = s.val
// fmt.Println("Lex returning", s)
return int(s.typ) return int(s.typ)
} }

View File

@ -96,88 +96,6 @@ const (
FlagTypedParamStringOkay 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 ( const (
// DomainXMLFlagSecure dumps XML with sensitive information included. // DomainXMLFlagSecure dumps XML with sensitive information included.
DomainXMLFlagSecure DomainXMLFlags = 1 << iota DomainXMLFlagSecure DomainXMLFlags = 1 << iota