bool LuaStack::init(void) { _state = lua_open(); luaL_openlibs(_state); toluafix_open(_state); // Register our version of the global "print" function const luaL_reg global_functions [] = { {"print", lua_print}, {NULL, NULL} }; luaL_register(_state, "_G", global_functions); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) luaopen_lua_extensions(_state); #endif g_luaType.clear(); register_all_cocos2dx(_state); register_all_cocos2dx_extension(_state); register_cocos2dx_extension_CCBProxy(_state); tolua_opengl_open(_state); register_all_cocos2dx_ui(_state); register_all_cocos2dx_studio(_state); register_all_cocos2dx_manual(_state); register_all_cocos2dx_module_manual(_state); register_all_cocos2dx_extension_manual(_state); register_all_cocos2dx_coco_studio_manual(_state); register_all_cocos2dx_ui_manual(_state); register_all_cocos2dx_spine(_state); register_all_cocos2dx_spine_manual(_state); register_glnode_manual(_state); #if CC_USE_PHYSICS register_all_cocos2dx_physics(_state); register_all_cocos2dx_physics_manual(_state); #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) LuaObjcBridge::luaopen_luaoc(_state); #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) LuaJavaBridge::luaopen_luaj(_state); #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) tolua_web_socket_open(_state); register_web_socket_manual(_state); #endif register_xml_http_request(_state); register_all_cocos2dx_deprecated(_state); register_all_cocos2dx_manual_deprecated(_state); tolua_script_handler_mgr_open(_state); // add cocos2dx loader addLuaLoader(cocos2dx_lua_loader); return true; }
int register_extension_module(lua_State* tolua_S) { lua_getglobal(tolua_S, "_G"); if (lua_istable(tolua_S,-1))//stack:...,_G, { register_all_cocos2dx_extension(tolua_S); register_all_cocos2dx_extension_manual(tolua_S); } lua_pop(tolua_S, 1); return 1; }
bool LuaStack::init(void) { _state = lua_open(); luaL_openlibs(_state); toluafix_open(_state); // Register our version of the global "print" function const luaL_reg global_functions [] = { {"print", lua_print}, {"LuaLoadChunksFromZIP", LuaStack::lua_loadChunksFromZIP}, {NULL, NULL} }; luaL_register(_state, "_G", global_functions); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) luaopen_lua_extensions(_state); #endif // register CCLuaStackSnapshot luaopen_snapshot(_state); g_luaType.clear(); register_all_cocos2dx(_state); register_all_cocos2dx_extension(_state); register_all_cocos2dx_manual(_state); register_all_cocos2dx_extension_manual(_state); // add spine support register_all_cocos2dx_spine(_state); register_all_cocos2dx_spine_manual(_state); #if CC_USE_EXTRA_FILTERS register_all_cocos2dx_extension_filter(_state); #endif luaopen_cocos2dx_extra_luabinding(_state); #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) luaopen_cocos2dx_extra_ios_iap_luabinding(_state); #endif luaopen_HelperFunc_luabinding(_state); #if CC_USE_PHYSICS register_all_cocos2dx_physics(_state); register_all_cocos2dx_physics_manual(_state); #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) LuaObjcBridge::luaopen_luaoc(_state); #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) LuaJavaBridge::luaopen_luaj(_state); #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) #if CC_USE_WEBSOCKET tolua_web_socket_open(_state); register_web_socket_manual(_state); #endif #endif #if ANYSDK_DEFINE > 0 register_all_anysdk(_state); register_all_anysdk_manual(_state); #endif //register_xml_http_request(_state); tolua_script_handler_mgr_open(_state); // add cocos2dx loader addLuaLoader(cocos2dx_lua_loader); return true; }