+2014-12-23 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * emacs-lisp/eieio.el (make-instance): Simplify by not adding an object
+ name argument.
+ (eieio-object-name): Use eieio-object-name-string.
+ (eieio--object-names): New const.
+ (eieio-object-name-string, eieio-object-set-name-string): Re-implement
+ using a hashtable rather than a built-in slot.
+ (eieio-constructor): Rename from `constructor'. Remove `newname' arg.
+ (clone): Don't mess with the object's "name".
+
+ * emacs-lisp/eieio-custom.el (eieio-widget-test): Remove dummy arg.
+ (eieio-object-value-get): Use eieio-object-set-name-string.
+
+ * emacs-lisp/eieio-core.el (eieio--defalias): Follow aliases.
+ (eieio--object): Remove `name' field.
+ (eieio-defclass): Adjust to new convention where constructors don't
+ take an "object name" any more.
+ (eieio--defgeneric-init-form, eieio--defmethod): Follow aliases.
+ (eieio-validate-slot-value, eieio-oset-default)
+ (eieio-slot-name-index): Don't hardcode eieio--object-num-slots.
+ (eieio-generic-call-primary-only): Simplify.
+
+ * emacs-lisp/eieio-base.el (clone) <eieio-instance-inheritor>:
+ Use call-next-method.
+ (eieio-constructor): Rename from `constructor'.
+ (eieio-persistent-convert-list-to-object): Drop objname.
+ (eieio-persistent-validate/fix-slot-value): Don't hardcode
+ eieio--object-num-slots.
+ (eieio-named): Use a normal slot.
+ (slot-missing) <eieio-named>: Remove.
+ (eieio-object-name-string, eieio-object-set-name-string, clone)
+ <eieio-named>: New methods.
+
2014-12-22 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/eieio-core.el (eieio--class-v): Rename from class-v.
;; Throw the regular signal.
(call-next-method)))
-(defmethod clone ((obj eieio-instance-inheritor) &rest params)
+(defmethod clone ((obj eieio-instance-inheritor) &rest _params)
"Clone OBJ, initializing `:parent' to OBJ.
All slots are unbound, except those initialized with PARAMS."
- (let ((nobj (make-vector (length obj) eieio-unbound))
- (nm (eieio--object-name obj))
- (passname (and params (stringp (car params))))
- (num 1))
- (aset nobj 0 'object)
- (setf (eieio--object-class nobj) (eieio--object-class obj))
- ;; The following was copied from the default clone.
- (if (not passname)
- (save-match-data
- (if (string-match "-\\([0-9]+\\)" nm)
- (setq num (1+ (string-to-number (match-string 1 nm)))
- nm (substring nm 0 (match-beginning 0))))
- (setf (eieio--object-name nobj) (concat nm "-" (int-to-string num))))
- (setf (eieio--object-name nobj) (car params)))
- ;; Now initialize from params.
- (if params (shared-initialize nobj (if passname (cdr params) params)))
+ (let ((nobj (call-next-method)))
(oset nobj parent-instance obj)
nobj))
A singleton is a class which will only ever have one instance."
:abstract t)
-(defmethod constructor :STATIC ((class eieio-singleton) _name &rest _slots)
+(defmethod eieio-constructor :STATIC ((class eieio-singleton) &rest _slots)
"Constructor for singleton CLASS.
NAME and SLOTS initialize the new object.
This constructor guarantees that no matter how many you request,
Note: This function recurses when a slot of :type of some object is
identified, and needing more object creation."
(let ((objclass (nth 0 inputlist))
- (objname (nth 1 inputlist))
+ ;; (objname (nth 1 inputlist))
(slots (nthcdr 2 inputlist))
(createslots nil))
(setq slots (cdr (cdr slots))))
- (apply 'make-instance objclass objname (nreverse createslots))
+ (apply #'make-instance objclass (nreverse createslots))
;;(eval inputlist)
))
(let ((slot-idx (eieio-slot-name-index class nil slot))
(type nil)
(classtype nil))
- (setq slot-idx (- slot-idx 3))
+ (setq slot-idx (- slot-idx
+ (eval-when-compile eieio--object-num-slots)))
(setq type (aref (eieio--class-public-type (eieio--class-v class))
slot-idx))
\f
;;; Named object
-;;
-;; Named objects use the objects `name' as a slot, and that slot
-;; is accessed with the `object-name' symbol.
(defclass eieio-named ()
- ()
- "Object with a name.
-Name storage already occurs in an object. This object provides get/set
-access to it."
+ ((object-name :initarg :object-name :initform nil))
+ "Object with a name."
:abstract t)
-(defmethod slot-missing ((obj eieio-named)
- slot-name operation &optional new-value)
- "Called when a non-existent slot is accessed.
-For variable `eieio-named', provide an imaginary `object-name' slot.
-Argument OBJ is the named object.
-Argument SLOT-NAME is the slot that was attempted to be accessed.
-OPERATION is the type of access, such as `oref' or `oset'.
-NEW-VALUE is the value that was being set into SLOT if OPERATION were
-a set type."
- (if (memq slot-name '(object-name :object-name))
- (cond ((eq operation 'oset)
- (if (not (stringp new-value))
- (signal 'invalid-slot-type
- (list obj slot-name 'string new-value)))
- (eieio-object-set-name-string obj new-value))
- (t (eieio-object-name-string obj)))
- (call-next-method)))
+(defmethod eieio-object-name-string ((obj eieio-named))
+ "Return a string which is OBJ's name."
+ (or (slot-value obj 'object-name)
+ (symbol-name (eieio-object-class obj))))
+
+(defmethod eieio-object-set-name-string ((obj eieio-named) name)
+ "Set the string which is OBJ's NAME."
+ (eieio--check-type stringp name)
+ (eieio-oset obj 'object-name name))
+
+(defmethod clone ((obj eieio-named) &rest params)
+ "Clone OBJ, initializing `:parent' to OBJ.
+All slots are unbound, except those initialized with PARAMS."
+ (let* ((newname (and (stringp (car params)) (pop params)))
+ (nobj (apply #'call-next-method obj params))
+ (nm (slot-value obj 'object-name)))
+ (eieio-oset obj 'object-name
+ (or newname
+ (save-match-data
+ (if (and nm (string-match "-\\([0-9]+\\)" nm))
+ (let ((num (1+ (string-to-number
+ (match-string 1 nm)))))
+ (concat (substring nm 0 (match-beginning 0))
+ "-" (int-to-string num)))
+ (concat nm "-1")))))
+ nobj))
(provide 'eieio-base)
"Like `defalias', but with less side-effects.
More specifically, it has no side-effects at all when the new function
definition is the same (`eq') as the old one."
+ (while (and (fboundp name) (symbolp (symbol-function name)))
+ ;; Follow aliases, so methods applied to obsolete aliases still work.
+ (setq name (symbol-function name)))
(unless (and (fboundp name)
(eq (symbol-function name) body))
(defalias name body)))
(eieio--define-field-accessors object
(-unused-0 ;;Constant slot, set to `object'.
- (class "class struct defining OBJ")
- name)) ;FIXME: Get rid of this field!
+ (class "class struct defining OBJ")))
;; FIXME: The constants below should have an `eieio-' prefix added!!
(defconst eieio--method-static 0 "Index into :static tag on a method.")
;; Create the test function
(let ((csym (intern (concat (symbol-name cname) "-p"))))
(fset csym
- (list 'lambda (list 'obj)
- (format "Test OBJ to see if it an object of type %s" cname)
- (list 'and '(eieio-object-p obj)
- (list 'same-class-p 'obj cname)))))
+ `(lambda (obj)
+ ,(format "Test OBJ to see if it an object of type %s" cname)
+ (and (eieio-object-p obj)
+ (same-class-p obj ',cname)))))
;; Make sure the method invocation order is a valid value.
(let ((io (class-option-assoc options :method-invocation-order)))
"Test OBJ to see if it an object is a child of type %s"
cname)
(and (eieio-object-p obj)
- (object-of-class-p obj ,cname))))
+ (object-of-class-p obj ',cname))))
;; When using typep, (typep OBJ 'myclass) returns t for objects which
;; are subclasses of myclass. For our predicates, however, it is
;; Non-abstract classes need a constructor.
(fset cname
- `(lambda (newname &rest slots)
+ `(lambda (&rest slots)
,(format "Create a new object with name NAME of class type %s" cname)
- (apply #'constructor ,cname newname slots)))
+ (if (and slots
+ (let ((x (car slots)))
+ (or (stringp x) (null x))))
+ (message "Obsolete name %S passed to %S constructor"
+ (pop slots) ',cname))
+ (apply #'eieio-constructor ',cname slots)))
)
;; Set up a specialized doc string.
nil)))
(aset cache 0 'object)
(setf (eieio--object-class cache) cname)
- (setf (eieio--object-name cache) 'default-cache-object)
(let ((eieio-skip-typecheck t))
;; All type-checking has been done to our satisfaction
;; before this call. Don't waste our time in this call..
(defun eieio--defgeneric-init-form (method doc-string)
"Form to use for the initial definition of a generic."
+ (while (and (fboundp method) (symbolp (symbol-function method)))
+ ;; Follow aliases, so methods applied to obsolete aliases still work.
+ (setq method (symbol-function method)))
+
(cond
((or (not (fboundp method))
(eq 'autoload (car-safe (symbol-function method))))
;; Primary key.
;; (t eieio--method-primary)
(t (error "Unknown method kind %S" kind)))))
+
+ (while (and (fboundp method) (symbolp (symbol-function method)))
+ ;; Follow aliases, so methods applied to obsolete aliases still work.
+ (setq method (symbol-function method)))
+
;; Make sure there is a generic (when called from defclass).
(eieio--defalias
method (eieio--defgeneric-init-form
(if eieio-skip-typecheck
nil
;; Trim off object IDX junk added in for the object index.
- (setq slot-idx (- slot-idx 3))
+ (setq slot-idx (- slot-idx (eval-when-compile eieio--object-num-slots)))
(let ((st (aref (eieio--class-public-type (eieio--class-v class)) slot-idx)))
(if (not (eieio-perform-slot-validation st value))
(signal 'invalid-slot-type (list class slot st value))))))
;;(signal 'invalid-slot-name (list (class-name cl) slot))
)
(eieio-barf-if-slot-unbound
- (let ((val (nth (- c 3) (eieio--class-public-d (eieio--class-v cl)))))
+ (let ((val (nth (- c (eval-when-compile eieio--object-num-slots))
+ (eieio--class-public-d (eieio--class-v cl)))))
(eieio-default-eval-maybe val))
obj cl 'oref-default))))
(signal 'invalid-slot-name (list (eieio-class-name class) slot)))
(eieio-validate-slot-value class c value slot)
;; Set this into the storage for defaults.
- (setcar (nthcdr (- c 3) (eieio--class-public-d (eieio--class-v class)))
+ (setcar (nthcdr (- c (eval-when-compile eieio--object-num-slots))
+ (eieio--class-public-d (eieio--class-v class)))
value)
;; Take the value, and put it into our cache object.
(eieio-oset (eieio--class-default-object-cache (eieio--class-v class))
(if (integerp fsi)
(cond
((not (cdr fsym))
- (+ 3 fsi))
+ (+ (eval-when-compile eieio--object-num-slots) fsi))
((and (eq (cdr fsym) 'protected)
(eieio--scoped-class)
(or (child-of-class-p class (eieio--scoped-class))
(and (eieio-object-p obj)
(child-of-class-p class (eieio--object-class obj)))))
- (+ 3 fsi))
+ (+ (eval-when-compile eieio--object-num-slots) fsi))
((and (eq (cdr fsym) 'private)
(or (and (eieio--scoped-class)
(eieio-slot-originating-class-p (eieio--scoped-class) slot))
eieio-initializing-object))
- (+ 3 fsi))
+ (+ (eval-when-compile eieio--object-num-slots) fsi))
(t nil))
(let ((fn (eieio-initarg-to-attribute class slot)))
(if fn (eieio-slot-name-index class obj fn) nil)))))
(setq mclass (eieio--object-class firstarg)))
((not firstarg)
(error "Method %s called on nil" method))
- ((not (eieio-object-p firstarg))
- (error "Primary-only method %s called on something not an object" method))
(t
- (error "EIEIO Error: Improperly classified method %s as primary only"
- method)
- ))
+ (error "Primary-only method %s called on something not an object" method)))
;; Make sure the class is a valid class
;; mclass can be nil (meaning a generic for should be used.
;; mclass cannot have a value that is not a class, however.
:documentation "A number of thingies."))
"A class for testing the widget on.")
-(defcustom eieio-widget-test (eieio-widget-test-class "Foo")
+(defcustom eieio-widget-test (eieio-widget-test-class)
"Test variable for editing an object."
:type 'object
:group 'eieio)
fgroup (cdr fgroup)
fcust (cdr fcust)))
;; Set any name updates on it.
- (if name (setf (eieio--object-name obj) name))
+ (if name (eieio-object-set-name-string obj name))
;; This is the same object we had before.
obj))
`make-instance' in CLOS doesn't use names the way Emacs does, so the
class is used as the name slot instead when INITARGS doesn't start with
a string."
- (if (and (car initargs) (stringp (car initargs)))
- (apply (class-constructor class) initargs)
- (apply (class-constructor class)
- (cond ((symbolp class) (symbol-name class))
- (t (format "%S" class)))
- initargs)))
+ (apply (class-constructor class) initargs))
\f
;;; CLOS methods and generics
If EXTRA, include that in the string returned to represent the symbol."
(eieio--check-type eieio-object-p obj)
(format "#<%s %s%s>" (symbol-name (eieio--object-class obj))
- (eieio--object-name obj) (or extra "")))
+ (eieio-object-name-string obj) (or extra "")))
(define-obsolete-function-alias 'object-name #'eieio-object-name "24.4")
-(defun eieio-object-name-string (obj) "Return a string which is OBJ's name."
- (eieio--check-type eieio-object-p obj)
- (eieio--object-name obj))
+(defconst eieio--object-names (make-hash-table :test #'eq :weakness 'key))
+
+;; In the past, every EIEIO object had a `name' field, so we had the two method
+;; below "for free". Since this field is very rarely used, we got rid of it
+;; and instead we keep it in a weak hash-tables, for those very rare objects
+;; that use it.
+(defmethod eieio-object-name-string (obj)
+ "Return a string which is OBJ's name."
+ (declare (obsolete eieio-named "25.1"))
+ (or (gethash obj eieio--object-names)
+ (symbol-name (eieio-object-class obj))))
(define-obsolete-function-alias
'object-name-string #'eieio-object-name-string "24.4")
-(defun eieio-object-set-name-string (obj name)
+(defmethod eieio-object-set-name-string (obj name)
"Set the string which is OBJ's NAME."
- (eieio--check-type eieio-object-p obj)
+ (declare (obsolete eieio-named "25.1"))
(eieio--check-type stringp name)
- (setf (eieio--object-name obj) name))
+ (setf (gethash obj eieio--object-names) name))
(define-obsolete-function-alias
'object-set-name-string 'eieio-object-set-name-string "24.4")
(defalias 'standard-class 'eieio-default-superclass)
-(defgeneric constructor (class newname &rest slots)
+(defgeneric eieio-constructor (class &rest slots)
"Default constructor for CLASS `eieio-default-superclass'.")
-(defmethod constructor :static
- ((class eieio-default-superclass) newname &rest slots)
+(define-obsolete-function-alias 'constructor #'eieio-constructor "25.1")
+
+(defmethod eieio-constructor :static
+ ((class eieio-default-superclass) &rest slots)
"Default constructor for CLASS `eieio-default-superclass'.
-NEWNAME is the name to be given to the constructed object.
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)))))
- ;; Update the name for the newly created object.
- (setf (eieio--object-name new-object) newname)
;; Call the initialize method on the new object with the slots
;; that were passed down to us.
(initialize-instance new-object slots)
(defmethod clone ((obj eieio-default-superclass) &rest params)
"Make a copy of OBJ, and then apply PARAMS."
- (let ((nobj (copy-sequence obj))
- (nm (eieio--object-name obj))
- (passname (and params (stringp (car params))))
- (num 1))
- (if params (shared-initialize nobj (if passname (cdr params) params)))
- (if (not passname)
- (save-match-data
- (if (string-match "-\\([0-9]+\\)" nm)
- (setq num (1+ (string-to-number (match-string 1 nm)))
- nm (substring nm 0 (match-beginning 0))))
- (setf (eieio--object-name nobj) (concat nm "-" (int-to-string num))))
- (setf (eieio--object-name nobj) (car params)))
+ (let ((nobj (copy-sequence obj)))
+ (if (stringp (car params))
+ (message "Obsolete name %S passed to clone" (pop params)))
+ (if params (shared-initialize nobj params))
nobj))
(defgeneric destructor (this &rest params)
\f
;;; Start of automatically extracted autoloads.
\f
-;;;### (autoloads nil "eieio-custom" "eieio-custom.el" "6413249ec10091eb7094238637b40e2c")
+;;;### (autoloads nil "eieio-custom" "eieio-custom.el" "3a6fffe3af331fe960f967d0da99e8e9")
;;; Generated autoloads from eieio-custom.el
(autoload 'customize-object "eieio-custom" "\
;;;***
\f
-;;;### (autoloads nil "eieio-opt" "eieio-opt.el" "6f114a48de40212413d2776eedc3ec14")
+;;;### (autoloads nil "eieio-opt" "eieio-opt.el" "2ff7d98da3f84c6af5c873ffb781930e")
;;; Generated autoloads from eieio-opt.el
(autoload 'eieio-browse "eieio-opt" "\
(defclass C-base2 () ())
(defclass C (C-base1 C-base2) ())
+;; Just use the obsolete name once, to make sure it also works.
(defmethod constructor :STATIC ((p C-base1) &rest args)
(eieio-test-method-store)
(if (next-method-p) (call-next-method))
)
-(defmethod constructor :STATIC ((p C-base2) &rest args)
+(defmethod eieio-constructor :STATIC ((p C-base2) &rest args)
(eieio-test-method-store)
(if (next-method-p) (call-next-method))
)
-(defmethod constructor :STATIC ((p C) &rest args)
+(defmethod eieio-constructor :STATIC ((p C) &rest args)
(eieio-test-method-store)
(call-next-method)
)
(defclass persistent-with-objs-slot-subs (eieio-persistent)
((pnp :initarg :pnp
- :type (or null persist-not-persistent-child)
+ :type (or null persist-not-persistent)
:initform nil))
"Class for testing the saving of slots with objects in them.")
(ert-deftest eieio-test-02-abstract-class ()
;; Abstract classes cannot be instantiated, so this should throw an
;; error
- (should-error (abstract-class "Test")))
+ (should-error (abstract-class)))
(defgeneric generic1 () "First generic function")
"Method generic1 that can take a non-object."
not-an-object)
- (let ((ans-obj (generic1 (class-a "test")))
+ (let ((ans-obj (generic1 (class-a)))
(ans-num (generic1 666)))
(should (eq ans-obj 'monkey))
(should (eq ans-num 666))))
;; Call static method on a class and see if it worked
(static-method-class-method static-method-class 'class)
(should (eq (oref static-method-class some-slot) 'class))
- (static-method-class-method (static-method-class "test") 'object)
+ (static-method-class-method (static-method-class) 'object)
(should (eq (oref static-method-class some-slot) 'object)))
(ert-deftest eieio-test-05-static-method-2 ()
(static-method-class-method static-method-class-2 'class)
(should (eq (oref static-method-class-2 some-slot) 'moose-class))
- (static-method-class-method (static-method-class-2 "test") 'object)
+ (static-method-class-method (static-method-class-2) 'object)
(should (eq (oref static-method-class-2 some-slot) 'moose-object)))
\f
(defvar eitest-b nil)
(ert-deftest eieio-test-06-allocate-objects ()
;; allocate an object to use
- (should (setq eitest-ab (class-ab "abby")))
- (should (setq eitest-a (class-a "aye")))
- (should (setq eitest-b (class-b "fooby"))))
+ (should (setq eitest-ab (class-ab)))
+ (should (setq eitest-a (class-a)))
+ (should (setq eitest-b (class-b))))
(ert-deftest eieio-test-07-make-instance ()
(should (make-instance 'class-ab))
(should (make-instance 'class-a :water 'cho))
- (should (make-instance 'class-b "a name")))
+ (should (make-instance 'class-b)))
(defmethod class-cn ((a class-a))
"Try calling `call-next-method' when there isn't one.
(call-next-method)
(oset a test-tag 1))
- (let ((ca (class-a "class act")))
+ (let ((ca (class-a)))
(should-not (/= (oref ca test-tag) 2))))
\f
(t (call-next-method))))
(ert-deftest eieio-test-17-virtual-slot ()
- (setq eitest-vsca (virtual-slot-class "eitest-vsca" :base-value 1))
+ (setq eitest-vsca (virtual-slot-class :base-value 1))
;; Check slot values
(should (= (oref eitest-vsca :base-value) 1))
(should (= (oref eitest-vsca :derived-value) 2))
;; should also be possible to initialize instance using virtual slot
- (setq eitest-vscb (virtual-slot-class "eitest-vscb" :derived-value 5))
+ (setq eitest-vscb (virtual-slot-class :derived-value 5))
(should (= (oref eitest-vscb :base-value) 4))
(should (= (oref eitest-vscb :derived-value) 5)))
;; After setting 'water to 'moose, make sure a new object has
;; the right stuff.
(oset-default (eieio-object-class eitest-a) water 'penguin)
- (should (eq (oref (class-a "foo") water) 'penguin))
+ (should (eq (oref (class-a) water) 'penguin))
;; Revert the above
(defmethod slot-unbound ((a class-a) &rest foo)
;; We should not be able to set a string here
(should-error (oset eitest-ab water "a string, not a symbol") :type 'invalid-slot-type)
(should-error (oset eitest-ab classslot "a string, not a symbol") :type 'invalid-slot-type)
- (should-error (class-a "broken-type-a" :water "a string not a symbol") :type 'invalid-slot-type))
+ (should-error (class-a :water "a string not a symbol") :type 'invalid-slot-type))
(ert-deftest eieio-test-20-class-allocated-slots ()
;; Test out class allocated slots
(defvar eitest-aa nil)
- (setq eitest-aa (class-a "another"))
+ (setq eitest-aa (class-a))
;; Make sure class slots do not track between objects
(let ((newval 'moose))
(ert-deftest eieio-test-21-eval-at-construction-time ()
;; initforms that need to be evalled at construction time.
(setq eieio-test-permuting-value 2)
- (setq eitest-pvinit (inittest "permuteme"))
+ (setq eitest-pvinit (inittest))
(should (eq (oref eitest-pvinit staticval) 1))
(should (eq (oref eitest-pvinit symval) 'eieio-test-permuting-value))
"Test class that will be a calculated value.")
(defclass eitest-superior nil
- ((sub :initform (eitest-subordinate "test")
+ ((sub :initform (eitest-subordinate)
:type eitest-subordinate))
"A class with an initform that creates a class.")
- (should (setq eitest-tests (eitest-superior "test")))
+ (should (setq eitest-tests (eitest-superior)))
(should-error
(eval
(should (not (class-a-child-p "foo"))))
(ert-deftest eieio-test-24-object-predicates ()
- (let ((listooa (list (class-ab "ab") (class-a "a")))
- (listoob (list (class-ab "ab") (class-b "b"))))
+ (let ((listooa (list (class-ab) (class-a)))
+ (listoob (list (class-ab) (class-b))))
(should (class-a-list-p listooa))
(should (class-b-list-p listoob))
(should-not (class-b-list-p listooa))
(defvar eitest-t1 nil)
(ert-deftest eieio-test-25-slot-tests ()
- (setq eitest-t1 (class-c "C1"))
+ (setq eitest-t1 (class-c))
;; Slot initialization
(should (eq (oref eitest-t1 slot-1) 'moose))
(should (eq (oref eitest-t1 :moose) 'moose))
;; Check private slot accessor
(should (string= (get-slot-2 eitest-t1) "penguin"))
;; Pass string instead of symbol
- (should-error (class-c "C2" :moose "not a symbol") :type 'invalid-slot-type)
+ (should-error (class-c :moose "not a symbol") :type 'invalid-slot-type)
(should (eq (get-slot-3 eitest-t1) 'emu))
(should (eq (get-slot-3 class-c) 'emu))
;; Check setf
(defvar eitest-t2 nil)
(ert-deftest eieio-test-26-default-inheritance ()
;; See previous test, nor for subclass
- (setq eitest-t2 (class-subc "subc"))
+ (setq eitest-t2 (class-subc))
(should (eq (oref eitest-t2 slot-1) 'moose))
(should (eq (oref eitest-t2 :moose) 'moose))
(should (string= (get-slot-2 eitest-t2) "linux"))
(should-error (oref eitest-t2 slot-2) :type 'invalid-slot-name)
(should (string= (get-slot-2 eitest-t2) "linux"))
- (should-error (class-subc "C2" :moose "not a symbol") :type 'invalid-slot-type))
+ (should-error (class-subc :moose "not a symbol") :type 'invalid-slot-type))
;;(ert-deftest eieio-test-27-inherited-new-value ()
;;; HACK ALERT: The new value of a class slot is inherited by the
(defvar eitest-p1 nil)
(defvar eitest-p2 nil)
(ert-deftest eieio-test-28-slot-protection ()
- (setq eitest-p1 (prot-1 ""))
- (setq eitest-p2 (prot-2 ""))
+ (setq eitest-p1 (prot-1))
+ (setq eitest-p2 (prot-2))
;; Access public slots
(oref eitest-p1 slot-1)
(oref eitest-p2 slot-1)
"This class should throw an error.")))
;; Initform should override instance allocation
- (let ((obj (slotattr-ok "moose")))
+ (let ((obj (slotattr-ok)))
(should (eq (oref obj initform) 'no-init))))
(defclass slotattr-class-base ()
(ert-deftest eieio-test-32-test-clone-boring-objects ()
;; A simple make instance with EIEIO extension
- (should (setq eitest-CLONETEST1 (make-instance 'class-a "a")))
+ (should (setq eitest-CLONETEST1 (make-instance 'class-a)))
(should (setq eitest-CLONETEST2 (clone eitest-CLONETEST1)))
;; CLOS form of make-instance
(ert-deftest eieio-test-33-instance-tracker ()
(let (IT-list IT1)
- (should (setq IT1 (IT "trackme")))
+ (should (setq IT1 (IT)))
;; The instance tracker must find this
(should (eieio-instance-tracker-find 'die 'slot1 'IT-list))
;; Test deletion
"A Singleton test object.")
(ert-deftest eieio-test-34-singletons ()
- (let ((obj1 (SINGLE "Moose"))
- (obj2 (SINGLE "Cow")))
+ (let ((obj1 (SINGLE))
+ (obj2 (SINGLE)))
(should (eieio-object-p obj1))
(should (eieio-object-p obj2))
(should (eq obj1 obj2))
(ert-deftest eieio-test-35-named-object ()
(let (N)
- (should (setq N (NAMED "Foo")))
+ (should (setq N (NAMED :object-name "Foo")))
(should (string= "Foo" (oref N object-name)))
(should-error (oref N missing-slot) :type 'invalid-slot-name)
(oset N object-name "NewName")