(list (cl-prin1-to-string (cl--slot-descriptor-name slot))
(cl-prin1-to-string (cl--slot-descriptor-type slot))
(cl-prin1-to-string (cl--slot-descriptor-initform slot))
- (let ((doc
- ;; The props are an alist in a `defclass',
- ;; but a plist when describing a `cl-defstruct'.
- (if (consp (car (cl--slot-descriptor-props slot)))
- (alist-get :documentation
- (cl--slot-descriptor-props slot))
- (plist-get (cl--slot-descriptor-props slot)
- :documentation))))
+ (let ((doc (alist-get :documentation
+ (cl--slot-descriptor-props slot))))
(if (not doc) ""
(setq has-doc t)
(substitute-command-keys doc)))))
(get name 'cl-struct-print))
(cl--find-class name)))))
-(defun cl--plist-remove (plist member)
- (cond
- ((null plist) nil)
- ((null member) plist)
- ((eq plist member) (cddr plist))
- (t `(,(car plist) ,(cadr plist) ,@(cl--plist-remove (cddr plist) member)))))
+(defun cl--plist-to-alist (plist)
+ (let ((res '()))
+ (while plist
+ (push (cons (pop plist) (pop plist)) res))
+ (nreverse res)))
(defun cl--struct-register-child (parent tag)
;; Can't use (cl-typep parent 'cl-structure-class) at this stage
(i 0)
(offset (if type 0 1)))
(dolist (slot slots)
- (let* ((props (cddr slot))
- (typep (plist-member props :type))
- (type (if typep (cadr typep) t)))
+ (let* ((props (cl--plist-to-alist (cddr slot)))
+ (typep (assq :type props))
+ (type (if (null typep) t
+ (setq props (delq typep props))
+ (cdr typep))))
(aset v i (cl--make-slot-desc
(car slot) (nth 1 slot)
- type (cl--plist-remove props typep))))
+ type props)))
(puthash (car slot) (+ i offset) index-table)
(cl-incf i))
v))