src/: Fix up some wrong exports.
[sod] / src / c-types-impl.lisp
index 7dd7b84..4a0f6e2 100644 (file)
 (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 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)))
 
 ;; Comparison protocol.
 
 
 ;; C syntax output protocol.
 
-(defmethod pprint-c-type ((type c-function-type) stream kernel)
-  (pprint-c-type (c-type-subtype type) stream
-                (lambda (stream prio spacep)
-                  (maybe-in-parens (stream (> prio 2))
-                    (when spacep (c-type-space stream))
-                    (funcall kernel stream 2 nil)
-                    (pprint-indent :block 4 stream)
-                    (pprint-logical-block
-                        (stream nil :prefix "(" :suffix ")")
-                      (let ((firstp t))
-                        (dolist (arg (c-function-arguments type))
-                          (if firstp
-                              (setf firstp nil)
-                              (format stream ", ~_"))
-                          (if (eq arg :ellipsis)
-                              (write-string "..." stream)
-                              (pprint-c-type (argument-type arg)
-                                             stream
-                                             (argument-name arg))))))))))
+(let ((void-arglist (list (make-argument nil c-type-void))))
+  (defmethod pprint-c-type ((type c-function-type) stream kernel)
+    (pprint-c-type (c-type-subtype type) stream
+                  (lambda (stream prio spacep)
+                    (maybe-in-parens (stream (> prio 2))
+                      (when spacep (c-type-space stream))
+                      (funcall kernel stream 2 nil)
+                      (pprint-indent :block 4 stream)
+                      (pprint-logical-block
+                          (stream nil :prefix "(" :suffix ")")
+                        (let ((firstp t))
+                          (dolist (arg (or (c-function-arguments type)
+                                           void-arglist))
+                            (if firstp
+                                (setf firstp nil)
+                                (format stream ", ~_"))
+                            (if (eq arg :ellipsis)
+                                (write-string "..." stream)
+                                (pprint-c-type (argument-type arg)
+                                               stream
+                                               (argument-name arg)))))))))))
 
 ;; S-expression notation protocol.
 
                        (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.