tlc

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2017 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateGoCode

func GenerateGoCode(sch *tlschema.Schema, options Options) string

func IDConstName

func IDConstName(comb *tlschema.Comb) string

Types

type ArgCondType

type ArgCondType int
const (
	NoCond ArgCondType = iota
	PureFlag
	FieldWithFlag
)

type ArgRepr

type ArgRepr struct {
	Arg        tlschema.Arg
	TLName     string
	GoName     string
	TypeRepr   Repr
	TLTypeName string

	CondType ArgCondType
	CondArg  *ArgRepr
	CondBit  int

	CondGetterGoName string
	CondSetterGoName string
}

func (*ArgRepr) HasField

func (ar *ArgRepr) HasField() bool

func (*ArgRepr) IsCond

func (ar *ArgRepr) IsCond() bool

type BigIntRepr

type BigIntRepr struct {
}

func (*BigIntRepr) AppendGoDefs

func (r *BigIntRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*BigIntRepr) AppendReadStmt

func (r *BigIntRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*BigIntRepr) AppendSwitchCase

func (r *BigIntRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*BigIntRepr) AppendWriteStmt

func (r *BigIntRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*BigIntRepr) GoImports

func (r *BigIntRepr) GoImports() []string

func (*BigIntRepr) GoType

func (r *BigIntRepr) GoType() string

func (*BigIntRepr) InternalTypeID

func (r *BigIntRepr) InternalTypeID() string

func (*BigIntRepr) Resolve

func (r *BigIntRepr) Resolve(resolver Resolver) error

func (*BigIntRepr) Specialize

func (r *BigIntRepr) Specialize(typ tlschema.TypeExpr) Repr

type BoolRepr

type BoolRepr struct {
	// contains filtered or unexported fields
}

func (*BoolRepr) AppendGoDefs

func (r *BoolRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*BoolRepr) AppendReadStmt

func (r *BoolRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*BoolRepr) AppendSwitchCase

func (r *BoolRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*BoolRepr) AppendWriteStmt

func (r *BoolRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*BoolRepr) GoImports

func (r *BoolRepr) GoImports() []string

func (*BoolRepr) GoType

func (r *BoolRepr) GoType() string

func (*BoolRepr) InternalTypeID

func (r *BoolRepr) InternalTypeID() string

func (*BoolRepr) Resolve

func (r *BoolRepr) Resolve(resolver Resolver) error

func (*BoolRepr) Specialize

func (r *BoolRepr) Specialize(typ tlschema.TypeExpr) Repr

type BoxedRepr

type BoxedRepr struct {
	Comb     *tlschema.Comb
	ItemRepr Repr
}

func (*BoxedRepr) AppendGoDefs

func (r *BoxedRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*BoxedRepr) AppendReadStmt

func (r *BoxedRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*BoxedRepr) AppendWriteStmt

func (r *BoxedRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*BoxedRepr) GoImports

func (r *BoxedRepr) GoImports() []string

func (*BoxedRepr) GoType

func (r *BoxedRepr) GoType() string

func (*BoxedRepr) InternalTypeID

func (r *BoxedRepr) InternalTypeID() string

func (*BoxedRepr) Resolve

func (r *BoxedRepr) Resolve(resolver Resolver) error

type BytesRepr

type BytesRepr struct {
}

func (*BytesRepr) AppendGoDefs

func (r *BytesRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*BytesRepr) AppendReadStmt

func (r *BytesRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*BytesRepr) AppendSwitchCase

func (r *BytesRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*BytesRepr) AppendWriteStmt

func (r *BytesRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*BytesRepr) GoImports

func (r *BytesRepr) GoImports() []string

func (*BytesRepr) GoType

func (r *BytesRepr) GoType() string

func (*BytesRepr) InternalTypeID

func (r *BytesRepr) InternalTypeID() string

func (*BytesRepr) Resolve

func (r *BytesRepr) Resolve(resolver Resolver) error

func (*BytesRepr) Specialize

func (r *BytesRepr) Specialize(typ tlschema.TypeExpr) Repr

type CodeGenOptions

type CodeGenOptions struct {
	SkipUtil     bool
	SkipSwitch   bool
	SkipComments bool
}

type Contributor

type Contributor interface {
	InternalTypeID() string
	Resolve(resolver Resolver) error

	AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)
	GoImports() []string
}

type DoubleRepr

type DoubleRepr struct {
}

func (*DoubleRepr) AppendGoDefs

func (r *DoubleRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*DoubleRepr) AppendReadStmt

func (r *DoubleRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*DoubleRepr) AppendSwitchCase

func (r *DoubleRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*DoubleRepr) AppendWriteStmt

func (r *DoubleRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*DoubleRepr) GoImports

func (r *DoubleRepr) GoImports() []string

func (*DoubleRepr) GoType

func (r *DoubleRepr) GoType() string

func (*DoubleRepr) InternalTypeID

func (r *DoubleRepr) InternalTypeID() string

func (*DoubleRepr) Resolve

func (r *DoubleRepr) Resolve(resolver Resolver) error

func (*DoubleRepr) Specialize

func (r *DoubleRepr) Specialize(typ tlschema.TypeExpr) Repr

type GenericRepr

type GenericRepr interface {
	Contributor
	Specialize(typ tlschema.TypeExpr) Repr
	AppendSwitchCase(buf *bytes.Buffer, indent string)
}

type GenericVectorRepr

type GenericVectorRepr struct {
	// contains filtered or unexported fields
}

func (*GenericVectorRepr) AppendGoDefs

func (r *GenericVectorRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*GenericVectorRepr) AppendSwitchCase

func (r *GenericVectorRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*GenericVectorRepr) GoImports

func (r *GenericVectorRepr) GoImports() []string

func (*GenericVectorRepr) InternalTypeID

func (r *GenericVectorRepr) InternalTypeID() string

func (*GenericVectorRepr) Resolve

func (r *GenericVectorRepr) Resolve(resolver Resolver) error

func (*GenericVectorRepr) Specialize

func (r *GenericVectorRepr) Specialize(typ tlschema.TypeExpr) Repr

type Int128Repr

type Int128Repr struct {
}

func (*Int128Repr) AppendGoDefs

func (r *Int128Repr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*Int128Repr) AppendReadStmt

func (r *Int128Repr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*Int128Repr) AppendSwitchCase

func (r *Int128Repr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*Int128Repr) AppendWriteStmt

func (r *Int128Repr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*Int128Repr) GoImports

func (r *Int128Repr) GoImports() []string

func (*Int128Repr) GoType

func (r *Int128Repr) GoType() string

func (*Int128Repr) InternalTypeID

func (r *Int128Repr) InternalTypeID() string

func (*Int128Repr) Resolve

func (r *Int128Repr) Resolve(resolver Resolver) error

func (*Int128Repr) Specialize

func (r *Int128Repr) Specialize(typ tlschema.TypeExpr) Repr

type Int256Repr

type Int256Repr struct {
}

func (*Int256Repr) AppendGoDefs

func (r *Int256Repr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*Int256Repr) AppendReadStmt

func (r *Int256Repr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*Int256Repr) AppendSwitchCase

func (r *Int256Repr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*Int256Repr) AppendWriteStmt

func (r *Int256Repr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*Int256Repr) GoImports

func (r *Int256Repr) GoImports() []string

func (*Int256Repr) GoType

func (r *Int256Repr) GoType() string

func (*Int256Repr) InternalTypeID

func (r *Int256Repr) InternalTypeID() string

func (*Int256Repr) Resolve

func (r *Int256Repr) Resolve(resolver Resolver) error

func (*Int256Repr) Specialize

func (r *Int256Repr) Specialize(typ tlschema.TypeExpr) Repr

type IntRepr

type IntRepr struct {
}

func (*IntRepr) AppendGoDefs

func (r *IntRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*IntRepr) AppendReadStmt

func (r *IntRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*IntRepr) AppendSwitchCase

func (r *IntRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*IntRepr) AppendWriteStmt

func (r *IntRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*IntRepr) GoImports

func (r *IntRepr) GoImports() []string

func (*IntRepr) GoType

func (r *IntRepr) GoType() string

func (*IntRepr) InternalTypeID

func (r *IntRepr) InternalTypeID() string

func (*IntRepr) Resolve

func (r *IntRepr) Resolve(resolver Resolver) error

func (*IntRepr) Specialize

func (r *IntRepr) Specialize(typ tlschema.TypeExpr) Repr

type LongRepr

type LongRepr struct {
}

func (*LongRepr) AppendGoDefs

func (r *LongRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*LongRepr) AppendReadStmt

func (r *LongRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*LongRepr) AppendSwitchCase

func (r *LongRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*LongRepr) AppendWriteStmt

func (r *LongRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*LongRepr) GoImports

func (r *LongRepr) GoImports() []string

func (*LongRepr) GoType

func (r *LongRepr) GoType() string

func (*LongRepr) InternalTypeID

func (r *LongRepr) InternalTypeID() string

func (*LongRepr) Resolve

func (r *LongRepr) Resolve(resolver Resolver) error

func (*LongRepr) Specialize

func (r *LongRepr) Specialize(typ tlschema.TypeExpr) Repr

type MultiCtorRepr

type MultiCtorRepr struct {
	TLName           string
	GoName           string
	GoMarkerFuncName string
	Structs          []*StructRepr
}

func (*MultiCtorRepr) AppendGoDefs

func (r *MultiCtorRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*MultiCtorRepr) AppendReadStmt

func (r *MultiCtorRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*MultiCtorRepr) AppendSwitchCase

func (r *MultiCtorRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*MultiCtorRepr) AppendWriteStmt

func (r *MultiCtorRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*MultiCtorRepr) GoImports

func (r *MultiCtorRepr) GoImports() []string

func (*MultiCtorRepr) GoType

func (r *MultiCtorRepr) GoType() string

func (*MultiCtorRepr) InternalTypeID

func (r *MultiCtorRepr) InternalTypeID() string

func (*MultiCtorRepr) Resolve

func (r *MultiCtorRepr) Resolve(resolver Resolver) error

func (*MultiCtorRepr) Specialize

func (r *MultiCtorRepr) Specialize(typ tlschema.TypeExpr) Repr

type NatRepr

type NatRepr struct {
}

func (*NatRepr) AppendGoDefs

func (r *NatRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*NatRepr) AppendReadStmt

func (r *NatRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*NatRepr) AppendSwitchCase

func (r *NatRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*NatRepr) AppendWriteStmt

func (r *NatRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*NatRepr) GoImports

func (r *NatRepr) GoImports() []string

func (*NatRepr) GoType

func (r *NatRepr) GoType() string

func (*NatRepr) InternalTypeID

func (r *NatRepr) InternalTypeID() string

func (*NatRepr) Resolve

func (r *NatRepr) Resolve(resolver Resolver) error

func (*NatRepr) Specialize

func (r *NatRepr) Specialize(typ tlschema.TypeExpr) Repr

type ObjectRepr

type ObjectRepr struct {
}

func (*ObjectRepr) AppendGoDefs

func (r *ObjectRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*ObjectRepr) AppendReadStmt

func (r *ObjectRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*ObjectRepr) AppendSwitchCase

func (r *ObjectRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*ObjectRepr) AppendWriteStmt

func (r *ObjectRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*ObjectRepr) GoImports

func (r *ObjectRepr) GoImports() []string

func (*ObjectRepr) GoType

func (r *ObjectRepr) GoType() string

func (*ObjectRepr) InternalTypeID

func (r *ObjectRepr) InternalTypeID() string

func (*ObjectRepr) Resolve

func (r *ObjectRepr) Resolve(resolver Resolver) error

func (*ObjectRepr) Specialize

func (r *ObjectRepr) Specialize(typ tlschema.TypeExpr) Repr

type Options

type Options struct {
	PackageName string
	SkipPrelude bool
}

type Repr

type Repr interface {
	Contributor
	AppendReadStmt(buf *bytes.Buffer, indent, dst string)
	AppendWriteStmt(buf *bytes.Buffer, indent, src string)
	GoType() string
}

type ReprMapper

type ReprMapper struct {
	// contains filtered or unexported fields
}

func NewReprMapper

func NewReprMapper(sch *tlschema.Schema) *ReprMapper

func (*ReprMapper) AddContributor

func (rm *ReprMapper) AddContributor(c Contributor) Contributor

func (*ReprMapper) AddSpecialType

func (rm *ReprMapper) AddSpecialType(name, def string, gr GenericRepr, internal bool)

func (*ReprMapper) AddType

func (rm *ReprMapper) AddType(typ *tlschema.Type)

func (*ReprMapper) AllTypeIDs

func (rm *ReprMapper) AllTypeIDs() []string

func (*ReprMapper) AppendGoDefs

func (rm *ReprMapper) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*ReprMapper) Finalize

func (rm *ReprMapper) Finalize()

func (*ReprMapper) FindComb

func (rm *ReprMapper) FindComb(name string) *tlschema.Comb

func (*ReprMapper) GoImports

func (rm *ReprMapper) GoImports() []string

func (*ReprMapper) ResolveTypeExpr

func (rm *ReprMapper) ResolveTypeExpr(expr tlschema.TypeExpr, context string) Repr

func (*ReprMapper) Specialize

func (rm *ReprMapper) Specialize(gr GenericRepr, typeExpr tlschema.TypeExpr) Repr

type Resolver

type Resolver interface {
	ResolveTypeExpr(expr tlschema.TypeExpr, context string) Repr
	AddContributor(c Contributor) Contributor
	FindComb(name string) *tlschema.Comb
}

type StringRepr

type StringRepr struct {
}

func (*StringRepr) AppendGoDefs

func (r *StringRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*StringRepr) AppendReadStmt

func (r *StringRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*StringRepr) AppendSwitchCase

func (r *StringRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*StringRepr) AppendWriteStmt

func (r *StringRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*StringRepr) GoImports

func (r *StringRepr) GoImports() []string

func (*StringRepr) GoType

func (r *StringRepr) GoType() string

func (*StringRepr) InternalTypeID

func (r *StringRepr) InternalTypeID() string

func (*StringRepr) Resolve

func (r *StringRepr) Resolve(resolver Resolver) error

func (*StringRepr) Specialize

func (r *StringRepr) Specialize(typ tlschema.TypeExpr) Repr

type StructRepr

type StructRepr struct {
	TLName string
	GoName string
	Ctor   *tlschema.Comb

	GoMarkerFuncName string

	ArgReprs []*ArgRepr
}

func (*StructRepr) AppendGoDefs

func (r *StructRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*StructRepr) AppendReadStmt

func (r *StructRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*StructRepr) AppendSwitchCase

func (r *StructRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*StructRepr) AppendWriteStmt

func (r *StructRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*StructRepr) GoImports

func (r *StructRepr) GoImports() []string

func (*StructRepr) GoType

func (r *StructRepr) GoType() string

func (*StructRepr) InternalTypeID

func (r *StructRepr) InternalTypeID() string

func (*StructRepr) Resolve

func (r *StructRepr) Resolve(resolver Resolver) error

func (*StructRepr) Specialize

func (r *StructRepr) Specialize(typ tlschema.TypeExpr) Repr

type TrueRepr

type TrueRepr struct {
	// contains filtered or unexported fields
}

func (*TrueRepr) AppendGoDefs

func (r *TrueRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*TrueRepr) AppendReadStmt

func (r *TrueRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*TrueRepr) AppendSwitchCase

func (r *TrueRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*TrueRepr) AppendWriteStmt

func (r *TrueRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*TrueRepr) GoImports

func (r *TrueRepr) GoImports() []string

func (*TrueRepr) GoType

func (r *TrueRepr) GoType() string

func (*TrueRepr) InternalTypeID

func (r *TrueRepr) InternalTypeID() string

func (*TrueRepr) Resolve

func (r *TrueRepr) Resolve(resolver Resolver) error

func (*TrueRepr) Specialize

func (r *TrueRepr) Specialize(typ tlschema.TypeExpr) Repr

type UnixTimeRepr

type UnixTimeRepr struct {
}

func (*UnixTimeRepr) AppendGoDefs

func (r *UnixTimeRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*UnixTimeRepr) AppendReadStmt

func (r *UnixTimeRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*UnixTimeRepr) AppendSwitchCase

func (r *UnixTimeRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*UnixTimeRepr) AppendWriteStmt

func (r *UnixTimeRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*UnixTimeRepr) GoImports

func (r *UnixTimeRepr) GoImports() []string

func (*UnixTimeRepr) GoType

func (r *UnixTimeRepr) GoType() string

func (*UnixTimeRepr) InternalTypeID

func (r *UnixTimeRepr) InternalTypeID() string

func (*UnixTimeRepr) Resolve

func (r *UnixTimeRepr) Resolve(resolver Resolver) error

func (*UnixTimeRepr) Specialize

func (r *UnixTimeRepr) Specialize(typ tlschema.TypeExpr) Repr

type UnsupportedRepr

type UnsupportedRepr struct {
	Name   string
	ErrMsg string
}

func (*UnsupportedRepr) AppendGoDefs

func (r *UnsupportedRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*UnsupportedRepr) AppendReadStmt

func (r *UnsupportedRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*UnsupportedRepr) AppendSwitchCase

func (r *UnsupportedRepr) AppendSwitchCase(buf *bytes.Buffer, indent string)

func (*UnsupportedRepr) AppendWriteStmt

func (r *UnsupportedRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*UnsupportedRepr) GoImports

func (r *UnsupportedRepr) GoImports() []string

func (*UnsupportedRepr) GoType

func (r *UnsupportedRepr) GoType() string

func (*UnsupportedRepr) InternalTypeID

func (r *UnsupportedRepr) InternalTypeID() string

func (*UnsupportedRepr) Resolve

func (r *UnsupportedRepr) Resolve(resolver Resolver) error

func (*UnsupportedRepr) Specialize

func (r *UnsupportedRepr) Specialize(typ tlschema.TypeExpr) Repr

type VectorRepr

type VectorRepr struct {
	ItemType tlschema.TypeExpr

	ItemRepr Repr
}

func (*VectorRepr) AppendGoDefs

func (r *VectorRepr) AppendGoDefs(buf *bytes.Buffer, options CodeGenOptions)

func (*VectorRepr) AppendReadStmt

func (r *VectorRepr) AppendReadStmt(buf *bytes.Buffer, indent, dst string)

func (*VectorRepr) AppendWriteStmt

func (r *VectorRepr) AppendWriteStmt(buf *bytes.Buffer, indent, src string)

func (*VectorRepr) GoImports

func (r *VectorRepr) GoImports() []string

func (*VectorRepr) GoType

func (r *VectorRepr) GoType() string

func (*VectorRepr) InternalTypeID

func (r *VectorRepr) InternalTypeID() string

func (*VectorRepr) Resolve

func (r *VectorRepr) Resolve(resolver Resolver) error

Jump to

Keyboard shortcuts

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