lua-users home
lua-l archive

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


Hi Andreas,

On Mon, Nov 25, 2002 at 02:06:16PM +0100, Andreas Rozek wrote:
> >unfortunately, there does not seem to be any other documentation
> >available. I could provide some examples from my own application, if
> >you think that they would help.
> 
> Oh yes, that would be fine, thanks in advance!

you can find the package at
ftp://ftp.cis.upenn.edu/pub/cvogler/animation.tar.gz

It is a collection of tools to animate vector graphics with
OpenOffice.org Draw. I used these animations to make a video about my
research. The most mature OOo UNO component bridge currently is the
one written in Java. So, I was more or less forced to use it, but I
wanted to use a more high-level language than Java - hence my use of
luajava.

> Well, as my idea is to present an interface  (to the Lua program-
> mer) which maps a single (Lua) table index (e.g. LuaVar[Slot]) on
> appropriate (Java)  set/get-methods  (such as JavaObj.setSlot and 
> JavaObj.getSlot) I'm not really unhappy about this behaviour.
> 
> Currently,  I plan to use  "gettable" and "settable"  tag methods
> for that purpose.  Is it possible to assign a "tag"  to Java pro-
> xies (sorry for that silly question - I'll find it out myself)

Take a look at uno.get_property_sheet() in uno.lua. It does something
similar to what you would like to accomplish.

> Real question (plain Lua) now: how can I achieve,  that (Lua) ta-
> ble indices which I have "simulated"  using gettable/settable tag
> methods appear in a "for key,value in table" loop?

You can't, unless you actually put the keys in the table. Again,
uno.get_property_sheet may be close to what you want to do.

>   local Key,Value;
>   for Key,Value in Window do
>     print("  "..Key..": "..Value);   -- throws an exception!
>   end;

Iteration over a Java proxy with for/foreach does not really make
sense, because these should not be used as regular lua tables. You
would need to use the Java reflection API on the underlying Java
object to accomplish what you want.

You could use this API to copy all the properties/member variables
into some kind of a proxy table, and access them from there.

- Christian