Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/script_engine/OLD/scriptable.h @ 8261

Last change on this file since 8261 was 8061, checked in by bensch, 19 years ago

merged the scriptengine back to the trunk

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