gen

package
v0.0.0-...-512e969 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2015 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteEncodeDecode

func WriteEncodeDecode(w io.Writer, p *Ptr, buf *bytes.Buffer) error

WriteEncodeDecode writes the EncodeMsg, EncodeTo, DecodeMsg, and DecodeFrom methods, using buf as scratch space.

func WriteEncodeDecodeTests

func WriteEncodeDecodeTests(w io.Writer, s *Struct, buf *bytes.Buffer) error

WriteEncodeDecodeTests writes tests for s.EncodeMsg and s.DecodeMsg, using buf as scratch space

func WriteMarshalUnmarshal

func WriteMarshalUnmarshal(w io.Writer, p *Ptr, buf *bytes.Buffer) error

WriteMarhsalUnmarshal writes the MarshalMsg, UnmarshalMsg, AppendMsg, and Maxsize methods using buf as scratch space.

func WriteMarshalUnmarshalTests

func WriteMarshalUnmarshalTests(w io.Writer, s *Struct, buf *bytes.Buffer) error

WriteMarshalUnmarshalTests writes tests for s.MarshalMsg and s.UnmarshalMsg, using buf as scratch space

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) Array

func (a *Array) Array() *Array

func (*Array) Base

func (a *Array) Base() *BaseElem

func (*Array) Map

func (a *Array) Map() *Map

func (*Array) Ptr

func (a *Array) Ptr() *Ptr

func (*Array) SetVarname

func (a *Array) SetVarname(s string)

func (*Array) Slice

func (a *Array) Slice() *Slice

func (*Array) String

func (a *Array) String() string

func (*Array) Struct

func (a *Array) Struct() *Struct

func (*Array) Type

func (a *Array) Type() ElemType

func (*Array) TypeName

func (a *Array) TypeName() string

func (*Array) Varname

func (a *Array) Varname() string

type Base

type Base int

Base is one of the base types

const (
	Invalid Base = 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.

func (Base) String

func (k Base) String() string

type BaseElem

type BaseElem struct {
	Value        Base
	Ident        string // IDENT name if unresolved
	Convert      bool   // should we do an explicit conversion?
	ShimToBase   string // shim to base type
	ShimFromBase string // shim from base type
	// contains filtered or unexported fields
}

func (*BaseElem) Array

func (s *BaseElem) Array() *Array

func (*BaseElem) Base

func (s *BaseElem) Base() *BaseElem

func (*BaseElem) BaseName

func (s *BaseElem) BaseName() string

BaseName returns the string form of the base type (e.g. Float64, Ident, etc)

func (*BaseElem) BaseType

func (s *BaseElem) BaseType() string

func (*BaseElem) FromBase

func (s *BaseElem) FromBase() string

FromBase, used if Convert==true, is used as {{Varname}} = {{FromBase}}(tmp)

func (*BaseElem) IsExt

func (s *BaseElem) IsExt() bool

is this an extension?

func (*BaseElem) IsIdent

func (s *BaseElem) IsIdent() bool

is this an external identity?

func (*BaseElem) IsIntf

func (s *BaseElem) IsIntf() bool

is this an interface{} ?

func (*BaseElem) Map

func (s *BaseElem) Map() *Map

func (*BaseElem) Ptr

func (s *BaseElem) Ptr() *Ptr

func (*BaseElem) SetVarname

func (s *BaseElem) SetVarname(a string)

func (*BaseElem) Slice

func (s *BaseElem) Slice() *Slice

func (*BaseElem) String

func (s *BaseElem) String() string

func (*BaseElem) Struct

func (s *BaseElem) Struct() *Struct

func (*BaseElem) ToBase

func (s *BaseElem) ToBase() string

ToBase, used if Convert==true, is used as tmp = {{ToBase}}({{Varname}})

func (*BaseElem) Type

func (s *BaseElem) Type() ElemType

func (*BaseElem) TypeName

func (s *BaseElem) TypeName() string

TypeName returns the syntactically correct Go type name for the base element.

func (*BaseElem) Varname

func (s *BaseElem) Varname() string

type Elem

type Elem interface {
	Type() ElemType // Returns element type

	// We need the following
	// because objects cannot
	// be type-asserted in templates.
	// Yes, this is gross.
	Ptr() *Ptr
	Slice() *Slice
	Struct() *Struct
	Base() *BaseElem
	Map() *Map
	Array() *Array

	// SetVarname sets this nodes
	// variable name and recursively
	// sets the names of all its children
	SetVarname(s string)

	// Varname is the variable
	// name of the node
	Varname() string

	// TypeName is the canonical
	// go type name of the node
	// e.g. "string", "int", "map[string]float64"
	TypeName() string

	// fmt.Stringer for debugging
	String() string
}

Elem is Base, Slice, Stuct, Map, or Ptr

type ElemType

type ElemType int

ElemType is one of Ptr, Map Slice, Struct, or Base

const (
	InvalidType ElemType = iota
	PtrType              // pointer-to-object
	SliceType            // slice-of-object
	StructType           // struct-of-objects
	BaseType             // object
	MapType              // map[string]object
	ArrayType            // [Size]object
)

type Map

type Map struct {
	Keyidx string // key variable name
	Validx string // value variable name
	Value  Elem
	// contains filtered or unexported fields
}

Map is a map[string]Elem

func (*Map) Array

func (m *Map) Array() *Array

func (*Map) Base

func (m *Map) Base() *BaseElem

func (*Map) Map

func (m *Map) Map() *Map

func (*Map) Ptr

func (m *Map) Ptr() *Ptr

func (*Map) SetVarname

func (m *Map) SetVarname(s string)

func (*Map) Slice

func (m *Map) Slice() *Slice

func (*Map) String

func (m *Map) String() string

func (*Map) Struct

func (m *Map) Struct() *Struct

func (*Map) Type

func (m *Map) Type() ElemType

func (*Map) TypeName

func (m *Map) TypeName() string

func (*Map) Varname

func (m *Map) Varname() string

type Ptr

type Ptr struct {
	Value Elem
	// contains filtered or unexported fields
}

func (*Ptr) Array

func (s *Ptr) Array() *Array

func (*Ptr) Base

func (s *Ptr) Base() *BaseElem

func (*Ptr) Map

func (s *Ptr) Map() *Map

func (*Ptr) Ptr

func (s *Ptr) Ptr() *Ptr

func (*Ptr) SetVarname

func (s *Ptr) SetVarname(a string)

func (*Ptr) Slice

func (s *Ptr) Slice() *Slice

func (*Ptr) String

func (s *Ptr) String() string

func (*Ptr) Struct

func (s *Ptr) Struct() *Struct

func (*Ptr) Type

func (s *Ptr) Type() ElemType

func (*Ptr) TypeName

func (s *Ptr) TypeName() string

func (*Ptr) Varname

func (s *Ptr) Varname() string

type Slice

type Slice struct {
	Index string
	Els   Elem // The type of each element
	// contains filtered or unexported fields
}

func (*Slice) Array

func (s *Slice) Array() *Array

func (*Slice) Base

func (s *Slice) Base() *BaseElem

func (*Slice) Map

func (s *Slice) Map() *Map

func (*Slice) Ptr

func (s *Slice) Ptr() *Ptr

func (*Slice) SetVarname

func (s *Slice) SetVarname(a string)

func (*Slice) Slice

func (s *Slice) Slice() *Slice

func (*Slice) String

func (s *Slice) String() string

func (*Slice) Struct

func (s *Slice) Struct() *Struct

func (*Slice) Type

func (s *Slice) Type() ElemType

func (*Slice) TypeName

func (s *Slice) TypeName() string

func (*Slice) Varname

func (s *Slice) Varname() string

type Struct

type Struct struct {
	Name    string        // struct type name
	Fields  []StructField // field list
	AsTuple bool          // write as an array instead of a map
}

func (*Struct) Array

func (s *Struct) Array() *Array

func (*Struct) Base

func (s *Struct) Base() *BaseElem

func (*Struct) Map

func (s *Struct) Map() *Map

func (*Struct) Ptr

func (s *Struct) Ptr() *Ptr

func (*Struct) SetVarname

func (s *Struct) SetVarname(a string)

func (*Struct) Slice

func (s *Struct) Slice() *Slice

func (*Struct) String

func (s *Struct) String() string

func (*Struct) Struct

func (s *Struct) Struct() *Struct

func (*Struct) Type

func (s *Struct) Type() ElemType

func (*Struct) TypeName

func (s *Struct) TypeName() string

func (*Struct) Varname

func (s *Struct) Varname() string

type StructField

type StructField struct {
	FieldTag  string
	FieldName string
	FieldElem Elem
}

func (StructField) String

func (s StructField) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL