lua-users home
lua-l archive

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

tolua ( is perfect for this...

it automatically creates wrapper functions around your class methods...

if you don't like tolua, you can still have a look at the code that tolua
creates and do something similar.


-----Original Message-----
[]On Behalf Of Björklund, Peter
Sent: Wednesday, August 29, 2001 6:02 PM
To: Multiple recipients of list
Subject: Lua and Objects


I'm sure that this question has been asked a few times. But bare with me :o)

In Lua I want to write something similar to this:

i = myExposedObject:someFunction( x )

In C++ I want to do something similar to:

static int someFunction( lua_State *L )
	object = (CppClass *) lua_popSelf( L ); // Insert correct function

	result = object->someFunctionImplementation();
	lua_pushnumber( L, result );

	return 1;

void main()
	CppClass exposedObject;

	// ....
	lua_register( L, "someFunction", someFunction );
	lua_setglobal( "myExposedObject", &exposedObject ); // Insert
correct function here
	// ....

	lua_dobuffer( ...... );

	// ....

Please help me out!

/Peter Bjorklund
Programmer DICE AB