/* Open function */
TOLUA_API int tolua_orxonox_open (lua_State* tolua_S)
{
...
tolua_beginmodule(tolua_S,NULL);
tolua_constant(tolua_S,"_CoreExport",_CoreExport);
tolua_module(tolua_S,"orxonox",0);
...
return 1;
}
Do you spot the _CoreExport? The 'defining constants' in the tolua++ reference was meant a little bit differently...
It seems to me that theses constants can then be used when writing lua code, as demonstrated here:
http://www.codenix.com/~tolua/tolua++.html#using (see #define TRUE and the blow in lua code somewhere)
--> whenever we use macros or preproc. constants, tolua will screw up.
Therefore (if what I claim is actually true) we will have to write clean header files ourselves or let something do it for us.
I have just made a few tests and can state the following:
- tolua_bind.cc includes all the 'cleaned' files, which means they have to be syntactically (c++) correct.
- We can use gcc preprocessor output.
- grep can only operate on a single line, but if we were to write tolua_export on every line, grep is extremely helpful
So far I came up with the idea to create the preprocessor output, then use grep to skip all the lines not containing // tolua_export. There is one thing missing: in tolua_bind.cc, we'll have to replace
#include "MyHeader_clean.h" with
#include "MyHeader.h"
because tolua_bind needs the right header with all #inlcude <string> etc.
On unix systems, sed can do the job and replace all MyHeader_clean.h with MyHeader.h
sed 's/_clean//g' tolua_bind.cc > tolua_bind2.cc
mv tolua_bind2.cc tolua_bind.cc
(of course '_clean' is not very unique and therefore not very suitable)
I haven't even started to script any of this, but I'm pretty convinced that it is possible. What hasn't been tested yet is how to find the preprocessed files and pick the right ones to pass to grep. We could use the tolua.pkg file formatted in a special way, so that cmake READ can store all the values and with a FOR EACH we could process them...
It all sounds very hypothetical, but with a little bit of time...
Or, we simply write the cleaned ourselves (should not be that difficult...)