static void rawgettable() { lua_Object t = luaL_nonnullarg(1); lua_Object i = luaL_nonnullarg(2); lua_pushobject(t); lua_pushobject(i); lua_pushobject(lua_rawgettable()); }
static void rawsettable (void) { lua_pushobject(luaL_nonnullarg(1)); lua_pushobject(luaL_nonnullarg(2)); lua_pushobject(luaL_nonnullarg(3)); lua_rawsettable(); }
static void rawsettable() { lua_Object t = luaL_nonnullarg(1); lua_Object i = luaL_nonnullarg(2); lua_Object v = luaL_nonnullarg(3); lua_pushobject(t); lua_pushobject(i); lua_pushobject(v); lua_rawsettable(); }
static void luaB_call (void) { lua_Object f = luaL_nonnullarg(1); Hash *arg = gethash(2); char *options = luaL_opt_string(3, ""); lua_Object err = lua_getparam(4); int narg = (int)getnarg(arg); int i, status; if (err != LUA_NOOBJECT) { /* set new error method */ lua_pushobject(err); err = lua_seterrormethod(); } /* push arg[1...n] */ luaD_checkstack(narg); for (i=0; i<narg; i++) *(L->stack.top++) = *luaH_getint(arg, i+1); status = lua_callfunction(f); if (err != LUA_NOOBJECT) { /* restore old error method */ lua_pushobject(err); lua_seterrormethod(); } if (status != 0) { /* error in call? */ if (strchr(options, 'x')) { lua_pushnil(); return; /* return nil to signal the error */ } else lua_error(NULL); } else { /* no errors */ if (strchr(options, 'p')) luaA_packresults(); else luaA_passresults(); } }
static void luaB_next (void) { Hash *a = gethash(1); TObject *k = luaA_Address(luaL_nonnullarg(2)); int i = (ttype(k) == LUA_T_NIL) ? 0 : luaH_pos(a, k)+1; if (luaA_next(a, i) == 0) lua_pushnil(); }
static void luaB_rawsetglobal (void) { char *n = luaL_check_string(1); lua_Object value = luaL_nonnullarg(2); lua_pushobject(value); lua_rawsetglobal(n); lua_pushobject(value); /* return given value */ }
static void settagmethod (void) { lua_Object nf = luaL_nonnullarg(3); lua_pushobject(nf); lua_pushobject(lua_settagmethod((int32)luaL_check_number(1), luaL_check_string(2))); }
static void rawsetglobal() { const char *n = luaL_check_string(1); lua_Object value = luaL_nonnullarg(2); lua_pushobject(value); lua_rawsetglobal(n); lua_pushobject(value); // return given value }
static void next() { lua_Object o = luaL_tablearg(1); lua_Object r = luaL_nonnullarg(2); Node *n = luaH_next(luaA_Address(o), luaA_Address(r)); if (n) { luaA_pushobject(&n->ref); luaA_pushobject(&n->val); } }
static void setlocal (void) { lua_Object func = lua_stackedfunction(luaL_check_int(1)); int numvar; luaL_arg_check(func != LUA_NOOBJECT, 1, "level out of range"); numvar = findlocal(func, 2); lua_pushobject(luaL_nonnullarg(3)); if (!lua_setlocal(func, numvar)) lua_error("no such local variable"); }
static void luaB_nextvar (void) { TObject *o = luaA_Address(luaL_nonnullarg(1)); TaggedString *g; if (ttype(o) == LUA_T_NIL) g = NULL; else { luaL_arg_check(ttype(o) == LUA_T_STRING, 1, "variable name expected"); g = tsvalue(o); } if (!luaA_nextvar(g)) lua_pushnil(); }
static void luaB_tinsert (void) { Hash *a = gethash(1); lua_Object v = lua_getparam(3); int n = (int)getnarg(a); int pos; if (v != LUA_NOOBJECT) pos = luaL_check_int(2); else { /* called with only 2 arguments */ v = luaL_nonnullarg(2); pos = n+1; } luaV_setn(a, n+1); /* a.n = n+1 */ for ( ;n>=pos; n--) luaH_move(a, n, n+1); /* a[n+1] = a[n] */ luaH_setint(a, pos, luaA_Address(v)); /* a[pos] = v */ }
static void luaI_call (void) { lua_Object f = luaL_nonnullarg(1); lua_Object arg = luaL_tablearg(2); const char *options = luaL_opt_string(3, ""); lua_Object err = lua_getparam(4); int32 narg = getnarg(arg); int32 i, status; if (err != LUA_NOOBJECT) { /* set new error method */ lua_pushobject(err); err = lua_seterrormethod(); } /* push arg[1...n] */ for (i=0; i<narg; i++) { lua_Object temp; /* temp = arg[i+1] */ lua_pushobject(arg); lua_pushnumber(i+1); temp = lua_rawgettable(); if (narg == MAX_INT && lua_isnil(temp)) break; lua_pushobject(temp); } status = lua_callfunction(f); if (err != LUA_NOOBJECT) { /* restore old error method */ lua_pushobject(err); lua_seterrormethod(); } if (status != 0) { /* error in call? */ if (strchr(options, 'x')) { lua_pushnil(); return; /* return nil to signal the error */ } else lua_error(NULL); } else { /* no errors */ if (strchr(options, 'p')) luaA_packresults(); else luaA_passresults(); } }
static void nextvar() { TObject *o = luaA_Address(luaL_nonnullarg(1)); TaggedString *g; if (ttype(o) == LUA_T_NIL) g = (TaggedString *)rootglobal.next; else { luaL_arg_check(ttype(o) == LUA_T_STRING, 1, "variable name expected"); g = tsvalue(o); // check whether name is in global var list luaL_arg_check((GCnode *)g != g->head.next, 1, "variable name expected"); g = (TaggedString *)g->head.next; } while (g && g->globalval.ttype == LUA_T_NIL) { // skip globals with nil g = (TaggedString *)g->head.next; } if (g) { pushstring(g); luaA_pushobject(&g->globalval); } }
static void luaB_settagmethod (void) { lua_Object nf = luaL_nonnullarg(3); lua_pushobject(nf); lua_pushobject(lua_settagmethod(luaL_check_int(1), luaL_check_string(2))); }
static void luaI_type() { lua_Object o = luaL_nonnullarg(1); lua_pushstring(luaO_typenames[-ttype(luaA_Address(o))]); lua_pushnumber(lua_tag(o)); }
static void luaB_rawgettable (void) { lua_pushobject(luaL_nonnullarg(1)); lua_pushobject(luaL_nonnullarg(2)); lua_pushobject(lua_rawgettable()); }