diff options
| author | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-02-18 21:57:04 -0500 |
|---|---|---|
| committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2013-02-18 21:57:04 -0500 |
| commit | 8ca4f1e02e22f74dc269b01bc4a32e01dd226dae (patch) | |
| tree | 0ed0df06d6430b812797c5ed3f4ff15b425a8dae /lisp/emacs-lisp/eieio-base.el | |
| parent | 6a0fda530d1d76374f72f8dfb2a0a3d50023e64d (diff) | |
| download | emacs-8ca4f1e02e22f74dc269b01bc4a32e01dd226dae.tar.gz | |
Cleanup some of EIEIO's namespace.
* lisp/emacs-lisp/eieio.el (eieio--define-field-accessors): New macro.
Use it to define all the class-* and object-* field accessors (renamed
to eieio--class-* and eieio--object-*). Update all uses.
(eieio--class-num-slots, eieio--object-num-slots): Rename from
class-num-slots and object-num-slots.
(eieio--check-type): New macro.
(eieio-defclass, eieio-oref, eieio-oref-default, same-class-p)
(object-of-class-p, child-of-class-p, object-slots, class-slot-initarg)
(eieio-oset, eieio-oset-default, object-assoc, object-assoc-list)
(object-assoc-list-safe): Use it.
(eieio-defclass): Tighten regexp.
(eieio--defmethod): Use `memq'. Signal an error for unknown method kind.
Remove unreachable code.
(object-class-fast): Declare obsolete.
(eieio-class-name, eieio-object-name, eieio-object-set-name-string)
(eieio-object-class, eieio-object-class-name, eieio-class-parents)
(eieio-class-children, eieio-class-precedence-list, eieio-class-parent):
Rename from class-name, object-name, object-set-name-string,
object-class, object-class-name, class-parents, class-children,
class-precedence-list, class-parent; with obsolete alias.
(class-of, class-direct-superclasses, class-direct-subclasses):
Declare obsolete.
(eieio-defmethod): Use `memq'; remove unreachable code.
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-read):
* lisp/emacs-lisp/eieio-opt.el (eieio-class-button, eieio-describe-generic)
(eieio-browse-tree, eieio-browse): Use eieio--check-type.
Diffstat (limited to 'lisp/emacs-lisp/eieio-base.el')
| -rw-r--r-- | lisp/emacs-lisp/eieio-base.el | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el index 24d680181bb..c8ae3f4bf1a 100644 --- a/lisp/emacs-lisp/eieio-base.el +++ b/lisp/emacs-lisp/eieio-base.el @@ -65,19 +65,19 @@ SLOT-NAME is the offending slot. FN is the function signaling the error." "Clone OBJ, initializing `:parent' to OBJ. All slots are unbound, except those initialized with PARAMS." (let ((nobj (make-vector (length obj) eieio-unbound)) - (nm (aref obj object-name)) + (nm (eieio--object-name obj)) (passname (and params (stringp (car params)))) (num 1)) (aset nobj 0 'object) - (aset nobj object-class (aref obj object-class)) + (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)))) - (aset nobj object-name (concat nm "-" (int-to-string num)))) - (aset nobj object-name (car params))) + (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))) (oset nobj parent-instance obj) @@ -232,8 +232,7 @@ for CLASS. Optional ALLOW-SUBCLASS says that it is ok for being pedantic." (unless class (message "Unsafe call to `eieio-persistent-read'.")) - (when (and class (not (class-p class))) - (signal 'wrong-type-argument (list 'class-p class))) + (when class (eieio--check-type class-p class)) (let ((ret nil) (buffstr nil)) (unwind-protect @@ -308,7 +307,7 @@ Second, any text properties will be stripped from strings." (type nil) (classtype nil)) (setq slot-idx (- slot-idx 3)) - (setq type (aref (aref (class-v class) class-public-type) + (setq type (aref (eieio--class-public-type (class-v class)) slot-idx)) (setq classtype (eieio-persistent-slot-type-is-class-p @@ -482,14 +481,13 @@ 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 (or (eq slot-name 'object-name) - (eq slot-name :object-name)) + (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))) - (object-set-name-string obj new-value)) - (t (object-name-string obj))) + (eieio-object-set-name-string obj new-value)) + (t (eieio-object-name-string obj))) (call-next-method))) (provide 'eieio-base) |
