Inheritance diagram for mortic::IScript:
Public Member Functions | |
IScript (IRoot *root) | |
Constructor. | |
virtual | ~IScript () |
Destructor. | |
virtual void | runSimpleString (std::string str)=0 |
Run a string in the script's namespace. | |
virtual bool | variableExists (std::string var)=0 |
Check if a variable exists. | |
virtual float | callFunction (std::string name, std::string format,...)=0 |
Call a function. | |
virtual std::string | getNamespace ()=0 |
Returns the name of the namespace dictionary. | |
virtual void | pushValue (float val)=0 |
Push a value on to the virtual stack. | |
virtual float | popValue ()=0 |
Pop a value from the virtual stack. |
This is the C++ interface to access python scripts loaded in IScriptManager. In all python code, this object can be found in "self". Thus, a python script can call "self.popValue()" to pop a value off the virtual stack. Read more about that in pushValue()
Definition at line 34 of file IScriptManager.h.
|
Constructor.
Definition at line 38 of file IScriptManager.h. |
|
Destructor.
Definition at line 41 of file IScriptManager.h. |
|
Call a function. This is a combination function that calls a function in python with the arguments given, converted into the appropriate type. The format argument is a string that gives the format of the arguments to come, much like C's printf. A 'b' sends a bool, an 'i' sends an int, and a 'f' sends a float. Objects can be identified by '<Object>', where 'Object' is the class name minus the 'I'. Example: "callFunction("test", "b<LogManager>", true, someLogManager)" calls "test(True, someLogManager)" in Python. Just expect this function to work the way it should. Note: normal, unspecific objects are identified by "<>".
|
|
Returns the name of the namespace dictionary. Not for the faint of heart. This returns the namespace dictionary that this script runs in, which is a hash of the source of the script.
|
|
Pop a value from the virtual stack. See pushValue() for more info on the virtual stack.
|
|
Push a value on to the virtual stack. This function pushes a float onto the virtual stack. What is the VS? Well, normally exchanging values between C and Python is a bit of a pain, especially in a portable way. One way to overcome it is to use a virtual stack of floating-point numbers. Because the script can reference itself with "self", the script can take values off the stack that C put there. So, I can pushValue(3.14) in C, then self.popValue() in Python would return 3.14! Why a float? Almost every value in Mortic can be represented as a float. Integers, floats, even IObjects when referenced by ID! Warning: Items are popped off the stack in the reverse of the order they were pushed. Think of a stack of papers: You can only take off the one you just put on top.
|
|
Run a string in the script's namespace. This runs the python command(s) given in the scripts namespace. This is how you call functions and basically do anything.
|
|
Check if a variable exists. This returns whether or not the variable given exists in the script's namespace.
|