X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/655037a5bd793e815bb68e3c103fc7e1bb1c79aa..c6b4ed992d81518f240509e6ab212d8fe705485a:/src/c-types-parse.lisp diff --git a/src/c-types-parse.lisp b/src/c-types-parse.lisp index 13f9145..d0b3d41 100644 --- a/src/c-types-parse.lisp +++ b/src/c-types-parse.lisp @@ -68,9 +68,9 @@ ;; Despite the fact that it looks pretty trivial, this can't be done with ;; `defstruct' for the simple reason that we add more methods to the ;; accessor functions later. - ((label :type keyword :initarg :label :reader ds-label) + ((%label :type keyword :initarg :label :reader ds-label) (name :type string :initarg :name :reader ds-name) - (kind :type (member type complexity sign size qualifier specs) + (kind :type (member %type complexity sign size qualifier %specs) :initarg :kind :reader ds-kind) (taggedp :type boolean :initarg :taggedp :initform nil :reader ds-taggedp)) @@ -89,8 +89,7 @@ (defparameter *declspec-map* (let ((map (make-hash-table :test #'equal))) - (dolist (item '((type :void :char :int :float :double - (:bool :compat "_Bool")) + (dolist (item '((%type :char :int :float :double) (complexity (:complex :compat "_Complex") (:imaginary :compat "_Imaginary")) ((type :taggedp t) :enum :struct :union) @@ -103,10 +102,8 @@ (if (consp spec) spec (list spec))) (dolist (spec (cdr item)) (destructuring-bind (label - &key - (name (string-downcase label)) - compat - (taggedp taggedp)) + &key (name (string-downcase label)) + compat (taggedp taggedp)) (if (consp spec) spec (list spec)) (let ((ds (make-instance 'declspec :label label @@ -125,22 +122,22 @@ (:documentation "Carrier for a storage specifier.")) (defmethod ds-label ((spec storespec)) spec) -(defmethod ds-kind ((spec storespec)) 'specs) +(defmethod ds-kind ((spec storespec)) '%specs) (defmethod ds-label ((ty c-type)) :c-type) (defmethod ds-name ((ty c-type)) (princ-to-string ty)) -(defmethod ds-kind ((ty c-type)) 'type) +(defmethod ds-kind ((ty c-type)) '%type) ;; A collection of declaration specifiers, and how to merge them together. (defclass declspecs () ;; This could have been done with `defstruct' just as well, but a ;; `defclass' can be tweaked interactively, which is a win at the moment. - ((type :initform nil :initarg :type :reader ds-type) + ((%type :initform nil :initarg :type :reader ds-type) (complexity :initform nil :initarg :complexity :reader ds-complexity) (sign :initform nil :initarg :sign :reader ds-sign) (size :initform nil :initarg :size :reader ds-size) - (specs :initform nil :initarg :specs :reader ds-specs) + (%specs :initform nil :initarg :specs :reader ds-specs) (qualifier :initform nil :initarg :qualifiers :reader ds-qualifiers)) (:documentation "Represents a collection of declaration specifiers. @@ -260,7 +257,8 @@ (let ((kw (token-value scanner))) (or (gethash kw *declspec-map*) (and (boundp '*module-type-map*) - (gethash kw *module-type-map*))))))) + (gethash kw *module-type-map*)) + (find-simple-c-type kw)))))) (cond ((or (not ds) (and predicate (not (funcall predicate ds)))) (values (list indicator) nil nil)) ((and (typep ds 'declspec) (ds-taggedp ds)) @@ -402,7 +400,7 @@ (disallow-keyword-functions (type) (when (typep type 'c-keyword-function-type) (error "Functions with keyword arguments are only ~ - allowed at top-level."))) + allowed at top-level"))) (star () ;; Prefix: `*' qualifiers