This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Accessing Java Vector from Kawa


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]