lua-users home
lua-l archive

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


Hi Jonas,

1) For some classes I want to support 'method calls' which are not part
of the class, e.g. so you can write obj.foo instead of obj:getFoo() and
obj.foo = bar instead of obj:setFoo(bar).

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 ).

2) When a script is trying to access a global that doesn't exist I'd
like to dynamically provide some value from some hash table in java land.

How would you normally solve those problems in LuaJava? In vanilla Lua I
guess it would involve metatables, and __index/__newindex.

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...

Also, is LuaJava 1.1 far from release?

No, actually it's ready, we are just finishing the release. Should be
out in a few days.

Cheers,

Thiago