int lua_neo_Loader_getPath(lua_State* tolua_S) { int argc = 0; neo::Loader* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S,1,"neo.Loader",0,&tolua_err)) goto tolua_lerror; #endif cobj = (neo::Loader*)tolua_tousertype(tolua_S,1,0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S,"invalid 'cobj' in function 'lua_neo_Loader_getPath'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S)-1; if (argc == 0) { if(!ok) return 0; const char* ret = cobj->getPath(); tolua_pushstring(tolua_S,(const char*)ret); return 1; } CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getPath",argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S,"#ferror in function 'lua_neo_Loader_getPath'.",&tolua_err); #endif return 0; }
/* function: tolua_type */ static int toluaI_tolua_tolua_type00(lua_State* tolua_S) { if ( !tolua_isnoobj(tolua_S,2) ) goto tolua_lerror; else { LUA_VALUE lo = ((LUA_VALUE) tolua_getvalue(tolua_S,1,0)); { const char* toluaI_ret = (const char*) tolua_type(lo); tolua_pushstring(tolua_S,toluaI_ret); } } return 1; tolua_lerror: tolua_error(tolua_S,"#ferror in function 'type'."); return 0; }
static int tolua_ReadBody_Char(lua_State *tolua_S) { #ifndef TOLUA_TXGUI_RELEASE tolua_Error tolua_err; if( !tolua_isusertype(tolua_S,1,"WILD_MSG_PACKAGE",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) { tolua_error(tolua_S,"#ferror in function 'WILD_MSG_PACKAGE::tolua_WildMsg_GetCMD'",&tolua_err); return 0; } #endif WILD_MSG_PACKAGE* self = (WILD_MSG_PACKAGE*)tolua_tousertype(tolua_S,1,0); string tolua_ret = self->ReadChar(); tolua_pushstring(tolua_S, tolua_ret.c_str()); return 1; }
//名字 int baseobject_getname(lua_State* L) { #ifdef _DEBUG tolua_Error err; if(!tolua_isusertype(L,1,"CBaseObject",0,&err)|| !tolua_isstring(L,2,0,&err)|| !tolua_isnoobj(L,3,&err)) { tolua_error(L,"#ferror in function 'baseobject_getname'.",&err); return 0; } #endif CBaseObject *self = (CBaseObject*)tolua_tousertype(L,1,0); if( self != NULL ) { tolua_pushstring(L,self->GetName()); return 1; } return 0; }
bool cPlugin_NewLua::OnHandshake(cClientHandle * a_Client, const AString & a_Username) { cCSLock Lock(m_CriticalSection); const char * FnName = GetHookFnName(cPluginManager::HOOK_HANDSHAKE); ASSERT(FnName != NULL); if (!PushFunction(FnName)) { return false; } tolua_pushusertype(m_LuaState, a_Client, "cClientHandle"); tolua_pushstring (m_LuaState, a_Username.c_str()); if (!CallFunction(2, 1, FnName)) { return false; } bool bRetVal = (tolua_toboolean(m_LuaState, -1, 0) > 0); lua_pop(m_LuaState, 1); return bRetVal; }
bool cPlugin_NewLua::OnDisconnect(cPlayer * a_Player, const AString & a_Reason) { cCSLock Lock(m_CriticalSection); const char * FnName = GetHookFnName(cPluginManager::HOOK_DISCONNECT); ASSERT(FnName != NULL); if (!PushFunction(FnName)) { return false; } tolua_pushusertype(m_LuaState, a_Player, "cPlayer"); tolua_pushstring (m_LuaState, a_Reason.c_str()); if (!CallFunction(2, 1, FnName)) { return false; } bool bRetVal = (tolua_toboolean(m_LuaState, -1, 0) > 0); lua_pop(m_LuaState, 1); return bRetVal; }
/* function: quest_get_desc */ static int toluaI_quest_quest_get_desc00(lua_State* tolua_S) { if ( !tolua_istype(tolua_S,1,LUA_TNUMBER,0) || !tolua_istype(tolua_S,2,LUA_TNUMBER,0) || !tolua_isnoobj(tolua_S,3) ) goto tolua_lerror; else { s32b q_idx = ((s32b) tolua_getnumber(tolua_S,1,0)); s32b line = ((s32b) tolua_getnumber(tolua_S,2,0)); { cptr toluaI_ret = (cptr) quest_get_desc(q_idx,line); tolua_pushstring(tolua_S,(const char*)toluaI_ret); } } return 1; tolua_lerror: tolua_error(tolua_S,"#ferror in function 'quest_get_desc'."); return 0; }
static int lua_giveitem(unit * s, unit * d, const item_type * itype, int n, struct order *ord) { lua_State *L = (lua_State *)global.vm_state; char fname[64]; int result = -1; const char *iname = itype->rtype->_name; assert(s != NULL); strlcpy(fname, iname, sizeof(fname)); strlcat(fname, "_give", sizeof(fname)); lua_getglobal(L, fname); if (lua_isfunction(L, -1)) { tolua_pushusertype(L, s, TOLUA_CAST "unit"); tolua_pushusertype(L, d, TOLUA_CAST "unit"); tolua_pushstring(L, iname); lua_pushinteger(L, n); if (lua_pcall(L, 4, 1, 0) != 0) { const char *error = lua_tostring(L, -1); log_error("unit %s calling '%s': %s.\n", unitname(s), fname, error); lua_pop(L, 1); } else { result = (int)lua_tonumber(L, -1); lua_pop(L, 1); } } else { log_error("unit %s trying to call '%s' : not a function.\n", unitname(s), fname); lua_pop(L, 1); } return result; }
static int tolua_common_wyDevice_getDeviceId00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"wyDevice",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { const char* tolua_ret = (const char*) wyDevice::getDeviceId(); tolua_pushstring(tolua_S,(const char*)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'getDeviceId'.",&tolua_err); return 0; #endif }
/* function: api_utilities_fc_version */ static int tolua_common_a_fc_version00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isnoobj(tolua_S,1,&tolua_err) ) goto tolua_lerror; else #endif { lua_State* L = tolua_S; { const char* tolua_ret = (const char*) api_utilities_fc_version(L); tolua_pushstring(tolua_S,(const char*)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'fc_version'.",&tolua_err); return 0; #endif }
static int lc_age(struct attrib *a, void *owner) { building_action *data = (building_action *)a->data.v; const char *fname = data->fname; const char *fparam = data->param; building *b = (building *)owner; int result = -1; assert(b != NULL); if (fname != NULL) { lua_State *L = (lua_State *)global.vm_state; lua_getglobal(L, fname); if (lua_isfunction(L, -1)) { tolua_pushusertype(L, (void *)b, TOLUA_CAST "building"); if (fparam) { tolua_pushstring(L, fparam); } if (lua_pcall(L, fparam ? 2 : 1, 1, 0) != 0) { const char *error = lua_tostring(L, -1); log_error("lc_age(%s) calling '%s': %s.\n", buildingname(b), fname, error); lua_pop(L, 1); } else { result = (int)lua_tonumber(L, -1); lua_pop(L, 1); } } else { log_error("lc_age(%s) calling '%s': not a function.\n", buildingname(b), fname); lua_pop(L, 1); } } return (result != 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; }
/* method: GetSuperName of class Object */ static int tolua_Object_Object_GetSuperName00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"Object",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else #endif { { char* tolua_ret = (char*) Object::GetSuperName(); tolua_pushstring(tolua_S,(const char*)tolua_ret); } } return 1; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'GetSuperName'.",&tolua_err); return 0; #endif }
static int tolua_region_get_terrain(lua_State * L) { region *self = (region *)tolua_tousertype(L, 1, 0); tolua_pushstring(L, self->terrain->_name); return 1; }
static int tolua_faction_get_email(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); tolua_pushstring(L, faction_getemail(self)); return 1; }
TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v) { lua_pushnumber(L,index); tolua_pushstring(L,v); lua_settable(L,lo); }
static int tolua_building_get_info(lua_State * L) { building *self = (building *)tolua_tousertype(L, 1, 0); tolua_pushstring(L, self->display); return 1; }
static int tolua_building_get_type(lua_State * L) { building *self = (building *)tolua_tousertype(L, 1, 0); tolua_pushstring(L, self->type->_name); return 1; }
static int tolua_faction_get_race(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); tolua_pushstring(L, self->race->_name); return 1; }
bool StringValueAdapter::pushValue(lua_State* state, StringValueAdapter::value_type value) { tolua_pushstring(state, value.c_str()); return true; }
static int tolua_ship_get_display(lua_State * L) { ship *self = (ship *)tolua_tousertype(L, 1, 0); tolua_pushstring(L, self->display); return 1; }
static int tolua_ship_get_name(lua_State * L) { ship *self = (ship *)tolua_tousertype(L, 1, 0); tolua_pushstring(L, ship_getname(self)); return 1; }
static int tolua_ship_get_type(lua_State * L) { ship *self = (ship *)tolua_tousertype(L, 1, 0); tolua_pushstring(L, self->type->_name); return 1; }
static int tolua_faction_get_info(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); tolua_pushstring(L, faction_getbanner(self)); return 1; }
static int tolua_region_get_name(lua_State * L) { region *self = (region *)tolua_tousertype(L, 1, 0); tolua_pushstring(L, region_getname(self)); return 1; }
static int tolua_building_get_name(lua_State * L) { building *self = (building *)tolua_tousertype(L, 1, 0); tolua_pushstring(L, building_getname(self)); return 1; }
static int tolua_plane_get_name(lua_State * L) { plane *self = (plane *)tolua_tousertype(L, 1, 0); tolua_pushstring(L, self->name); return 1; }
static int tolua_faction_get_locale(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); tolua_pushstring(L, locale_name(self->locale)); return 1; }