Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lapi.c File Reference
#include <assert.h>
#include <math.h>
#include <stdarg.h>
#include <string.h>
#include "lua.h"
#include "lapi.h"
#include "ldebug.h"
#include "ldo.h"
#include "lfunc.h"
#include "lgc.h"
#include "lmem.h"
#include "lobject.h"
#include "lstate.h"
#include "lstring.h"
#include "ltable.h"
#include "ltm.h"
#include "lundump.h"
#include "lvm.h"

Go to the source code of this file.

Data Structures

struct  CallS
 
struct  CCallS
 

Macros

#define lapi_c
 
#define LUA_CORE
 
#define api_checknelems(L, n)   api_check(L, (n) <= (L->top - L->base))
 
#define api_checkvalidindex(L, i)   api_check(L, (i) != luaO_nilobject)
 
#define api_incr_top(L)   {api_check(L, L->top < L->ci->top); L->top++;}
 
#define adjustresults(L, nres)    { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; }
 
#define checkresults(L, na, nr)    api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))
 

Functions

static TValueindex2adr (lua_State *L, int idx)
 
static Tablegetcurrenv (lua_State *L)
 
void luaA_pushobject (lua_State *L, const TValue *o)
 
LUA_API int lua_checkstack (lua_State *L, int size)
 
LUA_API void lua_xmove (lua_State *from, lua_State *to, int n)
 
LUA_API void lua_setlevel (lua_State *from, lua_State *to)
 
LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf)
 
LUA_API lua_Statelua_newthread (lua_State *L)
 
LUA_API int lua_gettop (lua_State *L)
 
LUA_API void lua_settop (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 void lua_pushvalue (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 t)
 
LUA_API int lua_iscfunction (lua_State *L, int idx)
 
LUA_API int lua_isnumber (lua_State *L, int idx)
 
LUA_API int lua_isstring (lua_State *L, int idx)
 
LUA_API int lua_isuserdata (lua_State *L, int idx)
 
LUA_API int lua_rawequal (lua_State *L, int index1, int index2)
 
LUA_API int lua_equal (lua_State *L, int index1, int index2)
 
LUA_API int lua_lessthan (lua_State *L, int index1, int index2)
 
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 len)
 
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 narray, int nrec)
 
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)
 
static void f_call (lua_State *L, void *ud)
 
LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc)
 
static void f_Ccall (lua_State *L, void *ud)
 
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 *data, const char *chunkname)
 
LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data)
 
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_newuserdata (lua_State *L, size_t size)
 
static const char * aux_upvalue (StkId fi, int n, TValue **val)
 
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)
 

Variables

const char lua_ident []
 

Macro Definition Documentation

◆ adjustresults

#define adjustresults ( L,
nres )    { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; }

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

768#define adjustresults(L,nres) \
769 { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; }

Referenced by finishCcall(), finishCcall(), finishCcall(), lua_call(), lua_callk(), lua_callk(), lua_pcall(), lua_pcallk(), and lua_pcallk().

◆ api_checknelems

◆ api_checkvalidindex

◆ api_incr_top

◆ checkresults

#define checkresults ( L,
na,
nr )    api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))

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

772#define checkresults(L,na,nr) \
773 api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))

Referenced by lua_call(), and lua_pcall().

◆ lapi_c

#define lapi_c

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

◆ LUA_CORE

#define LUA_CORE

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

Function Documentation

◆ aux_upvalue()

static const char * aux_upvalue ( StkId fi,
int n,
TValue ** val )
static

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

1039 {
1040 Closure *f;
1041 if (!ttisfunction(fi)) return NULL;
1042 f = clvalue(fi);
1043 if (f->c.isC) {
1044 if (!(1 <= n && n <= f->c.nupvalues)) return NULL;
1045 *val = &f->c.upvalue[n-1];
1046 return "";
1047 }
1048 else {
1049 Proto *p = f->l.p;
1050 if (!(1 <= n && n <= p->sizeupvalues)) return NULL;
1051 *val = f->l.upvals[n-1]->v;
1052 return getstr(p->upvalues[n-1]);
1053 }
1054}
#define NULL
Definition gmacros.h:924
#define ttisfunction(o)
#define clvalue(o)
#define getstr(ts)
struct Proto * p
TString ** upvalues

References Closure::c, clvalue, getstr, Closure::l, NULL, LClosure::p, ttisfunction, LClosure::upvals, CClosure::upvalue, Proto::upvalues, and UpVal::v.

Referenced by lua_getupvalue(), and lua_setupvalue().

◆ f_call()

static void f_call ( lua_State * L,
void * ud )
static

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

798 {
799 struct CallS *c = cast(struct CallS *, ud);
800 luaD_call(L, c->func, c->nresults);
801}
void luaD_call(lua_State *L, StkId func, int nResults)
#define cast(t, exp)

References cast, CallS::func, luaD_call(), and CallS::nresults.

Referenced by lua_pcall().

◆ f_Ccall()

static void f_Ccall ( lua_State * L,
void * ud )
static

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

837 {
838 struct CCallS *c = cast(struct CCallS *, ud);
839 Closure *cl;
840 cl = luaF_newCclosure(L, 0, getcurrenv(L));
841 cl->c.f = c->func;
842 setclvalue(L, L->top, cl); /* push function */
843 api_incr_top(L);
844 setpvalue(L->top, c->ud); /* push only argument */
845 api_incr_top(L);
846 luaD_call(L, L->top - 2, 0);
847}
static Table * getcurrenv(lua_State *L)
#define api_incr_top(L)
Closure * luaF_newCclosure(lua_State *L, int nelems, Table *e)
#define setpvalue(obj, x)
#define setclvalue(L, obj, x)
lua_CFunction func
lua_CFunction f

References api_incr_top, Closure::c, cast, CClosure::f, CCallS::func, getcurrenv(), luaD_call(), luaF_newCclosure(), setclvalue, setpvalue, lua_State::top, and CCallS::ud.

Referenced by lua_cpcall().

◆ getcurrenv()

static Table * getcurrenv ( lua_State * L)
static

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

79 {
80 if (L->ci == L->base_ci) /* no enclosing function? */
81 return hvalue(gt(L)); /* use global table as environment */
82 else {
83 Closure *func = curr_func(L);
84 return func->c.env;
85 }
86}
#define hvalue(o)
#define gt(L)
#define curr_func(L)

References lua_State::base_ci, Closure::c, lua_State::ci, curr_func, gt, and hvalue.

Referenced by f_Ccall(), lua_newuserdata(), and lua_pushcclosure().

◆ index2adr()

static TValue * index2adr ( lua_State * L,
int idx )
static

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

49 {
50 if (idx > 0) {
51 TValue *o = L->base + (idx - 1);
52 api_check(L, idx <= L->ci->top - L->base);
53 if (o >= L->top) return cast(TValue *, luaO_nilobject);
54 else return o;
55 }
56 else if (idx > LUA_REGISTRYINDEX) {
57 api_check(L, idx != 0 && -idx <= L->top - L->base);
58 return L->top + idx;
59 }
60 else switch (idx) { /* pseudo-indices */
61 case LUA_REGISTRYINDEX: return registry(L);
62 case LUA_ENVIRONINDEX: {
63 Closure *func = curr_func(L);
64 sethvalue(L, &L->env, func->c.env);
65 return &L->env;
66 }
67 case LUA_GLOBALSINDEX: return gt(L);
68 default: {
69 Closure *func = curr_func(L);
70 idx = LUA_GLOBALSINDEX - idx;
71 return (idx <= func->c.nupvalues)
72 ? &func->c.upvalue[idx-1]
74 }
75 }
76}
#define api_check
#define luaO_nilobject
#define sethvalue(L, obj, x)
#define registry(L)
#define LUA_REGISTRYINDEX
#define LUA_ENVIRONINDEX
#define LUA_GLOBALSINDEX

References api_check, lua_State::base, Closure::c, cast, curr_func, lua_State::env, gt, LUA_ENVIRONINDEX, LUA_GLOBALSINDEX, LUA_REGISTRYINDEX, luaO_nilobject, registry, sethvalue, lua_State::top, and CClosure::upvalue.

Referenced by lua_equal(), lua_getfenv(), lua_getfield(), lua_getmetatable(), lua_gettable(), lua_getupvalue(), lua_insert(), lua_iscfunction(), lua_isnumber(), lua_isuserdata(), lua_lessthan(), lua_next(), lua_objlen(), lua_pcall(), lua_pushvalue(), lua_rawequal(), lua_rawget(), lua_rawgeti(), lua_rawset(), lua_rawseti(), lua_remove(), lua_replace(), lua_setfenv(), lua_setfield(), lua_setmetatable(), lua_settable(), lua_setupvalue(), lua_toboolean(), lua_tocfunction(), lua_tointeger(), lua_tolstring(), lua_tonumber(), lua_topointer(), lua_tothread(), lua_touserdata(), and lua_type().

◆ 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)

References G, lua_lock, and lua_unlock.

Referenced by luaL_newstate().

◆ 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)

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 size )

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

References lua_State::base, lua_State::ci, lua_lock, lua_unlock, luaD_checkstack, LUAI_MAXCSTACK, CallInfo::top, and lua_State::top.

Referenced by auxresume(), auxresume(), auxresume(), auxresume(), checkstack(), checkstack(), checkstack(), db_do_next_row(), db_sql_normal_function(), dbvm_get_unames(), dbvm_get_utypes(), dbvm_get_uvalues(), finishpcall(), luaB_unpack(), luaL_checkstack(), luaL_checkstack(), pmain(), pmain(), pmain(), pmain(), tunpack(), unpack(), and unpack().

◆ 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 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)

References api_checknelems, api_incr_top, lua_State::base, cast_int, lua_lock, lua_unlock, luaC_checkGC, luaS_newlstr(), luaV_concat(), setsvalue2s, and lua_State::top.

Referenced by adjuststack(), db_errorfb(), findfield(), findfield(), findfield(), findfile(), ll_require(), loadline(), loadline(), luaB_auxwrap(), luaB_auxwrap(), luaB_auxwrap(), luaB_auxwrap(), luaB_error(), luaB_error(), luaB_error(), luaB_error(), luaL_error(), luaL_pushresult(), luaL_traceback(), multiline(), multiline(), and Xml_str().

◆ 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)

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_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 isLfunction(o)
static int writer(lua_State *L, const void *b, size_t size, void *B)

References api_checknelems, clvalue, isLfunction, lua_lock, lua_unlock, luaU_dump(), lua_State::top, and writer().

Referenced by str_dump(), str_dump(), str_dump(), and str_dump().

◆ lua_equal()

LUA_API int lua_equal ( lua_State * L,
int index1,
int index2 )

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 equalobj(L, o1, o2)

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

Referenced by Xml_iterate(), and Xml_match().

◆ lua_error()

◆ 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 LUA_GCSETPAUSE
#define LUA_GCCOUNT
#define LUA_GCCOLLECT
#define LUA_GCSTOP
#define LUA_GCRESTART
#define LUA_GCCOUNTB
#define LUA_GCSTEP
#define LUA_GCSETSTEPMUL

References cast, cast_int, G, global_State::gcpause, GCSpause, global_State::gcstate, global_State::gcstepmul, global_State::GCthreshold, LUA_GCCOLLECT, LUA_GCCOUNT, LUA_GCCOUNTB, LUA_GCRESTART, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL, LUA_GCSTEP, LUA_GCSTOP, lua_lock, lua_unlock, luaC_fullgc(), luaC_step(), MAX_LUMEM, and global_State::totalbytes.

Referenced by docall(), luaB_collectgarbage(), luaB_collectgarbage(), luaB_collectgarbage(), luaB_collectgarbage(), pmain(), pmain(), pmain(), and report().

◆ 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)

References G, lua_lock, lua_unlock, and CCallS::ud.

Referenced by resizebox(), and resizebox().

◆ 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 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)

References api_checkvalidindex, api_incr_top, index2adr(), lua_lock, lua_unlock, luaS_new, luaV_gettable, setsvalue, and lua_State::top.

Referenced by addtoclib(), aux_close(), checkclib(), checkclib(), db_gethook(), findfile(), findfile(), findfile(), findfile(), findloader(), findloader(), findloader(), g_iofile(), g_iofile(), g_iofile(), get_prompt(), getboolfield(), getboolfield(), getboolfield(), getboolfield(), getfield(), getfield(), getfield(), getfield(), getiofile(), getiofile(), getiofile(), hookf(), io_close(), io_close(), io_close(), io_lines(), io_lines(), io_lines(), io_type(), ll_addtoclib(), ll_checkclib(), ll_module(), ll_require(), ll_require(), ll_require(), ll_require(), loader_preload(), luaI_openlib(), luaL_checkudata(), luaL_getsubtable(), luaL_newmetatable(), luaL_requiref(), luaopen_io(), luaopen_math(), luaopen_package(), luaopen_string(), luaopen_table(), noenv(), noenv(), noenv(), pushglobalfuncname(), pushglobalfuncname(), searcher_preload(), searcher_preload(), searcher_preload(), and traceback().

◆ 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 LUA_TTABLE
struct Table * metatable

References api_incr_top, G, hvalue, index2adr(), lua_lock, LUA_TTABLE, LUA_TUSERDATA, lua_unlock, Table::metatable, NULL, sethvalue, lua_State::top, ttype, and uvalue.

Referenced by checktab(), checktab(), db_getmetatable(), db_getmetatable(), db_getmetatable(), db_getmetatable(), io_type(), ll_seeall(), luaB_getmetatable(), luaB_getmetatable(), luaB_getmetatable(), luaB_getmetatable(), luaB_newproxy(), luaL_checkudata(), luaL_getmetafield(), and luaL_testudata().

◆ 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}

References api_checkvalidindex, index2adr(), lua_lock, lua_unlock, luaV_gettable, and lua_State::top.

Referenced by add_value(), add_value(), add_value(), add_value(), dbvm_bind_names(), ll_register(), and Xml_pushDecode().

◆ 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}

References lua_State::base, cast_int, and lua_State::top.

Referenced by andaux(), aux_lines(), aux_lines(), aux_lines(), auxresume(), auxresume(), auxresume(), auxstatus(), b_or(), b_xor(), cleanupdb(), costatus(), db_busy_callback(), db_busy_handler(), db_commit_hook(), db_commit_hook_callback(), db_errorfb(), db_exec_callback(), db_progress_callback(), db_progress_handler(), db_rollback_hook(), db_rollback_hook_callback(), db_sql_finalize_function(), db_sql_normal_function(), db_trace(), db_trace_callback(), db_update_hook(), db_update_hook_callback(), dbvm_bind_values(), do_gsub(), docall(), docall(), docall(), docall(), dofilecont(), dofilecont(), dofilecont(), dotty(), dotty(), file_utime(), finishpcall(), finishpcall(), finishpcall(), g_read(), g_read(), g_read(), g_read(), g_write(), g_write(), g_write(), g_write(), io_lines(), l_print(), l_print(), ll_module(), loadline(), loadline(), luaB_assert(), luaB_assert(), luaB_assert(), luaB_assert(), luaB_auxwrap(), luaB_auxwrap(), luaB_auxwrap(), luaB_auxwrap(), luaB_coresume(), luaB_coresume(), luaB_coresume(), luaB_coresume(), luaB_costatus(), luaB_costatus(), luaB_dofile(), luaB_pcall(), luaB_pcall(), luaB_pcall(), luaB_pcall(), luaB_print(), luaB_print(), luaB_print(), luaB_print(), luaB_select(), luaB_select(), luaB_select(), luaB_select(), luaB_warn(), luaB_xpcall(), luaB_xpcall(), luaB_xpcall(), luaB_xpcall(), luaB_yield(), luaB_yield(), luaB_yield(), luaB_yield(), luaL_loadfile(), luaL_loadfilex(), luaL_traceback(), make_xml_object(), math_max(), math_max(), math_max(), math_max(), math_min(), math_min(), math_min(), math_min(), math_random(), math_random(), math_random(), math_random(), pack(), pack(), print(), pushglobalfuncname(), pushglobalfuncname(), pushglobalfuncname(), str_char(), str_char(), str_char(), str_char(), str_format(), str_format(), str_format(), str_format(), tinsert(), tinsert(), tinsert(), tinsert(), tpack(), utfchar(), utfchar(), Xml_eval(), and Xml_pushEncode().

◆ 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}
const char * name
Definition lsqlite3.c:2154
static const char * aux_upvalue(StkId fi, int n, TValue **val)

References api_incr_top, aux_upvalue(), index2adr(), lua_lock, lua_unlock, name, setobj2s, and lua_State::top.

Referenced by auxupvalue(), auxupvalue(), auxupvalue(), auxupvalue(), and checkupval().

◆ 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

References api_checkvalidindex, index2adr(), lua_lock, lua_unlock, setobjs2s, and lua_State::top.

◆ 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)

References index2adr(), and iscfunction.

Referenced by auxupvalue(), db_upvaluejoin(), db_upvaluejoin(), db_upvaluejoin(), luaB_cocreate(), luaB_getfenv(), luaB_setfenv(), and setfenv().

◆ 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)

References index2adr(), and tonumber.

Referenced by b_unpack(), db_errorfb(), db_exec_callback(), db_getinfo(), db_getinfo(), getfield(), interror(), interror(), luaB_setfenv(), luaB_tonumber(), luaL_checkinteger(), and luaL_checknumber().

◆ lua_isstring()

◆ 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)

References index2adr(), ttislightuserdata, and ttisuserdata.

Referenced by Xml_eval().

◆ lua_lessthan()

LUA_API int lua_lessthan ( lua_State * L,
int index1,
int index2 )

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 * data,
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_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)

References api_incr_top, lua_lock, lua_unlock, luaC_checkGC, luaE_newthread(), luai_userstatethread, setthvalue, and lua_State::top.

Referenced by luaB_cocreate(), luaB_cocreate(), luaB_cocreate(), and luaB_cocreate().

◆ lua_newuserdata()

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

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}
#define setuvalue(L, obj, x)
Udata * luaS_newudata(lua_State *L, size_t s, Table *e)

References api_incr_top, getcurrenv(), lua_lock, lua_unlock, luaC_checkGC, luaS_newudata(), setuvalue, and lua_State::top.

◆ 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 ttistable(o)
int luaH_next(lua_State *L, Table *t, StkId key)

References api_check, api_incr_top, hvalue, index2adr(), lua_lock, lua_unlock, luaH_next(), lua_State::top, and ttistable.

Referenced by cleanupdb(), db_close_vm(), findfield(), findfield(), findfield(), foreach(), luaB_next(), luaB_next(), luaB_next(), luaB_next(), maxn(), Xml_pushDecode(), Xml_pushEncode(), and Xml_str().

◆ 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)

References api_incr_top, lua_lock, lua_unlock, setbvalue, and lua_State::top.

Referenced by aux_lines(), aux_lines(), aux_lines(), aux_lines(), b_test(), change_dir(), db_getuservalue(), db_isopen(), db_load_extension(), db_register_function(), db_setmetatable(), dbvm_isopen(), file_lock(), file_unlock(), find_on_match(), finishpcall(), finishpcall(), finishpcall(), lfs_g_setmode(), ll_loadfunc(), ll_require(), ll_require(), ll_require(), ll_require(), lookforfunc(), lookforfunc(), lsqlite_complete(), luaB_close(), luaB_collectgarbage(), luaB_collectgarbage(), luaB_collectgarbage(), luaB_collectgarbage(), luaB_coresume(), luaB_coresume(), luaB_coresume(), luaB_coresume(), luaB_corunning(), luaB_corunning(), luaB_corunning(), luaB_newproxy(), luaB_pcall(), luaB_pcall(), luaB_pcall(), luaB_rawequal(), luaB_rawequal(), luaB_rawequal(), luaB_rawequal(), luaB_xpcall(), luaB_xpcall(), luaB_xpcall(), luaB_yieldable(), luaB_yieldable(), luaL_execresult(), luaL_fileresult(), luaL_setfuncs(), math_ult(), math_ult(), os_execute(), os_execute(), os_execute(), os_pushresult(), pmain(), pmain(), pmain(), pushresult(), pushresult(), setboolfield(), setboolfield(), setboolfield(), setboolfield(), settabsb(), settabsb(), settabsb(), Xml_find(), and Xml_iterate().

◆ lua_pushcclosure()

◆ 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)

References lua_lock, lua_unlock, luaC_checkGC, and luaO_pushvfstring().

Referenced by _file_info_(), addreturn(), addreturn(), auxresume(), change_dir(), checkoption(), checkoption(), checkoption(), controloptions(), db_errorfb(), db_getinfo(), db_getinfo(), db_getinfo(), db_getinfo(), db_last_insert_rowid(), db_tostring(), db_update_hook_callback(), dbvm_last_insert_rowid(), dbvm_tostring(), dotty(), dotty(), errfile(), errfile(), errfile(), errfile(), f_tostring(), f_tostring(), f_tostring(), file_lock(), file_unlock(), fileerror(), findfile(), io_tostring(), l_print(), l_print(), lcontext_tostring(), ll_register(), loader_Croot(), loader_preload(), loadfunc(), loadfunc(), loadfunc(), luaB_tostring(), luaL_checkoption(), luaL_checkoption(), luaL_fileresult(), luaL_loadfile(), luaL_loadfilex(), luaL_tolstring(), luaL_traceback(), luaL_typeerror(), luaL_typerror(), luaL_where(), mkfuncname(), msghandler(), msghandler(), os_pushresult(), pusherror(), pushfuncname(), pushfuncname(), pushfuncname(), pushline(), pushline(), pushline(), pushline(), pushresult(), pushutfchar(), pushutfchar(), searcher_Croot(), searcher_Croot(), searcher_Croot(), searcher_preload(), searcher_preload(), searcher_preload(), searchpath(), searchpath(), setpath(), setpath(), typeerror(), typeerror(), and Xml_str().

◆ 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)

References api_incr_top, cast_num, lua_lock, lua_unlock, setnvalue, and lua_State::top.

Referenced by _file_info_(), aux_lines(), aux_lines(), aux_lines(), b_size(), b_unpack(), byteoffset(), byteoffset(), cleanupbu(), cleanupvm(), codepoint(), codepoint(), db_busy_callback(), db_changes(), db_close(), db_errcode(), db_exec(), db_exec_callback(), db_gethook(), db_gethook(), db_gethook(), db_gethook(), db_prepare(), db_setcstacklimit(), db_total_changes(), db_update_hook_callback(), dbbu_pagecount(), dbbu_remaining(), dbbu_step(), dbvm_bind(), dbvm_bind_blob(), dbvm_bind_names(), dbvm_bind_parameter_count(), dbvm_bind_values(), dbvm_columns(), dbvm_reset(), dbvm_step(), f_seek(), f_seek(), f_seek(), foreachi(), get_onecapture(), getn(), gmatch(), gmatch(), gmatch_aux(), gmatch_aux(), hookf(), hookf(), hookf(), hookf(), ipairsaux(), ipairsaux(), ipairsaux(), ipairsaux(), iter_aux(), iter_aux(), iter_codes(), iter_codes(), lcontext_aggregate_count(), lsqlite_do_open(), luaB_collectgarbage(), luaB_collectgarbage(), luaB_collectgarbage(), luaB_gcinfo(), luaB_ipairs(), luaB_ipairs(), luaB_ipairs(), luaB_rawlen(), luaB_rawlen(), luaB_rawlen(), luaB_select(), luaB_select(), luaB_select(), luaB_select(), luaB_tonumber(), luaB_tonumber(), luaL_execresult(), luaL_fileresult(), luaL_ref(), luaL_unref(), luaopen_lsqlite3(), luaopen_LuaXML_lib(), luaopen_math(), main(), main(), math_abs(), math_abs(), math_fmod(), math_fmod(), math_frexp(), math_frexp(), math_random(), math_random(), math_toint(), math_toint(), os_execute(), os_pushresult(), pack(), pack(), pairsmeta(), pairsmeta(), push_onecapture(), push_onecapture(), push_onecapture(), push_st_atime(), push_st_blksize(), push_st_blocks(), push_st_ctime(), push_st_dev(), push_st_gid(), push_st_ino(), push_st_mtime(), push_st_nlink(), push_st_rdev(), push_st_size(), push_st_uid(), push_TAG_key(), pusherror(), pushnumint(), pushnumint(), pushresult(), setfield(), setfield(), setfield(), setfield(), setseed(), settabsi(), settabsi(), settabsi(), settabsi(), str_byte(), str_byte(), str_byte(), str_byte(), str_find_aux(), str_find_aux(), str_find_aux(), str_find_aux(), str_gsub(), str_gsub(), str_gsub(), str_gsub(), str_len(), str_len(), str_len(), str_len(), str_packsize(), str_packsize(), str_unpack(), str_unpack(), tpack(), traceback(), utflen(), utflen(), Xml_iterate(), and Xml_str().

◆ lua_pushlightuserdata()

◆ lua_pushlstring()

◆ 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}

References api_incr_top, lua_lock, lua_unlock, setnilvalue, and lua_State::top.

Referenced by _file_info_(), b_pack(), byteoffset(), change_dir(), cleanupbu(), cleanupdb(), cleanupvm(), db_close_vm(), db_exec(), db_gethook(), db_getinfo(), db_getinfo(), db_getinfo(), db_getlocal(), db_getlocal(), db_getlocal(), db_getmetatable(), db_getmetatable(), db_getmetatable(), db_getmetatable(), db_getuservalue(), db_getuservalue(), db_prepare(), db_push_value(), db_sql_finalize_function(), dir_iter(), dir_iter_factory(), file_lock(), file_unlock(), findfield(), findfield(), findfield(), foreach(), g_read(), g_read(), g_read(), get_dir(), hookf(), hookf(), hookf(), hookf(), io_lines(), io_lines(), io_lines(), io_noclose(), io_noclose(), io_noclose(), io_type(), io_type(), io_type(), lfs_g_setmode(), lfs_lock_dir(), ll_loadlib(), ll_loadlib(), ll_loadlib(), ll_searchpath(), ll_searchpath(), load_aux(), load_aux(), load_aux(), lsqlite_do_open(), lua_pushstring(), luaB_corunning(), luaB_getmetatable(), luaB_getmetatable(), luaB_getmetatable(), luaB_getmetatable(), luaB_next(), luaB_next(), luaB_next(), luaB_next(), luaB_pairs(), luaB_pairs(), luaB_pcall(), luaB_tonumber(), luaB_tonumber(), luaB_tonumber(), luaL_execresult(), luaL_fileresult(), make_link(), math_toint(), math_type(), maxn(), os_date(), os_date(), os_pushresult(), os_time(), os_time(), pairsmeta(), pairsmeta(), pusherror(), pushresult(), read_number(), read_number(), read_number(), read_number(), str_find_aux(), str_find_aux(), str_find_aux(), str_pack(), str_pack(), tremove(), tremove(), tremove(), tremove(), utflen(), vm_push_column(), Xml_pushDecode(), Xml_pushEncode(), and Xml_str().

◆ 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}

References api_incr_top, lua_lock, lua_unlock, setnvalue, and lua_State::top.

Referenced by b_unpack(), db_push_value(), f_seek(), luaB_collectgarbage(), luaB_collectgarbage(), luaB_collectgarbage(), luaB_collectgarbage(), luaB_tonumber(), luaB_tonumber(), luaL_checkversion_(), luaopen_math(), math_abs(), math_abs(), math_abs(), math_abs(), math_acos(), math_acos(), math_acos(), math_acos(), math_asin(), math_asin(), math_asin(), math_asin(), math_atan(), math_atan(), math_atan(), math_atan(), math_atan2(), math_atan2(), math_ceil(), math_ceil(), math_cos(), math_cos(), math_cos(), math_cos(), math_cosh(), math_cosh(), math_deg(), math_deg(), math_deg(), math_deg(), math_exp(), math_exp(), math_exp(), math_exp(), math_floor(), math_floor(), math_fmod(), math_fmod(), math_fmod(), math_fmod(), math_frexp(), math_frexp(), math_ldexp(), math_ldexp(), math_log(), math_log(), math_log(), math_log(), math_log10(), math_max(), math_max(), math_min(), math_min(), math_modf(), math_modf(), math_modf(), math_modf(), math_pow(), math_pow(), math_rad(), math_rad(), math_rad(), math_rad(), math_random(), math_random(), math_random(), math_random(), math_sin(), math_sin(), math_sin(), math_sin(), math_sinh(), math_sinh(), math_sqrt(), math_sqrt(), math_sqrt(), math_sqrt(), math_tan(), math_tan(), math_tan(), math_tan(), math_tanh(), math_tanh(), maxn(), os_clock(), os_clock(), os_clock(), os_clock(), os_difftime(), os_difftime(), os_difftime(), os_difftime(), os_time(), os_time(), pushnumint(), pushnumint(), read_number(), read_number(), str_unpack(), str_unpack(), and vm_push_column().

◆ 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)

References lua_pushlstring(), lua_pushnil(), NULL, and s.

Referenced by _file_info_(), auxupvalue(), auxupvalue(), auxupvalue(), auxupvalue(), checkfield(), checkfield(), checkload(), checkload(), checkload(), create_meta(), createargtable(), createargtable(), db_db_filename(), db_do_next_row(), db_do_rows(), db_errmsg(), db_exec_callback(), db_gethook(), db_gethook(), db_gethook(), db_gethook(), db_getlocal(), db_getlocal(), db_getlocal(), db_getlocal(), db_load_extension(), db_prepare(), db_sethook(), db_sethook(), db_setlocal(), db_setlocal(), db_setlocal(), db_setlocal(), db_trace_callback(), db_update_hook_callback(), dbvm_bind_names(), dbvm_bind_parameter_name(), dbvm_get_name(), dbvm_get_named_types(), dbvm_get_named_values(), dbvm_get_names(), dbvm_get_type(), dbvm_get_types(), dbvm_get_unames(), dbvm_get_utypes(), dir_iter(), dolibrary(), dolibrary(), dolibrary(), dolibrary(), findloader(), findloader(), findloader(), finishpcall(), get_dir(), getargs(), getargs(), hookf(), hookf(), hookf(), hookf(), lfs_g_setmode(), lfs_lock_dir(), ll_loadlib(), ll_loadlib(), ll_loadlib(), ll_loadlib(), ll_require(), ll_require(), ll_require(), lsqlite_do_open(), lsqlite_lversion(), lsqlite_temp_directory(), lsqlite_version(), luaB_costatus(), luaB_costatus(), luaB_tostring(), luaB_type(), luaB_type(), luaB_type(), luaB_type(), luaL_execresult(), luaL_fileresult(), luaL_getmetafield(), luaL_newmetatable(), luaL_openlibs(), luaL_requiref(), luaL_tolstring(), luaopen_lsqlite3(), make_link(), math_type(), mg_start2(), modinit(), os_getenv(), os_getenv(), os_getenv(), os_getenv(), os_setlocale(), os_setlocale(), os_setlocale(), os_setlocale(), os_tmpname(), os_tmpname(), os_tmpname(), os_tmpname(), push_st_mode(), push_st_perm(), pusherror(), pushglobalfuncname(), pushglobalfuncname(), pushline(), pushline(), pushmode(), searcher_Croot(), searcher_Croot(), searcher_Croot(), searchpath(), setpath(), setpath(), setpath(), setpath(), settabss(), settabss(), settabss(), settabss(), and Xml_eval().

◆ lua_pushthread()

LUA_API int lua_pushthread ( lua_State * L)

◆ 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}

References api_incr_top, index2adr(), lua_lock, lua_unlock, setobj2s, and lua_State::top.

Referenced by add_value(), add_value(), add_value(), add_value(), addtoclib(), addtoclib(), aux_lines(), aux_lines(), aux_lines(), auxsort(), auxsort(), auxsort(), auxsort(), base_open(), checkupval(), create_meta(), createmeta(), createmeta(), createmeta(), createmetatable(), createmetatable(), createmetatable(), createmetatable(), createsearcherstable(), createsearcherstable(), createsearcherstable(), createstdfile(), createstdfile(), createstdfile(), createstdfile(), db_exec_callback(), db_getinfo(), db_getinfo(), db_getinfo(), db_getinfo(), db_getlocal(), db_getlocal(), db_getlocal(), db_getlocal(), db_getregistry(), db_getregistry(), db_getregistry(), db_getregistry(), db_register_function(), db_sethook(), db_sethook(), db_sethook(), db_sethook(), db_sql_finalize_function(), db_sql_normal_function(), db_traceback(), db_traceback(), db_traceback(), dbvm_do_rows(), dir_iter_factory(), dooptions(), f_write(), f_write(), f_write(), finishpcall(), finishpcall(), foreach(), foreachi(), g_iofile(), g_iofile(), g_iofile(), g_iofile(), generic_reader(), generic_reader(), generic_reader(), generic_reader(), getfunc(), gethooktable(), io_lines(), io_readline(), io_readline(), io_readline(), io_readline(), iter_codes(), iter_codes(), ll_addtoclib(), ll_module(), ll_register(), ll_require(), ll_require(), ll_require(), ll_require(), ll_seeall(), load_aux(), load_aux(), load_aux(), lsqlite_backup_init(), luaB_cocreate(), luaB_cocreate(), luaB_cocreate(), luaB_cocreate(), luaB_error(), luaB_error(), luaB_error(), luaB_error(), luaB_getfenv(), luaB_ipairs(), luaB_ipairs(), luaB_ipairs(), luaB_newproxy(), luaB_pairs(), luaB_pairs(), luaB_print(), luaB_print(), luaB_print(), luaB_setfenv(), luaB_tostring(), luaB_xpcall(), luaB_xpcall(), luaB_xpcall(), luaI_openlib(), luaL_callmeta(), luaL_findtable(), luaL_getsubtable(), luaL_newmetatable(), luaL_requiref(), luaL_setfuncs(), luaL_tolstring(), luaopen_base(), luaopen_lfs(), luaopen_lsqlite3(), luaopen_LuaXML_lib(), luaopen_package(), luaopen_struct(), math_max(), math_max(), math_min(), math_min(), modinit(), newvm(), pack(), pairsmeta(), pairsmeta(), setfenv(), setn(), sort_comp(), sort_comp(), sort_comp(), sort_comp(), str_format(), str_gsub(), tmove(), tmove(), tonum(), traceback(), treatstackoption(), treatstackoption(), Xml_append(), Xml_eval(), Xml_find(), Xml_iterate(), Xml_match(), Xml_new(), Xml_pushEncode(), Xml_str(), and Xml_tag().

◆ 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}

References lua_lock, lua_unlock, luaC_checkGC, and luaO_pushvfstring().

Referenced by luaL_error().

◆ lua_rawequal()

LUA_API int lua_rawequal ( lua_State * L,
int index1,
int index2 )

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)

References index2adr(), luaO_nilobject, and luaO_rawequalObj().

Referenced by findfield(), findfield(), findfield(), io_type(), luaB_rawequal(), luaB_rawequal(), luaB_rawequal(), luaB_rawequal(), luaL_checkudata(), and luaL_testudata().

◆ lua_rawget()

◆ lua_rawgeti()

◆ lua_rawset()

◆ lua_rawseti()

◆ 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}

References api_checkvalidindex, index2adr(), lua_lock, lua_unlock, setobjs2s, and lua_State::top.

◆ 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)

References api_check, api_checknelems, api_checkvalidindex, lua_State::base_ci, Closure::c, lua_State::ci, curr_func, hvalue, index2adr(), LUA_ENVIRONINDEX, LUA_GLOBALSINDEX, lua_lock, lua_unlock, luaC_barrier, luaG_runerror(), setobj, lua_State::top, and ttistable.

◆ 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}

References G, lua_lock, lua_unlock, and CCallS::ud.

◆ 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)

References api_checknelems, api_checkvalidindex, index2adr(), lua_lock, lua_unlock, luaS_new, luaV_settable, setsvalue, and lua_State::top.

Referenced by addtoclib(), addtoclib(), auxopen(), base_open(), createclibstable(), createclibstable(), createmeta(), createmeta(), createmeta(), createmeta(), createmetatable(), createmetatable(), createmetatable(), createmetatable(), createsearcherstable(), createsearcherstable(), createstdfile(), createstdfile(), createstdfile(), createstdfile(), db_getinfo(), db_sethook(), db_sethook(), db_sethook(), dir_create_meta(), g_iofile(), g_iofile(), g_iofile(), link_info(), ll_addtoclib(), ll_module(), ll_require(), ll_require(), ll_require(), ll_require(), ll_seeall(), lock_create_meta(), luaI_openlib(), luaL_getsubtable(), luaL_newmetatable(), luaL_openlibs(), luaL_requiref(), luaL_setfuncs(), luaopen_base(), luaopen_LuaXML_lib(), luaopen_math(), luaopen_package(), luaopen_string(), luaopen_utf8(), modinit(), newbox(), newfenv(), pack(), pack(), pmain(), pmain(), pmain(), set_info(), setboolfield(), setboolfield(), setboolfield(), setboolfield(), setfield(), setfield(), setfield(), setfield(), setpath(), setpath(), setpath(), setpath(), settabsb(), settabsb(), settabsb(), settabsi(), settabsi(), settabsi(), settabsi(), settabss(), settabss(), settabss(), settabss(), tpack(), treatstackoption(), treatstackoption(), treatstackoption(), and treatstackoption().

◆ 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}
unsigned short nCcalls

References lua_State::nCcalls.

Referenced by auxresume().

◆ 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)

References api_check, api_checknelems, api_checkvalidindex, G, hvalue, index2adr(), lua_lock, LUA_TTABLE, LUA_TUSERDATA, lua_unlock, luaC_objbarrier, luaC_objbarriert, NULL, rawuvalue, lua_State::top, ttisnil, ttistable, ttype, and uvalue.

Referenced by base_open(), createclibstable(), createclibstable(), createmetatable(), createmetatable(), createmetatable(), createmetatable(), db_sethook(), db_sethook(), db_sethook(), db_setmetatable(), db_setmetatable(), db_setmetatable(), db_setmetatable(), dir_iter_factory(), lfs_lock_dir(), ll_register(), ll_seeall(), lsqlite_backup_init(), lsqlite_make_context(), luaB_newproxy(), luaB_setmetatable(), luaB_setmetatable(), luaB_setmetatable(), luaB_setmetatable(), luaL_setmetatable(), luaopen_lsqlite3(), luaopen_package(), make_xml_object(), newbox(), newbox(), newdb(), newfile(), and newvm().

◆ 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}

References api_checknelems, api_checkvalidindex, index2adr(), lua_lock, lua_unlock, luaV_settable, and lua_State::top.

Referenced by ll_register(), and luaL_findtable().

◆ 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}

References api_check, lua_State::base, lua_lock, lua_unlock, setnilvalue, and lua_State::top.

Referenced by _file_info_(), cleanupdb(), db_busy_callback(), db_busy_handler(), db_commit_hook(), db_commit_hook_callback(), db_create_collation(), db_debug(), db_debug(), db_debug(), db_debug(), db_do_rows(), db_exec(), db_exec_callback(), db_prepare(), db_progress_callback(), db_progress_handler(), db_register_function(), db_rollback_hook(), db_rollback_hook_callback(), db_setfenv(), db_sethook(), db_sethook(), db_sethook(), db_sethook(), db_setlocal(), db_setlocal(), db_setlocal(), db_setlocal(), db_setmetatable(), db_setmetatable(), db_setmetatable(), db_setmetatable(), db_setuservalue(), db_setuservalue(), db_setuservalue(), db_sql_finalize_function(), db_sql_normal_function(), db_trace(), db_trace_callback(), db_update_hook(), db_update_hook_callback(), doREPL(), doREPL(), dotty(), dotty(), find_on_match(), finishpcall(), gmatch(), gmatch(), gmatch(), gmatch(), io_readline(), io_readline(), io_readline(), io_readline(), lcontext_set_aggregate_context(), ll_require(), ll_require(), ll_require(), ll_require(), loadline(), loadline(), loadline(), loadline(), luaB_assert(), luaB_assert(), luaB_dofile(), luaB_dofile(), luaB_dofile(), luaB_error(), luaB_error(), luaB_error(), luaB_error(), luaB_load(), luaB_load(), luaB_load(), luaB_load(), luaB_newproxy(), luaB_next(), luaB_next(), luaB_next(), luaB_next(), luaB_rawget(), luaB_rawget(), luaB_rawget(), luaB_rawget(), luaB_rawset(), luaB_rawset(), luaB_rawset(), luaB_rawset(), luaB_setmetatable(), luaB_setmetatable(), luaB_setmetatable(), luaB_setmetatable(), luaB_tonumber(), luaB_tonumber(), luaB_xpcall(), luaL_loadfile(), luaL_loadfilex(), math_ceil(), math_ceil(), math_floor(), math_floor(), math_modf(), math_modf(), os_time(), os_time(), os_time(), os_time(), pushglobalfuncname(), pushglobalfuncname(), pushglobalfuncname(), sort(), sort(), sort(), sort(), str_dump(), str_dump(), str_dump(), str_dump(), trymt(), Xml_append(), Xml_eval(), Xml_find(), Xml_iterate(), Xml_match(), Xml_new(), Xml_registerCode(), Xml_str(), and Xml_tag().

◆ 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}

References api_checknelems, aux_upvalue(), clvalue, index2adr(), lua_lock, lua_unlock, luaC_barrier, name, setobj, and lua_State::top.

Referenced by auxupvalue(), auxupvalue(), auxupvalue(), auxupvalue(), load_aux(), load_aux(), and load_aux().

◆ 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}

References lua_State::status.

Referenced by auxresume(), auxresume(), auxstatus(), costatus(), luaB_auxwrap(), luaB_costatus(), and luaB_costatus().

◆ lua_toboolean()

◆ 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}

References clvalue, index2adr(), iscfunction, and NULL.

Referenced by aux_close().

◆ 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)

References index2adr(), lua_lock, lua_unlock, luaC_checkGC, luaV_tostring(), NULL, svalue, tsvalue, and ttisstring.

Referenced by add_s(), add_s(), add_s(), add_s(), addliteral(), addliteral(), generic_reader(), generic_reader(), generic_reader(), generic_reader(), gmatch_aux(), gmatch_aux(), incomplete(), incomplete(), incomplete(), incomplete(), loadline(), log_access(), luaB_load(), luaB_load(), luaB_load(), luaB_print(), luaB_print(), luaB_tonumber(), luaB_tonumber(), luaL_addvalue(), luaL_checklstring(), luaL_checklstring(), luaL_tolstring(), multiline(), multiline(), and tonum().

◆ 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

References clvalue, hvalue, index2adr(), LUA_TFUNCTION, LUA_TLIGHTUSERDATA, lua_touserdata(), LUA_TTABLE, LUA_TTHREAD, LUA_TUSERDATA, NULL, thvalue, and ttype.

Referenced by luaB_tostring(), luaL_tolstring(), print(), and str_format().

◆ lua_tothread()

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

◆ lua_touserdata()

◆ lua_type()

◆ lua_typename()

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

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[]

References LUA_TNONE, luaT_typenames, and UNUSED.

Referenced by dbvm_bind_index(), lcontext_result(), luaB_type(), luaB_type(), tag_error(), tag_error(), tag_error(), tag_error(), and Xml_str().

◆ lua_xmove()

◆ luaA_pushobject()

void luaA_pushobject ( lua_State * L,
const TValue * o )

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

89 {
90 setobj2s(L, L->top, o);
91 api_incr_top(L);
92}

References api_incr_top, setobj2s, and lua_State::top.

Referenced by lua_getlocal().

Variable Documentation

◆ lua_ident

const char lua_ident[]
Initial value:
=
"$Lua: " LUA_RELEASE " " LUA_COPYRIGHT " $\n"
"$Authors: " LUA_AUTHORS " $\n"
"$URL: www.lua.org $\n"
#define LUA_COPYRIGHT
#define LUA_AUTHORS
#define LUA_RELEASE

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