Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/script_engine/src/lib/script_engine/scriptable.h @ 7654

Last change on this file since 7654 was 7654, checked in by bensch, 18 years ago

orxonox/script_engine: moved everything into cc-files

File size: 1.8 KB
Line 
1#ifndef __SCRIPTABLE_H__
2#define __SCRIPTABLE_H__
3
4#include <string>
5#include <map>
6#include <list>
7
8#include "VirtualMachine.h"
9#include "luaincl.h"
10
11namespace OrxScript
12{
13  class LuaScript;
14
15  //internal representation of a LuaScript
16  struct Script
17  {
18    int lastMethodIndex;
19    int methodBase;
20    int thisReference;
21    LuaScript* script;
22    int scriptReference; // reference to the script in its own lua_State
23    std::map<int, std::string> functionMap;
24  };
25
26  class Scriptable
27  {
28    friend class LuaScript;
29
30  public:
31    Scriptable (void);
32    virtual ~Scriptable (void);
33
34    // Method indexing check
35    int methods (LuaVirtualMachine& virtualMachine);
36    //int methods(){;return 1;} //BAD BAD HACK HACK HACK !!!!!!!!!!!!!!
37
38    char whatIsThis();
39
40    // When the script calls a class method, this is called
41    virtual int scriptCalling (LuaVirtualMachine& vm, std::string functionName) = 0;
42
43    // When the script function has returns
44    virtual void handleReturns (LuaVirtualMachine& vm, const std::string& strFunc) = 0;
45
46    std::string getFunctionAtIndex(int index, LuaVirtualMachine& virtualMachine);
47
48  protected:
49    void registerFunction(std::string functionName);//Adds a function to the internal function list
50  private:
51    bool scriptableAdded(LuaScript* script, int scriptRef, int reference);
52    //void scriptableFunctionAdded(LuaScript* script, int reference);
53
54
55    Script* getScriptByPointer(LuaScript* script);
56    Script* getScriptByVirtualMachine(LuaVirtualMachine& virtualMachine);
57    std::map<int, std::string>* getFunctionMapByPointer(LuaScript* scriptPointer);
58    int getLastMethodIndexByPointer(LuaScript* script);
59
60
61    bool scriptIsInScriptList(LuaScript* script);
62
63    void scriptDeleted(LuaScript* deleted);
64
65
66
67    std::list<std::string> functionList;
68    std::list<Script> scriptList;
69  };
70
71}
72
73#endif // __SCRIPTABLE_H__
Note: See TracBrowser for help on using the repository browser.