[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: A couple of questions
- From: "Zulfiqar Malik" <zulfiqar.malik@...>
- Date: Wed, 16 Nov 2005 11:32:57 +0500
Hi,
Suppose I have a class registered in LUA. Suppose the following definition
of the class (I am using LuaBind for registration)
class CAdd
{
int m_a, m_b;
public:
CAdd(int a, int b)
{
m_a = a;
m_b = b;
}
int Add()
{
return m_a + m_b;
}
};
Now I make an object (global to that lua state) of this class from a LUA
script and do some operations. Everything works fine. Now suppose I want to
retrieve this object from C code. I get a user data (not light user data!)
type and a void * when I do lua_touserdata(.). Now I want to know whether
this void * will actually be a pointer to the CAdd object (I suppose it
should be)? I try type casting it to CAdd and get rubbish values:-(.
In addition, is there any way I can do something like lua_getglobal(state,
"a.m_a)? I tried but it returns nil. Is there a way to actually do something
like this?
Thanks in advance.
Regards,
Zulfiqar Inayat Malik.