[IronPython] Calling functions in IronPython that don't really exist
jslutter at reactorzero.com
Thu Dec 4 22:13:45 CET 2008
I'm writing an application that I want to provide runtime scripting via
IronPython for. This application loads "plug-ins" from assemblies to add
Each plug-in is a class with, for the sake of simplicity, a "Do" function.
What I'm trying to figure out is that if I have a class like:
public string Do( params object args )
..add the two arguments..
..return the result as a string..
That I could call it from IronPython like:
AddNumbers( 3, 4 )
When that happens a new instance of the AddNumbers class is created, the
arguments are then passed to the Do member function, the result is
returned back to Python.
This may seem like a weird way for scripting. But, doing it this way I
can do some other important things, such as keeping a history of the
commands. If, along with Do, the commands have Undo and Redo functions,
then I can keep the instances of the commands stored and should the user
need to undo their command, I can internally run the Undo function.
Any ideas on how I should approach this? I don't mind having to do a
good chunk of backend work so that to add new command plugins, I just
have to write a class with a Do function and possibly provide some
Attributes if necessary. If I have to make some concessions that is
fine, but I need to stick with the concept of creating an instance of a
class and executing a function to perform the operation.
I assume I'm either going to have to generate some sort of thunk
function (I have no idea where to start) or provide some sort of
'command runner' that really gets called.
Any help or guidance is mighty appreciated,
More information about the Ironpython-users