Commit 4610ce96 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

* 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.
parent d80fed09
2015-01-17 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/eieio.el (eieio-constructor): Handle obsolete object name
argument here (bug#19620)...
(defclass): ...instead of in the constructor here.
2015-01-16 Jorgen Schaefer <contact@jorgenschaefer.de> 2015-01-16 Jorgen Schaefer <contact@jorgenschaefer.de>
   
* emacs-lisp/package.el (package-archive-priorities): Specify * emacs-lisp/package.el (package-archive-priorities):
correct type. Specify correct type.
   
2015-01-17 Ulrich Müller <ulm@gentoo.org> 2015-01-17 Ulrich Müller <ulm@gentoo.org>
   
...@@ -71,8 +77,8 @@ ...@@ -71,8 +77,8 @@
   
2015-01-16 Artur Malabarba <bruce.connor.am@gmail.com> 2015-01-16 Artur Malabarba <bruce.connor.am@gmail.com>
   
* emacs-lisp/package.el (package--read-pkg-desc): New * emacs-lisp/package.el (package--read-pkg-desc):
function. Read a `define-package' form in current buffer. Return New function. Read a `define-package' form in current buffer. Return
the pkg-desc, with desc-kind set to KIND. the pkg-desc, with desc-kind set to KIND.
(package-dir-info): New function. Find package information for a (package-dir-info): New function. Find package information for a
directory. The return result is a `package-desc'. directory. The return result is a `package-desc'.
...@@ -80,8 +86,8 @@ ...@@ -80,8 +86,8 @@
(package-install-file): Install packages from directory. (package-install-file): Install packages from directory.
(package-desc-suffix) (package-desc-suffix)
(package-install-from-archive) (package-install-from-archive)
* emacs-lisp/package-x.el (package-upload-buffer-internal): Ensure * emacs-lisp/package-x.el (package-upload-buffer-internal):
all remaining instances of `package-desc-kind' handle the 'dir Ensure all remaining instances of `package-desc-kind' handle the 'dir
value. value.
   
2015-01-16 Jorgen Schaefer <contact@jorgenschaefer.de> 2015-01-16 Jorgen Schaefer <contact@jorgenschaefer.de>
......
...@@ -212,6 +212,7 @@ CLASS is a symbol." ;FIXME: Is it a vector or a symbol? ...@@ -212,6 +212,7 @@ CLASS is a symbol." ;FIXME: Is it a vector or a symbol?
(defmacro class-constructor (class) (defmacro class-constructor (class)
"Return the symbol representing the constructor of CLASS." "Return the symbol representing the constructor of CLASS."
(declare (debug t)) (declare (debug t))
;; FIXME: How/when would this not be a costly identity function?
`(eieio--class-symbol (eieio--class-v ,class))) `(eieio--class-symbol (eieio--class-v ,class)))
(defmacro eieio--class-option-assoc (list option) (defmacro eieio--class-option-assoc (list option)
......
...@@ -276,12 +276,6 @@ and reference them using the function `class-option'." ...@@ -276,12 +276,6 @@ and reference them using the function `class-option'."
`(defun ,name (&rest slots) `(defun ,name (&rest slots)
,(format "Create a new object with name NAME of class type %S." ,(format "Create a new object with name NAME of class type %S."
name) 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)))))) (apply #'eieio-constructor ',name slots))))))
...@@ -656,7 +650,14 @@ SLOTS are the initialization slots used by `shared-initialize'. ...@@ -656,7 +650,14 @@ SLOTS are the initialization slots used by `shared-initialize'.
This static method is called when an object is constructed. This static method is called when an object is constructed.
It allocates the vector used to represent an EIEIO object, and then It allocates the vector used to represent an EIEIO object, and then
calls `shared-initialize' on that object." 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 ;; Call the initialize method on the new object with the slots
;; that were passed down to us. ;; that were passed down to us.
(initialize-instance new-object slots) (initialize-instance new-object slots)
......
2015-01-17 Stefan Monnier <monnier@iro.umontreal.ca>
* automated/eieio-tests.el
(eieio-test-37-obsolete-name-in-constructor): New test.
2015-01-17 Stefan Monnier <monnier@iro.umontreal.ca> 2015-01-17 Stefan Monnier <monnier@iro.umontreal.ca>
* automated/eieio-tests.el (eieio-test-25-slot-tests) * automated/eieio-tests.el (eieio-test-25-slot-tests)
......
...@@ -892,6 +892,15 @@ Subclasses to override slot attributes.") ...@@ -892,6 +892,15 @@ Subclasses to override slot attributes.")
(should (= (length (eieio-build-class-alist 'opt-test1 nil)) 2)) (should (= (length (eieio-build-class-alist 'opt-test1 nil)) 2))
(should (= (length (eieio-build-class-alist 'opt-test1 t)) 1))) (should (= (length (eieio-build-class-alist 'opt-test1 t)) 1)))
(defclass eieio--testing ()
())
(defmethod constructor :static ((_x eieio--testing) newname &rest _args)
(list newname 2))
(ert-deftest eieio-test-37-obsolete-name-in-constructor ()
(should (equal (eieio--testing "toto") '("toto" 2))))
(provide 'eieio-tests) (provide 'eieio-tests)
;;; eieio-tests.el ends here ;;; eieio-tests.el ends here
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment