I'm trying to extend a c++ 3d simulation I'm working on with a second language (at the moment ECL) to dynamically influence it at runtime. That开发者_高级运维 is, I want to be able to have a script like this evaluated: (move object x y) that will move "object" to the position (x,y).
The problem is that in order for this to work the ECL environment needs to call some c++ member function of e.g. an instance of the corresponding node of the object to move it. Now I know how to embed for example ECL and have arbitrary code evaluated and also how to call plain c functions from some library, but I don't see how I can tell the ECL environment about specific instances and how to call their methods.
I suppose this a common thing (if not with ECL) to do and yet I haven't been able to find any information how to do this when the main program is written in c++ and uses some OO.
You could make a command line interface for the C++ application and then communicate via pipe. That is what I do. Its straightforward and for me it is fast enough.
精彩评论