luas

package
v0.0.0-...-63f9e25 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Prefix = "contract:"

Variables

This section is empty.

Functions

func DecodeRaw

func DecodeRaw(L *lua.LState, data []byte) (lua.LValue, error)

func Init

func Init()

func JsonDecode

func JsonDecode(L *lua.LState) int

func LValueDumps

func LValueDumps(value lua.LValue) ([]byte, error)

func Map

func Map(state *lua.LState, name string, st interface{}) error

Map maps the lua table to the given struct pointer with default options.

func ToGoValue

func ToGoValue(lv lua.LValue, opt Option) interface{}

ToGoValue converts the given LValue to a Go object.

func ToUpperCamelCase

func ToUpperCamelCase(s string) string

ToUpperCamelCase is an Option.NameFunc that converts strings from snake case to upper camel case.

Types

type CDb

type CDb struct {
	// contains filtered or unexported fields
}

func (*CDb) Float

func (c *CDb) Float(key string) float64

func (*CDb) Int

func (c *CDb) Int(key string) int

func (*CDb) SetFloat

func (c *CDb) SetFloat(key string, value float64)

func (*CDb) SetInt

func (c *CDb) SetInt(key string, value int)

func (*CDb) SetStr

func (c *CDb) SetStr(key, value string)

func (*CDb) SetTable

func (c *CDb) SetTable(key string, m map[string]interface{})

func (*CDb) Str

func (c *CDb) Str(key string) string

func (*CDb) Table

func (c *CDb) Table(key string) lua.LValue

type ContractDb

type ContractDb struct {
	// contains filtered or unexported fields
}

func NewDb

func NewDb(contractAddress []byte) *ContractDb

func (*ContractDb) Db

func (c *ContractDb) Db(name string) *CDb

type Mapper

type Mapper struct {
	Option Option
}

Mapper maps a lua table to a Go struct pointer.

func NewMapper

func NewMapper(opt Option) *Mapper

NewMapper returns a new mapper.

func (*Mapper) Dumps

func (mapper *Mapper) Dumps(tbl lua.LValue) ([]byte, error)

func (*Mapper) Map

func (mapper *Mapper) Map(tbl *lua.LTable, st interface{}) error

Map maps the lua table to the given struct pointer.

type Option

type Option struct {
	// Function to convert a lua table key to Go's one. This defaults to "ToUpperCamelCase".
	NameFunc func(string) string

	// Returns error if unused keys exist.
	ErrorUnused bool

	// A struct tag name for lua table keys . This defaults to "gluamapper"
	TagName string
}

Option is a configuration that is used to create a new mapper.

Jump to

Keyboard shortcuts

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