model

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

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 NewEnum

func NewEnum(name string) *Enum

InitEnum creates a new Enum.

func (*Enum) Default added in v0.9.0

func (e *Enum) Default() *EnumMember

func (*Enum) LookupMember added in v0.8.0

func (e *Enum) LookupMember(name string) *EnumMember

func (*Enum) ResolveAll

func (e *Enum) ResolveAll(mod *Module) error

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

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
}

EnumScope is used by the generator to generate code for an enum

type IModuleProvider

type IModuleProvider interface {
	GetModule() *Module
}

type ITypeProvider

type ITypeProvider interface {
	GetName() string
	GetKind() Kind
	GetSchema() *Schema
}

type Import

type Import struct {
	NamedNode `json:",inline" yaml:",inline"`
	Version   string `json:"version" yaml:"version"`
}

func NewImport

func NewImport(name string, version string) *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 NewInterface(name string) *Interface

func (Interface) LookupOperation added in v0.6.0

func (i Interface) LookupOperation(name string) *Operation

func (Interface) LookupProperty

func (i Interface) LookupProperty(name string) *TypedNode

func (Interface) LookupSignal

func (i Interface) LookupSignal(name string) *Signal

func (Interface) NoMembers

func (i Interface) NoMembers() bool

func (Interface) NoOperations added in v0.6.0

func (i Interface) NoOperations() bool

func (Interface) NoProperties

func (i Interface) NoProperties() bool

func (Interface) NoSignals

func (i Interface) NoSignals() bool

func (*Interface) ResolveAll

func (i *Interface) ResolveAll(mod *Module) error

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
}

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 = "null"
	TypeBool      KindType = "bool"
	TypeInt       KindType = "int"
	TypeFloat     KindType = "float"
	TypeString    KindType = "string"
	TypeEnum      KindType = "enum"
	TypeStruct    KindType = "struct"
	TypeInterface KindType = "interface"
)

type Module

type Module struct {
	NamedNode  `json:",inline" yaml:",inline"`
	Version    string       `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 NewModule

func NewModule(n string, v string) *Module

func (Module) LookupDefaultEnumMember added in v0.9.0

func (m Module) LookupDefaultEnumMember(name string) *EnumMember

func (Module) LookupEnum

func (m Module) LookupEnum(name string) *Enum

func (Module) LookupInterface

func (m Module) LookupInterface(name string) *Interface

func (Module) LookupNode

func (m Module) LookupNode(name string) *NamedNode

func (Module) LookupStruct

func (m Module) LookupStruct(name string) *Struct

func (*Module) ResolveAll

func (m *Module) ResolveAll() error

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
}

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"`
}

NamedNode is a base node with a name and a kind. { "name": "foo", "kind": "interface" }

func (*NamedNode) AsPath

func (n *NamedNode) AsPath() string

func (NamedNode) IsEmpty

func (n NamedNode) IsEmpty() bool

func (*NamedNode) ShortName

func (n *NamedNode) ShortName() string

func (*NamedNode) String

func (n *NamedNode) String() string

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 NewOperation(name string) *Operation

func (*Operation) ParamNames added in v0.8.0

func (m *Operation) ParamNames() []string

func (*Operation) ResolveAll added in v0.6.0

func (m *Operation) ResolveAll(mod *Module) error

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

func (s *Schema) GetEnum() *Enum

func (*Schema) GetInterface

func (s *Schema) GetInterface() *Interface

func (*Schema) GetStruct

func (s *Schema) GetStruct() *Struct

func (Schema) IsEmpty

func (s Schema) IsEmpty() bool

func (*Schema) IsEnum

func (s *Schema) IsEnum() bool

func (*Schema) IsInterface

func (s *Schema) IsInterface() bool

func (*Schema) IsStruct

func (s *Schema) IsStruct() bool

func (Schema) LookupNode

func (s Schema) LookupNode(name string) *NamedNode

Lookup returns the node with the given name inside the module

func (*Schema) ResolveAll

func (s *Schema) ResolveAll(m *Module) error

type Signal

type Signal struct {
	NamedNode `json:",inline" yaml:",inline"`
	Params    []*TypedNode `json:"params" yaml:"params"`
}

func NewSignal

func NewSignal(name string) *Signal

func (*Signal) ResolveAll

func (s *Signal) ResolveAll(m *Module) error

type Struct

type Struct struct {
	NamedNode `json:",inline" yaml:",inline"`
	Fields    []*TypedNode `json:"fields" yaml:"fields"`
}

func NewStruct

func NewStruct(name string) *Struct

func (*Struct) LookupField added in v0.8.0

func (s *Struct) LookupField(name string) *TypedNode

func (*Struct) ResolveAll

func (s *Struct) ResolveAll(m *Module) error

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
}

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 NewSystem

func NewSystem(name string) *System

func (System) LookupEnum

func (s System) LookupEnum(moduleName string, enumName string) *Enum

func (System) LookupInterface

func (s System) LookupInterface(moduleName string, ifaceName string) *Interface

func (System) LookupModule

func (s System) LookupModule(name string) *Module

LookupModule looks up a module by name

func (System) LookupOperation added in v0.6.0

func (s System) LookupOperation(moduleName string, ifaceName string, operationName string) *Operation

func (System) LookupProperty

func (s System) LookupProperty(moduleName string, ifaceName string, propName string) *TypedNode

func (System) LookupSignal

func (s System) LookupSignal(moduleName string, ifaceName string, eventName string) *Signal

func (System) LookupStruct

func (s System) LookupStruct(moduleName string, structName string) *Struct

func (*System) ResolveAll

func (s *System) ResolveAll() error

type SystemScope added in v0.8.0

type SystemScope struct {
	// System is the root of all modules
	System *System
}

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

func NewTypedNode(n string, k Kind) *TypedNode

func (TypedNode) GetKind

func (t TypedNode) GetKind() Kind

func (TypedNode) GetName

func (t TypedNode) GetName() string

func (TypedNode) GetSchema

func (t TypedNode) GetSchema() *Schema

func (TypedNode) HasType

func (t TypedNode) HasType() bool

func (*TypedNode) IsVoid added in v0.9.0

func (t *TypedNode) IsVoid() bool

func (*TypedNode) NoType

func (t *TypedNode) NoType() bool

func (*TypedNode) ResolveAll

func (t *TypedNode) ResolveAll(m *Module) error

func (TypedNode) TypeName added in v0.8.0

func (t TypedNode) TypeName() string

Jump to

Keyboard shortcuts

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