lua-users home
lua-l archive

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


Hi Thiago,

Thanks for the response and your hard work!

> Well, you cannot do this in the luajava object because it is a
> userdata and it's __index is important to finding and calling methods
> in the java object.
> 
> I guess you could create a table in lua and have the methods in it and
> use the __index to call the java object methods (pretty much extending
> the object in lua's OO ).

Perhaps I could hack the Java part of LuaJava. Like adding some code to LuaJavaAPI. But I'm not entirely sure where.

If I wanted obj.foo() to be equivalent to obj:getFoo() I guess I just need to add code to LuaJavaAPI.checkMethod() and LuaJavaAPI.objectIndex() to handle MyClass as a special case. Correct? (I would probably need to do obj:foo() and not obj.foo(), right?)

But what if I want obj.foo to be equivalent to obj:getFoo() and obj.foo = 'bar' to be equivalent to obj:setFoo('bar')? For obj.foo I could probably just add some code to LuaJavaAPI.checkField(), but that wouldn't work for obj.foo = 'bar' as far as I can tell. Does LuaJava support setting fields from Lua?
 
> Well, the solution woldn't be very different from plain lua and Lua
> with luajava, you just will have to write the index method calling the
> get function of a hashmap object.
> I'm not sure, but I guess you could write a metatable to the _G global
> table...

Ah, I'll try that.
 
> No, actually it's ready, we are just finishing the release. Should be
> out in a few days.

Ok, if I end up customizing LuaJava I will wait for 1.1. 


Cheers,
 Jonas

Spray Crazy samlar nätets roligaste filmer just nu. Gå in och titta eller ladda upp ditt eget bidrag på http://crazy.spray.se/