Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
ldblib.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"

Go to the source code of this file.

Macros

#define ldblib_c
 
#define LUA_LIB
 
#define HOOKKEY   "_HKEY"
 
#define gethooktable(L)   luaL_getsubtable(L, LUA_REGISTRYINDEX, HOOKKEY)
 

Functions

static void checkstack (lua_State *L, lua_State *L1, int n)
 
static int db_getregistry (lua_State *L)
 
static int db_getmetatable (lua_State *L)
 
static int db_setmetatable (lua_State *L)
 
static int db_getuservalue (lua_State *L)
 
static int db_setuservalue (lua_State *L)
 
static void settabss (lua_State *L, const char *i, const char *v)
 
static void settabsi (lua_State *L, const char *i, int v)
 
static void settabsb (lua_State *L, const char *i, int v)
 
static lua_Stategetthread (lua_State *L, int *arg)
 
static void treatstackoption (lua_State *L, lua_State *L1, const char *fname)
 
static int db_getinfo (lua_State *L)
 
static int db_getlocal (lua_State *L)
 
static int db_setlocal (lua_State *L)
 
static int auxupvalue (lua_State *L, int get)
 
static int db_getupvalue (lua_State *L)
 
static int db_setupvalue (lua_State *L)
 
static int checkupval (lua_State *L, int argf, int argnup)
 
static int db_upvalueid (lua_State *L)
 
static int db_upvaluejoin (lua_State *L)
 
static void hookf (lua_State *L, lua_Debug *ar)
 
static int makemask (const char *smask, int count)
 
static char * unmakemask (int mask, char *smask)
 
static int db_sethook (lua_State *L)
 
static int db_gethook (lua_State *L)
 
static int db_debug (lua_State *L)
 
static int db_traceback (lua_State *L)
 
LUAMOD_API int luaopen_debug (lua_State *L)
 

Variables

static const luaL_Reg dblib []
 

Macro Definition Documentation

◆ gethooktable

#define gethooktable ( L)    luaL_getsubtable(L, LUA_REGISTRYINDEX, HOOKKEY)

Definition at line 264 of file lua-5.2.4/src/ldblib.c.

Referenced by db_gethook(), db_gethook(), db_sethook(), db_sethook(), and hookf().

◆ HOOKKEY

#define HOOKKEY   "_HKEY"

Definition at line 21 of file lua-5.2.4/src/ldblib.c.

◆ ldblib_c

#define ldblib_c

Definition at line 12 of file lua-5.2.4/src/ldblib.c.

◆ LUA_LIB

#define LUA_LIB

Definition at line 13 of file lua-5.2.4/src/ldblib.c.

Function Documentation

◆ auxupvalue()

static int auxupvalue ( lua_State * L,
int get )
static

Definition at line 213 of file lua-5.2.4/src/ldblib.c.

213 {
214 const char *name;
215 int n = luaL_checkint(L, 2);
217 name = get ? lua_getupvalue(L, 1, n) : lua_setupvalue(L, 1, n);
218 if (name == NULL) return 0;
220 lua_insert(L, -(get+1));
221 return get + 1;
222}
#define NULL
Definition gmacros.h:924
const char * name
Definition lsqlite3.c:2154
LUA_API void lua_pushstring(lua_State *L, const char *s)
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)
LUALIB_API void luaL_checktype(lua_State *L, int narg, int t)
#define luaL_checkint(L, n)
#define LUA_TFUNCTION
#define lua_insert(L, idx)

References lua_getupvalue(), lua_insert, lua_pushstring(), lua_setupvalue(), LUA_TFUNCTION, luaL_checkint, luaL_checktype(), name, and NULL.

Referenced by db_getupvalue(), and db_setupvalue().

◆ checkstack()

static void checkstack ( lua_State * L,
lua_State * L1,
int n )
static

Definition at line 24 of file lua-5.2.4/src/ldblib.c.

24 {
25 if (L != L1 && !lua_checkstack(L1, n))
26 luaL_error(L, "stack overflow");
27}
LUA_API int lua_checkstack(lua_State *L, int size)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)

References lua_checkstack(), and luaL_error().

Referenced by db_gethook(), db_getinfo(), db_getlocal(), db_sethook(), and db_setlocal().

◆ checkupval()

static int checkupval ( lua_State * L,
int argf,
int argnup )
static

Definition at line 236 of file lua-5.2.4/src/ldblib.c.

236 {
237 lua_Debug ar;
238 int nup = luaL_checkint(L, argnup);
240 lua_pushvalue(L, argf);
241 lua_getinfo(L, ">u", &ar);
242 luaL_argcheck(L, 1 <= nup && nup <= ar.nups, argnup, "invalid upvalue index");
243 return nup;
244}
LUA_API void lua_pushvalue(lua_State *L, int idx)
#define luaL_argcheck(L, cond, numarg, extramsg)
LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)

References lua_getinfo(), lua_pushvalue(), LUA_TFUNCTION, luaL_argcheck, luaL_checkint, luaL_checktype(), and lua_Debug::nups.

Referenced by db_upvalueid(), and db_upvaluejoin().

◆ db_debug()

static int db_debug ( lua_State * L)
static

Definition at line 354 of file lua-5.2.4/src/ldblib.c.

354 {
355 for (;;) {
356 char buffer[250];
357 luai_writestringerror("%s", "lua_debug> ");
358 if (fgets(buffer, sizeof(buffer), stdin) == 0 ||
359 strcmp(buffer, "cont\n") == 0)
360 return 0;
361 if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") ||
362 lua_pcall(L, 0, 0, 0))
363 luai_writestringerror("%s\n", lua_tostring(L, -1));
364 lua_settop(L, 0); /* remove eventual returns */
365 }
366}
LUA_API void lua_settop(lua_State *L, int idx)
#define lua_tostring(L, i)
#define luaL_loadbuffer(L, s, sz, n)
#define lua_pcall(L, n, r, f)
#define luai_writestringerror(s, p)

References lua_pcall, lua_settop(), lua_tostring, luai_writestringerror, and luaL_loadbuffer.

◆ db_gethook()

static int db_gethook ( lua_State * L)
static

Definition at line 333 of file lua-5.2.4/src/ldblib.c.

333 {
334 int arg;
335 lua_State *L1 = getthread(L, &arg);
336 char buff[5];
337 int mask = lua_gethookmask(L1);
338 lua_Hook hook = lua_gethook(L1);
339 if (hook != NULL && hook != hookf) /* external hook? */
340 lua_pushliteral(L, "external hook");
341 else {
342 gethooktable(L);
343 checkstack(L, L1, 1);
344 lua_pushthread(L1); lua_xmove(L1, L, 1);
345 lua_rawget(L, -2); /* get hook */
346 lua_remove(L, -2); /* remove hook table */
347 }
348 lua_pushstring(L, unmakemask(mask, buff));
350 return 3;
351}
CURL_EXTERN int void * arg
Definition curl.h:2622
LUA_API int lua_pushthread(lua_State *L)
LUA_API void lua_rawget(lua_State *L, int idx)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
LUA_API void lua_xmove(lua_State *from, lua_State *to, int n)
LUA_API int lua_gethookmask(lua_State *L)
LUA_API int lua_gethookcount(lua_State *L)
LUA_API lua_Hook lua_gethook(lua_State *L)
#define lua_pushliteral(L, s)
void(* lua_Hook)(lua_State *L, lua_Debug *ar)
#define mask(n)
static lua_State * getthread(lua_State *L, int *arg)
static void hookf(lua_State *L, lua_Debug *ar)
#define gethooktable(L)
static char * unmakemask(int mask, char *smask)
static void checkstack(lua_State *L, lua_State *L1, int n)
#define lua_remove(L, idx)

References arg, checkstack(), gethooktable, getthread(), hookf(), lua_gethook(), lua_gethookcount(), lua_gethookmask(), lua_pushinteger(), lua_pushliteral, lua_pushstring(), lua_pushthread(), lua_rawget(), lua_remove, lua_xmove(), mask, NULL, and unmakemask().

◆ db_getinfo()

static int db_getinfo ( lua_State * L)
static

Definition at line 117 of file lua-5.2.4/src/ldblib.c.

117 {
118 lua_Debug ar;
119 int arg;
120 lua_State *L1 = getthread(L, &arg);
121 const char *options = luaL_optstring(L, arg+2, "flnStu");
122 checkstack(L, L1, 3);
123 if (lua_isnumber(L, arg+1)) {
124 if (!lua_getstack(L1, (int)lua_tointeger(L, arg+1), &ar)) {
125 lua_pushnil(L); /* level out of range */
126 return 1;
127 }
128 }
129 else if (lua_isfunction(L, arg+1)) {
130 lua_pushfstring(L, ">%s", options);
131 options = lua_tostring(L, -1);
132 lua_pushvalue(L, arg+1);
133 lua_xmove(L, L1, 1);
134 }
135 else
136 return luaL_argerror(L, arg+1, "function or level expected");
137 if (!lua_getinfo(L1, options, &ar))
138 return luaL_argerror(L, arg+2, "invalid option");
139 lua_createtable(L, 0, 2);
140 if (strchr(options, 'S')) {
141 settabss(L, "source", ar.source);
142 settabss(L, "short_src", ar.short_src);
143 settabsi(L, "linedefined", ar.linedefined);
144 settabsi(L, "lastlinedefined", ar.lastlinedefined);
145 settabss(L, "what", ar.what);
146 }
147 if (strchr(options, 'l'))
148 settabsi(L, "currentline", ar.currentline);
149 if (strchr(options, 'u')) {
150 settabsi(L, "nups", ar.nups);
151 settabsi(L, "nparams", ar.nparams);
152 settabsb(L, "isvararg", ar.isvararg);
153 }
154 if (strchr(options, 'n')) {
155 settabss(L, "name", ar.name);
156 settabss(L, "namewhat", ar.namewhat);
157 }
158 if (strchr(options, 't'))
159 settabsb(L, "istailcall", ar.istailcall);
160 if (strchr(options, 'L'))
161 treatstackoption(L, L1, "activelines");
162 if (strchr(options, 'f'))
163 treatstackoption(L, L1, "func");
164 return 1; /* return table */
165}
LUA_API void lua_pushnil(lua_State *L)
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
LUA_API int lua_isnumber(lua_State *L, int idx)
LUALIB_API int luaL_argerror(lua_State *L, int narg, const char *extramsg)
#define luaL_optstring(L, n, d)
LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar)
#define lua_isfunction(L, n)
static void settabsi(lua_State *L, const char *i, int v)
static void treatstackoption(lua_State *L, lua_State *L1, const char *fname)
static void settabsb(lua_State *L, const char *i, int v)
static void settabss(lua_State *L, const char *i, const char *v)
#define lua_tointeger(L, i)
const char * what
const char * source
char short_src[LUA_IDSIZE]
const char * name
unsigned char nparams
const char * namewhat

References arg, checkstack(), lua_Debug::currentline, getthread(), lua_Debug::istailcall, lua_Debug::isvararg, lua_Debug::lastlinedefined, lua_Debug::linedefined, lua_createtable(), lua_getinfo(), lua_getstack(), lua_isfunction, lua_isnumber(), lua_pushfstring(), lua_pushnil(), lua_pushvalue(), lua_tointeger, lua_tostring, lua_xmove(), luaL_argerror(), luaL_optstring, lua_Debug::name, lua_Debug::namewhat, lua_Debug::nparams, lua_Debug::nups, settabsb(), settabsi(), settabss(), lua_Debug::short_src, lua_Debug::source, treatstackoption(), and lua_Debug::what.

◆ db_getlocal()

static int db_getlocal ( lua_State * L)
static

Definition at line 168 of file lua-5.2.4/src/ldblib.c.

168 {
169 int arg;
170 lua_State *L1 = getthread(L, &arg);
171 lua_Debug ar;
172 const char *name;
173 int nvar = luaL_checkint(L, arg+2); /* local-variable index */
174 if (lua_isfunction(L, arg + 1)) { /* function argument? */
175 lua_pushvalue(L, arg + 1); /* push function */
176 lua_pushstring(L, lua_getlocal(L, NULL, nvar)); /* push local name */
177 return 1;
178 }
179 else { /* stack-level argument */
180 if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */
181 return luaL_argerror(L, arg+1, "level out of range");
182 checkstack(L, L1, 1);
183 name = lua_getlocal(L1, &ar, nvar);
184 if (name) {
185 lua_xmove(L1, L, 1); /* push local value */
186 lua_pushstring(L, name); /* push name */
187 lua_pushvalue(L, -2); /* re-order */
188 return 2;
189 }
190 else {
191 lua_pushnil(L); /* no name (nor value) */
192 return 1;
193 }
194 }
195}
LUA_API const char * lua_getlocal(lua_State *L, const lua_Debug *ar, int n)

References arg, checkstack(), getthread(), lua_getlocal(), lua_getstack(), lua_isfunction, lua_pushnil(), lua_pushstring(), lua_pushvalue(), lua_xmove(), luaL_argerror(), luaL_checkint, name, and NULL.

◆ db_getmetatable()

static int db_getmetatable ( lua_State * L)
static

Definition at line 36 of file lua-5.2.4/src/ldblib.c.

36 {
37 luaL_checkany(L, 1);
38 if (!lua_getmetatable(L, 1)) {
39 lua_pushnil(L); /* no metatable */
40 }
41 return 1;
42}
LUA_API int lua_getmetatable(lua_State *L, int objindex)
LUALIB_API void luaL_checkany(lua_State *L, int narg)

References lua_getmetatable(), lua_pushnil(), and luaL_checkany().

◆ db_getregistry()

static int db_getregistry ( lua_State * L)
static

Definition at line 30 of file lua-5.2.4/src/ldblib.c.

30 {
32 return 1;
33}
#define LUA_REGISTRYINDEX

References lua_pushvalue(), and LUA_REGISTRYINDEX.

◆ db_getupvalue()

static int db_getupvalue ( lua_State * L)
static

Definition at line 225 of file lua-5.2.4/src/ldblib.c.

225 {
226 return auxupvalue(L, 1);
227}
static int auxupvalue(lua_State *L, int get)

References auxupvalue().

◆ db_getuservalue()

static int db_getuservalue ( lua_State * L)
static

Definition at line 55 of file lua-5.2.4/src/ldblib.c.

55 {
56 if (lua_type(L, 1) != LUA_TUSERDATA)
57 lua_pushnil(L);
58 else
59 lua_getuservalue(L, 1);
60 return 1;
61}
LUA_API int lua_type(lua_State *L, int idx)
#define LUA_TUSERDATA
#define lua_getuservalue(L, idx)

References lua_getuservalue, lua_pushnil(), LUA_TUSERDATA, and lua_type().

◆ db_sethook()

static int db_sethook ( lua_State * L)
static

hooktable.__mode = "k"

Definition at line 304 of file lua-5.2.4/src/ldblib.c.

304 {
305 int arg, mask, count;
306 lua_Hook func;
307 lua_State *L1 = getthread(L, &arg);
308 if (lua_isnoneornil(L, arg+1)) {
309 lua_settop(L, arg+1);
310 func = NULL; mask = 0; count = 0; /* turn off hooks */
311 }
312 else {
313 const char *smask = luaL_checkstring(L, arg+2);
315 count = luaL_optint(L, arg+3, 0);
316 func = hookf; mask = makemask(smask, count);
317 }
318 if (gethooktable(L) == 0) { /* creating hook table? */
319 lua_pushstring(L, "k");
320 lua_setfield(L, -2, "__mode"); /** hooktable.__mode = "k" */
321 lua_pushvalue(L, -1);
322 lua_setmetatable(L, -2); /* setmetatable(hooktable) = hooktable */
323 }
324 checkstack(L, L1, 1);
325 lua_pushthread(L1); lua_xmove(L1, L, 1);
326 lua_pushvalue(L, arg+1);
327 lua_rawset(L, -3); /* set new hook */
328 lua_sethook(L1, func, mask, count); /* set hooks */
329 return 0;
330}
LUA_API int lua_setmetatable(lua_State *L, int objindex)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
LUA_API void lua_rawset(lua_State *L, int idx)
#define luaL_optint(L, n, d)
#define luaL_checkstring(L, n)
LUA_API int lua_sethook(lua_State *L, lua_Hook func, int mask, int count)
#define lua_isnoneornil(L, n)
static int makemask(const char *smask, int count)

References arg, checkstack(), gethooktable, getthread(), hookf(), lua_isnoneornil, lua_pushstring(), lua_pushthread(), lua_pushvalue(), lua_rawset(), lua_setfield(), lua_sethook(), lua_setmetatable(), lua_settop(), LUA_TFUNCTION, lua_xmove(), luaL_checkstring, luaL_checktype(), luaL_optint, makemask(), mask, and NULL.

◆ db_setlocal()

static int db_setlocal ( lua_State * L)
static

Definition at line 198 of file lua-5.2.4/src/ldblib.c.

198 {
199 int arg;
200 lua_State *L1 = getthread(L, &arg);
201 lua_Debug ar;
202 if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */
203 return luaL_argerror(L, arg+1, "level out of range");
204 luaL_checkany(L, arg+3);
205 lua_settop(L, arg+3);
206 checkstack(L, L1, 1);
207 lua_xmove(L, L1, 1);
208 lua_pushstring(L, lua_setlocal(L1, &ar, luaL_checkint(L, arg+2)));
209 return 1;
210}
LUA_API const char * lua_setlocal(lua_State *L, const lua_Debug *ar, int n)

References arg, checkstack(), getthread(), lua_getstack(), lua_pushstring(), lua_setlocal(), lua_settop(), lua_xmove(), luaL_argerror(), luaL_checkany(), and luaL_checkint.

◆ db_setmetatable()

static int db_setmetatable ( lua_State * L)
static

Definition at line 45 of file lua-5.2.4/src/ldblib.c.

45 {
46 int t = lua_type(L, 2);
47 luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
48 "nil or table expected");
49 lua_settop(L, 2);
50 lua_setmetatable(L, 1);
51 return 1; /* return 1st argument */
52}
#define LUA_TTABLE
#define LUA_TNIL

References lua_setmetatable(), lua_settop(), LUA_TNIL, LUA_TTABLE, lua_type(), and luaL_argcheck.

◆ db_setupvalue()

static int db_setupvalue ( lua_State * L)
static

Definition at line 230 of file lua-5.2.4/src/ldblib.c.

230 {
231 luaL_checkany(L, 3);
232 return auxupvalue(L, 0);
233}

References auxupvalue(), and luaL_checkany().

◆ db_setuservalue()

static int db_setuservalue ( lua_State * L)
static

Definition at line 64 of file lua-5.2.4/src/ldblib.c.

64 {
65 if (lua_type(L, 1) == LUA_TLIGHTUSERDATA)
66 luaL_argerror(L, 1, "full userdata expected, got light userdata");
68 if (!lua_isnoneornil(L, 2))
70 lua_settop(L, 2);
71 lua_setuservalue(L, 1);
72 return 1;
73}
#define LUA_TLIGHTUSERDATA
#define lua_setuservalue(L, idx)

References lua_isnoneornil, lua_settop(), lua_setuservalue, LUA_TLIGHTUSERDATA, LUA_TTABLE, LUA_TUSERDATA, lua_type(), luaL_argerror(), and luaL_checktype().

◆ db_traceback()

static int db_traceback ( lua_State * L)
static

Definition at line 369 of file lua-5.2.4/src/ldblib.c.

369 {
370 int arg;
371 lua_State *L1 = getthread(L, &arg);
372 const char *msg = lua_tostring(L, arg + 1);
373 if (msg == NULL && !lua_isnoneornil(L, arg + 1)) /* non-string 'msg'? */
374 lua_pushvalue(L, arg + 1); /* return it untouched */
375 else {
376 int level = luaL_optint(L, arg + 2, (L == L1) ? 1 : 0);
377 luaL_traceback(L, L1, msg, level);
378 }
379 return 1;
380}
LUALIB_API void luaL_traceback(lua_State *L, lua_State *L1, const char *msg, int level)

References arg, getthread(), lua_isnoneornil, lua_pushvalue(), lua_tostring, luaL_optint, luaL_traceback(), and NULL.

◆ db_upvalueid()

static int db_upvalueid ( lua_State * L)
static

Definition at line 247 of file lua-5.2.4/src/ldblib.c.

247 {
248 int n = checkupval(L, 1, 2);
250 return 1;
251}
LUA_API void lua_pushlightuserdata(lua_State *L, void *p)
LUA_API void * lua_upvalueid(lua_State *L, int fidx, int n)
static int checkupval(lua_State *L, int argf, int argnup)

References checkupval(), lua_pushlightuserdata(), and lua_upvalueid().

◆ db_upvaluejoin()

static int db_upvaluejoin ( lua_State * L)
static

Definition at line 254 of file lua-5.2.4/src/ldblib.c.

254 {
255 int n1 = checkupval(L, 1, 2);
256 int n2 = checkupval(L, 3, 4);
257 luaL_argcheck(L, !lua_iscfunction(L, 1), 1, "Lua function expected");
258 luaL_argcheck(L, !lua_iscfunction(L, 3), 3, "Lua function expected");
259 lua_upvaluejoin(L, 1, n1, 3, n2);
260 return 0;
261}
LUA_API int lua_iscfunction(lua_State *L, int idx)
LUA_API void lua_upvaluejoin(lua_State *L, int fidx1, int n1, int fidx2, int n2)

References checkupval(), lua_iscfunction(), lua_upvaluejoin(), and luaL_argcheck.

◆ getthread()

static lua_State * getthread ( lua_State * L,
int * arg )
static

Definition at line 94 of file lua-5.2.4/src/ldblib.c.

94 {
95 if (lua_isthread(L, 1)) {
96 *arg = 1;
97 return lua_tothread(L, 1);
98 }
99 else {
100 *arg = 0;
101 return L;
102 }
103}
LUA_API lua_State * lua_tothread(lua_State *L, int idx)
#define lua_isthread(L, n)

References arg, lua_isthread, and lua_tothread().

Referenced by db_gethook(), db_getinfo(), db_getlocal(), db_sethook(), db_setlocal(), and db_traceback().

◆ hookf()

static void hookf ( lua_State * L,
lua_Debug * ar )
static

Definition at line 267 of file lua-5.2.4/src/ldblib.c.

267 {
268 static const char *const hooknames[] =
269 {"call", "return", "line", "count", "tail call"};
270 gethooktable(L);
272 lua_rawget(L, -2);
273 if (lua_isfunction(L, -1)) {
274 lua_pushstring(L, hooknames[(int)ar->event]);
275 if (ar->currentline >= 0)
277 else lua_pushnil(L);
278 lua_assert(lua_getinfo(L, "lS", ar));
279 lua_call(L, 2, 0);
280 }
281}
#define lua_assert(c)
#define lua_call(L, n, r)

References lua_Debug::currentline, lua_Debug::event, gethooktable, lua_assert, lua_call, lua_getinfo(), lua_isfunction, lua_pushinteger(), lua_pushnil(), lua_pushstring(), lua_pushthread(), and lua_rawget().

Referenced by db_gethook(), and db_sethook().

◆ luaopen_debug()

LUAMOD_API int luaopen_debug ( lua_State * L)

Definition at line 404 of file lua-5.2.4/src/ldblib.c.

404 {
405 luaL_newlib(L, dblib);
406 return 1;
407}
#define luaL_newlib(L, l)
static const luaL_Reg dblib[]

References dblib, and luaL_newlib.

◆ makemask()

static int makemask ( const char * smask,
int count )
static

Definition at line 284 of file lua-5.2.4/src/ldblib.c.

284 {
285 int mask = 0;
286 if (strchr(smask, 'c')) mask |= LUA_MASKCALL;
287 if (strchr(smask, 'r')) mask |= LUA_MASKRET;
288 if (strchr(smask, 'l')) mask |= LUA_MASKLINE;
289 if (count > 0) mask |= LUA_MASKCOUNT;
290 return mask;
291}
#define LUA_MASKCOUNT
#define LUA_MASKCALL
#define LUA_MASKLINE
#define LUA_MASKRET

References LUA_MASKCALL, LUA_MASKCOUNT, LUA_MASKLINE, LUA_MASKRET, and mask.

Referenced by db_sethook().

◆ settabsb()

static void settabsb ( lua_State * L,
const char * i,
int v )
static

Definition at line 88 of file lua-5.2.4/src/ldblib.c.

88 {
89 lua_pushboolean(L, v);
90 lua_setfield(L, -2, i);
91}
LUA_API void lua_pushboolean(lua_State *L, int b)

References lua_pushboolean(), and lua_setfield().

Referenced by db_getinfo().

◆ settabsi()

static void settabsi ( lua_State * L,
const char * i,
int v )
static

Definition at line 82 of file lua-5.2.4/src/ldblib.c.

82 {
83 lua_pushinteger(L, v);
84 lua_setfield(L, -2, i);
85}

References lua_pushinteger(), and lua_setfield().

Referenced by db_getinfo().

◆ settabss()

static void settabss ( lua_State * L,
const char * i,
const char * v )
static

Definition at line 76 of file lua-5.2.4/src/ldblib.c.

76 {
77 lua_pushstring(L, v);
78 lua_setfield(L, -2, i);
79}

References lua_pushstring(), and lua_setfield().

Referenced by db_getinfo().

◆ treatstackoption()

static void treatstackoption ( lua_State * L,
lua_State * L1,
const char * fname )
static

Definition at line 106 of file lua-5.2.4/src/ldblib.c.

106 {
107 if (L == L1) {
108 lua_pushvalue(L, -2);
109 lua_remove(L, -3);
110 }
111 else
112 lua_xmove(L1, L, 1);
113 lua_setfield(L, -2, fname);
114}

References lua_pushvalue(), lua_remove, lua_setfield(), and lua_xmove().

Referenced by db_getinfo().

◆ unmakemask()

static char * unmakemask ( int mask,
char * smask )
static

Definition at line 294 of file lua-5.2.4/src/ldblib.c.

294 {
295 int i = 0;
296 if (mask & LUA_MASKCALL) smask[i++] = 'c';
297 if (mask & LUA_MASKRET) smask[i++] = 'r';
298 if (mask & LUA_MASKLINE) smask[i++] = 'l';
299 smask[i] = '\0';
300 return smask;
301}

References LUA_MASKCALL, LUA_MASKLINE, LUA_MASKRET, and mask.

Referenced by db_gethook().

Variable Documentation

◆ dblib

const luaL_Reg dblib[]
static
Initial value:
= {
{"debug", db_debug},
{"getuservalue", db_getuservalue},
{"gethook", db_gethook},
{"getinfo", db_getinfo},
{"getlocal", db_getlocal},
{"getregistry", db_getregistry},
{"getmetatable", db_getmetatable},
{"getupvalue", db_getupvalue},
{"upvaluejoin", db_upvaluejoin},
{"upvalueid", db_upvalueid},
{"setuservalue", db_setuservalue},
{"sethook", db_sethook},
{"setlocal", db_setlocal},
{"setmetatable", db_setmetatable},
{"setupvalue", db_setupvalue},
{"traceback", db_traceback},
}
static int db_setlocal(lua_State *L)
static int db_getuservalue(lua_State *L)
static int db_setuservalue(lua_State *L)
static int db_setmetatable(lua_State *L)
static int db_getinfo(lua_State *L)
static int db_gethook(lua_State *L)
static int db_getupvalue(lua_State *L)
static int db_getregistry(lua_State *L)
static int db_sethook(lua_State *L)
static int db_getmetatable(lua_State *L)
static int db_setupvalue(lua_State *L)
static int db_upvaluejoin(lua_State *L)
static int db_debug(lua_State *L)
static int db_upvalueid(lua_State *L)
static int db_traceback(lua_State *L)
static int db_getlocal(lua_State *L)

Definition at line 383 of file lua-5.2.4/src/ldblib.c.

383 {
384 {"debug", db_debug},
385 {"getuservalue", db_getuservalue},
386 {"gethook", db_gethook},
387 {"getinfo", db_getinfo},
388 {"getlocal", db_getlocal},
389 {"getregistry", db_getregistry},
390 {"getmetatable", db_getmetatable},
391 {"getupvalue", db_getupvalue},
392 {"upvaluejoin", db_upvaluejoin},
393 {"upvalueid", db_upvalueid},
394 {"setuservalue", db_setuservalue},
395 {"sethook", db_sethook},
396 {"setlocal", db_setlocal},
397 {"setmetatable", db_setmetatable},
398 {"setupvalue", db_setupvalue},
399 {"traceback", db_traceback},
400 {NULL, NULL}
401};

Referenced by luaopen_debug().