(built-in-class--make): Take list of types rather than classes

Consolidate the conversion from types to classes into
`built-in-class--make` instead of duplicating it in ever caller.

* lisp/emacs-lisp/cl-preloaded.el (built-in-class--make): Take list of
types rather than classes.
(cl--define-built-in-type): Simplify accordingly.
This commit is contained in:
Stefan Monnier 2025-03-25 02:09:48 -04:00
parent c3492b969d
commit 7ec0ee742d

View file

@ -292,7 +292,13 @@
(:include cl--class)
(:noinline t)
(:constructor nil)
(:constructor built-in-class--make (name docstring parents))
(:constructor built-in-class--make
(name docstring parent-types
&aux (parents
(mapcar (lambda (type)
(or (get type 'cl--class)
(error "Unknown type: %S" type)))
parent-types))))
(:copier nil))
"Type descriptors for built-in types.
The `slots' (and hence `index-table') are currently unused."
@ -322,13 +328,7 @@ The `slots' (and hence `index-table') are currently unused."
;; (message "Missing predicate for: %S" name)
nil)
(put ',name 'cl--class
(built-in-class--make ',name ,docstring
(mapcar (lambda (type)
(let ((class (get type 'cl--class)))
(unless class
(error "Unknown type: %S" type))
class))
',parents))))))
(built-in-class--make ',name ,docstring ',parents)))))
;; FIXME: Our type DAG has various quirks:
;; - Some `keyword's are also `symbol-with-pos' but that's not reflected