# 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"`

## Classes
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 TValue * | index2adr (lua_State *L, int idx)
static Table * | getcurrenv (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_State * | lua_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_State * | lua_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 []

## Define Documentation

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

#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 checkresults | ( | L,
|  | na,
|  | nr |  | ) | api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))

#define lapi_c

#define LUA_CORE

## Function Documentation

static const char* aux_upvalue | ( | StkId | fi,
|  | int | n,
|  | TValue ** | val |
| ) |  |  | `[static]`

static void f_call | ( | lua_State * | L,
|  | void * | ud |
| ) |  |  | `[static]`

static void f_Ccall | ( | lua_State * | L,
|  | void * | ud |
| ) |  |  | `[static]`

static Table* getcurrenv | ( | lua_State * | L | ) | `[static]`

static TValue* index2adr | ( | lua_State * | L,
|  | int | idx |
| ) |  |  | `[static]`

LUA_API lua_CFunction lua_atpanic | ( | lua_State * | L,
|  | lua_CFunction | panicf |
| ) |  |  |

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

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

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

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

LUA_API int lua_error | ( | lua_State * | L | ) |

LUA_API int lua_gc | ( | lua_State * | L,
|  | int | what,
|  | int | data |
| ) |  |  |

LUA_API lua_Alloc lua_getallocf | ( | lua_State * | L,
|  | void ** | ud |
| ) |  |  |

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

LUA_API void lua_gettable | ( | lua_State * | L,
|  | int | idx |
| ) |  |  |

LUA_API int lua_gettop | ( | lua_State * | L | ) |

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

LUA_API void lua_insert | ( | lua_State * | L,
|  | int | idx |
| ) |  |  |

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_lessthan | ( | lua_State * | L,
|  | int | index1,
|  | int | index2 |
| ) |  |  |

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

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

LUA_API int lua_pcall | ( | lua_State * | L,
|  | int | nargs,
|  | int | nresults,
|  | int | errfunc |
| ) |  |  |

LUA_API void lua_pushboolean | ( | lua_State * | L,
|  | int | b |
| ) |  |  |

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

LUA_API void lua_pushinteger | ( | lua_State * | L,
|  | lua_Integer | n |
| ) |  |  |

LUA_API void lua_pushlightuserdata | ( | lua_State * | L,
|  | void * | p |
| ) |  |  |

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

LUA_API void lua_pushnil | ( | lua_State * | L | ) |

LUA_API void lua_pushnumber | ( | lua_State * | L,
|  | lua_Number | n |
| ) |  |  |

LUA_API void lua_pushstring | ( | lua_State * | L,
|  | const char * | s |
| ) |  |  |

LUA_API int lua_pushthread | ( | lua_State * | L | ) |

LUA_API void lua_pushvalue | ( | lua_State * | L,
|  | int | idx |
| ) |  |  |

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

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

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

LUA_API void lua_replace | ( | lua_State * | L,
|  | int | idx |
| ) |  |  |

LUA_API void lua_setallocf | ( | lua_State * | L,
|  | lua_Alloc | f,
|  | void * | 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 void lua_setlevel | ( | lua_State * | from,
|  | lua_State * | to |
| ) |  |  |

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

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

LUA_API int lua_status | ( | lua_State * | L | ) |

LUA_API int lua_toboolean | ( | lua_State * | L,
|  | int | idx |
| ) |  |  |

LUA_API lua_CFunction lua_tocfunction | ( | lua_State * | L,
|  | int | idx |
| ) |  |  |

LUA_API lua_Integer lua_tointeger | ( | lua_State * | L,
|  | int | idx |
| ) |  |  |

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

LUA_API lua_Number lua_tonumber | ( | lua_State * | L,
|  | int | idx |
| ) |  |  |

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

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

LUA_API void* lua_touserdata | ( | 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 void lua_xmove | ( | lua_State * | from,
|  | lua_State * | to,
|  | int | n |
| ) |  |  |

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

## Variable Documentation

const char lua_ident[]

Initial value:

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