diff options
| author | Stefan Monnier | 2015-02-05 14:43:38 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2015-02-05 14:43:38 -0500 |
| commit | 72229f17ef6609e570e89a1ae86ed80a544e79e8 (patch) | |
| tree | 56380b5cb4282cf0383036a6c7aa7a140825b2d6 | |
| parent | ad5a7c86d017ce8e9ff1312331ef09181be823bf (diff) | |
| download | emacs-72229f17ef6609e570e89a1ae86ed80a544e79e8.tar.gz emacs-72229f17ef6609e570e89a1ae86ed80a544e79e8.zip | |
* lisp/emacs-lisp/eieio*.el: Use (:documentation ...) feature
* lisp/emacs-lisp/eieio-compat.el (eieio--defmethod): Use new
special (:documentation ...) feature.
* lisp/emacs-lisp/eieio-core.el (eieio-make-class-predicate)
(eieio-make-child-predicate): Same.
(eieio-copy-parents-into-subclass): Remove unused arg.
(eieio-defclass-internal): Adjust call accordingly and remove redundant
`pname' var.
(eieio--slot-name-index): Remove unused arg `obj' and adjust all
callers accordingly.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/emacs-lisp/eieio-base.el | 3 | ||||
| -rw-r--r-- | lisp/emacs-lisp/eieio-compat.el | 7 | ||||
| -rw-r--r-- | lisp/emacs-lisp/eieio-core.el | 43 |
4 files changed, 34 insertions, 29 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 51e944c9729..ce70d49a030 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,15 @@ | |||
| 1 | 2015-02-05 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2015-02-05 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * emacs-lisp/eieio-compat.el (eieio--defmethod): Use new | ||
| 4 | special (:documentation ...) feature. | ||
| 5 | * emacs-lisp/eieio-core.el (eieio-make-class-predicate) | ||
| 6 | (eieio-make-child-predicate): Same. | ||
| 7 | (eieio-copy-parents-into-subclass): Remove unused arg. | ||
| 8 | (eieio-defclass-internal): Adjust call accordingly and remove redundant | ||
| 9 | `pname' var. | ||
| 10 | (eieio--slot-name-index): Remove unused arg `obj' and adjust all | ||
| 11 | callers accordingly. | ||
| 12 | |||
| 3 | * emacs-lisp/cconv.el (cconv--convert-function): | 13 | * emacs-lisp/cconv.el (cconv--convert-function): |
| 4 | Add `docstring' argument. | 14 | Add `docstring' argument. |
| 5 | (cconv-convert): Use it to handle the new (:documentation ...) form. | 15 | (cconv-convert): Use it to handle the new (:documentation ...) form. |
diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el index 46585ee76c6..fcf02b92736 100644 --- a/lisp/emacs-lisp/eieio-base.el +++ b/lisp/emacs-lisp/eieio-base.el | |||
| @@ -290,8 +290,7 @@ constructor functions are considered valid. | |||
| 290 | Second, any text properties will be stripped from strings." | 290 | Second, any text properties will be stripped from strings." |
| 291 | (cond ((consp proposed-value) | 291 | (cond ((consp proposed-value) |
| 292 | ;; Lists with something in them need special treatment. | 292 | ;; Lists with something in them need special treatment. |
| 293 | (let ((slot-idx (eieio--slot-name-index class | 293 | (let ((slot-idx (eieio--slot-name-index class slot)) |
| 294 | nil slot)) | ||
| 295 | (type nil) | 294 | (type nil) |
| 296 | (classtype nil)) | 295 | (classtype nil)) |
| 297 | (setq slot-idx (- slot-idx | 296 | (setq slot-idx (- slot-idx |
diff --git a/lisp/emacs-lisp/eieio-compat.el b/lisp/emacs-lisp/eieio-compat.el index fcca99d79d5..7468c040e10 100644 --- a/lisp/emacs-lisp/eieio-compat.el +++ b/lisp/emacs-lisp/eieio-compat.el | |||
| @@ -188,11 +188,10 @@ Summary: | |||
| 188 | (args (help-function-arglist code 'preserve-names)) | 188 | (args (help-function-arglist code 'preserve-names)) |
| 189 | (doc-only (if docstring | 189 | (doc-only (if docstring |
| 190 | (let ((split (help-split-fundoc docstring nil))) | 190 | (let ((split (help-split-fundoc docstring nil))) |
| 191 | (if split (cdr split) docstring)))) | 191 | (if split (cdr split) docstring))))) |
| 192 | (new-docstring (help-add-fundoc-usage doc-only | ||
| 193 | (cons 'cl-cnm args)))) | ||
| 194 | ;; FIXME: ¡Add new-docstring to those closures! | ||
| 195 | (lambda (cnm &rest args) | 192 | (lambda (cnm &rest args) |
| 193 | (:documentation | ||
| 194 | (help-add-fundoc-usage doc-only (cons 'cl-cnm args))) | ||
| 196 | (cl-letf (((symbol-function 'call-next-method) cnm) | 195 | (cl-letf (((symbol-function 'call-next-method) cnm) |
| 197 | ((symbol-function 'next-method-p) | 196 | ((symbol-function 'next-method-p) |
| 198 | (lambda () (cl--generic-isnot-nnm-p cnm)))) | 197 | (lambda () (cl--generic-isnot-nnm-p cnm)))) |
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el index 77d8c01388b..fa8fefa1df0 100644 --- a/lisp/emacs-lisp/eieio-core.el +++ b/lisp/emacs-lisp/eieio-core.el | |||
| @@ -288,16 +288,17 @@ It creates an autoload function for CNAME's constructor." | |||
| 288 | 288 | ||
| 289 | (defun eieio-make-class-predicate (class) | 289 | (defun eieio-make-class-predicate (class) |
| 290 | (lambda (obj) | 290 | (lambda (obj) |
| 291 | ;; (:docstring (format "Test OBJ to see if it's an object of type %S." | 291 | (:documentation |
| 292 | ;; class)) | 292 | (format "Return non-nil if OBJ is an object of type `%S'.\n\n(fn OBJ)" |
| 293 | class)) | ||
| 293 | (and (eieio-object-p obj) | 294 | (and (eieio-object-p obj) |
| 294 | (same-class-p obj class)))) | 295 | (same-class-p obj class)))) |
| 295 | 296 | ||
| 296 | (defun eieio-make-child-predicate (class) | 297 | (defun eieio-make-child-predicate (class) |
| 297 | (lambda (obj) | 298 | (lambda (obj) |
| 298 | ;; (:docstring (format | 299 | (:documentation |
| 299 | ;; "Test OBJ to see if it's an object is a child of type %S." | 300 | (format "Return non-nil if OBJ is an object of type `%S' or a subclass. |
| 300 | ;; class)) | 301 | \n(fn OBJ)" class)) |
| 301 | (and (eieio-object-p obj) | 302 | (and (eieio-object-p obj) |
| 302 | (object-of-class-p obj class)))) | 303 | (object-of-class-p obj class)))) |
| 303 | 304 | ||
| @@ -312,8 +313,7 @@ See `defclass' for more information." | |||
| 312 | (run-hooks 'eieio-hook) | 313 | (run-hooks 'eieio-hook) |
| 313 | (setq eieio-hook nil) | 314 | (setq eieio-hook nil) |
| 314 | 315 | ||
| 315 | (let* ((pname superclasses) | 316 | (let* ((oldc (let ((c (eieio--class-v cname))) (if (eieio--class-p c) c))) |
| 316 | (oldc (let ((c (eieio--class-v cname))) (if (eieio--class-p c) c))) | ||
| 317 | (newc (if (and oldc (not (eieio--class-default-object-cache oldc))) | 317 | (newc (if (and oldc (not (eieio--class-default-object-cache oldc))) |
| 318 | ;; The oldc class is a stub setup by eieio-defclass-autoload. | 318 | ;; The oldc class is a stub setup by eieio-defclass-autoload. |
| 319 | ;; Reuse it instead of creating a new one, so that existing | 319 | ;; Reuse it instead of creating a new one, so that existing |
| @@ -338,9 +338,9 @@ See `defclass' for more information." | |||
| 338 | (setf (eieio--class-children newc) children) | 338 | (setf (eieio--class-children newc) children) |
| 339 | (remhash cname eieio-defclass-autoload-map)))) | 339 | (remhash cname eieio-defclass-autoload-map)))) |
| 340 | 340 | ||
| 341 | (if pname | 341 | (if superclasses |
| 342 | (progn | 342 | (progn |
| 343 | (dolist (p pname) | 343 | (dolist (p superclasses) |
| 344 | (if (not (and p (symbolp p))) | 344 | (if (not (and p (symbolp p))) |
| 345 | (error "Invalid parent class %S" p) | 345 | (error "Invalid parent class %S" p) |
| 346 | (let ((c (eieio--class-v p))) | 346 | (let ((c (eieio--class-v p))) |
| @@ -396,7 +396,7 @@ See `defclass' for more information." | |||
| 396 | 396 | ||
| 397 | ;; Before adding new slots, let's add all the methods and classes | 397 | ;; Before adding new slots, let's add all the methods and classes |
| 398 | ;; in from the parent class. | 398 | ;; in from the parent class. |
| 399 | (eieio-copy-parents-into-subclass newc superclasses) | 399 | (eieio-copy-parents-into-subclass newc) |
| 400 | 400 | ||
| 401 | ;; Store the new class vector definition into the symbol. We need to | 401 | ;; Store the new class vector definition into the symbol. We need to |
| 402 | ;; do this first so that we can call defmethod for the accessor. | 402 | ;; do this first so that we can call defmethod for the accessor. |
| @@ -784,7 +784,7 @@ if default value is nil." | |||
| 784 | )) | 784 | )) |
| 785 | )) | 785 | )) |
| 786 | 786 | ||
| 787 | (defun eieio-copy-parents-into-subclass (newc _parents) | 787 | (defun eieio-copy-parents-into-subclass (newc) |
| 788 | "Copy into NEWC the slots of PARENTS. | 788 | "Copy into NEWC the slots of PARENTS. |
| 789 | Follow the rules of not overwriting early parents when applying to | 789 | Follow the rules of not overwriting early parents when applying to |
| 790 | the new child class." | 790 | the new child class." |
| @@ -911,7 +911,7 @@ Argument FN is the function calling this verifier." | |||
| 911 | (if (eieio--class-p c) (eieio-class-un-autoload obj)) | 911 | (if (eieio--class-p c) (eieio-class-un-autoload obj)) |
| 912 | c)) | 912 | c)) |
| 913 | (t (eieio--object-class-object obj)))) | 913 | (t (eieio--object-class-object obj)))) |
| 914 | (c (eieio--slot-name-index class obj slot))) | 914 | (c (eieio--slot-name-index class slot))) |
| 915 | (if (not c) | 915 | (if (not c) |
| 916 | ;; It might be missing because it is a :class allocated slot. | 916 | ;; It might be missing because it is a :class allocated slot. |
| 917 | ;; Let's check that info out. | 917 | ;; Let's check that info out. |
| @@ -935,7 +935,7 @@ Fills in OBJ's SLOT with its default value." | |||
| 935 | (cl-check-type slot symbol) | 935 | (cl-check-type slot symbol) |
| 936 | (let* ((cl (cond ((symbolp obj) (eieio--class-v obj)) | 936 | (let* ((cl (cond ((symbolp obj) (eieio--class-v obj)) |
| 937 | (t (eieio--object-class-object obj)))) | 937 | (t (eieio--object-class-object obj)))) |
| 938 | (c (eieio--slot-name-index cl obj slot))) | 938 | (c (eieio--slot-name-index cl slot))) |
| 939 | (if (not c) | 939 | (if (not c) |
| 940 | ;; It might be missing because it is a :class allocated slot. | 940 | ;; It might be missing because it is a :class allocated slot. |
| 941 | ;; Let's check that info out. | 941 | ;; Let's check that info out. |
| @@ -973,7 +973,7 @@ Fills in OBJ's SLOT with VALUE." | |||
| 973 | (cl-check-type obj eieio-object) | 973 | (cl-check-type obj eieio-object) |
| 974 | (cl-check-type slot symbol) | 974 | (cl-check-type slot symbol) |
| 975 | (let* ((class (eieio--object-class-object obj)) | 975 | (let* ((class (eieio--object-class-object obj)) |
| 976 | (c (eieio--slot-name-index class obj slot))) | 976 | (c (eieio--slot-name-index class slot))) |
| 977 | (if (not c) | 977 | (if (not c) |
| 978 | ;; It might be missing because it is a :class allocated slot. | 978 | ;; It might be missing because it is a :class allocated slot. |
| 979 | ;; Let's check that info out. | 979 | ;; Let's check that info out. |
| @@ -997,7 +997,7 @@ Fills in the default value in CLASS' in SLOT with VALUE." | |||
| 997 | (setq class (eieio--class-object class)) | 997 | (setq class (eieio--class-object class)) |
| 998 | (cl-check-type class eieio--class) | 998 | (cl-check-type class eieio--class) |
| 999 | (cl-check-type slot symbol) | 999 | (cl-check-type slot symbol) |
| 1000 | (let* ((c (eieio--slot-name-index class nil slot))) | 1000 | (let* ((c (eieio--slot-name-index class slot))) |
| 1001 | (if (not c) | 1001 | (if (not c) |
| 1002 | ;; It might be missing because it is a :class allocated slot. | 1002 | ;; It might be missing because it is a :class allocated slot. |
| 1003 | ;; Let's check that info out. | 1003 | ;; Let's check that info out. |
| @@ -1021,12 +1021,9 @@ Fills in the default value in CLASS' in SLOT with VALUE." | |||
| 1021 | 1021 | ||
| 1022 | ;;; EIEIO internal search functions | 1022 | ;;; EIEIO internal search functions |
| 1023 | ;; | 1023 | ;; |
| 1024 | (defun eieio--slot-name-index (class obj slot) | 1024 | (defun eieio--slot-name-index (class slot) |
| 1025 | "In CLASS for OBJ find the index of the named SLOT. | 1025 | "In CLASS find the index of the named SLOT. |
| 1026 | The slot is a symbol which is installed in CLASS by the `defclass' | 1026 | The slot is a symbol which is installed in CLASS by the `defclass' call. |
| 1027 | call. OBJ can be nil, but if it is an object, and the slot in question | ||
| 1028 | is protected, access will be allowed if OBJ is a child of the currently | ||
| 1029 | scoped class. | ||
| 1030 | If SLOT is the value created with :initarg instead, | 1027 | If SLOT is the value created with :initarg instead, |
| 1031 | reverse-lookup that name, and recurse with the associated slot value." | 1028 | reverse-lookup that name, and recurse with the associated slot value." |
| 1032 | ;; Removed checks to outside this call | 1029 | ;; Removed checks to outside this call |
| @@ -1035,7 +1032,7 @@ reverse-lookup that name, and recurse with the associated slot value." | |||
| 1035 | (if (integerp fsi) | 1032 | (if (integerp fsi) |
| 1036 | (+ (eval-when-compile eieio--object-num-slots) fsi) | 1033 | (+ (eval-when-compile eieio--object-num-slots) fsi) |
| 1037 | (let ((fn (eieio--initarg-to-attribute class slot))) | 1034 | (let ((fn (eieio--initarg-to-attribute class slot))) |
| 1038 | (if fn (eieio--slot-name-index class obj fn) nil))))) | 1035 | (if fn (eieio--slot-name-index class fn) nil))))) |
| 1039 | 1036 | ||
| 1040 | (defun eieio--class-slot-name-index (class slot) | 1037 | (defun eieio--class-slot-name-index (class slot) |
| 1041 | "In CLASS find the index of the named SLOT. | 1038 | "In CLASS find the index of the named SLOT. |
| @@ -1255,7 +1252,7 @@ method invocation orders of the involved classes." | |||
| 1255 | (eieio--class-precedence-list tag)))) | 1252 | (eieio--class-precedence-list tag)))) |
| 1256 | 1253 | ||
| 1257 | 1254 | ||
| 1258 | ;;;### (autoloads nil "eieio-compat" "eieio-compat.el" "b568ffb3c90ed5d0ae673f0051d608ee") | 1255 | ;;;### (autoloads nil "eieio-compat" "eieio-compat.el" "5b04c9a8fff2bd3f3d3ac54aba0f65b7") |
| 1259 | ;;; Generated autoloads from eieio-compat.el | 1256 | ;;; Generated autoloads from eieio-compat.el |
| 1260 | 1257 | ||
| 1261 | (autoload 'eieio--defalias "eieio-compat" "\ | 1258 | (autoload 'eieio--defalias "eieio-compat" "\ |