文档介绍:FuBi: Automatic Function Exporting
for Scripting working
By Scott Bilas
scott@
/~scottb/gdc
Abstract
Much has been written about scripting engines – how to build the parser, how to design the virtual instruction set, and so on. And likewise, much has been written working – how to handle latency, how to pack up data efficiently, and how to pipe it to other machines. A critical piece tends to be missing, left as an exercise for the reader, and that is: how do you get your cool engine to talk to the game? That is, how does a scripting function call a C++ game function? How does work remote procedure call actually invoke the C++ function when it reaches the other machine? What about plicated issues such as passing pointers or strings over work?
Typical solutions to this problem end up requiring nontrivial architectural changes to your game engine and lots of shoehorn code. This paper describes a novel method for exporting a game’s functionality to dynamic systems such as scripting, networking, and databases that is pletely unobtrusive to a game’s systems. It can be bolted on to an existing game with very little effort. Exporting a game function of nearly any kind ultimately resolves down to inserting a single macro before the function declaration. Making the workable requires only a single additional macro inside of the function.
A prototype version of this system was published as the “Generic Function Binding Interface” gem in the book Game Programming Gems. Much has been learned since then. By the end of this paper, if you find yourself wondering whether or not this stuff really works, consider that an enhanced version of the design given here is essentially the foundation for much of Dungeon Siege, a game by Gas Powered Games. What started out as a 1000 line weeklong experiment (back when FuBi really just meant “function binder”) has turned into a 16K line gift that keeps on giving. This technique pletely changed the way that this author builds games.
Audien