When I was working with Lua in C#, I would add attributes to the methods I wanted to register with Lua, something like this:
// place tile marker
[LuaExport("settilemarker")]
public void SetTileMarker(int x, int y)
{
TileEditor.X = x;
TileEditor.Y = y;
}
Then, I would use reflection at runtime to find all these functions and register them, automagically, with a short piece of code that didn't have to be updated for each new function. This could also be used to automatically build a list of all registered commands easily etc.
My question is, is there any way to do this with Lua in C++? Like some kind of macro, or something. The information doesn't have to be available at runtime, I just want the convenience of marking each function right where it's defined and have them all be registered automatically, rather than having one long section somewhere of lua_register(..)s.
I've already found some tools that appear to be capable of generating code for this, but I was hoping there might be a way that doesn't require any extra manual work besides hitting Build. If not, I'll have to investigate those tools further after all.
Using Visual Studio 2010, by the way.