Documentation ¶
Index ¶
- func IsPrintable(e Elem) bool
- type Array
- func (c *Array) Alias(typ string)
- func (c *Array) AllowNil() bool
- func (a *Array) Complexity() int
- func (a *Array) Copy() Elem
- func (a *Array) IfZeroExpr() string
- func (a *Array) SetVarname(s string)
- func (a *Array) TypeName() string
- func (c *Array) Varname() string
- func (a *Array) ZeroExpr() string
- type BaseElem
- func (s *BaseElem) Alias(typ string)
- func (c *BaseElem) AllowNil() bool
- 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) IfZeroExpr() string
- func (s *BaseElem) Needsref(b bool)
- func (s *BaseElem) Printable() bool
- func (s *BaseElem) Resolved() bool
- func (s *BaseElem) SetVarname(a string)
- func (s *BaseElem) ToBase() string
- func (s *BaseElem) TypeName() string
- func (c *BaseElem) Varname() string
- func (s *BaseElem) ZeroExpr() string
- type Context
- type Elem
- type Map
- type Method
- type Primitive
- type Printer
- type Ptr
- func (c *Ptr) Alias(typ string)
- func (c *Ptr) AllowNil() bool
- func (s *Ptr) Complexity() int
- func (s *Ptr) Copy() Elem
- func (s *Ptr) IfZeroExpr() string
- func (s *Ptr) Needsinit() bool
- func (s *Ptr) SetVarname(a string)
- func (s *Ptr) TypeName() string
- func (c *Ptr) Varname() string
- func (s *Ptr) ZeroExpr() string
- type ShimMode
- type Slice
- func (c *Slice) Alias(typ string)
- func (s *Slice) AllowNil() bool
- func (s *Slice) Complexity() int
- func (s *Slice) Copy() Elem
- func (s *Slice) IfZeroExpr() string
- func (s *Slice) SetVarname(a string)
- func (s *Slice) TypeName() string
- func (c *Slice) Varname() string
- func (s *Slice) ZeroExpr() string
- type Struct
- func (c *Struct) Alias(typ string)
- func (c *Struct) AllowNil() bool
- func (s *Struct) AnyHasTagPart(pname string) bool
- func (s *Struct) Complexity() int
- func (s *Struct) Copy() Elem
- func (s *Struct) IfZeroExpr() string
- func (s *Struct) SetVarname(a string)
- func (s *Struct) TypeName() string
- func (c *Struct) Varname() string
- func (s *Struct) ZeroExpr() string
- type StructField
- type TransformPass
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPrintable ¶
Types ¶
type Array ¶
type Array struct { Index string // index variable name Size string // array size Els Elem // child // contains filtered or unexported fields }
func (*Array) Complexity ¶
func (*Array) IfZeroExpr ¶ added in v1.1.1
IfZeroExpr unsupported
func (*Array) SetVarname ¶
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 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) IfZeroExpr ¶ added in v1.1.1
IfZeroExpr returns the expression to compare to zero/empty.
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) SetVarname ¶
type Context ¶ added in v1.1.0
type Context struct {
// contains filtered or unexported fields
}
func (*Context) PushString ¶ added in v1.1.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 // 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 // AllowNil will return true for types that can be nil but doesn't automatically check. // This is true for slices and maps. AllowNil() bool // 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 // 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 { KeyTyp string Keyidx string // key variable name Validx string // value variable name Value Elem // value element // contains filtered or unexported fields }
Map is a map[string]Elem
func (*Map) Complexity ¶
func (*Map) IfZeroExpr ¶ added in v1.1.1
IfZeroExpr returns the expression to compare to zero/empty.
func (*Map) SetVarname ¶
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 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 (*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) IfZeroExpr ¶ added in v1.1.1
IfZeroExpr returns the expression to compare to zero/empty.
func (*Ptr) SetVarname ¶
type Slice ¶
type Slice struct { Index string Els Elem // The type of each element // contains filtered or unexported fields }
func (*Slice) Complexity ¶
func (*Slice) IfZeroExpr ¶ added in v1.1.1
IfZeroExpr returns the expression to compare to zero/empty.
func (*Slice) SetVarname ¶
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) AnyHasTagPart ¶ added in v1.1.1
AnyHasTagPart returns true if HasTagPart(p) is true for any field.
func (*Struct) Complexity ¶
func (*Struct) IfZeroExpr ¶ added in v1.1.1
IfZeroExpr returns the expression to compare to zero/empty.
func (*Struct) SetVarname ¶
type StructField ¶
type StructField struct { FieldTag string // the string inside the `msg:""` tag up to the first comma FieldTagParts []string // the string inside the `msg:""` tag split by commas RawTag string // the full struct tag FieldName string // the name of the struct field FieldElem Elem // the field type }
func (*StructField) HasTagPart ¶ added in v1.1.1
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.