Function: eieio-oref

eieio-oref is a byte-compiled function defined in eieio-core.el.gz.

Signature

(eieio-oref OBJ SLOT)

Documentation

Return the value in OBJ at SLOT in the object vector.

This function has :around advice: eieio-oref@closql-object.

Aliases

slot-value

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/eieio-core.el.gz
;;; Get/Set slots in an object.

(defun eieio-oref (obj slot)
  "Return the value in OBJ at SLOT in the object vector."
  (declare (compiler-macro
            (lambda (exp)
              (ignore obj)
              (pcase slot
                ((and (or `',name (and name (pred keywordp)))
                      (guard (not (eieio--known-slot-name-p name))))
                 (macroexp-warn-and-return
                  (format-message "Unknown slot `%S'" name)
                  exp nil 'compile-only name))
                (_ exp))))
           ;; FIXME: Make it a gv-expander such that the hash-table lookup is
           ;; only performed once when used in `push' and friends?
           (gv-setter eieio-oset))
  (cl-check-type slot symbol)
  (cond
   ((cl-typep obj '(or eieio-object cl-structure-object))
    (let* ((class (eieio--object-class obj))
           (c (eieio--slot-name-index class slot)))
      (if (not c)
	  ;; It might be missing because it is a :class allocated slot.
	  ;; Let's check that info out.
	  (if (setq c (eieio--class-slot-name-index class slot))
	      ;; Oref that slot.
	      (aref (eieio--class-class-allocation-values class) c)
	    ;; The slot-missing method is a cool way of allowing an object author
	    ;; to intercept missing slot definitions.  Since it is also the LAST
	    ;; thing called in this fn, its return value would be retrieved.
	    (slot-missing obj slot 'oref))
	(eieio-barf-if-slot-unbound (aref obj c) obj slot 'oref))))
   ((cl-typep obj 'oclosure) (oclosure--slot-value obj slot))
   (t
    (signal 'wrong-type-argument
            (list '(or eieio-object cl-structure-object oclosure) obj)))))