Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

lua/lapi.c File Reference

#include <assert.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"

Include dependency graph for lapi.c:

Go to the source code of this file.

Data Structures

struct  CallS
struct  CCallS

Defines

#define lapi_c
#define api_check(L, o)
#define api_checknelems(L, n)   api_check(L, (n) <= (L->top - L->base))
#define api_incr_top(L)   {api_check(L, L->top < L->ci->top); L->top++;}
#define GCscalel(x)   ((x)>>10)
#define GCscale(x)   (cast(int, GCscalel(x)))
#define GCunscale(x)   (cast(lu_mem, x)<<10)

Functions

static TObjectnegindex (lua_State *L, int idx)
static TObjectluaA_index (lua_State *L, int idx)
static TObjectluaA_indexAcceptable (lua_State *L, int idx)
void luaA_pushobject (lua_State *L, const TObject *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 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 int lua_toboolean (lua_State *L, int idx)
LUA_API const char * lua_tostring (lua_State *L, int idx)
LUA_API size_t lua_strlen (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_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 void lua_gettable (lua_State *L, int idx)
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_newtable (lua_State *L)
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_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_Chunkreader reader, void *data, const char *chunkname)
LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data)
LUA_API int lua_getgcthreshold (lua_State *L)
LUA_API int lua_getgccount (lua_State *L)
LUA_API void lua_setgcthreshold (lua_State *L, int newthreshold)
LUA_API const char * lua_version (void)
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 void * lua_newuserdata (lua_State *L, size_t size)
LUA_API int lua_pushupvalues (lua_State *L)
static const char * aux_upvalue (lua_State *L, int funcindex, int n, TObject **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 []


Define Documentation

#define api_check L,
 ) 
 

Definition at line 39 of file lapi.c.

Referenced by lua_next(), lua_pushupvalues(), lua_rawget(), lua_rawgeti(), lua_rawset(), lua_rawseti(), lua_setfenv(), lua_setmetatable(), lua_settop(), luaA_index(), luaA_indexAcceptable(), and negindex().

#define api_checknelems L,
 )     api_check(L, (n) <= (L->top - L->base))
 

Definition at line 42 of file lapi.c.

Referenced by lua_call(), lua_concat(), lua_dump(), lua_error(), lua_pushcclosure(), lua_rawset(), lua_rawseti(), lua_replace(), lua_setfenv(), lua_setmetatable(), lua_settable(), lua_setupvalue(), and lua_xmove().

#define api_incr_top  )     {api_check(L, L->top < L->ci->top); L->top++;}
 

Definition at line 44 of file lapi.c.

Referenced by lua_concat(), lua_getfenv(), lua_getmetatable(), lua_getupvalue(), lua_newtable(), lua_newthread(), lua_newuserdata(), lua_next(), lua_pushboolean(), lua_pushcclosure(), lua_pushlightuserdata(), lua_pushlstring(), lua_pushnil(), lua_pushnumber(), lua_pushvalue(), lua_rawgeti(), and lua_xmove().

#define GCscale  )     (cast(int, GCscalel(x)))
 

Definition at line 780 of file lapi.c.

Referenced by lua_getgccount(), and lua_getgcthreshold().

#define GCscalel  )     ((x)>>10)
 

Definition at line 779 of file lapi.c.

Referenced by lua_setgcthreshold().

#define GCunscale  )     (cast(lu_mem, x)<<10)
 

Definition at line 781 of file lapi.c.

Referenced by lua_setgcthreshold().

#define lapi_c
 

Definition at line 11 of file lapi.c.


Function Documentation

static const char* aux_upvalue lua_State L,
int  funcindex,
int  n,
TObject **  val
[static]
 

Definition at line 895 of file lapi.c.

References Closure::c, clvalue, getstr, CClosure::isC, Closure::l, luaA_index(), CClosure::nupvalues, LClosure::p, Proto::sizeupvalues, ttisfunction, LClosure::upvals, CClosure::upvalue, Proto::upvalues, and UpVal::v.

Referenced by lua_getupvalue(), and lua_setupvalue().

static void f_call lua_State L,
void *  ud
[static]
 

Definition at line 683 of file lapi.c.

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

Referenced by lua_pcall().

static void f_Ccall lua_State L,
void *  ud
[static]
 

Definition at line 715 of file lapi.c.

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

Referenced by lua_cpcall().

LUA_API lua_CFunction lua_atpanic lua_State L,
lua_CFunction  panicf
 

Definition at line 138 of file lapi.c.

References G, lua_lock, and lua_unlock.

LUA_API void lua_call lua_State L,
int  nargs,
int  nresults
 

Definition at line 662 of file lapi.c.

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

LUA_API int lua_checkstack lua_State L,
int  size
 

Definition at line 109 of file lapi.c.

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

LUA_API void lua_concat lua_State L,
int  n
 

Definition at line 846 of file lapi.c.

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

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

Definition at line 730 of file lapi.c.

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

LUA_API int lua_dump lua_State L,
lua_Chunkwriter  writer,
void *  data
 

Definition at line 757 of file lapi.c.

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

LUA_API int lua_equal lua_State L,
int  index1,
int  index2
 

Definition at line 279 of file lapi.c.

References equalobj, lua_lock, lua_unlock, and luaA_indexAcceptable().

LUA_API int lua_error lua_State L  ) 
 

Definition at line 820 of file lapi.c.

References api_checknelems, lua_lock, lua_unlock, and luaG_errormsg().

LUA_API void lua_getfenv lua_State L,
int  idx
 

Definition at line 563 of file lapi.c.

References api_incr_top, clvalue, gt, isLfunction, lua_lock, lua_unlock, luaA_index(), setobj2s, and lua_State::top.

LUA_API int lua_getgccount lua_State L  ) 
 

Definition at line 791 of file lapi.c.

References G, GCscale, lua_lock, and lua_unlock.

LUA_API int lua_getgcthreshold lua_State L  ) 
 

Definition at line 783 of file lapi.c.

References G, GCscale, lua_lock, and lua_unlock.

LUA_API int lua_getmetatable lua_State L,
int  objindex
 

Definition at line 535 of file lapi.c.

References api_incr_top, defaultmeta, hvalue, lua_lock, lua_unlock, luaA_indexAcceptable(), sethvalue, lua_State::top, ttype, and uvalue.

LUA_API void lua_gettable lua_State L,
int  idx
 

Definition at line 496 of file lapi.c.

References lua_lock, lua_unlock, luaA_index(), luaV_gettable(), setobj2s, and lua_State::top.

LUA_API int lua_gettop lua_State L  ) 
 

Definition at line 169 of file lapi.c.

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

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

Definition at line 919 of file lapi.c.

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

LUA_API void lua_insert lua_State L,
int  idx
 

Definition at line 200 of file lapi.c.

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

LUA_API int lua_iscfunction lua_State L,
int  idx
 

Definition at line 246 of file lapi.c.

References iscfunction, and luaA_indexAcceptable().

LUA_API int lua_isnumber lua_State L,
int  idx
 

Definition at line 252 of file lapi.c.

References luaA_indexAcceptable(), and tonumber.

LUA_API int lua_isstring lua_State L,
int  idx
 

Definition at line 259 of file lapi.c.

References lua_type().

LUA_API int lua_isuserdata lua_State L,
int  idx
 

Definition at line 265 of file lapi.c.

References luaA_indexAcceptable(), ttislightuserdata, and ttisuserdata.

LUA_API int lua_lessthan lua_State L,
int  index1,
int  index2
 

Definition at line 292 of file lapi.c.

References lua_lock, lua_unlock, luaA_indexAcceptable(), and luaV_lessthan().

LUA_API int lua_load lua_State L,
lua_Chunkreader  reader,
void *  data,
const char *  chunkname
 

Definition at line 742 of file lapi.c.

References lua_lock, LUA_SIGNATURE, lua_unlock, luaD_protectedparser(), luaZ_init(), and luaZ_lookahead().

LUA_API void lua_newtable lua_State L  ) 
 

Definition at line 526 of file lapi.c.

References api_incr_top, lua_lock, lua_unlock, luaC_checkGC, luaH_new(), sethvalue, and lua_State::top.

LUA_API lua_State* lua_newthread lua_State L  ) 
 

Definition at line 148 of file lapi.c.

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

LUA_API void* lua_newuserdata lua_State L,
size_t  size
 

Definition at line 863 of file lapi.c.

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

LUA_API int lua_next lua_State L,
int  idx
 

Definition at line 829 of file lapi.c.

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

LUA_API int lua_pcall lua_State L,
int  nargs,
int  nresults,
int  errfunc
 

Definition at line 692 of file lapi.c.

References f_call(), CallS::func, lua_lock, lua_unlock, luaA_index(), luaD_pcall(), CallS::nresults, savestack, and lua_State::top.

LUA_API void lua_pushboolean lua_State L,
int  b
 

Definition at line 474 of file lapi.c.

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

LUA_API void lua_pushcclosure lua_State L,
lua_CFunction  fn,
int  n
 

Definition at line 458 of file lapi.c.

References api_checknelems, api_incr_top, Closure::c, CClosure::f, lua_lock, lua_unlock, luaC_checkGC, luaF_newCclosure(), setclvalue, setobj2n, lua_State::top, and CClosure::upvalue.

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

Definition at line 445 of file lapi.c.

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

LUA_API void lua_pushlightuserdata lua_State L,
void *  p
 

Definition at line 482 of file lapi.c.

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

LUA_API void lua_pushlstring lua_State L,
const char *  s,
size_t  len
 

Definition at line 417 of file lapi.c.

References api_incr_top, lua_lock, lua_unlock, luaC_checkGC, luaS_newlstr(), setsvalue2s, and lua_State::top.

Referenced by lua_pushstring().

LUA_API void lua_pushnil lua_State L  ) 
 

Definition at line 401 of file lapi.c.

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

Referenced by lua_pushstring().

LUA_API void lua_pushnumber lua_State L,
lua_Number  n
 

Definition at line 409 of file lapi.c.

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

LUA_API void lua_pushstring lua_State L,
const char *  s
 

Definition at line 426 of file lapi.c.

References lua_pushlstring(), and lua_pushnil().

LUA_API int lua_pushupvalues lua_State L  ) 
 

Definition at line 877 of file lapi.c.

References api_check, lua_State::base, Closure::c, clvalue, CCallS::func, iscfunction, lua_lock, lua_unlock, luaD_checkstack, CClosure::nupvalues, setobj2s, lua_State::top, and CClosure::upvalue.

Referenced by luaD_precall().

LUA_API void lua_pushvalue lua_State L,
int  idx
 

Definition at line 220 of file lapi.c.

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

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

Definition at line 434 of file lapi.c.

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

LUA_API int lua_rawequal lua_State L,
int  index1,
int  index2
 

Definition at line 271 of file lapi.c.

References luaA_indexAcceptable(), and luaO_rawequalObj().

LUA_API void lua_rawget lua_State L,
int  idx
 

Definition at line 505 of file lapi.c.

References api_check, hvalue, lua_lock, lua_unlock, luaA_index(), luaH_get(), setobj2s, lua_State::top, and ttistable.

LUA_API void lua_rawgeti lua_State L,
int  idx,
int  n
 

Definition at line 515 of file lapi.c.

References api_check, api_incr_top, hvalue, lua_lock, lua_unlock, luaA_index(), luaH_getnum(), setobj2s, lua_State::top, and ttistable.

LUA_API void lua_rawset lua_State L,
int  idx
 

Definition at line 589 of file lapi.c.

References api_check, api_checknelems, hvalue, lua_lock, lua_unlock, luaA_index(), luaH_set(), setobj2t, lua_State::top, and ttistable.

LUA_API void lua_rawseti lua_State L,
int  idx,
int  n
 

Definition at line 601 of file lapi.c.

References api_check, api_checknelems, hvalue, lua_lock, lua_unlock, luaA_index(), luaH_setnum(), setobj2t, lua_State::top, and ttistable.

LUA_API void lua_remove lua_State L,
int  idx
 

Definition at line 190 of file lapi.c.

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

LUA_API void lua_replace lua_State L,
int  idx
 

Definition at line 211 of file lapi.c.

References api_checknelems, lua_lock, lua_unlock, luaA_index(), setobj, and lua_State::top.

LUA_API int lua_setfenv lua_State L,
int  idx
 

Definition at line 641 of file lapi.c.

References api_check, api_checknelems, clvalue, isLfunction, lua_lock, lua_unlock, luaA_index(), lua_State::top, and ttistable.

LUA_API void lua_setgcthreshold lua_State L,
int  newthreshold
 

Definition at line 799 of file lapi.c.

References cast, G, GCscalel, GCunscale, lua_lock, lua_unlock, luaC_checkGC, and MAX_LUMEM.

LUA_API int lua_setmetatable lua_State L,
int  objindex
 

Definition at line 613 of file lapi.c.

References api_check, api_checknelems, defaultmeta, hvalue, lua_lock, lua_unlock, luaA_index(), lua_State::top, ttisnil, ttistable, ttype, and uvalue.

LUA_API void lua_settable lua_State L,
int  idx
 

Definition at line 578 of file lapi.c.

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

LUA_API void lua_settop lua_State L,
int  idx
 

Definition at line 174 of file lapi.c.

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

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

Definition at line 933 of file lapi.c.

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

LUA_API size_t lua_strlen lua_State L,
int  idx
 

Definition at line 339 of file lapi.c.

References lua_lock, lua_unlock, luaA_indexAcceptable(), luaV_tostring(), tsvalue, and ttisstring.

LUA_API int lua_toboolean lua_State L,
int  idx
 

Definition at line 316 of file lapi.c.

References l_isfalse, and luaA_indexAcceptable().

LUA_API lua_CFunction lua_tocfunction lua_State L,
int  idx
 

Definition at line 355 of file lapi.c.

References clvalue, iscfunction, and luaA_indexAcceptable().

LUA_API lua_Number lua_tonumber lua_State L,
int  idx
 

Definition at line 306 of file lapi.c.

References luaA_indexAcceptable(), nvalue, and tonumber.

LUA_API const void* lua_topointer lua_State L,
int  idx
 

Definition at line 378 of file lapi.c.

References clvalue, hvalue, lua_touserdata(), luaA_indexAcceptable(), thvalue, and ttype.

LUA_API const char* lua_tostring lua_State L,
int  idx
 

Definition at line 322 of file lapi.c.

References lua_lock, lua_unlock, luaA_indexAcceptable(), luaC_checkGC, luaV_tostring(), svalue, and ttisstring.

LUA_API lua_State* lua_tothread lua_State L,
int  idx
 

Definition at line 372 of file lapi.c.

References luaA_indexAcceptable(), thvalue, and ttisthread.

LUA_API void* lua_touserdata lua_State L,
int  idx
 

Definition at line 361 of file lapi.c.

References luaA_indexAcceptable(), pvalue, ttype, and uvalue.

Referenced by lua_topointer().

LUA_API int lua_type lua_State L,
int  idx
 

Definition at line 234 of file lapi.c.

References luaA_indexAcceptable(), and ttype.

Referenced by lua_isstring().

LUA_API const char* lua_typename lua_State L,
int  t
 

Definition at line 240 of file lapi.c.

References luaT_typenames, and UNUSED.

LUA_API const char* lua_version void   ) 
 

Definition at line 815 of file lapi.c.

LUA_API void lua_xmove lua_State from,
lua_State to,
int  n
 

Definition at line 125 of file lapi.c.

References api_checknelems, api_incr_top, lua_lock, lua_unlock, setobj2s, and lua_State::top.

static TObject* luaA_index lua_State L,
int  idx
[static]
 

Definition at line 73 of file lapi.c.

References api_check, lua_State::base, and negindex().

Referenced by aux_upvalue(), lua_getfenv(), lua_gettable(), lua_insert(), lua_next(), lua_pcall(), lua_pushvalue(), lua_rawget(), lua_rawgeti(), lua_rawset(), lua_rawseti(), lua_remove(), lua_replace(), lua_setfenv(), lua_setmetatable(), and lua_settable().

static TObject* luaA_indexAcceptable lua_State L,
int  idx
[static]
 

Definition at line 89 of file lapi.c.

References api_check, lua_State::base, negindex(), and lua_State::top.

Referenced by lua_equal(), lua_getmetatable(), lua_iscfunction(), lua_isnumber(), lua_isuserdata(), lua_lessthan(), lua_rawequal(), lua_strlen(), lua_toboolean(), lua_tocfunction(), lua_tonumber(), lua_topointer(), lua_tostring(), lua_tothread(), lua_touserdata(), and lua_type().

void luaA_pushobject lua_State L,
const TObject o
 

Definition at line 103 of file lapi.c.

References incr_top, setobj2s, and lua_State::top.

Referenced by lua_getlocal().

static TObject* negindex lua_State L,
int  idx
[static]
 

Definition at line 50 of file lapi.c.

References api_check, lua_State::base, clvalue, gt, iscfunction, lua_assert, and registry.

Referenced by luaA_index(), and luaA_indexAcceptable().


Variable Documentation

const char lua_ident[]
 

Initial value:

  "$Lua: " LUA_VERSION " " LUA_COPYRIGHT " $\n"
  "$Authors: " LUA_AUTHORS " $\n"
  "$URL: www.lua.org $\n"

Definition at line 31 of file lapi.c.


Generated on Wed Oct 29 05:56:04 2008 for rpm by  doxygen 1.4.4