X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/ae0f15ee8427fa91cfd1945bfded847032cb8a25..b7fcf94152e4c1938fbca55d13b1e6a64b694bd6:/src/c-types-impl.lisp diff --git a/src/c-types-impl.lisp b/src/c-types-impl.lisp index d0d4a74..719e610 100644 --- a/src/c-types-impl.lisp +++ b/src/c-types-impl.lisp @@ -96,6 +96,46 @@ initargs))) ;;;-------------------------------------------------------------------------- +;;; Storage specifiers. + +(defmethod c-type-equal-p :around + ((type-a c-storage-specifiers-type) (type-b c-type)) + "Ignore storage specifiers when comparing C types." + (c-type-equal-p (c-type-subtype type-a) type-b)) + +(defmethod c-type-equal-p :around + ((type-a c-type) (type-b c-storage-specifiers-type)) + "Ignore storage specifiers when comparing C types." + (c-type-equal-p type-a (c-type-subtype type-b))) + +(defun make-storage-specifiers-type (subtype specifiers) + "Construct a type based on SUBTYPE, carrying the storage SPECIFIERS." + (if (null specifiers) subtype + (make-or-intern-c-type 'c-storage-specifiers-type subtype + :specifiers specifiers + :subtype subtype))) + +(defmethod pprint-c-type ((type c-storage-specifiers-type) stream kernel) + (dolist (spec (c-type-specifiers type)) + (pprint-c-storage-specifier spec stream) + (write-char #\space stream) + (pprint-newline :miser stream)) + (pprint-c-type (c-type-subtype type) stream kernel)) + +(defmethod print-c-type + (stream (type c-storage-specifiers-type) &optional colon atsign) + (declare (ignore colon atsign)) + (format stream "~:@" + (c-type-subtype type) (c-type-specifiers type))) + +(export 'specs) +(define-c-type-syntax specs (subtype &rest specifiers) + `(make-storage-specifiers-type + ,(expand-c-type-spec subtype) + (list ,@(mapcar #'expand-c-storage-specifier specifiers)))) + +;;;-------------------------------------------------------------------------- ;;; Simple C types. ;; Class definition.