[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: How to know calling convention inside __index function
- From: "John Labenski" <jlabenski@...>
- Date: Wed, 30 May 2007 16:04:46 -0400
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
print(udata.GetStuff)
print(udata.GetStuff())
print(udata:GetStuff())
udata.SetStuff(5)
udata.SetStuff = 5
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.name, 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