diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2014-12-22 15:13:02 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2014-12-22 15:13:02 -0500 |
commit | bcebc831bb9c1fd82b4693e6a091a4cf591dc3ec (patch) | |
tree | 1fe8d3bf282f4cc676396aec6f4b02424a8b01f0 /lisp/emacs-lisp/eieio-opt.el | |
parent | b11d8924b565bd96939537b10a70bb3c26532bed (diff) | |
download | emacs-bcebc831bb9c1fd82b4693e6a091a4cf591dc3ec.tar.gz emacs-bcebc831bb9c1fd82b4693e6a091a4cf591dc3ec.tar.bz2 emacs-bcebc831bb9c1fd82b4693e6a091a4cf591dc3ec.zip |
* lisp/emacs-lisp/eieio*.el: Use hashtables rather than obarrays
* lisp/emacs-lisp/eieio-core.el (class): Rename field symbol-obarray to
symbol-hashtable. It contains a hashtable instead of an obarray.
(generic-p): Use symbol property `eieio-method-hashtable' instead of
`eieio-method-obarray'.
(generic-primary-only-p, generic-primary-only-one-p):
Slight optimization.
(eieio-defclass-autoload-map): Use a hashtable instead of an obarray.
(eieio-defclass-autoload, eieio-defclass): Adjust/simplify accordingly.
(eieio-class-un-autoload): Use autoload-do-load.
(eieio-defclass): Use dolist, cl-pushnew, cl-callf.
Use new cl-deftype-satisfies. Adjust to use of hashtables.
Don't hardcode the value of eieio--object-num-slots.
(eieio-defgeneric-form-primary-only-one): Remove `doc-string' arg.
Use a closure rather than a backquoted lambda.
(eieio--defmethod): Adjust call accordingly. Set doc-string via the
function-documentation property.
(eieio-slot-originating-class-p, eieio-slot-name-index)
(eieiomt--optimizing-hashtable, eieiomt-install, eieiomt-add)
(eieio-generic-form): Adjust to use of hashtables.
(eieiomt--sym-optimize): Rename from eieiomt-sym-optimize; take
additional class argument.
(eieio-generic-call-methodname): Remove, unused.
* lisp/emacs-lisp/eieio-custom.el: Use lexical-binding.
(eieio-object-value-to-abstract): Simplify.
* lisp/emacs-lisp/eieio-datadebug.el: Use lexical-binding.
* lisp/emacs-lisp/eieio-opt.el (eieio-build-class-list): Use cl-mapcan.
(eieio-build-class-alist): Use dolist.
(eieio-all-generic-functions): Adjust to use of hashtables.
* lisp/emacs-lisp/eieio.el (child-of-class-p): Fix case where `class' is
`eieio-default-superclass'.
* test/automated/eieio-test-methodinvoke.el (eieio-test-method-store):
Remove use of eieio-generic-call-methodname.
(eieio-test-method-order-list-3, eieio-test-method-order-list-6)
(eieio-test-method-order-list-7, eieio-test-method-order-list-8):
Adjust the expected result accordingly.
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-slot-type-is-class-p):
Prefer \' to $.
Diffstat (limited to 'lisp/emacs-lisp/eieio-opt.el')
-rw-r--r-- | lisp/emacs-lisp/eieio-opt.el | 88 |
1 files changed, 42 insertions, 46 deletions
diff --git a/lisp/emacs-lisp/eieio-opt.el b/lisp/emacs-lisp/eieio-opt.el index 6f1d01c211f..86a17a17b7a 100644 --- a/lisp/emacs-lisp/eieio-opt.el +++ b/lisp/emacs-lisp/eieio-opt.el @@ -218,11 +218,10 @@ Outputs to the current buffer." (defun eieio-build-class-list (class) "Return a list of all classes that inherit from CLASS." (if (class-p class) - (apply #'append - (mapcar - (lambda (c) - (append (list c) (eieio-build-class-list c))) - (eieio-class-children-fast class))) + (cl-mapcan + (lambda (c) + (append (list c) (eieio-build-class-list c))) + (eieio-class-children-fast class)) (list class))) (defun eieio-build-class-alist (&optional class instantiable-only buildlist) @@ -235,11 +234,12 @@ Optional argument BUILDLIST is more list to attach and is used internally." (sublst (eieio--class-children (class-v cc)))) (unless (assoc (symbol-name cc) buildlist) (when (or (not instantiable-only) (not (class-abstract-p cc))) + ;; FIXME: Completion tables don't need alists, and ede/generic.el needs + ;; the symbols rather than their names. (setq buildlist (cons (cons (symbol-name cc) 1) buildlist)))) - (while sublst + (dolist (elem sublst) (setq buildlist (eieio-build-class-alist - (car sublst) instantiable-only buildlist)) - (setq sublst (cdr sublst))) + elem instantiable-only buildlist))) buildlist)) (defvar eieio-read-class nil @@ -378,51 +378,47 @@ are not abstract." "Return a list of all generic functions. Optional CLASS argument returns only those functions that contain methods for CLASS." - (let ((l nil) tree (cn (if class (symbol-name class) nil))) + (let ((l nil)) (mapatoms (lambda (symbol) - (setq tree (get symbol 'eieio-method-obarray)) - (if tree - (progn - ;; A symbol might be interned for that class in one of - ;; these three slots in the method-obarray. - (if (or (not class) - (fboundp (intern-soft cn (aref tree 0))) - (fboundp (intern-soft cn (aref tree 1))) - (fboundp (intern-soft cn (aref tree 2)))) - (setq l (cons symbol l))))))) + (let ((tree (get symbol 'eieio-method-hashtable))) + (when tree + ;; A symbol might be interned for that class in one of + ;; these three slots in the method-obarray. + (if (or (not class) + (car (gethash class (aref tree 0))) + (car (gethash class (aref tree 1))) + (car (gethash class (aref tree 2)))) + (setq l (cons symbol l))))))) l)) (defun eieio-method-documentation (generic class) "Return a list of the specific documentation of GENERIC for CLASS. If there is not an explicit method for CLASS in GENERIC, or if that function has no documentation, then return nil." - (let ((tree (get generic 'eieio-method-obarray)) - (cn (symbol-name class)) - before primary after) - (if (not tree) - nil + (let ((tree (get generic 'eieio-method-hashtable))) + (when tree ;; A symbol might be interned for that class in one of - ;; these three slots in the method-obarray. - (setq before (intern-soft cn (aref tree 0)) - primary (intern-soft cn (aref tree 1)) - after (intern-soft cn (aref tree 2))) - (if (not (or (fboundp before) - (fboundp primary) - (fboundp after))) - nil - (list (if (fboundp before) - (cons (help-function-arglist before) - (documentation before)) - nil) - (if (fboundp primary) - (cons (help-function-arglist primary) - (documentation primary)) - nil) - (if (fboundp after) - (cons (help-function-arglist after) - (documentation after)) - nil)))))) + ;; these three slots in the method-hashtable. + ;; FIXME: Where do these 0/1/2 come from? Isn't 0 for :static, + ;; 1 for before, and 2 for primary (and 3 for after)? + (let ((before (car (gethash class (aref tree 0)))) + (primary (car (gethash class (aref tree 1)))) + (after (car (gethash class (aref tree 2))))) + (if (not (or before primary after)) + nil + (list (if before + (cons (help-function-arglist before) + (documentation before)) + nil) + (if primary + (cons (help-function-arglist primary) + (documentation primary)) + nil) + (if after + (cons (help-function-arglist after) + (documentation after)) + nil))))))) (defvar eieio-read-generic nil "History of the `eieio-read-generic' prompt.") @@ -627,7 +623,7 @@ Optional argument HISTORYVAR is the variable to use as history." () "Menu part in easymenu format used in speedbar while in `eieio' mode.") -(defun eieio-class-speedbar (dir-or-object depth) +(defun eieio-class-speedbar (_dir-or-object _depth) "Create buttons in speedbar that represents the current project. DIR-OR-OBJECT is the object to expand, or nil, and DEPTH is the current expansion depth." @@ -676,7 +672,7 @@ Argument INDENT is the depth of indentation." (t (error "Ooops... not sure what to do"))) (speedbar-center-buffer-smartly)) -(defun eieio-describe-class-sb (text token indent) +(defun eieio-describe-class-sb (_text token _indent) "Describe the class TEXT in TOKEN. INDENT is the current indentation level." (dframe-with-attached-buffer |