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(); } }
void lua_iolibopen (void) { luaL_openlib(iolib, (sizeof(iolib)/sizeof(iolib[0]))); openwithtags(); lua_pushcfunction(errorfb); lua_seterrormethod(); }
void lua_iolibopen() { g_files = new Common::HashMap<int32, LuaFile *>(); luaL_openlib(iolib, (sizeof(iolib) / sizeof(iolib[0]))); luaL_addlibtolist(iolibtag, (sizeof(iolibtag) / sizeof(iolibtag[0]))); openwithtags(); lua_pushcfunction(errorfb); lua_seterrormethod(); }
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 seterrormethod() { lua_Object nf = luaL_functionarg(1); lua_pushobject(nf); lua_pushobject(lua_seterrormethod()); }