generator

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: Apache-2.0, BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessChain         = "chain"
	AccessCreator       = "creator"
	AccessSelf          = "self"
	AliasThis           = "this"
	InitFunc            = "Init"
	KindFunc            = "Func"
	KindView            = "View"
	PropImmutable       = "Immutable"
	PropMutable         = "Mutable"
	SpecialFuncInit     = "funcInit"
	SpecialFuncSetOwner = "setOwner"
	SpecialViewGetOwner = "getOwner"
)

Variables

View Source
var (
	ModuleCwd  = "???"
	ModuleName = "???"
	ModulePath = "???"
)
View Source
var FieldTypes = map[string]int32{
	"Address":   wasmlib.TYPE_ADDRESS,
	"AgentID":   wasmlib.TYPE_AGENT_ID,
	"Bytes":     wasmlib.TYPE_BYTES,
	"ChainID":   wasmlib.TYPE_CHAIN_ID,
	"Color":     wasmlib.TYPE_COLOR,
	"Hash":      wasmlib.TYPE_HASH,
	"Hname":     wasmlib.TYPE_HNAME,
	"Int16":     wasmlib.TYPE_INT16,
	"Int32":     wasmlib.TYPE_INT32,
	"Int64":     wasmlib.TYPE_INT64,
	"RequestID": wasmlib.TYPE_REQUEST_ID,
	"String":    wasmlib.TYPE_STRING,
}

Functions

func FindModulePath

func FindModulePath() error

Types

type Field

type Field struct {
	Name     string // external name for this field
	Alias    string // internal name alias, can be different from Name
	Array    bool
	Comment  string
	KeyID    int
	MapKey   string
	Optional bool
	Type     string
	TypeID   int32
}

func (*Field) Compile

func (f *Field) Compile(s *Schema, fldName, fldType string) error

type FieldMap

type FieldMap map[string]*Field

TODO describe schema details in docs

type FieldMapMap

type FieldMapMap map[string]FieldMap

TODO describe schema details in docs

type Func

type Func struct {
	Access   string
	Kind     string
	FuncName string
	Hname    iscp.Hname
	String   string
	Params   []*Field
	Results  []*Field
	Type     string
}

type FuncDef

type FuncDef 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 FuncDefMap

type FuncDefMap map[string]*FuncDef

type GenBase added in v0.2.2

type GenBase struct {
	Folder string

	NewTypes map[string]bool
	// contains filtered or unexported fields
}

func (*GenBase) Generate added in v0.2.2

func (g *GenBase) Generate(s *Schema) error

type Generator added in v0.2.2

type Generator interface {
	// contains filtered or unexported methods
}

type GoGenerator added in v0.2.2

type GoGenerator struct {
	GenBase
}

func NewGoGenerator added in v0.2.2

func NewGoGenerator() *GoGenerator

type RustGenerator added in v0.2.2

type RustGenerator struct {
	GenBase
}

func NewRustGenerator added in v0.2.2

func NewRustGenerator() *RustGenerator

type Schema

type Schema struct {
	Name          string
	FullName      string
	Description   string
	KeyID         int
	ConstLen      int
	ConstNames    []string
	ConstValues   []string
	CoreContracts bool
	SchemaTime    time.Time
	Funcs         []*Func
	Params        []*Field
	Results       []*Field
	StateVars     []*Field
	Structs       []*Struct
	Typedefs      []*Field
	Views         []*Func
}

func NewSchema

func NewSchema() *Schema

func (*Schema) Compile

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

func (*Schema) GenerateJava

func (s *Schema) GenerateJava() error

func (*Schema) GenerateJavaConsts

func (s *Schema) GenerateJavaConsts() error

func (*Schema) GenerateJavaFunc

func (s *Schema) GenerateJavaFunc(file *os.File, f *Func) error

func (*Schema) GenerateJavaFuncScanner

func (s *Schema) GenerateJavaFuncScanner(file *os.File) ([]string, StringMap, error)

func (*Schema) GenerateJavaFuncs

func (s *Schema) GenerateJavaFuncs() error

func (*Schema) GenerateJavaFuncsNew

func (s *Schema) GenerateJavaFuncsNew(scFileName string) error

func (*Schema) GenerateJavaLib

func (s *Schema) GenerateJavaLib() error

func (*Schema) GenerateJavaThunk

func (s *Schema) GenerateJavaThunk(file, params *os.File, f *Func)

func (*Schema) GenerateJavaType added in v0.2.2

func (s *Schema) GenerateJavaType(td *Struct) error

func (*Schema) GenerateJavaTypes

func (s *Schema) GenerateJavaTypes() error

type SchemaDef

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

type StringMap

type StringMap map[string]string

TODO describe schema details in docs

type StringMapMap

type StringMapMap map[string]StringMap

TODO describe schema details in docs

type Struct

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

type TypeScriptGenerator added in v0.2.2

type TypeScriptGenerator struct {
	GenBase
}

func NewTypeScriptGenerator added in v0.2.2

func NewTypeScriptGenerator() *TypeScriptGenerator

Jump to

Keyboard shortcuts

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