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 green.Ztype)
- func (s *Array) IsInInterfaceSlice() bool
- func (s *Array) IsInterface() bool
- func (s *Array) SetIsInInterfaceSlice()
- func (a *Array) SetVarname(s string)
- func (a *Array) TypeClue() 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 green.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) TypeClue() string
- func (s *BaseElem) TypeName() string
- func (s *BaseElem) ZeroLiteral(v string) string
- type Common
- type Elem
- type HasMethodPrefix
- type Map
- func (m *Map) Complexity() int
- func (m *Map) Copy() Elem
- func (m *Map) GetZtype() (r green.Ztype)
- func (s *Map) IsInInterfaceSlice() bool
- func (s *Map) IsInterface() bool
- func (m *Map) SetIsInInterfaceSlice()
- func (m *Map) SetVarname(s string)
- func (m *Map) TypeClue() 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 green.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) TypeClue() 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 green.Ztype)
- func (s *Slice) IsInInterfaceSlice() bool
- func (s *Slice) IsInterface() bool
- func (s *Slice) SetIsInInterfaceSlice()
- func (s *Slice) SetVarname(a string)
- func (a *Slice) TypeClue() 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 green.Ztype)
- func (s *Struct) IsInInterfaceSlice() bool
- func (s *Struct) IsInterface() bool
- func (s *Struct) SetIsInInterfaceSlice()
- func (s *Struct) SetVarname(a string)
- func (s *Struct) TypeClue() 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 CryptoRandInt64 ¶ added in v0.360.0
func CryptoRandInt64() int64
Use crypto/rand to get an random int64.
func IsEmptyBool ¶ added in v0.120.0
func IsEmptyNumber ¶ added in v0.120.0
func IsEmptyTime ¶ added in v0.120.0
func IsNilInterface ¶ added in v0.400.0
func IsPrintable ¶
func MathRandInt64 ¶ added in v0.360.0
func MathRandInt64() int64
func SeedOurMathRandSrc ¶ added in v0.360.0
func SeedOurMathRandSrc(seed int64)
func SetFilename ¶ added in v0.360.0
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 ¶ added in v0.400.0
func (*Array) IsInterface ¶ added in v0.400.0
func (*Array) SetIsInInterfaceSlice ¶ added in v0.400.0
func (s *Array) SetIsInInterfaceSlice()
func (*Array) SetVarname ¶
func (*Array) ZeroLiteral ¶ added in v0.120.0
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 ¶ added in v0.400.0
func (*BaseElem) IsInterface ¶ added in v0.400.0
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 ¶ added in v0.400.0
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 ¶ added in v0.120.0
type Common ¶ added in v0.410.0
type Common struct {
// contains filtered or unexported fields
}
Common data/methods for every Elem
func (*Common) MethodPrefix ¶ added in v0.410.0
func (*Common) SetHasMethodPrefix ¶ added in v0.410.0
func (c *Common) SetHasMethodPrefix(hmp HasMethodPrefix)
func (*Common) SetVarname ¶ added in v0.410.0
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)
IsInterface() bool
IsInInterfaceSlice() bool
SetIsInInterfaceSlice()
SetZid(zid int64)
GetZid() int64
// 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 ¶ added in v0.310.0
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 ¶ added in v0.400.0
func (*Map) IsInterface ¶ added in v0.400.0
func (*Map) SetIsInInterfaceSlice ¶ added in v0.400.0
func (m *Map) SetIsInInterfaceSlice()
func (*Map) SetVarname ¶
func (*Map) ZeroLiteral ¶ added in v0.120.0
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 Duration // time.Duration )
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 ¶ added in v0.400.0
func (*Ptr) IsInterface ¶ added in v0.400.0
func (*Ptr) SetIsInInterfaceSlice ¶ added in v0.400.0
func (s *Ptr) SetIsInInterfaceSlice()
func (*Ptr) SetVarname ¶
func (*Ptr) ZeroLiteral ¶ added in v0.120.0
type Slice ¶
func (*Slice) Complexity ¶
func (*Slice) IsInInterfaceSlice ¶ added in v0.400.0
func (*Slice) IsInterface ¶ added in v0.400.0
func (*Slice) SetIsInInterfaceSlice ¶ added in v0.400.0
func (s *Slice) SetIsInInterfaceSlice()
func (*Slice) SetVarname ¶
func (*Slice) ZeroLiteral ¶ added in v0.120.0
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 ¶ added in v0.400.0
func (*Struct) IsInterface ¶ added in v0.400.0
func (*Struct) SetIsInInterfaceSlice ¶ added in v0.400.0
func (s *Struct) SetIsInInterfaceSlice()
func (*Struct) SetVarname ¶
func (*Struct) ZeroLiteral ¶ added in v0.120.0
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?
// for dedup
IsPointer bool // the field is a pointer
// 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
}
func (*StructField) IsInterface ¶ added in v0.400.0
func (s *StructField) IsInterface() 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.