1 ;;;; macros, global variable definitions, and other miscellaneous support stuff
2 ;;;; used by the rest of the PCL subsystem
4 ;;;; This software is part of the SBCL system. See the README file for
7 ;;;; This software is derived from software originally released by Xerox
8 ;;;; Corporation. Copyright and release statements follow. Later modifications
9 ;;;; to the software are in the public domain and are provided with
10 ;;;; absolutely no warranty. See the COPYING and CREDITS files for more
13 ;;;; copyright information from original PCL sources:
15 ;;;; Copyright (c) 1985, 1986, 1987, 1988, 1989, 1990 Xerox Corporation.
16 ;;;; All rights reserved.
18 ;;;; Use and copying of this software and preparation of derivative works based
19 ;;;; upon this software are permitted. Any distribution of this software or
20 ;;;; derivative works must comply with all applicable United States export
23 ;;;; This software is made available AS IS, and Xerox Corporation makes no
24 ;;;; warranty about the software, its performance or its conformity to any
29 (/show "starting pcl/macros.lisp")
32 ;; As of sbcl-0.7.0.6, SBCL actively uses this declaration
33 ;; to propagate information needed to set up nice debug
34 ;; names (as seen e.g. in BACKTRACE) for method functions.
36 ;; These nonstandard declarations seem to be used privately
37 ;; within PCL itself to pass information around, so we can't
41 ;; This declaration may also be used within PCL to pass
42 ;; information around, I'm not sure. -- WHN 2000-12-30
45 (/show "done with DECLAIM DECLARATION")
47 (defun get-declaration (name declarations &optional default)
48 (dolist (d declarations default)
49 (dolist (form (cdr d))
50 (when (and (consp form) (eq (car form) name))
51 (return-from get-declaration (cdr form))))))
53 (/show "pcl/macros.lisp 85")
55 (defmacro doplist ((key val) plist &body body)
56 `(let ((.plist-tail. ,plist) ,key ,val)
57 (loop (when (null .plist-tail.) (return nil))
58 (setq ,key (pop .plist-tail.))
59 (when (null .plist-tail.)
60 (error "malformed plist, odd number of elements"))
61 (setq ,val (pop .plist-tail.))
64 (/show "pcl/macros.lisp 101")
66 (defmacro dolist-carefully ((var list improper-list-handler) &body body)
68 (.dolist-carefully. ,list))
69 (loop (when (null .dolist-carefully.) (return nil))
70 (if (consp .dolist-carefully.)
72 (setq ,var (pop .dolist-carefully.))
74 (,improper-list-handler)))))
78 ;;;; This is documented in the CLOS specification.
80 (/show "pcl/macros.lisp 119")
82 (declaim (inline legal-class-name-p))
83 (defun legal-class-name-p (x)
86 (defvar *create-classes-from-internal-structure-definitions-p* t)
88 (defun find-class-from-cell (symbol cell &optional (errorp t))
90 (or (classoid-cell-pcl-class cell)
91 (when *create-classes-from-internal-structure-definitions-p*
92 (let ((classoid (classoid-cell-classoid cell)))
94 (or (condition-classoid-p classoid)
95 (defstruct-classoid-p classoid)))
96 (ensure-non-standard-class symbol classoid))))))
97 (cond ((null errorp) nil)
98 ((legal-class-name-p symbol)
99 (error "There is no class named ~S." symbol))
101 (error "~S is not a legal class name." symbol)))))
103 (defun find-class (symbol &optional (errorp t) environment)
104 (declare (ignore environment))
105 (find-class-from-cell symbol
106 (find-classoid-cell symbol)
110 ;;; This DEFVAR was originally in defs.lisp, now moved here.
112 ;;; Possible values are NIL, EARLY, BRAID, or COMPLETE.
113 (declaim (type (member nil early braid complete) **boot-state**))
114 (defglobal **boot-state** nil)
116 (/show "pcl/macros.lisp 187")
118 (define-compiler-macro find-class (&whole form
119 symbol &optional (errorp t) environment)
120 (declare (ignore environment))
121 (if (and (constantp symbol)
122 (legal-class-name-p (setf symbol (constant-form-value symbol)))
124 (member **boot-state** '(braid complete)))
125 (let ((errorp (not (null (constant-form-value errorp))))
126 (cell (make-symbol "CLASSOID-CELL")))
127 `(let ((,cell (load-time-value (find-classoid-cell ',symbol :create t))))
128 (or (classoid-cell-pcl-class ,cell)
130 `(find-class-from-cell ',symbol ,cell t)
131 `(when (classoid-cell-classoid ,cell)
132 (find-class-from-cell ',symbol ,cell nil))))))
135 (declaim (inline class-classoid))
136 (defun class-classoid (class)
137 (layout-classoid (class-wrapper class)))
139 (defun (setf find-class) (new-value name &optional errorp environment)
140 (declare (ignore errorp environment))
141 (cond ((legal-class-name-p name)
142 (with-single-package-locked-error
143 (:symbol name "Using ~A as the class-name argument in ~
146 (let ((cell (find-classoid-cell name :create new-value)))
148 (setf (classoid-cell-pcl-class cell) new-value)
149 (when (eq **boot-state** 'complete)
150 (let ((classoid (class-classoid new-value)))
151 (setf (find-classoid name) classoid)
152 (%set-class-type-translation new-value classoid))))
154 (%clear-classoid name cell)))
155 (when (or (eq **boot-state** 'complete)
156 (eq **boot-state** 'braid))
157 (update-ctors 'setf-find-class :class new-value :name name))
160 (error "~S is not a legal class name." name))))
162 (/show "pcl/macros.lisp 241")
164 (defmacro function-funcall (form &rest args)
165 `(funcall (the function ,form) ,@args))
167 (defmacro function-apply (form &rest args)
168 `(apply (the function ,form) ,@args))
170 (/show "pcl/macros.lisp 249")
172 (defun get-setf-fun-name (name)
175 (defsetf slot-value set-slot-value)
177 (/show "finished with pcl/macros.lisp")