实现主c++之间的通信程序和嵌入式ECL
我正在尝试使用第二种语言(目前是 ECL)扩展我正在开发的 C++ 3D 模拟,以在运行时动态地影响它。也就是说,我希望能够评估这样的脚本: (移动对象xy) 这会将“对象”移动到位置 (x,y)。
问题是,为了使其工作,ECL 环境需要调用一些 C++ 成员函数,例如对象的相应节点的实例来移动它。 现在我知道如何嵌入例如 ECL 并评估任意代码,以及如何从某些库调用纯 c 函数,但我不知道如何告诉 ECL 环境有关特定实例以及如何调用它们的方法。
我想这是一个常见的事情(如果不是使用 ECL),但当主程序是用 C++ 编写并使用一些 OO 时,我还没有找到任何信息如何做到这一点。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以为 C++ 应用程序创建一个命令行界面,然后通过管道进行通信。
这就是我所做的。它很简单,对我来说它足够快。
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.