mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-06 03:40:56 -08:00
eieio-core.el: Make slot-value work on defstructs
Adjust the values in EIEIO's index-tables so they are compatible with those of defstructs. * lisp/emacs-lisp/eieio-core.el (eieio--slot-name-index): Don't add the `eieio--object-num-slots` offset. (eieio-defclass-internal): Add the `eieio--object-num-slots` offset here instead. (eieio-oref): Allow its use on `cl-structure-object`. * lisp/emacs-lisp/eieio.el (eieio-pcase-slot-index-from-index-table): Don't need to add the `eieio--object-num-slots` offset. * doc/misc/eieio.texi (Accessing Slots, Accessing Slots): Mention the use on structs. * test/lisp/emacs-lisp/eieio-tests/eieio-tests.el (eieio-test-defstruct-slot-value): New test.
This commit is contained in:
parent
c062c9d4db
commit
d553e603f4
5 changed files with 28 additions and 11 deletions
|
|
@ -359,9 +359,7 @@ variable name of the same name as the slot."
|
|||
|
||||
(defun eieio-pcase-slot-index-from-index-table (index-table slot)
|
||||
"Find the index to pass to `aref' to access SLOT."
|
||||
(let ((index (gethash slot index-table)))
|
||||
(if index (+ (eval-when-compile eieio--object-num-slots)
|
||||
index))))
|
||||
(gethash slot index-table))
|
||||
|
||||
(pcase-defmacro eieio (&rest fields)
|
||||
"Pcase patterns that match EIEIO object EXPVAL.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue