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)
int lua_checkstack (lua_State *L, int size)
void lua_xmove (lua_State *from, lua_State *to, int n)
lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf)
lua_Statelua_newthread (lua_State *L)
int lua_gettop (lua_State *L)
void lua_settop (lua_State *L, int idx)
void lua_remove (lua_State *L, int idx)
void lua_insert (lua_State *L, int idx)
void lua_replace (lua_State *L, int idx)
void lua_pushvalue (lua_State *L, int idx)
int lua_type (lua_State *L, int idx)
const char * lua_typename (lua_State *L, int t)
int lua_iscfunction (lua_State *L, int idx)
int lua_isnumber (lua_State *L, int idx)
int lua_isstring (lua_State *L, int idx)
int lua_isuserdata (lua_State *L, int idx)
int lua_rawequal (lua_State *L, int index1, int index2)
int lua_equal (lua_State *L, int index1, int index2)
int lua_lessthan (lua_State *L, int index1, int index2)
lua_Number lua_tonumber (lua_State *L, int idx)
lua_Integer lua_tointeger (lua_State *L, int idx)
int lua_toboolean (lua_State *L, int idx)
const char * lua_tolstring (lua_State *L, int idx, size_t *len)
size_t lua_objlen (lua_State *L, int idx)
lua_CFunction lua_tocfunction (lua_State *L, int idx)
void * lua_touserdata (lua_State *L, int idx)
lua_Statelua_tothread (lua_State *L, int idx)
const void * lua_topointer (lua_State *L, int idx)
void lua_pushnil (lua_State *L)
void lua_pushnumber (lua_State *L, lua_Number n)
void lua_pushinteger (lua_State *L, lua_Integer n)
void lua_pushlstring (lua_State *L, const char *s, size_t len)
void lua_pushstring (lua_State *L, const char *s)
const char * lua_pushvfstring (lua_State *L, const char *fmt, va_list argp)
const char * lua_pushfstring (lua_State *L, const char *fmt,...)
void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n)
void lua_pushboolean (lua_State *L, int b)
void lua_pushlightuserdata (lua_State *L, void *p)
int lua_pushthread (lua_State *L)
void lua_gettable (lua_State *L, int idx)
void lua_getfield (lua_State *L, int idx, const char *k)
void lua_rawget (lua_State *L, int idx)
void lua_rawgeti (lua_State *L, int idx, int n)
void lua_createtable (lua_State *L, int narray, int nrec)
int lua_getmetatable (lua_State *L, int objindex)
void lua_getfenv (lua_State *L, int idx)
void lua_settable (lua_State *L, int idx)
void lua_setfield (lua_State *L, int idx, const char *k)
void lua_rawset (lua_State *L, int idx)
void lua_rawseti (lua_State *L, int idx, int n)
int lua_setmetatable (lua_State *L, int objindex)
int lua_setfenv (lua_State *L, int idx)
void lua_call (lua_State *L, int nargs, int nresults)
static void f_call (lua_State *L, void *ud)
int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc)
static void f_Ccall (lua_State *L, void *ud)
int lua_cpcall (lua_State *L, lua_CFunction func, void *ud)
int lua_load (lua_State *L, lua_Reader reader, void *data, const char *chunkname)
int lua_dump (lua_State *L, lua_Writer writer, void *data)
int lua_status (lua_State *L)
int lua_gc (lua_State *L, int what, int data)
int lua_error (lua_State *L)
int lua_next (lua_State *L, int idx)
void lua_concat (lua_State *L, int n)
lua_Alloc lua_getallocf (lua_State *L, void **ud)
void lua_setallocf (lua_State *L, lua_Alloc f, void *ud)
void * lua_newuserdata (lua_State *L, size_t size)
static const char * aux_upvalue (StkId fi, int n, TValue **val)
const char * lua_getupvalue (lua_State *L, int funcindex, int n)
const char * lua_setupvalue (lua_State *L, int funcindex, int n)

Variables

const char lua_ident []


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 (  )     {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_CFunction lua_atpanic ( lua_State L,
lua_CFunction  panicf 
)

Definition at line 126 of file lapi.c.

References G, lua_lock, and lua_unlock.

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

int lua_checkstack ( lua_State L,
int  size 
)

void lua_concat ( lua_State L,
int  n 
)

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.

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.

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.

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.

int lua_error ( lua_State L  ) 

Definition at line 957 of file lapi.c.

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

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

lua_Alloc lua_getallocf ( lua_State L,
void **  ud 
)

Definition at line 1000 of file lapi.c.

References G, lua_lock, and lua_unlock.

void lua_getfenv ( lua_State L,
int  idx 
)

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

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.

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.

int lua_gettop ( lua_State L  ) 

Definition at line 155 of file lapi.c.

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

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, setobj2s, and lua_State::top.

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.

int lua_iscfunction ( lua_State L,
int  idx 
)

Definition at line 250 of file lapi.c.

References index2adr(), and iscfunction.

int lua_isnumber ( lua_State L,
int  idx 
)

Definition at line 256 of file lapi.c.

References index2adr(), and tonumber.

int lua_isstring ( lua_State L,
int  idx 
)

Definition at line 263 of file lapi.c.

References lua_type().

int lua_isuserdata ( lua_State L,
int  idx 
)

Definition at line 269 of file lapi.c.

References index2adr(), ttislightuserdata, and ttisuserdata.

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().

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_State* lua_newthread ( lua_State L  ) 

void* lua_newuserdata ( lua_State L,
size_t  size 
)

int lua_next ( lua_State L,
int  idx 
)

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.

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

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.

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

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().

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.

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.

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().

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().

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.

void lua_pushstring ( lua_State L,
const char *  s 
)

Definition at line 450 of file lapi.c.

References lua_pushlstring(), and lua_pushnil().

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.

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.

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().

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().

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.

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

void lua_rawset ( lua_State L,
int  idx 
)

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

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.

void lua_replace ( lua_State L,
int  idx 
)

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

Definition at line 1010 of file lapi.c.

References G, lua_lock, and lua_unlock.

int lua_setfenv ( lua_State L,
int  idx 
)

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

int lua_setmetatable ( lua_State L,
int  objindex 
)

void lua_settable ( lua_State L,
int  idx 
)

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.

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

int lua_status ( lua_State L  ) 

Definition at line 886 of file lapi.c.

References lua_State::status.

int lua_toboolean ( lua_State L,
int  idx 
)

Definition at line 333 of file lapi.c.

References index2adr(), and l_isfalse.

lua_CFunction lua_tocfunction ( lua_State L,
int  idx 
)

Definition at line 375 of file lapi.c.

References clvalue, index2adr(), and iscfunction.

lua_Integer lua_tointeger ( lua_State L,
int  idx 
)

Definition at line 319 of file lapi.c.

References index2adr(), nvalue, and tonumber.

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_Number lua_tonumber ( lua_State L,
int  idx 
)

Definition at line 309 of file lapi.c.

References index2adr(), nvalue, and tonumber.

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_State* lua_tothread ( lua_State L,
int  idx 
)

Definition at line 391 of file lapi.c.

References index2adr(), thvalue, and ttisthread.

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().

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().

const char* lua_typename ( lua_State L,
int  t 
)

Definition at line 244 of file lapi.c.

References luaT_typenames, and UNUSED.

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

Initial value:

  "$Lua: "  "Lua 5.1.2"  " "  "Copyright (C) 1994-2007 Lua.org, PUC-Rio"  " $\n"
  "$Authors: "  "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"  " $\n"
  "$URL: www.lua.org $\n"

Definition at line 34 of file lapi.c.


Generated on Wed Nov 19 15:01:48 2008 for rpm by  doxygen 1.5.6