From: Mark Wooding Date: Thu, 26 May 2016 08:26:09 +0000 (+0100) Subject: src/c-types-parse.lisp: Improve handling of compatibility keywords. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/commitdiff_plain/cab163b724806bf1d0dcf48795dba8ca1ffbd967?ds=inline src/c-types-parse.lisp: Improve handling of compatibility keywords. 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. --- diff --git a/src/c-types-parse.lisp b/src/c-types-parse.lisp index e700a01..58e3ced 100644 --- a/src/c-types-parse.lisp +++ b/src/c-types-parse.lisp @@ -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.")