Documentation
¶
Index ¶
- func IsDangling(e Elem) bool
- func SetSortInterface(sorttype string, sortintf string)
- type Array
- func (c *Array) AddCallback(cb Callback)
- func (c *Array) Alias(typ string)
- func (c *Array) AllocBound() string
- func (a *Array) Comparable() bool
- func (a *Array) Complexity() int
- func (a *Array) Copy() Elem
- func (c *Array) GetCallbacks() []Callback
- func (a *Array) IfZeroExpr() string
- func (c *Array) MaxTotalBytes() string
- func (c *Array) SetAllocBound(s string)
- func (c *Array) SetMaxTotalBytes(s string)
- func (a *Array) SetVarname(s string)
- func (c *Array) SortInterface() string
- func (a *Array) TypeName() string
- func (c *Array) Varname() string
- func (a *Array) ZeroExpr() string
- type BaseElem
- func (c *BaseElem) AddCallback(cb Callback)
- func (s *BaseElem) Alias(typ string)
- func (c *BaseElem) AllocBound() string
- func (s *BaseElem) BaseName() string
- func (s *BaseElem) BaseType() string
- func (s *BaseElem) Comparable() bool
- func (s *BaseElem) Complexity() int
- func (s *BaseElem) Copy() Elem
- func (s *BaseElem) Dangling() bool
- func (s *BaseElem) FromBase() string
- func (c *BaseElem) GetCallbacks() []Callback
- func (s *BaseElem) IfZeroExpr() string
- func (c *BaseElem) MaxTotalBytes() string
- func (s *BaseElem) Needsref(b bool)
- func (s *BaseElem) Resolved() bool
- func (c *BaseElem) SetAllocBound(s string)
- func (c *BaseElem) SetMaxTotalBytes(s string)
- func (s *BaseElem) SetVarname(a string)
- func (s *BaseElem) SortInterface() string
- func (s *BaseElem) ToBase() string
- func (s *BaseElem) TypeName() string
- func (c *BaseElem) Varname() string
- func (s *BaseElem) ZeroExpr() string
- type Callback
- type CallbackType
- type Context
- type Elem
- type Map
- func (c *Map) AddCallback(cb Callback)
- func (c *Map) Alias(typ string)
- func (c *Map) AllocBound() string
- func (m *Map) Comparable() bool
- func (m *Map) Complexity() int
- func (m *Map) Copy() Elem
- func (c *Map) GetCallbacks() []Callback
- func (m *Map) IfZeroExpr() string
- func (c *Map) MaxTotalBytes() string
- func (c *Map) SetAllocBound(s string)
- func (c *Map) SetMaxTotalBytes(s string)
- func (m *Map) SetVarname(s string)
- func (c *Map) SortInterface() string
- func (m *Map) TypeName() string
- func (c *Map) Varname() string
- func (m *Map) ZeroExpr() string
- type Method
- type Primitive
- type Printer
- type Ptr
- func (c *Ptr) AddCallback(cb Callback)
- func (c *Ptr) Alias(typ string)
- func (c *Ptr) AllocBound() string
- func (s *Ptr) Comparable() bool
- func (s *Ptr) Complexity() int
- func (s *Ptr) Copy() Elem
- func (c *Ptr) GetCallbacks() []Callback
- func (s *Ptr) IfZeroExpr() string
- func (c *Ptr) MaxTotalBytes() string
- func (s *Ptr) Needsinit() bool
- func (c *Ptr) SetAllocBound(s string)
- func (c *Ptr) SetMaxTotalBytes(s string)
- func (s *Ptr) SetVarname(a string)
- func (c *Ptr) SortInterface() string
- func (s *Ptr) TypeName() string
- func (c *Ptr) Varname() string
- func (s *Ptr) ZeroExpr() string
- type ShimMode
- type Slice
- func (c *Slice) AddCallback(cb Callback)
- func (c *Slice) Alias(typ string)
- func (c *Slice) AllocBound() string
- func (s *Slice) Comparable() bool
- func (s *Slice) Complexity() int
- func (s *Slice) Copy() Elem
- func (c *Slice) GetCallbacks() []Callback
- func (s *Slice) IfZeroExpr() string
- func (c *Slice) MaxTotalBytes() string
- func (c *Slice) SetAllocBound(s string)
- func (c *Slice) SetMaxTotalBytes(s string)
- func (s *Slice) SetVarname(a string)
- func (c *Slice) SortInterface() string
- func (s *Slice) TypeName() string
- func (c *Slice) Varname() string
- func (s *Slice) ZeroExpr() string
- type Struct
- func (c *Struct) AddCallback(cb Callback)
- func (c *Struct) Alias(typ string)
- func (c *Struct) AllocBound() string
- func (s *Struct) AnyHasTagPart(pname string) bool
- func (s *Struct) Comparable() bool
- func (s *Struct) Complexity() int
- func (s *Struct) Copy() Elem
- func (c *Struct) GetCallbacks() []Callback
- func (s *Struct) HasAnyStructTag() bool
- func (s *Struct) HasUnderscoreStructTag() bool
- func (s *Struct) IfZeroExpr() string
- func (c *Struct) MaxTotalBytes() string
- func (c *Struct) SetAllocBound(s string)
- func (c *Struct) SetMaxTotalBytes(s string)
- func (s *Struct) SetVarname(a string)
- func (c *Struct) SortInterface() string
- func (s *Struct) TypeName() string
- func (s *Struct) UnderscoreStructHasTagPart(pname string) bool
- func (c *Struct) Varname() string
- func (s *Struct) ZeroExpr() string
- type StructField
- type Topics
- type TransformPass
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDangling ¶
func SetSortInterface ¶
Types ¶
type Array ¶
type Array struct { Index string // index variable name Size string // array size SizeHint string // const object referred to by Size Els Elem // child // contains filtered or unexported fields }
func (*Array) AddCallback ¶ added in v1.1.49
func (c *Array) AddCallback(cb Callback)
func (*Array) AllocBound ¶ added in v1.1.17
func (c *Array) AllocBound() string
func (*Array) Comparable ¶ added in v1.1.12
Comparable returns whether this elem's type is comparable.
func (*Array) Complexity ¶
func (*Array) GetCallbacks ¶ added in v1.1.49
func (c *Array) GetCallbacks() []Callback
func (*Array) IfZeroExpr ¶
IfZeroExpr returns the expression to compare to zero/empty.
func (*Array) MaxTotalBytes ¶ added in v1.1.55
func (c *Array) MaxTotalBytes() string
func (*Array) SetAllocBound ¶ added in v1.1.17
func (c *Array) SetAllocBound(s string)
func (*Array) SetMaxTotalBytes ¶ added in v1.1.55
func (c *Array) SetMaxTotalBytes(s string)
func (*Array) SetVarname ¶
func (*Array) SortInterface ¶
func (c *Array) SortInterface() string
type BaseElem ¶
type BaseElem struct { ShimMode ShimMode // Method used to shim ShimToBase string // shim to base type, or empty ShimFromBase string // shim from base type, or empty Value Primitive // Type of element IdentName string // name, for Value == IDENT 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) AddCallback ¶ added in v1.1.49
func (c *BaseElem) AddCallback(cb Callback)
func (*BaseElem) AllocBound ¶ added in v1.1.17
func (c *BaseElem) AllocBound() string
func (*BaseElem) BaseName ¶
BaseName returns the string form of the base type (e.g. Float64, Ident, etc)
func (*BaseElem) Comparable ¶ added in v1.1.12
Comparable returns whether this elem's type is comparable.
func (*BaseElem) Complexity ¶
func (*BaseElem) FromBase ¶
FromBase, used if Convert==true, is used as {{Varname}} = {{FromBase}}(tmp)
func (*BaseElem) GetCallbacks ¶ added in v1.1.49
func (c *BaseElem) GetCallbacks() []Callback
func (*BaseElem) IfZeroExpr ¶
IfZeroExpr returns the expression to compare to zero/empty.
func (*BaseElem) MaxTotalBytes ¶ added in v1.1.55
func (c *BaseElem) MaxTotalBytes() 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) SetAllocBound ¶ added in v1.1.17
func (c *BaseElem) SetAllocBound(s string)
func (*BaseElem) SetMaxTotalBytes ¶ added in v1.1.55
func (c *BaseElem) SetMaxTotalBytes(s string)
func (*BaseElem) SetVarname ¶
func (*BaseElem) SortInterface ¶
SortInterface returns a sort.Interface for sorting a slice of this type.
type Callback ¶ added in v1.1.49
type Callback struct { Fname string CallbackType CallbackType }
Callback represents a function that can is expected to be printed into the generated code. for example, at the end of a successful unmarshalling.
func (Callback) IsUnmarshallCallback ¶ added in v1.1.49
type CallbackType ¶ added in v1.1.49
type CallbackType uint64
const UnmarshalCallBack CallbackType = 1
UnmarshalCallBack represents a type callback that should run over the generated code.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func (*Context) PushString ¶
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 // ZeroExpr returns the expression for the correct zero/empty // value. Can be used for assignment. // Returns "" if zero/empty not supported for this Elem. ZeroExpr() string // IfZeroExpr returns the expression to compare to zero/empty // for this type. It is meant to be used in an if statement // and may include the simple statement form followed by // semicolon and then the expression. // Returns "" if zero/empty not supported for this Elem. IfZeroExpr() string // SortInterface returns the sort.Interface for sorting a // slice of this type. SortInterface() string // Comparable returns whether the type is comparable, along the lines // of the Go spec (https://golang.org/ref/spec#Comparison_operators), // used to determine whether we can compare to a zero value to determine // zeroness. Comparable() bool // SetAllocBound specifies the maximum number of elements to allocate // when decoding this type. Meaningful for slices and maps. // Blank means unspecified bound. "-" means no bound. SetAllocBound(bound string) // AllocBound returns the maximum number of elements to allocate // when decoding this type. Meaningful for slices and maps. AllocBound() string // SetMaxTotalBytes specifies the maximum number of bytes to allocate when // decoding this type. // Blank means unspecified bound. "-" means no bound. SetMaxTotalBytes(bound string) // MaxTotalBytes specifies the maximum number of bytes to allocate when // decoding this type. Meaningful for slices of strings or byteslices. MaxTotalBytes() string // AddCallback adds to the elem a Callback it should call at the end of marshaling AddCallback(Callback) // GetCallbacks fetches all callbacks this Elem stored. GetCallbacks() []Callback // 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 Map ¶
type Map struct { Keyidx string // key variable name Key Elem // type of map key Validx string // value variable name Value Elem // value element // contains filtered or unexported fields }
Map is a map[string]Elem
func (*Map) AddCallback ¶ added in v1.1.49
func (c *Map) AddCallback(cb Callback)
func (*Map) AllocBound ¶ added in v1.1.17
func (c *Map) AllocBound() string
func (*Map) Comparable ¶ added in v1.1.12
Comparable returns whether this elem's type is comparable.
func (*Map) Complexity ¶
func (*Map) GetCallbacks ¶ added in v1.1.49
func (c *Map) GetCallbacks() []Callback
func (*Map) IfZeroExpr ¶
IfZeroExpr returns the expression to compare to zero/empty.
func (*Map) MaxTotalBytes ¶ added in v1.1.55
func (c *Map) MaxTotalBytes() string
func (*Map) SetAllocBound ¶ added in v1.1.17
func (c *Map) SetAllocBound(s string)
func (*Map) SetMaxTotalBytes ¶ added in v1.1.55
func (c *Map) SetMaxTotalBytes(s string)
func (*Map) SetVarname ¶
func (*Map) SortInterface ¶
func (c *Map) SortInterface() string
type Method ¶
type Method uint8
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 Uintptr Byte Int Int8 Int16 Int32 Int64 Bool Intf // interface{} Time // time.Time Ext // extension Error // error Duration // time.Duration 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) AddCallback ¶ added in v1.1.49
func (c *Ptr) AddCallback(cb Callback)
func (*Ptr) AllocBound ¶ added in v1.1.17
func (c *Ptr) AllocBound() string
func (*Ptr) Comparable ¶ added in v1.1.12
Comparable returns whether this elem's type is comparable.
func (*Ptr) Complexity ¶
func (*Ptr) GetCallbacks ¶ added in v1.1.49
func (c *Ptr) GetCallbacks() []Callback
func (*Ptr) IfZeroExpr ¶
IfZeroExpr returns the expression to compare to zero/empty.
func (*Ptr) MaxTotalBytes ¶ added in v1.1.55
func (c *Ptr) MaxTotalBytes() string
func (*Ptr) SetAllocBound ¶ added in v1.1.17
func (c *Ptr) SetAllocBound(s string)
func (*Ptr) SetMaxTotalBytes ¶ added in v1.1.55
func (c *Ptr) SetMaxTotalBytes(s string)
func (*Ptr) SetVarname ¶
func (*Ptr) SortInterface ¶
func (c *Ptr) SortInterface() string
type Slice ¶
type Slice struct { Index string Els Elem // The type of each element // contains filtered or unexported fields }
func (*Slice) AddCallback ¶ added in v1.1.49
func (c *Slice) AddCallback(cb Callback)
func (*Slice) AllocBound ¶ added in v1.1.17
func (c *Slice) AllocBound() string
func (*Slice) Comparable ¶ added in v1.1.12
Comparable returns whether this elem's type is comparable.
func (*Slice) Complexity ¶
func (*Slice) GetCallbacks ¶ added in v1.1.49
func (c *Slice) GetCallbacks() []Callback
func (*Slice) IfZeroExpr ¶
IfZeroExpr returns the expression to compare to zero/empty.
func (*Slice) MaxTotalBytes ¶ added in v1.1.55
func (c *Slice) MaxTotalBytes() string
func (*Slice) SetAllocBound ¶ added in v1.1.17
func (c *Slice) SetAllocBound(s string)
func (*Slice) SetMaxTotalBytes ¶ added in v1.1.55
func (c *Slice) SetMaxTotalBytes(s string)
func (*Slice) SetVarname ¶
func (*Slice) SortInterface ¶
func (c *Slice) SortInterface() string
type Struct ¶
type Struct struct { Fields []StructField // field list AsTuple bool // write as an array instead of a map // contains filtered or unexported fields }
func (*Struct) AddCallback ¶ added in v1.1.49
func (c *Struct) AddCallback(cb Callback)
func (*Struct) AllocBound ¶ added in v1.1.17
func (c *Struct) AllocBound() string
func (*Struct) AnyHasTagPart ¶
AnyHasTagPart returns true if HasTagPart(p) is true for any field.
func (*Struct) Comparable ¶ added in v1.1.12
Comparable returns whether this elem's type is comparable.
func (*Struct) Complexity ¶
func (*Struct) GetCallbacks ¶ added in v1.1.49
func (c *Struct) GetCallbacks() []Callback
func (*Struct) HasAnyStructTag ¶ added in v1.1.34
HasAnyStructTag returns true if any of the fields in the struct have a codec: tag. This is used to determine which structs we can skip because they are not intended for encoding/decoding.
func (*Struct) HasUnderscoreStructTag ¶ added in v1.1.18
HasUnderscoreStructTag returns true if there is a field named _struct with a codec: tag. This is used to ensure developers don't forget to annotate their structs with omitempty (unless explicitly opted out).
func (*Struct) IfZeroExpr ¶
IfZeroExpr returns the expression to compare to zero/empty.
func (*Struct) MaxTotalBytes ¶ added in v1.1.55
func (c *Struct) MaxTotalBytes() string
func (*Struct) SetAllocBound ¶ added in v1.1.17
func (c *Struct) SetAllocBound(s string)
func (*Struct) SetMaxTotalBytes ¶ added in v1.1.55
func (c *Struct) SetMaxTotalBytes(s string)
func (*Struct) SetVarname ¶
func (*Struct) SortInterface ¶
func (c *Struct) SortInterface() string
func (*Struct) UnderscoreStructHasTagPart ¶
UnderscoreStructHasTagPart returns true if HasTagPart(p) is true for the _struct field.
type StructField ¶
type StructField struct { FieldTag string // the string inside the `codec:""` tag up to the first comma FieldTagParts []string // the string inside the `codec:""` tag split by commas RawTag string // the full struct tag HasCodecTag bool // has a `codec:` tag FieldName string // the name of the struct field FieldElem Elem // the field type FieldPath []string // set of embedded struct names for accessing FieldName }
func (*StructField) HasTagPart ¶
func (sf *StructField) HasTagPart(pname string) bool
HasTagPart returns true if the specified tag part (option) is present.
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.