chiark / gitweb /
src/c-types-parse.lisp: Improve handling of compatibility keywords.
authorMark Wooding <mdw@distorted.org.uk>
Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 29 May 2016 14:08:43 +0000 (15:08 +0100)
Newer C standards tend to introduce new keywords in the reserved space,
as `_Shiny', and possibly add a macro, tucked away in some header file,
for `shiny'.  We already deal with this for `_Bool', `_Complex', and so
on, but adding more is annoying.  Add a `:compat' keyword so that the
table initialization machinery can do the work for us.

src/c-types-parse.lisp

index e700a018c5b1a7bfa00eeea740afa3590f49bc93..58e3ced06115bbdc726df1cb14646d2bc8686085 100644 (file)
@@ -90,9 +90,9 @@   (default-slot (ds 'name slot-names)
 (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)
@@ -104,17 +104,18 @@ (defparameter *declspec-map*
          (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.")