Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 28, 2010, 7:16:12 PM (15 years ago)
Author:
rgrieder
Message:

Modified Debugger.lua so we can debug any Lua files from our Resources.
Debugging strings loaded with loadstring() cannot be debugged (not supported by Debugger.lua, it always assumes files).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gamestate/src/libraries/core/LuaState.cc

    r6625 r6626  
    135135
    136136        std::string chunkname;
    137         if (sourceFileInfo != NULL && !sourceFileInfo->fileSystemPath.empty())
     137        if (sourceFileInfo != NULL)
    138138        {
    139139            // Provide lua_load with the filename for debug purposes
    140140            // The '@' is a Lua convention to identify the chunk name as filename
    141             chunkname = '@' + sourceFileInfo->fileSystemPath;
    142         }
    143         else
    144         {
    145             // Use the beginning of the code string to identify the chunk
    146             chunkname = code.substr(0, 80);
     141            chunkname = '@' + sourceFileInfo->filename;
     142        }
     143        else
     144        {
     145            // Use the code string to identify the chunk
     146            chunkname = code;
    147147        }
    148148
     
    195195    }
    196196
     197    //! Returns the content of a file
     198    std::string LuaState::getSourceCode(const std::string& filename)
     199    {
     200        shared_ptr<ResourceInfo> info = Resource::getInfo(filename);
     201        if (info == NULL)
     202            return "";
     203        else
     204            return Resource::open(info)->getAsString();
     205    }
     206
    197207#if LUA_VERSION_NUM != 501
    198208    const char * LuaState::lua_Chunkreader(lua_State *L, void *data, size_t *size)
Note: See TracChangeset for help on using the changeset viewer.