diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2015-01-17 09:41:51 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2015-01-17 09:41:51 -0500 |
commit | 4610ce96c1a6d8574f85d8bd543fb8e1e02d6718 (patch) | |
tree | e45ced4c0cc372da452d81b4c73b693cbbcb2018 /lisp/emacs-lisp | |
parent | d80fed096336339d9e4e1137cdfcf236db38886a (diff) | |
download | emacs-4610ce96c1a6d8574f85d8bd543fb8e1e02d6718.tar.gz |
* lisp/emacs-lisp/eieio.el: Improve `constructor' compatibility.
Fixes: debbugs:19620
(eieio-constructor): Handle obsolete object name argument here...
(defclass): ...instead of in the constructor here.
* test/automated/eieio-tests.el
(eieio-test-37-obsolete-name-in-constructor): New test.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/eieio-core.el | 1 | ||||
-rw-r--r-- | lisp/emacs-lisp/eieio.el | 15 |
2 files changed, 9 insertions, 7 deletions
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el index 0747d97960c..0e589d6cf6e 100644 --- a/lisp/emacs-lisp/eieio-core.el +++ b/lisp/emacs-lisp/eieio-core.el @@ -212,6 +212,7 @@ CLASS is a symbol." ;FIXME: Is it a vector or a symbol? (defmacro class-constructor (class) "Return the symbol representing the constructor of CLASS." (declare (debug t)) + ;; FIXME: How/when would this not be a costly identity function? `(eieio--class-symbol (eieio--class-v ,class))) (defmacro eieio--class-option-assoc (list option) diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index 392316ccd75..e7a606ffd8c 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el @@ -276,12 +276,6 @@ and reference them using the function `class-option'." `(defun ,name (&rest slots) ,(format "Create a new object with name NAME of class type %S." name) - (if (and slots - (let ((x (car slots))) - (or (stringp x) (null x)))) - (funcall (if eieio-backward-compatibility #'ignore #'message) - "Obsolete name %S passed to %S constructor" - (pop slots) ',name)) (apply #'eieio-constructor ',name slots)))))) @@ -656,7 +650,14 @@ SLOTS are the initialization slots used by `shared-initialize'. This static method is called when an object is constructed. It allocates the vector used to represent an EIEIO object, and then calls `shared-initialize' on that object." - (let* ((new-object (copy-sequence (eieio--class-default-object-cache (eieio--class-v class))))) + (let* ((new-object (copy-sequence (eieio--class-default-object-cache + (eieio--class-v class))))) + (if (and slots + (let ((x (car slots))) + (or (stringp x) (null x)))) + (funcall (if eieio-backward-compatibility #'ignore #'message) + "Obsolete name %S passed to %S constructor" + (pop slots) class)) ;; Call the initialize method on the new object with the slots ;; that were passed down to us. (initialize-instance new-object slots) |