lua-users home
lua-l archive

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


Hi

Simple question, how to pass class pointer as argument to LUA function ?
I use LUA 5.0 And LuaBind
I've registered some class members:

luabind::class_<c_FOO>(g_L, "c_FOO")
                            .def("Do", &c_FOO::Do)
                            .def("DoOther", &c_FOO::DoOther)
                            ;

And now (in C++) I have method like this:

void c_FOO::CallSomeLuaFunction()
{
  //
  // And now I need to call 'function Lua_Foo(arg1)'
  // where arg1 is a 'this'
  // and inside call some of c_FOO methods
  // arg1:Do() for example
  //

  lua_pushstring(g_L, "LuaFoo");
  lua_gettable(g_L, LUA_GLOBALSINDEX);
  lua_pushstring(g_L, "this");
  lua_call(g_L, 1, 0);

  //
  // The code above do nothing, how to modify it ???
  //
}

THX