Documentation ¶
Index ¶
- Constants
- Variables
- func LoadModels() error
- func NewCodeFileForModel(ct ComplexType) *CodeFile
- func ResolveCyclicDependencies(loadedModels []*Model)
- type ArrayModel
- type BuiltinType
- type BytesModel
- type ComplexType
- type EnumModel
- type Field
- type FixedModel
- type Graph
- func (g *Graph) AddParent(id Identifier, parent Identifier)
- func (g *Graph) AllDependencies(id Identifier, set IdentifierSet) IdentifierSet
- func (g *Graph) FindCycle(nextNode Identifier, depth int, path Path) []Identifier
- func (g *Graph) FlagCyclic(id Identifier)
- func (g *Graph) IsCyclic(id Identifier) bool
- func (g *Graph) SetChildren(id Identifier, set IdentifierSet)
- type GraphNode
- type Identifier
- type IdentifierSet
- type MapModel
- type Model
- func (m *Model) GoType() (def *Statement)
- func (m *Model) IsBytesOrPrimitive() bool
- func (m *Model) IsMapOrArray() bool
- func (m *Model) PointerType() *Statement
- func (m *Model) RestLiEncodeModel(encoder string, accessor *Statement) (*Statement, bool)
- func (m *Model) RestLiReducedEncodeModel(accessor *Statement) (def *Statement, hasError bool)
- func (m *Model) RestLiURLEncodeModel(accessor *Statement) (def *Statement, hasError bool)
- func (m *Model) String() string
- func (m *Model) UnmarshalJSON(data []byte) (err error)
- type ModelReference
- type Path
- type PdscModel
- type PrimitiveModel
- type RecordModel
- type TyperefModel
- type UnionFieldModel
- type UnionModel
- type WrongTypeError
Constants ¶
View Source
const ArrayModelTypeName = "array"
View Source
const BytesModelTypeName = "bytes"
View Source
const EnumModelTypeName = "enum"
View Source
const FixedModelTypeName = "fixed"
View Source
const MapModelTypeName = "map"
View Source
const RecordModelTypeName = "record"
View Source
const TyperefModelTypeName = "typeref"
Variables ¶
View Source
var ( NullPrimitive = PrimitiveModel{"null", "interface{}"} IntPrimitive = PrimitiveModel{"int", "int32"} LongPrimitive = PrimitiveModel{"long", "int64"} FloatPrimitive = PrimitiveModel{"float", "float32"} DoublePrimitive = PrimitiveModel{"double", "float64"} BooleanPrimitive = PrimitiveModel{"boolean", "bool"} StringPrimitive = PrimitiveModel{"string", "string"} )
View Source
var DependencyGraph = make(Graph)
View Source
var ModelRegistry = &modelRegistry{ resolvedTypes: make(map[Identifier]*PdscModel), unresolvedModels: make(map[Identifier][]unresolvedModel), }
Functions ¶
func LoadModels ¶
func LoadModels() error
func NewCodeFileForModel ¶
func NewCodeFileForModel(ct ComplexType) *CodeFile
func ResolveCyclicDependencies ¶
func ResolveCyclicDependencies(loadedModels []*Model)
Types ¶
type ArrayModel ¶
type ArrayModel struct {
Items *Model
}
func (*ArrayModel) GoType ¶
func (a *ArrayModel) GoType() *Statement
func (*ArrayModel) UnmarshalJSON ¶
func (a *ArrayModel) UnmarshalJSON(data []byte) error
type BuiltinType ¶
type BuiltinType interface { GoType() (def *Statement) // contains filtered or unexported methods }
type BytesModel ¶
type BytesModel struct { }
func (*BytesModel) GoType ¶
func (b *BytesModel) GoType() *Statement
func (*BytesModel) UnmarshalJSON ¶
func (b *BytesModel) UnmarshalJSON(data []byte) error
type ComplexType ¶
type ComplexType interface { GoType() (def *Statement) GenerateCode() (def *Statement) PackagePath() string GetIdentifier() Identifier CopyWithAlias(alias string) ComplexType }
type EnumModel ¶
type EnumModel struct { Identifier Doc string Symbols []string SymbolDocs map[string]string }
func (*EnumModel) CopyWithAlias ¶
func (e *EnumModel) CopyWithAlias(alias string) ComplexType
func (*EnumModel) GenerateCode ¶
func (e *EnumModel) GenerateCode() (def *Statement)
func (*EnumModel) SymbolIdentifier ¶
func (*EnumModel) UnmarshalJSON ¶
type Field ¶
type Field struct { Name string `json:"name"` Doc string `json:"doc"` Type *Model `json:"type"` Optional bool `json:"optional"` Default json.RawMessage `json:"default"` }
func (*Field) RawAccessor ¶
func (f *Field) RawAccessor(accessor *Statement) *Statement
type FixedModel ¶
type FixedModel struct { Identifier Doc string Size int }
func (*FixedModel) CopyWithAlias ¶
func (f *FixedModel) CopyWithAlias(alias string) ComplexType
func (*FixedModel) GenerateCode ¶
func (f *FixedModel) GenerateCode() (def *Statement)
func (*FixedModel) UnmarshalJSON ¶
func (f *FixedModel) UnmarshalJSON(data []byte) error
type Graph ¶
type Graph map[Identifier]*GraphNode
func (*Graph) AddParent ¶
func (g *Graph) AddParent(id Identifier, parent Identifier)
func (*Graph) AllDependencies ¶
func (g *Graph) AllDependencies(id Identifier, set IdentifierSet) IdentifierSet
func (*Graph) FindCycle ¶
func (g *Graph) FindCycle(nextNode Identifier, depth int, path Path) []Identifier
func (*Graph) FlagCyclic ¶
func (g *Graph) FlagCyclic(id Identifier)
func (*Graph) IsCyclic ¶
func (g *Graph) IsCyclic(id Identifier) bool
func (*Graph) SetChildren ¶
func (g *Graph) SetChildren(id Identifier, set IdentifierSet)
type GraphNode ¶
type GraphNode struct { Identifier Identifier Parents IdentifierSet Children IdentifierSet IsCyclic bool }
type Identifier ¶
func (*Identifier) GetIdentifier ¶
func (i *Identifier) GetIdentifier() Identifier
func (Identifier) GetQualifiedClasspath ¶
func (i Identifier) GetQualifiedClasspath() string
func (*Identifier) GoType ¶
func (i *Identifier) GoType() *Statement
func (*Identifier) PackagePath ¶
func (i *Identifier) PackagePath() string
func (Identifier) String ¶ added in v0.7.1
func (i Identifier) String() string
type IdentifierSet ¶
type IdentifierSet map[Identifier]bool
func (*IdentifierSet) Add ¶
func (set *IdentifierSet) Add(id Identifier)
func (*IdentifierSet) AddAll ¶
func (set *IdentifierSet) AddAll(other IdentifierSet)
func (*IdentifierSet) Get ¶
func (set *IdentifierSet) Get(id Identifier) bool
func (*IdentifierSet) Remove ¶
func (set *IdentifierSet) Remove(id Identifier)
func (IdentifierSet) String ¶
func (set IdentifierSet) String() string
type Model ¶
type Model struct { BuiltinType BuiltinType ComplexType ComplexType }
func (*Model) IsBytesOrPrimitive ¶
func (*Model) IsMapOrArray ¶
func (*Model) PointerType ¶
func (m *Model) PointerType() *Statement
func (*Model) RestLiEncodeModel ¶
func (*Model) RestLiReducedEncodeModel ¶
func (*Model) RestLiURLEncodeModel ¶
func (*Model) UnmarshalJSON ¶
type ModelReference ¶
type ModelReference Identifier
func (*ModelReference) Resolve ¶
func (r *ModelReference) Resolve() (ComplexType, error)
func (*ModelReference) UnmarshalJSON ¶
func (r *ModelReference) UnmarshalJSON(data []byte) error
type Path ¶
type Path struct { VisitedNodes map[Identifier]int VisitedNamespaces map[string]int }
func (*Path) IntroducesCycle ¶ added in v0.7.2
func (p *Path) IntroducesCycle(nextNode Identifier, depth int) []Identifier
type PdscModel ¶
type PdscModel struct { Type ComplexType File string }
func (*PdscModel) GenerateModelCode ¶
func (m *PdscModel) GenerateModelCode() *CodeFile
type PrimitiveModel ¶
type PrimitiveModel [2]string
func ParsePrimitiveModel ¶
func ParsePrimitiveModel(p string) *PrimitiveModel
func (*PrimitiveModel) GoType ¶
func (p *PrimitiveModel) GoType() *Statement
func (*PrimitiveModel) UnmarshalJSON ¶
func (p *PrimitiveModel) UnmarshalJSON(data []byte) error
type RecordModel ¶
type RecordModel struct { Identifier Doc string Include []*Model Fields []Field // contains filtered or unexported fields }
func (*RecordModel) CopyWithAlias ¶
func (r *RecordModel) CopyWithAlias(alias string) ComplexType
func (*RecordModel) GenerateCode ¶
func (r *RecordModel) GenerateCode() (def *Statement)
func (*RecordModel) UnmarshalJSON ¶
func (r *RecordModel) UnmarshalJSON(data []byte) error
type TyperefModel ¶
type TyperefModel struct { Identifier Doc string Ref *Model }
func (*TyperefModel) CopyWithAlias ¶
func (r *TyperefModel) CopyWithAlias(alias string) ComplexType
func (*TyperefModel) GenerateCode ¶
func (r *TyperefModel) GenerateCode() (def *Statement)
func (*TyperefModel) UnmarshalJSON ¶
func (r *TyperefModel) UnmarshalJSON(data []byte) error
type UnionFieldModel ¶
func (*UnionFieldModel) UnmarshalJSON ¶
func (u *UnionFieldModel) UnmarshalJSON(data []byte) error
type UnionModel ¶
type UnionModel struct { Types []UnionFieldModel IsOptional bool }
func (*UnionModel) GoType ¶
func (u *UnionModel) GoType() (def *Statement)
func (*UnionModel) UnmarshalJSON ¶
func (u *UnionModel) UnmarshalJSON(data []byte) error
type WrongTypeError ¶
type WrongTypeError struct {
Expected, Actual string
}
func (*WrongTypeError) Error ¶
func (w *WrongTypeError) Error() string
Click to show internal directories.
Click to hide internal directories.