Re: Getting a C++ object back from a luabind::object?
Nigel Atkinson <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <1305761450.1899.4.camel@virNatty> |
Perhaps
return luabind::touserdata<Object*>(o);
instead? I.e. cast to a pointer rather than an object it self. Perhaps
underneath, it uses dynamic_cast.
I haven't used luabind::touserdata before though - I'm just guessing.
Personally I would have gone with
return luabind::object_cast<Object*>(o);
Nigel
On Wed, 2011-05-18 at 09:26 -0700, Josh Klint wrote:
> Here's what I'm trying:
>
> void Interpreter::PushObject(Object* o)
> {
> if (objectmap[o]==NULL) objectmap[o] = new luabind::object(L,o);
> objectmap[o]->push(L);
> }
>
> Object* Interpreter::ToObject(const int& index)
> {
> luabind::object o = luabind::object(L,index);
> return luabind::touserdata<Object>(o);
> }
>
> But if I use this code:
> Entity* entity = new Entity; //The class "Entity" is derived from "Object"
> PushObject(entity);
> entity = (Entity*)ToObject(-1);
>
> The value returned from ToObject() is NULL.
>
>
> Best Regards,
>
> Josh Klint
> CEO
> Leadwerks Software
> www.leadwerks.com
>
> -----Original Message-----
> From: Reko Tiira [mailto:[email protected]]
> Sent: Wednesday, May 18, 2011 1:35 AM
> To: [email protected]
> Subject: Re: [luabind] Getting a C++ object back from a luabind::object?
>
> I think what you want is:
>
> return luabind::touserdata<Object>(o);
>
> Regards,
> Reko Tiira
>
> ----------------------------------------------------------------------------
> --
> What Every C/C++ and Fortran developer Should Know!
> Read this article and learn how Intel has extended the reach of its
> next-generation tools to help Windows* and Linux* C/C++ and Fortran
> developers boost performance applications - including clusters.
> http://p.sf.net/sfu/intel-dev2devmay
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>
> ------------------------------------------------------------------------------
> What Every C/C++ and Fortran developer Should Know!
> Read this article and learn how Intel has extended the reach of its
> next-generation tools to help Windows* and Linux* C/C++ and Fortran
> developers boost performance applications - including clusters.
> http://p.sf.net/sfu/intel-dev2devmay
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay