1 #ifndef AVR_SCRIPTENGINE_H
2 #define AVR_SCRIPTENGINE_H
6 #include "script/Scriptable.h"
7 #include "script/ScriptUtil.h"
13 //! Thrown if the application or script performs invalid script operation.
14 class ScriptException
: public util::Exception
{
16 ScriptException() : Exception(msg
) {}
17 ScriptException(const std::string
& msg
) : Exception(msg
) {}
18 ScriptException(const char *msg
) : Exception(msg
) {}
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
30 class ScriptProgram
: public script::Scriptable
{
32 ScriptProgram(script::VM
*vm
, const Program
& program
);
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
);
47 const Program
& program
;
51 static script::ScriptMethod
<ScriptProgram
> sm_methods
[];
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
);
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
{
74 void setProgram(const Program
& program
);
75 void loadConfig(const char *filename
);
78 ScriptProgram
*program
;
83 #endif /*SCRIPTENGINE_H_*/