[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Problem with passing pointers ( touserdata )
- From: Michael Bauroth <Michael.Bauroth@...>
- Date: Wed, 05 Nov 2008 13:01:27 +0100
Hi,
I'm using an ARM port of Lua (Lua5.1-CE). Don't know if this matters.
Additionally I'm using Lunar / Luna to register a class and some
functions to Lua, e.g.
const char FComponent::className[] = "Component";
FLuna< FComponent >::RegType FComponent::methods[] = {
method( FComponent, SetPosition ),
method( FComponent, SetDimensions ),
method( FComponent, SetBackground ),
method( FComponent, SetParent ),
{ 0, 0 }
};
Creating the object from Lua works well, e.g.
comp = Component:new()
print( comp )
result in Lua is: Button (000ADE70)
pointer in C++: 0x000ade70
Both sides (C++ and Lua) show the same pointer value.
When I use this value in the next step to send it back from Lua to C++,
the value differs in C++ !?
comp = Component:new()
print( comp )
comp:SetParent( comp )
--> comp is 000ADE70
int FComponent::SetParent( lua_State *L )
{
void* value = ( void*)lua_touserdata( L, 1 );
return 0;
}
--> value is 0x000adf28
What happens here? Am I missing something?
Help / hints would be very appreciated.
Thanks in advance.
Micha