summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/eieio.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2015-01-04 23:11:37 -0500
committerStefan Monnier <monnier@iro.umontreal.ca>2015-01-04 23:11:37 -0500
commitcb4db863192aed6c4d0b28e6490f08d5518ff3e7 (patch)
tree5d8e5dd834b7a3991e61631fcfcc209a7a25416e /lisp/emacs-lisp/eieio.el
parent232823a1f163cebeafdab20ea2eb3f2da9645185 (diff)
downloademacs-cb4db863192aed6c4d0b28e6490f08d5518ff3e7.tar.gz
emacs-cb4db863192aed6c4d0b28e6490f08d5518ff3e7.tar.bz2
emacs-cb4db863192aed6c4d0b28e6490f08d5518ff3e7.zip
* lisp/emacs-lisp/eieio*.el: Use class objects in `parent' field.
* lisp/emacs-lisp/eieio-core.el (eieio-class-object): New function. (eieio-class-parents-fast): Remove macro. (eieio--class-option-assoc): Rename from class-option-assoc. Update all callers. (eieio--class-option): Rename from class-option. Change `class' arg to be a class object. Update all callers. (eieio--class-method-invocation-order): Rename from class-method-invocation-order. Change `class' arg to be a class object. Update all callers. (eieio-defclass-autoload, eieio-defclass): Set the `parent' field to a list of class objects rather than names. (eieio-defclass): Remove redundant quotes. Use `eieio-oref-default' for accessors to class allocated slots. (eieio--perform-slot-validation-for-default): Rename from eieio-perform-slot-validation-for-default. Update all callers. (eieio--add-new-slot): Rename from eieio-add-new-slot. Update all callers. Use push. (eieio-copy-parents-into-subclass): Adjust to new content of `parent' field. Use dolist. (eieio-oref): Remove support for providing a class rather than an object. (eieio-oref-default): Prefer class objects over class names. (eieio--slot-originating-class-p): Rename from eieio-slot-originating-class-p. Update all callers. Use `or'. (eieio--slot-name-index): Turn check into assertion. (eieio--class-slot-name-index): Rename from eieio-class-slot-name-index. Change `class' arg to be a class object. Update all callers. (eieio-attribute-to-initarg): Move to eieio-test-persist.el. (eieio--c3-candidate): Rename from eieio-c3-candidate. Update all callers. (eieio--c3-merge-lists): Rename from eieio-c3-merge-lists. Update all callers. (eieio--class-precedence-c3): Rename from eieio-class-precedence-c3. Update all callers. (eieio--class-precedence-dfs): Rename from eieio-class-precedence-dfs. Update all callers. (eieio--class-precedence-bfs): Rename from eieio-class-precedence-bfs. Update all callers. Adjust to new `parent' content. (eieio--class-precedence-list): Rename from -class-precedence-list. Update all callers. (eieio-generic-call): Use autoloadp and autoload-do-load. Slight simplification. (eieio-generic-call, eieio-generic-call-primary-only): Adjust to new return value of `eieio-generic-form'. (eieiomt-add): Index the hashtable with class objects rather than class names. (eieio-generic-form): Accept class objects as well. * lisp/emacs-lisp/eieio.el (eieio-class-parents): Accept class objects. (eieio--class-slot-initarg): Rename from class-slot-initarg. Change `class' arg to be a class object. Update all callers. (call-next-method): Adjust to new return value of `eieio-generic-form'. (eieio-default-superclass): Set var to the class object. (eieio-edebug-prin1-to-string): Fix recursive call for lists. Change print behavior to affect class objects rather than class symbols. * lisp/emacs-lisp/eieio-base.el (eieio-persistent-convert-list-to-object): Adjust to new convention for eieio-persistent-validate/fix-slot-value. (eieio-persistent-validate/fix-slot-value): Change `class' arg to be a class object. Update all callers. * test/automated/eieio-test-persist.el (eieio--attribute-to-initarg): Move from eieio-core.el. Rename from eieio-attribute-to-initarg. Change arg to be a class object. Update all callers. * test/automated/eieio-tests.el (eieio-test-04-static-method) (eieio-test-05-static-method-2): Use oref-default to access class slots. (eieio-test-23-inheritance-check): Don't assume that eieio-class-parents returns class names, or that a class can only have a single name.
Diffstat (limited to 'lisp/emacs-lisp/eieio.el')
-rw-r--r--lisp/emacs-lisp/eieio.el41
1 files changed, 21 insertions, 20 deletions
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el
index e80791f9f75..878667106c8 100644
--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -1,7 +1,7 @@
;;; eieio.el --- Enhanced Implementation of Emacs Interpreted Objects -*- lexical-binding:t -*-
;;; or maybe Eric's Implementation of Emacs Interpreted Objects
-;; Copyright (C) 1995-1996, 1998-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1996, 1998-2015 Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
;; Version: 1.4
@@ -319,8 +319,9 @@ If EXTRA, include that in the string returned to represent the symbol."
"Return parent classes to CLASS. (overload of variable).
The CLOS function `class-direct-superclasses' is aliased to this function."
- (eieio--check-type class-p class)
- (eieio-class-parents-fast class))
+ (let ((c (eieio-class-object class)))
+ (eieio--class-parent c)))
+
(define-obsolete-function-alias 'class-parents #'eieio-class-parents "24.4")
(defun eieio-class-children (class)
@@ -366,10 +367,8 @@ The CLOS function `class-direct-subclasses' is aliased to this function."
(setq class (eieio--class-object class))
(eieio--check-type eieio--class-p class)
(while (and child (not (eq child class)))
- ;; FIXME: eieio--class-parent should return class-objects rather than
- ;; class-names!
(setq p (append p (eieio--class-parent child))
- child (eieio--class-v (pop p))))
+ child (pop p)))
(if child t))))
(defun object-slots (obj)
@@ -377,9 +376,9 @@ The CLOS function `class-direct-subclasses' is aliased to this function."
(eieio--check-type eieio-object-p obj)
(eieio--class-public-a (eieio--object-class-object obj)))
-(defun class-slot-initarg (class slot) "Fetch from CLASS, SLOT's :initarg."
- (eieio--check-type class-p class)
- (let ((ia (eieio--class-initarg-tuples (eieio--class-v class)))
+(defun eieio--class-slot-initarg (class slot) "Fetch from CLASS, SLOT's :initarg."
+ (eieio--check-type eieio--class-p class)
+ (let ((ia (eieio--class-initarg-tuples class))
(f nil))
(while (and ia (not f))
(if (eq (cdr (car ia)) slot)
@@ -426,11 +425,9 @@ OBJECT can be an instance or a class."
(defun slot-exists-p (object-or-class slot)
"Return non-nil if OBJECT-OR-CLASS has SLOT."
- (let ((cv (eieio--class-v (cond ((eieio-object-p object-or-class)
- (eieio-object-class object-or-class))
- ((class-p object-or-class)
- object-or-class))
- )))
+ (let ((cv (cond ((eieio-object-p object-or-class)
+ (eieio--object-class-object object-or-class))
+ (t (eieio-class-object object-or-class)))))
(or (memq slot (eieio--class-public-a cv))
(memq slot (eieio--class-class-allocation-a cv)))
))
@@ -555,7 +552,7 @@ Use `next-method-p' to find out if there is a next method to call."
(eieio-generic-call-arglst newargs)
(fcn (car next))
)
- (eieio--with-scoped-class (eieio--class-v (cdr next))
+ (eieio--with-scoped-class (cdr next)
(apply fcn newargs)) ))))
;;; Here are some CLOS items that need the CL package
@@ -580,6 +577,8 @@ Its slots are automatically adopted by classes with no specified parents.
This class is not stored in the `parent' slot of a class vector."
:abstract t)
+(setq eieio-default-superclass (eieio--class-v 'eieio-default-superclass))
+
(defalias 'standard-class 'eieio-default-superclass)
(defgeneric eieio-constructor (class &rest slots)
@@ -797,7 +796,7 @@ this object."
(eieio-print-depth (1+ eieio-print-depth)))
(while publa
(when (slot-boundp this (car publa))
- (let ((i (class-slot-initarg cl (car publa)))
+ (let ((i (eieio--class-slot-initarg cv (car publa)))
(v (eieio-oref this (car publa)))
)
(unless (or (not i) (equal v (car publd)))
@@ -874,11 +873,13 @@ of `eq'."
Used as advice around `edebug-prin1-to-string', held in the
variable PRINT-FUNCTION. Optional argument NOESCAPE is passed to
`prin1-to-string' when appropriate."
- (cond ((class-p object) (eieio-class-name object))
+ (cond ((eieio--class-p object) (eieio-class-name object))
((eieio-object-p object) (object-print object))
- ((and (listp object) (or (class-p (car object))
+ ((and (listp object) (or (eieio--class-p (car object))
(eieio-object-p (car object))))
- (concat "(" (mapconcat #'eieio-edebug-prin1-to-string object " ")
+ (concat "(" (mapconcat
+ (lambda (x) (eieio-edebug-prin1-to-string print-function x))
+ object " ")
")"))
(t (funcall print-function object noescape))))
@@ -888,7 +889,7 @@ variable PRINT-FUNCTION. Optional argument NOESCAPE is passed to
;;; Start of automatically extracted autoloads.
-;;;### (autoloads nil "eieio-custom" "eieio-custom.el" "2b4c57cf907e879e8bbc88d8f0e2de4c")
+;;;### (autoloads nil "eieio-custom" "eieio-custom.el" "a3f314e2a27e52444df4597c6ae51458")
;;; Generated autoloads from eieio-custom.el
(autoload 'customize-object "eieio-custom" "\