Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 28, 2010, 7:16:12 PM (14 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).

Location:
code/branches/gamestate/src/libraries/core
Files:
2 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)
  • code/branches/gamestate/src/libraries/core/LuaState.h

    r6442 r6626  
    8080        void luaLog(unsigned int level, const std::string& message); // tolua_export
    8181        bool fileExists(const std::string& filename); // tolua_export
     82        std::string getSourceCode(const std::string& filename); // tolua_export
    8283
    8384        const std::stringstream& getOutput() const { return output_; }
Note: See TracChangeset for help on using the changeset viewer.