lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type)

Class Foo;

Foo*    pFoo = new Foo();

tolua_pushusertype( L,  pFoo, "Foo" );

 Off hand I can't remeber how to determine ownership of pFoo.

----- Original Message ----- From: "Enrico Colombini" <erix@erix.it>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Monday, March 12, 2007 8:19 AM
Subject: tolua++: passing C++ objects to Lua?


I read tolua++ manual and I found it pretty clear. I didn't understand, however, if I can make it work in the other direction: passing objects of known 'type' from C++ to a Lua function.

Example: if tolua++ knows of the C++ type "Thing", I need to pass a Thing object (not necessarily originating from Lua) from C++ to a Lua function and have Lua treat this value as if it were created by Thing:new().

In other words, I'd like to know how to push into a Lua stack a tolua++-recognized object+tag combination from the C++ side, if that's possible.

  Enrico