lua-users home
lua-l archive

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


(this thread is quite outdated now, a recent update was posted by
Peter: http://lua-users.org/lists/lua-l/2008-08/msg00602.html)

2009/1/16 Anders Backman <andersb@cs.umu.se>:
> What if you do:
> register.h:
> class register {
>   typedef vector<A*> AVector;
>   AVector entries;
>   void exec() {
> for(register::iterator it = register::begin(); it != register.end(); ++it)
> {
>   (*it).foo(); // Call the method B::foo()  (which was instantiated in lua)
> }
>
>
> };
> struct A { virtual void foo(){}; };
> struct B : { void foo(){}; };
>
> script.lua:
> R = new_Register();
> b = new_B()
> b:foo()
>
> R:add(b);
> R:exec();

If you bind those classes with lqt it will work as expected. I assume
that you wanted also something like

b.foo = function() print("executing Lua version of void foo()") end

which also works properly now.

The constructor convention is now
R = Register.new()
or simply
R = Register()

mauro