lua-users home
lua-l archive

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


Hi!

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
here

	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