Obtaining pointer to a C++ object

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Obtaining pointer to a C++ object

Ignacio Burgueño-3
Hi everyone.
I need to gain acces to a pointer of a C++ object, wrapped by Luna.
For instance, I need to pass an object of type Account as a parameter of a C
function.

i.e.
local account = Account()
myfunction(account)

I don't know how, within "myfunction" obtain the pointer to the 'account'
instance ? I thought that the pointer would be in the table, but I couldn't
find it.

Thanks in advance
Ignacio Burgueño




Reply | Threaded
Open this post in threaded view
|

Re: Obtaining pointer to a C++ object

Björn De Meyer
Ignacio Burgueño wrote:
/snip everything

AFAIKS, Luna stores the object pointer in an upvalue to your C function.
I only know how to get that upvalue in LUA 5, though, so check the 
lua 4 documentation.

-- 
"No one knows true heroes, for they speak not of their greatness." -- 
Daniel Remar.
Björn De Meyer 
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Obtaining pointer to a C++ object

Ignacio Burgueño-3
Thanks, Björn. I've just managed to do it with LUA 4.0

Greetings
Ignacio Burgueño

----- Original Message -----
From: "Björn De Meyer" <[hidden email]>
To: "Multiple recipients of list" <[hidden email]>
Sent: Wednesday, September 18, 2002 1:42 PM
Subject: Re: Obtaining pointer to a C++ object


> Ignacio Burgueño wrote:
> /snip everything
>
> AFAIKS, Luna stores the object pointer in an upvalue to your C function.
> I only know how to get that upvalue in LUA 5, though, so check the
> lua 4 documentation.


Reply | Threaded
Open this post in threaded view
|

Problems compiling Luna

jose marin2
In reply to this post by Björn De Meyer
Hi!

I've just downloaded the Luna file and tryied to compile the first 
sample,
but received the following error:

C:\lua\luna.tar\luna\teste\account.cpp(40) : 
error C2440: 'initializing' : cannot convert from 
'      int (__thiscall Account::*)(struct lua_State *)' to 
'const int (__thiscall Account::*)(struct lua_State *)'


the line 40 is

{"deposit",  &Account::deposit},

I've read the files luna.h and account.cpp, but found nothing that 
could explain that...

Any tip?

BTW, anybody is using Luna in your projects?



Reply | Threaded
Open this post in threaded view
|

Re: Problems compiling Luna

Milano Carvalho
It seems your compiler doesn't accept an int param if it must be a const int so I think you need convert it by yourself.

Milano



From: "jose_marin2 <[hidden email]>" <[hidden email]>
Reply-To: [hidden email]
To: Multiple recipients of list <[hidden email]>
Subject: Problems compiling Luna
Date: Sun, 16 Feb 2003 02:36:30 -0000

Hi!

I've just downloaded the Luna file and tryied to compile the first
sample,
but received the following error:

C:\lua\luna.tar\luna\teste\account.cpp(40) :
error C2440: 'initializing' : cannot convert from
'      int (__thiscall Account::*)(struct lua_State *)' to
'const int (__thiscall Account::*)(struct lua_State *)'


the line 40 is

{"deposit",  &Account::deposit},

I've read the files luna.h and account.cpp, but found nothing that
could explain that...

Any tip?

BTW, anybody is using Luna in your projects?




_________________________________________________________________
MSN Hotmail, o maior webmail do Brasil.  http://www.hotmail.com