Re: Getting a C++ object back from a luabind::object?

"Josh Klint" <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <000c01cc1578$598c5690$0ca503b0$@com>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.