lua-users home
lua-l archive

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

If I have a userdata that has an attached metatable with a C function
for __index, how do I determine how it was called.

For example:

udata = CreateUserData() -- get a userdata with __index C metafunction


udata.SetStuff = 5

In my C __index function I only see two items on the stack, the
userdata and the string name of the key, "GetStuff", for example.

When I try to use the debug functions like below I get blanks for everything.

int n = 0;
lua_Debug lDebug
while (lua_getstack(L, n, &lDebug))
    lua_getinfo(L, "Sn", &lDebug);
    print("'%s' '%s' '%s'\n", lDebug.what,, lDebug.namewhat);

I am most interested in knowing the difference between
udata.GetStuff <==> udata:GetStuff()
udata.SetStuff = 5 <==> udata:SetStuff(5)

Thanks for any help,
   John Labenski