lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Jens Wessling wrote:
The only thing I have to do to export a function to Lua is to preface it with LUA_EXPORT. This is #defined as __declspec(__dllexport)

Which, when you are using VC++ means to put the function declaration in the export table.

I then parse the binary image of the executable at run time and extract all of the functions that are exported, demangle their names, and use this information, not only to call the C++ function from Lua, but to insure they are called in a type-safe way, even for userdata/void* data. This idea was first proposed and written by Scott Bilas. For a good reference, see FuBi at http://members.aa.net/~scottb/gdc/ .


I have looked at that paper, but since I am working on multiple
platforms/compilers I'm not able to use the technique (or rather,
I didn't feel like making it work on other platforms). My macros
aren't really all that intrusive, I'll stick with them.

Did you figure out a solution to passing parameters by reference?
What would you do in the case of, say:

  void getWindowSize(int* width, int* height);

I've worked around this case so far by either rewriting the
function or adding special code to the wrapper, but a generic
transparent solution would be nice.

Jason