Changeset 8688
- Timestamp:
- May 30, 2011, 6:51:00 PM (13 years ago)
- Location:
- code/branches/unity_build
- Files:
-
- 1 added
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/unity_build/cmake/tools/GenerateToluaBindings.cmake
r8650 r8688 49 49 SET(_tolua_pkgfile "${CMAKE_CURRENT_BINARY_DIR}/tolua.pkg") 50 50 SET(_tolua_cxxfile "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ToluaBind${_tolua_package}.cc") 51 SET(_tolua_hfile "${CMAKE_BINARY_DIR}/src/toluabind/${CMAKE_CFG_INTDIR}/ToluaBind${_tolua_package}.h")51 #SET(_tolua_hfile "${CMAKE_BINARY_DIR}/src/toluabind/${CMAKE_CFG_INTDIR}/ToluaBind${_tolua_package}.h") 52 52 53 53 SET(${_target_source_files} 54 54 ${${_target_source_files}} 55 55 ${_tolua_cxxfile} 56 ${_tolua_hfile}57 56 PARENT_SCOPE 58 57 ) … … 76 75 ENDFOREACH(_tolua_inputfile) 77 76 77 IF(TOLUA_PARSER_HOOK_SCRIPT) 78 # Hook scripts may contain functions that act as Tolua hooks 79 SET(_hook_script -L "${TOLUA_PARSER_HOOK_SCRIPT}") 80 ENDIF() 81 78 82 ADD_CUSTOM_COMMAND( 79 OUTPUT ${_tolua_cxxfile} ${_tolua_hfile}83 OUTPUT ${_tolua_cxxfile} 80 84 COMMAND toluaapp_orxonox -n ${_tolua_package} 81 85 -w ${CMAKE_CURRENT_SOURCE_DIR} 82 86 -o ${_tolua_cxxfile} 83 -H ${_tolua_hfile}84 87 -s ${TOLUA_PARSER_SOURCE} 88 ${_hook_script} 85 89 ${_tolua_pkgfile} 86 90 DEPENDS ${TOLUA_PARSER_DEPENDENCIES} -
code/branches/unity_build/src/CMakeLists.txt
r8644 r8688 145 145 ################### Tolua Bind ################## 146 146 147 # Create directory because the tolua application doesn't work otherwise 148 IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR}) 149 FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR}) 150 ENDIF() 151 152 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR}) 147 # Add hook script to the lua code that generates the bindings 148 SET(TOLUA_PARSER_HOOK_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/libraries/core/ToluaInterfaceHook.lua) 149 SET(TOLUA_PARSER_DEPENDENCIES ${TOLUA_PARSER_DEPENDENCIES} ${TOLUA_PARSER_HOOK_SCRIPT}) 153 150 154 151 ################ Sub Directories ################ -
code/branches/unity_build/src/external/tolua/lua/basic.lua
r5738 r8688 354 354 end 355 355 356 356 -- called after all the required C++ includes have been written 357 function post_include_hook(package_name) 358 end -
code/branches/unity_build/src/external/tolua/lua/package.lua
r8363 r8688 135 135 i = i+1 136 136 end 137 138 post_include_hook(self.name) 137 139 138 140 output('\n') -
code/branches/unity_build/src/libraries/core/LuaState.cc
r8351 r8688 40 40 #include "util/Exception.h" 41 41 #include "Resource.h" 42 #include "ToluaBindCore.h"43 42 #include "command/IOConsole.h" 44 43 45 44 namespace orxonox 46 45 { 47 LuaState::ToluaInterfaceMap LuaState::toluaInterfaces_s;48 std::vector<LuaState*> LuaState::instances_s;49 50 46 const std::string LuaState::ERROR_HANDLER_NAME = "errorHandler"; 51 52 // Do this after declaring toluaInterfaces_s and instances_s to avoid larger problems53 DeclareToluaInterface(Core);54 47 55 48 LuaState::LuaState() … … 277 270 } 278 271 272 /*static*/ LuaState::ToluaInterfaceMap& LuaState::getToluaInterfaces() 273 { 274 static ToluaInterfaceMap p; 275 return p; 276 } 277 278 /*static*/ std::vector<LuaState*>& LuaState::getInstances() 279 { 280 static std::vector<LuaState*> p; 281 return p; 282 } 283 279 284 /*static*/ bool LuaState::addToluaInterface(int (*function)(lua_State*), const std::string& name) 280 285 { 281 for (ToluaInterfaceMap::const_iterator it = toluaInterfaces_s.begin(); it != toluaInterfaces_s.end(); ++it)286 for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it) 282 287 { 283 288 if (it->first == name || it->second == function) … … 287 292 } 288 293 } 289 toluaInterfaces_s[name] = function;294 getToluaInterfaces()[name] = function; 290 295 291 296 // Open interface in all LuaStates 292 for (std::vector<LuaState*>::const_iterator it = instances_s.begin(); it != instances_s.end(); ++it)297 for (std::vector<LuaState*>::const_iterator it = getInstances().begin(); it != getInstances().end(); ++it) 293 298 (*function)((*it)->luaState_); 294 299 … … 299 304 /*static*/ bool LuaState::removeToluaInterface(const std::string& name) 300 305 { 301 ToluaInterfaceMap::iterator it = toluaInterfaces_s.find(name);302 if (it == toluaInterfaces_s.end())306 ToluaInterfaceMap::iterator it = getToluaInterfaces().find(name); 307 if (it == getToluaInterfaces().end()) 303 308 { 304 309 COUT(2) << "Warning: Cannot remove Tolua interface '" << name << "': Not found" << std::endl; … … 307 312 308 313 // Close interface in all LuaStates 309 for (std::vector<LuaState*>::const_iterator itState = instances_s.begin(); itState != instances_s.end(); ++itState)314 for (std::vector<LuaState*>::const_iterator itState = getInstances().begin(); itState != getInstances().end(); ++itState) 310 315 { 311 316 lua_pushnil((*itState)->luaState_); … … 314 319 315 320 // Remove entry 316 toluaInterfaces_s.erase(it);321 getToluaInterfaces().erase(it); 317 322 318 323 // Return dummy bool … … 322 327 /*static*/ void LuaState::openToluaInterfaces(lua_State* state) 323 328 { 324 for (ToluaInterfaceMap::const_iterator it = toluaInterfaces_s.begin(); it != toluaInterfaces_s.end(); ++it)329 for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it) 325 330 (*it->second)(state); 326 331 } … … 328 333 /*static*/ void LuaState::closeToluaInterfaces(lua_State* state) 329 334 { 330 for (ToluaInterfaceMap::const_iterator it = toluaInterfaces_s.begin(); it != toluaInterfaces_s.end(); ++it)335 for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it) 331 336 { 332 337 lua_pushnil(state); -
code/branches/unity_build/src/libraries/core/LuaState.h
r8672 r8688 48 48 #include <vector> 49 49 #include <boost/shared_ptr.hpp> 50 51 #include "ToluaInterface.h"52 50 53 51 namespace orxonox // tolua_export … … 120 118 121 119 typedef std::map<std::string, int (*)(lua_State *L)> ToluaInterfaceMap; 122 static ToluaInterfaceMap toluaInterfaces_s;123 static std::vector<LuaState*> instances_s;120 static ToluaInterfaceMap& getToluaInterfaces(); 121 static std::vector<LuaState*>& getInstances(); 124 122 }; // tolua_export 123 124 125 //! Helper class that registers/unregisters tolua bindings 126 class ToluaBindingsHelper 127 { 128 public: 129 ToluaBindingsHelper(int (*function)(lua_State*), const std::string& libraryName) 130 : libraryName_(libraryName) 131 { 132 LuaState::addToluaInterface(function, libraryName_); 133 } 134 ~ToluaBindingsHelper() 135 { 136 LuaState::removeToluaInterface(libraryName_); 137 } 138 private: 139 std::string libraryName_; 140 }; 125 141 } // tolua_export 126 142 -
code/branches/unity_build/src/modules/notifications/NotificationManager.cc
r8079 r8688 47 47 #include "NotificationQueue.h" 48 48 49 #include "ToluaBindNotifications.h"50 51 49 namespace orxonox 52 50 { … … 54 52 const std::string NotificationManager::ALL("all"); 55 53 const std::string NotificationManager::NONE("none"); 56 57 // Register tolua_open function when loading the library.58 DeclareToluaInterface(Notifications);59 54 60 55 ManageScopedSingleton(NotificationManager, ScopeID::Root, false); -
code/branches/unity_build/src/modules/pickup/PickupManager.cc
r7801 r8688 49 49 #include "PickupRepresentation.h" 50 50 51 #include "ToluaBindPickup.h"52 53 51 namespace orxonox 54 52 { 55 // Register tolua_open function when loading the library56 DeclareToluaInterface(Pickup);57 58 53 ManageScopedSingleton(PickupManager, ScopeID::Root, false); 59 54 -
code/branches/unity_build/src/modules/questsystem/QuestManager.cc
r8079 r8688 47 47 #include "QuestItem.h" 48 48 49 #include "ToluaBindQuestsystem.h"50 51 49 namespace orxonox 52 50 { 53 // Register tolua_open function when loading the library54 DeclareToluaInterface(Questsystem);55 56 51 ManageScopedSingleton(QuestManager, ScopeID::Root, false); 57 52 -
code/branches/unity_build/src/orxonox/Main.cc
r7801 r8688 39 39 #include "core/Game.h" 40 40 #include "core/LuaState.h" 41 #include "ToluaBindOrxonox.h"42 #include "ToluaBindNetwork.h"43 44 DeclareToluaInterface(Orxonox);45 DeclareToluaInterface(Network);46 41 47 42 namespace orxonox
Note: See TracChangeset
for help on using the changeset viewer.