Data Structures | Defines | Functions | Variables

lua/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"
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 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 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 [] = "$URL: www.lua.org $\n"

Define Documentation

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

Definition at line 764 of file lapi.c.

Referenced by lua_call(), and lua_pcall().

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

Definition at line 768 of file lapi.c.

Referenced by lua_call(), and lua_pcall().

#define lapi_c

Definition at line 13 of file lapi.c.

#define LUA_CORE

Definition at line 14 of file lapi.c.


Function Documentation

static const char* aux_upvalue ( StkId  fi,
int  n,
TValue **  val 
) [static]
static void f_call ( lua_State L,
void *  ud 
) [static]

Definition at line 794 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]
static Table* getcurrenv ( lua_State L ) [static]

Definition at line 79 of file lapi.c.

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

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

static TValue* index2adr ( lua_State L,
int  idx 
) [static]
LUA_API lua_CFunction lua_atpanic ( lua_State L,
lua_CFunction  panicf 
)

Definition at line 126 of file lapi.c.

References G, lua_lock, and lua_unlock.

LUA_API void lua_call ( lua_State L,
int  nargs,
int  nresults 
)
LUA_API int lua_checkstack ( lua_State L,
int  size 
)
LUA_API void lua_concat ( lua_State L,
int  n 
)
LUA_API int lua_cpcall ( lua_State L,
lua_CFunction  func,
void *  ud 
)

Definition at line 846 of file lapi.c.

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

LUA_API void lua_createtable ( lua_State L,
int  narray,
int  nrec 
)

Definition at line 574 of file lapi.c.

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

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

Definition at line 871 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 283 of file lapi.c.

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

LUA_API int lua_error ( lua_State L )

Definition at line 957 of file lapi.c.

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

LUA_API int lua_gc ( lua_State L,
int  what,
int  data 
)
LUA_API lua_Alloc lua_getallocf ( lua_State L,
void **  ud 
)

Definition at line 1000 of file lapi.c.

References G, lua_lock, and lua_unlock.

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

Definition at line 583 of file lapi.c.

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

LUA_API void lua_gettable ( lua_State L,
int  idx 
)

Definition at line 530 of file lapi.c.

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

LUA_API int lua_gettop ( lua_State L )

Definition at line 155 of file lapi.c.

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

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

Definition at line 1050 of file lapi.c.

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

LUA_API void lua_insert ( lua_State L,
int  idx 
)

Definition at line 187 of file lapi.c.

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

LUA_API int lua_iscfunction ( lua_State L,
int  idx 
)

Definition at line 250 of file lapi.c.

References index2adr(), and iscfunction.

LUA_API int lua_isnumber ( lua_State L,
int  idx 
)

Definition at line 256 of file lapi.c.

References index2adr(), and tonumber.

LUA_API int lua_isstring ( lua_State L,
int  idx 
)

Definition at line 263 of file lapi.c.

References lua_type().

LUA_API int lua_isuserdata ( lua_State L,
int  idx 
)

Definition at line 269 of file lapi.c.

References index2adr(), ttislightuserdata, and ttisuserdata.

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

Definition at line 295 of file lapi.c.

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

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

Definition at line 858 of file lapi.c.

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

LUA_API lua_State* lua_newthread ( lua_State L )
LUA_API void* lua_newuserdata ( lua_State L,
size_t  size 
)
LUA_API int lua_next ( lua_State L,
int  idx 
)
LUA_API size_t lua_objlen ( lua_State L,
int  idx 
)

Definition at line 357 of file lapi.c.

References hvalue, index2adr(), lua_lock, lua_unlock, luaH_getn(), luaV_tostring(), tsvalue, ttype, and uvalue.

LUA_API int lua_pcall ( lua_State L,
int  nargs,
int  nresults,
int  errfunc 
)
LUA_API void lua_pushboolean ( lua_State L,
int  b 
)

Definition at line 499 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 
)
LUA_API const char* lua_pushfstring ( lua_State L,
const char *  fmt,
  ... 
)

Definition at line 469 of file lapi.c.

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

LUA_API void lua_pushinteger ( lua_State L,
lua_Integer  n 
)

Definition at line 433 of file lapi.c.

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

LUA_API void lua_pushlightuserdata ( lua_State L,
void *  p 
)

Definition at line 507 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 441 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 417 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 425 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 450 of file lapi.c.

References lua_pushlstring(), and lua_pushnil().

LUA_API int lua_pushthread ( lua_State L )

Definition at line 515 of file lapi.c.

References api_incr_top, G, lua_lock, lua_unlock, setthvalue, and lua_State::top.

LUA_API void lua_pushvalue ( lua_State L,
int  idx 
)

Definition at line 224 of file lapi.c.

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

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

Definition at line 458 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 275 of file lapi.c.

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

LUA_API void lua_rawget ( lua_State L,
int  idx 
)

Definition at line 553 of file lapi.c.

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

LUA_API void lua_rawgeti ( lua_State L,
int  idx,
int  n 
)
LUA_API void lua_rawset ( lua_State L,
int  idx 
)
LUA_API void lua_rawseti ( lua_State L,
int  idx,
int  n 
)
LUA_API void lua_remove ( lua_State L,
int  idx 
)

Definition at line 176 of file lapi.c.

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

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

Definition at line 1010 of file lapi.c.

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

LUA_API int lua_setfenv ( lua_State L,
int  idx 
)
LUA_API void lua_setfield ( lua_State L,
int  idx,
const char *  k 
)
LUA_API int lua_setmetatable ( lua_State L,
int  objindex 
)
LUA_API void lua_settable ( lua_State L,
int  idx 
)
LUA_API void lua_settop ( lua_State L,
int  idx 
)

Definition at line 160 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 
)
LUA_API int lua_status ( lua_State L )

Definition at line 886 of file lapi.c.

References lua_State::status.

LUA_API int lua_toboolean ( lua_State L,
int  idx 
)

Definition at line 333 of file lapi.c.

References index2adr(), and l_isfalse.

LUA_API lua_CFunction lua_tocfunction ( lua_State L,
int  idx 
)

Definition at line 375 of file lapi.c.

References clvalue, index2adr(), and iscfunction.

LUA_API lua_Integer lua_tointeger ( lua_State L,
int  idx 
)

Definition at line 319 of file lapi.c.

References index2adr(), nvalue, and tonumber.

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

Definition at line 339 of file lapi.c.

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

LUA_API lua_Number lua_tonumber ( lua_State L,
int  idx 
)

Definition at line 309 of file lapi.c.

References index2adr(), nvalue, and tonumber.

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

Definition at line 397 of file lapi.c.

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

LUA_API lua_State* lua_tothread ( lua_State L,
int  idx 
)

Definition at line 391 of file lapi.c.

References index2adr(), thvalue, and ttisthread.

LUA_API void* lua_touserdata ( lua_State L,
int  idx 
)

Definition at line 381 of file lapi.c.

References index2adr(), pvalue, rawuvalue, and ttype.

Referenced by lua_topointer().

LUA_API int lua_type ( lua_State L,
int  idx 
)

Definition at line 238 of file lapi.c.

References index2adr(), luaO_nilobject, and ttype.

Referenced by lua_isstring().

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

Definition at line 244 of file lapi.c.

References luaT_typenames, and UNUSED.

LUA_API void lua_xmove ( lua_State from,
lua_State to,
int  n 
)
void luaA_pushobject ( lua_State L,
const TValue o 
)

Definition at line 89 of file lapi.c.

References api_incr_top, setobj2s, and lua_State::top.

Referenced by lua_getlocal().


Variable Documentation

const char lua_ident[] = "$URL: www.lua.org $\n"

Definition at line 34 of file lapi.c.