src/c-types-parse.lisp: Improve handling of compatibility keywords.
[sod] / src / c-types-parse.lisp
index e700a01..58e3ced 100644 (file)
@@ -90,9 +90,9 @@
 (defparameter *declspec-map*
   (let ((map (make-hash-table :test #'equal)))
     (dolist (item '((type :void :char :int :float :double
-                         (:bool :name "_Bool"))
-                   (complexity (:complex :name "_Complex")
-                               (:imaginary :name "_Imaginary"))
+                         (:bool :compat "_Bool"))
+                   (complexity (:complex :compat "_Complex")
+                               (:imaginary :compat "_Imaginary"))
                    ((type :taggedp t) :enum :struct :union)
                    (size :short :long (:long-long :name "long long"))
                    (sign :signed :unsigned)
          (destructuring-bind (label
                               &key
                               (name (string-downcase label))
+                              compat
                               (taggedp taggedp))
              (if (consp spec) spec (list spec))
            (let ((ds (make-instance 'declspec
                                     :label label
-                                    :name name
+                                    :name (or compat name)
                                     :kind kind
                                     :taggedp taggedp)))
              (setf (gethash name map) ds
-                   (gethash label map) ds))))))
-    (dolist (label '(:complex :imaginary :bool))
-      (setf (gethash (string-downcase label) map) (gethash label map)))
+                   (gethash label map) ds)
+             (when compat
+               (setf (gethash compat map) ds)))))))
     map)
   "Maps symbolic labels and textual names to `declspec' instances.")