1

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?

4

1 回答 1

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.

于 2013-04-04T17:04:04.357 回答