diff options
| author | Stefan Monnier | 2015-01-04 23:11:37 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2015-01-04 23:11:37 -0500 |
| commit | cb4db863192aed6c4d0b28e6490f08d5518ff3e7 (patch) | |
| tree | 5d8e5dd834b7a3991e61631fcfcc209a7a25416e /test | |
| parent | 232823a1f163cebeafdab20ea2eb3f2da9645185 (diff) | |
| download | emacs-cb4db863192aed6c4d0b28e6490f08d5518ff3e7.tar.gz 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 'test')
| -rw-r--r-- | test/ChangeLog | 13 | ||||
| -rw-r--r-- | test/automated/eieio-test-persist.el | 11 | ||||
| -rw-r--r-- | test/automated/eieio-tests.el | 14 |
3 files changed, 31 insertions, 7 deletions
diff --git a/test/ChangeLog b/test/ChangeLog index 53e2c49c9d7..8e3b83efbb0 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2015-01-05 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * automated/eieio-tests.el (eieio-test-04-static-method) | ||
| 4 | (eieio-test-05-static-method-2): Use oref-default to access | ||
| 5 | class slots. | ||
| 6 | (eieio-test-23-inheritance-check): Don't assume that | ||
| 7 | eieio-class-parents returns class names, or that a class can only have | ||
| 8 | a single name. | ||
| 9 | |||
| 10 | * automated/eieio-test-persist.el (eieio--attribute-to-initarg): | ||
| 11 | Move from eieio-core.el. Rename from eieio-attribute-to-initarg. | ||
| 12 | Change arg to be a class object. Update all callers. | ||
| 13 | |||
| 1 | 2014-12-29 Stefan Monnier <monnier@iro.umontreal.ca> | 14 | 2014-12-29 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 15 | ||
| 3 | * automated/eieio-test-methodinvoke.el (eieio-test-method-store): | 16 | * automated/eieio-test-methodinvoke.el (eieio-test-method-store): |
diff --git a/test/automated/eieio-test-persist.el b/test/automated/eieio-test-persist.el index 00de3cf0d7c..5ea7cf25740 100644 --- a/test/automated/eieio-test-persist.el +++ b/test/automated/eieio-test-persist.el | |||
| @@ -32,6 +32,14 @@ | |||
| 32 | (require 'eieio-base) | 32 | (require 'eieio-base) |
| 33 | (require 'ert) | 33 | (require 'ert) |
| 34 | 34 | ||
| 35 | (defun eieio--attribute-to-initarg (class attribute) | ||
| 36 | "In CLASS, convert the ATTRIBUTE into the corresponding init argument tag. | ||
| 37 | This is usually a symbol that starts with `:'." | ||
| 38 | (let ((tuple (rassoc attribute (eieio--class-initarg-tuples class)))) | ||
| 39 | (if tuple | ||
| 40 | (car tuple) | ||
| 41 | nil))) | ||
| 42 | |||
| 35 | (defun persist-test-save-and-compare (original) | 43 | (defun persist-test-save-and-compare (original) |
| 36 | "Compare the object ORIGINAL against the one read fromdisk." | 44 | "Compare the object ORIGINAL against the one read fromdisk." |
| 37 | 45 | ||
| @@ -53,7 +61,8 @@ | |||
| 53 | (let* ((oneslot (car slot-names)) | 61 | (let* ((oneslot (car slot-names)) |
| 54 | (origvalue (eieio-oref original oneslot)) | 62 | (origvalue (eieio-oref original oneslot)) |
| 55 | (fromdiskvalue (eieio-oref fromdisk oneslot)) | 63 | (fromdiskvalue (eieio-oref fromdisk oneslot)) |
| 56 | (initarg-p (eieio-attribute-to-initarg class oneslot)) | 64 | (initarg-p (eieio--attribute-to-initarg |
| 65 | (eieio--class-v class) oneslot)) | ||
| 57 | ) | 66 | ) |
| 58 | 67 | ||
| 59 | (if initarg-p | 68 | (if initarg-p |
diff --git a/test/automated/eieio-tests.el b/test/automated/eieio-tests.el index 91ddfc4fcf3..f3088bacf32 100644 --- a/test/automated/eieio-tests.el +++ b/test/automated/eieio-tests.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; eieio-tests.el -- eieio tests routines | 1 | ;;; eieio-tests.el -- eieio tests routines |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1999-2003, 2005-2010, 2012-2014 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1999-2003, 2005-2010, 2012-2015 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Eric M. Ludlam <zappo@gnu.org> | 5 | ;; Author: Eric M. Ludlam <zappo@gnu.org> |
| 6 | 6 | ||
| @@ -199,9 +199,9 @@ Argument C is the class bound to this static method." | |||
| 199 | (ert-deftest eieio-test-04-static-method () | 199 | (ert-deftest eieio-test-04-static-method () |
| 200 | ;; Call static method on a class and see if it worked | 200 | ;; Call static method on a class and see if it worked |
| 201 | (static-method-class-method static-method-class 'class) | 201 | (static-method-class-method static-method-class 'class) |
| 202 | (should (eq (oref static-method-class some-slot) 'class)) | 202 | (should (eq (oref-default static-method-class some-slot) 'class)) |
| 203 | (static-method-class-method (static-method-class) 'object) | 203 | (static-method-class-method (static-method-class) 'object) |
| 204 | (should (eq (oref static-method-class some-slot) 'object))) | 204 | (should (eq (oref-default static-method-class some-slot) 'object))) |
| 205 | 205 | ||
| 206 | (ert-deftest eieio-test-05-static-method-2 () | 206 | (ert-deftest eieio-test-05-static-method-2 () |
| 207 | (defclass static-method-class-2 (static-method-class) | 207 | (defclass static-method-class-2 (static-method-class) |
| @@ -215,9 +215,9 @@ Argument C is the class bound to this static method." | |||
| 215 | (oset-default c some-slot (intern (concat "moose-" (symbol-name value))))) | 215 | (oset-default c some-slot (intern (concat "moose-" (symbol-name value))))) |
| 216 | 216 | ||
| 217 | (static-method-class-method static-method-class-2 'class) | 217 | (static-method-class-method static-method-class-2 'class) |
| 218 | (should (eq (oref static-method-class-2 some-slot) 'moose-class)) | 218 | (should (eq (oref-default static-method-class-2 some-slot) 'moose-class)) |
| 219 | (static-method-class-method (static-method-class-2) 'object) | 219 | (static-method-class-method (static-method-class-2) 'object) |
| 220 | (should (eq (oref static-method-class-2 some-slot) 'moose-object))) | 220 | (should (eq (oref-default static-method-class-2 some-slot) 'moose-object))) |
| 221 | 221 | ||
| 222 | 222 | ||
| 223 | ;;; Perform method testing | 223 | ;;; Perform method testing |
| @@ -536,7 +536,9 @@ METHOD is the method that was attempting to be called." | |||
| 536 | (should (object-of-class-p eitest-ab class-b)) | 536 | (should (object-of-class-p eitest-ab class-b)) |
| 537 | (should (object-of-class-p eitest-ab class-ab)) | 537 | (should (object-of-class-p eitest-ab class-ab)) |
| 538 | (should (eq (eieio-class-parents class-a) nil)) | 538 | (should (eq (eieio-class-parents class-a) nil)) |
| 539 | (should (equal (eieio-class-parents class-ab) '(class-a class-b))) | 539 | ;; FIXME: eieio-class-parents now returns class objects! |
| 540 | (should (equal (mapcar #'eieio-class-object (eieio-class-parents class-ab)) | ||
| 541 | (mapcar #'eieio-class-object '(class-a class-b)))) | ||
| 540 | (should (same-class-p eitest-a class-a)) | 542 | (should (same-class-p eitest-a class-a)) |
| 541 | (should (class-a-p eitest-a)) | 543 | (should (class-a-p eitest-a)) |
| 542 | (should (not (class-a-p eitest-ab))) | 544 | (should (not (class-a-p eitest-ab))) |