lua-users home
lua-l archive

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



On 05/10/2006, at 1:11 PM, Glenn Maynard wrote:

The Lua binding I'm using for C++ classes removes the "self" parameter
from the stack.  It's always passed to the bound class, after type
checking.  This allows arguments to be referenced more naturally, with
the first argument at 1, rather than 2.

This causes a problem: it confuses luaL_argerror, since it expects the
self parameter to be there; it subtracts one, giving the wrong offset
for error messages (and "bad self" for errors on argument 1).

Any suggestions on how to deal with this?

I had the same situation in my code. What I did is pull out the "self" argument (if it existed) and then did:

lua_remove (L, 1);

This then makes subsequent processing take each argument in a natural way (now the 1st argument after self is argument 1, and the errors are correct).

- Nick