0.6.12.34:
[sbcl.git] / tests / interface.pure.lisp
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
4 ;;;; While most of SBCL is derived from the CMU CL system, the test
5 ;;;; files (like this one) were written from scratch after the fork
6 ;;;; from CMU CL.
7 ;;;; 
8 ;;;; This software is in the public domain and is provided with
9 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
10 ;;;; more information.
11
12 (in-package :cl-user)
13
14 ;;; Check for fbound external symbols in public packages that have no
15 ;;; argument list information. (This can happen if we get carried away
16 ;;; with byte compilation, since at least in sbcl-0.6.12 the byte
17 ;;; compiler can't record argument list information.)
18 (defvar *public-package-names*
19   '("SB-ALIEN" "SB-C-CALL" "SB-DEBUG" "SB-EXT" "SB-GRAY" "SB-MP"
20     "SB-PROFILE" "SB-PCL" "COMMON-LISP"))
21 (defun has-arglist-info-p (function)
22   (declare (type function function))
23   ;; The Lisp-level type FUNCTION can conceal a multitude of sins..
24   (case (sb-kernel:get-type function)
25     ((#.sb-vm:function-header-type #.sb-vm:closure-function-header-type)
26       (sb-kernel:%function-arglist function))
27     (#.sb-vm:closure-header-type (has-arglist-info-p
28                                   (sb-kernel:%closure-function
29                                    function)))
30     ;; in code/describe.lisp, ll. 227 (%describe-function), we use a scheme
31     ;; like above, and it seems to work. -- MNA 2001-06-12
32     ;;
33     ;; (There might be other cases with arglist info also.
34     ;; FUNCTION-HEADER-TYPE and CLOSURE-HEADER-TYPE just
35     ;; happen to be the two case that I had my nose rubbed in when
36     ;; debugging a GC problem caused by applying %FUNCTION-ARGLIST to
37     ;; a closure. -- WHN 2001-06-05)
38     (t nil)))
39 (defun check-ext-symbols-arglist (package)
40   (format t "~% looking at package: ~A" package)
41   (do-external-symbols (ext-sym package)
42     (when (fboundp ext-sym)
43       (let ((fun (symbol-function ext-sym)))
44         (cond ((macro-function ext-sym)
45                ;; FIXME: Macro functions should have their argument list
46                ;; information checked separately. Just feeding them into
47                ;; the ordinary-function logic below doesn't work right,
48                ;; though, and I haven't figured out what does work
49                ;; right. For now we just punt.
50                (values))
51               #+nil 
52               ((sb-int:info :function :accessor-for ext-sym)
53                (values))
54               ((typep fun 'generic-function)
55                 (sb-pcl::generic-function-pretty-arglist fun))
56               (t
57                (let ((fun (symbol-function ext-sym)))
58                  (unless (has-arglist-info-p fun)
59                    (error "Function ~A has no arg-list information available."
60                           ext-sym)))))))))
61 (dolist (public-package *public-package-names*)
62   (when (find-package public-package)
63     (check-ext-symbols-arglist public-package)))
64 (terpri)
65
66 ;;; FIXME: It would probably be good to require here that every
67 ;;; external symbol either has a doc string or has some good excuse
68 ;;; (like being an accessor for a structure which has a doc string).
69
70 (print "done with interface.pure.lisp")
71