static int io_time (lua_State *L) { if (lua_isnoneornil(L, 1)) /* called without args? */ lua_pushnumber(L, time(NULL)); /* return current time */ else { time_t t; struct tm ts; luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 1); /* make sure table is at the top */ ts.tm_sec = getfield(L, "sec", 0); ts.tm_min = getfield(L, "min", 0); ts.tm_hour = getfield(L, "hour", 12); ts.tm_mday = getfield(L, "day", -2); ts.tm_mon = getfield(L, "month", -2) - 1; ts.tm_year = getfield(L, "year", -2) - 1900; ts.tm_isdst = getboolfield(L, "isdst"); t = mktime(&ts); if (t == (time_t)(-1)) lua_pushnil(L); else lua_pushnumber(L, t); } return 1; }
int CMyListBox::AddStringL(lua_State* L) { if(lua_istable(L, 1)) { int nTop = lua_gettop(L); lua_pushnil(L); while(lua_next(L, -2) != 0) { AddString(PAS(L, -1)); lua_pop(L, 1); } lua_pop(L, 1); } else if(lua_isnumber(L, 1) && !lua_isnoneornil(L, 2)) { InsertString(PAI(L, 1), PAS(L, 2)); } else { AddString(PAS(L, 1)); } return 0; }
static int GLua_BitStream_WriteData(lua_State *L) { GLua_Bitstream_t *stream = GLua_CheckBitStream(L, 1); unsigned int length; unsigned int deslength; const char *val = luaL_checklstring(L,2, &length); if (!lua_isnoneornil(L,3)) { deslength = luaL_checkinteger(L,3); if (length < deslength) { luaL_error(L, "BitStream_WriteData: Specified length is less than data length"); } length = deslength; } if (stream->reading) { luaL_error(L, "Attempted to write to a read-only bitstream"); return 0; } BitStream_WriteData(&stream->stream, (const unsigned char *)val, length); return 0; }
static int rdl_resource_method_call1_keepstack (struct resource *r, const char *method, enum method_arg_type mtype, void *argptr) { int rc = 0; lua_State *L = r->rdl->L; if (lua_rdl_resource_method_push (r, method) < 0) return (-1); if (mtype == M_ARG_TYPE_STRING) lua_pushstring (L, *(char **)argptr); else if (mtype == M_ARG_TYPE_INTEGER) lua_pushinteger (L, (lua_Integer) *(size_t *)argptr); /* * stack: [ Method, object, arg ] */ if (lua_pcall (L, 2, LUA_MULTRET, 0) || lua_isnoneornil (L, 1)) { VERR (r->rdl->rl, "%s(): %s\n", method, lua_tostring (L, -1)); lua_settop (L, 0); rc = -1; } return (rc); }
static int g_iofile (lua_State *L, const char *name, const char *mode) { if (!lua_isnoneornil(L, 1)) { const char *filename = lua_tostring(L, 1); lua_pushstring(L, name); if (filename) { FILE **pf = newfile(L); *pf = fopen(filename, mode); if (*pf == NULL) { lua_pushfstring(L, "%s: %s", filename, strerror(errno)); luaL_argerror(L, 1, lua_tostring(L, -1)); } } else { tofile(L, 1); /* check that it's a valid file handle */ lua_pushvalue(L, 1); } lua_rawset(L, lua_upvalueindex(1)); } /* return current value */ lua_pushstring(L, name); lua_rawget(L, lua_upvalueindex(1)); return 1; }
template<> void ExtraInit<Document>(lua_State* L, int metatable_index) { //we will inherit from Element ExtraInit<Element>(L,metatable_index); LuaType<Element>::_regfunctions(L,metatable_index,metatable_index - 1); AddTypeToElementAsTable<Document>(L); //create the DocumentFocus table lua_getglobal(L,"DocumentFocus"); if(lua_isnoneornil(L,-1)) { lua_pop(L,1); //pop unsucessful getglobal lua_newtable(L); //create a table for holding the enum lua_pushinteger(L,ElementDocument::NONE); lua_setfield(L,-2,"NONE"); lua_pushinteger(L,ElementDocument::FOCUS); lua_setfield(L,-2,"FOCUS"); lua_pushinteger(L,ElementDocument::MODAL); lua_setfield(L,-2,"MODAL"); lua_setglobal(L,"DocumentFocus"); } }
static int subr_ui_load_view(lua_State* L) { const char *filename; int retval; if (lua_isnoneornil(L,1)) return luaL_error(L,"Expecting one parameter: a filename (string)"); filename = lua_tostring(L,1); if (strcmp(filename_extension(filename),".lua")==0) { log_printf(LOG_WARNING,"%s seems to be a card LUA script: perhaps you should use the 'Analyzer'" " menu instead to open this file.",filename_base(filename)); } dyntree_model_iter_remove(gui_cardview_get_store(),NULL); retval = dyntree_model_iter_from_xml_file(gui_cardview_get_store(),NULL,filename); lua_pushboolean(L,retval); return 1; }
static int libd_drawScaled(lua_State *L) { fixed_t x, y, scale; INT32 flags; patch_t *patch; const UINT8 *colormap = NULL; if (!hud_running) return luaL_error(L, "HUD rendering code should not be called outside of rendering hooks!"); x = luaL_checkinteger(L, 1); y = luaL_checkinteger(L, 2); scale = luaL_checkinteger(L, 3); patch = *((patch_t **)luaL_checkudata(L, 4, META_PATCH)); flags = luaL_optinteger(L, 5, 0); if (!lua_isnoneornil(L, 6)) colormap = luaL_checkudata(L, 6, META_COLORMAP); flags &= ~V_PARAMMASK; // Don't let crashes happen. V_DrawFixedPatch(x, y, scale, flags, patch, colormap); return 0; }
int LAffineTransform::fromTargetPoints ( lua_State *L ) { float x00 = LUA::getNumber<float>(2); float y00 = LUA::getNumber<float>(2); float x10 = LUA::getNumber<float>(2); float y10 = LUA::getNumber<float>(2); float x01 = LUA::getNumber<float>(2); float y01 = LUA::getNumber<float>(2); if(lua_isnoneornil(L,2)) return LUA::storeAndReturnUserdata<LAffineTransform>( new LAffineTransform(L, AffineTransform::fromTargetPoints( x00, y00, x10, y10, x01, y01 ) )); float targetX2 = LUA::getNumber<float>(2); float targetY2 = LUA::getNumber<float>(2); float sourceX3 = LUA::getNumber<float>(2); float sourceY3 = LUA::getNumber<float>(2); float targetX3 = LUA::getNumber<float>(2); float targetY3 = LUA::getNumber<float>(2); return LUA::storeAndReturnUserdata<LAffineTransform>( new LAffineTransform(L, AffineTransform::fromTargetPoints( x00, y00, x10, y10, x01, y01, targetX2, targetY2, sourceX3, sourceY3, targetX3, targetY3 ) )); }
static int g_iofile(lua_State* L, int f, const char* mode) { if (!lua_isnoneornil(L, 1)) { const char* filename = lua_tostring(L, 1); if (filename) { FILE** pf = newfile(L); *pf = fopen(filename, mode); if (*pf == NULL) fileerror(L, 1, filename); } else { tofile(L); /* check that it's a valid file handle */ lua_pushvalue(L, 1); } lua_rawseti(L, LUA_ENVIRONINDEX, f); } /* return current value */ lua_rawgeti(L, LUA_ENVIRONINDEX, f); return 1; }
static int l_surface_scale(lua_State *L) { THRenderTarget* pCanvas = luaT_testuserdata<THRenderTarget>(L); THScaledItems eToScale = THSI_None; if(lua_isnoneornil(L, 3)) { eToScale = THSI_All; } else { size_t iLength; const char* sOption = lua_tolstring(L, 3, &iLength); if(sOption && iLength >= 6 && std::memcmp(sOption, "bitmap", 6) == 0) { eToScale = THSI_Bitmaps; } else luaL_error(L, "Expected \"bitmap\" as 2nd argument"); } lua_pushboolean(L, pCanvas->setScaleFactor(static_cast<float>( luaL_checknumber(L, 2)), eToScale) ? 1 : 0); return 1; }
static LUA_FUNCTION(openssl_base64) { size_t l = 0; BIO *bio = load_bio_object(L, 1); int encode = lua_isnoneornil(L, 2) ? 1 : lua_toboolean(L, 2); BIO *b64 = BIO_new(BIO_f_base64()); BIO *out = BIO_new(BIO_s_mem()); BUF_MEM* mem; if (encode) { BIO_push(b64, out); BIO_get_mem_ptr(bio, &mem); lua_pushlstring(L, mem->data, mem->length); BIO_write(b64, mem->data, mem->length); BIO_flush(b64); } else { char inbuf[512]; int inlen; BIO_push(b64, bio); while ((inlen = BIO_read(b64, inbuf, 512)) > 0) BIO_write(out, inbuf, inlen); BIO_flush(out); } BIO_get_mem_ptr(out, &mem); lua_pushlstring(L, mem->data, mem->length); BIO_free_all(b64); if (encode) BIO_free(bio); else BIO_free(out); return 1; }
static value_t* lua_to_value(language_t*li, int idx) { lua_internal_t*lua = (lua_internal_t*)li->internal; lua_State*l = lua->state; if(lua_gettop(l)+idx < 0) { language_error(li, "[lua] Stack overflow: idx=%d, top=%d\n", idx, lua_gettop(l)); return NULL; } else if(lua_isnoneornil(l, idx)) { return value_new_void(); } else if(lua_isboolean(l, idx)) { return value_new_boolean(lua_toboolean(l, idx)); } else if(lua_isnumber(l, idx)) { return value_new_float32(lua_tonumber(l, idx)); } else if(lua_isnumber(l, idx)) { return value_new_int32(lua_tointeger(l, idx)); } else if(lua_isstring(l, idx)) { value_t*v = value_new_string(lua_tostring(l, idx)); return v; } else if(lua_istable(l, idx)) { value_t*array = array_new(); int i; for(i=0;;i++) { lua_pushinteger(l, i); lua_gettable(l, idx<0?idx-1:idx); if(lua_isnil(l, -1)) { lua_pop(l, 1); break; } array_append(array, lua_to_value(li, -1)); lua_pop(l, 1); } return array; } language_error(li, "Don't know how to process lua type: %d\n"); return NULL; }
static const char * address_port(lua_State *L, char *tmp, const char * addr, int port_index, int *port) { const char * host; if (lua_isnoneornil(L,port_index)) { host = strchr(addr, '['); if (host) { // is ipv6 ++host; const char * sep = strchr(addr,']'); if (sep == NULL) { luaL_error(L, "Invalid address %s.",addr); } memcpy(tmp, host, sep-host); tmp[sep-host] = '\0'; host = tmp; sep = strchr(sep + 1, ':'); if (sep == NULL) { luaL_error(L, "Invalid address %s.",addr); } *port = strtoul(sep+1,NULL,10); } else { // is ipv4 const char * sep = strchr(addr,':'); if (sep == NULL) { luaL_error(L, "Invalid address %s.",addr); } memcpy(tmp, addr, sep-addr); tmp[sep-addr] = '\0'; host = tmp; *port = strtoul(sep+1,NULL,10); } } else { host = addr; *port = luaL_optinteger(L,port_index, 0); } return host; }
/* * Arguments: [date (table)] * | * Arguments: [date (string), format (string)] * Returns: [time (number)] */ static int sys_time (lua_State *L) { time_t t; if (lua_isnoneornil(L, 1)) t = time(NULL); /* current time */ else { struct tm tm; if (lua_istable(L, 1)) { lua_settop(L, 1); tm.tm_sec = date_getfield(L, "sec", 0); tm.tm_min = date_getfield(L, "min", 0); tm.tm_hour = date_getfield(L, "hour", 0); tm.tm_mday = date_getfield(L, "day", -2); tm.tm_mon = date_getfield(L, "month", -2) - 1; tm.tm_year = date_getfield(L, "year", -2) - 1900; tm.tm_isdst = date_getfield(L, "isdst", -1); } else { const char *s = luaL_checkstring(L, 1); const char *format = luaL_checkstring(L, 2); memset(&tm, 0, sizeof(struct tm)); tm.tm_isdst = -1; if (!strptime(s, format, &tm)) goto err; } t = mktime(&tm); if (t == (time_t) -1) goto err; } lua_pushnumber(L, (lua_Number) t); return 1; err: return sys_seterror(L, 0); }
void vm_hw_lua_interrupt(vm_t* vm, void* ud) { struct lua_hardware* hw = (struct lua_hardware*)ud; int interrupt; lua_getglobal(hw->state, "interrupt"); interrupt = lua_gettop(hw->state); if (lua_isnoneornil(hw->state, interrupt)) { lua_pop(hw->state, 1); return; } // Load function and arguments. lua_pushvalue(hw->state, interrupt); vm_hw_lua_cpu_push_cpu(hw->state, vm); // Call the function. if (lua_pcall(hw->state, 1, 0, 0) != 0) { printf("lua error in interrupt was %s.\n", lua_tostring(hw->state, -1)); lua_pop(hw->state, 1); } lua_pop(hw->state, 1); }
void vm_hw_lua_cycle(vm_t* vm, uint16_t pos, void* ud) { struct lua_hardware* hw = (struct lua_hardware*)ud; int cycle; lua_getglobal(hw->state, "cycle"); cycle = lua_gettop(hw->state); if (lua_isnoneornil(hw->state, -1)) { lua_pop(hw->state, 1); return; } // Load function and arguments. lua_pushvalue(hw->state, cycle); vm_hw_lua_cpu_push_cpu(hw->state, vm); // Call the function. if (lua_pcall(hw->state, 1, 0, 0) != 0) { printf("lua error in cycle was %s.\n", lua_tostring(hw->state, -1)); lua_pop(hw->state, 1); } lua_pop(hw->state, 1); }
static LUA_FUNCTION(openssl_evp_BytesToKey) { EVP_CIPHER* c = CHECK_OBJECT(1, EVP_CIPHER, "openssl.evp_cipher"); size_t lsalt, lk; const char* k = luaL_checklstring(L, 2, &lk); const char* salt = luaL_optlstring(L, 3, NULL, &lsalt); const EVP_MD* m = lua_isnoneornil(L, 4) ? EVP_get_digestbyname("sha1") : get_digest(L, 4); char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH]; int ret; if (salt != NULL && lsalt < PKCS5_SALT_LEN) { lua_pushfstring(L, "salt must not shorter than %d", PKCS5_SALT_LEN); luaL_argerror(L, 3, lua_tostring(L, -1)); } ret = EVP_BytesToKey(c, m, (unsigned char*)salt, (unsigned char*)k, lk, 1, (unsigned char*)key, (unsigned char*)iv); if (ret > 1) { lua_pushlstring(L, key, EVP_CIPHER_key_length(c)); lua_pushlstring(L, iv, EVP_CIPHER_iv_length(c)); return 2; } return openssl_pushresult(L, ret); }
/** * mosync.SysBufferToString(buffer) * * Create a new Lua string from a null-terminated * C-string pointed to by "buffer". * Return Lua string on success, nil on error. */ static int luaBufferToString(lua_State *L) { // First param is pointer to text buffer, must not // be nil and must be light user data. if (!lua_isnoneornil(L, 1) && lua_islightuserdata(L, 1)) { char* text = (char*) lua_touserdata(L, 1); if (NULL != text) { // This copies the text into a new Lua string. lua_pushstring(L, text); } else { lua_pushnil(L); } } else { lua_pushnil(L); } return 1; // Number of results }
static int SyncTableIndex(lua_State* dstL) { if (lua_isnoneornil(dstL, -1)) return 0; auto slh = CLuaHandleSynced::GetSyncedHandle(dstL); if (!slh->IsValid()) return 0; auto srcL = slh->GetLuaState(); const int srcTop = lua_gettop(srcL); const int dstTop = lua_gettop(dstL); // copy the index & get value lua_pushvalue(srcL, LUA_GLOBALSINDEX); const int keyCopied = LuaUtils::CopyData(srcL, dstL, 1); assert(keyCopied > 0); lua_rawget(srcL, -2); // copy to destination const int valueCopied = LuaUtils::CopyData(dstL, srcL, 1); if (lua_istable(dstL, -1)) { // disallow writing in SYNCED[...] lua_newtable(dstL); { // the metatable LuaPushNamedCFunc(dstL, "__newindex", SyncTableNewIndex); LuaPushNamedCFunc(dstL, "__metatable", SyncTableMetatable); } lua_setmetatable(dstL, -2); } assert(valueCopied == 1); assert(dstTop + 1 == lua_gettop(dstL)); lua_settop(srcL, srcTop); return valueCopied; }
static LUA_FUNCTION(openssl_digest_new) { const EVP_MD* md = get_digest(L, 1); if (md) { int ret; ENGINE* e = (!lua_isnoneornil(L, 2)) ? CHECK_OBJECT(2, ENGINE, "openssl.engine") : NULL; EVP_MD_CTX* ctx = EVP_MD_CTX_create(); EVP_MD_CTX_init(ctx); ret = EVP_DigestInit_ex(ctx, md, e); if (ret == 1) { PUSH_OBJECT(ctx, "openssl.evp_digest_ctx"); } else { EVP_MD_CTX_destroy(ctx); return openssl_pushresult(L, ret); } } else lua_pushnil(L); return 1; }
static int traceback(lua_State *L) { if (!lua_isstring(L, 1)) { /* Non-string error object? Try metamethod. */ if (lua_isnoneornil(L, 1) || !luaL_callmeta(L, 1, "__tostring") || !lua_isstring(L, -1)) return 1; /* Return non-string error object. */ lua_remove(L, 1); /* Replace object by result of __tostring metamethod. */ } lua_getfield(L, LUA_GLOBALSINDEX, "debug"); if (!lua_istable(L, -1)) { lua_pop(L, 1); return 1; } lua_getfield(L, -1, "traceback"); if (!lua_isfunction(L, -1)) { lua_pop(L, 2); return 1; } lua_pushvalue(L, 1); /* Push error message. */ lua_pushinteger(L, 2); /* Skip this function and debug.traceback(). */ lua_call(L, 2, 1); /* Call debug.traceback(). */ return 1; }
static int os_time (LuaThread *L) { THREAD_CHECK(L); time_t t; if (lua_isnoneornil(L, 1)) /* called without args? */ t = time(NULL); /* get current time */ else { struct tm ts; luaL_checktype(L, 1, LUA_TTABLE); L->stack_.setTopIndex(1); /* make sure table is at the top */ ts.tm_sec = getfield(L, "sec", 0); ts.tm_min = getfield(L, "min", 0); ts.tm_hour = getfield(L, "hour", 12); ts.tm_mday = getfield(L, "day", -1); ts.tm_mon = getfield(L, "month", -1) - 1; ts.tm_year = getfield(L, "year", -1) - 1900; ts.tm_isdst = getboolfield(L, "isdst"); t = mktime(&ts); } if (t == (time_t)(-1)) L->stack_.push(LuaValue::Nil()); else lua_pushnumber(L, (double)t); return 1; }
static int t_find (lua_State *L) { luaL_checktype(L, 1, LUA_TTABLE); luaL_checkany(L, 2); #if 1 lua_settop(L, 3); if (!lua_find(L, 1)) { lua_pushnil(L); } #else if (!lua_isnoneornil(L, 3)) lua_pushvalue(L, 3); else lua_pushnil(L); while (lua_next(L, 1)) { if (lua_equal(L, -1, 2)) { lua_pop(L, 1); return 1; } lua_pop(L, 1); } lua_pushnil(L); #endif return 1; }
/** * Evaluate Lua code. */ static int luaEngineEval(lua_State *L) { // First param is pointer to the engine, it must not // be nil and must be light user data. if (!lua_isnoneornil(L, 1) && lua_islightuserdata(L, 1)) { LuaEngine* engine = (LuaEngine*) lua_touserdata(L, 1); if (NULL != engine) { const char* code = luaL_checkstring(L, 2); int result = engine->eval(code); if (0 != result) { // Return true to Lua. lua_pushboolean(L, 1); return 1; // Number of results } } } // Return false to Lua. lua_pushboolean(L, 0); return 1; // Number of results }
static int reportAchievement(lua_State* L) { GooglePlay *gms = getInstance(L, 1); const char* id = luaL_checkstring(L, 2); int numSteps = 0; int immediate = 0; if (!lua_isnoneornil(L, 3)) { if(lua_isboolean(L, 3)) { immediate = lua_toboolean(L, 3); } else { numSteps = luaL_checkinteger(L, 3); immediate = lua_toboolean(L, 4); } } gms->reportAchievement(id, numSteps, immediate); return 0; }
static int os_time (lua_State *L) { time_t t; if (lua_isnoneornil(L, 1)) /* called without args? */ t = time(NULL); /* get current time */ else { struct tm ts; luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 1); /* make sure table is at the top */ ts.tm_sec = getfield(L, "sec", 0, 0); ts.tm_min = getfield(L, "min", 0, 0); ts.tm_hour = getfield(L, "hour", 12, 0); ts.tm_mday = getfield(L, "day", -1, 0); ts.tm_mon = getfield(L, "month", -1, 1); ts.tm_year = getfield(L, "year", -1, 1900); ts.tm_isdst = getboolfield(L, "isdst"); t = mktime(&ts); setallfields(L, &ts); /* update fields with normalized values */ } if (t != (time_t)(l_timet)t || t == (time_t)(-1)) return luaL_error(L, "time result cannot be represented in this installation"); l_pushtime(L, t); return 1; }
/* Returns a static map */ map_t *map_load_static(const char *name) { /* Make sure the map exists */ lua_getglobal(L, name); if (lua_isnoneornil(L, -1)) { return NULL; } /* Fill in the map dimensions */ lua_getfield(L, -1, "width"); if (lua_isnoneornil(L, -1)) { return NULL; } int width = lua_tonumber(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "height"); if (lua_isnoneornil(L, -1)) { return NULL; } int height = lua_tonumber(L, -1); lua_pop(L, 1); /* Create the map as usual */ map_t *map = map_new(width, height); /* Get the tiles */ lua_getfield(L, -1, "tiles"); if (lua_isnoneornil(L, -1)) { return NULL; } const char *raw_tiles = lua_tostring(L, -1); lua_pop(L, 1); /* Fill in the tiles based on the map */ const char *ok_tiles = OK_TILES; int cur_tile = 0, scan = 0; while (raw_tiles[scan++]) { if (strchr(ok_tiles, raw_tiles[scan])) { switch (raw_tiles[scan]) { case '.': map->tiles[cur_tile++] = tileset[TILE_FLOOR]; break; case '#': map->tiles[cur_tile++] = tileset[TILE_WALL]; break; case '@': player->x = cur_tile % map->width; player->y = (cur_tile-(cur_tile%map->width))/map->width; map->tiles[cur_tile++] = tileset[TILE_FLOOR]; default: break; } } } /* Run an optional initialization function */ lua_getfield(L, -1, "init"); if (!lua_isnoneornil(L, -1)) { lua_call(L, 0, 0); } /* Clean up the stack */ lua_pop(L, 2); return map; }
/** * poll({{fd = socket, events = FLAGS}, ...}, timeout) */ static int nixio_poll(lua_State *L) { int len = lua_objlen(L, 1); int i, fd; int timeout = luaL_optint(L, 2, 0); int status = -1; /* we are being abused as sleep() replacement... */ if (lua_isnoneornil(L, 1) || len < 1) { if (!poll(NULL, 0, timeout)) { lua_pushinteger(L, 0); return 1; } else { return nixio__perror(L); } } luaL_checktype(L, 1, LUA_TTABLE); struct pollfd *fds = calloc(len, sizeof(struct pollfd)); if (!fds) { return luaL_error(L, NIXIO_OOM); } for (i = 0; i < len; i++) { lua_rawgeti(L, 1, i+1); if (!lua_istable(L, -1)) { free(fds); return luaL_argerror(L, 1, "invalid datastructure"); } lua_pushliteral(L, "fd"); lua_rawget(L, -2); fd = nixio__tofd(L, -1); if (fd == -1) { free(fds); return luaL_argerror(L, 1, "invalid fd in datastructure"); } fds[i].fd = fd; lua_pushliteral(L, "events"); lua_rawget(L, -3); fds[i].events = (short)lua_tointeger(L, -1); lua_pop(L, 3); } status = poll(fds, (nfds_t)len, timeout); if (status == 0) { free(fds); lua_pushboolean(L, 0); return 1; } else if (status < 0) { free(fds); return nixio__perror(L); } for (i = 0; i < len; i++) { lua_rawgeti(L, 1, i+1); lua_pushliteral(L, "revents"); lua_pushinteger(L, fds[i].revents); lua_rawset(L, -3); lua_pop(L, 1); } free(fds); lua_pushinteger(L, status); lua_pushvalue(L, 1); return 2; }
bool LuaState::IsValid(int index) const { return lua_isnoneornil(m_state, index) == 0; }