[Ecls-list] updating refererence pointers in UFFI
goffioul at imec.be
Mon Sep 4 08:24:29 UTC 2006
As already answered, you can achieve that by allocating foreign objects
yourself in LISP and passing them as argument to your C function. For
instance, when allocating a foreign object of type :int in ECL, it would
be passed as int* to a C function.
However, it would be much easier if ECL could do it automatically. I'm
thinking about CLISP here, where you can tag FFI arguments as in, out
or in-out. All out/in-out arguments are returned as secondary values of
the FFI function. out-only arguments does not need to be specified as
input arguments. This might me complicated to implement, but this would
ease the work of the user.
For example, something like:
(ffi:def-function ("f1" f1)
((a :int) ;; default to :in
(b :int :out)
(c :int :in-out))
(f1 1 2)
=> 1 maps to 'a', 2 maps to 'c'
=> returns 3 values: function result, b and c
What do you think?
> I may have asked his ages ago but can't seem to find any record of it.
> I should probably post this on some UFFI mail list if I can
> find one aswell, but any ideas with ECL.
> I am using UFFI to call our DLL (written in C) functions and
> most of it works ok.
> I can pass cstrings ok as in cl_init().
> But other functions such as cl_elementGetAttachment() creates
> C strings and return them by assigning them to dereferenced
> argument pointers.
> Also pointers to longs are dereferenced.
> Eg. for the "attachment" argument, in C we pass the address
> of a C string pointer. This get updated with the newly
> allocated C string pointer.
> So is there any way to pass the C-function via UFFI a C
> pointer arg of somekind and have it updated when returning to Lisp ??
> It doesn't seem to fit in with the Lisp way of doing things,
> but is this possible in any way ?
> I am not compiling any of this in Windows. Its just pure interpretive.
> long cl_init(const char *configFileName);
> ((ffi:def-function ("cl_init" init)
> ((configFileName :cstring ))
> :returning :long
> long cl_elementGetAttachment(long hDoc, unsigned int index,
> char **name, char **attachment, unsigned long
> *attachmentSize, bool detach);
> ((ffi:def-function ("cl_elementgetattachment" element-get-attachment)
> ((hdoc :long) (index :unsigned-short) (name
> (attachment :pointer-void) (attachmentsize
> (detach :unsigned-char))
> Using Tomcat but need to do more? Need to support web
> services, security?
> Get stuff done quickly with pre-integrated technology to make
> your job easier Download IBM WebSphere Application Server
> v.1.0.1 based on Apache Geronimo
> Ecls-list mailing list
> Ecls-list at lists.sourceforge.net
More information about the ecl-devel