这篇教程C++ tolua_pushusertype函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中tolua_pushusertype函数的典型用法代码示例。如果您正苦于以下问题:C++ tolua_pushusertype函数的具体用法?C++ tolua_pushusertype怎么用?C++ tolua_pushusertype使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了tolua_pushusertype函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: tolua_get_tarray_M_mpp/* get function: mpp */static int tolua_get_tarray_M_mpp(lua_State* tolua_S){ int tolua_index;#ifndef TOLUA_RELEASE { tolua_Error tolua_err; if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); }#endif tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;#ifndef TOLUA_RELEASE if (tolua_index<0 || tolua_index>=10) tolua_error(tolua_S,"array indexing out of range.",NULL);#endif tolua_pushusertype(tolua_S,(void*)mpp[tolua_index],"Point"); return 1;}
开发者ID:ConnorShore,项目名称:Game,代码行数:19,
示例2: tolua_ship_createstatic int tolua_ship_create(lua_State * L){ region *r = (region *)tolua_tousertype(L, 1, 0); const char *sname = tolua_tostring(L, 2, 0); if (sname) { const ship_type *stype = st_find(sname); if (stype) { ship *sh = new_ship(stype, r, default_locale); sh->size = stype->construction ? stype->construction->maxsize : 1; tolua_pushusertype(L, (void *)sh, TOLUA_CAST "ship"); return 1; } else { log_error("Unknown ship type '%s'/n", sname); } } return 0;}
开发者ID:philbooth,项目名称:server,代码行数:18,
示例3: tolua_building_createstatic int tolua_building_create(lua_State * L){ region *r = (region *)tolua_tousertype(L, 1, 0); const char *bname = tolua_tostring(L, 2, 0); if (!r) { log_error("building.create expects a region as argument 1"); } else if (!bname) { log_error("building.create expects a name as argument 2"); } else { const building_type *btype = bt_find(bname); if (btype) { building *b = new_building(btype, r, default_locale); tolua_pushusertype(L, (void *)b, TOLUA_CAST "building"); return 1; } } return 0;}
开发者ID:CTD1,项目名称:eressea-server-bugfixing,代码行数:18,
示例4: lock/** Assign usertype to global variable. * @param name name of global variable to assign the value to * @param data usertype data * @param type_name type name of the data * @param name_space C++ namespace of type, prepended to type_name */voidLuaContext::set_usertype(const char *name, void *data, const char *type_name, const char *name_space){ MutexLocker lock(__lua_mutex); std::string type_n = type_name; if ( name_space ) { type_n = std::string(name_space) + "::" + type_name; } assert_unique_name(name, "usertype"); __usertypes[name] = std::make_pair(data, type_n); tolua_pushusertype(__L, data, type_n.c_str()); lua_setglobal(__L, name);}
开发者ID:tempbottle,项目名称:fawkes,代码行数:24,
示例5: JIVEL_STACK_CHECK_BEGINJiveTile *jive_style_tile(lua_State *L, int index, const char *key, JiveTile *def) { JiveTile *value; JIVEL_STACK_CHECK_BEGIN(L); lua_pushcfunction(L, jiveL_style_value); lua_pushvalue(L, index); lua_pushstring(L, key); tolua_pushusertype(L, def, "Tile"); lua_call(L, 3, 1); value = tolua_tousertype(L, -1, 0); lua_pop(L, 1); JIVEL_STACK_CHECK_END(L); return value;}
开发者ID:gnalbandian,项目名称:squeezeplay,代码行数:18,
示例6: player_trade_get_session_idint player_trade_get_session_id(lua_State* L){#ifdef _DEBUG tolua_Error err; if( !tolua_isusertype(L,1,"CPlayerTrade",0,&err) || !tolua_isusertype(L,2,"CGameClient",0,&err)|| !tolua_isnumber(L,3,0,&err)|| !tolua_isnoobj(L,4,&err) ) { tolua_error(L,"#ferror in function 'player_trade_get_session_id'.",&err); return 0; }#endif CPlayerTrade* selfTrade = (CPlayerTrade*)tolua_tousertype(L,1,0); const CGUID& guid = selfTrade->GetSessionID(); tolua_pushusertype(L,(void*)&guid,"CGUID"); return 1;}
开发者ID:xiongshaogang,项目名称:mmo-resourse,代码行数:18,
示例7: tolua_pushusertypevoid LuaScripting::ExecuteHook(Entity *_entity, const char *_hook, int _value){ tolua_pushusertype(m_luaState, (void*)_entity, "Entity"); lua_setglobal(m_luaState, "entity"); lua_pop(m_luaState, 1); if (RunScript(_entity->GetName())) { lua_getglobal(m_luaState, _hook); if (lua_isfunction(m_luaState, -1)) { lua_pushnumber(m_luaState, _value); if (!strcmp(_hook, "onMouseOver") || !strcmp(_hook, "onMouseLeave")) { lua_call(m_luaState, 0, 0); } else { lua_call(m_luaState, 1, 0); } } } ResetEntityFileGlobals();}
开发者ID:EddieRingle,项目名称:cerberus,代码行数:18,
示例8: lua_glue_auto_GlDisplayService_constructorint lua_glue_auto_GlDisplayService_constructor(lua_State* L){ bool ok = true; glfw::GlfwContext* context; ok &= luaval_to_object<glfw::GlfwContext>(L, 1, "glfw.GlfwContext", &context, "display.GlDisplayService:GlDisplayService"); if (!ok) { tolua_error(L, "invalid arguments in function 'lua_glue_auto_GlDisplayService_constructor'", nullptr); return 0; } display::GlDisplayService* cobj = new display::GlDisplayService(*context); tolua_pushusertype(L, (void*)cobj, "display.GlDisplayService"); tolua_register_gc(L, lua_gettop(L)); return 1;}
开发者ID:scphillips,项目名称:Epic,代码行数:18,
示例9: __export inline virtual void __export(T const& container, const char* data_type, const char* out_table) { lua_State *lua = ScriptEngine::getSingleton().getLuaState(); lua_newtable(lua); // declare the empty table out_table typename T::const_iterator cursor; int count = 0; for (cursor = container.begin(); cursor != container.end(); ++cursor) { lua_pushinteger(lua, (++count)); tolua_pushusertype(lua, (void*)(*cursor), data_type); lua_settable(lua, -3); } lua_setglobal(lua, out_table); }
开发者ID:amireh,项目名称:Hax,代码行数:18,
示例10: tolua_bnd_cast/* Type casting */static int tolua_bnd_cast (lua_State* L){ void* v = tolua_tousertype(L,1,NULL); const char* s = tolua_tostring(L,2,NULL); if (!v) lua_pushnil(L); else if (v && s) { tolua_getmetatable(L,s); /* stack: ubox[u] super super[mt] flag mt */ if (lua_isnil(L,-1)) { tolua_error(L,"Unknown 'type' for 'tolua.cast' function",NULL); } tolua_pushusertype(L,v,s); } else { tolua_error(L,"Invalid arguments for 'tolua.cast' function",NULL); } return 1;}
开发者ID:261117370,项目名称:tolua,代码行数:20,
示例11: tolua_MessageHandler_sShareInstance////////////////////////////////////////////////////////////////////////////MessageHandler//////////////////////////////////////////////////////////////////////////static int tolua_MessageHandler_sShareInstance(lua_State *tolua_S){#ifndef TOLUA_ISEER_RELEASE tolua_Error tolua_err; if( !tolua_isusertable(tolua_S,1,"MessageHandler",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) { tolua_error(tolua_S,"#ferror in function 'MessageHandler::sShareInstance'",&tolua_err); return 0; }#endif MessageHandler *tolua_ret = MessageHandler::sShareInstance(); tolua_pushusertype(tolua_S,(void*)tolua_ret,"MessageHandler"); return 1;}
开发者ID:JamShan,项目名称:xcode_jifengyongzhezhuan,代码行数:21,
示例12: lua_gettop//------------------------------------------------------------------------------void QContactListener::PreSolve(b2Contact* pContact, const b2Manifold* oldManifold){ QNode* pNodeA = (QNode*)pContact->GetFixtureA()->GetBody()->GetUserData(); QNode* pNodeB = (QNode*)pContact->GetFixtureB()->GetBody()->GetUserData(); int ls = lua_gettop(g_L); LUA_EVENT_PREPARE("collisionPreSolve"); // On stack: event LUA_EVENT_SET_STRING("phase", "began"); LUA_EVENT_SET_TOLUA_PTR("nodeA", (void*)pNodeA, pNodeA->_getToLuaClassName()); LUA_EVENT_SET_TOLUA_PTR("nodeB", (void*)pNodeB, pNodeB->_getToLuaClassName()); LUA_EVENT_SET_TOLUA_PTR("target", (void*)pNodeA, pNodeA->_getToLuaClassName()); ls = lua_gettop(g_L); QContact con(pContact); ls = lua_gettop(g_L); LUA_EVENT_SET_TOLUA_PTR("contact", (void*)&con, "quick::QPhysics::Contact"); ls = lua_gettop(g_L); // World point of collision... is this correct? b2WorldManifold wm; pContact->GetWorldManifold(&wm); float dx = g_Sim->scaleP2D(wm.points[0].x); float dy = g_Sim->scaleP2D(wm.points[0].y); LUA_EVENT_SET_NUMBER("x", dx); LUA_EVENT_SET_NUMBER("y", dy); ls = lua_gettop(g_L); lua_getfield(g_L, LUA_GLOBALSINDEX, "handleNodeEvent"); lua_pushvalue(g_L, -2); // On stack: handleNodeEvent(event) tolua_pushusertype(g_L, (void*)pNodeA, pNodeA->_getToLuaClassName()); // On stack: handleNodeEvent(event, node) ls = lua_gettop(g_L); int s = lua_pcall(g_L, 2, 1, 0); ls = lua_gettop(g_L); LUA_REPORT_ERRORS(g_L, s); lua_pop(g_L, 2); ls = lua_gettop(g_L); bool b = true;}
开发者ID:AlexYanJianhua,项目名称:OpenQuick,代码行数:45,
示例13: lua_getfield void instance::pass_evt_to_lua(const Event& evt) { // pass to lua lua_getfield(lua_, LUA_GLOBALSINDEX, "processEvt"); if(!lua_isfunction(lua_, 1)) { log_->errorStream() << "could not find Lua event processor!" << " event: " << Event::_uid_to_string(evt.UID) << "#" << (int)evt.UID; lua_pop(lua_,1); return; } tolua_pushusertype(lua_,(void*)&evt,"Pixy::Event"); lua_call(lua_, 1, 1); int result = lua_toboolean(lua_, lua_gettop(lua_)); lua_remove(lua_, lua_gettop(lua_)); }
开发者ID:amireh,项目名称:Phantom,代码行数:19,
示例14: jiveL_style_fontint jiveL_style_font(lua_State *L) { /* stack is: * 1: widget * 2: key * 3: default */ jiveL_style_value(L); if (lua_isnil(L, -1)) { lua_pop(L, 1); /* default font */ tolua_pushusertype(L, jive_font_load("fonts/FreeSans.ttf", 15), "Font"); } return 1;}
开发者ID:gnalbandian,项目名称:squeezeplay,代码行数:19,
示例15: lua_ftk_bitmap_createstatic int lua_ftk_bitmap_create(lua_State* L){ tolua_Error err = {0}; FtkBitmap* retv; int w; int h; FtkColor clear_color; int param_ok = tolua_isnumber(L, 1, 0, &err) && tolua_isnumber(L, 2, 0, &err) && tolua_isusertype(L, 3, "FtkColor", 0, &err); return_val_if_fail(param_ok, 0); w = tolua_tonumber(L, 1, 0); h = tolua_tonumber(L, 2, 0); clear_color = *(FtkColor*)tolua_tousertype(L, 3, 0); retv = ftk_bitmap_create(w, h, clear_color); tolua_pushusertype(L, (FtkBitmap*)retv, "FtkBitmap"); return 1;}
开发者ID:htbegin,项目名称:pyftk,代码行数:19,
示例16: tolua_cNetwork_CreateUDPEndpoint/** Binds cNetwork::CreateUDPEndpoint */static int tolua_cNetwork_CreateUDPEndpoint(lua_State * L){ // Function signature: // cNetwork:CreateUDPEndpoint(Port, Callbacks) -> cUDPEndpoint cLuaState S(L); if ( !S.CheckParamStaticSelf("cNetwork") || !S.CheckParamNumber(2) || !S.CheckParamTable(3) || !S.CheckParamEnd(4) ) { return 0; } // Read the params: int port; cLuaState::cTableRefPtr callbacks; if (!S.GetStackValues(2, port, callbacks)) { return S.ApiParamError("Cannot read parameters"); } // Check validity: if ((port < 0) || (port > 65535)) { return S.ApiParamError("Port number out of range (%d, range 0 - 65535)", port); } ASSERT(callbacks != nullptr); // Invalid callbacks would have resulted in GetStackValues() returning false // Create the LuaUDPEndpoint glue class: auto endpoint = std::make_shared<cLuaUDPEndpoint>(std::move(callbacks)); endpoint->Open(static_cast<UInt16>(port), endpoint); // Register the endpoint to be garbage-collected by Lua: tolua_pushusertype(L, endpoint.get(), "cUDPEndpoint"); tolua_register_gc(L, lua_gettop(L)); // Return the endpoint object: S.Push(endpoint.get()); return 1;}
开发者ID:ThuGie,项目名称:MCServer,代码行数:44,
示例17: lua_register_sls_world_getSlothint lua_register_sls_world_getSloth(lua_State* tolua_S){ int argc = 0; sls::World* cobj = nullptr; cobj = (sls::World*)tolua_tousertype(tolua_S,1,0); if (!cobj) return 0; argc = lua_gettop(tolua_S) - 1; if (argc == 1) { tolua_Error tolua_err; if (tolua_isnumber(tolua_S,2,0,&tolua_err)) { int val = tolua_tonumber(tolua_S, 2, 0); sls::Sloth* ret = &(cobj->getSloth(val)); tolua_pushusertype(tolua_S,(void*)ret,"sls.Sloth"); return 1; } } return 0;}
开发者ID:grayfire,项目名称:SlothEvolution,代码行数:20,
示例18: sprintf//----------------------------------------------------------------------------------------bool BaseLevelBuilder::excuteScript(){ char buffer[64]; int levelId = m_level->getID(); sprintf(buffer, "Script//Level//%d.lua", levelId); CCLuaEngine* luaEngine = (CCLuaEngine*)CCScriptEngineManager::sharedManager()->getScriptEngine(); if (luaEngine) { lua_State *lua_S = luaEngine->getLuaState(); tolua_pushusertype(lua_S,(void*)this,"BaseLevelBuilder"); lua_setglobal(lua_S,"baseLevelBuilderObject"); } //execute the script std::string path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(buffer); CCScriptEngineManager::sharedManager()->getScriptEngine()->executeScriptFile(path.c_str()); return true;}
开发者ID:niuzb,项目名称:hellopetclient,代码行数:21,
示例19: toluaI_quest_quest00/* function: lua_get_quest */static int toluaI_quest_quest00(lua_State* tolua_S){ if ( !tolua_istype(tolua_S,1,LUA_TNUMBER,0) || !tolua_isnoobj(tolua_S,2) ) goto tolua_lerror; else { s32b q_idx = ((s32b) tolua_getnumber(tolua_S,1,0)); { quest_type* toluaI_ret = (quest_type*) lua_get_quest(q_idx); tolua_pushusertype(tolua_S,(void*)toluaI_ret,tolua_tag(tolua_S,"quest_type")); } } return 1;tolua_lerror: tolua_error(tolua_S,"#ferror in function 'quest'."); return 0;}
开发者ID:jcubic,项目名称:ToME,代码行数:21,
示例20: tolua_DecalScript_ADDDECALSPRITEMESSAGE_new00static int tolua_DecalScript_ADDDECALSPRITEMESSAGE_new00(lua_State* tolua_S){ tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"ADDDECALSPRITEMESSAGE",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else { { ADDDECALSPRITEMESSAGE* tolua_ret = (ADDDECALSPRITEMESSAGE*) new ADDDECALSPRITEMESSAGE(); tolua_pushusertype(tolua_S,(void*)tolua_ret,"ADDDECALSPRITEMESSAGE"); } } return 1;tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0;}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:20,
示例21: tolua_AIObjectScript_COMMANDSEQUENCEPARAMS_new00static int tolua_AIObjectScript_COMMANDSEQUENCEPARAMS_new00(lua_State* tolua_S){ tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"COMMANDSEQUENCEPARAMS",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else { { COMMANDSEQUENCEPARAMS* tolua_ret = (COMMANDSEQUENCEPARAMS*) new COMMANDSEQUENCEPARAMS(); tolua_pushusertype(tolua_S,(void*)tolua_ret,"COMMANDSEQUENCEPARAMS"); } } return 1;tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0;}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:20,
示例22: tolua_FadeUtility_FADEUTILITYPARAMS_new00static int tolua_FadeUtility_FADEUTILITYPARAMS_new00(lua_State* tolua_S){ tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"FADEUTILITYPARAMS",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) goto tolua_lerror; else { { FADEUTILITYPARAMS* tolua_ret = (FADEUTILITYPARAMS*) new FADEUTILITYPARAMS(); tolua_pushusertype(tolua_S,(void*)tolua_ret,"FADEUTILITYPARAMS"); } } return 1;tolua_lerror: tolua_error(tolua_S,"#ferror in function 'new'.",&tolua_err); return 0;}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:20,
示例23: toluaI_sound_sound___load_music00/* function: music_load_music */static int toluaI_sound_sound___load_music00(lua_State* tolua_S){ if ( !tolua_istype(tolua_S,1,LUA_TSTRING,0) || !tolua_isnoobj(tolua_S,2) ) goto tolua_lerror; else { cptr file = ((cptr) tolua_getstring(tolua_S,1,0)); { Mix_Music* toluaI_ret = (Mix_Music*) music_load_music(file); tolua_pushusertype(tolua_S,(void*)toluaI_ret,tolua_tag(tolua_S,"Mix_Music")); } } return 1;tolua_lerror: tolua_error(tolua_S,"#ferror in function '__load_music'."); return 0;}
开发者ID:jcubic,项目名称:ToME,代码行数:21,
示例24: tolua_MessageHandler_GetCurWildMsgPackagestatic int tolua_MessageHandler_GetCurWildMsgPackage(lua_State *tolua_S){#ifndef TOLUA_TXGUI_RELEASE tolua_Error tolua_err; if( !tolua_isusertype(tolua_S,1,"MessageHandler",0,&tolua_err) || !tolua_isnoobj(tolua_S,2,&tolua_err) ) { tolua_error(tolua_S,"#ferror in function 'MessageHandler::getCurWildMsgPackage'",&tolua_err); return 0; }#endif MessageHandler* self = (MessageHandler*)tolua_tousertype(tolua_S,1,0); WILD_MSG_PACKAGE* tolua_ret = (WILD_MSG_PACKAGE*) self->getWildMsgPackage(); tolua_pushusertype(tolua_S,(void*)tolua_ret,"WILD_MSG_PACKAGE"); return 1;}
开发者ID:JamShan,项目名称:xcode_jifengyongzhezhuan,代码行数:20,
示例25: tolua_GUID_CGUID_new01static int tolua_GUID_CGUID_new01(lua_State* tolua_S){ tolua_Error tolua_err; if ( !tolua_isusertable(tolua_S,1,"CGUID",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else { const char* str = ((const char*) tolua_tostring(tolua_S,2,0)); { CGUID* tolua_ret = (CGUID*) Mtolua_new((CGUID)(str)); tolua_pushusertype(tolua_S,(void*)tolua_ret,"CGUID"); } } return 1;tolua_lerror: return tolua_GUID_CGUID_new00(tolua_S);}
开发者ID:xiongshaogang,项目名称:mmo-resourse,代码行数:21,
示例26: baseobject_getid//====================================================================================================================================//得到IDint baseobject_getid(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_getid'.",&err); return 0; }#endif CBaseObject *self = (CBaseObject*)tolua_tousertype(L,1,0); //10.10注释 if( self != NULL ) { const CGUID& guid = self->GetExID(); tolua_pushusertype(L,(void*)&guid,"CGUID"); return 1; } return 0;}
开发者ID:xiongshaogang,项目名称:mmo-resourse,代码行数:23,
示例27: Lockbool cPlugin_NewLua::OnWeatherChanged(cWorld & a_World){ cCSLock Lock(m_CriticalSection); const char * FnName = GetHookFnName(cPluginManager::HOOK_WEATHER_CHANGED); ASSERT(FnName != NULL); if (!PushFunction(FnName)) { return false; } tolua_pushusertype(m_LuaState, &a_World, "cWorld"); if (!CallFunction(1, 1, FnName)) { return false; } bool bRetVal = (tolua_toboolean(m_LuaState, -1, 0) > 0); lua_pop(m_LuaState, 1); return bRetVal;}
开发者ID:l0ud,项目名称:MCServer,代码行数:21,
示例28: tolua_get_tarray_Array_pp/* get function: pp of class Array */static int tolua_get_tarray_Array_pp(lua_State* tolua_S){ int tolua_index; Array* self; lua_pushstring(tolua_S,".self"); lua_rawget(tolua_S,1); self = (Array*) lua_touserdata(tolua_S,-1);#ifndef TOLUA_RELEASE { tolua_Error tolua_err; if (!tolua_isnumber(tolua_S,2,0,&tolua_err)) tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err); }#endif tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;#ifndef TOLUA_RELEASE if (tolua_index<0 || tolua_index>=10) tolua_error(tolua_S,"array indexing out of range.",NULL);#endif tolua_pushusertype(tolua_S,(void*)self->pp[tolua_index],"Point"); return 1;}
开发者ID:ConnorShore,项目名称:Game,代码行数:23,
注:本文中的tolua_pushusertype函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ tolua_toboolean函数代码示例 C++ tolua_pushboolean函数代码示例 |