Function: cl--old-struct-type-of

cl--old-struct-type-of is a byte-compiled function defined in cl-lib.el.gz.

Signature

(cl--old-struct-type-of ORIG-FUN OBJECT)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-lib.el.gz
(defun cl--old-struct-type-of (orig-fun object)
  (or (and (vectorp object) (> (length object) 0)
           (let ((tag (aref object 0)))
             (when (and (symbolp tag)
                        (string-prefix-p "cl-struct-" (symbol-name tag)))
               (unless (eq (symbol-function tag)
                           :quick-object-witness-check)
                 ;; Old-style old-style struct:
                 ;; Convert to new-style old-style struct!
                 (let* ((type (intern (substring (symbol-name tag)
                                                 (length "cl-struct-"))))
                        (class (cl--struct-get-class type)))
                   ;; If the `cl-defstruct' was recompiled after the code
                   ;; which constructed `object', `cl--struct-get-class' may
                   ;; not have called `cl-struct-define' and setup the tag
                   ;; symbol for us.
                   (unless (eq (symbol-function tag)
                               :quick-object-witness-check)
                     (set tag class)
                     (fset tag :quick-object-witness-check))))
               (cl--class-name (symbol-value tag)))))
      (funcall orig-fun object)))