is allocate-foreign-object really a macro?
"Hoehle, Joerg-Cyril" <[email protected]> Fri, 19 Apr 2002 09:31:54 +0200
| Newsgroups | gmane.lisp.uffi.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Kevin Rosenberg wrote:
> You are right, it could be a function. I chose to make it a macro for
> efficiency sake as well as being consistent with the almost all of the
> other forms of UFFI: a macro wrapper around native FFI's.
I didn't notice this. You should highlight this in your design section. This is important to know and consider, also for the user.
Yesterday afternoon, I quickly looked at UFFI again, looking at what CLISP still needs to provide to enable a "port" from UFFI to CLISP. I believe it's not much anymore.
;UFFI supports some keywords:
(defun uffi:convert-from-foreign-string (address &key length (null-terminated-p T))
;; UFFI style interface with CLISP type syntax
(ffi:with-stack-foreign (ptr c-pointer (foreign-address address))
(let ((type (if null-terminated-p
(if length
`(c-ptr-null (c-array-max character ,length))
'c-string)
(if length
`(c-ptr-null (c-array character ,length))
(error "bad combination")))))
(ffi::foreign-value (ffi::%cast ptr (ffi::parse-c-type type))))))
This would be much harder to write as a macro.
Please don't expect too much now. I have *no* plans to port it myself. I'm already busy with way too many things in CLISP etc. But I *do* offer to create functionality that CLISP needs to provide for this purpose. E.g., I have experimental WITH-FOREIGN-STACK macros.
Regards,
Jorg Hohle.