lua-users home
lua-l archive

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

I'd like to register a function to be called from Lua, however there are
two issues I'm running into:

1.  I'd like to avoid passing a lua_state

Granted, this isn't going to be directly possible, but basically I'd
like to hide Lua from the rest of my application and instead have it go
through a proxy.  So instead of:

int callback( struct lua_State *pLua );

I'd like to be able have something more like:

int callback( MyProxy *pProxy )

Where "callback" would query pProxy for the arguments supplied.  This
way I don't have external code dependent on Lua directly.

Is there a clean way of doing this or should I just handle the double
indirection myself (i.e. the proxy is called back, and then it calls the
real function with appropriately parsed args)?

2.  How to pass a "this" pointer?

Is there a standard way of passing a "this" pointer when calling C++
objects from Lua?  Right now I'm using a global, which seems rather