|
Hi I have a follow on question about namespaces from my earlier post about Swig and timers. Lets say for the sake of argument I have made some function bindings using a mixture of Swig and some hand bindings >From the way Swig works, when called from Lua this would give me something like -- Some function calls graphics.initGraphics() graphics. setColour(aColour) comms.setBaudrate(baud) On reflection I have decided I would prefer the namespaces to look something like acme.graphics.initGraphics() acme.graphics. setColour(aColour) acme.comms.setBaudrate(baud) I am stuck as to how I can achieve this ? I guess I have 3 options 1) Create the bindings with the extra nesting level, for the manual bindings I might be able to figure this out in C, but I dont thing Swig allows you to add the extra nesting level of the namespaces (I could be wrong though ?) 2) Write some Lua code that would move the original tables to the new namespace version, and call that from a C init function with luaL_dostring() -- for each table I need to move, acme={} acme.graphics={} for k,v in pairs(graphics) do acme.graphics[k] = v end graphics = nil 3) Take the above Lua code, and translate it into the equivalent C API functions. I dont know how I would move a table though in C ? None of the above sound very easy or pleasant, however I am probably missing the obvious and elegant way to achieve this ? Any advice or code examples would be welcomed please. Thanks Regards Geoff |