internal

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

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 (e *EnumModel) SymbolIdentifier(symbol string) string

func (*EnumModel) UnmarshalJSON

func (e *EnumModel) UnmarshalJSON(data []byte) error

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

func (f *Field) IsPointer() bool

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

type Identifier struct {
	Namespace string `json:"namespace"`
	Name      string `json:"name"`
}

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 MapModel

type MapModel struct {
	Values *Model
}

func (*MapModel) GoType

func (m *MapModel) GoType() *Statement

func (*MapModel) UnmarshalJSON

func (m *MapModel) UnmarshalJSON(data []byte) error

type Model

type Model struct {
	BuiltinType BuiltinType
	ComplexType ComplexType
}

func (*Model) GoType

func (m *Model) GoType() (def *Statement)

func (*Model) IsBytesOrPrimitive

func (m *Model) IsBytesOrPrimitive() bool

func (*Model) IsMapOrArray

func (m *Model) IsMapOrArray() bool

func (*Model) PointerType

func (m *Model) PointerType() *Statement

func (*Model) RestLiEncodeModel

func (m *Model) RestLiEncodeModel(encoder string, accessor *Statement) (*Statement, bool)

func (*Model) RestLiReducedEncodeModel

func (m *Model) RestLiReducedEncodeModel(accessor *Statement) (def *Statement, hasError bool)

func (*Model) RestLiURLEncodeModel

func (m *Model) RestLiURLEncodeModel(accessor *Statement) (def *Statement, hasError bool)

func (*Model) String

func (m *Model) String() string

func (*Model) UnmarshalJSON

func (m *Model) UnmarshalJSON(data []byte) (err error)

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

func (p *Path) CopyWith(id Identifier, depth int) Path

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

type UnionFieldModel struct {
	Type  *Model
	Alias string
}

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

Jump to

Keyboard shortcuts

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