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