Documentation ¶
Index ¶
- type DataParser
- type Enum
- type EnumMember
- type EnumScope
- type IModuleProvider
- type ITypeProvider
- type Import
- type Interface
- func (i Interface) LookupOperation(name string) *Operation
- func (i Interface) LookupProperty(name string) *TypedNode
- func (i Interface) LookupSignal(name string) *Signal
- func (i Interface) NoMembers() bool
- func (i Interface) NoOperations() bool
- func (i Interface) NoProperties() bool
- func (i Interface) NoSignals() bool
- func (i *Interface) ResolveAll(mod *Module) error
- type InterfaceScope
- type Kind
- type KindType
- type Module
- func (m Module) LookupDefaultEnumMember(name string) *EnumMember
- func (m Module) LookupEnum(name string) *Enum
- func (m Module) LookupInterface(name string) *Interface
- func (m Module) LookupNode(name string) *NamedNode
- func (m Module) LookupStruct(name string) *Struct
- func (m *Module) ResolveAll() error
- type ModuleScope
- type NamedNode
- type Operation
- type Schema
- func (s *Schema) GetEnum() *Enum
- func (s *Schema) GetInterface() *Interface
- func (s *Schema) GetStruct() *Struct
- func (s Schema) IsEmpty() bool
- func (s *Schema) IsEnum() bool
- func (s *Schema) IsInterface() bool
- func (s Schema) IsNotVoid() bool
- func (s *Schema) IsStruct() bool
- func (s Schema) LookupNode(name string) *NamedNode
- func (s *Schema) ResolveAll(m *Module) error
- type Signal
- type Struct
- type StructScope
- type System
- func (s System) LookupEnum(moduleName string, enumName string) *Enum
- func (s System) LookupInterface(moduleName string, ifaceName string) *Interface
- func (s System) LookupModule(name string) *Module
- func (s System) LookupOperation(moduleName string, ifaceName string, operationName string) *Operation
- func (s System) LookupProperty(moduleName string, ifaceName string, propName string) *TypedNode
- func (s System) LookupSignal(moduleName string, ifaceName string, eventName string) *Signal
- func (s System) LookupStruct(moduleName string, structName string) *Struct
- func (s *System) ResolveAll() error
- type SystemScope
- type TypedNode
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataParser ¶
type DataParser struct {
// contains filtered or unexported fields
}
func NewDataParser ¶
func NewDataParser(s *System) *DataParser
func (*DataParser) LintModule ¶
func (p *DataParser) LintModule(module *Module) error
func (*DataParser) ParseFile ¶
func (p *DataParser) ParseFile(file string) error
func (*DataParser) ParseJson ¶
func (p *DataParser) ParseJson(data []byte) error
func (*DataParser) ParseYaml ¶
func (p *DataParser) ParseYaml(data []byte) error
type Enum ¶
type Enum struct { NamedNode `json:",inline" yaml:",inline"` Members []*EnumMember `json:"members" yaml:"members"` }
Enum is an enumeration.
func (*Enum) Default ¶ added in v0.9.0
func (e *Enum) Default() *EnumMember
Default returns the default member of the enum, which is the first member
func (*Enum) LookupMember ¶ added in v0.8.0
func (e *Enum) LookupMember(name string) *EnumMember
LookupMember returns the member with the given name, or nil if no such member exists.
func (*Enum) ResolveAll ¶
ResolveAll resolves all references in the enum.
type EnumMember ¶
type EnumMember struct { NamedNode `json:",inline" yaml:",inline"` Value int `json:"value" yaml:"value"` }
EnumMember is a member of an enumeration.
func NewEnumMember ¶
func NewEnumMember(name string, value int) *EnumMember
NewEnumMember creates a new EnumMember.
func (*EnumMember) ResolveAll ¶
func (e *EnumMember) ResolveAll(m *Module) error
ResolveAll resolves all references in the enum member.
type EnumScope ¶ added in v0.8.0
type EnumScope struct { // System is the root of all modules System *System // Module is the module that contains the interfaces, structs, and enums Module *Module // Enum is the enum that contains the values Enum *Enum // Features is the list of features that are enabled Features map[string]bool // Meta is the map of metadata Meta map[string]any }
EnumScope is used by the generator to generate code for an enum
type IModuleProvider ¶
type IModuleProvider interface {
GetModule() *Module
}
type ITypeProvider ¶
type Import ¶
type Interface ¶
type Interface struct { NamedNode `json:",inline" yaml:",inline"` Properties []*TypedNode `json:"properties" yaml:"properties"` Operations []*Operation `json:"operations" yaml:"operations"` Signals []*Signal `json:"signals" yaml:"signals"` }
func NewInterface ¶
func (Interface) LookupOperation ¶ added in v0.6.0
func (Interface) LookupProperty ¶
func (Interface) LookupSignal ¶
func (Interface) NoOperations ¶ added in v0.6.0
func (Interface) NoProperties ¶
func (*Interface) ResolveAll ¶
type InterfaceScope ¶ added in v0.8.0
type InterfaceScope struct { // System is the root of all modules System *System // Module is the module that contains the interfaces, structs, and enums Module *Module // Interface is the interface that contains the properties, operations and signals Interface *Interface // Features is the list of features that are enabled Features map[string]bool // Meta is the map of metadata Meta map[string]any }
InterfaceScope is used by the generator to generate code for an interface
type Kind ¶
type Kind string
Kind is an enumeration of the kinds of nodes.
const ( KindSystem Kind = "system" KindModule Kind = "module" KindImport Kind = "import" KindInterface Kind = "interface" KindProperty Kind = "property" KindOperation Kind = "operation" KindParam Kind = "param" KindReturn Kind = "return" KindSignal Kind = "signal" KindStruct Kind = "struct" KindField Kind = "field" KindEnum Kind = "enum" KindMember Kind = "member" )
type KindType ¶
type KindType string
const ( TypeVoid KindType = "void" TypeBool KindType = "bool" TypeInt KindType = "int" TypeInt32 KindType = "int32" TypeInt64 KindType = "int64" TypeFloat KindType = "float" TypeFloat32 KindType = "float32" TypeFloat64 KindType = "float64" TypeString KindType = "string" TypeEnum KindType = "enum" TypeStruct KindType = "struct" TypeInterface KindType = "interface" )
type Module ¶
type Module struct { NamedNode `json:",inline" yaml:",inline"` Version Version `json:"version" yaml:"version"` Imports []*Import `json:"imports" yaml:"imports"` Interfaces []*Interface `json:"interfaces" yaml:"interfaces"` Structs []*Struct `json:"structs" yaml:"structs"` Enums []*Enum `json:"enums" yaml:"enums"` }
func (Module) LookupDefaultEnumMember ¶ added in v0.9.0
func (m Module) LookupDefaultEnumMember(name string) *EnumMember
func (Module) LookupEnum ¶
func (Module) LookupInterface ¶
func (Module) LookupNode ¶
func (Module) LookupStruct ¶
func (*Module) ResolveAll ¶
type ModuleScope ¶ added in v0.8.0
type ModuleScope struct { // System is the root of all modules System *System // Module is the module that contains the interfaces, structs, and enums Module *Module // Features is the list of features that are enabled Features map[string]bool // Meta is the map of metadata Meta map[string]any }
ModuleScope is used by the generator to generate code for a module
type NamedNode ¶
type NamedNode struct { Name string `json:"name" yaml:"name"` Kind Kind `json:"kind" yaml:"kind"` Description string `json:"description" yaml:"description"` Meta map[string]interface{} `json:"meta" yaml:"meta"` }
NamedNode is a base node with a name and a kind. { "name": "foo", "kind": "interface" }
type Operation ¶ added in v0.6.0
type Operation struct { NamedNode `json:",inline" yaml:",inline"` Params []*TypedNode `json:"params" yaml:"params"` Return *TypedNode `json:"return" yaml:"return"` }
func NewOperation ¶ added in v0.6.0
func (*Operation) ParamNames ¶ added in v0.8.0
func (*Operation) ResolveAll ¶ added in v0.6.0
type Schema ¶
type Schema struct { Type string `json:"type" yaml:"type"` IsArray bool `json:"array" yaml:"array"` Module *Module KindType KindType IsPrimitive bool IsSymbol bool IsResolved bool // contains filtered or unexported fields }
TypeNode is a node with type information. { type: array, items: { type: string } }
func (*Schema) GetInterface ¶
func (*Schema) IsInterface ¶
func (Schema) LookupNode ¶
Lookup returns the node with the given name inside the module
func (*Schema) ResolveAll ¶
ResolveAll resolves all the types in the schema
type Signal ¶
type Signal struct { NamedNode `json:",inline" yaml:",inline"` Params []*TypedNode `json:"params" yaml:"params"` }
func (*Signal) ResolveAll ¶
type Struct ¶
type Struct struct { NamedNode `json:",inline" yaml:",inline"` Fields []*TypedNode `json:"fields" yaml:"fields"` }
func (*Struct) LookupField ¶ added in v0.8.0
func (*Struct) ResolveAll ¶
type StructScope ¶ added in v0.8.0
type StructScope struct { // System is the root of all modules System *System // Module is the module that contains the interfaces, structs, and enums Module *Module // Struct is the struct that contains the fields Struct *Struct // Features is the list of features that are enabled Features map[string]bool // Meta is the map of metadata Meta map[string]any }
StructScope is used by the generator to generate code for a struct
type System ¶
type System struct { NamedNode `json:",inline" yaml:",inline"` Modules []*Module `json:"modules" yaml:"modules"` }
func (System) LookupInterface ¶
func (System) LookupModule ¶
LookupModule looks up a module by name
func (System) LookupOperation ¶ added in v0.6.0
func (System) LookupProperty ¶
func (System) LookupSignal ¶
func (System) LookupStruct ¶
func (*System) ResolveAll ¶
type SystemScope ¶ added in v0.8.0
type SystemScope struct { // System is the root of all modules System *System // Features is the list of features that are enabled Features map[string]bool // Meta is the map of metadata Meta map[string]any }
SystemScope is used by the generator to generate code for a system
type TypedNode ¶
type TypedNode struct { NamedNode `json:",inline" yaml:",inline"` Schema `json:",inline" yaml:",inline"` }
TypedNode is a base node with a schema type. { name: "foo", kind: "property", type: "string" }
func NewTypedNode ¶
NewTypedNode creates a new typed node
func (*TypedNode) IsFloat ¶ added in v0.20.0
IsFloat returns true if the schema is a float (e.g. float, float32, float64)
func (*TypedNode) ResolveAll ¶
ResolveAll resolves all the types in the schema