Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 19, 2008, 11:46:37 PM (16 years ago)
Author:
rgrieder
Message:

Merged script_trigger branch into objecthierarchy branch.
Also merged changes in Script.cc and Script.h manually to LuaBind.cc and LuaBind.h.

Location:
code/branches/objecthierarchy
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy

  • code/branches/objecthierarchy/src/core/LuaBind.cc

    • Property svn:eol-style set to native
    r1954 r1959  
    3232#include <map>
    3333
    34 #include "CoreIncludes.h"
    35 
    36 extern "C" {
    37 #include <lualib.h>
    38 #include <lauxlib.h>
    39 }
    40 
     34#include "lua/lua.hpp"
    4135#include "tolua/tolua++.h"
    4236#include "tolua/tolua_bind.h"
     37#include "util/String.h"
     38#include "CoreIncludes.h"
    4339
    4440namespace orxonox
     
    6056    luaopen_debug(luaState_);
    6157#endif
    62     tolua_core_open(luaState_);
     58    tolua_Core_open(luaState_);
    6359    output_ = "";
    6460    isRunning_ = false;
     
    6864  {
    6965    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;
    7168  }
    7269
     
    10198
    10299    if (luaTags) luaSource_ = replaceLuaTags(levelString);
    103     COUT(4) << "ParsedSourceCode: " << luaSource_ << std::endl;
     100    COUT(5) << "ParsedSourceCode: " << luaSource_ << std::endl;
    104101  }
    105102
     
    152149  }
    153150
    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 
    173151  std::string LuaBind::replaceLuaTags(const std::string& text)
    174152  {
    175153    // 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;
    179157      while ((pos = text.find("<?lua", pos)) != std::string::npos)
    180158        luaTags[pos++] = true;
    181159    }
    182160    {
    183       unsigned int pos = 0;
     161      size_t pos = 0;
    184162      while ((pos = text.find("?>", pos)) != std::string::npos)
    185163        luaTags[pos++] = false;
     
    188166    // erase all tags from the map that are between two quotes
    189167    {
    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;
    192170      bool bBetweenQuotes = false;
    193       unsigned int pos = 0;
     171      size_t pos = 0;
    194172      while ((pos = getNextQuote(text, pos)) != std::string::npos)
    195173      {
     
    214192    {
    215193      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)
    219197          expectedValue = !expectedValue;
    220198        else
     
    234212    std::string output;
    235213    {
    236       std::map<unsigned int, bool>::iterator it = luaTags.begin();
     214      std::map<size_t, bool>::iterator it = luaTags.begin();
    237215      bool bInPrintFunction = true;
    238       unsigned int start = 0;
    239       unsigned int end = 0;
     216      size_t start = 0;
     217      size_tend = 0;
    240218
    241219      do
     
    253231          std::string temp = text.substr(start, end - start);
    254232          {
    255             unsigned int pos = 0;
     233            size_t pos = 0;
    256234            while ((pos = temp.find('[', pos)) != std::string::npos)
    257235            {
    258236              unsigned int tempCounter = 1;
    259               unsigned int tempPos = pos++;
     237              size_t tempPos = pos++;
    260238              while(temp[++tempPos] == '=') {
    261239                tempCounter++;
     
    272250          }
    273251          {
    274             unsigned int pos = 0;
     252            size_t pos = 0;
    275253            while ((pos = temp.find(']', pos)) != std::string::npos)
    276254            {
    277255              unsigned int tempCounter = 1;
    278               unsigned int tempPos = pos++;
     256              size_t tempPos = pos++;
    279257              while(temp[++tempPos] == '=') {
    280258                tempCounter++;
Note: See TracChangeset for help on using the changeset viewer.