lua-users home
lua-l archive

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


Javier Guerra wrote:
On Friday 07 April 2006 1:48 pm, Matt Campbell wrote:
I would suggest adding "LuaInterpreter& L" as the first argument to
registered functions, and changing the current global utility functions
such as luaReturn to LuaInterpreter methods.  This way, your C++ binding
framework would support multiple Lua states in a portable way.

i think the LuaArgs object could have a reference to the LuaInterpreter object; if you need it, just call an accessor method.
Exactly.
also, the luaReturn in particular could be a macro (so it can do a full return), but should get a reference either to the LuaInterpreter object or the LuaArgs (and therefore to the LuaInterpreter itself).
There might be other ways that would avoid macros. E.g. having the return value in the function args:

   void func(const LuaArgs& args, LuaReturn& ret)
   {
       ...
   }

Both could have references to the LuaInterpreter object. You could even overload for the cases where you know there are no return values ever, allowing you to write

   void func(const LuaArgs& args)
   {
       ...
   }

for a function that returns nothing to the lua interpreter.

Thanks for your input Javier. Cheers,
Oliver