Changeset 3370 for code/trunk/src/core/LuaBind.cc
- Timestamp:
- Jul 30, 2009, 2:10:44 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/resource (added) merged: 3328,3336-3340,3342-3350,3352-3366
- Property svn:mergeinfo changed
-
code/trunk/src/core/LuaBind.cc
r3301 r3370 39 39 #include "util/Debug.h" 40 40 #include "util/StringUtils.h" 41 #include "ToluaBindCore.h"42 41 #include "Core.h" 43 42 44 43 namespace orxonox 45 44 { 46 LuaBind* LuaBind::singleton Ref_s = NULL;45 LuaBind* LuaBind::singletonPtr_s = NULL; 47 46 48 47 LuaBind::LuaBind() 49 48 { 50 assert(LuaBind::singletonRef_s == 0);51 LuaBind::singletonRef_s = this;52 53 49 this->includePath_ = Core::getMediaPathString(); 54 50 … … 65 61 luaopen_debug(luaState_); 66 62 #endif 67 tolua_Core_open(luaState_); 63 64 // Open all available tolua interfaces 65 this->openToluaInterfaces(luaState_); 66 68 67 output_ = ""; 69 68 isRunning_ = false; 70 69 } 70 71 LuaBind::~LuaBind() 72 { 73 this->closeToluaInterfaces(luaState_); 74 }; 71 75 72 76 void LuaBind::luaPrint(const std::string& str) … … 315 319 } 316 320 321 void LuaBind::addToluaInterface(int (*function)(lua_State*), const std::string& name) 322 { 323 toluaInterfaces_.push_back(std::make_pair(name, function)); 324 // Apply changes to our own lua state as well 325 (*function)(luaState_); 326 } 327 328 void LuaBind::openToluaInterfaces(lua_State* state) 329 { 330 for (unsigned int i = 0; i < toluaInterfaces_.size(); ++i) 331 (*toluaInterfaces_[i].second)(state); 332 } 333 334 void LuaBind::closeToluaInterfaces(lua_State* state) 335 { 336 for (unsigned int i = 0; i < toluaInterfaces_.size(); ++i) 337 { 338 lua_pushnil(state); 339 lua_setglobal(state, toluaInterfaces_[i].first.c_str()); 340 } 341 } 342 317 343 }
Note: See TracChangeset
for help on using the changeset viewer.