Help us shape the future of Go! Take the 2026 Go Developer Survey

lua

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK        = 0
	YIELD     = 1
	ERRRUN    = 2
	ERRSYNTAX = 3
	ERRMEM    = 4
	ERRERR    = 5
)

thread status

View Source
const (
	NONE          c.Int = -1
	NIL           c.Int = 0
	BOOLEAN       c.Int = 1
	LIGHTUSERDATA c.Int = 2
	NUMBER        c.Int = 3
	STRING        c.Int = 4
	TABLE         c.Int = 5
	FUNCTION      c.Int = 6
	USERDATA      c.Int = 7
	THREAD        c.Int = 8
	NUMTYPES      c.Int = 9
)

* basic types

View Source
const (
	RIDX_MAINTHREAD = 1
	RIDX_GLOBALS    = 2
	RIDX_LAST       = RIDX_GLOBALS
)

predefined values in the registry

View Source
const (
	GCSTOP       = 0
	GCRESTART    = 1
	GCCOLLECT    = 2
	GCCOUNT      = 3
	GCCOUNTB     = 4
	GCSTEP       = 5
	GCSETPAUSE   = 6
	GCSETSTEPMUL = 7
	GCISRUNNING  = 9
	GCGEN        = 10
	GCINC        = 11
)
View Source
const (
	HOOKCALL     = 0
	HOOKRET      = 1
	HOOKLINE     = 2
	HOOKCOUNT    = 3
	HOOKTAILCALL = 4
)
View Source
const (
	MASKCALL  = 1 << HOOKCOUNT
	MASKRET   = 1 << HOOKRET
	MASKLINE  = 1 << HOOKLINE
	MASKCOUNT = 1 << HOOKCOUNT
)
View Source
const (
	EXTRASPACE = unsafe.Sizeof(uintptr(0))
)

@@ LUA_EXTRASPACE defines the size of a raw memory area associated with ** a Lua state with very fast access. ** CHANGE it if you need a different size.

View Source
const (
	IDSIZE = 60
)

@@ LUA_IDSIZE gives the maximum size for the description of the source ** of a function in debug information. ** CHANGE it if you want a different size.

View Source
const (
	LLGoPackage = "link: $(pkg-config --libs lua); -llua -lm"
)
View Source
const (
	MAXSTACK = 1000000
)
View Source
const (
	MINSTACK = 20
)

minimum Lua stack available to a C function

View Source
const (
	MULTRET = -1
)

option for multiple returns in 'lua_pcall' and 'lua_call'

View Source
const (
	NUMTAGS = NUMTYPES
)
View Source
const (
	REGISTRYINDEX = -MAXSTACK - 1000
)

Variables

This section is empty.

Functions

func Upvalueindex

func Upvalueindex(i c.Int) c.Int

Types

type Alloc

type Alloc func(ud c.Pointer, ptr c.Pointer, osize c.Ulong, nsize c.Ulong) c.Pointer

llgo:type C

type CFunction

type CFunction func(L *State) c.Int

llgo:type C

type CallInfo

type CallInfo struct {
	Unused [8]byte
}

type Debug

type Debug struct {
	Event           c.Int
	Name            *c.Char        /* (n) */
	Namewhat        *c.Char        /* (n) 'global', 'local', 'field', 'method' */
	What            *c.Char        /* (S) 'Lua', 'C', 'main', 'tail' */
	Source          *c.Char        /* (S) */
	Srclen          uintptr        /* (S) */
	Currentline     c.Int          /* (l) */
	Linedefined     c.Int          /* (S) */
	Lastlinedefined c.Int          /* (S) */
	Nups            byte           /* (u) number of upvalues */
	Nparams         byte           /* (u) number of parameters */
	Isvararg        c.Char         /* (u) */
	Istailcall      c.Char         /* (t) */
	Ftransfer       uint16         /* (r) index of first value transferred */
	Ntransfer       uint16         /* (r) number of transferred values */
	ShortSrc        [IDSIZE]c.Char /* (S) */
	/* private part */
	ICi *CallInfo
}

type Hook

type Hook func(L *State, ar *Debug)

llgo:type C

type Integer

type Integer = c.Int

type for integer functions

type KContext

type KContext = c.Pointer

type for continuation-function contexts

type KFunction

type KFunction func(L *State, status c.Int, ctx KContext) c.Int

llgo:type C

type Number

type Number = c.Double

type of numbers in Lua

type Reader

type Reader func(L *State, ud c.Pointer, sz *c.Ulong) *c.Char

llgo:type C

type State

type State struct {
	Unused [8]byte
}

func Newstate__0

func Newstate__0(f Alloc, ud c.Pointer) *State

llgo:link Newstate__0 C.lua_newstate

func Newstate__1

func Newstate__1() *State

func (*State) Absindex

func (L *State) Absindex(idx c.Int) c.Int

llgo:link (*State).Absindex C.lua_absindex

func (*State) Atpanic

func (L *State) Atpanic(panicf CFunction) CFunction

llgo:link (*State).Atpanic C.lua_atpanic

func (*State) Call

func (L *State) Call(nargs c.Int, nresults c.Int) c.Int

func (*State) Callk

func (L *State) Callk(nargs c.Int, nresults c.Int, ctx KContext, k KFunction) c.Int

llgo:link (*State).Callk C.lua_callk

func (*State) Checkinteger

func (L *State) Checkinteger(arg c.Int) Integer

llgo:link (*State).Checkinteger C.luaL_checkinteger

func (*State) Checknumber

func (L *State) Checknumber(arg c.Int) Number

llgo:link (*State).Checknumber C.luaL_checknumber

func (*State) Checkstack

func (L *State) Checkstack(n c.Int) c.Int

llgo:link (*State).Checkstack C.lua_checkstack

func (*State) Close

func (L *State) Close()

llgo:link (*State).Close C.lua_close

func (*State) Closeslot

func (L *State) Closeslot(idx c.Int)

llgo:link (*State).Closeslot C.lua_closeslot

func (*State) Closethread

func (L *State) Closethread(from *State) c.Int

llgo:link (*State).Closethread C.lua_closethread

func (*State) Concat

func (L *State) Concat(n c.Int)

llgo:link (*State).Concat C.lua_concat

func (*State) Copy

func (L *State) Copy(fromidx c.Int, toidx c.Int)

llgo:link (*State).Copy C.lua_copy

func (*State) Createtable

func (L *State) Createtable(narr c.Int, nrec c.Int)

llgo:link (*State).Createtable C.lua_createtable

func (*State) Dofile

func (L *State) Dofile(filename *c.Char) c.Int

func (*State) Dostring

func (L *State) Dostring(str *c.Char) c.Int

func (*State) Dump

func (L *State) Dump(writer Writer, data c.Pointer, strip c.Int) c.Int

llgo:link (*State).Dump C.lua_dump

func (*State) Error

func (L *State) Error() c.Int

llgo:link (*State).Error C.lua_error

func (*State) Gc

func (L *State) Gc(what c.Int, __llgo_va_list ...any) c.Int

llgo:link (*State).Gc C.lua_gc

func (*State) Getallocf

func (L *State) Getallocf(ud *c.Pointer) Alloc

llgo:link (*State).Getallocf C.lua_getallocf

func (*State) Getextraspace

func (L *State) Getextraspace() c.Pointer

func (*State) Getfield

func (L *State) Getfield(idx c.Int, k *c.Char) c.Int

llgo:link (*State).Getfield C.lua_getfield

func (*State) Getglobal

func (L *State) Getglobal(name *c.Char) c.Int

llgo:link (*State).Getglobal C.lua_getglobal

func (*State) Gethook

func (L *State) Gethook() Hook

llgo:link (*State).Gethook C.lua_gethook

func (*State) Gethookcount

func (L *State) Gethookcount() c.Int

llgo:link (*State).Gethookcount C.lua_gethookcount

func (*State) Gethookmask

func (L *State) Gethookmask() c.Int

llgo:link (*State).Gethookmask C.lua_gethookmask

func (*State) Geti

func (L *State) Geti(idx c.Int, n Integer) c.Int

llgo:link (*State).Geti C.lua_geti

func (*State) Getinfo

func (L *State) Getinfo(what *c.Char, ar *Debug) c.Int

llgo:link (*State).Getinfo C.lua_getinfo

func (*State) Getiuservalue

func (L *State) Getiuservalue(idx c.Int, n c.Int) c.Int

llgo:link (*State).Getiuservalue C.lua_getiuservalue

func (*State) Getlocal

func (L *State) Getlocal(ar *Debug, n c.Int) *c.Char

llgo:link (*State).Getlocal C.lua_getlocal

func (*State) Getmetatable

func (L *State) Getmetatable(objindex c.Int) c.Int

llgo:link (*State).Getmetatable C.lua_getmetatable

func (*State) Getstack

func (L *State) Getstack(level c.Int, ar *Debug) c.Int

llgo:link (*State).Getstack C.lua_getstack

func (*State) Gettable

func (L *State) Gettable(idx c.Int) c.Int

llgo:link (*State).Gettable C.lua_gettable

func (*State) Gettop

func (L *State) Gettop() c.Int

llgo:link (*State).Gettop C.lua_gettop

func (*State) Getupvalue

func (L *State) Getupvalue(funcindex c.Int, n c.Int) *c.Char

llgo:link (*State).Getupvalue C.lua_getupvalue

func (*State) Getuservalue

func (L *State) Getuservalue(idx c.Int) c.Int

func (*State) Insert

func (L *State) Insert(idx c.Int)

func (*State) Isboolean

func (L *State) Isboolean(n c.Int) bool

func (*State) Iscfunction

func (L *State) Iscfunction(idx c.Int) c.Int

llgo:link (*State).Iscfunction C.lua_iscfunction

func (*State) Isfunction

func (L *State) Isfunction(n c.Int) bool

func (*State) Isinteger

func (L *State) Isinteger(idx c.Int) c.Int

llgo:link (*State).Isinteger C.lua_isinteger

func (*State) Islightuserdata

func (L *State) Islightuserdata(n c.Int) bool

func (*State) Isnil

func (L *State) Isnil(n c.Int) bool

func (*State) Isnone

func (L *State) Isnone(n c.Int) bool

func (*State) Isnoneornil

func (L *State) Isnoneornil(n c.Int) bool

func (*State) Isnumber

func (L *State) Isnumber(idx c.Int) c.Int

llgo:link (*State).Isnumber C.lua_isnumber

func (*State) Isstring

func (L *State) Isstring(idx c.Int) c.Int

llgo:link (*State).Isstring C.lua_isstring

func (*State) Istable

func (L *State) Istable(n c.Int) bool

func (*State) Isthread

func (L *State) Isthread(n c.Int) bool

func (*State) Isuserdata

func (L *State) Isuserdata(idx c.Int) c.Int

llgo:link (*State).Isuserdata C.lua_isuserdata

func (*State) Isyieldable

func (L *State) Isyieldable() c.Int

llgo:link (*State).Isyieldable C.lua_isyieldable

func (*State) LError

func (L *State) LError(format *c.Char, __llgo_va_list ...any) c.Int

llgo:link (*State).LError C.luaL_error

func (*State) Len

func (L *State) Len(idx c.Int)

llgo:link (*State).Len C.lua_len

func (*State) Load

func (L *State) Load(reader Reader, dt c.Pointer, chunkname *c.Char, mode *c.Char) c.Int

llgo:link (*State).Load C.lua_load

func (*State) Loadfile

func (L *State) Loadfile(filename *c.Char) c.Int

func (*State) Loadfilex

func (L *State) Loadfilex(filename *c.Char, mode *c.Char) c.Int

llgo:link (*State).Loadfilex C.luaL_loadfilex

func (*State) Loadstring

func (L *State) Loadstring(s *c.Char) c.Int

llgo:link (*State).Loadstring C.luaL_loadstring

func (*State) Newtable

func (L *State) Newtable()

func (*State) Newthread

func (L *State) Newthread() *State

llgo:link (*State).Newthread C.lua_newthread

func (*State) Newuserdata

func (L *State) Newuserdata(sz uintptr) c.Pointer

func (*State) Newuserdatauv

func (L *State) Newuserdatauv(sz uintptr, nuvalue c.Int) c.Pointer

llgo:link (*State).Newuserdatauv C.lua_newuserdatauv

func (*State) Next

func (L *State) Next(idx c.Int) c.Int

llgo:link (*State).Next C.lua_next

func (*State) Openlibs

func (L *State) Openlibs()

llgo:link (*State).Openlibs C.luaL_openlibs

func (*State) Pcall

func (L *State) Pcall(nargs c.Int, nresults c.Int, errfunc c.Int) c.Int

func (*State) Pcallk

func (L *State) Pcallk(nargs c.Int, nresults c.Int, errfunc c.Int, ctx KContext, k KFunction) c.Int

llgo:link (*State).Pcallk C.lua_pcallk

func (*State) Pop

func (L *State) Pop(n c.Int)

func (*State) Pushboolean

func (L *State) Pushboolean(b c.Int)

llgo:link (*State).Pushboolean C.lua_pushboolean

func (*State) Pushcclosure

func (L *State) Pushcclosure(fn CFunction, n c.Int)

llgo:link (*State).Pushcclosure C.lua_pushcclosure

func (*State) Pushcfunction

func (L *State) Pushcfunction(f CFunction)

func (*State) Pushfstring

func (L *State) Pushfstring(format *c.Char, __llgo_va_list ...any) *c.Char

llgo:link (*State).Pushfstring C.lua_pushfstring

func (*State) Pushglobaltable

func (L *State) Pushglobaltable() c.Int

func (*State) Pushinteger

func (L *State) Pushinteger(n Integer)

llgo:link (*State).Pushinteger C.lua_pushinteger

func (*State) Pushlightuserdata

func (L *State) Pushlightuserdata(p c.Pointer)

llgo:link (*State).Pushlightuserdata C.lua_pushlightuserdata

func (*State) Pushliteral

func (L *State) Pushliteral(s *c.Char) *c.Char

func (*State) Pushlstring

func (L *State) Pushlstring(s *c.Char, len c.Ulong) *c.Char

llgo:link (*State).Pushlstring C.lua_pushlstring

func (*State) Pushnil

func (L *State) Pushnil()

llgo:link (*State).Pushnil C.lua_pushnil

func (*State) Pushnumber

func (L *State) Pushnumber(n Number)

llgo:link (*State).Pushnumber C.lua_pushnumber

func (*State) Pushstring

func (L *State) Pushstring(s *c.Char) *c.Char

llgo:link (*State).Pushstring C.lua_pushstring

func (*State) Pushthread

func (L *State) Pushthread() c.Int

llgo:link (*State).Pushthread C.lua_pushthread

func (*State) Pushvalue

func (L *State) Pushvalue(idx c.Int)

llgo:link (*State).Pushvalue C.lua_pushvalue

func (*State) Rawget

func (L *State) Rawget(idx c.Int) c.Int

llgo:link (*State).Rawget C.lua_rawget

func (*State) Rawgeti

func (L *State) Rawgeti(idx c.Int, n Integer) c.Int

llgo:link (*State).Rawgeti C.lua_rawgeti

func (*State) Rawgetp

func (L *State) Rawgetp(idx c.Int, p c.Pointer) c.Int

llgo:link (*State).Rawgetp C.lua_rawgetp

func (*State) Rawset

func (L *State) Rawset(idx c.Int)

llgo:link (*State).Rawset C.lua_rawset

func (*State) Rawseti

func (L *State) Rawseti(idx c.Int, n Integer)

llgo:link (*State).Rawseti C.lua_rawseti

func (*State) Rawsetp

func (L *State) Rawsetp(idx c.Int, p c.Pointer)

llgo:link (*State).Rawsetp C.lua_rawsetp

func (*State) Register

func (L *State) Register(name *c.Char, f CFunction)

func (*State) Remove

func (L *State) Remove(idx c.Int)

func (*State) Replace

func (L *State) Replace(idx c.Int)

func (*State) Resetthread

func (L *State) Resetthread(from *State) c.Int

llgo:link (*State).Resetthread C.lua_resetthread

func (*State) Resume

func (L *State) Resume(from *State, narg c.Int, nres *c.Int) c.Int

llgo:link (*State).Resume C.lua_resume

func (*State) Rotate

func (L *State) Rotate(idx c.Int, n c.Int)

llgo:link (*State).Rotate C.lua_rotate

func (*State) Setallocf

func (L *State) Setallocf(f Alloc, ud c.Pointer) Alloc

llgo:link (*State).Setallocf C.lua_setallocf

func (*State) Setcstacklimit

func (L *State) Setcstacklimit(limit c.Uint) c.Int

llgo:link (*State).Setcstacklimit C.lua_setcstacklimit

func (*State) Setfield

func (L *State) Setfield(idx c.Int, k *c.Char)

llgo:link (*State).Setfield C.lua_setfield

func (*State) Setglobal

func (L *State) Setglobal(name *c.Char)

llgo:link (*State).Setglobal C.lua_setglobal

func (*State) Sethook

func (L *State) Sethook(fn Hook, mask c.Int, count c.Int)

llgo:link (*State).Sethook C.lua_sethook

func (*State) Seti

func (L *State) Seti(idx c.Int, n Integer)

llgo:link (*State).Seti C.lua_seti

func (*State) Setiuservalue

func (L *State) Setiuservalue(idx c.Int, n c.Int) c.Int

llgo:link (*State).Setiuservalue C.lua_setiuservalue

func (*State) Setlocal

func (L *State) Setlocal(ar *Debug, n c.Int) *c.Char

llgo:link (*State).Setlocal C.lua_setlocal

func (*State) Setmetatable

func (L *State) Setmetatable(objindex c.Int) c.Int

llgo:link (*State).Setmetatable C.lua_setmetatable

func (*State) Settable

func (L *State) Settable(idx c.Int)

llgo:link (*State).Settable C.lua_settable

func (*State) Settop

func (L *State) Settop(idx c.Int)

llgo:link (*State).Settop C.lua_settop

func (*State) Setupvalue

func (L *State) Setupvalue(funcindex c.Int, n c.Int) *c.Char

llgo:link (*State).Setupvalue C.lua_setupvalue

func (*State) Setuservalue

func (L *State) Setuservalue(idx c.Int) c.Int

func (*State) Setwarnf

func (L *State) Setwarnf(f WarnFunction, ud c.Pointer)

llgo:link (*State).Setwarnf C.lua_setwarnf

func (*State) Status

func (L *State) Status() c.Int

llgo:link (*State).Status C.lua_status

func (*State) Stringtonumber

func (L *State) Stringtonumber(s *c.Char) c.Ulong

llgo:link (*State).Stringtonumber C.lua_stringtonumber

func (*State) Toboolean

func (L *State) Toboolean(idx c.Int) bool

llgo:link (*State).Toboolean C.lua_toboolean

func (*State) Tocfunction

func (L *State) Tocfunction(idx c.Int) CFunction

llgo:link (*State).Tocfunction C.lua_tocfunction

func (*State) Toclose

func (L *State) Toclose(idx c.Int)

llgo:link (*State).Toclose C.lua_toclose

func (*State) Tointeger

func (L *State) Tointeger(idx c.Int) Integer

func (*State) Tointegerx

func (L *State) Tointegerx(idx c.Int, isnum *c.Int) Integer

llgo:link (*State).Tointegerx C.lua_tointegerx

func (*State) Tolstring

func (L *State) Tolstring(idx c.Int, len *c.Ulong) *c.Char

llgo:link (*State).Tolstring C.lua_tolstring

func (*State) Tonumber

func (L *State) Tonumber(idx c.Int) Number

func (*State) Tonumberx

func (L *State) Tonumberx(idx c.Int, isnum *c.Int) Number

llgo:link (*State).Tonumberx C.lua_tonumberx

func (*State) Topointer

func (L *State) Topointer(idx c.Int) c.Pointer

llgo:link (*State).Topointer C.lua_topointer

func (*State) Tostring

func (L *State) Tostring(idx c.Int) *c.Char

func (*State) Tothread

func (L *State) Tothread(idx c.Int) *State

llgo:link (*State).Tothread C.lua_tothread

func (*State) Touserdata

func (L *State) Touserdata(idx c.Int) c.Pointer

llgo:link (*State).Touserdata C.lua_touserdata

func (*State) Type

func (L *State) Type(idx c.Int) c.Int

llgo:link (*State).Type C.lua_type

func (*State) Typename

func (L *State) Typename(tp c.Int) *c.Char

llgo:link (*State).Typename C.lua_typename

func (*State) Upvalueid

func (L *State) Upvalueid(fidx c.Int, n c.Int) c.Pointer

llgo:link (*State).Upvalueid C.lua_upvalueid

func (*State) Upvaluejoin

func (L *State) Upvaluejoin(fidx1 c.Int, n1 c.Int, fidx2 c.Int, n2 c.Int)

llgo:link (*State).Upvaluejoin C.lua_upvaluejoin

func (*State) Version

func (L *State) Version() Number

llgo:link (*State).Version C.lua_version

func (*State) Warning

func (L *State) Warning(msg *c.Char, tocont c.Int)

llgo:link (*State).Warning C.lua_warning

func (*State) Xmove

func (L *State) Xmove(to *State, n c.Int)

llgo:link (*State).Xmove C.lua_xmove

func (*State) Yield

func (L *State) Yield(nresults c.Int) c.Int

func (*State) Yieldk

func (L *State) Yieldk(nresults c.Int, ctx KContext, k KFunction) c.Int

llgo:link (*State).Yieldk C.lua_yieldk

type Unsigned

type Unsigned = c.Uint

unsigned integer type

type WarnFunction

type WarnFunction func(ud c.Pointer, msg c.Char, tocont c.Int)

llgo:type C

type Writer

type Writer func(L *State, p c.Pointer, sz c.Ulong, ud c.Pointer) c.Int

llgo:type C

Directories

Path Synopsis
_demo
coroutine command
coroutine-cfunc command
custom-panic command
debug command
dump/load command
dump/save command
error command
extraspace command
funccall-concat command
funccall-number command
funccall-string command
hello command
loadcall command
metatable command
stack command
state-alloc command
table command
thread command
userdata command

Jump to

Keyboard shortcuts

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