Documentation ¶
Index ¶
- func CryptoRandInt64() int64
- func IsEmptyBool(f string) string
- func IsEmptyNumber(f string) string
- func IsEmptyTime(f string) string
- func IsLenZero(f string) string
- func IsNilInterface(f string) string
- func IsPrintable(e Elem) bool
- func MathRandInt64() int64
- func SeedOurMathRandSrc(seed int64)
- func SetFilename(fn string)
- type Array
- func (a *Array) Complexity() int
- func (a *Array) Copy() Elem
- func (a *Array) GetZtype() (r zebra.Ztype)
- func (s *Array) IsInInterfaceSlice() bool
- func (s *Array) IsInterface() bool
- func (s *Array) SetIsInInterfaceSlice()
- func (a *Array) SetVarname(s string)
- func (a *Array) TypeName() string
- func (a *Array) ZeroLiteral(v string) string
- type BaseElem
- func (s *BaseElem) Alias(typ string)
- func (s *BaseElem) BaseName() string
- func (s *BaseElem) BaseType() string
- func (s *BaseElem) Complexity() int
- func (s *BaseElem) Copy() Elem
- func (s *BaseElem) FromBase() string
- func (s *BaseElem) GetZtype() (r zebra.Ztype)
- func (s *BaseElem) IsInInterfaceSlice() bool
- func (s *BaseElem) IsInterface() bool
- func (s *BaseElem) Needsref(b bool)
- func (s *BaseElem) Printable() bool
- func (s *BaseElem) Resolved() bool
- func (s *BaseElem) SetIsInInterfaceSlice()
- func (s *BaseElem) SetVarname(a string)
- func (s *BaseElem) ToBase() string
- func (s *BaseElem) TypeName() string
- func (s *BaseElem) ZeroLiteral(v string) string
- type Common
- func (c *Common) Alias(typ string)
- func (c *Common) GetZid() int64
- func (c *Common) MethodPrefix() string
- func (c *Common) SetHasMethodPrefix(hmp HasMethodPrefix)
- func (c *Common) SetVarname(s string)
- func (c *Common) SetZid(zid int64)
- func (c *Common) SkipMe() bool
- func (c *Common) Varname() string
- type Elem
- type HasMethodPrefix
- type Map
- func (m *Map) Complexity() int
- func (m *Map) Copy() Elem
- func (m *Map) GetZtype() (r zebra.Ztype)
- func (s *Map) IsInInterfaceSlice() bool
- func (s *Map) IsInterface() bool
- func (m *Map) SetIsInInterfaceSlice()
- func (m *Map) SetVarname(s string)
- func (m *Map) TypeName() string
- func (m *Map) ZeroLiteral(v string) string
- type Method
- type Primitive
- type Printer
- type Ptr
- func (s *Ptr) Complexity() int
- func (s *Ptr) Copy() Elem
- func (s *Ptr) GetZtype() (r zebra.Ztype)
- func (s *Ptr) IsInInterfaceSlice() bool
- func (s *Ptr) IsInterface() bool
- func (s *Ptr) Needsinit() bool
- func (s *Ptr) SetIsInInterfaceSlice()
- func (s *Ptr) SetVarname(a string)
- func (s *Ptr) TypeName() string
- func (s *Ptr) ZeroLiteral(v string) string
- type Slice
- func (s *Slice) Complexity() int
- func (s *Slice) Copy() Elem
- func (s *Slice) GetZtype() (r zebra.Ztype)
- func (s *Slice) IsInInterfaceSlice() bool
- func (s *Slice) IsInterface() bool
- func (s *Slice) SetIsInInterfaceSlice()
- func (s *Slice) SetVarname(a string)
- func (s *Slice) TypeName() string
- func (a *Slice) ZeroLiteral(v string) string
- type Struct
- func (s *Struct) Complexity() int
- func (s *Struct) Copy() Elem
- func (s *Struct) GetZtype() (r zebra.Ztype)
- func (s *Struct) IsInInterfaceSlice() bool
- func (s *Struct) IsInterface() bool
- func (s *Struct) SetIsInInterfaceSlice()
- func (s *Struct) SetVarname(a string)
- func (s *Struct) TypeName() string
- func (s *Struct) ZeroLiteral(v string) string
- type StructField
- type TransformPass
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsEmptyBool ¶
func IsEmptyNumber ¶
func IsEmptyTime ¶
func IsNilInterface ¶
func IsPrintable ¶
func MathRandInt64 ¶
func MathRandInt64() int64
func SeedOurMathRandSrc ¶
func SeedOurMathRandSrc(seed int64)
func SetFilename ¶
func SetFilename(fn string)
Types ¶
type Array ¶
type Array struct { Common Index string // index variable name SizeNamed string // array size SizeResolved string // array size Els Elem // child }
func (*Array) Complexity ¶
func (*Array) IsInInterfaceSlice ¶
func (*Array) IsInterface ¶
func (*Array) SetIsInInterfaceSlice ¶
func (s *Array) SetIsInInterfaceSlice()
func (*Array) SetVarname ¶
func (*Array) ZeroLiteral ¶
type BaseElem ¶
type BaseElem struct { Common ShimToBase string // shim to base type, or empty ShimFromBase string // shim from base type, or empty Value Primitive // Type of element Convert bool // should we do an explicit conversion? // contains filtered or unexported fields }
BaseElem is an element that can be represented by a primitive MessagePack type.
func (*BaseElem) BaseName ¶
BaseName returns the string form of the base type (e.g. Float64, Ident, etc)
func (*BaseElem) Complexity ¶
func (*BaseElem) FromBase ¶
FromBase, used if Convert==true, is used as {{Varname}} = {{FromBase}}(tmp)
func (*BaseElem) IsInInterfaceSlice ¶
func (*BaseElem) IsInterface ¶
func (*BaseElem) Resolved ¶
Resolved returns whether or not the type of the element is a primitive or a builtin provided by the package.
func (*BaseElem) SetIsInInterfaceSlice ¶
func (s *BaseElem) SetIsInInterfaceSlice()
func (*BaseElem) SetVarname ¶
func (*BaseElem) TypeName ¶
TypeName returns the syntactically correct Go type name for the base element.
func (*BaseElem) ZeroLiteral ¶
type Common ¶
type Common struct { Skip bool // contains filtered or unexported fields }
Common data/methods for every Elem
func (*Common) MethodPrefix ¶
func (*Common) SetHasMethodPrefix ¶
func (c *Common) SetHasMethodPrefix(hmp HasMethodPrefix)
func (*Common) SetVarname ¶
type Elem ¶
type Elem interface { // SetVarname sets this nodes // variable name and recursively // sets the names of all its children. // In general, this should only be // called on the parent of the tree. SetVarname(s string) // Varname returns the variable // name of the element. Varname() string // TypeName is the canonical // go type name of the node // e.g. "string", "int", "map[string]float64" // OR the alias name, if it has been set. TypeName() string // Alias sets a type (alias) name Alias(typ string) // Copy should perform a deep copy of the object Copy() Elem // Complexity returns a measure of the // complexity of element (greater than // or equal to 1.) Complexity() int // ZeroLiteral returns the literal expression // needed to initialize an element named v to its // zero value. e.g. 0 for numbers, "" for strings, // or Truck{} for a struct Truck. ZeroLiteral(v string) string // GetZtype provides type info in a uniform way. GetZtype() zebra.Ztype // for template instantiation with custom method prefix MethodPrefix() string SetHasMethodPrefix(hmp HasMethodPrefix) IsInterface() bool IsInInterfaceSlice() bool SetIsInInterfaceSlice() SkipMe() bool SetZid(zid int64) GetZid() int64 // contains filtered or unexported methods }
Elem is a go type capable of being serialized into MessagePack. It is implemented by *Ptr, *Struct, *Array, *Slice, *Map, and *BaseElem.
type HasMethodPrefix ¶
type HasMethodPrefix interface {
MethodPrefix() string
}
type Map ¶
type Map struct { Common Keyidx string // key variable name Validx string // value variable name Value Elem // value element KeyTyp string KeyDeclTyp string }
Map is a map[string]Elem
func (*Map) Complexity ¶
func (*Map) IsInInterfaceSlice ¶
func (*Map) IsInterface ¶
func (*Map) SetIsInInterfaceSlice ¶
func (m *Map) SetIsInInterfaceSlice()
func (*Map) SetVarname ¶
func (*Map) ZeroLiteral ¶
type Method ¶
type Method uint16
Method is a bitfield representing something that the generator knows how to print.
type Primitive ¶
type Primitive uint8
Base is one of the base types
const ( Invalid Primitive = iota Bytes String Float32 Float64 Complex64 Complex128 Uint Uint8 Uint16 Uint32 Uint64 Byte Int Int8 Int16 Int32 Int64 Bool Intf // interface{} Time // time.Time Ext // extension IDENT // IDENT means an unrecognized identifier )
this is effectively the list of currently available ReadXxxx / WriteXxxx methods.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
func NewPrinter ¶
func (*Printer) ApplyDirective ¶
func (p *Printer) ApplyDirective(pass Method, t TransformPass)
ApplyDirective applies a directive to a named pass and all of its dependents.
type Ptr ¶
func (*Ptr) Complexity ¶
func (*Ptr) IsInInterfaceSlice ¶
func (*Ptr) IsInterface ¶
func (*Ptr) SetIsInInterfaceSlice ¶
func (s *Ptr) SetIsInInterfaceSlice()
func (*Ptr) SetVarname ¶
func (*Ptr) ZeroLiteral ¶
type Slice ¶
func (*Slice) Complexity ¶
func (*Slice) IsInInterfaceSlice ¶
func (*Slice) IsInterface ¶
func (*Slice) SetIsInInterfaceSlice ¶
func (s *Slice) SetIsInInterfaceSlice()
func (*Slice) SetVarname ¶
func (*Slice) ZeroLiteral ¶
type Struct ¶
type Struct struct { Common Fields []StructField // field list AsTuple bool // write as an array instead of a map KeyTyp string SkipCount int // contains filtered or unexported fields }
func (*Struct) Complexity ¶
func (*Struct) IsInInterfaceSlice ¶
func (*Struct) IsInterface ¶
func (*Struct) SetIsInInterfaceSlice ¶
func (s *Struct) SetIsInInterfaceSlice()
func (*Struct) SetVarname ¶
func (*Struct) ZeroLiteral ¶
type StructField ¶
type StructField struct { FieldTag string // the string inside the `msg:""` tag FieldName string // the name of the struct field FieldElem Elem // the field type OmitEmpty bool // if the tag `msg:",omitempty"` was found Deprecated bool // if the tag `deprecated:"true"` was found Skip bool // if msg:"-" or field is type struct{} ShowZero bool // if msg:",showzero" tag was found. IsIface bool // the field type is an interface? // ZebraId defaults to -1, meaning not-tagged with a zebra id. // if ZebraId >= 0, then the tag `zebra:"N"` was found, with ZebraId == N. ZebraId int64 }
func (*StructField) IsInterface ¶
func (s *StructField) IsInterface() bool
func (*StructField) SkipMe ¶
func (s *StructField) SkipMe() bool
type TransformPass ¶
TransformPass is a pass that transforms individual elements. (Note that if the returned is different from the argument, it should not point to the same objects.)
func IgnoreTypename ¶
func IgnoreTypename(name string) TransformPass
IgnoreTypename is a pass that just ignores types of a given name.