Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/LuaState.h @ 5868

Last change on this file since 5868 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 3.6 KB
RevLine 
[1959]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Benjamin Knecht
[5654]24 *      Reto Grieder
[1959]25 *   Co-authors:
26 *      ...
27 *
28 */
29
[5654]30#ifndef _LuaState_H__
31#define _LuaState_H__
[1959]32
33#include "CorePrereqs.h"
34
[5654]35#include <map>
36#include <sstream>
[3196]37#include <string>
[3370]38#include <vector>
[5654]39#include <boost/shared_ptr.hpp>
[1959]40
[5654]41#include "util/ScopeGuard.h"
[5655]42#include "ToluaInterface.h"
[3370]43
[2710]44// tolua_begin
45namespace orxonox
46{
[5654]47    /**
48    @brief
49        Representation of an interface to lua
50    */
51    class _CoreExport LuaState
52    {
[3370]53// tolua_end
[5654]54    public:
55        LuaState();
56        ~LuaState();
[2710]57
[5781]58        void doFile(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export
[5654]59        void doString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo = shared_ptr<ResourceInfo>());
[1959]60
[5781]61        void includeFile(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export
[5654]62        void includeString(const std::string& code, shared_ptr<ResourceInfo> sourceFileInfo = shared_ptr<ResourceInfo>());
[1959]63
[5654]64        void luaPrint(const std::string& str); // tolua_export
65        void luaLog(unsigned int level, const std::string& message); // tolua_export
[5781]66        bool fileExists(const std::string& filename, const std::string& resourceGroup = "General", bool bSearchOtherPaths = true); // tolua_export
[2662]67
[5654]68        const std::stringstream& getOutput() const { return output_; }
69        void clearOutput() { output_.clear(); } // tolua_export
[1959]70
[5654]71        void setIncludeParser(std::string (*function)(const std::string&)) { includeParseFunction_ = function; }
72        lua_State* getInternalLuaState() { return luaState_; }
[1959]73
[5654]74        static bool addToluaInterface(int (*function)(lua_State*), const std::string& name);
75        static bool removeToluaInterface(const std::string& name);
76        static void openToluaInterfaces(lua_State* state);
77        static void closeToluaInterfaces(lua_State* state);
[1959]78
[5654]79    private:
[5781]80        shared_ptr<ResourceInfo> getFileInfo(const std::string& filename, const std::string& resourceGroup, bool bSearchOtherPaths);
[1959]81
[5654]82#if LUA_VERSION_NUM != 501
83        struct LoadS
84        {
85            const char* s;
86            size_t size;
87        };
[2026]88
[5654]89        static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size);
90#endif
[3370]91
[5654]92        std::stringstream output_;
93        lua_State* luaState_;
94        bool bIsRunning_;
95        shared_ptr<ResourceInfo> sourceFileInfo_;
96        std::string (*includeParseFunction_)(const std::string&);
[1959]97
[5654]98        typedef std::map<std::string, int (*)(lua_State *L)> ToluaInterfaceMap;
99        static ToluaInterfaceMap toluaInterfaces_s;
100        static std::vector<LuaState*> instances_s;
101    }; // tolua_export
102} // tolua_export
[1959]103
[5654]104#endif /* _LuaState_H__ */
Note: See TracBrowser for help on using the repository browser.