model

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: Apache-2.0 Imports: 8 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) 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 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 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 (
	TypeNull      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) 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 NamedNode

type NamedNode struct {
	Name string `json:"name" yaml:"name"`
	Kind Kind   `json:"kind" yaml:"kind"`
}

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) GetKind added in v0.6.0

func (m *Operation) GetKind() Kind

func (*Operation) GetName added in v0.6.0

func (m *Operation) GetName() string

func (*Operation) GetParams added in v0.6.0

func (m *Operation) GetParams() []*TypedNode

func (*Operation) GetSchema added in v0.6.0

func (m *Operation) GetSchema() *Schema

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) GetParams added in v0.6.0

func (s *Signal) GetParams() []*TypedNode

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

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

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

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

func (t *TypedNode) NoType() bool

func (*TypedNode) ResolveAll

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

Jump to

Keyboard shortcuts

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