I'm making a scripting language with a bytecode machine in C++ just for fun. I plan to use it with an editor for a simple game. But I need to change scene nodes' positions, rotations etc within a script. This means I have to plan a bindining system. I don't know anything about bindings at all and how this has to be made. What are the main approaches and techniques for this?
Asked
Active
Viewed 184 times
1 Answers
1
If you have a fixed number of primitive functions that you want to call from your scripting language, you can just add instructions in your VM for them. See for instance Betz, "Embedded languages", Byte 13 #12 (Nov 1988) 409–416 (if you can find a copy).
However, it is more flexible to bind the names at run time. For this, you need to implement an environment for holding global variables and functions and an API to register them from C. In all, a sizeable piece of design and work. See for instance how Lua handles this in Passing a Language through the Eye of a Needle.

lhf
- 70,581
- 9
- 108
- 149
-
Yes, I think it will make its job. I can register functions of a general template: func (std::list
arguments). I can also do the same with classes: define onMethod (int, std::list – Dmitry K. May 13 '13 at 09:53arguments). These ones will be wrapper functions and classes. Thanks.