This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Accessing Java Vector from Kawa
- From: Marco Vezzoli <marco dot vezzoli at st dot com>
- To: amin1 at student dot monash dot edu
- Cc: kawa at sources dot redhat dot com
- Date: Mon, 04 Feb 2002 13:51:04 +0100
- Subject: Re: Accessing Java Vector from Kawa
- References: <2fd863125f.3125f2fd86@mail2.monash.edu.au>
amin1@student.monash.edu wrote:
>
> Hello ,
>
> I am using Kawa to communicate between Java and scheme scripts and it
> is a very good tool.
>
> Now I want to access a Java Vector from scheme, but when I pass a Java
> Vector to Kawa, I can not access it as a scheme vector nor as a scheme
> list (I get wrong type exception).
>
> Is there a way that I can use to convert a Java Vector, or any other
> java collection, to a scheme list or vector?
>
> Thanks
> Amir
the html docs seems to be out of date about the java type of a scheme
vector.
here is some simple code; hope this helps.
#|kawa:66|# (invoke '#() 'get-class)
class gnu.lists.FVector
#|kawa:67|# (define v (make <java.util.Vector>))
#|kawa:68|# (invoke v 'add "something")
#t
#|kawa:69|# (invoke v 'add "something else")
#t
#|kawa:70|# v
[something, something else]
#|kawa:72|# (define enum (invoke v 'elements))
#|kawa:73|# enum
java.util.Vector$1@fdbb59
#|kawa:79|# (let loop ((result '()))
#|(---:80|# (if (invoke enum 'has-more-elements)
#|(---:81|# (loop (cons (invoke enum 'next-element) result))
#|(---:82|# result))
(something else something)
--
(--cafe babe--)
Marco Vezzoli marco.vezzoli@st.com
CR&D Intranet Developement STMicroelectronics
tel. +39 039 603 6852 fax. +39 039 603 5055