Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


Diff of /contrib/sb-grovel/def-to-lisp.lisp [93c815] .. [1cae06] Maximize Restore

  Switch to side-by-side view

--- a/contrib/sb-grovel/def-to-lisp.lisp
+++ b/contrib/sb-grovel/def-to-lisp.lisp
@@ -36,6 +36,19 @@
 	   "    printf (\"~@?\\n\"~@{, ~A~});~%"
 	   (c-escape formatter)
+(defun c-for-enum (lispname elements export)
+  (printf "(cl:eval-when (:compile-toplevel :load-toplevel :execute) (sb-alien:define-alien-type ~A (sb-alien:enum nil" lispname)
+  (dolist (element elements)
+    (destructuring-bind (lisp-element-name c-element-name) element
+      (printf " (~S %d)" lisp-element-name c-element-name)))
+  (printf ")))")
+  (when export
+    (dolist (element elements)
+      (destructuring-bind (lisp-element-name c-element-name) element
+        (declare (ignore c-element-name))
+	(unless (keywordp lisp-element-name)
+	  (printf "(export '~S)" lisp-element-name))))))
 (defun c-for-structure (lispname cstruct)
   (destructuring-bind (cname &rest elements) cstruct
@@ -87,6 +100,8 @@
 	   (as-c "#else")
 	   (printf "(sb-int:style-warn \"Couldn't grovel for ~A (unknown to the C compiler).\")" cname)
 	   (as-c "#endif"))
+          (:enum
+           (c-for-enum lispname cname export))
 	   (printf "(cl:eval-when (:compile-toplevel :load-toplevel :execute) (sb-alien:define-alien-type ~A (sb-alien:%ssigned %d)))" lispname
 		   (format nil "SIGNED_(~A)" cname)