00001 #ifndef HEADER_SCRIPTSTATE_H
00002 #define HEADER_SCRIPTSTATE_H
00003
00004 class Path;
00005 class Scripter;
00006
00007 #include "NoCopy.h"
00008
00009 #include <string>
00010
00011 extern "C" {
00012 #include "lua.h"
00013 }
00014
00015
00016
00017
00018 class ScriptState : public NoCopy {
00019 private:
00020 lua_State *m_state;
00021 int m_errorHandlerIndex;
00022 private:
00023 void prepareErrorHandler();
00024 void insertErrorHandler(int index);
00025 void callStack(int error, int params=0, int returns=0);
00026 public:
00027 ScriptState();
00028 ~ScriptState();
00029
00030 void doFile(const Path &file);
00031 void doString(const std::string &input);
00032 bool callCommand(int funcRef, int param);
00033 void unref(int funcRef);
00034
00035 void registerFunc(const char *name, lua_CFunction func);
00036 void registerLeader(Scripter *leader);
00037 };
00038
00039 #endif