model

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: Apache-2.0, BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FieldTypes = map[string]bool{
	"Address":   true,
	"AgentID":   true,
	"BigInt":    true,
	"Bool":      true,
	"Bytes":     true,
	"ChainID":   true,
	"Hash":      true,
	"Hname":     true,
	"Int8":      true,
	"Int16":     true,
	"Int32":     true,
	"Int64":     true,
	"NftID":     true,
	"RequestID": true,
	"String":    true,
	"TokenID":   true,
	"Uint8":     true,
	"Uint16":    true,
	"Uint32":    true,
	"Uint64":    true,
}

Functions

func LineErrorf added in v0.3.0

func LineErrorf(lineNr int, format string, args ...interface{}) error

Types

type DefElt added in v0.3.0

type DefElt struct {
	Val     string
	Comment string
	Line    int
}

type DefEltList added in v0.3.0

type DefEltList []DefElt

func (DefEltList) Len added in v0.3.0

func (l DefEltList) Len() int

func (DefEltList) Less added in v0.3.0

func (l DefEltList) Less(i, j int) bool

func (DefEltList) Swap added in v0.3.0

func (l DefEltList) Swap(i, j int)

type DefMap added in v0.3.0

type DefMap map[DefElt]*DefElt

func (DefMap) ToStringMap added in v0.3.0

func (m DefMap) ToStringMap() StringMap

type DefMapMap added in v0.3.0

type DefMapMap map[DefElt]*DefMap

func (DefMapMap) ToStringMapMap added in v0.3.0

func (m DefMapMap) ToStringMapMap() StringMapMap

type DefNameMap added in v0.3.0

type DefNameMap map[string]*DefElt

type DefNameMapMap added in v0.3.0

type DefNameMapMap map[string]*DefMap

type Field

type Field struct {
	Name       string // external name for this field
	Alias      string // internal name alias, can be different from Name
	Array      bool
	FldComment string
	MapKey     string
	Optional   bool
	Type       string
	BaseType   bool
	Comment    string
	Line       int // the line number originally in yaml/json file
}

func (*Field) Compile

func (f *Field) Compile(s *Schema, fldNameDef, fldTypeDef *DefElt) error

type FieldMap

type FieldMap map[string]*Field

type Func

type Func struct {
	Name    string
	Access  DefElt
	Kind    string
	Hname   isc.Hname
	Params  []*Field
	Results []*Field
	Line    int
	Comment string
}

type FuncDef

type FuncDef struct {
	Access  DefElt
	Params  DefMap
	Results DefMap
	Line    int
	Comment string
}

type FuncDefMap

type FuncDefMap map[DefElt]*FuncDef

func (FuncDefMap) ToRawFuncDefMap added in v0.3.0

func (m FuncDefMap) ToRawFuncDefMap() RawFuncDefMap

type FuncNameDefMap added in v0.3.0

type FuncNameDefMap map[string]*FuncDef

type JSONSchemaDef added in v0.3.0

type JSONSchemaDef RawSchemaDef

func (*JSONSchemaDef) ToSchemaDef added in v0.3.0

func (s *JSONSchemaDef) ToSchemaDef() *SchemaDef

type RawFuncDef added in v0.3.0

type RawFuncDef struct {
	Access  string    `json:"access,omitempty" yaml:"access,omitempty"`
	Params  StringMap `json:"params,omitempty" yaml:"params,omitempty"`
	Results StringMap `json:"results,omitempty" yaml:"results,omitempty"`
}

type RawFuncDefMap added in v0.3.0

type RawFuncDefMap map[string]*RawFuncDef

func (RawFuncDefMap) ToFuncDefMap added in v0.3.0

func (m RawFuncDefMap) ToFuncDefMap() FuncDefMap

type RawSchemaDef added in v0.3.0

type RawSchemaDef struct {
	Name        string        `json:"name" yaml:"name"`
	Description string        `json:"description" yaml:"description"`
	Events      StringMapMap  `json:"events" yaml:"events"`
	Structs     StringMapMap  `json:"structs" yaml:"structs"`
	Typedefs    StringMap     `json:"typedefs" yaml:"typedefs"`
	State       StringMap     `json:"state" yaml:"state"`
	Funcs       RawFuncDefMap `json:"funcs" yaml:"funcs"`
	Views       RawFuncDefMap `json:"views" yaml:"views"`
}

type Schema

type Schema struct {
	ContractName  string
	Copyright     string
	PackageName   string
	Description   string
	CoreContracts bool
	SchemaTime    time.Time
	Events        []*Struct
	Funcs         []*Func
	Params        []*Field
	Results       []*Field
	StateVars     []*Field
	Structs       []*Struct
	Typedefs      []*Field
}

func NewSchema

func NewSchema() *Schema

func (*Schema) Compile

func (s *Schema) Compile(schemaDef *SchemaDef) error

type SchemaDef

type SchemaDef struct {
	Copyright   string
	Name        DefElt
	Description DefElt
	Events      DefMapMap
	Structs     DefMapMap
	Typedefs    DefMap
	State       DefMap
	Funcs       FuncDefMap
	Views       FuncDefMap
}

func NewSchemaDef added in v0.3.0

func NewSchemaDef() *SchemaDef

func (*SchemaDef) ToRawSchemaDef added in v0.3.0

func (s *SchemaDef) ToRawSchemaDef() *RawSchemaDef

type StringMap

type StringMap map[string]string

func (StringMap) ToDefMap added in v0.3.0

func (mm StringMap) ToDefMap() DefMap

type StringMapMap

type StringMapMap map[string]StringMap

func (StringMapMap) ToDefMapMap added in v0.3.0

func (mm StringMapMap) ToDefMapMap() DefMapMap

type Struct

type Struct struct {
	Name   DefElt
	Fields []*Field
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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