Changeset 1959 for code/branches/objecthierarchy/src/core/LuaBind.cc
- Timestamp:
- Oct 19, 2008, 11:46:37 PM (17 years ago)
- Location:
- code/branches/objecthierarchy
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy
- Property svn:mergeinfo changed
/code/branches/script_trigger (added) merged: 1296,1307,1383,1541,1550,1671,1693,1851,1904,1906
- Property svn:mergeinfo changed
-
code/branches/objecthierarchy/src/core/LuaBind.cc
- Property svn:eol-style set to native
r1954 r1959 32 32 #include <map> 33 33 34 #include "CoreIncludes.h" 35 36 extern "C" { 37 #include <lualib.h> 38 #include <lauxlib.h> 39 } 40 34 #include "lua/lua.hpp" 41 35 #include "tolua/tolua++.h" 42 36 #include "tolua/tolua_bind.h" 37 #include "util/String.h" 38 #include "CoreIncludes.h" 43 39 44 40 namespace orxonox … … 60 56 luaopen_debug(luaState_); 61 57 #endif 62 tolua_ core_open(luaState_);58 tolua_Core_open(luaState_); 63 59 output_ = ""; 64 60 isRunning_ = false; … … 68 64 { 69 65 output_ += str; 70 COUT(4) << "Lua_output!:" << std::endl << str << std::endl << "***" << std::endl; 66 // COUT(4) << "Lua_output!:" << std::endl << str << std::endl << "***" << std::endl; 67 COUT(5) << str; 71 68 } 72 69 … … 101 98 102 99 if (luaTags) luaSource_ = replaceLuaTags(levelString); 103 COUT( 4) << "ParsedSourceCode: " << luaSource_ << std::endl;100 COUT(5) << "ParsedSourceCode: " << luaSource_ << std::endl; 104 101 } 105 102 … … 152 149 } 153 150 154 unsigned int LuaBind::getNextQuote(const std::string& text, unsigned int start)155 {156 unsigned int quote = start - 1;157 158 while ((quote = text.find('\"', quote + 1)) != std::string::npos)159 {160 unsigned int backslash = quote;161 unsigned int numbackslashes = 0;162 for (; backslash > 0; backslash--, numbackslashes++)163 if (text[backslash - 1] != '\\')164 break;165 166 if (numbackslashes % 2 == 0)167 break;168 }169 170 return quote;171 }172 173 151 std::string LuaBind::replaceLuaTags(const std::string& text) 174 152 { 175 153 // chreate map with all Lua tags 176 std::map< unsigned int, bool> luaTags;177 { 178 unsigned int pos = 0;154 std::map<size_t, bool> luaTags; 155 { 156 size_t pos = 0; 179 157 while ((pos = text.find("<?lua", pos)) != std::string::npos) 180 158 luaTags[pos++] = true; 181 159 } 182 160 { 183 unsigned int pos = 0;161 size_t pos = 0; 184 162 while ((pos = text.find("?>", pos)) != std::string::npos) 185 163 luaTags[pos++] = false; … … 188 166 // erase all tags from the map that are between two quotes 189 167 { 190 std::map< unsigned int, bool>::iterator it = luaTags.begin();191 std::map< unsigned int, bool>::iterator it2 = it;168 std::map<size_t, bool>::iterator it = luaTags.begin(); 169 std::map<size_t, bool>::iterator it2 = it; 192 170 bool bBetweenQuotes = false; 193 unsigned int pos = 0;171 size_t pos = 0; 194 172 while ((pos = getNextQuote(text, pos)) != std::string::npos) 195 173 { … … 214 192 { 215 193 bool expectedValue = true; 216 for (std::map< unsigned int, bool>::iterator it = luaTags.begin(); it != luaTags.end(); ++it)217 { 218 if ( (*it).second == expectedValue)194 for (std::map<size_t, bool>::iterator it = luaTags.begin(); it != luaTags.end(); ++it) 195 { 196 if (it->second == expectedValue) 219 197 expectedValue = !expectedValue; 220 198 else … … 234 212 std::string output; 235 213 { 236 std::map< unsigned int, bool>::iterator it = luaTags.begin();214 std::map<size_t, bool>::iterator it = luaTags.begin(); 237 215 bool bInPrintFunction = true; 238 unsigned int start = 0;239 unsigned intend = 0;216 size_t start = 0; 217 size_tend = 0; 240 218 241 219 do … … 253 231 std::string temp = text.substr(start, end - start); 254 232 { 255 unsigned int pos = 0;233 size_t pos = 0; 256 234 while ((pos = temp.find('[', pos)) != std::string::npos) 257 235 { 258 236 unsigned int tempCounter = 1; 259 unsigned int tempPos = pos++;237 size_t tempPos = pos++; 260 238 while(temp[++tempPos] == '=') { 261 239 tempCounter++; … … 272 250 } 273 251 { 274 unsigned int pos = 0;252 size_t pos = 0; 275 253 while ((pos = temp.find(']', pos)) != std::string::npos) 276 254 { 277 255 unsigned int tempCounter = 1; 278 unsigned int tempPos = pos++;256 size_t tempPos = pos++; 279 257 while(temp[++tempPos] == '=') { 280 258 tempCounter++;
Note: See TracChangeset
for help on using the changeset viewer.