model

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 13 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

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) NoMembers added in v0.28.0

func (e *Enum) NoMembers() bool

NoMembers returns true if the enum has no members.

func (*Enum) Validate added in v0.33.0

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

Validate 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) Validate added in v0.33.0

func (e *EnumMember) Validate(m *Module) error

Validate 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 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) Validate added in v0.33.0

func (i *Interface) Validate(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
	// 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"`
	Checksum   string       `json:"checksum" yaml:"checksum"`
}

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) Validate added in v0.33.0

func (m *Module) Validate() 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
	// 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 {
	Id          uint                   `json:"-" yaml:"-"` // internal id
	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" }

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) Validate added in v0.33.0

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

type Schema

type Schema struct {
	Type     string   `json:"type" yaml:"type"`
	IsArray  bool     `json:"array" yaml:"array"`
	Module   *Module  `json:"-" yaml:"-"`
	KindType KindType `json:"kindType" yaml:"kindType"`

	IsPrimitive bool `json:"isPrimitive" yaml:"isPrimitive"`
	IsSymbol    bool `json:"isSymbol" yaml:"isSymbol"`
	IsResolved  bool `json:"-" yaml:"-"`
	// 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

IsEmpty returns true if the schema is empty

func (*Schema) IsEnum

func (s *Schema) IsEnum() bool

func (*Schema) IsInterface

func (s *Schema) IsInterface() bool

func (Schema) IsNotVoid added in v0.19.0

func (s Schema) IsNotVoid() bool

IsNotVoid returns true if the schema is not void

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) Validate added in v0.33.0

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

Validate resolves all the types in the schema

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) Validate added in v0.33.0

func (s *Signal) Validate(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) NoFields added in v0.28.0

func (s *Struct) NoFields() bool

func (*Struct) Validate added in v0.33.0

func (s *Struct) Validate(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
	// 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"`
	Checksum  string    `json:"checksum" yaml:"checksum"`
}

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) Validate added in v0.33.0

func (s *System) Validate() error

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"`
	IsReadOnly bool `json:"readonly" yaml:"readonly"`
}

TypedNode is a base node with a schema type. { name: "foo", kind: "property", type: "string" }

func NewTypedNode

func NewTypedNode(n string, k Kind) *TypedNode

NewTypedNode creates a new typed node

func (TypedNode) GetKind

func (t TypedNode) GetKind() Kind

GetKind returns the kind of the node

func (TypedNode) GetName

func (t TypedNode) GetName() string

GetName returns the name of the node

func (TypedNode) GetSchema

func (t TypedNode) GetSchema() *Schema

GetSchema returns the schema of the node

func (*TypedNode) IsFloat added in v0.20.0

func (t *TypedNode) IsFloat() bool

IsFloat returns true if the schema is a float (e.g. float, float32, float64)

func (*TypedNode) IsInt added in v0.20.0

func (t *TypedNode) IsInt() bool

func (*TypedNode) IsVoid added in v0.9.0

func (t *TypedNode) IsVoid() bool

IsVoid returns true if the schema is void

func (TypedNode) TypeName added in v0.8.0

func (t TypedNode) TypeName() string

TypeName returns the name of the type, e.g. String, Int32, Int32Array, InterfaceFoo, StructBar, EnumBaz Can be used to call conversion functions based on type name

func (*TypedNode) Validate added in v0.33.0

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

Validate resolves all the types in the schema

type Version added in v0.13.13

type Version string

func (Version) Major added in v0.13.13

func (v Version) Major() int

func (Version) Minor added in v0.13.13

func (v Version) Minor() int

func (Version) Patch added in v0.13.13

func (v Version) Patch() int

func (Version) String added in v0.13.13

func (v Version) String() string

Jump to

Keyboard shortcuts

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