int32 lua_ref(int32 lock) { int32 ref; checkCparams(1); ref = luaC_ref(lua_state->stack.top - 1, lock); lua_state->stack.top--; return ref; }
lua_Object lua_seterrormethod (void) { lua_Object temp; checkCparams(1); temp = lua_getglobal("_ERRORMESSAGE"); lua_setglobal("_ERRORMESSAGE"); return temp; }
lua_Object lua_seterrormethod (void) { TObject temp = L->errorim; checkCparams(1); L->errorim = *(--L->stack.top); return put_luaObject(&temp); }
lua_Object lua_rawgettable (void) { checkCparams(2); if (ttype(L->stack.top-2) != LUA_T_ARRAY) lua_error("indexed expression not a table in rawgettable"); *(L->stack.top-2) = *luaH_get(avalue(L->stack.top-2), L->stack.top-1); --L->stack.top; return put_luaObjectonTop(); }
void lua_pushCclosure(lua_CFunction fn, int32 n) { if (!fn) lua_error("API error - attempt to push a NULL Cfunction"); checkCparams(n); ttype(lua_state->stack.top) = LUA_T_CPROTO; fvalue(lua_state->stack.top) = fn; incr_top; luaV_closure(n); }
lua_Object lua_settagmethod (int tag, char *event) { TObject newmethod; checkCparams(1); newmethod = *(--top); lua_pushnumber(tag); lua_pushstring(event); *top = newmethod; incr_top; do_unprotectedrun(luaI_settagmethod, 3, 1); return put_luaObjectonTop(); }
void lua_pushcclosure (lua_CFunction fn, int n) { if (fn == NULL) lua_error("API error - attempt to push a NULL Cfunction"); checkCparams(n); ttype(L->stack.top) = LUA_T_CPROTO; fvalue(L->stack.top) = fn; incr_top; luaV_closure(n); luaC_checkGC(); }
lua_Object lua_rawgettable() { checkCparams(2); if (ttype(lua_state->stack.top-2) != LUA_T_ARRAY) { lua_error("indexed expression not a table in rawgettable"); } else { TObject *h = luaH_get(avalue(lua_state->stack.top - 2), lua_state->stack.top - 1); --lua_state->stack.top; if (h) { *(lua_state->stack.top-1) = *h; } else { ttype(lua_state->stack.top-1) = LUA_T_NIL; } } return put_luaObjectonTop(); }
lua_Object lua_rawgettable (void) { checkCparams(2); if (ttype(top-2) != LUA_T_ARRAY) lua_error("indexed expression not a table in raw gettable"); else { TObject *h = lua_hashget(avalue(top-2), top-1); --top; if (h != NULL) *(top-1) = *h; else ttype(top-1) = LUA_T_NIL; } return put_luaObjectonTop(); }
void lua_settag(int32 tag) { checkCparams(1); luaT_realtag(tag); switch (ttype(lua_state->stack.top - 1)) { case LUA_T_ARRAY: (lua_state->stack.top - 1)->value.a->htag = tag; break; case LUA_T_USERDATA: (lua_state->stack.top - 1)->value.ud.tag = tag; break; default: luaL_verror("cannot change the tag of a %.20s", luaO_typenames[-ttype((lua_state->stack.top - 1))]); } lua_state->stack.top--; }
int lua_setlocal (lua_Function func, int local_number) { TObject *f = Address(func); char *name = luaI_getlocalname(f->value.tf, local_number, lua_currentline(func)); checkCparams(1); --top; if (name) { /* if "name", there must be a LUA_T_LINE */ /* therefore, f+2 points to function base */ *((f+2)+(local_number-1)) = *top; return 1; } else return 0; }
int32 lua_setlocal(lua_Function func, int32 local_number) { // check whether func is a Lua function if (lua_tag(func) != LUA_T_PROTO) return 0; else { TObject *f = Address(func); TProtoFunc *fp = luaA_protovalue(f)->value.tf; char *name = luaF_getlocalname(fp, local_number, lua_currentline(func)); checkCparams(1); --lua_state->stack.top; if (name) { // if "name", there must be a LUA_T_LINE // therefore, f+2 points to function base *((f + 2) + (local_number - 1)) = *lua_state->stack.top; return 1; } else return 0; } }
int lua_ref (int lock) { checkCparams(1); return luaI_ref(--top, lock); }
void lua_settable (void) { checkCparams(3); luaV_settable(L->stack.top-3); L->stack.top -= 2; /* pop table and index */ }
void lua_setglobal (char *name) { checkCparams(1); setglobal(luaI_findsymbolbyname(name)); }
lua_Object lua_gettable (void) { checkCparams(2); luaV_gettable(); return put_luaObjectonTop(); }
lua_Object lua_pop (void) { checkCparams(1); return put_luaObjectonTop(); }
lua_Object lua_settagmethod (int tag, char *event) { checkCparams(1); luaT_settagmethod(tag, event, L->stack.top-1); return put_luaObjectonTop(); }
void lua_rawsetglobal (char *name) { TaggedString *ts = luaS_new(name); checkCparams(1); luaS_rawsetglobal(ts, --L->stack.top); }
void lua_rawsettable (void) { checkCparams(3); storesubscript(top-3, 0); }
void lua_rawsettable (void) { checkCparams(3); luaV_rawsettable(L->stack.top-3); }
/* ** API: receives on the stack the table and the index. ** returns the value. */ lua_Object lua_gettable (void) { checkCparams(2); pushsubscript(); return put_luaObjectonTop(); }
void lua_settable (void) { checkCparams(3); luaV_settable(L->stack.top-3, 1); }
void lua_rawsetglobal (char *name) { Word n = luaI_findsymbolbyname(name); checkCparams(1); s_object(n) = *(--top); }
lua_Object lua_seterrormethod() { TObject temp = errorim; checkCparams(1); errorim = *(--lua_state->stack.top); return put_luaObject(&temp); }
void lua_setglobal (char *name) { checkCparams(1); luaD_checkstack(2); /* may need that to call T.M. */ luaV_setglobal(luaS_new(name)); }
lua_Object lua_seterrormethod (void) { checkCparams(1); do_unprotectedrun(luaI_seterrormethod, 1, 1); return put_luaObjectonTop(); }
void lua_rawsettable() { checkCparams(3); luaV_settable(lua_state->stack.top-3, 0); }
void lua_settag (int tag) { checkCparams(1); luaI_settag(tag, --top); }