CFFI tends to have name specifications like (c-name lisp-name) whenever fully specifying the names as a list.
In CFFI-Grovel, we're tentatively doing (lisp-name &rest c-names) in several places (for constants and enums). This is so that we can easily provide a list of alternative c-names for the groveler to try as it hunts for the symbol. e.g.:
(defconstant (path-max "PATH_MAX" "MAXPATHLEN"))
which covers both SYSVish and BSDish systems.
But this is bad because it's backwards from what CFFI does. Anyone have any ideas on a good syntax? I'd really like groveler forms to strongly resemble CFFI (or CL) forms to reduce user confusion.
Matthew Backes lucca@accela.net
On Mon, 2006-01-02 at 23:59 -0800, Matthew Backes wrote:
CFFI tends to have name specifications like (c-name lisp-name) whenever fully specifying the names as a list.
In CFFI-Grovel, we're tentatively doing (lisp-name &rest c-names) in several places (for constants and enums). This is so that we can easily provide a list of alternative c-names for the groveler to try as it hunts for the symbol. e.g.:
(defconstant (path-max "PATH_MAX" "MAXPATHLEN"))
which covers both SYSVish and BSDish systems.
But this is bad because it's backwards from what CFFI does. Anyone have any ideas on a good syntax? I'd really like groveler forms to strongly resemble CFFI (or CL) forms to reduce user confusion.
Personally, I find it confusing to use the same name as a CL or CFFI operator with a different syntax and semantics. If I understand how CFFI-GROVEL works, the forms in the constants file are data, not code, so it doesn't seem appropriate to try to make them look like code.
What about a syntax like:
(type "size_t" :size :unsigned) (constant ("PATH_MAX" "MAXPATHLEN") path-max) ;; This struct syntax probably needs some work... (struct "pollfd" pollfd (("fd" fd) ("events" events) ("revents" revents)) (:documentation "Poll file descriptor structure.")) (variable "errno" errno :int)
with the general form being:
(OBJECT C-NAME-STRING-OR-LIST LISP-NAME &rest options)
(I assume this is grossly incompatible with SB-GROVEL, which I haven't really used. Obviously if you are trying to stay close to SB-GROVEL, this might not be a good idea...)
James
We wound up changing the names of all the forms, removing the def- prefix. This keeps them similar enough to the CFFI names that there's still mnemonic value - my original thinking was that there's no good reason to force users to memorize more names.
Yeah, sb-grovel compatibility was never a goal; changing the interface is definitely always an option. We're still undecided on the best way to handle object names.
-- Dan Knapp