X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/c07860afc55d0d49b9e920dca790b902b8d5cb15..437938912d93089d7716a119363e49db5a57cba8:/src/c-types-impl.lisp diff --git a/src/c-types-impl.lisp b/src/c-types-impl.lisp index b4f02e1..ed65110 100644 --- a/src/c-types-impl.lisp +++ b/src/c-types-impl.lisp @@ -418,24 +418,30 @@ (export '(c-function-type c-function-arguments)) (defclass c-function-type (c-type) ((subtype :initarg :subtype :type c-type :reader c-type-subtype) - (arguments :initarg :arguments :type list :reader c-function-arguments)) + (arguments :type list :reader c-function-arguments)) (:documentation "C function types. The subtype is the return type, as implied by the C syntax for function declarations.")) +(defmethod shared-initialize :after + ((type c-function-type) slot-names &key (arguments nil argsp)) + (declare (ignore slot-names)) + (when argsp + (setf (slot-value type 'arguments) + (if (and arguments + (null (cdr arguments)) + (not (eq (car arguments) :ellipsis)) + (eq (argument-type (car arguments)) c-type-void)) + nil + arguments)))) + ;; Constructor function. (export 'make-function-type) (defun make-function-type (subtype arguments) "Return a new function type, returning SUBTYPE and accepting ARGUMENTS." (make-instance 'c-function-type :subtype subtype - :arguments (if (and arguments - (null (cdr arguments)) - (not (eq (car arguments) :ellipsis)) - (eq (argument-type (car arguments)) - c-type-void)) - nil - arguments))) + :arguments arguments)) ;; Comparison protocol. @@ -485,7 +491,7 @@ (list (argument-name arg) (argument-type arg)))) (c-function-arguments type)))) -(export '(fun function func fn)) +(export '(fun function () func fn)) (define-c-type-syntax fun (ret &rest args) "Return the type of functions which returns RET and has arguments ARGS.