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 IsPrintable(e Elem) bool
- func MathRandInt64() int64
- func SeedOurMathRandSrc(seed int64)
- func SetFilename(fn string)
- type Array
- func (c *Array) Alias(typ string)
- func (a *Array) Complexity() int
- func (a *Array) Copy() Elem
- func (a *Array) GetZtype() (r green.Ztype)
- func (c *Array) MethodPrefix() string
- func (c *Array) SetHasMethodPrefix(hmp HasMethodPrefix)
- func (a *Array) SetVarname(s string)
- func (a *Array) TypeClue() string
- func (a *Array) TypeName() string
- func (c *Array) Varname() 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 green.Ztype)
- func (c *BaseElem) MethodPrefix() string
- func (s *BaseElem) Needsref(b bool)
- func (s *BaseElem) Printable() bool
- func (s *BaseElem) Resolved() bool
- func (c *BaseElem) SetHasMethodPrefix(hmp HasMethodPrefix)
- func (s *BaseElem) SetVarname(a string)
- func (s *BaseElem) ToBase() string
- func (s *BaseElem) TypeClue() string
- func (s *BaseElem) TypeName() string
- func (c *BaseElem) Varname() string
- func (s *BaseElem) ZeroLiteral(v string) string
- type Elem
- type HasMethodPrefix
- type Map
- func (c *Map) Alias(typ string)
- func (m *Map) Complexity() int
- func (m *Map) Copy() Elem
- func (m *Map) GetZtype() (r green.Ztype)
- func (c *Map) MethodPrefix() string
- func (c *Map) SetHasMethodPrefix(hmp HasMethodPrefix)
- func (m *Map) SetVarname(s string)
- func (m *Map) TypeClue() string
- func (m *Map) TypeName() string
- func (c *Map) Varname() string
- func (m *Map) ZeroLiteral(v string) string
- type Method
- type Primitive
- type Printer
- type Ptr
- func (c *Ptr) Alias(typ string)
- func (s *Ptr) Complexity() int
- func (s *Ptr) Copy() Elem
- func (s *Ptr) GetZtype() (r green.Ztype)
- func (c *Ptr) MethodPrefix() string
- func (s *Ptr) Needsinit() bool
- func (c *Ptr) SetHasMethodPrefix(hmp HasMethodPrefix)
- func (s *Ptr) SetVarname(a string)
- func (s *Ptr) TypeClue() string
- func (s *Ptr) TypeName() string
- func (c *Ptr) Varname() string
- func (s *Ptr) ZeroLiteral(v string) string
- type Slice
- func (c *Slice) Alias(typ string)
- func (s *Slice) Complexity() int
- func (s *Slice) Copy() Elem
- func (s *Slice) GetZtype() (r green.Ztype)
- func (c *Slice) MethodPrefix() string
- func (c *Slice) SetHasMethodPrefix(hmp HasMethodPrefix)
- func (s *Slice) SetVarname(a string)
- func (a *Slice) TypeClue() string
- func (s *Slice) TypeName() string
- func (c *Slice) Varname() string
- func (a *Slice) ZeroLiteral(v string) string
- type Struct
- func (c *Struct) Alias(typ string)
- func (s *Struct) Complexity() int
- func (s *Struct) Copy() Elem
- func (s *Struct) GetZtype() (r green.Ztype)
- func (c *Struct) MethodPrefix() string
- func (c *Struct) SetHasMethodPrefix(hmp HasMethodPrefix)
- func (s *Struct) SetVarname(a string)
- func (s *Struct) TypeClue() string
- func (s *Struct) TypeName() string
- func (c *Struct) Varname() 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 IsPrintable ¶
func MathRandInt64 ¶
func MathRandInt64() int64
func SeedOurMathRandSrc ¶
func SeedOurMathRandSrc(seed int64)
func SetFilename ¶
func SetFilename(fn string)
Types ¶
type Array ¶
type Array struct { Index string // index variable name SizeNamed string // array size SizeResolved string // array size Els Elem // child // contains filtered or unexported fields }
func (*Array) Complexity ¶
func (*Array) MethodPrefix ¶
func (c *Array) MethodPrefix() string
func (*Array) SetHasMethodPrefix ¶
func (c *Array) SetHasMethodPrefix(hmp HasMethodPrefix)
func (*Array) SetVarname ¶
func (*Array) ZeroLiteral ¶
type BaseElem ¶
type BaseElem struct { 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) MethodPrefix ¶
func (c *BaseElem) MethodPrefix() string
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) SetHasMethodPrefix ¶
func (c *BaseElem) SetHasMethodPrefix(hmp HasMethodPrefix)
func (*BaseElem) SetVarname ¶
func (*BaseElem) TypeName ¶
TypeName returns the syntactically correct Go type name for the base element.
func (*BaseElem) ZeroLiteral ¶
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() green.Ztype // for template instantiation with custom method prefix MethodPrefix() string SetHasMethodPrefix(hmp HasMethodPrefix) // The clue is a 3-character string added // to on-the-wire field name // to salvage the uint -> int fiasco of classic msgpack // implementations. // // The clue and the version together prevent gross // decoding type and version mismatches. // Avoid Knight Capital like meltdowns and never // change a field without bumping the version number. TypeClue() string // 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 { Keyidx string // key variable name Validx string // value variable name Value Elem // value element KeyTyp string KeyDeclTyp string // contains filtered or unexported fields }
Map is a map[string]Elem
func (*Map) Complexity ¶
func (*Map) MethodPrefix ¶
func (c *Map) MethodPrefix() string
func (*Map) SetHasMethodPrefix ¶
func (c *Map) SetHasMethodPrefix(hmp HasMethodPrefix)
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 ¶
type Ptr struct { Value Elem // contains filtered or unexported fields }
func (*Ptr) Complexity ¶
func (*Ptr) MethodPrefix ¶
func (c *Ptr) MethodPrefix() string
func (*Ptr) SetHasMethodPrefix ¶
func (c *Ptr) SetHasMethodPrefix(hmp HasMethodPrefix)
func (*Ptr) SetVarname ¶
func (*Ptr) ZeroLiteral ¶
type Slice ¶
type Slice struct { Index string Els Elem // The type of each element // contains filtered or unexported fields }
func (*Slice) Complexity ¶
func (*Slice) MethodPrefix ¶
func (c *Slice) MethodPrefix() string
func (*Slice) SetHasMethodPrefix ¶
func (c *Slice) SetHasMethodPrefix(hmp HasMethodPrefix)
func (*Slice) SetVarname ¶
func (*Slice) ZeroLiteral ¶
type Struct ¶
type Struct struct { 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) MethodPrefix ¶
func (c *Struct) MethodPrefix() string
func (*Struct) SetHasMethodPrefix ¶
func (c *Struct) SetHasMethodPrefix(hmp HasMethodPrefix)
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. // 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 FieldTagZidClue string }
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.