Export struct field names
Tue Sep 12 10:09:25 PDT 2006 Daniel Dickison (danieldickison@gmail.com)
* Export struct field names
Is there a reason CFFI uses regular symbols instead of keywords for struct fields? Enums use keywords ands works fabulously.
diff -rN -u old-c2ffi/CFFI-Generator.lisp new-c2ffi/CFFI-Generator.lisp
--- old-c2ffi/CFFI-Generator.lisp 2014-07-26 02:11:43.000000000 -0700
+++ new-c2ffi/CFFI-Generator.lisp 2014-07-26 02:11:43.000000000 -0700
@@ -77,19 +77,22 @@
(field-nodes (mapcan #'(lambda (id)
(awhen (find-in-tree root-node "Field" `(("id" ,id)))
(list it)))
- field-ids)))
+ field-ids))
+ (slot-names nil))
(list
`(,func ,lisp-name
,@(mapcar #'(lambda (field-node)
(when (node-attribute "bits" field-node)
(warn "Array fields in structs/unions not currently supported~% In struct: ~S~% field: ~S" node field-node))
- (list*
- (str->sym (node-attribute "name" field-node))
- (type-with-id ffi (node-attribute "type" field-node))
- (awhen (and (eql type :Struct)
- (node-attribute "offset" field-node))
- (list :offset (parse-integer it)))))
+ (let ((slot-name (str->sym (node-attribute "name" field-node))))
+ (push slot-name slot-names)
+ (list*
+ slot-name
+ (type-with-id ffi (node-attribute "type" field-node))
+ (awhen (and (eql type :Struct)
+ (node-attribute "offset" field-node))
+ (list :offset (parse-integer it))))))
field-nodes))
- `(export ',lisp-name))))
+ `(export ',(cons lisp-name slot-names)))))
\ No newline at end of file
diff -rN -u old-c2ffi/GCC-XML.lisp new-c2ffi/GCC-XML.lisp
--- old-c2ffi/GCC-XML.lisp 2014-07-26 02:11:43.000000000 -0700
+++ new-c2ffi/GCC-XML.lisp 2014-07-26 02:11:43.000000000 -0700
@@ -5,6 +5,7 @@
(defvar *gccxml-command* "gccxml")
(defun generate-xml (h-file xml-file &optional options)
+ "Runs GCC-XML to generate an XML file from a C header file, with compiler options passed from the list `options`. *Note: This function is currently only available in OpenMCL.*"
(format *terminal-io* "~&~%Running ~A~%Options: ~A~%Input: ~S~%Output: ~S~%"
*gccxml-command* options
(namestring (truename h-file))
diff -rN -u old-c2ffi/c2ffi.lisp new-c2ffi/c2ffi.lisp
--- old-c2ffi/c2ffi.lisp 2014-07-26 02:11:43.000000000 -0700
+++ new-c2ffi/c2ffi.lisp 2014-07-26 02:11:43.000000000 -0700
@@ -14,7 +14,7 @@
&key (generator-class 'cffi-generator)
gcc-options
in-package)
- "Generates FFI files for each input file designated by `h-files`. Each input file is first parsed by the GCC-XML program, whose XML output is then parsed by an instance of `generator-class`.
+ "Generates FFI files for each input file designated by `h-files`. Each input file is first parsed by the GCC-XML program, whose XML output is then parsed by an instance of `generator-class`. *Note: this function is currently only available in OpenMCL.*
* `h-files` -- a list of pathnames or a pathname designator. If it is a single
pathname designator, it may include wildcards which will be expanded