Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lua.h File Reference
#include <stdarg.h>
#include <stddef.h>
#include "luaconf.h"

Go to the source code of this file.

Data Structures

struct  lua_Debug
 

Macros

#define LUA_VERSION   "Lua 5.1"
 
#define LUA_RELEASE   "Lua 5.1.5"
 
#define LUA_VERSION_NUM   501
 
#define LUA_COPYRIGHT   "Copyright (C) 1994-2012 Lua.org, PUC-Rio"
 
#define LUA_AUTHORS   "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
 
#define LUA_SIGNATURE   "\033Lua"
 
#define LUA_MULTRET   (-1)
 
#define LUA_REGISTRYINDEX   (-10000)
 
#define LUA_ENVIRONINDEX   (-10001)
 
#define LUA_GLOBALSINDEX   (-10002)
 
#define lua_upvalueindex(i)   (LUA_GLOBALSINDEX-(i))
 
#define LUA_YIELD   1
 
#define LUA_ERRRUN   2
 
#define LUA_ERRSYNTAX   3
 
#define LUA_ERRMEM   4
 
#define LUA_ERRERR   5
 
#define LUA_TNONE   (-1)
 
#define LUA_TNIL   0
 
#define LUA_TBOOLEAN   1
 
#define LUA_TLIGHTUSERDATA   2
 
#define LUA_TNUMBER   3
 
#define LUA_TSTRING   4
 
#define LUA_TTABLE   5
 
#define LUA_TFUNCTION   6
 
#define LUA_TUSERDATA   7
 
#define LUA_TTHREAD   8
 
#define LUA_MINSTACK   20
 
#define LUA_GCSTOP   0
 
#define LUA_GCRESTART   1
 
#define LUA_GCCOLLECT   2
 
#define LUA_GCCOUNT   3
 
#define LUA_GCCOUNTB   4
 
#define LUA_GCSTEP   5
 
#define LUA_GCSETPAUSE   6
 
#define LUA_GCSETSTEPMUL   7
 
#define lua_pop(L, n)   lua_settop(L, -(n)-1)
 
#define lua_newtable(L)   lua_createtable(L, 0, 0)
 
#define lua_register(L, n, f)   (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
 
#define lua_pushcfunction(L, f)   lua_pushcclosure(L, (f), 0)
 
#define lua_strlen(L, i)   lua_objlen(L, (i))
 
#define lua_isfunction(L, n)   (lua_type(L, (n)) == LUA_TFUNCTION)
 
#define lua_istable(L, n)   (lua_type(L, (n)) == LUA_TTABLE)
 
#define lua_islightuserdata(L, n)   (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
 
#define lua_isnil(L, n)   (lua_type(L, (n)) == LUA_TNIL)
 
#define lua_isboolean(L, n)   (lua_type(L, (n)) == LUA_TBOOLEAN)
 
#define lua_isthread(L, n)   (lua_type(L, (n)) == LUA_TTHREAD)
 
#define lua_isnone(L, n)   (lua_type(L, (n)) == LUA_TNONE)
 
#define lua_isnoneornil(L, n)   (lua_type(L, (n)) <= 0)
 
#define lua_pushliteral(L, s)    lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
 
#define lua_setglobal(L, s)   lua_setfield(L, LUA_GLOBALSINDEX, (s))
 
#define lua_getglobal(L, s)   lua_getfield(L, LUA_GLOBALSINDEX, (s))
 
#define lua_tostring(L, i)   lua_tolstring(L, (i), NULL)
 
#define lua_open()   luaL_newstate()
 
#define lua_getregistry(L)   lua_pushvalue(L, LUA_REGISTRYINDEX)
 
#define lua_getgccount(L)   lua_gc(L, LUA_GCCOUNT, 0)
 
#define lua_Chunkreader   lua_Reader
 
#define lua_Chunkwriter   lua_Writer
 
#define LUA_HOOKCALL   0
 
#define LUA_HOOKRET   1
 
#define LUA_HOOKLINE   2
 
#define LUA_HOOKCOUNT   3
 
#define LUA_HOOKTAILRET   4
 
#define LUA_MASKCALL   (1 << LUA_HOOKCALL)
 
#define LUA_MASKRET   (1 << LUA_HOOKRET)
 
#define LUA_MASKLINE   (1 << LUA_HOOKLINE)
 
#define LUA_MASKCOUNT   (1 << LUA_HOOKCOUNT)
 

Typedefs

typedef struct lua_State lua_State
 
typedef int(* lua_CFunction) (lua_State *L)
 
typedef const char *(* lua_Reader) (lua_State *L, void *ud, size_t *sz)
 
typedef int(* lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud)
 
typedef void *(* lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize)
 
typedef LUA_NUMBER lua_Number
 
typedef LUA_INTEGER lua_Integer
 
typedef struct lua_Debug lua_Debug
 
typedef void(* lua_Hook) (lua_State *L, lua_Debug *ar)
 

Functions

LUA_API lua_Statelua_newstate (lua_Alloc f, void *ud)
 
LUA_API void lua_close (lua_State *L)
 
LUA_API lua_Statelua_newthread (lua_State *L)
 
LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf)
 
LUA_API int lua_gettop (lua_State *L)
 
LUA_API void lua_settop (lua_State *L, int idx)
 
LUA_API void lua_pushvalue (lua_State *L, int idx)
 
LUA_API void lua_remove (lua_State *L, int idx)
 
LUA_API void lua_insert (lua_State *L, int idx)
 
LUA_API void lua_replace (lua_State *L, int idx)
 
LUA_API int lua_checkstack (lua_State *L, int sz)
 
LUA_API void lua_xmove (lua_State *from, lua_State *to, int n)
 
LUA_API int lua_isnumber (lua_State *L, int idx)
 
LUA_API int lua_isstring (lua_State *L, int idx)
 
LUA_API int lua_iscfunction (lua_State *L, int idx)
 
LUA_API int lua_isuserdata (lua_State *L, int idx)
 
LUA_API int lua_type (lua_State *L, int idx)
 
LUA_API const char * lua_typename (lua_State *L, int tp)
 
LUA_API int lua_equal (lua_State *L, int idx1, int idx2)
 
LUA_API int lua_rawequal (lua_State *L, int idx1, int idx2)
 
LUA_API int lua_lessthan (lua_State *L, int idx1, int idx2)
 
LUA_API lua_Number lua_tonumber (lua_State *L, int idx)
 
LUA_API lua_Integer lua_tointeger (lua_State *L, int idx)
 
LUA_API int lua_toboolean (lua_State *L, int idx)
 
LUA_API const char * lua_tolstring (lua_State *L, int idx, size_t *len)
 
LUA_API size_t lua_objlen (lua_State *L, int idx)
 
LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx)
 
LUA_API void * lua_touserdata (lua_State *L, int idx)
 
LUA_API lua_Statelua_tothread (lua_State *L, int idx)
 
LUA_API const void * lua_topointer (lua_State *L, int idx)
 
LUA_API void lua_pushnil (lua_State *L)
 
LUA_API void lua_pushnumber (lua_State *L, lua_Number n)
 
LUA_API void lua_pushinteger (lua_State *L, lua_Integer n)
 
LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t l)
 
LUA_API void lua_pushstring (lua_State *L, const char *s)
 
LUA_API const char * lua_pushvfstring (lua_State *L, const char *fmt, va_list argp)
 
LUA_API const char * lua_pushfstring (lua_State *L, const char *fmt,...)
 
LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n)
 
LUA_API void lua_pushboolean (lua_State *L, int b)
 
LUA_API void lua_pushlightuserdata (lua_State *L, void *p)
 
LUA_API int lua_pushthread (lua_State *L)
 
LUA_API void lua_gettable (lua_State *L, int idx)
 
LUA_API void lua_getfield (lua_State *L, int idx, const char *k)
 
LUA_API void lua_rawget (lua_State *L, int idx)
 
LUA_API void lua_rawgeti (lua_State *L, int idx, int n)
 
LUA_API void lua_createtable (lua_State *L, int narr, int nrec)
 
LUA_API void * lua_newuserdata (lua_State *L, size_t sz)
 
LUA_API int lua_getmetatable (lua_State *L, int objindex)
 
LUA_API void lua_getfenv (lua_State *L, int idx)
 
LUA_API void lua_settable (lua_State *L, int idx)
 
LUA_API void lua_setfield (lua_State *L, int idx, const char *k)
 
LUA_API void lua_rawset (lua_State *L, int idx)
 
LUA_API void lua_rawseti (lua_State *L, int idx, int n)
 
LUA_API int lua_setmetatable (lua_State *L, int objindex)
 
LUA_API int lua_setfenv (lua_State *L, int idx)
 
LUA_API void lua_call (lua_State *L, int nargs, int nresults)
 
LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc)
 
LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud)
 
LUA_API int lua_load (lua_State *L, lua_Reader reader, void *dt, const char *chunkname)
 
LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data)
 
LUA_API int lua_yield (lua_State *L, int nresults)
 
LUA_API int lua_resume (lua_State *L, int narg)
 
LUA_API int lua_status (lua_State *L)
 
LUA_API int lua_gc (lua_State *L, int what, int data)
 
LUA_API int lua_error (lua_State *L)
 
LUA_API int lua_next (lua_State *L, int idx)
 
LUA_API void lua_concat (lua_State *L, int n)
 
LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud)
 
LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud)
 
LUA_API void lua_setlevel (lua_State *from, lua_State *to)
 
LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar)
 
LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar)
 
LUA_API const char * lua_getlocal (lua_State *L, const lua_Debug *ar, int n)
 
LUA_API const char * lua_setlocal (lua_State *L, const lua_Debug *ar, int n)
 
LUA_API const char * lua_getupvalue (lua_State *L, int funcindex, int n)
 
LUA_API const char * lua_setupvalue (lua_State *L, int funcindex, int n)
 
LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count)
 
LUA_API lua_Hook lua_gethook (lua_State *L)
 
LUA_API int lua_gethookmask (lua_State *L)
 
LUA_API int lua_gethookcount (lua_State *L)
 

Macro Definition Documentation

◆ LUA_AUTHORS

#define LUA_AUTHORS   "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"

Definition at line 23 of file lua-5.1.5/src/lua.h.

◆ lua_Chunkreader

#define lua_Chunkreader   lua_Reader

Definition at line 293 of file lua-5.1.5/src/lua.h.

◆ lua_Chunkwriter

#define lua_Chunkwriter   lua_Writer

Definition at line 294 of file lua-5.1.5/src/lua.h.

◆ LUA_COPYRIGHT

#define LUA_COPYRIGHT   "Copyright (C) 1994-2012 Lua.org, PUC-Rio"

◆ LUA_ENVIRONINDEX

#define LUA_ENVIRONINDEX   (-10001)

◆ LUA_ERRERR

◆ LUA_ERRMEM

#define LUA_ERRMEM   4

◆ LUA_ERRRUN

#define LUA_ERRRUN   2

◆ LUA_ERRSYNTAX

◆ LUA_GCCOLLECT

#define LUA_GCCOLLECT   2

◆ LUA_GCCOUNT

#define LUA_GCCOUNT   3

◆ LUA_GCCOUNTB

#define LUA_GCCOUNTB   4

◆ LUA_GCRESTART

#define LUA_GCRESTART   1

◆ LUA_GCSETPAUSE

#define LUA_GCSETPAUSE   6

◆ LUA_GCSETSTEPMUL

#define LUA_GCSETSTEPMUL   7

◆ LUA_GCSTEP

#define LUA_GCSTEP   5

◆ LUA_GCSTOP

#define LUA_GCSTOP   0

◆ lua_getgccount

#define lua_getgccount ( L)    lua_gc(L, LUA_GCCOUNT, 0)

Definition at line 291 of file lua-5.1.5/src/lua.h.

Referenced by luaB_gcinfo().

◆ lua_getglobal

◆ lua_getregistry

#define lua_getregistry ( L)    lua_pushvalue(L, LUA_REGISTRYINDEX)

Definition at line 289 of file lua-5.1.5/src/lua.h.

◆ LUA_GLOBALSINDEX

#define LUA_GLOBALSINDEX   (-10002)

◆ LUA_HOOKCALL

#define LUA_HOOKCALL   0

Definition at line 311 of file lua-5.1.5/src/lua.h.

Referenced by callhook(), callhook(), luaD_hookcall(), and luaD_precall().

◆ LUA_HOOKCOUNT

#define LUA_HOOKCOUNT   3

Definition at line 314 of file lua-5.1.5/src/lua.h.

Referenced by luaG_traceexec(), luaG_traceexec(), traceexec(), and traceexec().

◆ LUA_HOOKLINE

#define LUA_HOOKLINE   2

Definition at line 313 of file lua-5.1.5/src/lua.h.

Referenced by luaG_traceexec(), luaG_traceexec(), traceexec(), and traceexec().

◆ LUA_HOOKRET

#define LUA_HOOKRET   1

Definition at line 312 of file lua-5.1.5/src/lua.h.

Referenced by callrethooks(), luaD_poscall(), luaD_poscall(), and rethook().

◆ LUA_HOOKTAILRET

#define LUA_HOOKTAILRET   4

Definition at line 315 of file lua-5.1.5/src/lua.h.

Referenced by callrethooks(), and luaD_callhook().

◆ lua_isboolean

#define lua_isboolean ( L,
n )   (lua_type(L, (n)) == LUA_TBOOLEAN)

Definition at line 268 of file lua-5.1.5/src/lua.h.

Referenced by luaB_newproxy(), os_exit(), os_exit(), os_exit(), and print().

◆ lua_isfunction

◆ lua_islightuserdata

#define lua_islightuserdata ( L,
n )   (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)

Definition at line 266 of file lua-5.1.5/src/lua.h.

◆ lua_isnil

◆ lua_isnone

◆ lua_isnoneornil

◆ lua_istable

◆ lua_isthread

#define lua_isthread ( L,
n )   (lua_type(L, (n)) == LUA_TTHREAD)

Definition at line 269 of file lua-5.1.5/src/lua.h.

Referenced by getthread(), getthread(), getthread(), and getthread().

◆ LUA_MASKCALL

◆ LUA_MASKCOUNT

◆ LUA_MASKLINE

◆ LUA_MASKRET

◆ LUA_MINSTACK

◆ LUA_MULTRET

◆ lua_newtable

◆ lua_open

#define lua_open ( )    luaL_newstate()

Definition at line 287 of file lua-5.1.5/src/lua.h.

Referenced by main(), main(), and main().

◆ lua_pop

#define lua_pop ( L,
n )   lua_settop(L, -(n)-1)

Definition at line 254 of file lua-5.1.5/src/lua.h.

Referenced by add_value(), add_value(), add_value(), add_value(), addreturn(), addreturn(), addtoclib(), addtoclib(), auxresume(), auxresume(), auxresume(), auxsort(), auxsort(), auxsort(), auxsort(), b_unpack(), checkclib(), checkclib(), checktab(), checktab(), cleanupdb(), cleanupvm(), collwrapper(), create_meta(), createmeta(), createmeta(), createmeta(), createmetatable(), createmetatable(), createmetatable(), createmetatable(), db_close_vm(), db_do_rows(), db_errorfb(), db_exec_callback(), db_prepare(), db_sethook(), db_setlocal(), db_setlocal(), db_sql_finalize_function(), db_sql_normal_function(), dbbu_gc(), dbvm_bind_names(), finalreport(), findfield(), findfield(), findfield(), findloader(), findloader(), findloader(), foreach(), foreachi(), g_read(), g_read(), g_read(), g_read(), gctm(), gctm(), gctm(), generic_reader(), generic_reader(), generic_reader(), get_prompt(), getboolfield(), getboolfield(), getboolfield(), getboolfield(), getfield(), getfield(), getfield(), getfield(), gethooktable(), handle_script(), handle_script(), incomplete(), incomplete(), incomplete(), incomplete(), ll_addtoclib(), ll_checkclib(), ll_module(), ll_register(), ll_require(), ll_require(), ll_require(), ll_require(), load_aux(), load_aux(), load_aux(), luaB_newproxy(), luaB_print(), luaB_print(), luaB_print(), luaB_print(), luaI_openlib(), luaL_addvalue(), luaL_checkudata(), luaL_checkversion_(), luaL_findtable(), luaL_getmetafield(), luaL_getsubtable(), luaL_len(), luaL_newmetatable(), luaL_openlibs(), luaL_ref(), luaL_requiref(), luaL_setfuncs(), luaL_testudata(), luaopen_io(), luaopen_LuaXML_lib(), luaopen_package(), master_thread_run(), maxn(), mg_start2(), newvm(), noenv(), noenv(), noenv(), partition(), partition(), pushglobalfuncname(), pushglobalfuncname(), pushline(), pushline(), pushline(), report(), report(), report(), report(), setfenv(), setpath(), setpath(), setrandfunc(), sort_comp(), sort_comp(), sort_comp(), sort_comp(), str_format(), str_format(), str_format(), traceback(), Xml_eval(), Xml_iterate(), Xml_match(), Xml_pushDecode(), Xml_pushEncode(), and Xml_str().

◆ lua_pushcfunction

◆ lua_pushliteral

◆ lua_register

#define lua_register ( L,
n,
f )   (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))

Definition at line 258 of file lua-5.1.5/src/lua.h.

Referenced by main().

◆ LUA_REGISTRYINDEX

#define LUA_REGISTRYINDEX   (-10000)

Definition at line 36 of file lua-5.1.5/src/lua.h.

Referenced by addtoclib(), addtoclib(), checkclib(), checkclib(), cleanupbu(), cleanupdb(), cleanupvm(), collfree(), collwrapper(), createclibstable(), createclibstable(), createstdfile(), createstdfile(), createstdfile(), db_busy_callback(), db_busy_handler(), db_busy_timeout(), db_close_vm(), db_commit_hook(), db_commit_hook_callback(), db_create_collation(), db_gethook(), db_gethook(), db_getregistry(), db_getregistry(), db_getregistry(), db_getregistry(), db_progress_callback(), db_progress_handler(), db_register_function(), db_rollback_hook(), db_rollback_hook_callback(), db_sethook(), db_sethook(), db_sql_finalize_function(), db_sql_normal_function(), db_trace(), db_trace_callback(), db_update_hook(), db_update_hook_callback(), g_iofile(), g_iofile(), g_iofile(), gethooktable(), getiofile(), getiofile(), getiofile(), hookf(), hookf(), hookf(), index2addr(), index2addr(), index2adr(), index2value(), io_close(), io_close(), io_close(), io_lines(), io_lines(), io_lines(), io_type(), lcontext_get_aggregate_context(), lcontext_set_aggregate_context(), lcontext_user_data(), ll_addtoclib(), ll_checkclib(), ll_module(), ll_register(), ll_require(), ll_require(), ll_require(), ll_require(), lsqlite_backup_init(), lsqlite_make_context(), luaI_openlib(), luaL_checkudata(), luaL_newmetatable(), luaL_openlibs(), luaL_requiref(), luaopen_lsqlite3(), luaopen_LuaXML_lib(), luaopen_package(), moveto(), newdb(), newvm(), noenv(), noenv(), noenv(), pmain(), pmain(), pmain(), pushglobalfuncname(), pushglobalfuncname(), searcher_preload(), searcher_preload(), searcher_preload(), Xml_pushDecode(), Xml_pushEncode(), and Xml_registerCode().

◆ LUA_RELEASE

#define LUA_RELEASE   "Lua 5.1.5"

Definition at line 20 of file lua-5.1.5/src/lua.h.

Referenced by doargs(), mg_get_system_info(), and print_version().

◆ lua_setglobal

◆ LUA_SIGNATURE

◆ lua_strlen

◆ LUA_TBOOLEAN

◆ LUA_TFUNCTION

◆ LUA_TLIGHTUSERDATA

◆ LUA_TNIL

◆ LUA_TNONE

◆ LUA_TNUMBER

◆ lua_tostring

#define lua_tostring ( L,
i )   lua_tolstring(L, (i), NULL)

Definition at line 279 of file lua-5.1.5/src/lua.h.

Referenced by _file_info_(), addreturn(), addreturn(), checkload(), checkload(), checkload(), combine(), combine(), combine(), db_debug(), db_debug(), db_debug(), db_getinfo(), db_getinfo(), db_sql_finalize_function(), db_sql_normal_function(), db_traceback(), db_traceback(), db_traceback(), dbvm_bind_index(), do_gsub(), dotty(), dotty(), errfile(), errfile(), errfile(), errfile(), fileerror(), finalreport(), findfile(), findfile(), findfile(), findfile(), findloader(), findloader(), findloader(), g_iofile(), g_iofile(), g_iofile(), g_iofile(), g_read(), g_read(), get_prompt(), get_prompt(), get_prompt(), gmatch_aux(), io_readline(), io_readline(), io_readline(), l_print(), l_print(), link_info(), ll_require(), loader_Croot(), loaderror(), loadline(), luaB_print(), luaB_select(), luaB_select(), luaB_select(), luaB_select(), luaB_tostring(), luaB_warn(), luaL_argerror(), luaL_argerror(), luaL_gsub(), luaL_loadfile(), luaL_loadfilex(), luaL_tolstring(), luaL_typeerror(), main(), main(), msghandler(), msghandler(), panic(), panic(), panic(), panic(), pmain(), pmain(), pmain(), pmain(), print(), pushfuncname(), pushfuncname(), pushfuncname(), pushglobalfuncname(), pushglobalfuncname(), report(), report(), report(), report(), searcher_Croot(), searcher_Croot(), searcher_Croot(), searchpath(), searchpath(), searchpath(), traceback(), typeerror(), Xml_decode(), Xml_pushDecode(), Xml_pushEncode(), Xml_str(), and XMLencoding_replacement().

◆ LUA_TSTRING

◆ LUA_TTABLE

◆ LUA_TTHREAD

◆ LUA_TUSERDATA

◆ lua_upvalueindex

◆ LUA_VERSION

#define LUA_VERSION   "Lua 5.1"

Definition at line 19 of file lua-5.1.5/src/lua.h.

Referenced by base_open(), and luaopen_base().

◆ LUA_VERSION_NUM

#define LUA_VERSION_NUM   501

Definition at line 21 of file lua-5.1.5/src/lua.h.

Referenced by lua_version(), and mg_get_system_info().

◆ LUA_YIELD

Typedef Documentation

◆ lua_Alloc

typedef void *(* lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize)

Definition at line 66 of file lua-5.1.5/src/lua.h.

◆ lua_CFunction

typedef int(* lua_CFunction) (lua_State *L)

Definition at line 52 of file lua-5.1.5/src/lua.h.

◆ lua_Debug

typedef struct lua_Debug lua_Debug

Definition at line 326 of file lua-5.1.5/src/lua.h.

◆ lua_Hook

typedef void(* lua_Hook) (lua_State *L, lua_Debug *ar)

Definition at line 330 of file lua-5.1.5/src/lua.h.

◆ lua_Integer

Definition at line 103 of file lua-5.1.5/src/lua.h.

◆ lua_Number

Definition at line 99 of file lua-5.1.5/src/lua.h.

◆ lua_Reader

typedef const char *(* lua_Reader) (lua_State *L, void *ud, size_t *sz)

Definition at line 58 of file lua-5.1.5/src/lua.h.

◆ lua_State

typedef struct lua_State lua_State

Definition at line 50 of file lua-5.1.5/src/lua.h.

◆ lua_Writer

typedef int(* lua_Writer) (lua_State *L, const void *p, size_t sz, void *ud)

Definition at line 60 of file lua-5.1.5/src/lua.h.

Function Documentation

◆ lua_atpanic()

LUA_API lua_CFunction lua_atpanic ( lua_State * L,
lua_CFunction panicf )

Definition at line 130 of file lua-5.1.5/src/lapi.c.

130 {
131 lua_CFunction old;
132 lua_lock(L);
133 old = G(L)->panic;
134 G(L)->panic = panicf;
135 lua_unlock(L);
136 return old;
137}
#define lua_unlock(L)
#define lua_lock(L)
#define G(L)
int(* lua_CFunction)(lua_State *L)

◆ lua_call()

LUA_API void lua_call ( lua_State * L,
int nargs,
int nresults )

Definition at line 776 of file lua-5.1.5/src/lapi.c.

776 {
777 StkId func;
778 lua_lock(L);
779 api_checknelems(L, nargs+1);
780 checkresults(L, nargs, nresults);
781 func = L->top - (nargs+1);
782 luaD_call(L, func, nresults);
783 adjustresults(L, nresults);
784 lua_unlock(L);
785}
#define checkresults(L, na, nr)
#define api_checknelems(L, n)
#define adjustresults(L, nres)
void luaD_call(lua_State *L, StkId func, int nResults)

References adjustresults, api_checknelems, checkresults, lua_lock, lua_unlock, luaD_call(), and lua_State::top.

◆ lua_checkstack()

LUA_API int lua_checkstack ( lua_State * L,
int sz )

Definition at line 95 of file lua-5.1.5/src/lapi.c.

95 {
96 int res = 1;
97 lua_lock(L);
98 if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK)
99 res = 0; /* stack overflow */
100 else if (size > 0) {
101 luaD_checkstack(L, size);
102 if (L->ci->top < L->top + size)
103 L->ci->top = L->top + size;
104 }
105 lua_unlock(L);
106 return res;
107}
#define luaD_checkstack(L, n)
#define LUAI_MAXCSTACK

◆ lua_close()

LUA_API void lua_close ( lua_State * L)

Definition at line 199 of file lua-5.1.5/src/lstate.c.

199 {
200 L = G(L)->mainthread; /* only the main thread can be closed */
201 lua_lock(L);
202 luaF_close(L, L->stack); /* close all upvalues for this thread */
203 luaC_separateudata(L, 1); /* separate udata that have GC metamethods */
204 L->errfunc = 0; /* no error function during GC metamethods */
205 do { /* repeat until no more errors */
206 L->ci = L->base_ci;
207 L->base = L->top = L->ci->base;
208 L->nCcalls = L->baseCcalls = 0;
209 } while (luaD_rawrunprotected(L, callallgcTM, NULL) != 0);
210 lua_assert(G(L)->tmudata == NULL);
212 close_state(L);
213}
#define NULL
Definition gmacros.h:924
int luaD_rawrunprotected(lua_State *L, Pfunc f, void *ud)
void luaF_close(lua_State *L, StkId level)
size_t luaC_separateudata(lua_State *L, int all)
#define lua_assert(c)
static void close_state(lua_State *L)
static void callallgcTM(lua_State *L, void *ud)
#define luai_userstateclose(L)
unsigned short nCcalls
unsigned short baseCcalls

◆ lua_concat()

LUA_API void lua_concat ( lua_State * L,
int n )

Definition at line 990 of file lua-5.1.5/src/lapi.c.

990 {
991 lua_lock(L);
992 api_checknelems(L, n);
993 if (n >= 2) {
994 luaC_checkGC(L);
995 luaV_concat(L, n, cast_int(L->top - L->base) - 1);
996 L->top -= (n-1);
997 }
998 else if (n == 0) { /* push empty string */
999 setsvalue2s(L, L->top, luaS_newlstr(L, "", 0));
1000 api_incr_top(L);
1001 }
1002 /* else n == 1; nothing to do */
1003 lua_unlock(L);
1004}
#define api_incr_top(L)
#define luaC_checkGC(L)
#define cast_int(i)
#define setsvalue2s
TString * luaS_newlstr(lua_State *L, const char *str, size_t l)
void luaV_concat(lua_State *L, int total, int last)

◆ lua_cpcall()

LUA_API int lua_cpcall ( lua_State * L,
lua_CFunction func,
void * ud )

Definition at line 850 of file lua-5.1.5/src/lapi.c.

850 {
851 struct CCallS c;
852 int status;
853 lua_lock(L);
854 c.func = func;
855 c.ud = ud;
856 status = luaD_pcall(L, f_Ccall, &c, savestack(L, L->top), 0);
857 lua_unlock(L);
858 return status;
859}
static void f_Ccall(lua_State *L, void *ud)
int luaD_pcall(lua_State *L, Pfunc func, void *u, ptrdiff_t old_top, ptrdiff_t ef)
#define savestack(L, p)
lua_CFunction func

References f_Ccall(), CCallS::func, lua_lock, lua_unlock, luaD_pcall(), savestack, lua_State::top, and CCallS::ud.

Referenced by main(), and main().

◆ lua_createtable()

LUA_API void lua_createtable ( lua_State * L,
int narr,
int nrec )

Definition at line 578 of file lua-5.1.5/src/lapi.c.

578 {
579 lua_lock(L);
580 luaC_checkGC(L);
581 sethvalue(L, L->top, luaH_new(L, narray, nrec));
582 api_incr_top(L);
583 lua_unlock(L);
584}
#define sethvalue(L, obj, x)
Table * luaH_new(lua_State *L, int narray, int nhash)

◆ lua_dump()

LUA_API int lua_dump ( lua_State * L,
lua_Writer writer,
void * data )

Definition at line 875 of file lua-5.1.5/src/lapi.c.

875 {
876 int status;
877 TValue *o;
878 lua_lock(L);
879 api_checknelems(L, 1);
880 o = L->top - 1;
881 if (isLfunction(o))
882 status = luaU_dump(L, clvalue(o)->l.p, writer, data, 0);
883 else
884 status = 1;
885 lua_unlock(L);
886 return status;
887}
int luaU_dump(lua_State *L, const Proto *f, lua_Writer w, void *data, int strip)
#define clvalue(o)
#define isLfunction(o)
static int writer(lua_State *L, const void *b, size_t size, void *B)

◆ lua_equal()

LUA_API int lua_equal ( lua_State * L,
int idx1,
int idx2 )

Definition at line 287 of file lua-5.1.5/src/lapi.c.

287 {
288 StkId o1, o2;
289 int i;
290 lua_lock(L); /* may call tag method */
291 o1 = index2adr(L, index1);
292 o2 = index2adr(L, index2);
293 i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 : equalobj(L, o1, o2);
294 lua_unlock(L);
295 return i;
296}
static TValue * index2adr(lua_State *L, int idx)
#define luaO_nilobject
#define equalobj(L, o1, o2)

References equalobj, index2adr(), lua_lock, lua_unlock, and luaO_nilobject.

Referenced by Xml_iterate(), and Xml_match().

◆ lua_error()

LUA_API int lua_error ( lua_State * L)

Definition at line 964 of file lua-5.1.5/src/lapi.c.

964 {
965 lua_lock(L);
966 api_checknelems(L, 1);
967 luaG_errormsg(L);
968 lua_unlock(L);
969 return 0; /* to avoid warnings */
970}
void luaG_errormsg(lua_State *L)

◆ lua_gc()

LUA_API int lua_gc ( lua_State * L,
int what,
int data )

Definition at line 899 of file lua-5.1.5/src/lapi.c.

899 {
900 int res = 0;
901 global_State *g;
902 lua_lock(L);
903 g = G(L);
904 switch (what) {
905 case LUA_GCSTOP: {
907 break;
908 }
909 case LUA_GCRESTART: {
910 g->GCthreshold = g->totalbytes;
911 break;
912 }
913 case LUA_GCCOLLECT: {
914 luaC_fullgc(L);
915 break;
916 }
917 case LUA_GCCOUNT: {
918 /* GC values are expressed in Kbytes: #bytes/2^10 */
919 res = cast_int(g->totalbytes >> 10);
920 break;
921 }
922 case LUA_GCCOUNTB: {
923 res = cast_int(g->totalbytes & 0x3ff);
924 break;
925 }
926 case LUA_GCSTEP: {
927 lu_mem a = (cast(lu_mem, data) << 10);
928 if (a <= g->totalbytes)
929 g->GCthreshold = g->totalbytes - a;
930 else
931 g->GCthreshold = 0;
932 while (g->GCthreshold <= g->totalbytes) {
933 luaC_step(L);
934 if (g->gcstate == GCSpause) { /* end of cycle? */
935 res = 1; /* signal it */
936 break;
937 }
938 }
939 break;
940 }
941 case LUA_GCSETPAUSE: {
942 res = g->gcpause;
943 g->gcpause = data;
944 break;
945 }
946 case LUA_GCSETSTEPMUL: {
947 res = g->gcstepmul;
948 g->gcstepmul = data;
949 break;
950 }
951 default: res = -1; /* invalid option */
952 }
953 lua_unlock(L);
954 return res;
955}
void luaC_fullgc(lua_State *L)
void luaC_step(lua_State *L)
#define GCSpause
LUAI_UMEM lu_mem
#define MAX_LUMEM
#define cast(t, exp)
#define LUA_GCSETPAUSE
#define LUA_GCCOUNT
#define LUA_GCCOLLECT
#define LUA_GCSTOP
#define LUA_GCRESTART
#define LUA_GCCOUNTB
#define LUA_GCSTEP
#define LUA_GCSETSTEPMUL

◆ lua_getallocf()

LUA_API lua_Alloc lua_getallocf ( lua_State * L,
void ** ud )

Definition at line 1007 of file lua-5.1.5/src/lapi.c.

1007 {
1008 lua_Alloc f;
1009 lua_lock(L);
1010 if (ud) *ud = G(L)->ud;
1011 f = G(L)->frealloc;
1012 lua_unlock(L);
1013 return f;
1014}
void *(* lua_Alloc)(void *ud, void *ptr, size_t osize, size_t nsize)

◆ lua_getfenv()

LUA_API void lua_getfenv ( lua_State * L,
int idx )

Definition at line 616 of file lua-5.1.5/src/lapi.c.

616 {
617 StkId o;
618 lua_lock(L);
619 o = index2adr(L, idx);
621 switch (ttype(o)) {
622 case LUA_TFUNCTION:
623 sethvalue(L, L->top, clvalue(o)->c.env);
624 break;
625 case LUA_TUSERDATA:
626 sethvalue(L, L->top, uvalue(o)->env);
627 break;
628 case LUA_TTHREAD:
629 setobj2s(L, L->top, gt(thvalue(o)));
630 break;
631 default:
632 setnilvalue(L->top);
633 break;
634 }
635 api_incr_top(L);
636 lua_unlock(L);
637}
#define api_checkvalidindex(L, i)
#define uvalue(o)
#define setobj2s
#define thvalue(o)
#define ttype(o)
#define setnilvalue(obj)
#define gt(L)
#define LUA_TTHREAD
#define LUA_TUSERDATA
#define LUA_TFUNCTION

References api_checkvalidindex, api_incr_top, clvalue, gt, index2adr(), lua_lock, LUA_TFUNCTION, LUA_TTHREAD, LUA_TUSERDATA, lua_unlock, sethvalue, setnilvalue, setobj2s, thvalue, lua_State::top, ttype, and uvalue.

Referenced by aux_close(), db_getfenv(), and luaB_getfenv().

◆ lua_getfield()

LUA_API void lua_getfield ( lua_State * L,
int idx,
const char * k )

Definition at line 544 of file lua-5.1.5/src/lapi.c.

544 {
545 StkId t;
546 TValue key;
547 lua_lock(L);
548 t = index2adr(L, idx);
550 setsvalue(L, &key, luaS_new(L, k));
551 luaV_gettable(L, t, &key, L->top);
552 api_incr_top(L);
553 lua_unlock(L);
554}
#define setsvalue(L, obj, x)
#define luaS_new(L, s)
#define luaV_gettable(L, t, k, v)

◆ lua_gethook()

LUA_API lua_Hook lua_gethook ( lua_State * L)

Definition at line 69 of file lua-5.1.5/src/ldebug.c.

69 {
70 return L->hook;
71}

◆ lua_gethookcount()

LUA_API int lua_gethookcount ( lua_State * L)

Definition at line 79 of file lua-5.1.5/src/ldebug.c.

79 {
80 return L->basehookcount;
81}

◆ lua_gethookmask()

LUA_API int lua_gethookmask ( lua_State * L)

Definition at line 74 of file lua-5.1.5/src/ldebug.c.

74 {
75 return L->hookmask;
76}

◆ lua_getinfo()

LUA_API int lua_getinfo ( lua_State * L,
const char * what,
lua_Debug * ar )

Definition at line 232 of file lua-5.1.5/src/ldebug.c.

232 {
233 int status;
234 Closure *f = NULL;
235 CallInfo *ci = NULL;
236 lua_lock(L);
237 if (*what == '>') {
238 StkId func = L->top - 1;
239 luai_apicheck(L, ttisfunction(func));
240 what++; /* skip the '>' */
241 f = clvalue(func);
242 L->top--; /* pop function */
243 }
244 else if (ar->i_ci != 0) { /* no tail call? */
245 ci = L->base_ci + ar->i_ci;
247 f = clvalue(ci->func);
248 }
249 status = auxgetinfo(L, what, ar, f, ci);
250 if (strchr(what, 'f')) {
251 if (f == NULL) setnilvalue(L->top);
252 else setclvalue(L, L->top, f);
253 incr_top(L);
254 }
255 if (strchr(what, 'L'))
256 collectvalidlines(L, f);
257 lua_unlock(L);
258 return status;
259}
static void collectvalidlines(lua_State *L, Closure *f)
static int auxgetinfo(lua_State *L, const char *what, lua_Debug *ar, Closure *f, CallInfo *ci)
#define incr_top(L)
#define ttisfunction(o)
#define setclvalue(L, obj, x)
#define luai_apicheck(L, o)

◆ lua_getlocal()

LUA_API const char * lua_getlocal ( lua_State * L,
const lua_Debug * ar,
int n )

Definition at line 127 of file lua-5.1.5/src/ldebug.c.

127 {
128 CallInfo *ci = L->base_ci + ar->i_ci;
129 const char *name = findlocal(L, ci, n);
130 lua_lock(L);
131 if (name)
132 luaA_pushobject(L, ci->base + (n - 1));
133 lua_unlock(L);
134 return name;
135}
const char * name
Definition lsqlite3.c:2154
void luaA_pushobject(lua_State *L, const TValue *o)
static const char * findlocal(lua_State *L, CallInfo *ci, int n)

◆ lua_getmetatable()

LUA_API int lua_getmetatable ( lua_State * L,
int objindex )

Definition at line 587 of file lua-5.1.5/src/lapi.c.

587 {
588 const TValue *obj;
589 Table *mt = NULL;
590 int res;
591 lua_lock(L);
592 obj = index2adr(L, objindex);
593 switch (ttype(obj)) {
594 case LUA_TTABLE:
595 mt = hvalue(obj)->metatable;
596 break;
597 case LUA_TUSERDATA:
598 mt = uvalue(obj)->metatable;
599 break;
600 default:
601 mt = G(L)->mt[ttype(obj)];
602 break;
603 }
604 if (mt == NULL)
605 res = 0;
606 else {
607 sethvalue(L, L->top, mt);
608 api_incr_top(L);
609 res = 1;
610 }
611 lua_unlock(L);
612 return res;
613}
#define hvalue(o)
#define LUA_TTABLE
struct Table * metatable

◆ lua_getstack()

LUA_API int lua_getstack ( lua_State * L,
int level,
lua_Debug * ar )

Definition at line 84 of file lua-5.1.5/src/ldebug.c.

84 {
85 int status;
86 CallInfo *ci;
87 lua_lock(L);
88 for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) {
89 level--;
90 if (f_isLua(ci)) /* Lua function? */
91 level -= ci->tailcalls; /* skip lost tail calls */
92 }
93 if (level == 0 && ci > L->base_ci) { /* level found? */
94 status = 1;
95 ar->i_ci = cast_int(ci - L->base_ci);
96 }
97 else if (level < 0) { /* level is of a lost tail call? */
98 status = 1;
99 ar->i_ci = 0;
100 }
101 else status = 0; /* no such level */
102 lua_unlock(L);
103 return status;
104}
#define f_isLua(ci)

◆ lua_gettable()

LUA_API void lua_gettable ( lua_State * L,
int idx )

Definition at line 534 of file lua-5.1.5/src/lapi.c.

534 {
535 StkId t;
536 lua_lock(L);
537 t = index2adr(L, idx);
539 luaV_gettable(L, t, L->top - 1, L->top - 1);
540 lua_unlock(L);
541}

◆ lua_gettop()

LUA_API int lua_gettop ( lua_State * L)

Definition at line 159 of file lua-5.1.5/src/lapi.c.

159 {
160 return cast_int(L->top - L->base);
161}

◆ lua_getupvalue()

LUA_API const char * lua_getupvalue ( lua_State * L,
int funcindex,
int n )

Definition at line 1057 of file lua-5.1.5/src/lapi.c.

1057 {
1058 const char *name;
1059 TValue *val;
1060 lua_lock(L);
1061 name = aux_upvalue(index2adr(L, funcindex), n, &val);
1062 if (name) {
1063 setobj2s(L, L->top, val);
1064 api_incr_top(L);
1065 }
1066 lua_unlock(L);
1067 return name;
1068}
static const char * aux_upvalue(StkId fi, int n, TValue **val)

◆ lua_insert()

LUA_API void lua_insert ( lua_State * L,
int idx )

Definition at line 191 of file lua-5.1.5/src/lapi.c.

191 {
192 StkId p;
193 StkId q;
194 lua_lock(L);
195 p = index2adr(L, idx);
197 for (q = L->top; q>p; q--) setobjs2s(L, q, q-1);
198 setobjs2s(L, p, L->top);
199 lua_unlock(L);
200}
#define setobjs2s

◆ lua_iscfunction()

LUA_API int lua_iscfunction ( lua_State * L,
int idx )

Definition at line 254 of file lua-5.1.5/src/lapi.c.

254 {
255 StkId o = index2adr(L, idx);
256 return iscfunction(o);
257}
#define iscfunction(o)

◆ lua_isnumber()

LUA_API int lua_isnumber ( lua_State * L,
int idx )

Definition at line 260 of file lua-5.1.5/src/lapi.c.

260 {
261 TValue n;
262 const TValue *o = index2adr(L, idx);
263 return tonumber(o, &n);
264}
#define tonumber(o, n)

◆ lua_isstring()

LUA_API int lua_isstring ( lua_State * L,
int idx )

Definition at line 267 of file lua-5.1.5/src/lapi.c.

267 {
268 int t = lua_type(L, idx);
269 return (t == LUA_TSTRING || t == LUA_TNUMBER);
270}
LUA_API int lua_type(lua_State *L, int idx)
#define LUA_TSTRING
#define LUA_TNUMBER

◆ lua_isuserdata()

LUA_API int lua_isuserdata ( lua_State * L,
int idx )

Definition at line 273 of file lua-5.1.5/src/lapi.c.

273 {
274 const TValue *o = index2adr(L, idx);
275 return (ttisuserdata(o) || ttislightuserdata(o));
276}
#define ttislightuserdata(o)
#define ttisuserdata(o)

◆ lua_lessthan()

LUA_API int lua_lessthan ( lua_State * L,
int idx1,
int idx2 )

Definition at line 299 of file lua-5.1.5/src/lapi.c.

299 {
300 StkId o1, o2;
301 int i;
302 lua_lock(L); /* may call tag method */
303 o1 = index2adr(L, index1);
304 o2 = index2adr(L, index2);
305 i = (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
306 : luaV_lessthan(L, o1, o2);
307 lua_unlock(L);
308 return i;
309}
int luaV_lessthan(lua_State *L, const TValue *l, const TValue *r)

References index2adr(), lua_lock, lua_unlock, luaO_nilobject, and luaV_lessthan().

Referenced by sort_comp().

◆ lua_load()

LUA_API int lua_load ( lua_State * L,
lua_Reader reader,
void * dt,
const char * chunkname )

Definition at line 862 of file lua-5.1.5/src/lapi.c.

863 {
864 ZIO z;
865 int status;
866 lua_lock(L);
867 if (!chunkname) chunkname = "?";
868 luaZ_init(L, &z, reader, data);
869 status = luaD_protectedparser(L, &z, chunkname);
870 lua_unlock(L);
871 return status;
872}
int luaD_protectedparser(lua_State *L, ZIO *z, const char *name)
void luaZ_init(lua_State *L, ZIO *z, lua_Reader reader, void *data)
static const char * reader(lua_State *L, void *ud, size_t *size)

References lua_lock, lua_unlock, luaD_protectedparser(), luaZ_init(), and reader().

Referenced by combine(), combine(), combine(), luaB_load(), luaB_load(), luaB_load(), luaB_load(), luaL_loadbuffer(), luaL_loadbufferx(), luaL_loadfile(), and luaL_loadfilex().

◆ lua_newstate()

LUA_API lua_State * lua_newstate ( lua_Alloc f,
void * ud )

Definition at line 143 of file lua-5.1.5/src/lstate.c.

143 {
144 int i;
145 lua_State *L;
146 global_State *g;
147 void *l = (*f)(ud, NULL, 0, state_size(LG));
148 if (l == NULL) return NULL;
149 L = tostate(l);
150 g = &((LG *)L)->g;
151 L->next = NULL;
152 L->tt = LUA_TTHREAD;
154 L->marked = luaC_white(g);
155 set2bits(L->marked, FIXEDBIT, SFIXEDBIT);
156 preinit_state(L, g);
157 g->frealloc = f;
158 g->ud = ud;
159 g->mainthread = L;
160 g->uvhead.u.l.prev = &g->uvhead;
161 g->uvhead.u.l.next = &g->uvhead;
162 g->GCthreshold = 0; /* mark it as unfinished state */
163 g->strt.size = 0;
164 g->strt.nuse = 0;
165 g->strt.hash = NULL;
167 luaZ_initbuffer(L, &g->buff);
168 g->panic = NULL;
169 g->gcstate = GCSpause;
170 g->rootgc = obj2gco(L);
171 g->sweepstrgc = 0;
172 g->sweepgc = &g->rootgc;
173 g->gray = NULL;
174 g->grayagain = NULL;
175 g->weak = NULL;
176 g->tmudata = NULL;
177 g->totalbytes = sizeof(LG);
180 g->gcdept = 0;
181 for (i=0; i<NUM_TAGS; i++) g->mt[i] = NULL;
182 if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) {
183 /* memory allocation error: free partial state */
184 close_state(L);
185 L = NULL;
186 }
187 else
189 return L;
190}
#define bit2mask(b1, b2)
#define WHITE0BIT
#define FIXEDBIT
#define SFIXEDBIT
#define set2bits(x, b1, b2)
#define luaC_white(g)
#define NUM_TAGS
#define state_size(x)
#define tostate(l)
static void f_luaopen(lua_State *L, void *ud)
static void preinit_state(lua_State *L, global_State *g)
struct LG LG
#define obj2gco(v)
#define registry(L)
#define luai_userstateopen(L)
#define LUAI_GCPAUSE
#define LUAI_GCMUL
#define luaZ_initbuffer(L, buff)
struct UpVal * prev
union UpVal::@48 u
struct UpVal * next
struct UpVal::@48::@49 l
struct lua_State * mainthread
lua_CFunction panic
struct Table * mt[NUM_TAGS]

◆ lua_newthread()

LUA_API lua_State * lua_newthread ( lua_State * L)

Definition at line 140 of file lua-5.1.5/src/lapi.c.

140 {
141 lua_State *L1;
142 lua_lock(L);
143 luaC_checkGC(L);
144 L1 = luaE_newthread(L);
145 setthvalue(L, L->top, L1);
146 api_incr_top(L);
147 lua_unlock(L);
149 return L1;
150}
#define setthvalue(L, obj, x)
lua_State * luaE_newthread(lua_State *L)
#define luai_userstatethread(L, L1)

◆ lua_newuserdata()

LUA_API void * lua_newuserdata ( lua_State * L,
size_t sz )

Definition at line 1025 of file lua-5.1.5/src/lapi.c.

1025 {
1026 Udata *u;
1027 lua_lock(L);
1028 luaC_checkGC(L);
1029 u = luaS_newudata(L, size, getcurrenv(L));
1030 setuvalue(L, L->top, u);
1031 api_incr_top(L);
1032 lua_unlock(L);
1033 return u + 1;
1034}
static Table * getcurrenv(lua_State *L)
#define setuvalue(L, obj, x)
Udata * luaS_newudata(lua_State *L, size_t s, Table *e)

◆ lua_next()

LUA_API int lua_next ( lua_State * L,
int idx )

Definition at line 973 of file lua-5.1.5/src/lapi.c.

973 {
974 StkId t;
975 int more;
976 lua_lock(L);
977 t = index2adr(L, idx);
978 api_check(L, ttistable(t));
979 more = luaH_next(L, hvalue(t), L->top - 1);
980 if (more) {
981 api_incr_top(L);
982 }
983 else /* no more elements */
984 L->top -= 1; /* remove key */
985 lua_unlock(L);
986 return more;
987}
#define api_check
#define ttistable(o)
int luaH_next(lua_State *L, Table *t, StkId key)

◆ lua_objlen()

LUA_API size_t lua_objlen ( lua_State * L,
int idx )

Definition at line 361 of file lua-5.1.5/src/lapi.c.

361 {
362 StkId o = index2adr(L, idx);
363 switch (ttype(o)) {
364 case LUA_TSTRING: return tsvalue(o)->len;
365 case LUA_TUSERDATA: return uvalue(o)->len;
366 case LUA_TTABLE: return luaH_getn(hvalue(o));
367 case LUA_TNUMBER: {
368 size_t l;
369 lua_lock(L); /* `luaV_tostring' may create a new string */
370 l = (luaV_tostring(L, o) ? tsvalue(o)->len : 0);
371 lua_unlock(L);
372 return l;
373 }
374 default: return 0;
375 }
376}
#define tsvalue(o)
int luaH_getn(Table *t)
int luaV_tostring(lua_State *L, StkId obj)

References hvalue, index2adr(), lua_lock, LUA_TNUMBER, LUA_TSTRING, LUA_TTABLE, LUA_TUSERDATA, lua_unlock, luaH_getn(), luaV_tostring(), tsvalue, ttype, and uvalue.

Referenced by luaL_ref(), read_chars(), and read_line().

◆ lua_pcall()

LUA_API int lua_pcall ( lua_State * L,
int nargs,
int nresults,
int errfunc )

Definition at line 805 of file lua-5.1.5/src/lapi.c.

805 {
806 struct CallS c;
807 int status;
808 ptrdiff_t func;
809 lua_lock(L);
810 api_checknelems(L, nargs+1);
811 checkresults(L, nargs, nresults);
812 if (errfunc == 0)
813 func = 0;
814 else {
815 StkId o = index2adr(L, errfunc);
817 func = savestack(L, o);
818 }
819 c.func = L->top - (nargs+1); /* function to be called */
820 c.nresults = nresults;
821 status = luaD_pcall(L, f_call, &c, savestack(L, c.func), func);
823 lua_unlock(L);
824 return status;
825}
static void f_call(lua_State *L, void *ud)

References adjustresults, api_checknelems, api_checkvalidindex, checkresults, f_call(), CallS::func, index2adr(), lua_lock, lua_unlock, luaD_pcall(), CallS::nresults, savestack, and lua_State::top.

◆ lua_pushboolean()

LUA_API void lua_pushboolean ( lua_State * L,
int b )

Definition at line 503 of file lua-5.1.5/src/lapi.c.

503 {
504 lua_lock(L);
505 setbvalue(L->top, (b != 0)); /* ensure that true is 1 */
506 api_incr_top(L);
507 lua_unlock(L);
508}
#define setbvalue(obj, x)

◆ lua_pushcclosure()

LUA_API void lua_pushcclosure ( lua_State * L,
lua_CFunction fn,
int n )

Definition at line 486 of file lua-5.1.5/src/lapi.c.

486 {
487 Closure *cl;
488 lua_lock(L);
489 luaC_checkGC(L);
490 api_checknelems(L, n);
491 cl = luaF_newCclosure(L, n, getcurrenv(L));
492 cl->c.f = fn;
493 L->top -= n;
494 while (n--)
495 setobj2n(L, &cl->c.upvalue[n], L->top+n);
496 setclvalue(L, L->top, cl);
498 api_incr_top(L);
499 lua_unlock(L);
500}
Closure * luaF_newCclosure(lua_State *L, int nelems, Table *e)
#define iswhite(x)
#define setobj2n
lua_CFunction f

◆ lua_pushfstring()

LUA_API const char * lua_pushfstring ( lua_State * L,
const char * fmt,
... )

Definition at line 473 of file lua-5.1.5/src/lapi.c.

473 {
474 const char *ret;
475 va_list argp;
476 lua_lock(L);
477 luaC_checkGC(L);
478 va_start(argp, fmt);
479 ret = luaO_pushvfstring(L, fmt, argp);
480 va_end(argp);
481 lua_unlock(L);
482 return ret;
483}
const char * luaO_pushvfstring(lua_State *L, const char *fmt, va_list argp)

◆ lua_pushinteger()

LUA_API void lua_pushinteger ( lua_State * L,
lua_Integer n )

Definition at line 437 of file lua-5.1.5/src/lapi.c.

437 {
438 lua_lock(L);
439 setnvalue(L->top, cast_num(n));
440 api_incr_top(L);
441 lua_unlock(L);
442}
#define cast_num(i)
#define setnvalue(obj, x)

◆ lua_pushlightuserdata()

LUA_API void lua_pushlightuserdata ( lua_State * L,
void * p )

Definition at line 511 of file lua-5.1.5/src/lapi.c.

511 {
512 lua_lock(L);
513 setpvalue(L->top, p);
514 api_incr_top(L);
515 lua_unlock(L);
516}
#define setpvalue(obj, x)

◆ lua_pushlstring()

LUA_API void lua_pushlstring ( lua_State * L,
const char * s,
size_t l )

Definition at line 445 of file lua-5.1.5/src/lapi.c.

445 {
446 lua_lock(L);
447 luaC_checkGC(L);
448 setsvalue2s(L, L->top, luaS_newlstr(L, s, len));
449 api_incr_top(L);
450 lua_unlock(L);
451}
CURL_EXTERN CURLMcode curl_socket_t s
Definition multi.h:318

◆ lua_pushnil()

LUA_API void lua_pushnil ( lua_State * L)

Definition at line 421 of file lua-5.1.5/src/lapi.c.

421 {
422 lua_lock(L);
423 setnilvalue(L->top);
424 api_incr_top(L);
425 lua_unlock(L);
426}

◆ lua_pushnumber()

LUA_API void lua_pushnumber ( lua_State * L,
lua_Number n )

Definition at line 429 of file lua-5.1.5/src/lapi.c.

429 {
430 lua_lock(L);
431 setnvalue(L->top, n);
432 api_incr_top(L);
433 lua_unlock(L);
434}

◆ lua_pushstring()

LUA_API void lua_pushstring ( lua_State * L,
const char * s )

Definition at line 454 of file lua-5.1.5/src/lapi.c.

454 {
455 if (s == NULL)
456 lua_pushnil(L);
457 else
458 lua_pushlstring(L, s, strlen(s));
459}
LUA_API void lua_pushnil(lua_State *L)
LUA_API void lua_pushlstring(lua_State *L, const char *s, size_t len)

◆ lua_pushthread()

LUA_API int lua_pushthread ( lua_State * L)

Definition at line 519 of file lua-5.1.5/src/lapi.c.

519 {
520 lua_lock(L);
521 setthvalue(L, L->top, L);
522 api_incr_top(L);
523 lua_unlock(L);
524 return (G(L)->mainthread == L);
525}

◆ lua_pushvalue()

LUA_API void lua_pushvalue ( lua_State * L,
int idx )

Definition at line 228 of file lua-5.1.5/src/lapi.c.

228 {
229 lua_lock(L);
230 setobj2s(L, L->top, index2adr(L, idx));
231 api_incr_top(L);
232 lua_unlock(L);
233}

◆ lua_pushvfstring()

LUA_API const char * lua_pushvfstring ( lua_State * L,
const char * fmt,
va_list argp )

Definition at line 462 of file lua-5.1.5/src/lapi.c.

463 {
464 const char *ret;
465 lua_lock(L);
466 luaC_checkGC(L);
467 ret = luaO_pushvfstring(L, fmt, argp);
468 lua_unlock(L);
469 return ret;
470}

◆ lua_rawequal()

LUA_API int lua_rawequal ( lua_State * L,
int idx1,
int idx2 )

Definition at line 279 of file lua-5.1.5/src/lapi.c.

279 {
280 StkId o1 = index2adr(L, index1);
281 StkId o2 = index2adr(L, index2);
282 return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
283 : luaO_rawequalObj(o1, o2);
284}
int luaO_rawequalObj(const TValue *t1, const TValue *t2)

◆ lua_rawget()

LUA_API void lua_rawget ( lua_State * L,
int idx )

Definition at line 557 of file lua-5.1.5/src/lapi.c.

557 {
558 StkId t;
559 lua_lock(L);
560 t = index2adr(L, idx);
561 api_check(L, ttistable(t));
562 setobj2s(L, L->top - 1, luaH_get(hvalue(t), L->top - 1));
563 lua_unlock(L);
564}
const TValue * luaH_get(Table *t, const TValue *key)

◆ lua_rawgeti()

LUA_API void lua_rawgeti ( lua_State * L,
int idx,
int n )

Definition at line 567 of file lua-5.1.5/src/lapi.c.

567 {
568 StkId o;
569 lua_lock(L);
570 o = index2adr(L, idx);
571 api_check(L, ttistable(o));
572 setobj2s(L, L->top, luaH_getnum(hvalue(o), n));
573 api_incr_top(L);
574 lua_unlock(L);
575}
const TValue * luaH_getnum(Table *t, int key)

◆ lua_rawset()

LUA_API void lua_rawset ( lua_State * L,
int idx )

Definition at line 671 of file lua-5.1.5/src/lapi.c.

671 {
672 StkId t;
673 lua_lock(L);
674 api_checknelems(L, 2);
675 t = index2adr(L, idx);
676 api_check(L, ttistable(t));
677 setobj2t(L, luaH_set(L, hvalue(t), L->top-2), L->top-1);
678 luaC_barriert(L, hvalue(t), L->top-1);
679 L->top -= 2;
680 lua_unlock(L);
681}
#define luaC_barriert(L, t, v)
#define setobj2t
TValue * luaH_set(lua_State *L, Table *t, const TValue *key)

◆ lua_rawseti()

LUA_API void lua_rawseti ( lua_State * L,
int idx,
int n )

Definition at line 684 of file lua-5.1.5/src/lapi.c.

684 {
685 StkId o;
686 lua_lock(L);
687 api_checknelems(L, 1);
688 o = index2adr(L, idx);
689 api_check(L, ttistable(o));
690 setobj2t(L, luaH_setnum(L, hvalue(o), n), L->top-1);
691 luaC_barriert(L, hvalue(o), L->top-1);
692 L->top--;
693 lua_unlock(L);
694}
TValue * luaH_setnum(lua_State *L, Table *t, int key)

◆ lua_remove()

LUA_API void lua_remove ( lua_State * L,
int idx )

Definition at line 180 of file lua-5.1.5/src/lapi.c.

180 {
181 StkId p;
182 lua_lock(L);
183 p = index2adr(L, idx);
185 while (++p < L->top) setobjs2s(L, p-1, p);
186 L->top--;
187 lua_unlock(L);
188}

◆ lua_replace()

LUA_API void lua_replace ( lua_State * L,
int idx )

Definition at line 203 of file lua-5.1.5/src/lapi.c.

203 {
204 StkId o;
205 lua_lock(L);
206 /* explicit test for incompatible code */
207 if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci)
208 luaG_runerror(L, "no calling environment");
209 api_checknelems(L, 1);
210 o = index2adr(L, idx);
212 if (idx == LUA_ENVIRONINDEX) {
213 Closure *func = curr_func(L);
214 api_check(L, ttistable(L->top - 1));
215 func->c.env = hvalue(L->top - 1);
216 luaC_barrier(L, func, L->top - 1);
217 }
218 else {
219 setobj(L, o, L->top - 1);
220 if (idx < LUA_GLOBALSINDEX) /* function upvalue? */
221 luaC_barrier(L, curr_func(L), L->top - 1);
222 }
223 L->top--;
224 lua_unlock(L);
225}
void luaG_runerror(lua_State *L, const char *fmt,...)
#define luaC_barrier(L, p, v)
#define setobj(L, obj1, obj2)
#define curr_func(L)
#define LUA_ENVIRONINDEX
#define LUA_GLOBALSINDEX

◆ lua_resume()

LUA_API int lua_resume ( lua_State * L,
int narg )

Definition at line 418 of file lua-5.1.5/src/ldo.c.

418 {
419 int status;
420 lua_lock(L);
421 if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
422 return resume_error(L, "cannot resume non-suspended coroutine");
423 if (L->nCcalls >= LUAI_MAXCCALLS)
424 return resume_error(L, "C stack overflow");
425 luai_userstateresume(L, nargs);
426 lua_assert(L->errfunc == 0);
427 L->baseCcalls = ++L->nCcalls;
428 status = luaD_rawrunprotected(L, resume, L->top - nargs);
429 if (status != 0) { /* error? */
430 L->status = cast_byte(status); /* mark thread as `dead' */
431 luaD_seterrorobj(L, status, L->top);
432 L->ci->top = L->top;
433 }
434 else {
435 lua_assert(L->nCcalls == L->baseCcalls);
436 status = L->status;
437 }
438 --L->nCcalls;
439 lua_unlock(L);
440 return status;
441}
void luaD_seterrorobj(lua_State *L, int errcode, StkId oldtop)
static int resume_error(lua_State *L, const char *msg)
static void resume(lua_State *L, void *ud)
#define cast_byte(i)
#define LUA_YIELD
#define LUAI_MAXCCALLS
#define luai_userstateresume(L, n)

References lua_State::base_ci, lua_State::baseCcalls, cast_byte, lua_State::ci, lua_State::errfunc, lua_assert, lua_lock, lua_unlock, LUA_YIELD, luaD_rawrunprotected(), luaD_seterrorobj(), LUAI_MAXCCALLS, luai_userstateresume, lua_State::nCcalls, resume(), resume_error(), lua_longjmp::status, lua_State::status, CallInfo::top, and lua_State::top.

Referenced by auxresume(), auxresume(), auxresume(), and auxresume().

◆ lua_setallocf()

LUA_API void lua_setallocf ( lua_State * L,
lua_Alloc f,
void * ud )

Definition at line 1017 of file lua-5.1.5/src/lapi.c.

1017 {
1018 lua_lock(L);
1019 G(L)->ud = ud;
1020 G(L)->frealloc = f;
1021 lua_unlock(L);
1022}

◆ lua_setfenv()

LUA_API int lua_setfenv ( lua_State * L,
int idx )

Definition at line 734 of file lua-5.1.5/src/lapi.c.

734 {
735 StkId o;
736 int res = 1;
737 lua_lock(L);
738 api_checknelems(L, 1);
739 o = index2adr(L, idx);
741 api_check(L, ttistable(L->top - 1));
742 switch (ttype(o)) {
743 case LUA_TFUNCTION:
744 clvalue(o)->c.env = hvalue(L->top - 1);
745 break;
746 case LUA_TUSERDATA:
747 uvalue(o)->env = hvalue(L->top - 1);
748 break;
749 case LUA_TTHREAD:
750 sethvalue(L, gt(thvalue(o)), hvalue(L->top - 1));
751 break;
752 default:
753 res = 0;
754 break;
755 }
756 if (res) luaC_objbarrier(L, gcvalue(o), hvalue(L->top - 1));
757 L->top--;
758 lua_unlock(L);
759 return res;
760}
#define luaC_objbarrier(L, p, o)
#define gcvalue(o)

References api_check, api_checknelems, api_checkvalidindex, clvalue, gcvalue, gt, hvalue, index2adr(), lua_lock, LUA_TFUNCTION, LUA_TTHREAD, LUA_TUSERDATA, lua_unlock, luaC_objbarrier, sethvalue, thvalue, lua_State::top, ttistable, ttype, and uvalue.

Referenced by createstdfile(), db_setfenv(), luaB_setfenv(), luaopen_io(), and setfenv().

◆ lua_setfield()

LUA_API void lua_setfield ( lua_State * L,
int idx,
const char * k )

Definition at line 657 of file lua-5.1.5/src/lapi.c.

657 {
658 StkId t;
659 TValue key;
660 lua_lock(L);
661 api_checknelems(L, 1);
662 t = index2adr(L, idx);
664 setsvalue(L, &key, luaS_new(L, k));
665 luaV_settable(L, t, &key, L->top - 1);
666 L->top--; /* pop value */
667 lua_unlock(L);
668}
#define luaV_settable(L, t, k, v)

◆ lua_sethook()

LUA_API int lua_sethook ( lua_State * L,
lua_Hook func,
int mask,
int count )

Definition at line 56 of file lua-5.1.5/src/ldebug.c.

56 {
57 if (func == NULL || mask == 0) { /* turn off hooks? */
58 mask = 0;
59 func = NULL;
60 }
61 L->hook = func;
62 L->basehookcount = count;
65 return 1;
66}
#define resethookcount(L)
#define mask(n)

◆ lua_setlevel()

LUA_API void lua_setlevel ( lua_State * from,
lua_State * to )

Definition at line 125 of file lua-5.1.5/src/lapi.c.

125 {
126 to->nCcalls = from->nCcalls;
127}

References lua_State::nCcalls.

Referenced by auxresume().

◆ lua_setlocal()

LUA_API const char * lua_setlocal ( lua_State * L,
const lua_Debug * ar,
int n )

Definition at line 138 of file lua-5.1.5/src/ldebug.c.

138 {
139 CallInfo *ci = L->base_ci + ar->i_ci;
140 const char *name = findlocal(L, ci, n);
141 lua_lock(L);
142 if (name)
143 setobjs2s(L, ci->base + (n - 1), L->top - 1);
144 L->top--; /* pop value */
145 lua_unlock(L);
146 return name;
147}

◆ lua_setmetatable()

LUA_API int lua_setmetatable ( lua_State * L,
int objindex )

Definition at line 697 of file lua-5.1.5/src/lapi.c.

697 {
698 TValue *obj;
699 Table *mt;
700 lua_lock(L);
701 api_checknelems(L, 1);
702 obj = index2adr(L, objindex);
703 api_checkvalidindex(L, obj);
704 if (ttisnil(L->top - 1))
705 mt = NULL;
706 else {
707 api_check(L, ttistable(L->top - 1));
708 mt = hvalue(L->top - 1);
709 }
710 switch (ttype(obj)) {
711 case LUA_TTABLE: {
712 hvalue(obj)->metatable = mt;
713 if (mt)
714 luaC_objbarriert(L, hvalue(obj), mt);
715 break;
716 }
717 case LUA_TUSERDATA: {
718 uvalue(obj)->metatable = mt;
719 if (mt)
720 luaC_objbarrier(L, rawuvalue(obj), mt);
721 break;
722 }
723 default: {
724 G(L)->mt[ttype(obj)] = mt;
725 break;
726 }
727 }
728 L->top--;
729 lua_unlock(L);
730 return 1;
731}
#define luaC_objbarriert(L, t, o)
#define ttisnil(o)
#define rawuvalue(o)

◆ lua_settable()

LUA_API void lua_settable ( lua_State * L,
int idx )

Definition at line 645 of file lua-5.1.5/src/lapi.c.

645 {
646 StkId t;
647 lua_lock(L);
648 api_checknelems(L, 2);
649 t = index2adr(L, idx);
651 luaV_settable(L, t, L->top - 2, L->top - 1);
652 L->top -= 2; /* pop index and value */
653 lua_unlock(L);
654}

◆ lua_settop()

LUA_API void lua_settop ( lua_State * L,
int idx )

Definition at line 164 of file lua-5.1.5/src/lapi.c.

164 {
165 lua_lock(L);
166 if (idx >= 0) {
167 api_check(L, idx <= L->stack_last - L->base);
168 while (L->top < L->base + idx)
169 setnilvalue(L->top++);
170 L->top = L->base + idx;
171 }
172 else {
173 api_check(L, -(idx+1) <= (L->top - L->base));
174 L->top += idx+1; /* `subtract' index (index is negative) */
175 }
176 lua_unlock(L);
177}

◆ lua_setupvalue()

LUA_API const char * lua_setupvalue ( lua_State * L,
int funcindex,
int n )

Definition at line 1071 of file lua-5.1.5/src/lapi.c.

1071 {
1072 const char *name;
1073 TValue *val;
1074 StkId fi;
1075 lua_lock(L);
1076 fi = index2adr(L, funcindex);
1077 api_checknelems(L, 1);
1078 name = aux_upvalue(fi, n, &val);
1079 if (name) {
1080 L->top--;
1081 setobj(L, val, L->top);
1082 luaC_barrier(L, clvalue(fi), L->top);
1083 }
1084 lua_unlock(L);
1085 return name;
1086}

◆ lua_status()

LUA_API int lua_status ( lua_State * L)

Definition at line 890 of file lua-5.1.5/src/lapi.c.

890 {
891 return L->status;
892}

◆ lua_toboolean()

LUA_API int lua_toboolean ( lua_State * L,
int idx )

Definition at line 337 of file lua-5.1.5/src/lapi.c.

337 {
338 const TValue *o = index2adr(L, idx);
339 return !l_isfalse(o);
340}
#define l_isfalse(o)

◆ lua_tocfunction()

LUA_API lua_CFunction lua_tocfunction ( lua_State * L,
int idx )

Definition at line 379 of file lua-5.1.5/src/lapi.c.

379 {
380 StkId o = index2adr(L, idx);
381 return (!iscfunction(o)) ? NULL : clvalue(o)->c.f;
382}

◆ lua_tointeger()

LUA_API lua_Integer lua_tointeger ( lua_State * L,
int idx )

Definition at line 323 of file lua-5.1.5/src/lapi.c.

323 {
324 TValue n;
325 const TValue *o = index2adr(L, idx);
326 if (tonumber(o, &n)) {
327 lua_Integer res;
328 lua_Number num = nvalue(o);
329 lua_number2integer(res, num);
330 return res;
331 }
332 else
333 return 0;
334}
#define nvalue(o)
LUA_INTEGER lua_Integer
LUA_NUMBER lua_Number
#define lua_number2integer(i, d)

References index2adr(), lua_number2integer, nvalue, and tonumber.

◆ lua_tolstring()

LUA_API const char * lua_tolstring ( lua_State * L,
int idx,
size_t * len )

Definition at line 343 of file lua-5.1.5/src/lapi.c.

343 {
344 StkId o = index2adr(L, idx);
345 if (!ttisstring(o)) {
346 lua_lock(L); /* `luaV_tostring' may create a new string */
347 if (!luaV_tostring(L, o)) { /* conversion failed? */
348 if (len != NULL) *len = 0;
349 lua_unlock(L);
350 return NULL;
351 }
352 luaC_checkGC(L);
353 o = index2adr(L, idx); /* previous call may reallocate the stack */
354 lua_unlock(L);
355 }
356 if (len != NULL) *len = tsvalue(o)->len;
357 return svalue(o);
358}
#define ttisstring(o)
#define svalue(o)

◆ lua_tonumber()

LUA_API lua_Number lua_tonumber ( lua_State * L,
int idx )

Definition at line 313 of file lua-5.1.5/src/lapi.c.

313 {
314 TValue n;
315 const TValue *o = index2adr(L, idx);
316 if (tonumber(o, &n))
317 return nvalue(o);
318 else
319 return 0;
320}

References index2adr(), nvalue, and tonumber.

◆ lua_topointer()

LUA_API const void * lua_topointer ( lua_State * L,
int idx )

Definition at line 401 of file lua-5.1.5/src/lapi.c.

401 {
402 StkId o = index2adr(L, idx);
403 switch (ttype(o)) {
404 case LUA_TTABLE: return hvalue(o);
405 case LUA_TFUNCTION: return clvalue(o);
406 case LUA_TTHREAD: return thvalue(o);
407 case LUA_TUSERDATA:
409 return lua_touserdata(L, idx);
410 default: return NULL;
411 }
412}
LUA_API void * lua_touserdata(lua_State *L, int idx)
#define LUA_TLIGHTUSERDATA

◆ lua_tothread()

LUA_API lua_State * lua_tothread ( lua_State * L,
int idx )

Definition at line 395 of file lua-5.1.5/src/lapi.c.

395 {
396 StkId o = index2adr(L, idx);
397 return (!ttisthread(o)) ? NULL : thvalue(o);
398}
#define ttisthread(o)

◆ lua_touserdata()

LUA_API void * lua_touserdata ( lua_State * L,
int idx )

Definition at line 385 of file lua-5.1.5/src/lapi.c.

385 {
386 StkId o = index2adr(L, idx);
387 switch (ttype(o)) {
388 case LUA_TUSERDATA: return (rawuvalue(o) + 1);
389 case LUA_TLIGHTUSERDATA: return pvalue(o);
390 default: return NULL;
391 }
392}
#define pvalue(o)

◆ lua_type()

LUA_API int lua_type ( lua_State * L,
int idx )

Definition at line 242 of file lua-5.1.5/src/lapi.c.

242 {
243 StkId o = index2adr(L, idx);
244 return (o == luaO_nilobject) ? LUA_TNONE : ttype(o);
245}
#define LUA_TNONE

◆ lua_typename()

LUA_API const char * lua_typename ( lua_State * L,
int tp )

Definition at line 248 of file lua-5.1.5/src/lapi.c.

248 {
249 UNUSED(L);
250 return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
251}
#define UNUSED(x)
const char *const luaT_typenames[]

◆ lua_xmove()

LUA_API void lua_xmove ( lua_State * from,
lua_State * to,
int n )

Definition at line 110 of file lua-5.1.5/src/lapi.c.

110 {
111 int i;
112 if (from == to) return;
113 lua_lock(to);
114 api_checknelems(from, n);
115 api_check(from, G(from) == G(to));
116 api_check(from, to->ci->top - to->top >= n);
117 from->top -= n;
118 for (i = 0; i < n; i++) {
119 setobj2s(to, to->top++, from->top + i);
120 }
121 lua_unlock(to);
122}

◆ lua_yield()

LUA_API int lua_yield ( lua_State * L,
int nresults )

Definition at line 444 of file lua-5.1.5/src/ldo.c.

444 {
445 luai_userstateyield(L, nresults);
446 lua_lock(L);
447 if (L->nCcalls > L->baseCcalls)
448 luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
449 L->base = L->top - nresults; /* protect stack slots below */
450 L->status = LUA_YIELD;
451 lua_unlock(L);
452 return -1;
453}
#define luai_userstateyield(L, n)

References lua_State::base, lua_State::baseCcalls, lua_lock, lua_unlock, LUA_YIELD, luaG_runerror(), luai_userstateyield, lua_State::nCcalls, lua_State::status, and lua_State::top.