Fixed problem in DeviceSettings::strParam, returned wrong string
[avr-sim.git] / src / ScriptEngine.h
blob5c80fc9853d614caf0be7d45c4a74d0784cbedc9
1 #ifndef AVR_SCRIPTENGINE_H
2 #define AVR_SCRIPTENGINE_H
4 #include "Exception.h"
5 #include "script/VM.h"
6 #include "script/Scriptable.h"
7 #include "script/ScriptUtil.h"
9 namespace avr {
11 class Program;
13 //! Thrown if the application or script performs invalid script operation.
14 class ScriptException : public util::Exception {
15 public:
16 ScriptException() : Exception(msg) {}
17 ScriptException(const std::string & msg) : Exception(msg) {}
18 ScriptException(const char *msg) : Exception(msg) {}
21 /**
22 * @author Tom Haber
23 * @date May 17, 2008
24 * @brief Representation of a program in the scripting environment
26 * Representation of a program in the scripting environment.
27 * Provides two methods for getting the symbols in flash
28 * and ram (data).
30 class ScriptProgram : public script::Scriptable {
31 public:
32 ScriptProgram(script::VM *vm, const Program & program);
33 ~ScriptProgram();
35 public:
36 /**
37 * When a (C++) method is called from a script, this function
38 * is executed and unique method identifier is passed as parameter.
39 * Derived classes must override this if they add new scriptable methods.
40 * @param vm Script virtual machine executing the method.
41 * @param i Unique identifier (index) of the called method.
42 * @return Number of arguments returned in the script stack.
44 int methodCall(int i);
46 private:
47 const Program & program;
49 // scripting
50 int methodBase;
51 static script::ScriptMethod<ScriptProgram> sm_methods[];
53 private:
54 int script_functionName(const char *funcName);
55 int script_dataName(const char *funcName);
56 int script_functionAddress(const char *funcName);
57 int script_dataAddress(const char *funcName);
60 /**
61 * @author Tom Haber
62 * @date May 17, 2008
63 * @brief The scripting environment
65 * Representation the scripting environment in avr-sim.
66 * Contains the scripting representations of some core classes.
68 class ScriptEngine : public script::VM {
69 public:
70 ScriptEngine();
71 ~ScriptEngine();
73 public:
74 void setProgram(const Program & program);
75 void loadConfig(const char *filename);
77 private:
78 ScriptProgram *program;
83 #endif /*SCRIPTENGINE_H_*/