luabox

package module
v0.0.0-...-bd535e2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const ENV_KEY = "LUABOX_ENV"
View Source
const E_READONLY = FsError("readonly filesystem")

Variables

View Source
var BaseLibs map[string]LuaFile

Functions

func DeepPush

func DeepPush(l *lua.State, v interface{}) int

func LoadFile

func LoadFile(l *lua.State, fileName, mode string) error

func LoadLuaFile

func LoadLuaFile(l *lua.State, f LuaFile) error

func MustPullVarargs

func MustPullVarargs(l *lua.State, startIndex int) []interface{}

func PackageOpen

func PackageOpen(l *lua.State) int

PackageOpen opens the package library. Usually passed to Require.

func Parse

func Parse(l *lua.State) int

func ParseJson

func ParseJson(l *lua.State) int

func PullStringTable

func PullStringTable(l *lua.State, idx int) (map[string]string, error)

func PullTable

func PullTable(l *lua.State, idx int) (interface{}, error)

func PullVarargs

func PullVarargs(l *lua.State, startIndex int) ([]interface{}, error)

func Repr

func Repr(l *lua.State) int

func ReprJson

func ReprJson(l *lua.State) int

func ScanLibs

func ScanLibs(libDir string, libDirName string) (map[string]LuaFile, error)

func SetEnvironment

func SetEnvironment(l *lua.State, environment *Environment)

func SyscallOpen

func SyscallOpen(l *lua.State) int

Types

type Environment

type Environment struct {
	Fs         Filesystem
	Input      io.Reader
	Output     WriteSyncer
	Log        Log
	Env        map[string]string
	Args       []string
	Context    context.Context
	GoLibs     []lua.RegistryFunction
	LuaLibs    map[string]LuaFile
	PreInitLua []LuaFile
}

func GetEnvironment

func GetEnvironment(l *lua.State) (*Environment, error)

func (*Environment) Init

func (e *Environment) Init() (*lua.State, error)

type FileInfo

type FileInfo struct {
	Name         string
	SelfUrl      string
	IsDir        bool
	LastModified time.Time
	Size         uint64
	ETag         string
}

type Filesystem

type Filesystem interface {
	GetReader(file string) (io.ReadCloser, error)
	GetWriter(file string) (io.WriteCloser, error)
	List(path string) ([]FileInfo, error)
	Delete(path string) error
}

type FsError

type FsError string

func (FsError) Error

func (e FsError) Error() string

type Level

type Level int8
const (
	DEBUG_LEVEL Level = iota - 1
	INFO_LEVEL
	WARN_LEVEL
	ERROR_LEVEL
	FATAL_LEVEL
)

type Log

type Log interface {
	GetLevel() Level
	WithFields(context map[string]interface{}) Log
	Debug(msg string, context map[string]interface{})
	Info(msg string, context map[string]interface{})
	Warn(msg string, context map[string]interface{})
	Error(msg string, context map[string]interface{})
	Fatal(msg string, context map[string]interface{})
}

type LuaFile

type LuaFile struct {
	Name string
	Code string
}

type VFS

type VFS struct {
	BaseFs   Filesystem
	Prefixes map[string]Filesystem
}

func (*VFS) Delete

func (vfs *VFS) Delete(file string) error

func (*VFS) GetReader

func (vfs *VFS) GetReader(file string) (io.ReadCloser, error)

func (*VFS) GetWriter

func (vfs *VFS) GetWriter(file string) (io.WriteCloser, error)

func (*VFS) List

func (vfs *VFS) List(file string) ([]FileInfo, error)

type WriteSyncer

type WriteSyncer interface {
	io.Writer
	Sync() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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