Function: eieio-persistent-fix-value
eieio-persistent-fix-value is a byte-compiled function defined in
eieio-base.el.gz.
Signature
(eieio-persistent-fix-value PROPOSED-VALUE)
Documentation
Fix PROPOSED-VALUE.
Remove leading quotes from lists, and the symbol list from the
head of lists. Explicitly construct any objects found, and strip
any text properties from string values.
This function will descend into the contents of lists, hash tables, and vectors.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/eieio-base.el.gz
(defun eieio-persistent-fix-value (proposed-value)
"Fix PROPOSED-VALUE.
Remove leading quotes from lists, and the symbol `list' from the
head of lists. Explicitly construct any objects found, and strip
any text properties from string values.
This function will descend into the contents of lists, hash
tables, and vectors."
(cond ((consp proposed-value)
;; Lists with something in them need special treatment.
(cond ((eq (car proposed-value) 'quote)
(while (eq (car-safe proposed-value) 'quote)
(setq proposed-value (car (cdr proposed-value))))
proposed-value)
;; An empty list sometimes shows up as (list), which is dumb, but
;; we need to support it for backward compar.
((and (eq (car proposed-value) 'list)
(= (length proposed-value) 1))
nil)
;; List of object constructors.
((and (eq (car proposed-value) 'list)
;; 2nd item is a list.
(consp (car (cdr proposed-value)))
;; 1st elt of 2nd item is a class name.
(class-p (car (car (cdr proposed-value)))))
;; We have a list of objects here. Lets load them
;; in.
(let ((objlist nil))
(dolist (subobj (cdr proposed-value))
(push (eieio-persistent-make-instance
(car subobj) (cdr subobj))
objlist))
;; return the list of objects ... reversed.
(nreverse objlist)))
;; We have a slot with a single object that can be
;; saved here. Recurse and evaluate that
;; sub-object.
((class-p (car proposed-value))
(eieio-persistent-make-instance
(car proposed-value) (cdr proposed-value)))
(t
proposed-value)))
;; For hash-tables and vectors, the top-level `read' will not
;; "look inside" member values, so we need to do that
;; explicitly. Because `eieio-override-prin1' is recursive in
;; the case of hash-tables and vectors, we recurse
;; `eieio-persistent-validate/fix-slot-value' here as well.
((hash-table-p proposed-value)
(maphash
(lambda (key value)
(setf (gethash key proposed-value)
(if (class-p (car-safe value))
(eieio-persistent-make-instance
(car value) (cdr value))
(eieio-persistent-fix-value value))))
proposed-value)
proposed-value)
((vectorp proposed-value)
(dotimes (i (length proposed-value))
(let ((val (aref proposed-value i)))
(aset proposed-value i
(if (class-p (car-safe val))
(eieio-persistent-make-instance
(car val) (cdr val))
(eieio-persistent-fix-value val)))))
proposed-value)
((stringp proposed-value)
;; Else, check for strings, remove properties.
(substring-no-properties proposed-value))
(t
;; Else, just return whatever the constant was.
proposed-value)))