]> code.delx.au - gnu-emacs/blob - lisp/emacs-lisp/eieio-core.el
More-conservative ‘format’ quote restyling
[gnu-emacs] / lisp / emacs-lisp / eieio-core.el
1 ;;; eieio-core.el --- Core implementation for eieio -*- lexical-binding:t -*-
2
3 ;; Copyright (C) 1995-1996, 1998-2015 Free Software Foundation, Inc.
4
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;; Version: 1.4
7 ;; Keywords: OO, lisp
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23
24 ;;; Commentary:
25 ;;
26 ;; The "core" part of EIEIO is the implementation for the object
27 ;; system (such as eieio-defclass, or eieio-defmethod) but not the
28 ;; base classes for the object system, which are defined in EIEIO.
29 ;;
30 ;; See the commentary for eieio.el for more about EIEIO itself.
31
32 ;;; Code:
33
34 (require 'cl-lib)
35 (require 'pcase)
36
37 ;;;
38 ;; A few functions that are better in the official EIEIO src, but
39 ;; used from the core.
40 (declare-function slot-unbound "eieio")
41 (declare-function slot-missing "eieio")
42 (declare-function child-of-class-p "eieio")
43 (declare-function same-class-p "eieio")
44 (declare-function object-of-class-p "eieio")
45
46 \f
47 ;;;
48 ;; Variable declarations.
49 ;;
50 (defvar eieio-hook nil
51 "This hook is executed, then cleared each time `defclass' is called.")
52
53 (defvar eieio-error-unsupported-class-tags nil
54 "Non-nil to throw an error if an encountered tag is unsupported.
55 This may prevent classes from CLOS applications from being used with EIEIO
56 since EIEIO does not support all CLOS tags.")
57
58 (defvar eieio-skip-typecheck nil
59 "If non-nil, skip all slot typechecking.
60 Set this to t permanently if a program is functioning well to get a
61 small speed increase. This variable is also used internally to handle
62 default setting for optimization purposes.")
63
64 (defvar eieio-optimize-primary-methods-flag t
65 "Non-nil means to optimize the method dispatch on primary methods.")
66
67 (defvar eieio-backward-compatibility t
68 "If nil, drop support for some behaviors of older versions of EIEIO.
69 Currently under control of this var:
70 - Define every class as a var whose value is the class symbol.
71 - Define <class>-child-p and <class>-list-p predicates.
72 - Allow object names in constructors.")
73
74 (defconst eieio-unbound
75 (if (and (boundp 'eieio-unbound) (symbolp eieio-unbound))
76 eieio-unbound
77 (make-symbol "unbound"))
78 "Uninterned symbol representing an unbound slot in an object.")
79
80 ;; This is a bootstrap for eieio-default-superclass so it has a value
81 ;; while it is being built itself.
82 (defvar eieio-default-superclass nil)
83
84 (progn
85 ;; Arrange for field access not to bother checking if the access is indeed
86 ;; made to an eieio--class object.
87 (cl-declaim (optimize (safety 0)))
88
89 (cl-defstruct (eieio--class
90 (:constructor nil)
91 (:constructor eieio--class-make (name))
92 (:include cl--class)
93 (:copier nil))
94 children
95 initarg-tuples ;; initarg tuples list
96 (class-slots nil :type eieio--slot)
97 class-allocation-values ;; class allocated value vector
98 default-object-cache ;; what a newly created object would look like.
99 ; This will speed up instantiation time as
100 ; only a `copy-sequence' will be needed, instead of
101 ; looping over all the values and setting them from
102 ; the default.
103 options ;; storage location of tagged class option
104 ; Stored outright without modifications or stripping
105 )
106 ;; Set it back to the default value.
107 (cl-declaim (optimize (safety 1))))
108
109
110 (cl-defstruct (eieio--object
111 (:type vector) ;We manage our own tagging system.
112 (:constructor nil)
113 (:copier nil))
114 ;; `class-tag' holds a symbol, which is not the class name, but is instead
115 ;; properly prefixed as an internal EIEIO thingy and which holds the class
116 ;; object/struct in its `symbol-value' slot.
117 class-tag)
118
119 (eval-when-compile
120 (defconst eieio--object-num-slots
121 (length (cl-struct-slot-info 'eieio--object))))
122
123 (defsubst eieio--object-class (obj)
124 (symbol-value (eieio--object-class-tag obj)))
125
126 \f
127 ;;; Important macros used internally in eieio.
128
129 (require 'cl-macs) ;For cl--find-class.
130
131 (defsubst eieio--class-object (class)
132 "Return the class object."
133 (if (symbolp class)
134 ;; Keep the symbol if class-v is nil, for better error messages.
135 (or (cl--find-class class) class)
136 class))
137
138 (defun class-p (class)
139 "Return non-nil if CLASS is a valid class vector.
140 CLASS is a symbol." ;FIXME: Is it a vector or a symbol?
141 (and (symbolp class) (eieio--class-p (cl--find-class class))))
142
143 (defun eieio--class-print-name (class)
144 "Return a printed representation of CLASS."
145 (format "#<class %s>" (eieio-class-name class)))
146
147 (defun eieio-class-name (class)
148 "Return a Lisp like symbol name for CLASS."
149 (setq class (eieio--class-object class))
150 (cl-check-type class eieio--class)
151 (eieio--class-name class))
152 (define-obsolete-function-alias 'class-name #'eieio-class-name "24.4")
153
154 (defalias 'eieio--class-constructor #'identity
155 "Return the symbol representing the constructor of CLASS.")
156
157 (defmacro eieio--class-option-assoc (list option)
158 "Return from LIST the found OPTION, or nil if it doesn't exist."
159 `(car-safe (cdr (memq ,option ,list))))
160
161 (defsubst eieio--class-option (class option)
162 "Return the value stored for CLASS' OPTION.
163 Return nil if that option doesn't exist."
164 (eieio--class-option-assoc (eieio--class-options class) option))
165
166 (defun eieio-object-p (obj)
167 "Return non-nil if OBJ is an EIEIO object."
168 (and (vectorp obj)
169 (> (length obj) 0)
170 (let ((tag (eieio--object-class-tag obj)))
171 (and (symbolp tag)
172 ;; (eq (symbol-function tag) :quick-object-witness-check)
173 (boundp tag)
174 (eieio--class-p (symbol-value tag))))))
175
176 (define-obsolete-function-alias 'object-p 'eieio-object-p "25.1")
177
178 (defun class-abstract-p (class)
179 "Return non-nil if CLASS is abstract.
180 Abstract classes cannot be instantiated."
181 (eieio--class-option (cl--find-class class) :abstract))
182
183 (defsubst eieio--class-method-invocation-order (class)
184 "Return the invocation order of CLASS.
185 Abstract classes cannot be instantiated."
186 (or (eieio--class-option class :method-invocation-order)
187 :breadth-first))
188
189
190 \f
191 ;;;
192 ;; Class Creation
193
194 (defvar eieio-defclass-autoload-map (make-hash-table)
195 "Symbol map of superclasses we find in autoloads.")
196
197 ;; We autoload this because it's used in `make-autoload'.
198 ;;;###autoload
199 (defun eieio-defclass-autoload (cname _superclasses filename doc)
200 "Create autoload symbols for the EIEIO class CNAME.
201 SUPERCLASSES are the superclasses that CNAME inherits from.
202 DOC is the docstring for CNAME.
203 This function creates a mock-class for CNAME and adds it into
204 SUPERCLASSES as children.
205 It creates an autoload function for CNAME's constructor."
206 ;; Assume we've already debugged inputs.
207
208 ;; We used to store the list of superclasses in the `parent' slot (as a list
209 ;; of class names). But now this slot holds a list of class objects, and
210 ;; those parents may not exist yet, so the corresponding class objects may
211 ;; simply not exist yet. So instead we just don't store the list of parents
212 ;; here in eieio-defclass-autoload at all, since it seems that they're just
213 ;; not needed before the class is actually loaded.
214 (let* ((oldc (cl--find-class cname))
215 (newc (eieio--class-make cname)))
216 (if (eieio--class-p oldc)
217 nil ;; Do nothing if we already have this class.
218
219 ;; turn this into a usable self-pointing symbol
220 (when eieio-backward-compatibility
221 (set cname cname)
222 (make-obsolete-variable cname (format "use '%s instead" cname) "25.1"))
223
224 ;; Store the new class vector definition into the symbol. We need to
225 ;; do this first so that we can call defmethod for the accessor.
226 ;; The vector will be updated by the following while loop and will not
227 ;; need to be stored a second time.
228 (setf (cl--find-class cname) newc)
229
230 ;; Create an autoload on top of our constructor function.
231 (autoload cname filename doc nil nil)
232 (autoload (intern (format "%s-p" cname)) filename "" nil nil)
233 (when eieio-backward-compatibility
234 (autoload (intern (format "%s-child-p" cname)) filename "" nil nil)
235 (autoload (intern (format "%s-list-p" cname)) filename "" nil nil)))))
236
237 (defsubst eieio-class-un-autoload (cname)
238 "If class CNAME is in an autoload state, load its file."
239 (autoload-do-load (symbol-function cname))) ; cname
240
241 (cl-deftype list-of (elem-type)
242 `(and list
243 (satisfies (lambda (list)
244 (cl-every (lambda (elem) (cl-typep elem ',elem-type))
245 list)))))
246
247
248 (defun eieio-make-class-predicate (class)
249 (lambda (obj)
250 (:documentation
251 (format "Return non-nil if OBJ is an object of type `%S'.\n\n(fn OBJ)"
252 class))
253 (and (eieio-object-p obj)
254 (same-class-p obj class))))
255
256 (defun eieio-make-child-predicate (class)
257 (lambda (obj)
258 (:documentation
259 (format "Return non-nil if OBJ is an object of type `%S' or a subclass.
260 \n(fn OBJ)" class))
261 (and (eieio-object-p obj)
262 (object-of-class-p obj class))))
263
264 (defvar eieio--known-slot-names nil)
265
266 (defun eieio-defclass-internal (cname superclasses slots options)
267 "Define CNAME as a new subclass of SUPERCLASSES.
268 SLOTS are the slots residing in that class definition, and OPTIONS
269 holds the class options.
270 See `defclass' for more information."
271 ;; Run our eieio-hook each time, and clear it when we are done.
272 ;; This way people can add hooks safely if they want to modify eieio
273 ;; or add definitions when eieio is loaded or something like that.
274 (run-hooks 'eieio-hook)
275 (setq eieio-hook nil)
276
277 (let* ((oldc (let ((c (cl--find-class cname))) (if (eieio--class-p c) c)))
278 (newc (or oldc
279 ;; Reuse `oldc' instead of creating a new one, so that
280 ;; existing references stay valid. E.g. when
281 ;; reloading the file that does the `defclass', we don't
282 ;; want to create a new class object.
283 (eieio--class-make cname)))
284 (groups nil) ;; list of groups id'd from slots
285 (clearparent nil))
286
287 ;; If this class already existed, and we are updating its structure,
288 ;; make sure we keep the old child list. This can cause bugs, but
289 ;; if no new slots are created, it also saves time, and prevents
290 ;; method table breakage, particularly when the users is only
291 ;; byte compiling an EIEIO file.
292 (if oldc
293 (progn
294 (cl-assert (eq newc oldc))
295 ;; Reset the fields.
296 (setf (eieio--class-parents newc) nil)
297 (setf (eieio--class-slots newc) nil)
298 (setf (eieio--class-initarg-tuples newc) nil)
299 (setf (eieio--class-class-slots newc) nil))
300 ;; If the old class did not exist, but did exist in the autoload map,
301 ;; then adopt those children. This is like the above, but deals with
302 ;; autoloads nicely.
303 (let ((children (gethash cname eieio-defclass-autoload-map)))
304 (when children
305 (setf (eieio--class-children newc) children)
306 (remhash cname eieio-defclass-autoload-map))))
307
308 (if superclasses
309 (progn
310 (dolist (p superclasses)
311 (if (not (and p (symbolp p)))
312 (error "Invalid parent class %S" p)
313 (let ((c (cl--find-class p)))
314 (if (not (eieio--class-p c))
315 ;; bad class
316 (error "Given parent class %S is not a class" p)
317 ;; good parent class...
318 ;; save new child in parent
319 (cl-pushnew cname (eieio--class-children c))
320 ;; Get custom groups, and store them into our local copy.
321 (mapc (lambda (g) (cl-pushnew g groups :test #'equal))
322 (eieio--class-option c :custom-groups))
323 ;; Save parent in child.
324 (push c (eieio--class-parents newc))))))
325 ;; Reverse the list of our parents so that they are prioritized in
326 ;; the same order as specified in the code.
327 (cl-callf nreverse (eieio--class-parents newc)))
328 ;; If there is nothing to loop over, then inherit from the
329 ;; default superclass.
330 (unless (eq cname 'eieio-default-superclass)
331 ;; adopt the default parent here, but clear it later...
332 (setq clearparent t)
333 ;; save new child in parent
334 (cl-pushnew cname (eieio--class-children eieio-default-superclass))
335 ;; save parent in child
336 (setf (eieio--class-parents newc) (list eieio-default-superclass))))
337
338 ;; turn this into a usable self-pointing symbol; FIXME: Why?
339 (when eieio-backward-compatibility
340 (set cname cname)
341 (make-obsolete-variable cname (format "use '%s instead" cname) "25.1"))
342
343 ;; Create a handy list of the class test too
344 (when eieio-backward-compatibility
345 (let ((csym (intern (concat (symbol-name cname) "-list-p"))))
346 (defalias csym
347 `(lambda (obj)
348 ,(format
349 "Test OBJ to see if it a list of objects which are a child of type %s"
350 cname)
351 (when (listp obj)
352 (let ((ans t)) ;; nil is valid
353 ;; Loop over all the elements of the input list, test
354 ;; each to make sure it is a child of the desired object class.
355 (while (and obj ans)
356 (setq ans (and (eieio-object-p (car obj))
357 (object-of-class-p (car obj) ,cname)))
358 (setq obj (cdr obj)))
359 ans))))
360 (make-obsolete csym (format "use (cl-typep ... '(list-of %s)) instead"
361 cname)
362 "25.1")))
363
364 ;; Before adding new slots, let's add all the methods and classes
365 ;; in from the parent class.
366 (eieio-copy-parents-into-subclass newc)
367
368 ;; Store the new class vector definition into the symbol. We need to
369 ;; do this first so that we can call defmethod for the accessor.
370 ;; The vector will be updated by the following while loop and will not
371 ;; need to be stored a second time.
372 (setf (cl--find-class cname) newc)
373
374 ;; Query each slot in the declaration list and mangle into the
375 ;; class structure I have defined.
376 (pcase-dolist (`(,name . ,slot) slots)
377 (let* ((init (or (plist-get slot :initform)
378 (if (member :initform slot) nil
379 eieio-unbound)))
380 (initarg (plist-get slot :initarg))
381 (docstr (plist-get slot :documentation))
382 (prot (plist-get slot :protection))
383 (alloc (plist-get slot :allocation))
384 (type (plist-get slot :type))
385 (custom (plist-get slot :custom))
386 (label (plist-get slot :label))
387 (customg (plist-get slot :group))
388 (printer (plist-get slot :printer))
389
390 (skip-nil (eieio--class-option-assoc options :allow-nil-initform))
391 )
392
393 ;; Clean up the meaning of protection.
394 (setq prot
395 (pcase prot
396 ((or 'nil 'public ':public) nil)
397 ((or 'protected ':protected) 'protected)
398 ((or 'private ':private) 'private)
399 (_ (signal 'invalid-slot-type (list :protection prot)))))
400
401 ;; The default type specifier is supposed to be t, meaning anything.
402 (if (not type) (setq type t))
403
404 ;; intern the symbol so we can use it blankly
405 (if eieio-backward-compatibility
406 (and initarg (not (keywordp initarg))
407 (progn
408 (set initarg initarg)
409 (make-obsolete-variable
410 initarg (format "use '%s instead" initarg) "25.1"))))
411
412 ;; The customgroup should be a list of symbols.
413 (cond ((and (null customg) custom)
414 (setq customg '(default)))
415 ((not (listp customg))
416 (setq customg (list customg))))
417 ;; The customgroup better be a list of symbols.
418 (dolist (cg customg)
419 (unless (symbolp cg)
420 (signal 'invalid-slot-type (list :group cg))))
421
422 ;; First up, add this slot into our new class.
423 (eieio--add-new-slot
424 newc (cl--make-slot-descriptor
425 name init type
426 `(,@(if docstr `((:documentation . ,docstr)))
427 ,@(if custom `((:custom . ,custom)))
428 ,@(if label `((:label . ,label)))
429 ,@(if customg `((:group . ,customg)))
430 ,@(if printer `((:printer . ,printer)))
431 ,@(if prot `((:protection . ,prot)))))
432 initarg alloc 'defaultoverride skip-nil)
433
434 ;; We need to id the group, and store them in a group list attribute.
435 (dolist (cg customg)
436 (cl-pushnew cg groups :test #'equal))
437 ))
438
439 ;; Now that everything has been loaded up, all our lists are backwards!
440 ;; Fix that up now and then them into vectors.
441 (cl-callf (lambda (slots) (apply #'vector (nreverse slots)))
442 (eieio--class-slots newc))
443 (cl-callf nreverse (eieio--class-initarg-tuples newc))
444
445 ;; The storage for class-class-allocation-type needs to be turned into
446 ;; a vector now.
447 (cl-callf (lambda (slots) (apply #'vector slots))
448 (eieio--class-class-slots newc))
449
450 ;; Also, setup the class allocated values.
451 (let* ((slots (eieio--class-class-slots newc))
452 (n (length slots))
453 (v (make-vector n nil)))
454 (dotimes (i n)
455 (setf (aref v i) (eieio-default-eval-maybe
456 (cl--slot-descriptor-initform (aref slots i)))))
457 (setf (eieio--class-class-allocation-values newc) v))
458
459 ;; Attach slot symbols into a hashtable, and store the index of
460 ;; this slot as the value this table.
461 (let* ((slots (eieio--class-slots newc))
462 ;; (cslots (eieio--class-class-slots newc))
463 (oa (make-hash-table :test #'eq)))
464 ;; (dotimes (cnt (length cslots))
465 ;; (setf (gethash (cl--slot-descriptor-name (aref cslots cnt)) oa) (- -1 cnt)))
466 (dotimes (cnt (length slots))
467 (setf (gethash (cl--slot-descriptor-name (aref slots cnt)) oa) cnt))
468 (setf (eieio--class-index-table newc) oa))
469
470 ;; Set up a specialized doc string.
471 ;; Use stored value since it is calculated in a non-trivial way
472 (let ((docstring (eieio--class-option-assoc options :documentation)))
473 (setf (eieio--class-docstring newc) docstring)
474 (when eieio-backward-compatibility
475 (put cname 'variable-documentation docstring)))
476
477 ;; Save the file location where this class is defined.
478 (add-to-list 'current-load-list `(define-type . ,cname))
479
480 ;; We have a list of custom groups. Store them into the options.
481 (let ((g (eieio--class-option-assoc options :custom-groups)))
482 (mapc (lambda (cg) (cl-pushnew cg g :test 'equal)) groups)
483 (if (memq :custom-groups options)
484 (setcar (cdr (memq :custom-groups options)) g)
485 (setq options (cons :custom-groups (cons g options)))))
486
487 ;; Set up the options we have collected.
488 (setf (eieio--class-options newc) options)
489
490 ;; if this is a superclass, clear out parent (which was set to the
491 ;; default superclass eieio-default-superclass)
492 (if clearparent (setf (eieio--class-parents newc) nil))
493
494 ;; Create the cached default object.
495 (let ((cache (make-vector (+ (length (eieio--class-slots newc))
496 (eval-when-compile eieio--object-num-slots))
497 nil))
498 ;; We don't strictly speaking need to use a symbol, but the old
499 ;; code used the class's name rather than the class's object, so
500 ;; we follow this preference for using a symbol, which is probably
501 ;; convenient to keep the printed representation of such Elisp
502 ;; objects readable.
503 (tag (intern (format "eieio-class-tag--%s" cname))))
504 (set tag newc)
505 (fset tag :quick-object-witness-check)
506 (setf (eieio--object-class-tag cache) tag)
507 (let ((eieio-skip-typecheck t))
508 ;; All type-checking has been done to our satisfaction
509 ;; before this call. Don't waste our time in this call..
510 (eieio-set-defaults cache t))
511 (setf (eieio--class-default-object-cache newc) cache))
512
513 ;; Return our new class object
514 ;; newc
515 cname
516 ))
517
518 (defsubst eieio-eval-default-p (val)
519 "Whether the default value VAL should be evaluated for use."
520 (and (consp val) (symbolp (car val)) (fboundp (car val))))
521
522 (defun eieio--perform-slot-validation-for-default (slot skipnil)
523 "For SLOT, signal if its type does not match its default value.
524 If SKIPNIL is non-nil, then if default value is nil return t instead."
525 (let ((value (cl--slot-descriptor-initform slot))
526 (spec (cl--slot-descriptor-type slot)))
527 (if (not (or (eieio-eval-default-p value) ;FIXME: Why?
528 eieio-skip-typecheck
529 (and skipnil (null value))
530 (eieio--perform-slot-validation spec value)))
531 (signal 'invalid-slot-type (list (cl--slot-descriptor-name slot) spec value)))))
532
533 (defun eieio--slot-override (old new skipnil)
534 (cl-assert (eq (cl--slot-descriptor-name old) (cl--slot-descriptor-name new)))
535 ;; There is a match, and we must override the old value.
536 (let* ((a (cl--slot-descriptor-name old))
537 (tp (cl--slot-descriptor-type old))
538 (d (cl--slot-descriptor-initform new))
539 (type (cl--slot-descriptor-type new))
540 (oprops (cl--slot-descriptor-props old))
541 (nprops (cl--slot-descriptor-props new))
542 (custg (alist-get :group nprops)))
543 ;; If type is passed in, is it the same?
544 (if (not (eq type t))
545 (if (not (equal type tp))
546 (error
547 "Child slot type ‘%s’ does not match inherited type ‘%s’ for ‘%s’"
548 type tp a))
549 (setf (cl--slot-descriptor-type new) tp))
550 ;; If we have a repeat, only update the initarg...
551 (unless (eq d eieio-unbound)
552 (eieio--perform-slot-validation-for-default new skipnil)
553 (setf (cl--slot-descriptor-initform old) d))
554
555 ;; PLN Tue Jun 26 11:57:06 2007 : The protection is
556 ;; checked and SHOULD match the superclass
557 ;; protection. Otherwise an error is thrown. However
558 ;; I wonder if a more flexible schedule might be
559 ;; implemented.
560 ;;
561 ;; EML - We used to have (if prot... here,
562 ;; but a prot of 'nil means public.
563 ;;
564 (let ((super-prot (alist-get :protection oprops))
565 (prot (alist-get :protection nprops)))
566 (if (not (eq prot super-prot))
567 (error "Child slot protection ‘%s’ does not match inherited protection ‘%s’ for ‘%s’"
568 prot super-prot a)))
569 ;; End original PLN
570
571 ;; PLN Tue Jun 26 11:57:06 2007 :
572 ;; Do a non redundant combination of ancient custom
573 ;; groups and new ones.
574 (when custg
575 (let* ((list1 (alist-get :group oprops)))
576 (dolist (elt custg)
577 (unless (memq elt list1)
578 (push elt list1)))
579 (setf (alist-get :group (cl--slot-descriptor-props old)) list1)))
580 ;; End PLN
581
582 ;; PLN Mon Jun 25 22:44:34 2007 : If a new cust is
583 ;; set, simply replaces the old one.
584 (dolist (prop '(:custom :label :documentation :printer))
585 (when (alist-get prop (cl--slot-descriptor-props new))
586 (setf (alist-get prop (cl--slot-descriptor-props old))
587 (alist-get prop (cl--slot-descriptor-props new))))
588
589 ) ))
590
591 (defun eieio--add-new-slot (newc slot init alloc
592 &optional defaultoverride skipnil)
593 "Add into NEWC attribute SLOT.
594 If a slot of that name already exists in NEWC, then do nothing. If it doesn't exist,
595 INIT is the initarg, if any.
596 Argument ALLOC specifies if the slot is allocated per instance, or per class.
597 If optional DEFAULTOVERRIDE is non-nil, then if A exists in NEWC,
598 we must override its value for a default.
599 Optional argument SKIPNIL indicates if type checking should be skipped
600 if default value is nil."
601 ;; Make sure we duplicate those items that are sequences.
602 (let* ((a (cl--slot-descriptor-name slot))
603 (d (cl--slot-descriptor-initform slot))
604 (old (car (cl-member a (eieio--class-slots newc)
605 :key #'cl--slot-descriptor-name)))
606 (cold (car (cl-member a (eieio--class-class-slots newc)
607 :key #'cl--slot-descriptor-name))))
608 (cl-pushnew a eieio--known-slot-names)
609 (condition-case nil
610 (if (sequencep d) (setq d (copy-sequence d)))
611 ;; This copy can fail on a cons cell with a non-cons in the cdr. Let's
612 ;; skip it if it doesn't work.
613 (error nil))
614 ;; (if (sequencep type) (setq type (copy-sequence type)))
615 ;; (if (sequencep cust) (setq cust (copy-sequence cust)))
616 ;; (if (sequencep custg) (setq custg (copy-sequence custg)))
617
618 ;; To prevent override information w/out specification of storage,
619 ;; we need to do this little hack.
620 (if cold (setq alloc :class))
621
622 (if (memq alloc '(nil :instance))
623 ;; In this case, we modify the INSTANCE version of a given slot.
624 (progn
625 ;; Only add this element if it is so-far unique
626 (if (not old)
627 (progn
628 (eieio--perform-slot-validation-for-default slot skipnil)
629 (push slot (eieio--class-slots newc))
630 )
631 ;; When defaultoverride is true, we are usually adding new local
632 ;; attributes which must override the default value of any slot
633 ;; passed in by one of the parent classes.
634 (when defaultoverride
635 (eieio--slot-override old slot skipnil)))
636 (when init
637 (cl-pushnew (cons init a) (eieio--class-initarg-tuples newc)
638 :test #'equal)))
639
640 ;; CLASS ALLOCATED SLOTS
641 (if (not cold)
642 (progn
643 (eieio--perform-slot-validation-for-default slot skipnil)
644 ;; Here we have found a :class version of a slot. This
645 ;; requires a very different approach.
646 (push slot (eieio--class-class-slots newc)))
647 (when defaultoverride
648 ;; There is a match, and we must override the old value.
649 (eieio--slot-override cold slot skipnil))))))
650
651 (defun eieio-copy-parents-into-subclass (newc)
652 "Copy into NEWC the slots of PARENTS.
653 Follow the rules of not overwriting early parents when applying to
654 the new child class."
655 (let ((sn (eieio--class-option-assoc (eieio--class-options newc)
656 :allow-nil-initform)))
657 (dolist (pcv (eieio--class-parents newc))
658 ;; First, duplicate all the slots of the parent.
659 (let ((pslots (eieio--class-slots pcv))
660 (pinit (eieio--class-initarg-tuples pcv)))
661 (dotimes (i (length pslots))
662 (let* ((sd (cl--copy-slot-descriptor (aref pslots i)))
663 (init (car (rassq (cl--slot-descriptor-name sd) pinit))))
664 (eieio--add-new-slot newc sd init nil nil sn))
665 )) ;; while/let
666 ;; Now duplicate all the class alloc slots.
667 (let ((pcslots (eieio--class-class-slots pcv)))
668 (dotimes (i (length pcslots))
669 (eieio--add-new-slot newc (cl--copy-slot-descriptor
670 (aref pcslots i))
671 nil :class sn)
672 )))))
673
674 \f
675 ;;; Slot type validation
676
677 ;; This is a hideous hack for replacing `typep' from cl-macs, to avoid
678 ;; requiring the CL library at run-time. It can be eliminated if/when
679 ;; `typep' is merged into Emacs core.
680
681 (defun eieio--perform-slot-validation (spec value)
682 "Return non-nil if SPEC does not match VALUE."
683 (or (eq spec t) ; t always passes
684 (eq value eieio-unbound) ; unbound always passes
685 (cl-typep value spec)))
686
687 (defun eieio--validate-slot-value (class slot-idx value slot)
688 "Make sure that for CLASS referencing SLOT-IDX, VALUE is valid.
689 Checks the :type specifier.
690 SLOT is the slot that is being checked, and is only used when throwing
691 an error."
692 (if eieio-skip-typecheck
693 nil
694 ;; Trim off object IDX junk added in for the object index.
695 (setq slot-idx (- slot-idx (eval-when-compile eieio--object-num-slots)))
696 (let ((st (cl--slot-descriptor-type (aref (eieio--class-slots class)
697 slot-idx))))
698 (if (not (eieio--perform-slot-validation st value))
699 (signal 'invalid-slot-type
700 (list (eieio--class-name class) slot st value))))))
701
702 (defun eieio--validate-class-slot-value (class slot-idx value slot)
703 "Make sure that for CLASS referencing SLOT-IDX, VALUE is valid.
704 Checks the :type specifier.
705 SLOT is the slot that is being checked, and is only used when throwing
706 an error."
707 (if eieio-skip-typecheck
708 nil
709 (let ((st (cl--slot-descriptor-type (aref (eieio--class-class-slots class)
710 slot-idx))))
711 (if (not (eieio--perform-slot-validation st value))
712 (signal 'invalid-slot-type
713 (list (eieio--class-name class) slot st value))))))
714
715 (defun eieio-barf-if-slot-unbound (value instance slotname fn)
716 "Throw a signal if VALUE is a representation of an UNBOUND slot.
717 INSTANCE is the object being referenced. SLOTNAME is the offending
718 slot. If the slot is ok, return VALUE.
719 Argument FN is the function calling this verifier."
720 (if (and (eq value eieio-unbound) (not eieio-skip-typecheck))
721 (slot-unbound instance (eieio--object-class instance) slotname fn)
722 value))
723
724 \f
725 ;;; Get/Set slots in an object.
726
727 (defun eieio-oref (obj slot)
728 "Return the value in OBJ at SLOT in the object vector."
729 (declare (compiler-macro
730 (lambda (exp)
731 (ignore obj)
732 (pcase slot
733 ((and (or `',name (and name (pred keywordp)))
734 (guard (not (memq name eieio--known-slot-names))))
735 (macroexp--warn-and-return
736 (format-message "Unknown slot ‘%S’" name) exp 'compile-only))
737 (_ exp)))))
738 (cl-check-type slot symbol)
739 (cl-check-type obj (or eieio-object class))
740 (let* ((class (cond ((symbolp obj)
741 (error "eieio-oref called on a class: %s" obj)
742 (let ((c (cl--find-class obj)))
743 (if (eieio--class-p c) (eieio-class-un-autoload obj))
744 c))
745 (t (eieio--object-class obj))))
746 (c (eieio--slot-name-index class slot)))
747 (if (not c)
748 ;; It might be missing because it is a :class allocated slot.
749 ;; Let's check that info out.
750 (if (setq c (eieio--class-slot-name-index class slot))
751 ;; Oref that slot.
752 (aref (eieio--class-class-allocation-values class) c)
753 ;; The slot-missing method is a cool way of allowing an object author
754 ;; to intercept missing slot definitions. Since it is also the LAST
755 ;; thing called in this fn, its return value would be retrieved.
756 (slot-missing obj slot 'oref)
757 ;;(signal 'invalid-slot-name (list (eieio-object-name obj) slot))
758 )
759 (cl-check-type obj eieio-object)
760 (eieio-barf-if-slot-unbound (aref obj c) obj slot 'oref))))
761
762
763 (defun eieio-oref-default (obj slot)
764 "Do the work for the macro `oref-default' with similar parameters.
765 Fills in OBJ's SLOT with its default value."
766 (cl-check-type obj (or eieio-object class))
767 (cl-check-type slot symbol)
768 (let* ((cl (cond ((symbolp obj) (cl--find-class obj))
769 (t (eieio--object-class obj))))
770 (c (eieio--slot-name-index cl slot)))
771 (if (not c)
772 ;; It might be missing because it is a :class allocated slot.
773 ;; Let's check that info out.
774 (if (setq c
775 (eieio--class-slot-name-index cl slot))
776 ;; Oref that slot.
777 (aref (eieio--class-class-allocation-values cl)
778 c)
779 (slot-missing obj slot 'oref-default)
780 ;;(signal 'invalid-slot-name (list (class-name cl) slot))
781 )
782 (eieio-barf-if-slot-unbound
783 (let ((val (cl--slot-descriptor-initform
784 (aref (eieio--class-slots cl)
785 (- c (eval-when-compile eieio--object-num-slots))))))
786 (eieio-default-eval-maybe val))
787 obj (eieio--class-name cl) 'oref-default))))
788
789 (defun eieio-default-eval-maybe (val)
790 "Check VAL, and return what `oref-default' would provide."
791 ;; FIXME: What the hell is this supposed to do? Shouldn't it evaluate
792 ;; variables as well? Why not just always call `eval'?
793 (cond
794 ;; Is it a function call? If so, evaluate it.
795 ((eieio-eval-default-p val)
796 (eval val))
797 ;;;; check for quoted things, and unquote them
798 ;;((and (consp val) (eq (car val) 'quote))
799 ;; (car (cdr val)))
800 ;; return it verbatim
801 (t val)))
802
803 (defun eieio-oset (obj slot value)
804 "Do the work for the macro `oset'.
805 Fills in OBJ's SLOT with VALUE."
806 (cl-check-type obj eieio-object)
807 (cl-check-type slot symbol)
808 (let* ((class (eieio--object-class obj))
809 (c (eieio--slot-name-index class slot)))
810 (if (not c)
811 ;; It might be missing because it is a :class allocated slot.
812 ;; Let's check that info out.
813 (if (setq c
814 (eieio--class-slot-name-index class slot))
815 ;; Oset that slot.
816 (progn
817 (eieio--validate-class-slot-value class c value slot)
818 (aset (eieio--class-class-allocation-values class)
819 c value))
820 ;; See oref for comment on `slot-missing'
821 (slot-missing obj slot 'oset value)
822 ;;(signal 'invalid-slot-name (list (eieio-object-name obj) slot))
823 )
824 (eieio--validate-slot-value class c value slot)
825 (aset obj c value))))
826
827 (defun eieio-oset-default (class slot value)
828 "Do the work for the macro `oset-default'.
829 Fills in the default value in CLASS' in SLOT with VALUE."
830 (setq class (eieio--class-object class))
831 (cl-check-type class eieio--class)
832 (cl-check-type slot symbol)
833 (let* ((c (eieio--slot-name-index class slot)))
834 (if (not c)
835 ;; It might be missing because it is a :class allocated slot.
836 ;; Let's check that info out.
837 (if (setq c (eieio--class-slot-name-index class slot))
838 (progn
839 ;; Oref that slot.
840 (eieio--validate-class-slot-value class c value slot)
841 (aset (eieio--class-class-allocation-values class) c
842 value))
843 (signal 'invalid-slot-name (list (eieio--class-name class) slot)))
844 ;; `oset-default' on an instance-allocated slot is allowed by EIEIO but
845 ;; not by CLOS and is mildly inconsistent with the :initform thingy, so
846 ;; it'd be nice to get of it. This said, it is/was used at one place by
847 ;; gnus/registry.el, so it might be used elsewhere as well, so let's
848 ;; keep it for now.
849 ;; FIXME: Generate a compile-time warning for it!
850 ;; (error "Can't ‘oset-default’ an instance-allocated slot: %S of %S"
851 ;; slot class)
852 (eieio--validate-slot-value class c value slot)
853 ;; Set this into the storage for defaults.
854 (if (eieio-eval-default-p value)
855 (error "Can't set default to a sexp that gets evaluated again"))
856 (setf (cl--slot-descriptor-initform
857 ;; FIXME: Apparently we set it both in `slots' and in
858 ;; `object-cache', which seems redundant.
859 (aref (eieio--class-slots class)
860 (- c (eval-when-compile eieio--object-num-slots))))
861 value)
862 ;; Take the value, and put it into our cache object.
863 (eieio-oset (eieio--class-default-object-cache class)
864 slot value)
865 )))
866
867 \f
868 ;;; EIEIO internal search functions
869 ;;
870 (defun eieio--slot-name-index (class slot)
871 "In CLASS find the index of the named SLOT.
872 The slot is a symbol which is installed in CLASS by the `defclass' call.
873 If SLOT is the value created with :initarg instead,
874 reverse-lookup that name, and recurse with the associated slot value."
875 ;; Removed checks to outside this call
876 (let* ((fsi (gethash slot (eieio--class-index-table class))))
877 (if (integerp fsi)
878 (+ (eval-when-compile eieio--object-num-slots) fsi)
879 (let ((fn (eieio--initarg-to-attribute class slot)))
880 (if fn
881 ;; Accessing a slot via its :initarg is accepted by EIEIO
882 ;; (but not CLOS) but is a bad idea (for one: it's slower).
883 ;; FIXME: We should emit a compile-time warning when this happens!
884 (eieio--slot-name-index class fn)
885 nil)))))
886
887 (defun eieio--class-slot-name-index (class slot)
888 "In CLASS find the index of the named SLOT.
889 The slot is a symbol which is installed in CLASS by the `defclass'
890 call. If SLOT is the value created with :initarg instead,
891 reverse-lookup that name, and recurse with the associated slot value."
892 ;; This will happen less often, and with fewer slots. Do this the
893 ;; storage cheap way.
894 (let ((index nil)
895 (slots (eieio--class-class-slots class)))
896 (dotimes (i (length slots))
897 (if (eq slot (cl--slot-descriptor-name (aref slots i)))
898 (setq index i)))
899 index))
900
901 ;;;
902 ;; Way to assign slots based on a list. Used for constructors, or
903 ;; even resetting an object at run-time
904 ;;
905 (defun eieio-set-defaults (obj &optional set-all)
906 "Take object OBJ, and reset all slots to their defaults.
907 If SET-ALL is non-nil, then when a default is nil, that value is
908 reset. If SET-ALL is nil, the slots are only reset if the default is
909 not nil."
910 (let ((slots (eieio--class-slots (eieio--object-class obj))))
911 (dotimes (i (length slots))
912 (let* ((name (cl--slot-descriptor-name (aref slots i)))
913 (df (eieio-oref-default obj name)))
914 (if (or df set-all)
915 (eieio-oset obj name df))))))
916
917 (defun eieio--initarg-to-attribute (class initarg)
918 "For CLASS, convert INITARG to the actual attribute name.
919 If there is no translation, pass it in directly (so we can cheat if
920 need be... May remove that later...)"
921 (let ((tuple (assoc initarg (eieio--class-initarg-tuples class))))
922 (if tuple
923 (cdr tuple)
924 nil)))
925
926 ;;;
927 ;; Method Invocation order: C3
928 (defun eieio--c3-candidate (class remaining-inputs)
929 "Return CLASS if it can go in the result now, otherwise nil."
930 ;; Ensure CLASS is not in any position but the first in any of the
931 ;; element lists of REMAINING-INPUTS.
932 (and (not (let ((found nil))
933 (while (and remaining-inputs (not found))
934 (setq found (member class (cdr (car remaining-inputs)))
935 remaining-inputs (cdr remaining-inputs)))
936 found))
937 class))
938
939 (defun eieio--c3-merge-lists (reversed-partial-result remaining-inputs)
940 "Merge REVERSED-PARTIAL-RESULT REMAINING-INPUTS in a consistent order, if possible.
941 If a consistent order does not exist, signal an error."
942 (setq remaining-inputs (delq nil remaining-inputs))
943 (if (null remaining-inputs)
944 ;; If all remaining inputs are empty lists, we are done.
945 (nreverse reversed-partial-result)
946 ;; Otherwise, we try to find the next element of the result. This
947 ;; is achieved by considering the first element of each
948 ;; (non-empty) input list and accepting a candidate if it is
949 ;; consistent with the rests of the input lists.
950 (let* ((found nil)
951 (tail remaining-inputs)
952 (next (progn
953 (while (and tail (not found))
954 (setq found (eieio--c3-candidate (caar tail)
955 remaining-inputs)
956 tail (cdr tail)))
957 found)))
958 (if next
959 ;; The graph is consistent so far, add NEXT to result and
960 ;; merge input lists, dropping NEXT from their heads where
961 ;; applicable.
962 (eieio--c3-merge-lists
963 (cons next reversed-partial-result)
964 (mapcar (lambda (l) (if (eq (cl-first l) next) (cl-rest l) l))
965 remaining-inputs))
966 ;; The graph is inconsistent, give up
967 (signal 'inconsistent-class-hierarchy (list remaining-inputs))))))
968
969 (defsubst eieio--class/struct-parents (class)
970 (or (eieio--class-parents class)
971 `(,eieio-default-superclass)))
972
973 (defun eieio--class-precedence-c3 (class)
974 "Return all parents of CLASS in c3 order."
975 (let ((parents (eieio--class-parents (cl--find-class class))))
976 (eieio--c3-merge-lists
977 (list class)
978 (append
979 (or
980 (mapcar #'eieio--class-precedence-c3 parents)
981 `((,eieio-default-superclass)))
982 (list parents))))
983 )
984 ;;;
985 ;; Method Invocation Order: Depth First
986
987 (defun eieio--class-precedence-dfs (class)
988 "Return all parents of CLASS in depth-first order."
989 (let* ((parents (eieio--class-parents class))
990 (classes (copy-sequence
991 (apply #'append
992 (list class)
993 (or
994 (mapcar
995 (lambda (parent)
996 (cons parent
997 (eieio--class-precedence-dfs parent)))
998 parents)
999 `((,eieio-default-superclass))))))
1000 (tail classes))
1001 ;; Remove duplicates.
1002 (while tail
1003 (setcdr tail (delq (car tail) (cdr tail)))
1004 (setq tail (cdr tail)))
1005 classes))
1006
1007 ;;;
1008 ;; Method Invocation Order: Breadth First
1009 (defun eieio--class-precedence-bfs (class)
1010 "Return all parents of CLASS in breadth-first order."
1011 (let* ((result)
1012 (queue (eieio--class/struct-parents class)))
1013 (while queue
1014 (let ((head (pop queue)))
1015 (unless (member head result)
1016 (push head result)
1017 (unless (eq head eieio-default-superclass)
1018 (setq queue (append queue (eieio--class/struct-parents head)))))))
1019 (cons class (nreverse result)))
1020 )
1021
1022 ;;;
1023 ;; Method Invocation Order
1024
1025 (defun eieio--class-precedence-list (class)
1026 "Return (transitively closed) list of parents of CLASS.
1027 The order, in which the parents are returned depends on the
1028 method invocation orders of the involved classes."
1029 (if (or (null class) (eq class eieio-default-superclass))
1030 nil
1031 (unless (eieio--class-default-object-cache class)
1032 (eieio-class-un-autoload (eieio--class-name class)))
1033 (cl-case (eieio--class-method-invocation-order class)
1034 (:depth-first
1035 (eieio--class-precedence-dfs class))
1036 (:breadth-first
1037 (eieio--class-precedence-bfs class))
1038 (:c3
1039 (eieio--class-precedence-c3 class))))
1040 )
1041 (define-obsolete-function-alias
1042 'class-precedence-list 'eieio--class-precedence-list "24.4")
1043
1044 \f
1045 ;;; Here are some special types of errors
1046 ;;
1047 (define-error 'invalid-slot-name "Invalid slot name")
1048 (define-error 'invalid-slot-type "Invalid slot type")
1049 (define-error 'unbound-slot "Unbound slot")
1050 (define-error 'inconsistent-class-hierarchy "Inconsistent class hierarchy")
1051
1052 ;;; Hooking into cl-generic.
1053
1054 (require 'cl-generic)
1055
1056 ;;;; General support to dispatch based on the type of the argument.
1057
1058 (defconst eieio--generic-generalizer
1059 (cl-generic-make-generalizer
1060 ;; Use the exact same tagcode as for cl-struct, so that methods
1061 ;; that dispatch on both kinds of objects get to share this
1062 ;; part of the dispatch code.
1063 50 #'cl--generic-struct-tag
1064 (lambda (tag)
1065 (and (symbolp tag) (boundp tag) (eieio--class-p (symbol-value tag))
1066 (mapcar #'eieio--class-name
1067 (eieio--class-precedence-list (symbol-value tag)))))))
1068
1069 (cl-defmethod cl-generic-generalizers :extra "class" (specializer)
1070 ;; CLHS says:
1071 ;; A class must be defined before it can be used as a parameter
1072 ;; specializer in a defmethod form.
1073 ;; So we can ignore types that are not known to denote classes.
1074 (or
1075 (and (eieio--class-p (eieio--class-object specializer))
1076 (list eieio--generic-generalizer))
1077 (cl-call-next-method)))
1078
1079 ;;;; Dispatch for arguments which are classes.
1080
1081 ;; Since EIEIO does not support metaclasses, users can't easily use the
1082 ;; "dispatch on argument type" for class arguments. That's why EIEIO's
1083 ;; `defmethod' added the :static qualifier. For cl-generic, such a qualifier
1084 ;; would not make much sense (e.g. to which argument should it apply?).
1085 ;; Instead, we add a new "subclass" specializer.
1086
1087 (defun eieio--generic-subclass-specializers (tag)
1088 (when (eieio--class-p tag)
1089 (mapcar (lambda (class)
1090 `(subclass ,(eieio--class-name class)))
1091 (eieio--class-precedence-list tag))))
1092
1093 (defconst eieio--generic-subclass-generalizer
1094 (cl-generic-make-generalizer
1095 60 (lambda (name) `(and (symbolp ,name) (cl--find-class ,name)))
1096 #'eieio--generic-subclass-specializers))
1097
1098 (cl-defmethod cl-generic-generalizers ((_specializer (head subclass)))
1099 (list eieio--generic-subclass-generalizer))
1100
1101 \f
1102 ;;;### (autoloads nil "eieio-compat" "eieio-compat.el" "ea8c7f24ed47c6b71ac37cbdae1c9931")
1103 ;;; Generated autoloads from eieio-compat.el
1104
1105 (autoload 'eieio--defalias "eieio-compat" "\
1106 Like `defalias', but with less side-effects.
1107 More specifically, it has no side-effects at all when the new function
1108 definition is the same (`eq') as the old one.
1109
1110 \(fn NAME BODY)" nil nil)
1111
1112 (autoload 'defgeneric "eieio-compat" "\
1113 Create a generic function METHOD.
1114 DOC-STRING is the base documentation for this class. A generic
1115 function has no body, as its purpose is to decide which method body
1116 is appropriate to use. Uses `defmethod' to create methods, and calls
1117 `defgeneric' for you. With this implementation the ARGS are
1118 currently ignored. You can use `defgeneric' to apply specialized
1119 top level documentation to a method.
1120
1121 \(fn METHOD ARGS &optional DOC-STRING)" nil t)
1122
1123 (function-put 'defgeneric 'doc-string-elt '3)
1124
1125 (make-obsolete 'defgeneric 'cl-defgeneric '"25.1")
1126
1127 (autoload 'defmethod "eieio-compat" "\
1128 Create a new METHOD through `defgeneric' with ARGS.
1129
1130 The optional second argument KEY is a specifier that
1131 modifies how the method is called, including:
1132 :before - Method will be called before the :primary
1133 :primary - The default if not specified
1134 :after - Method will be called after the :primary
1135 :static - First arg could be an object or class
1136 The next argument is the ARGLIST. The ARGLIST specifies the arguments
1137 to the method as with `defun'. The first argument can have a type
1138 specifier, such as:
1139 ((VARNAME CLASS) ARG2 ...)
1140 where VARNAME is the name of the local variable for the method being
1141 created. The CLASS is a class symbol for a class made with `defclass'.
1142 A DOCSTRING comes after the ARGLIST, and is optional.
1143 All the rest of the args are the BODY of the method. A method will
1144 return the value of the last form in the BODY.
1145
1146 Summary:
1147
1148 (defmethod mymethod [:before | :primary | :after | :static]
1149 ((typearg class-name) arg2 &optional opt &rest rest)
1150 \"doc-string\"
1151 body)
1152
1153 \(fn METHOD &rest ARGS)" nil t)
1154
1155 (function-put 'defmethod 'doc-string-elt '3)
1156
1157 (make-obsolete 'defmethod 'cl-defmethod '"25.1")
1158
1159 (autoload 'eieio--defgeneric-init-form "eieio-compat" "\
1160
1161
1162 \(fn METHOD DOC-STRING)" nil nil)
1163
1164 (autoload 'eieio--defmethod "eieio-compat" "\
1165
1166
1167 \(fn METHOD KIND ARGCLASS CODE)" nil nil)
1168
1169 (autoload 'eieio-defmethod "eieio-compat" "\
1170 Obsolete work part of an old version of the `defmethod' macro.
1171
1172 \(fn METHOD ARGS)" nil nil)
1173
1174 (make-obsolete 'eieio-defmethod 'cl-defmethod '"24.1")
1175
1176 (autoload 'eieio-defgeneric "eieio-compat" "\
1177 Obsolete work part of an old version of the `defgeneric' macro.
1178
1179 \(fn METHOD DOC-STRING)" nil nil)
1180
1181 (make-obsolete 'eieio-defgeneric 'cl-defgeneric '"24.1")
1182
1183 (autoload 'eieio-defclass "eieio-compat" "\
1184
1185
1186 \(fn CNAME SUPERCLASSES SLOTS OPTIONS)" nil nil)
1187
1188 (make-obsolete 'eieio-defclass 'eieio-defclass-internal '"25.1")
1189
1190 ;;;***
1191 \f
1192
1193 (provide 'eieio-core)
1194
1195 ;;; eieio-core.el ends here