2014-10-17 05:09:24 +00:00
|
|
|
|
;;; eieio.el --- Enhanced Implementation of Emacs Interpreted Objects -*- lexical-binding:t -*-
|
2011-11-13 07:48:23 +00:00
|
|
|
|
;;; or maybe Eric's Implementation of Emacs Interpreted Objects
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
2015-01-05 04:11:37 +00:00
|
|
|
|
;; Copyright (C) 1995-1996, 1998-2015 Free Software Foundation, Inc.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
2009-10-01 02:50:00 +00:00
|
|
|
|
;; Author: Eric M. Ludlam <zappo@gnu.org>
|
2013-01-31 19:58:56 +00:00
|
|
|
|
;; Version: 1.4
|
2009-09-28 00:49:54 +00:00
|
|
|
|
;; Keywords: OO, lisp
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
;;
|
|
|
|
|
;; EIEIO is a series of Lisp routines which implements a subset of
|
|
|
|
|
;; CLOS, the Common Lisp Object System. In addition, EIEIO also adds
|
|
|
|
|
;; a few new features which help it integrate more strongly with the
|
|
|
|
|
;; Emacs running environment.
|
|
|
|
|
;;
|
|
|
|
|
;; See eieio.texi for complete documentation on using this package.
|
2010-09-19 04:23:57 +00:00
|
|
|
|
;;
|
|
|
|
|
;; Note: the implementation of the c3 algorithm is based on:
|
|
|
|
|
;; Kim Barrett et al.: A Monotonic Superclass Linearization for Dylan
|
|
|
|
|
;; Retrieved from:
|
|
|
|
|
;; http://192.220.96.201/dylan/linearization-oopsla96.html
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
;; There is funny stuff going on with typep and deftype. This
|
|
|
|
|
;; is the only way I seem to be able to make this stuff load properly.
|
|
|
|
|
|
|
|
|
|
;; @TODO - fix :initform to be a form, not a quoted value
|
|
|
|
|
;; @TODO - Prefix non-clos functions with `eieio-'.
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2013-01-31 19:58:56 +00:00
|
|
|
|
(defvar eieio-version "1.4"
|
2009-09-28 00:49:54 +00:00
|
|
|
|
"Current version of EIEIO.")
|
|
|
|
|
|
|
|
|
|
(defun eieio-version ()
|
|
|
|
|
"Display the current version of EIEIO."
|
|
|
|
|
(interactive)
|
|
|
|
|
(message eieio-version))
|
|
|
|
|
|
Merge from CEDET upstream (8564).
* lisp/emacs-lisp:
* emacs-lisp/eieio.el (eieio--defalias, eieio-hook)
(eieio-error-unsupported-class-tags, eieio-skip-typecheck)
(eieio-optimize-primary-methods-flag, eieio-initializing-object)
(eieio-unbound, eieio-default-superclass)
(eieio--define-field-accessors, method-static, method-before)
(method-primary, method-after, method-num-lists)
(method-generic-before, method-generic-primary)
(method-generic-after, method-num-slots)
(eieio-specialized-key-to-generic-key)
(eieio--check-type, class-v, class-p)
(eieio-class-name, define-obsolete-function-alias)
(eieio-class-parents-fast, eieio-class-children-fast)
(same-class-fast-p, class-constructor, generic-p)
(generic-primary-only-p, generic-primary-only-one-p)
(class-option-assoc, class-option, eieio-object-p)
(class-abstract-p, class-method-invocation-order)
(eieio-defclass-autoload-map, eieio-defclass-autoload)
(eieio-class-un-autoload, eieio-defclass)
(eieio-eval-default-p, eieio-perform-slot-validation-for-default)
(eieio-add-new-slot, eieio-copy-parents-into-subclass)
(eieio--defgeneric-init-form, eieio-defgeneric-form)
(eieio-defgeneric-reset-generic-form)
(eieio-defgeneric-form-primary-only)
(eieio-defgeneric-reset-generic-form-primary-only)
(eieio-defgeneric-form-primary-only-one)
(eieio-defgeneric-reset-generic-form-primary-only-one)
(eieio-unbind-method-implementations)
(eieio--defmethod, eieio--typep)
(eieio-perform-slot-validation, eieio-validate-slot-value)
(eieio-validate-class-slot-value, eieio-barf-if-slot-unbound)
(eieio-oref, eieio-oref-default, eieio-default-eval-maybe)
(eieio-oset, eieio-oset-default, eieio-slot-originating-class-p)
(eieio-slot-name-index, eieio-class-slot-name-index)
(eieio-set-defaults, eieio-initarg-to-attribute)
(eieio-attribute-to-initarg, eieio-c3-candidate)
(eieio-c3-merge-lists, eieio-class-precedence-c3)
(eieio-class-precedence-dfs, eieio-class-precedence-bfs)
(eieio-class-precedence-list, eieio-generic-call-methodname)
(eieio-generic-call-arglst, eieio-generic-call-key)
(eieio-generic-call-next-method-list)
(eieio-pre-method-execution-functions, eieio-generic-call)
(eieio-generic-call-primary-only, eieiomt-method-list)
(eieiomt-optimizing-obarray, eieiomt-install)
(eieiomt-add, eieiomt-next, eieiomt-sym-optimize)
(eieio-generic-form, eieio-defmethod, make-obsolete)
(eieio-defgeneric, make-obsolete): Moved to eieio-core.el
(defclass): Remove `eval-and-compile' from macro.
(call-next-method, shared-initialize): Instead of using
`scoped-class' variable, use new eieio--scoped-class, and
eieio--with-scoped-class.
(initialize-instance): Rename local variable 'scoped-class' to
'this-class' to remove ambiguitity from old global.
* emacs-lisp/eieio-core.el: New file. Derived from key parts of
eieio.el.
(eieio--scoped-class-stack): New variable
(eieio--scoped-class): New fcn
(eieio--with-scoped-class): New scoping macro.
(eieio-defclass): Use pushnew instead of add-to-list.
(eieio-defgeneric-form-primary-only-one, eieio-oset-default)
(eieio-slot-name-index, eieio-set-defaults, eieio-generic-call)
(eieio-generic-call-primary-only, eieiomt-add): Instead of using
`scoped-class' variable, use new eieio--scoped-class, and
eieio--with-scoped-class.
* emacs-lisp/eieio-base.el (cl-lib): Require during compile.
* admin/grammars:
* grammars/srecode-template.wy (variable): Accept a single number
as a variable value. Allows the 'priority' to be set to a number.
(wisent-srecode-template-lexer): Move number up so it can be
created.
* etc/srecode:
* srecode/c.srt (header_guard): Add :c parameter so it works
standalone
* lisp/cedet:
* semantic/edit.el (semantic-change-function): Use
`save-match-data' around running hooks.
* semantic/decorate/mode.el
(semantic-decorate-style-predicate-default)
(semantic-decorate-style-highlighter-default): New.
(semantic-decoration-mode): Do not require
`semantic/decorate/include' anymore.
(semantic-toggle-decoration-style): Error if an unknown decoration
style is toggled.
(define-semantic-decoration-style): Add new :load option. When
:load is specified, add autoload tokens for the definition
functions so that code is loaded when the mode is used.
(semantic-decoration-on-includes): New autoload definition for
highlighting includes.
* semantic/bovine/c.el (semantic-lex-c-ifdef): Allow some misc
characters to appear after the tested variable.
* semantic/ede-grammar.el (project-compile-target): Calculate full
src name via ede-expand-filename instead of the crutch of the
current buffer. Enables this target to compile in batch mode.
* semantic/idle.el
(semantic-idle-symbol-maybe-highlight): Wrap highlighting of
remote symbol with `save-excursion'.
(semantic-idle-scheduler-work-parse-neighboring-files): Instead of
using directory-files on each found mode pattern, collect all the
patterns for the current mode, and then for each file, see if it
matches any of them. If it does, parse the file. (Patch
inspiration from Tomasz Gajewski.)
* semantic/ctxt.el (semantic-ctxt-end-of-symbol): New.
(semantic-ctxt-current-symbol-default): New.
* semantic/bovine/el.el (semantic-default-elisp-setup): Add
autoload cookie. Explain existence.
(footer): Add local variable for loaddefs.
* semantic/db.el (semanticdb-file-table-object): Add new filter,
only checking for regular files too.
* semantic/wisent/python.el
(semantic-format-tag-abbreviate): New override. Cuts back on size
of code tags.
* srecode/compile.el (srecode-compile-templates): Fix warning
punctuation. Remove status messages to clean up testing output
* ede/base.el (ede-project-placeholder-cache-file): Update doc to
mention 'nil' value.
(ede-save-cache): Disable cache save if file is nil.
* ede.el (ede-initialize-state-current-buffer): Flush deleted
projects.
(global-ede-mode): Always append our find-file-hook to the end.
(ede-flush-deleted-projects): New command.
* ede/cpp-root.el (ede-preprocessor-map): Protect against init
problems.
* ede/proj.el (ede-proj-target): Added a new "custom" option for
custom symbols representing a compiler or linker instead of
restricting things to only the predefined compilers and linkers.
* semantic.el (semantic-mode-map): To avoid showing showing
Development menu twice, only disable menu item if menu-bar is
actually enabled, otherwise the popup 'global menu' might display
a disabled Development menu.
* semantic/complete.el
(semantic-displayor-show-request): Fix which slot in obj is set to
the max tags.
2013-06-02 13:33:09 +00:00
|
|
|
|
(require 'eieio-core)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Defining a new class
|
|
|
|
|
;;
|
|
|
|
|
(defmacro defclass (name superclass slots &rest options-and-doc)
|
|
|
|
|
"Define NAME as a new class derived from SUPERCLASS with SLOTS.
|
|
|
|
|
OPTIONS-AND-DOC is used as the class' options and base documentation.
|
|
|
|
|
SUPERCLASS is a list of superclasses to inherit from, with SLOTS
|
|
|
|
|
being the slots residing in that class definition. NOTE: Currently
|
|
|
|
|
only one slot may exist in SUPERCLASS as multiple inheritance is not
|
|
|
|
|
yet supported. Supported tags are:
|
|
|
|
|
|
2009-10-05 15:32:08 +00:00
|
|
|
|
:initform - Initializing form.
|
|
|
|
|
:initarg - Tag used during initialization.
|
|
|
|
|
:accessor - Tag used to create a function to access this slot.
|
|
|
|
|
:allocation - Specify where the value is stored.
|
|
|
|
|
Defaults to `:instance', but could also be `:class'.
|
|
|
|
|
:writer - A function symbol which will `write' an object's slot.
|
|
|
|
|
:reader - A function symbol which will `read' an object.
|
|
|
|
|
:type - The type of data allowed in this slot (see `typep').
|
2009-09-28 00:49:54 +00:00
|
|
|
|
:documentation
|
|
|
|
|
- A string documenting use of this slot.
|
|
|
|
|
|
|
|
|
|
The following are extensions on CLOS:
|
|
|
|
|
:protection - Specify protection for this slot.
|
2009-10-05 15:32:08 +00:00
|
|
|
|
Defaults to `:public'. Also use `:protected', or `:private'.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
:custom - When customizing an object, the custom :type. Public only.
|
|
|
|
|
:label - A text string label used for a slot when customizing.
|
|
|
|
|
:group - Name of a customization group this slot belongs in.
|
|
|
|
|
:printer - A function to call to print the value of a slot.
|
|
|
|
|
See `eieio-override-prin1' as an example.
|
|
|
|
|
|
|
|
|
|
A class can also have optional options. These options happen in place
|
2009-10-05 15:32:08 +00:00
|
|
|
|
of documentation (including a :documentation tag), in addition to
|
2009-09-28 00:49:54 +00:00
|
|
|
|
documentation, or not at all. Supported options are:
|
|
|
|
|
|
|
|
|
|
:documentation - The doc-string used for this class.
|
|
|
|
|
|
|
|
|
|
Options added to EIEIO:
|
|
|
|
|
|
2009-10-05 15:32:08 +00:00
|
|
|
|
:allow-nil-initform - Non-nil to skip typechecking of null initforms.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
:custom-groups - List of custom group names. Organizes slots into
|
|
|
|
|
reasonable groups for customizations.
|
|
|
|
|
:abstract - Non-nil to prevent instances of this class.
|
|
|
|
|
If a string, use as an error string if someone does
|
|
|
|
|
try to make an instance.
|
|
|
|
|
:method-invocation-order
|
2009-10-01 02:50:00 +00:00
|
|
|
|
- Control the method invocation order if there is
|
2009-09-28 00:49:54 +00:00
|
|
|
|
multiple inheritance. Valid values are:
|
|
|
|
|
:breadth-first - The default.
|
|
|
|
|
:depth-first
|
|
|
|
|
|
|
|
|
|
Options in CLOS not supported in EIEIO:
|
|
|
|
|
|
|
|
|
|
:metaclass - Class to use in place of `standard-class'
|
|
|
|
|
:default-initargs - Initargs to use when initializing new objects of
|
|
|
|
|
this class.
|
|
|
|
|
|
2009-10-05 15:32:08 +00:00
|
|
|
|
Due to the way class options are set up, you can add any tags you wish,
|
|
|
|
|
and reference them using the function `class-option'."
|
2014-10-17 05:09:24 +00:00
|
|
|
|
(declare (doc-string 4))
|
2013-06-19 20:27:49 +00:00
|
|
|
|
;; This is eval-and-compile only to silence spurious compiler warnings
|
|
|
|
|
;; about functions and variables not known to be defined.
|
|
|
|
|
;; When eieio-defclass code is merged here and this becomes
|
|
|
|
|
;; transparent to the compiler, the eval-and-compile can be removed.
|
|
|
|
|
`(eval-and-compile
|
|
|
|
|
(eieio-defclass ',name ',superclass ',slots ',options-and-doc)))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; CLOS style implementation of object creators.
|
|
|
|
|
;;
|
|
|
|
|
(defun make-instance (class &rest initargs)
|
|
|
|
|
"Make a new instance of CLASS based on INITARGS.
|
|
|
|
|
CLASS is a class symbol. For example:
|
|
|
|
|
|
|
|
|
|
(make-instance 'foo)
|
|
|
|
|
|
|
|
|
|
INITARGS is a property list with keywords based on the :initarg
|
|
|
|
|
for each slot. For example:
|
|
|
|
|
|
|
|
|
|
(make-instance 'foo :slot1 value1 :slotN valueN)
|
|
|
|
|
|
2009-10-01 02:50:00 +00:00
|
|
|
|
Compatibility note:
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
If the first element of INITARGS is a string, it is used as the
|
|
|
|
|
name of the class.
|
|
|
|
|
|
|
|
|
|
In EIEIO, the class' constructor requires a name for use when printing.
|
|
|
|
|
`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."
|
2014-12-23 03:05:46 +00:00
|
|
|
|
(apply (class-constructor class) initargs))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; CLOS methods and generics
|
|
|
|
|
;;
|
2014-10-17 05:09:24 +00:00
|
|
|
|
(defmacro defgeneric (method _args &optional doc-string)
|
2009-10-05 15:32:08 +00:00
|
|
|
|
"Create a generic function METHOD.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
DOC-STRING is the base documentation for this class. A generic
|
2009-10-05 15:32:08 +00:00
|
|
|
|
function has no body, as its purpose is to decide which method body
|
|
|
|
|
is appropriate to use. Uses `defmethod' to create methods, and calls
|
|
|
|
|
`defgeneric' for you. With this implementation the ARGS are
|
2009-09-28 00:49:54 +00:00
|
|
|
|
currently ignored. You can use `defgeneric' to apply specialized
|
|
|
|
|
top level documentation to a method."
|
2014-10-17 05:09:24 +00:00
|
|
|
|
(declare (doc-string 3))
|
2011-05-07 04:03:49 +00:00
|
|
|
|
`(eieio--defalias ',method
|
|
|
|
|
(eieio--defgeneric-init-form ',method ,doc-string)))
|
|
|
|
|
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(defmacro defmethod (method &rest args)
|
|
|
|
|
"Create a new METHOD through `defgeneric' with ARGS.
|
|
|
|
|
|
2009-10-05 15:32:08 +00:00
|
|
|
|
The optional second argument KEY is a specifier that
|
2009-09-28 00:49:54 +00:00
|
|
|
|
modifies how the method is called, including:
|
2009-10-05 15:32:08 +00:00
|
|
|
|
:before - Method will be called before the :primary
|
|
|
|
|
:primary - The default if not specified
|
|
|
|
|
:after - Method will be called after the :primary
|
|
|
|
|
:static - First arg could be an object or class
|
2009-09-28 00:49:54 +00:00
|
|
|
|
The next argument is the ARGLIST. The ARGLIST specifies the arguments
|
|
|
|
|
to the method as with `defun'. The first argument can have a type
|
|
|
|
|
specifier, such as:
|
|
|
|
|
((VARNAME CLASS) ARG2 ...)
|
|
|
|
|
where VARNAME is the name of the local variable for the method being
|
|
|
|
|
created. The CLASS is a class symbol for a class made with `defclass'.
|
|
|
|
|
A DOCSTRING comes after the ARGLIST, and is optional.
|
|
|
|
|
All the rest of the args are the BODY of the method. A method will
|
|
|
|
|
return the value of the last form in the BODY.
|
|
|
|
|
|
|
|
|
|
Summary:
|
|
|
|
|
|
|
|
|
|
(defmethod mymethod [:before | :primary | :after | :static]
|
|
|
|
|
((typearg class-name) arg2 &optional opt &rest rest)
|
|
|
|
|
\"doc-string\"
|
|
|
|
|
body)"
|
2014-12-22 20:46:16 +00:00
|
|
|
|
(declare (doc-string 3)
|
|
|
|
|
(debug
|
|
|
|
|
(&define ; this means we are defining something
|
|
|
|
|
[&or name ("setf" :name setf name)]
|
|
|
|
|
;; ^^ This is the methods symbol
|
|
|
|
|
[ &optional symbolp ] ; this is key :before etc
|
|
|
|
|
list ; arguments
|
|
|
|
|
[ &optional stringp ] ; documentation string
|
|
|
|
|
def-body ; part to be debugged
|
|
|
|
|
)))
|
2011-05-05 03:42:09 +00:00
|
|
|
|
(let* ((key (if (keywordp (car args)) (pop args)))
|
Get rid of funvec.
* lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode): Handle new form of
`byte-constant'.
(byte-compile-close-variables, displaying-byte-compile-warnings):
Add edebug spec.
(byte-compile-toplevel-file-form): New fun, split out of
byte-compile-file-form.
(byte-compile-from-buffer): Use it to avoid applying cconv
multiple times.
(byte-compile): Only strip `function' if it's present.
(byte-compile-lambda): Add `reserved-csts' argument.
Use new lexenv arg of byte-compile-top-level.
(byte-compile-reserved-constants): New var.
(byte-compile-constants-vector): Obey it.
(byte-compile-constants-vector): Handle new `byte-constant' form.
(byte-compile-top-level): Add args `lexenv' and `reserved-csts'.
(byte-compile-form): Don't check callargs here.
(byte-compile-normal-call): Do it here instead.
(byte-compile-push-unknown-constant)
(byte-compile-resolve-unknown-constant): Remove, unused.
(byte-compile-make-closure): Use `make-byte-code' rather than `curry',
putting the environment into the "constant" pool.
(byte-compile-get-closed-var): Use special byte-constant.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker): Handle new
intermediate special form `internal-make-vector'.
(byte-optimize-lapcode): Handle new form of `byte-constant'.
* lisp/help-fns.el (describe-function-1): Don't handle funvecs.
* lisp/emacs-lisp/macroexp.el (macroexpand-all-1): Only convert quote to
function if the content is a lambda expression, not if it's a closure.
* emacs-lisp/eieio-come.el: Remove.
* lisp/emacs-lisp/eieio.el: Don't require eieio-comp.
(defmethod): Do a bit more work to find the body and wrap it into
a function before passing it to eieio-defmethod.
(eieio-defmethod): New arg `code' for it.
* lisp/emacs-lisp/debug.el (debugger-setup-buffer): Don't hide things in
debugger backtrace.
* lisp/emacs-lisp/cl-extra.el (cl-macroexpand-all): Use backquotes, and be
more careful when quoting a function value.
* lisp/emacs-lisp/cconv.el (cconv-freevars): Accept defvar/defconst.
(cconv-closure-convert-rec): Catch stray `internal-make-closure'.
* lisp/Makefile.in (COMPILE_FIRST): Compile pcase and cconv early.
* src/eval.c (Qcurry): Remove.
(funcall_funvec): Remove.
(funcall_lambda): Move new byte-code handling to reduce impact.
Treat all args as lexical in the case of lexbind.
(Fcurry): Remove.
* src/data.c (Qfunction_vector): Remove.
(Ffunvecp): Remove.
* src/lread.c (read1): Revert to calling make_byte_code here.
(read_vector): Don't call make_byte_code any more.
* src/lisp.h (enum pvec_type): Rename back to PVEC_COMPILED.
(XSETCOMPILED): Rename back from XSETFUNVEC.
(FUNVEC_SIZE): Remove.
(FUNVEC_COMPILED_TAG_P, FUNVEC_COMPILED_P): Remove.
(COMPILEDP): Rename back from FUNVECP.
* src/fns.c (Felt): Remove unexplained FUNVEC check.
* src/doc.c (Fdocumentation): Don't handle funvec.
* src/alloc.c (make_funvec, Ffunvec): Remove.
* doc/lispref/vol2.texi (Top):
* doc/lispref/vol1.texi (Top):
* doc/lispref/objects.texi (Programming Types, Funvec Type, Type Predicates):
* doc/lispref/functions.texi (Functions, What Is a Function, FunctionCurrying):
* doc/lispref/elisp.texi (Top): Remove mentions of funvec and curry.
2011-02-25 03:27:45 +00:00
|
|
|
|
(params (car args))
|
|
|
|
|
(arg1 (car params))
|
2011-05-08 02:33:28 +00:00
|
|
|
|
(fargs (if (consp arg1)
|
2011-05-07 04:03:49 +00:00
|
|
|
|
(cons (car arg1) (cdr params))
|
|
|
|
|
params))
|
|
|
|
|
(class (if (consp arg1) (nth 1 arg1)))
|
2011-05-08 02:33:28 +00:00
|
|
|
|
(code `(lambda ,fargs ,@(cdr args))))
|
2011-05-07 04:03:49 +00:00
|
|
|
|
`(progn
|
|
|
|
|
;; Make sure there is a generic and the byte-compiler sees it.
|
|
|
|
|
(defgeneric ,method ,args
|
|
|
|
|
,(or (documentation code)
|
|
|
|
|
(format "Generically created method `%s'." method)))
|
2011-05-16 19:49:28 +00:00
|
|
|
|
(eieio--defmethod ',method ',key ',class #',code))))
|
2011-05-05 03:42:09 +00:00
|
|
|
|
|
2009-09-28 00:49:54 +00:00
|
|
|
|
;;; Get/Set slots in an object.
|
|
|
|
|
;;
|
|
|
|
|
(defmacro oref (obj slot)
|
|
|
|
|
"Retrieve the value stored in OBJ in the slot named by SLOT.
|
|
|
|
|
Slot is the name of the slot when created by `defclass' or the label
|
|
|
|
|
created by the :initarg tag."
|
2014-12-22 20:46:16 +00:00
|
|
|
|
(declare (debug (form symbolp)))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
`(eieio-oref ,obj (quote ,slot)))
|
|
|
|
|
|
|
|
|
|
(defalias 'slot-value 'eieio-oref)
|
|
|
|
|
(defalias 'set-slot-value 'eieio-oset)
|
|
|
|
|
|
|
|
|
|
(defmacro oref-default (obj slot)
|
2009-10-05 15:32:08 +00:00
|
|
|
|
"Get the default value of OBJ (maybe a class) for SLOT.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
The default value is the value installed in a class with the :initform
|
|
|
|
|
tag. SLOT can be the slot name, or the tag specified by the :initarg
|
|
|
|
|
tag in the `defclass' call."
|
2014-12-22 20:46:16 +00:00
|
|
|
|
(declare (debug (form symbolp)))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
`(eieio-oref-default ,obj (quote ,slot)))
|
|
|
|
|
|
|
|
|
|
;;; Handy CLOS macros
|
|
|
|
|
;;
|
|
|
|
|
(defmacro with-slots (spec-list object &rest body)
|
|
|
|
|
"Bind SPEC-LIST lexically to slot values in OBJECT, and execute BODY.
|
|
|
|
|
This establishes a lexical environment for referring to the slots in
|
|
|
|
|
the instance named by the given slot-names as though they were
|
|
|
|
|
variables. Within such a context the value of the slot can be
|
|
|
|
|
specified by using its slot name, as if it were a lexically bound
|
|
|
|
|
variable. Both setf and setq can be used to set the value of the
|
|
|
|
|
slot.
|
|
|
|
|
|
|
|
|
|
SPEC-LIST is of a form similar to `let'. For example:
|
|
|
|
|
|
|
|
|
|
((VAR1 SLOT1)
|
|
|
|
|
SLOT2
|
|
|
|
|
SLOTN
|
|
|
|
|
(VARN+1 SLOTN+1))
|
|
|
|
|
|
|
|
|
|
Where each VAR is the local variable given to the associated
|
2009-10-05 15:32:08 +00:00
|
|
|
|
SLOT. A slot specified without a variable name is given a
|
2009-09-28 00:49:54 +00:00
|
|
|
|
variable name of the same name as the slot."
|
2014-12-22 20:46:16 +00:00
|
|
|
|
(declare (indent 2) (debug (sexp sexp def-body)))
|
2014-10-17 05:09:24 +00:00
|
|
|
|
(require 'cl-lib)
|
2014-03-12 15:02:45 +00:00
|
|
|
|
;; Transform the spec-list into a cl-symbol-macrolet spec-list.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(let ((mappings (mapcar (lambda (entry)
|
|
|
|
|
(let ((var (if (listp entry) (car entry) entry))
|
|
|
|
|
(slot (if (listp entry) (cadr entry) entry)))
|
|
|
|
|
(list var `(slot-value ,object ',slot))))
|
|
|
|
|
spec-list)))
|
2014-03-12 15:02:45 +00:00
|
|
|
|
(append (list 'cl-symbol-macrolet mappings)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
body)))
|
|
|
|
|
|
|
|
|
|
;;; Simple generators, and query functions. None of these would do
|
|
|
|
|
;; well embedded into an object.
|
|
|
|
|
;;
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(define-obsolete-function-alias
|
2014-12-29 17:11:09 +00:00
|
|
|
|
'object-class-fast #'eieio--object-class-name "24.4")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(defun eieio-object-name (obj &optional extra)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
"Return a Lisp like symbol string for object OBJ.
|
|
|
|
|
If EXTRA, include that in the string returned to represent the symbol."
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(eieio--check-type eieio-object-p obj)
|
2014-12-29 17:11:09 +00:00
|
|
|
|
(format "#<%s %s%s>" (eieio--object-class-name obj)
|
2014-12-23 03:05:46 +00:00
|
|
|
|
(eieio-object-name-string obj) (or extra "")))
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(define-obsolete-function-alias 'object-name #'eieio-object-name "24.4")
|
|
|
|
|
|
2014-12-23 03:05:46 +00:00
|
|
|
|
(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))))
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(define-obsolete-function-alias
|
|
|
|
|
'object-name-string #'eieio-object-name-string "24.4")
|
|
|
|
|
|
2014-12-23 03:05:46 +00:00
|
|
|
|
(defmethod eieio-object-set-name-string (obj name)
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
"Set the string which is OBJ's NAME."
|
2014-12-23 03:05:46 +00:00
|
|
|
|
(declare (obsolete eieio-named "25.1"))
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(eieio--check-type stringp name)
|
2014-12-23 03:05:46 +00:00
|
|
|
|
(setf (gethash obj eieio--object-names) name))
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(define-obsolete-function-alias
|
|
|
|
|
'object-set-name-string 'eieio-object-set-name-string "24.4")
|
|
|
|
|
|
2014-12-29 17:11:09 +00:00
|
|
|
|
(defun eieio-object-class (obj)
|
|
|
|
|
"Return the class struct defining OBJ."
|
|
|
|
|
;; FIXME: We say we return a "struct" but we return a symbol instead!
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(eieio--check-type eieio-object-p obj)
|
2014-12-29 17:11:09 +00:00
|
|
|
|
(eieio--object-class-name obj))
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(define-obsolete-function-alias 'object-class #'eieio-object-class "24.4")
|
|
|
|
|
;; CLOS name, maybe?
|
|
|
|
|
(define-obsolete-function-alias 'class-of #'eieio-object-class "24.4")
|
|
|
|
|
|
|
|
|
|
(defun eieio-object-class-name (obj)
|
|
|
|
|
"Return a Lisp like symbol name for OBJ's class."
|
|
|
|
|
(eieio--check-type eieio-object-p obj)
|
2014-12-29 17:11:09 +00:00
|
|
|
|
(eieio-class-name (eieio--object-class-name obj)))
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(define-obsolete-function-alias
|
|
|
|
|
'object-class-name 'eieio-object-class-name "24.4")
|
|
|
|
|
|
|
|
|
|
(defun eieio-class-parents (class)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
"Return parent classes to CLASS. (overload of variable).
|
|
|
|
|
|
|
|
|
|
The CLOS function `class-direct-superclasses' is aliased to this function."
|
2015-01-05 04:11:37 +00:00
|
|
|
|
(let ((c (eieio-class-object class)))
|
|
|
|
|
(eieio--class-parent c)))
|
|
|
|
|
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(define-obsolete-function-alias 'class-parents #'eieio-class-parents "24.4")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(defun eieio-class-children (class)
|
|
|
|
|
"Return child classes to CLASS.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
The CLOS function `class-direct-subclasses' is aliased to this function."
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(eieio--check-type class-p class)
|
|
|
|
|
(eieio-class-children-fast class))
|
|
|
|
|
(define-obsolete-function-alias
|
|
|
|
|
'class-children #'eieio-class-children "24.4")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
;; Official CLOS functions.
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(define-obsolete-function-alias
|
|
|
|
|
'class-direct-superclasses #'eieio-class-parents "24.4")
|
|
|
|
|
(define-obsolete-function-alias
|
|
|
|
|
'class-direct-subclasses #'eieio-class-children "24.4")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(defmacro eieio-class-parent (class)
|
|
|
|
|
"Return first parent class to CLASS. (overload of variable)."
|
|
|
|
|
`(car (eieio-class-parents ,class)))
|
2013-09-19 20:11:48 +00:00
|
|
|
|
(define-obsolete-function-alias 'class-parent 'eieio-class-parent "24.4")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
(defun same-class-p (obj class) "Return t if OBJ is of class-type CLASS."
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(eieio--check-type class-p class)
|
|
|
|
|
(eieio--check-type eieio-object-p obj)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(same-class-fast-p obj class))
|
|
|
|
|
|
|
|
|
|
(defun object-of-class-p (obj class)
|
|
|
|
|
"Return non-nil if OBJ is an instance of CLASS or CLASS' subclasses."
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(eieio--check-type eieio-object-p obj)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
;; class will be checked one layer down
|
2014-12-29 17:11:09 +00:00
|
|
|
|
(child-of-class-p (eieio--object-class-object obj) class))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
;; Backwards compatibility
|
|
|
|
|
(defalias 'obj-of-class-p 'object-of-class-p)
|
|
|
|
|
|
|
|
|
|
(defun child-of-class-p (child class)
|
2009-10-05 15:32:08 +00:00
|
|
|
|
"Return non-nil if CHILD class is a subclass of CLASS."
|
2014-12-29 17:11:09 +00:00
|
|
|
|
(setq child (eieio--class-object child))
|
|
|
|
|
(eieio--check-type eieio--class-p child)
|
* 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 $.
2014-12-22 20:13:02 +00:00
|
|
|
|
;; `eieio-default-superclass' is never mentioned in eieio--class-parent,
|
|
|
|
|
;; so we have to special case it here.
|
|
|
|
|
(or (eq class 'eieio-default-superclass)
|
|
|
|
|
(let ((p nil))
|
2014-12-29 17:11:09 +00:00
|
|
|
|
(setq class (eieio--class-object class))
|
|
|
|
|
(eieio--check-type eieio--class-p class)
|
* 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 $.
2014-12-22 20:13:02 +00:00
|
|
|
|
(while (and child (not (eq child class)))
|
2014-12-29 17:11:09 +00:00
|
|
|
|
(setq p (append p (eieio--class-parent child))
|
2015-01-05 04:11:37 +00:00
|
|
|
|
child (pop p)))
|
* 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 $.
2014-12-22 20:13:02 +00:00
|
|
|
|
(if child t))))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
2010-09-19 04:23:57 +00:00
|
|
|
|
(defun object-slots (obj)
|
|
|
|
|
"Return list of slots available in OBJ."
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(eieio--check-type eieio-object-p obj)
|
2014-12-29 17:11:09 +00:00
|
|
|
|
(eieio--class-public-a (eieio--object-class-object obj)))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
2015-01-05 04:11:37 +00:00
|
|
|
|
(defun eieio--class-slot-initarg (class slot) "Fetch from CLASS, SLOT's :initarg."
|
|
|
|
|
(eieio--check-type eieio--class-p class)
|
|
|
|
|
(let ((ia (eieio--class-initarg-tuples class))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(f nil))
|
|
|
|
|
(while (and ia (not f))
|
|
|
|
|
(if (eq (cdr (car ia)) slot)
|
|
|
|
|
(setq f (car (car ia))))
|
|
|
|
|
(setq ia (cdr ia)))
|
|
|
|
|
f))
|
|
|
|
|
|
2012-10-14 01:42:48 +00:00
|
|
|
|
;;; Object Set macros
|
|
|
|
|
;;
|
|
|
|
|
(defmacro oset (obj slot value)
|
|
|
|
|
"Set the value in OBJ for slot SLOT to VALUE.
|
|
|
|
|
SLOT is the slot name as specified in `defclass' or the tag created
|
|
|
|
|
with in the :initarg slot. VALUE can be any Lisp object."
|
2014-12-22 20:46:16 +00:00
|
|
|
|
(declare (debug (form symbolp form)))
|
2012-10-14 01:42:48 +00:00
|
|
|
|
`(eieio-oset ,obj (quote ,slot) ,value))
|
|
|
|
|
|
|
|
|
|
(defmacro oset-default (class slot value)
|
|
|
|
|
"Set the default slot in CLASS for SLOT to VALUE.
|
|
|
|
|
The default value is usually set with the :initform tag during class
|
|
|
|
|
creation. This allows users to change the default behavior of classes
|
|
|
|
|
after they are created."
|
2014-12-22 20:46:16 +00:00
|
|
|
|
(declare (debug (form symbolp form)))
|
2012-10-14 01:42:48 +00:00
|
|
|
|
`(eieio-oset-default ,class (quote ,slot) ,value))
|
|
|
|
|
|
2009-09-28 00:49:54 +00:00
|
|
|
|
;;; CLOS queries into classes and slots
|
|
|
|
|
;;
|
|
|
|
|
(defun slot-boundp (object slot)
|
2009-10-05 15:32:08 +00:00
|
|
|
|
"Return non-nil if OBJECT's SLOT is bound.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
Setting a slot's value makes it bound. Calling `slot-makeunbound' will
|
|
|
|
|
make a slot unbound.
|
|
|
|
|
OBJECT can be an instance or a class."
|
|
|
|
|
;; Skip typechecking while retrieving this value.
|
|
|
|
|
(let ((eieio-skip-typecheck t))
|
|
|
|
|
;; Return nil if the magic symbol is in there.
|
2011-05-05 03:42:09 +00:00
|
|
|
|
(not (eq (cond
|
|
|
|
|
((eieio-object-p object) (eieio-oref object slot))
|
|
|
|
|
((class-p object) (eieio-oref-default object slot))
|
|
|
|
|
(t (signal 'wrong-type-argument (list 'eieio-object-p object))))
|
|
|
|
|
eieio-unbound))))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
(defun slot-makeunbound (object slot)
|
|
|
|
|
"In OBJECT, make SLOT unbound."
|
|
|
|
|
(eieio-oset object slot eieio-unbound))
|
|
|
|
|
|
|
|
|
|
(defun slot-exists-p (object-or-class slot)
|
2009-10-05 15:32:08 +00:00
|
|
|
|
"Return non-nil if OBJECT-OR-CLASS has SLOT."
|
2015-01-05 04:11:37 +00:00
|
|
|
|
(let ((cv (cond ((eieio-object-p object-or-class)
|
|
|
|
|
(eieio--object-class-object object-or-class))
|
|
|
|
|
(t (eieio-class-object object-or-class)))))
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(or (memq slot (eieio--class-public-a cv))
|
|
|
|
|
(memq slot (eieio--class-class-allocation-a cv)))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
(defun find-class (symbol &optional errorp)
|
|
|
|
|
"Return the class that SYMBOL represents.
|
|
|
|
|
If there is no class, nil is returned if ERRORP is nil.
|
|
|
|
|
If ERRORP is non-nil, `wrong-argument-type' is signaled."
|
|
|
|
|
(if (not (class-p symbol))
|
|
|
|
|
(if errorp (signal 'wrong-type-argument (list 'class-p symbol))
|
|
|
|
|
nil)
|
2014-12-22 20:46:16 +00:00
|
|
|
|
(eieio--class-v symbol)))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
;;; Slightly more complex utility functions for objects
|
|
|
|
|
;;
|
|
|
|
|
(defun object-assoc (key slot list)
|
|
|
|
|
"Return an object if KEY is `equal' to SLOT's value of an object in LIST.
|
2009-10-05 15:32:08 +00:00
|
|
|
|
LIST is a list of objects whose slots are searched.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
Objects in LIST do not need to have a slot named SLOT, nor does
|
|
|
|
|
SLOT need to be bound. If these errors occur, those objects will
|
|
|
|
|
be ignored."
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(eieio--check-type listp list)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(while (and list (not (condition-case nil
|
|
|
|
|
;; This prevents errors for missing slots.
|
|
|
|
|
(equal key (eieio-oref (car list) slot))
|
|
|
|
|
(error nil))))
|
|
|
|
|
(setq list (cdr list)))
|
|
|
|
|
(car list))
|
|
|
|
|
|
|
|
|
|
(defun object-assoc-list (slot list)
|
|
|
|
|
"Return an association list with the contents of SLOT as the key element.
|
|
|
|
|
LIST must be a list of objects with SLOT in it.
|
|
|
|
|
This is useful when you need to do completing read on an object group."
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(eieio--check-type listp list)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(let ((assoclist nil))
|
|
|
|
|
(while list
|
|
|
|
|
(setq assoclist (cons (cons (eieio-oref (car list) slot)
|
|
|
|
|
(car list))
|
|
|
|
|
assoclist))
|
|
|
|
|
(setq list (cdr list)))
|
|
|
|
|
(nreverse assoclist)))
|
|
|
|
|
|
|
|
|
|
(defun object-assoc-list-safe (slot list)
|
|
|
|
|
"Return an association list with the contents of SLOT as the key element.
|
|
|
|
|
LIST must be a list of objects, but those objects do not need to have
|
|
|
|
|
SLOT in it. If it does not, then that element is left out of the association
|
|
|
|
|
list."
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(eieio--check-type listp list)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(let ((assoclist nil))
|
|
|
|
|
(while list
|
|
|
|
|
(if (slot-exists-p (car list) slot)
|
|
|
|
|
(setq assoclist (cons (cons (eieio-oref (car list) slot)
|
|
|
|
|
(car list))
|
|
|
|
|
assoclist)))
|
|
|
|
|
(setq list (cdr list)))
|
|
|
|
|
(nreverse assoclist)))
|
|
|
|
|
|
|
|
|
|
(defun object-add-to-list (object slot item &optional append)
|
|
|
|
|
"In OBJECT's SLOT, add ITEM to the list of elements.
|
|
|
|
|
Optional argument APPEND indicates we need to append to the list.
|
|
|
|
|
If ITEM already exists in the list in SLOT, then it is not added.
|
|
|
|
|
Comparison is done with `equal' through the `member' function call.
|
|
|
|
|
If SLOT is unbound, bind it to the list containing ITEM."
|
|
|
|
|
(let (ov)
|
|
|
|
|
;; Find the originating list.
|
|
|
|
|
(if (not (slot-boundp object slot))
|
|
|
|
|
(setq ov (list item))
|
|
|
|
|
(setq ov (eieio-oref object slot))
|
|
|
|
|
;; turn it into a list.
|
|
|
|
|
(unless (listp ov)
|
|
|
|
|
(setq ov (list ov)))
|
|
|
|
|
;; Do the combination
|
|
|
|
|
(if (not (member item ov))
|
|
|
|
|
(setq ov
|
|
|
|
|
(if append
|
|
|
|
|
(append ov (list item))
|
|
|
|
|
(cons item ov)))))
|
|
|
|
|
;; Set back into the slot.
|
|
|
|
|
(eieio-oset object slot ov)))
|
|
|
|
|
|
|
|
|
|
(defun object-remove-from-list (object slot item)
|
|
|
|
|
"In OBJECT's SLOT, remove occurrences of ITEM.
|
2009-10-05 15:32:08 +00:00
|
|
|
|
Deletion is done with `delete', which deletes by side effect,
|
2009-09-28 00:49:54 +00:00
|
|
|
|
and comparisons are done with `equal'.
|
|
|
|
|
If SLOT is unbound, do nothing."
|
|
|
|
|
(if (not (slot-boundp object slot))
|
|
|
|
|
nil
|
|
|
|
|
(eieio-oset object slot (delete item (eieio-oref object slot)))))
|
|
|
|
|
|
Merge from CEDET upstream (8564).
* lisp/emacs-lisp:
* emacs-lisp/eieio.el (eieio--defalias, eieio-hook)
(eieio-error-unsupported-class-tags, eieio-skip-typecheck)
(eieio-optimize-primary-methods-flag, eieio-initializing-object)
(eieio-unbound, eieio-default-superclass)
(eieio--define-field-accessors, method-static, method-before)
(method-primary, method-after, method-num-lists)
(method-generic-before, method-generic-primary)
(method-generic-after, method-num-slots)
(eieio-specialized-key-to-generic-key)
(eieio--check-type, class-v, class-p)
(eieio-class-name, define-obsolete-function-alias)
(eieio-class-parents-fast, eieio-class-children-fast)
(same-class-fast-p, class-constructor, generic-p)
(generic-primary-only-p, generic-primary-only-one-p)
(class-option-assoc, class-option, eieio-object-p)
(class-abstract-p, class-method-invocation-order)
(eieio-defclass-autoload-map, eieio-defclass-autoload)
(eieio-class-un-autoload, eieio-defclass)
(eieio-eval-default-p, eieio-perform-slot-validation-for-default)
(eieio-add-new-slot, eieio-copy-parents-into-subclass)
(eieio--defgeneric-init-form, eieio-defgeneric-form)
(eieio-defgeneric-reset-generic-form)
(eieio-defgeneric-form-primary-only)
(eieio-defgeneric-reset-generic-form-primary-only)
(eieio-defgeneric-form-primary-only-one)
(eieio-defgeneric-reset-generic-form-primary-only-one)
(eieio-unbind-method-implementations)
(eieio--defmethod, eieio--typep)
(eieio-perform-slot-validation, eieio-validate-slot-value)
(eieio-validate-class-slot-value, eieio-barf-if-slot-unbound)
(eieio-oref, eieio-oref-default, eieio-default-eval-maybe)
(eieio-oset, eieio-oset-default, eieio-slot-originating-class-p)
(eieio-slot-name-index, eieio-class-slot-name-index)
(eieio-set-defaults, eieio-initarg-to-attribute)
(eieio-attribute-to-initarg, eieio-c3-candidate)
(eieio-c3-merge-lists, eieio-class-precedence-c3)
(eieio-class-precedence-dfs, eieio-class-precedence-bfs)
(eieio-class-precedence-list, eieio-generic-call-methodname)
(eieio-generic-call-arglst, eieio-generic-call-key)
(eieio-generic-call-next-method-list)
(eieio-pre-method-execution-functions, eieio-generic-call)
(eieio-generic-call-primary-only, eieiomt-method-list)
(eieiomt-optimizing-obarray, eieiomt-install)
(eieiomt-add, eieiomt-next, eieiomt-sym-optimize)
(eieio-generic-form, eieio-defmethod, make-obsolete)
(eieio-defgeneric, make-obsolete): Moved to eieio-core.el
(defclass): Remove `eval-and-compile' from macro.
(call-next-method, shared-initialize): Instead of using
`scoped-class' variable, use new eieio--scoped-class, and
eieio--with-scoped-class.
(initialize-instance): Rename local variable 'scoped-class' to
'this-class' to remove ambiguitity from old global.
* emacs-lisp/eieio-core.el: New file. Derived from key parts of
eieio.el.
(eieio--scoped-class-stack): New variable
(eieio--scoped-class): New fcn
(eieio--with-scoped-class): New scoping macro.
(eieio-defclass): Use pushnew instead of add-to-list.
(eieio-defgeneric-form-primary-only-one, eieio-oset-default)
(eieio-slot-name-index, eieio-set-defaults, eieio-generic-call)
(eieio-generic-call-primary-only, eieiomt-add): Instead of using
`scoped-class' variable, use new eieio--scoped-class, and
eieio--with-scoped-class.
* emacs-lisp/eieio-base.el (cl-lib): Require during compile.
* admin/grammars:
* grammars/srecode-template.wy (variable): Accept a single number
as a variable value. Allows the 'priority' to be set to a number.
(wisent-srecode-template-lexer): Move number up so it can be
created.
* etc/srecode:
* srecode/c.srt (header_guard): Add :c parameter so it works
standalone
* lisp/cedet:
* semantic/edit.el (semantic-change-function): Use
`save-match-data' around running hooks.
* semantic/decorate/mode.el
(semantic-decorate-style-predicate-default)
(semantic-decorate-style-highlighter-default): New.
(semantic-decoration-mode): Do not require
`semantic/decorate/include' anymore.
(semantic-toggle-decoration-style): Error if an unknown decoration
style is toggled.
(define-semantic-decoration-style): Add new :load option. When
:load is specified, add autoload tokens for the definition
functions so that code is loaded when the mode is used.
(semantic-decoration-on-includes): New autoload definition for
highlighting includes.
* semantic/bovine/c.el (semantic-lex-c-ifdef): Allow some misc
characters to appear after the tested variable.
* semantic/ede-grammar.el (project-compile-target): Calculate full
src name via ede-expand-filename instead of the crutch of the
current buffer. Enables this target to compile in batch mode.
* semantic/idle.el
(semantic-idle-symbol-maybe-highlight): Wrap highlighting of
remote symbol with `save-excursion'.
(semantic-idle-scheduler-work-parse-neighboring-files): Instead of
using directory-files on each found mode pattern, collect all the
patterns for the current mode, and then for each file, see if it
matches any of them. If it does, parse the file. (Patch
inspiration from Tomasz Gajewski.)
* semantic/ctxt.el (semantic-ctxt-end-of-symbol): New.
(semantic-ctxt-current-symbol-default): New.
* semantic/bovine/el.el (semantic-default-elisp-setup): Add
autoload cookie. Explain existence.
(footer): Add local variable for loaddefs.
* semantic/db.el (semanticdb-file-table-object): Add new filter,
only checking for regular files too.
* semantic/wisent/python.el
(semantic-format-tag-abbreviate): New override. Cuts back on size
of code tags.
* srecode/compile.el (srecode-compile-templates): Fix warning
punctuation. Remove status messages to clean up testing output
* ede/base.el (ede-project-placeholder-cache-file): Update doc to
mention 'nil' value.
(ede-save-cache): Disable cache save if file is nil.
* ede.el (ede-initialize-state-current-buffer): Flush deleted
projects.
(global-ede-mode): Always append our find-file-hook to the end.
(ede-flush-deleted-projects): New command.
* ede/cpp-root.el (ede-preprocessor-map): Protect against init
problems.
* ede/proj.el (ede-proj-target): Added a new "custom" option for
custom symbols representing a compiler or linker instead of
restricting things to only the predefined compilers and linkers.
* semantic.el (semantic-mode-map): To avoid showing showing
Development menu twice, only disable menu item if menu-bar is
actually enabled, otherwise the popup 'global menu' might display
a disabled Development menu.
* semantic/complete.el
(semantic-displayor-show-request): Fix which slot in obj is set to
the max tags.
2013-06-02 13:33:09 +00:00
|
|
|
|
;;;
|
|
|
|
|
;; Method Calling Functions
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
(defun next-method-p ()
|
2009-10-05 15:32:08 +00:00
|
|
|
|
"Return non-nil if there is a next method.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
Returns a list of lambda expressions which is the `next-method'
|
|
|
|
|
order."
|
|
|
|
|
eieio-generic-call-next-method-list)
|
|
|
|
|
|
|
|
|
|
(defun call-next-method (&rest replacement-args)
|
|
|
|
|
"Call the superclass method from a subclass method.
|
|
|
|
|
The superclass method is specified in the current method list,
|
|
|
|
|
and is called the next method.
|
|
|
|
|
|
|
|
|
|
If REPLACEMENT-ARGS is non-nil, then use them instead of
|
|
|
|
|
`eieio-generic-call-arglst'. The generic arg list are the
|
|
|
|
|
arguments passed in at the top level.
|
|
|
|
|
|
|
|
|
|
Use `next-method-p' to find out if there is a next method to call."
|
Merge from CEDET upstream (8564).
* lisp/emacs-lisp:
* emacs-lisp/eieio.el (eieio--defalias, eieio-hook)
(eieio-error-unsupported-class-tags, eieio-skip-typecheck)
(eieio-optimize-primary-methods-flag, eieio-initializing-object)
(eieio-unbound, eieio-default-superclass)
(eieio--define-field-accessors, method-static, method-before)
(method-primary, method-after, method-num-lists)
(method-generic-before, method-generic-primary)
(method-generic-after, method-num-slots)
(eieio-specialized-key-to-generic-key)
(eieio--check-type, class-v, class-p)
(eieio-class-name, define-obsolete-function-alias)
(eieio-class-parents-fast, eieio-class-children-fast)
(same-class-fast-p, class-constructor, generic-p)
(generic-primary-only-p, generic-primary-only-one-p)
(class-option-assoc, class-option, eieio-object-p)
(class-abstract-p, class-method-invocation-order)
(eieio-defclass-autoload-map, eieio-defclass-autoload)
(eieio-class-un-autoload, eieio-defclass)
(eieio-eval-default-p, eieio-perform-slot-validation-for-default)
(eieio-add-new-slot, eieio-copy-parents-into-subclass)
(eieio--defgeneric-init-form, eieio-defgeneric-form)
(eieio-defgeneric-reset-generic-form)
(eieio-defgeneric-form-primary-only)
(eieio-defgeneric-reset-generic-form-primary-only)
(eieio-defgeneric-form-primary-only-one)
(eieio-defgeneric-reset-generic-form-primary-only-one)
(eieio-unbind-method-implementations)
(eieio--defmethod, eieio--typep)
(eieio-perform-slot-validation, eieio-validate-slot-value)
(eieio-validate-class-slot-value, eieio-barf-if-slot-unbound)
(eieio-oref, eieio-oref-default, eieio-default-eval-maybe)
(eieio-oset, eieio-oset-default, eieio-slot-originating-class-p)
(eieio-slot-name-index, eieio-class-slot-name-index)
(eieio-set-defaults, eieio-initarg-to-attribute)
(eieio-attribute-to-initarg, eieio-c3-candidate)
(eieio-c3-merge-lists, eieio-class-precedence-c3)
(eieio-class-precedence-dfs, eieio-class-precedence-bfs)
(eieio-class-precedence-list, eieio-generic-call-methodname)
(eieio-generic-call-arglst, eieio-generic-call-key)
(eieio-generic-call-next-method-list)
(eieio-pre-method-execution-functions, eieio-generic-call)
(eieio-generic-call-primary-only, eieiomt-method-list)
(eieiomt-optimizing-obarray, eieiomt-install)
(eieiomt-add, eieiomt-next, eieiomt-sym-optimize)
(eieio-generic-form, eieio-defmethod, make-obsolete)
(eieio-defgeneric, make-obsolete): Moved to eieio-core.el
(defclass): Remove `eval-and-compile' from macro.
(call-next-method, shared-initialize): Instead of using
`scoped-class' variable, use new eieio--scoped-class, and
eieio--with-scoped-class.
(initialize-instance): Rename local variable 'scoped-class' to
'this-class' to remove ambiguitity from old global.
* emacs-lisp/eieio-core.el: New file. Derived from key parts of
eieio.el.
(eieio--scoped-class-stack): New variable
(eieio--scoped-class): New fcn
(eieio--with-scoped-class): New scoping macro.
(eieio-defclass): Use pushnew instead of add-to-list.
(eieio-defgeneric-form-primary-only-one, eieio-oset-default)
(eieio-slot-name-index, eieio-set-defaults, eieio-generic-call)
(eieio-generic-call-primary-only, eieiomt-add): Instead of using
`scoped-class' variable, use new eieio--scoped-class, and
eieio--with-scoped-class.
* emacs-lisp/eieio-base.el (cl-lib): Require during compile.
* admin/grammars:
* grammars/srecode-template.wy (variable): Accept a single number
as a variable value. Allows the 'priority' to be set to a number.
(wisent-srecode-template-lexer): Move number up so it can be
created.
* etc/srecode:
* srecode/c.srt (header_guard): Add :c parameter so it works
standalone
* lisp/cedet:
* semantic/edit.el (semantic-change-function): Use
`save-match-data' around running hooks.
* semantic/decorate/mode.el
(semantic-decorate-style-predicate-default)
(semantic-decorate-style-highlighter-default): New.
(semantic-decoration-mode): Do not require
`semantic/decorate/include' anymore.
(semantic-toggle-decoration-style): Error if an unknown decoration
style is toggled.
(define-semantic-decoration-style): Add new :load option. When
:load is specified, add autoload tokens for the definition
functions so that code is loaded when the mode is used.
(semantic-decoration-on-includes): New autoload definition for
highlighting includes.
* semantic/bovine/c.el (semantic-lex-c-ifdef): Allow some misc
characters to appear after the tested variable.
* semantic/ede-grammar.el (project-compile-target): Calculate full
src name via ede-expand-filename instead of the crutch of the
current buffer. Enables this target to compile in batch mode.
* semantic/idle.el
(semantic-idle-symbol-maybe-highlight): Wrap highlighting of
remote symbol with `save-excursion'.
(semantic-idle-scheduler-work-parse-neighboring-files): Instead of
using directory-files on each found mode pattern, collect all the
patterns for the current mode, and then for each file, see if it
matches any of them. If it does, parse the file. (Patch
inspiration from Tomasz Gajewski.)
* semantic/ctxt.el (semantic-ctxt-end-of-symbol): New.
(semantic-ctxt-current-symbol-default): New.
* semantic/bovine/el.el (semantic-default-elisp-setup): Add
autoload cookie. Explain existence.
(footer): Add local variable for loaddefs.
* semantic/db.el (semanticdb-file-table-object): Add new filter,
only checking for regular files too.
* semantic/wisent/python.el
(semantic-format-tag-abbreviate): New override. Cuts back on size
of code tags.
* srecode/compile.el (srecode-compile-templates): Fix warning
punctuation. Remove status messages to clean up testing output
* ede/base.el (ede-project-placeholder-cache-file): Update doc to
mention 'nil' value.
(ede-save-cache): Disable cache save if file is nil.
* ede.el (ede-initialize-state-current-buffer): Flush deleted
projects.
(global-ede-mode): Always append our find-file-hook to the end.
(ede-flush-deleted-projects): New command.
* ede/cpp-root.el (ede-preprocessor-map): Protect against init
problems.
* ede/proj.el (ede-proj-target): Added a new "custom" option for
custom symbols representing a compiler or linker instead of
restricting things to only the predefined compilers and linkers.
* semantic.el (semantic-mode-map): To avoid showing showing
Development menu twice, only disable menu item if menu-bar is
actually enabled, otherwise the popup 'global menu' might display
a disabled Development menu.
* semantic/complete.el
(semantic-displayor-show-request): Fix which slot in obj is set to
the max tags.
2013-06-02 13:33:09 +00:00
|
|
|
|
(if (not (eieio--scoped-class))
|
2009-10-05 15:32:08 +00:00
|
|
|
|
(error "`call-next-method' not called within a class specific method"))
|
2014-12-22 20:46:16 +00:00
|
|
|
|
(if (and (/= eieio-generic-call-key eieio--method-primary)
|
|
|
|
|
(/= eieio-generic-call-key eieio--method-static))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(error "Cannot `call-next-method' except in :primary or :static methods")
|
|
|
|
|
)
|
|
|
|
|
(let ((newargs (or replacement-args eieio-generic-call-arglst))
|
|
|
|
|
(next (car eieio-generic-call-next-method-list))
|
|
|
|
|
)
|
2014-12-29 17:11:09 +00:00
|
|
|
|
(if (not (and next (car next)))
|
2014-10-17 05:09:24 +00:00
|
|
|
|
(apply #'no-next-method (car newargs) (cdr newargs))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(let* ((eieio-generic-call-next-method-list
|
|
|
|
|
(cdr eieio-generic-call-next-method-list))
|
2010-09-19 04:23:57 +00:00
|
|
|
|
(eieio-generic-call-arglst newargs)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(fcn (car next))
|
|
|
|
|
)
|
2015-01-05 04:11:37 +00:00
|
|
|
|
(eieio--with-scoped-class (cdr next)
|
Merge from CEDET upstream (8564).
* lisp/emacs-lisp:
* emacs-lisp/eieio.el (eieio--defalias, eieio-hook)
(eieio-error-unsupported-class-tags, eieio-skip-typecheck)
(eieio-optimize-primary-methods-flag, eieio-initializing-object)
(eieio-unbound, eieio-default-superclass)
(eieio--define-field-accessors, method-static, method-before)
(method-primary, method-after, method-num-lists)
(method-generic-before, method-generic-primary)
(method-generic-after, method-num-slots)
(eieio-specialized-key-to-generic-key)
(eieio--check-type, class-v, class-p)
(eieio-class-name, define-obsolete-function-alias)
(eieio-class-parents-fast, eieio-class-children-fast)
(same-class-fast-p, class-constructor, generic-p)
(generic-primary-only-p, generic-primary-only-one-p)
(class-option-assoc, class-option, eieio-object-p)
(class-abstract-p, class-method-invocation-order)
(eieio-defclass-autoload-map, eieio-defclass-autoload)
(eieio-class-un-autoload, eieio-defclass)
(eieio-eval-default-p, eieio-perform-slot-validation-for-default)
(eieio-add-new-slot, eieio-copy-parents-into-subclass)
(eieio--defgeneric-init-form, eieio-defgeneric-form)
(eieio-defgeneric-reset-generic-form)
(eieio-defgeneric-form-primary-only)
(eieio-defgeneric-reset-generic-form-primary-only)
(eieio-defgeneric-form-primary-only-one)
(eieio-defgeneric-reset-generic-form-primary-only-one)
(eieio-unbind-method-implementations)
(eieio--defmethod, eieio--typep)
(eieio-perform-slot-validation, eieio-validate-slot-value)
(eieio-validate-class-slot-value, eieio-barf-if-slot-unbound)
(eieio-oref, eieio-oref-default, eieio-default-eval-maybe)
(eieio-oset, eieio-oset-default, eieio-slot-originating-class-p)
(eieio-slot-name-index, eieio-class-slot-name-index)
(eieio-set-defaults, eieio-initarg-to-attribute)
(eieio-attribute-to-initarg, eieio-c3-candidate)
(eieio-c3-merge-lists, eieio-class-precedence-c3)
(eieio-class-precedence-dfs, eieio-class-precedence-bfs)
(eieio-class-precedence-list, eieio-generic-call-methodname)
(eieio-generic-call-arglst, eieio-generic-call-key)
(eieio-generic-call-next-method-list)
(eieio-pre-method-execution-functions, eieio-generic-call)
(eieio-generic-call-primary-only, eieiomt-method-list)
(eieiomt-optimizing-obarray, eieiomt-install)
(eieiomt-add, eieiomt-next, eieiomt-sym-optimize)
(eieio-generic-form, eieio-defmethod, make-obsolete)
(eieio-defgeneric, make-obsolete): Moved to eieio-core.el
(defclass): Remove `eval-and-compile' from macro.
(call-next-method, shared-initialize): Instead of using
`scoped-class' variable, use new eieio--scoped-class, and
eieio--with-scoped-class.
(initialize-instance): Rename local variable 'scoped-class' to
'this-class' to remove ambiguitity from old global.
* emacs-lisp/eieio-core.el: New file. Derived from key parts of
eieio.el.
(eieio--scoped-class-stack): New variable
(eieio--scoped-class): New fcn
(eieio--with-scoped-class): New scoping macro.
(eieio-defclass): Use pushnew instead of add-to-list.
(eieio-defgeneric-form-primary-only-one, eieio-oset-default)
(eieio-slot-name-index, eieio-set-defaults, eieio-generic-call)
(eieio-generic-call-primary-only, eieiomt-add): Instead of using
`scoped-class' variable, use new eieio--scoped-class, and
eieio--with-scoped-class.
* emacs-lisp/eieio-base.el (cl-lib): Require during compile.
* admin/grammars:
* grammars/srecode-template.wy (variable): Accept a single number
as a variable value. Allows the 'priority' to be set to a number.
(wisent-srecode-template-lexer): Move number up so it can be
created.
* etc/srecode:
* srecode/c.srt (header_guard): Add :c parameter so it works
standalone
* lisp/cedet:
* semantic/edit.el (semantic-change-function): Use
`save-match-data' around running hooks.
* semantic/decorate/mode.el
(semantic-decorate-style-predicate-default)
(semantic-decorate-style-highlighter-default): New.
(semantic-decoration-mode): Do not require
`semantic/decorate/include' anymore.
(semantic-toggle-decoration-style): Error if an unknown decoration
style is toggled.
(define-semantic-decoration-style): Add new :load option. When
:load is specified, add autoload tokens for the definition
functions so that code is loaded when the mode is used.
(semantic-decoration-on-includes): New autoload definition for
highlighting includes.
* semantic/bovine/c.el (semantic-lex-c-ifdef): Allow some misc
characters to appear after the tested variable.
* semantic/ede-grammar.el (project-compile-target): Calculate full
src name via ede-expand-filename instead of the crutch of the
current buffer. Enables this target to compile in batch mode.
* semantic/idle.el
(semantic-idle-symbol-maybe-highlight): Wrap highlighting of
remote symbol with `save-excursion'.
(semantic-idle-scheduler-work-parse-neighboring-files): Instead of
using directory-files on each found mode pattern, collect all the
patterns for the current mode, and then for each file, see if it
matches any of them. If it does, parse the file. (Patch
inspiration from Tomasz Gajewski.)
* semantic/ctxt.el (semantic-ctxt-end-of-symbol): New.
(semantic-ctxt-current-symbol-default): New.
* semantic/bovine/el.el (semantic-default-elisp-setup): Add
autoload cookie. Explain existence.
(footer): Add local variable for loaddefs.
* semantic/db.el (semanticdb-file-table-object): Add new filter,
only checking for regular files too.
* semantic/wisent/python.el
(semantic-format-tag-abbreviate): New override. Cuts back on size
of code tags.
* srecode/compile.el (srecode-compile-templates): Fix warning
punctuation. Remove status messages to clean up testing output
* ede/base.el (ede-project-placeholder-cache-file): Update doc to
mention 'nil' value.
(ede-save-cache): Disable cache save if file is nil.
* ede.el (ede-initialize-state-current-buffer): Flush deleted
projects.
(global-ede-mode): Always append our find-file-hook to the end.
(ede-flush-deleted-projects): New command.
* ede/cpp-root.el (ede-preprocessor-map): Protect against init
problems.
* ede/proj.el (ede-proj-target): Added a new "custom" option for
custom symbols representing a compiler or linker instead of
restricting things to only the predefined compilers and linkers.
* semantic.el (semantic-mode-map): To avoid showing showing
Development menu twice, only disable menu item if menu-bar is
actually enabled, otherwise the popup 'global menu' might display
a disabled Development menu.
* semantic/complete.el
(semantic-displayor-show-request): Fix which slot in obj is set to
the max tags.
2013-06-02 13:33:09 +00:00
|
|
|
|
(apply fcn newargs)) ))))
|
2010-09-19 04:23:57 +00:00
|
|
|
|
|
2009-09-28 00:49:54 +00:00
|
|
|
|
;;; Here are some CLOS items that need the CL package
|
|
|
|
|
;;
|
|
|
|
|
|
2014-10-17 05:09:24 +00:00
|
|
|
|
(gv-define-simple-setter eieio-oref eieio-oset)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;; We want all objects created by EIEIO to have some default set of
|
2011-11-14 23:59:56 +00:00
|
|
|
|
;; behaviors so we can create object utilities, and allow various
|
2009-09-28 00:49:54 +00:00
|
|
|
|
;; types of error checking. To do this, create the default EIEIO
|
|
|
|
|
;; class, and when no parent class is specified, use this as the
|
|
|
|
|
;; default. (But don't store it in the other classes as the default,
|
|
|
|
|
;; allowing for transparent support.)
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
(defclass eieio-default-superclass nil
|
|
|
|
|
nil
|
|
|
|
|
"Default parent class for classes with no specified parent class.
|
2009-10-05 15:32:08 +00:00
|
|
|
|
Its slots are automatically adopted by classes with no specified parents.
|
|
|
|
|
This class is not stored in the `parent' slot of a class vector."
|
2009-09-28 00:49:54 +00:00
|
|
|
|
:abstract t)
|
|
|
|
|
|
2015-01-05 04:11:37 +00:00
|
|
|
|
(setq eieio-default-superclass (eieio--class-v 'eieio-default-superclass))
|
|
|
|
|
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(defalias 'standard-class 'eieio-default-superclass)
|
|
|
|
|
|
2014-12-23 03:05:46 +00:00
|
|
|
|
(defgeneric eieio-constructor (class &rest slots)
|
2009-10-05 15:32:08 +00:00
|
|
|
|
"Default constructor for CLASS `eieio-default-superclass'.")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
2014-12-23 03:05:46 +00:00
|
|
|
|
(define-obsolete-function-alias 'constructor #'eieio-constructor "25.1")
|
|
|
|
|
|
|
|
|
|
(defmethod eieio-constructor :static
|
|
|
|
|
((class eieio-default-superclass) &rest slots)
|
2009-10-05 15:32:08 +00:00
|
|
|
|
"Default constructor for CLASS `eieio-default-superclass'.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
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."
|
2014-12-22 20:46:16 +00:00
|
|
|
|
(let* ((new-object (copy-sequence (eieio--class-default-object-cache (eieio--class-v class)))))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
;; Call the initialize method on the new object with the slots
|
|
|
|
|
;; that were passed down to us.
|
|
|
|
|
(initialize-instance new-object slots)
|
|
|
|
|
;; Return the created object.
|
|
|
|
|
new-object))
|
|
|
|
|
|
|
|
|
|
(defgeneric shared-initialize (obj slots)
|
|
|
|
|
"Set slots of OBJ with SLOTS which is a list of name/value pairs.
|
|
|
|
|
Called from the constructor routine.")
|
|
|
|
|
|
|
|
|
|
(defmethod shared-initialize ((obj eieio-default-superclass) slots)
|
|
|
|
|
"Set slots of OBJ with SLOTS which is a list of name/value pairs.
|
|
|
|
|
Called from the constructor routine."
|
2014-12-29 17:11:09 +00:00
|
|
|
|
(eieio--with-scoped-class (eieio--object-class-object obj)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(while slots
|
2014-12-29 17:11:09 +00:00
|
|
|
|
(let ((rn (eieio--initarg-to-attribute (eieio--object-class-object obj)
|
|
|
|
|
(car slots))))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(if (not rn)
|
|
|
|
|
(slot-missing obj (car slots) 'oset (car (cdr slots)))
|
|
|
|
|
(eieio-oset obj rn (car (cdr slots)))))
|
|
|
|
|
(setq slots (cdr (cdr slots))))))
|
|
|
|
|
|
|
|
|
|
(defgeneric initialize-instance (this &optional slots)
|
2009-10-05 15:32:08 +00:00
|
|
|
|
"Construct the new object THIS based on SLOTS.")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
(defmethod initialize-instance ((this eieio-default-superclass)
|
|
|
|
|
&optional slots)
|
2009-10-05 15:32:08 +00:00
|
|
|
|
"Construct the new object THIS based on SLOTS.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
SLOTS is a tagged list where odd numbered elements are tags, and
|
2009-10-05 15:32:08 +00:00
|
|
|
|
even numbered elements are the values to store in the tagged slot.
|
|
|
|
|
If you overload the `initialize-instance', there you will need to
|
|
|
|
|
call `shared-initialize' yourself, or you can call `call-next-method'
|
|
|
|
|
to have this constructor called automatically. If these steps are
|
|
|
|
|
not taken, then new objects of your class will not have their values
|
2009-09-28 00:49:54 +00:00
|
|
|
|
dynamically set from SLOTS."
|
Merge from CEDET upstream (8564).
* lisp/emacs-lisp:
* emacs-lisp/eieio.el (eieio--defalias, eieio-hook)
(eieio-error-unsupported-class-tags, eieio-skip-typecheck)
(eieio-optimize-primary-methods-flag, eieio-initializing-object)
(eieio-unbound, eieio-default-superclass)
(eieio--define-field-accessors, method-static, method-before)
(method-primary, method-after, method-num-lists)
(method-generic-before, method-generic-primary)
(method-generic-after, method-num-slots)
(eieio-specialized-key-to-generic-key)
(eieio--check-type, class-v, class-p)
(eieio-class-name, define-obsolete-function-alias)
(eieio-class-parents-fast, eieio-class-children-fast)
(same-class-fast-p, class-constructor, generic-p)
(generic-primary-only-p, generic-primary-only-one-p)
(class-option-assoc, class-option, eieio-object-p)
(class-abstract-p, class-method-invocation-order)
(eieio-defclass-autoload-map, eieio-defclass-autoload)
(eieio-class-un-autoload, eieio-defclass)
(eieio-eval-default-p, eieio-perform-slot-validation-for-default)
(eieio-add-new-slot, eieio-copy-parents-into-subclass)
(eieio--defgeneric-init-form, eieio-defgeneric-form)
(eieio-defgeneric-reset-generic-form)
(eieio-defgeneric-form-primary-only)
(eieio-defgeneric-reset-generic-form-primary-only)
(eieio-defgeneric-form-primary-only-one)
(eieio-defgeneric-reset-generic-form-primary-only-one)
(eieio-unbind-method-implementations)
(eieio--defmethod, eieio--typep)
(eieio-perform-slot-validation, eieio-validate-slot-value)
(eieio-validate-class-slot-value, eieio-barf-if-slot-unbound)
(eieio-oref, eieio-oref-default, eieio-default-eval-maybe)
(eieio-oset, eieio-oset-default, eieio-slot-originating-class-p)
(eieio-slot-name-index, eieio-class-slot-name-index)
(eieio-set-defaults, eieio-initarg-to-attribute)
(eieio-attribute-to-initarg, eieio-c3-candidate)
(eieio-c3-merge-lists, eieio-class-precedence-c3)
(eieio-class-precedence-dfs, eieio-class-precedence-bfs)
(eieio-class-precedence-list, eieio-generic-call-methodname)
(eieio-generic-call-arglst, eieio-generic-call-key)
(eieio-generic-call-next-method-list)
(eieio-pre-method-execution-functions, eieio-generic-call)
(eieio-generic-call-primary-only, eieiomt-method-list)
(eieiomt-optimizing-obarray, eieiomt-install)
(eieiomt-add, eieiomt-next, eieiomt-sym-optimize)
(eieio-generic-form, eieio-defmethod, make-obsolete)
(eieio-defgeneric, make-obsolete): Moved to eieio-core.el
(defclass): Remove `eval-and-compile' from macro.
(call-next-method, shared-initialize): Instead of using
`scoped-class' variable, use new eieio--scoped-class, and
eieio--with-scoped-class.
(initialize-instance): Rename local variable 'scoped-class' to
'this-class' to remove ambiguitity from old global.
* emacs-lisp/eieio-core.el: New file. Derived from key parts of
eieio.el.
(eieio--scoped-class-stack): New variable
(eieio--scoped-class): New fcn
(eieio--with-scoped-class): New scoping macro.
(eieio-defclass): Use pushnew instead of add-to-list.
(eieio-defgeneric-form-primary-only-one, eieio-oset-default)
(eieio-slot-name-index, eieio-set-defaults, eieio-generic-call)
(eieio-generic-call-primary-only, eieiomt-add): Instead of using
`scoped-class' variable, use new eieio--scoped-class, and
eieio--with-scoped-class.
* emacs-lisp/eieio-base.el (cl-lib): Require during compile.
* admin/grammars:
* grammars/srecode-template.wy (variable): Accept a single number
as a variable value. Allows the 'priority' to be set to a number.
(wisent-srecode-template-lexer): Move number up so it can be
created.
* etc/srecode:
* srecode/c.srt (header_guard): Add :c parameter so it works
standalone
* lisp/cedet:
* semantic/edit.el (semantic-change-function): Use
`save-match-data' around running hooks.
* semantic/decorate/mode.el
(semantic-decorate-style-predicate-default)
(semantic-decorate-style-highlighter-default): New.
(semantic-decoration-mode): Do not require
`semantic/decorate/include' anymore.
(semantic-toggle-decoration-style): Error if an unknown decoration
style is toggled.
(define-semantic-decoration-style): Add new :load option. When
:load is specified, add autoload tokens for the definition
functions so that code is loaded when the mode is used.
(semantic-decoration-on-includes): New autoload definition for
highlighting includes.
* semantic/bovine/c.el (semantic-lex-c-ifdef): Allow some misc
characters to appear after the tested variable.
* semantic/ede-grammar.el (project-compile-target): Calculate full
src name via ede-expand-filename instead of the crutch of the
current buffer. Enables this target to compile in batch mode.
* semantic/idle.el
(semantic-idle-symbol-maybe-highlight): Wrap highlighting of
remote symbol with `save-excursion'.
(semantic-idle-scheduler-work-parse-neighboring-files): Instead of
using directory-files on each found mode pattern, collect all the
patterns for the current mode, and then for each file, see if it
matches any of them. If it does, parse the file. (Patch
inspiration from Tomasz Gajewski.)
* semantic/ctxt.el (semantic-ctxt-end-of-symbol): New.
(semantic-ctxt-current-symbol-default): New.
* semantic/bovine/el.el (semantic-default-elisp-setup): Add
autoload cookie. Explain existence.
(footer): Add local variable for loaddefs.
* semantic/db.el (semanticdb-file-table-object): Add new filter,
only checking for regular files too.
* semantic/wisent/python.el
(semantic-format-tag-abbreviate): New override. Cuts back on size
of code tags.
* srecode/compile.el (srecode-compile-templates): Fix warning
punctuation. Remove status messages to clean up testing output
* ede/base.el (ede-project-placeholder-cache-file): Update doc to
mention 'nil' value.
(ede-save-cache): Disable cache save if file is nil.
* ede.el (ede-initialize-state-current-buffer): Flush deleted
projects.
(global-ede-mode): Always append our find-file-hook to the end.
(ede-flush-deleted-projects): New command.
* ede/cpp-root.el (ede-preprocessor-map): Protect against init
problems.
* ede/proj.el (ede-proj-target): Added a new "custom" option for
custom symbols representing a compiler or linker instead of
restricting things to only the predefined compilers and linkers.
* semantic.el (semantic-mode-map): To avoid showing showing
Development menu twice, only disable menu item if menu-bar is
actually enabled, otherwise the popup 'global menu' might display
a disabled Development menu.
* semantic/complete.el
(semantic-displayor-show-request): Fix which slot in obj is set to
the max tags.
2013-06-02 13:33:09 +00:00
|
|
|
|
;; First, see if any of our defaults are `lambda', and
|
|
|
|
|
;; re-evaluate them and apply the value to our slots.
|
2014-12-29 17:11:09 +00:00
|
|
|
|
(let* ((this-class (eieio--object-class-object this))
|
Merge from CEDET upstream (8564).
* lisp/emacs-lisp:
* emacs-lisp/eieio.el (eieio--defalias, eieio-hook)
(eieio-error-unsupported-class-tags, eieio-skip-typecheck)
(eieio-optimize-primary-methods-flag, eieio-initializing-object)
(eieio-unbound, eieio-default-superclass)
(eieio--define-field-accessors, method-static, method-before)
(method-primary, method-after, method-num-lists)
(method-generic-before, method-generic-primary)
(method-generic-after, method-num-slots)
(eieio-specialized-key-to-generic-key)
(eieio--check-type, class-v, class-p)
(eieio-class-name, define-obsolete-function-alias)
(eieio-class-parents-fast, eieio-class-children-fast)
(same-class-fast-p, class-constructor, generic-p)
(generic-primary-only-p, generic-primary-only-one-p)
(class-option-assoc, class-option, eieio-object-p)
(class-abstract-p, class-method-invocation-order)
(eieio-defclass-autoload-map, eieio-defclass-autoload)
(eieio-class-un-autoload, eieio-defclass)
(eieio-eval-default-p, eieio-perform-slot-validation-for-default)
(eieio-add-new-slot, eieio-copy-parents-into-subclass)
(eieio--defgeneric-init-form, eieio-defgeneric-form)
(eieio-defgeneric-reset-generic-form)
(eieio-defgeneric-form-primary-only)
(eieio-defgeneric-reset-generic-form-primary-only)
(eieio-defgeneric-form-primary-only-one)
(eieio-defgeneric-reset-generic-form-primary-only-one)
(eieio-unbind-method-implementations)
(eieio--defmethod, eieio--typep)
(eieio-perform-slot-validation, eieio-validate-slot-value)
(eieio-validate-class-slot-value, eieio-barf-if-slot-unbound)
(eieio-oref, eieio-oref-default, eieio-default-eval-maybe)
(eieio-oset, eieio-oset-default, eieio-slot-originating-class-p)
(eieio-slot-name-index, eieio-class-slot-name-index)
(eieio-set-defaults, eieio-initarg-to-attribute)
(eieio-attribute-to-initarg, eieio-c3-candidate)
(eieio-c3-merge-lists, eieio-class-precedence-c3)
(eieio-class-precedence-dfs, eieio-class-precedence-bfs)
(eieio-class-precedence-list, eieio-generic-call-methodname)
(eieio-generic-call-arglst, eieio-generic-call-key)
(eieio-generic-call-next-method-list)
(eieio-pre-method-execution-functions, eieio-generic-call)
(eieio-generic-call-primary-only, eieiomt-method-list)
(eieiomt-optimizing-obarray, eieiomt-install)
(eieiomt-add, eieiomt-next, eieiomt-sym-optimize)
(eieio-generic-form, eieio-defmethod, make-obsolete)
(eieio-defgeneric, make-obsolete): Moved to eieio-core.el
(defclass): Remove `eval-and-compile' from macro.
(call-next-method, shared-initialize): Instead of using
`scoped-class' variable, use new eieio--scoped-class, and
eieio--with-scoped-class.
(initialize-instance): Rename local variable 'scoped-class' to
'this-class' to remove ambiguitity from old global.
* emacs-lisp/eieio-core.el: New file. Derived from key parts of
eieio.el.
(eieio--scoped-class-stack): New variable
(eieio--scoped-class): New fcn
(eieio--with-scoped-class): New scoping macro.
(eieio-defclass): Use pushnew instead of add-to-list.
(eieio-defgeneric-form-primary-only-one, eieio-oset-default)
(eieio-slot-name-index, eieio-set-defaults, eieio-generic-call)
(eieio-generic-call-primary-only, eieiomt-add): Instead of using
`scoped-class' variable, use new eieio--scoped-class, and
eieio--with-scoped-class.
* emacs-lisp/eieio-base.el (cl-lib): Require during compile.
* admin/grammars:
* grammars/srecode-template.wy (variable): Accept a single number
as a variable value. Allows the 'priority' to be set to a number.
(wisent-srecode-template-lexer): Move number up so it can be
created.
* etc/srecode:
* srecode/c.srt (header_guard): Add :c parameter so it works
standalone
* lisp/cedet:
* semantic/edit.el (semantic-change-function): Use
`save-match-data' around running hooks.
* semantic/decorate/mode.el
(semantic-decorate-style-predicate-default)
(semantic-decorate-style-highlighter-default): New.
(semantic-decoration-mode): Do not require
`semantic/decorate/include' anymore.
(semantic-toggle-decoration-style): Error if an unknown decoration
style is toggled.
(define-semantic-decoration-style): Add new :load option. When
:load is specified, add autoload tokens for the definition
functions so that code is loaded when the mode is used.
(semantic-decoration-on-includes): New autoload definition for
highlighting includes.
* semantic/bovine/c.el (semantic-lex-c-ifdef): Allow some misc
characters to appear after the tested variable.
* semantic/ede-grammar.el (project-compile-target): Calculate full
src name via ede-expand-filename instead of the crutch of the
current buffer. Enables this target to compile in batch mode.
* semantic/idle.el
(semantic-idle-symbol-maybe-highlight): Wrap highlighting of
remote symbol with `save-excursion'.
(semantic-idle-scheduler-work-parse-neighboring-files): Instead of
using directory-files on each found mode pattern, collect all the
patterns for the current mode, and then for each file, see if it
matches any of them. If it does, parse the file. (Patch
inspiration from Tomasz Gajewski.)
* semantic/ctxt.el (semantic-ctxt-end-of-symbol): New.
(semantic-ctxt-current-symbol-default): New.
* semantic/bovine/el.el (semantic-default-elisp-setup): Add
autoload cookie. Explain existence.
(footer): Add local variable for loaddefs.
* semantic/db.el (semanticdb-file-table-object): Add new filter,
only checking for regular files too.
* semantic/wisent/python.el
(semantic-format-tag-abbreviate): New override. Cuts back on size
of code tags.
* srecode/compile.el (srecode-compile-templates): Fix warning
punctuation. Remove status messages to clean up testing output
* ede/base.el (ede-project-placeholder-cache-file): Update doc to
mention 'nil' value.
(ede-save-cache): Disable cache save if file is nil.
* ede.el (ede-initialize-state-current-buffer): Flush deleted
projects.
(global-ede-mode): Always append our find-file-hook to the end.
(ede-flush-deleted-projects): New command.
* ede/cpp-root.el (ede-preprocessor-map): Protect against init
problems.
* ede/proj.el (ede-proj-target): Added a new "custom" option for
custom symbols representing a compiler or linker instead of
restricting things to only the predefined compilers and linkers.
* semantic.el (semantic-mode-map): To avoid showing showing
Development menu twice, only disable menu item if menu-bar is
actually enabled, otherwise the popup 'global menu' might display
a disabled Development menu.
* semantic/complete.el
(semantic-displayor-show-request): Fix which slot in obj is set to
the max tags.
2013-06-02 13:33:09 +00:00
|
|
|
|
(slot (eieio--class-public-a this-class))
|
|
|
|
|
(defaults (eieio--class-public-d this-class)))
|
|
|
|
|
(while slot
|
|
|
|
|
;; For each slot, see if we need to evaluate it.
|
|
|
|
|
;;
|
|
|
|
|
;; Paul Landes said in an email:
|
|
|
|
|
;; > CL evaluates it if it can, and otherwise, leaves it as
|
|
|
|
|
;; > the quoted thing as you already have. This is by the
|
|
|
|
|
;; > Sonya E. Keene book and other things I've look at on the
|
|
|
|
|
;; > web.
|
|
|
|
|
(let ((dflt (eieio-default-eval-maybe (car defaults))))
|
|
|
|
|
(when (not (eq dflt (car defaults)))
|
|
|
|
|
(eieio-oset this (car slot) dflt) ))
|
|
|
|
|
;; Next.
|
|
|
|
|
(setq slot (cdr slot)
|
|
|
|
|
defaults (cdr defaults))))
|
|
|
|
|
;; Shared initialize will parse our slots for us.
|
|
|
|
|
(shared-initialize this slots))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
(defgeneric slot-missing (object slot-name operation &optional new-value)
|
|
|
|
|
"Method invoked when an attempt to access a slot in OBJECT fails.")
|
|
|
|
|
|
|
|
|
|
(defmethod slot-missing ((object eieio-default-superclass) slot-name
|
2014-10-17 05:09:24 +00:00
|
|
|
|
_operation &optional _new-value)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
"Method invoked when an attempt to access a slot in OBJECT fails.
|
|
|
|
|
SLOT-NAME is the name of the failed slot, OPERATION is the type of access
|
|
|
|
|
that was requested, and optional NEW-VALUE is the value that was desired
|
|
|
|
|
to be set.
|
|
|
|
|
|
|
|
|
|
This method is called from `oref', `oset', and other functions which
|
|
|
|
|
directly reference slots in EIEIO objects."
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(signal 'invalid-slot-name (list (eieio-object-name object)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
slot-name)))
|
|
|
|
|
|
|
|
|
|
(defgeneric slot-unbound (object class slot-name fn)
|
|
|
|
|
"Slot unbound is invoked during an attempt to reference an unbound slot.")
|
|
|
|
|
|
|
|
|
|
(defmethod slot-unbound ((object eieio-default-superclass)
|
|
|
|
|
class slot-name fn)
|
|
|
|
|
"Slot unbound is invoked during an attempt to reference an unbound slot.
|
|
|
|
|
OBJECT is the instance of the object being reference. CLASS is the
|
|
|
|
|
class of OBJECT, and SLOT-NAME is the offending slot. This function
|
|
|
|
|
throws the signal `unbound-slot'. You can overload this function and
|
|
|
|
|
return the value to use in place of the unbound value.
|
|
|
|
|
Argument FN is the function signaling this error.
|
|
|
|
|
Use `slot-boundp' to determine if a slot is bound or not.
|
|
|
|
|
|
|
|
|
|
In CLOS, the argument list is (CLASS OBJECT SLOT-NAME), but
|
|
|
|
|
EIEIO can only dispatch on the first argument, so the first two are swapped."
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(signal 'unbound-slot (list (eieio-class-name class) (eieio-object-name object)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
slot-name fn)))
|
|
|
|
|
|
|
|
|
|
(defgeneric no-applicable-method (object method &rest args)
|
|
|
|
|
"Called if there are no implementations for OBJECT in METHOD.")
|
|
|
|
|
|
|
|
|
|
(defmethod no-applicable-method ((object eieio-default-superclass)
|
2014-10-17 05:09:24 +00:00
|
|
|
|
method &rest _args)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
"Called if there are no implementations for OBJECT in METHOD.
|
|
|
|
|
OBJECT is the object which has no method implementation.
|
|
|
|
|
ARGS are the arguments that were passed to METHOD.
|
|
|
|
|
|
|
|
|
|
Implement this for a class to block this signal. The return
|
|
|
|
|
value becomes the return value of the original method call."
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(signal 'no-method-definition (list method (eieio-object-name object)))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(defgeneric no-next-method (object &rest args)
|
|
|
|
|
"Called from `call-next-method' when no additional methods are available.")
|
|
|
|
|
|
|
|
|
|
(defmethod no-next-method ((object eieio-default-superclass)
|
|
|
|
|
&rest args)
|
|
|
|
|
"Called from `call-next-method' when no additional methods are available.
|
|
|
|
|
OBJECT is othe object being called on `call-next-method'.
|
2009-10-05 15:32:08 +00:00
|
|
|
|
ARGS are the arguments it is called by.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
This method signals `no-next-method' by default. Override this
|
2009-10-05 15:32:08 +00:00
|
|
|
|
method to not throw an error, and its return value becomes the
|
2009-09-28 00:49:54 +00:00
|
|
|
|
return value of `call-next-method'."
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(signal 'no-next-method (list (eieio-object-name object) args))
|
2012-10-12 20:07:58 +00:00
|
|
|
|
)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
(defgeneric clone (obj &rest params)
|
|
|
|
|
"Make a copy of OBJ, and then supply PARAMS.
|
|
|
|
|
PARAMS is a parameter list of the same form used by `initialize-instance'.
|
|
|
|
|
|
|
|
|
|
When overloading `clone', be sure to call `call-next-method'
|
|
|
|
|
first and modify the returned object.")
|
|
|
|
|
|
|
|
|
|
(defmethod clone ((obj eieio-default-superclass) &rest params)
|
|
|
|
|
"Make a copy of OBJ, and then apply PARAMS."
|
2014-12-23 03:05:46 +00:00
|
|
|
|
(let ((nobj (copy-sequence obj)))
|
|
|
|
|
(if (stringp (car params))
|
|
|
|
|
(message "Obsolete name %S passed to clone" (pop params)))
|
|
|
|
|
(if params (shared-initialize nobj params))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
nobj))
|
|
|
|
|
|
|
|
|
|
(defgeneric destructor (this &rest params)
|
|
|
|
|
"Destructor for cleaning up any dynamic links to our object.")
|
|
|
|
|
|
2014-10-17 05:09:24 +00:00
|
|
|
|
(defmethod destructor ((_this eieio-default-superclass) &rest _params)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
"Destructor for cleaning up any dynamic links to our object.
|
|
|
|
|
Argument THIS is the object being destroyed. PARAMS are additional
|
|
|
|
|
ignored parameters."
|
|
|
|
|
;; No cleanup... yet.
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(defgeneric object-print (this &rest strings)
|
|
|
|
|
"Pretty printer for object THIS. Call function `object-name' with STRINGS.
|
|
|
|
|
|
|
|
|
|
It is sometimes useful to put a summary of the object into the
|
2009-10-05 15:32:08 +00:00
|
|
|
|
default #<notation> string when using EIEIO browsing tools.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
Implement this method to customize the summary.")
|
|
|
|
|
|
|
|
|
|
(defmethod object-print ((this eieio-default-superclass) &rest strings)
|
|
|
|
|
"Pretty printer for object THIS. Call function `object-name' with STRINGS.
|
|
|
|
|
The default method for printing object THIS is to use the
|
|
|
|
|
function `object-name'.
|
|
|
|
|
|
|
|
|
|
It is sometimes useful to put a summary of the object into the
|
2009-10-05 15:32:08 +00:00
|
|
|
|
default #<notation> string when using EIEIO browsing tools.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
Implement this function and specify STRINGS in a call to
|
|
|
|
|
`call-next-method' to provide additional summary information.
|
|
|
|
|
When passing in extra strings from child classes, always remember
|
|
|
|
|
to prepend a space."
|
2014-10-17 05:09:24 +00:00
|
|
|
|
(eieio-object-name this (apply #'concat strings)))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
(defvar eieio-print-depth 0
|
|
|
|
|
"When printing, keep track of the current indentation depth.")
|
|
|
|
|
|
|
|
|
|
(defgeneric object-write (this &optional comment)
|
|
|
|
|
"Write out object THIS to the current stream.
|
2009-10-05 15:32:08 +00:00
|
|
|
|
Optional COMMENT will add comments to the beginning of the output.")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
(defmethod object-write ((this eieio-default-superclass) &optional comment)
|
|
|
|
|
"Write object THIS out to the current stream.
|
|
|
|
|
This writes out the vector version of this object. Complex and recursive
|
|
|
|
|
object are discouraged from being written.
|
|
|
|
|
If optional COMMENT is non-nil, include comments when outputting
|
|
|
|
|
this object."
|
|
|
|
|
(when comment
|
|
|
|
|
(princ ";; Object ")
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(princ (eieio-object-name-string this))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(princ "\n")
|
|
|
|
|
(princ comment)
|
|
|
|
|
(princ "\n"))
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(let* ((cl (eieio-object-class this))
|
2014-12-22 20:46:16 +00:00
|
|
|
|
(cv (eieio--class-v cl)))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
;; Now output readable lisp to recreate this object
|
|
|
|
|
;; It should look like this:
|
|
|
|
|
;; (<constructor> <name> <slot> <slot> ... )
|
|
|
|
|
;; Each slot's slot is writen using its :writer.
|
|
|
|
|
(princ (make-string (* eieio-print-depth 2) ? ))
|
|
|
|
|
(princ "(")
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(princ (symbol-name (class-constructor (eieio-object-class this))))
|
2012-10-01 18:10:29 +00:00
|
|
|
|
(princ " ")
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(prin1 (eieio-object-name-string this))
|
2012-10-01 18:10:29 +00:00
|
|
|
|
(princ "\n")
|
2009-09-28 00:49:54 +00:00
|
|
|
|
;; Loop over all the public slots
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(let ((publa (eieio--class-public-a cv))
|
|
|
|
|
(publd (eieio--class-public-d cv))
|
|
|
|
|
(publp (eieio--class-public-printer cv))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(eieio-print-depth (1+ eieio-print-depth)))
|
|
|
|
|
(while publa
|
|
|
|
|
(when (slot-boundp this (car publa))
|
2015-01-05 04:11:37 +00:00
|
|
|
|
(let ((i (eieio--class-slot-initarg cv (car publa)))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(v (eieio-oref this (car publa)))
|
|
|
|
|
)
|
|
|
|
|
(unless (or (not i) (equal v (car publd)))
|
2012-12-12 02:16:05 +00:00
|
|
|
|
(unless (bolp)
|
|
|
|
|
(princ "\n"))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(princ (make-string (* eieio-print-depth 2) ? ))
|
|
|
|
|
(princ (symbol-name i))
|
|
|
|
|
(if (car publp)
|
|
|
|
|
;; Use our public printer
|
2012-12-12 02:16:05 +00:00
|
|
|
|
(progn
|
|
|
|
|
(princ " ")
|
|
|
|
|
(funcall (car publp) v))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
;; Use our generic override prin1 function.
|
2012-12-12 02:16:05 +00:00
|
|
|
|
(princ (if (or (eieio-object-p v)
|
|
|
|
|
(eieio-object-p (car-safe v)))
|
|
|
|
|
"\n" " "))
|
|
|
|
|
(eieio-override-prin1 v)))))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(setq publa (cdr publa) publd (cdr publd)
|
2012-12-12 02:16:05 +00:00
|
|
|
|
publp (cdr publp))))
|
|
|
|
|
(princ ")")
|
|
|
|
|
(when (= eieio-print-depth 0)
|
|
|
|
|
(princ "\n"))))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
(defun eieio-override-prin1 (thing)
|
2009-10-05 15:32:08 +00:00
|
|
|
|
"Perform a `prin1' on THING taking advantage of object knowledge."
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(cond ((eieio-object-p thing)
|
|
|
|
|
(object-write thing))
|
2012-12-12 02:16:05 +00:00
|
|
|
|
((consp thing)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(eieio-list-prin1 thing))
|
|
|
|
|
((class-p thing)
|
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.
2013-02-19 02:57:04 +00:00
|
|
|
|
(princ (eieio-class-name thing)))
|
2012-12-12 02:16:05 +00:00
|
|
|
|
((or (keywordp thing) (booleanp thing))
|
|
|
|
|
(prin1 thing))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
((symbolp thing)
|
|
|
|
|
(princ (concat "'" (symbol-name thing))))
|
|
|
|
|
(t (prin1 thing))))
|
|
|
|
|
|
|
|
|
|
(defun eieio-list-prin1 (list)
|
|
|
|
|
"Display LIST where list may contain objects."
|
|
|
|
|
(if (not (eieio-object-p (car list)))
|
|
|
|
|
(progn
|
|
|
|
|
(princ "'")
|
|
|
|
|
(prin1 list))
|
|
|
|
|
(princ (make-string (* eieio-print-depth 2) ? ))
|
2012-12-12 02:16:05 +00:00
|
|
|
|
(princ "(list")
|
|
|
|
|
(let ((eieio-print-depth (1+ eieio-print-depth)))
|
|
|
|
|
(while list
|
|
|
|
|
(princ "\n")
|
|
|
|
|
(if (eieio-object-p (car list))
|
|
|
|
|
(object-write (car list))
|
|
|
|
|
(princ (make-string (* eieio-print-depth 2) ? ))
|
|
|
|
|
(eieio-override-prin1 (car list)))
|
|
|
|
|
(setq list (cdr list))))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(princ ")")))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Unimplemented functions from CLOS
|
|
|
|
|
;;
|
2014-10-17 05:09:24 +00:00
|
|
|
|
(defun change-class (_obj _class)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
"Change the class of OBJ to type CLASS.
|
|
|
|
|
This may create or delete slots, but does not affect the return value
|
|
|
|
|
of `eq'."
|
2009-10-05 15:32:08 +00:00
|
|
|
|
(error "EIEIO: `change-class' is unimplemented"))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
2014-01-08 21:30:12 +00:00
|
|
|
|
;; Hook ourselves into help system for describing classes and methods.
|
|
|
|
|
(add-hook 'help-fns-describe-function-functions 'eieio-help-generic)
|
|
|
|
|
(add-hook 'help-fns-describe-function-functions 'eieio-help-constructor)
|
|
|
|
|
|
2009-09-28 00:49:54 +00:00
|
|
|
|
;;; Interfacing with edebug
|
|
|
|
|
;;
|
2014-11-02 15:24:33 +00:00
|
|
|
|
(defun eieio-edebug-prin1-to-string (print-function object &optional noescape)
|
2009-10-05 15:32:08 +00:00
|
|
|
|
"Display EIEIO OBJECT in fancy format.
|
2014-11-02 15:24:33 +00:00
|
|
|
|
|
|
|
|
|
Used as advice around `edebug-prin1-to-string', held in the
|
|
|
|
|
variable PRINT-FUNCTION. Optional argument NOESCAPE is passed to
|
|
|
|
|
`prin1-to-string' when appropriate."
|
2015-01-05 04:11:37 +00:00
|
|
|
|
(cond ((eieio--class-p object) (eieio-class-name object))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
((eieio-object-p object) (object-print object))
|
2015-01-05 04:11:37 +00:00
|
|
|
|
((and (listp object) (or (eieio--class-p (car object))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
(eieio-object-p (car object))))
|
2015-01-05 04:11:37 +00:00
|
|
|
|
(concat "(" (mapconcat
|
|
|
|
|
(lambda (x) (eieio-edebug-prin1-to-string print-function x))
|
|
|
|
|
object " ")
|
2014-10-17 05:09:24 +00:00
|
|
|
|
")"))
|
2014-11-02 15:24:33 +00:00
|
|
|
|
(t (funcall print-function object noescape))))
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
2014-12-22 20:46:16 +00:00
|
|
|
|
(advice-add 'edebug-prin1-to-string
|
|
|
|
|
:around #'eieio-edebug-prin1-to-string)
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
2011-02-18 08:00:08 +00:00
|
|
|
|
|
|
|
|
|
;;; Start of automatically extracted autoloads.
|
|
|
|
|
|
2015-01-05 04:11:37 +00:00
|
|
|
|
;;;### (autoloads nil "eieio-custom" "eieio-custom.el" "a3f314e2a27e52444df4597c6ae51458")
|
2011-02-18 08:00:08 +00:00
|
|
|
|
;;; Generated autoloads from eieio-custom.el
|
|
|
|
|
|
|
|
|
|
(autoload 'customize-object "eieio-custom" "\
|
|
|
|
|
Customize OBJ in a custom buffer.
|
|
|
|
|
Optional argument GROUP is the sub-group of slots to display.
|
|
|
|
|
|
|
|
|
|
\(fn OBJ &optional GROUP)" nil nil)
|
|
|
|
|
|
|
|
|
|
;;;***
|
|
|
|
|
|
2014-12-23 03:05:46 +00:00
|
|
|
|
;;;### (autoloads nil "eieio-opt" "eieio-opt.el" "2ff7d98da3f84c6af5c873ffb781930e")
|
2011-02-18 08:00:08 +00:00
|
|
|
|
;;; Generated autoloads from eieio-opt.el
|
|
|
|
|
|
|
|
|
|
(autoload 'eieio-browse "eieio-opt" "\
|
|
|
|
|
Create an object browser window to show all objects.
|
|
|
|
|
If optional ROOT-CLASS, then start with that, otherwise start with
|
|
|
|
|
variable `eieio-default-superclass'.
|
|
|
|
|
|
|
|
|
|
\(fn &optional ROOT-CLASS)" t nil)
|
|
|
|
|
|
2014-01-09 20:31:21 +00:00
|
|
|
|
(autoload 'eieio-help-class "eieio-opt" "\
|
|
|
|
|
Print help description for CLASS.
|
2011-02-18 08:00:08 +00:00
|
|
|
|
If CLASS is actually an object, then also display current values of that object.
|
|
|
|
|
|
2014-01-09 20:31:21 +00:00
|
|
|
|
\(fn CLASS)" nil nil)
|
2011-02-18 08:00:08 +00:00
|
|
|
|
|
2014-01-09 20:31:21 +00:00
|
|
|
|
(autoload 'eieio-help-constructor "eieio-opt" "\
|
|
|
|
|
Describe CTR if it is a class constructor.
|
2011-02-18 08:00:08 +00:00
|
|
|
|
|
2014-01-09 20:31:21 +00:00
|
|
|
|
\(fn CTR)" nil nil)
|
2011-02-18 08:00:08 +00:00
|
|
|
|
|
2014-01-09 20:31:21 +00:00
|
|
|
|
(autoload 'eieio-help-generic "eieio-opt" "\
|
|
|
|
|
Describe GENERIC if it is a generic function.
|
2011-02-18 08:00:08 +00:00
|
|
|
|
|
2014-01-09 20:31:21 +00:00
|
|
|
|
\(fn GENERIC)" nil nil)
|
2011-02-18 08:00:08 +00:00
|
|
|
|
|
|
|
|
|
;;;***
|
|
|
|
|
|
|
|
|
|
;;; End of automatically extracted autoloads.
|
2009-09-28 00:49:54 +00:00
|
|
|
|
|
|
|
|
|
(provide 'eieio)
|
|
|
|
|
|
|
|
|
|
;;; eieio ends here
|