]> git.eshelyaron.com Git - emacs.git/commitdiff
(built-in-class--make): Take list of types rather than classes
authorStefan Monnier <monnier@iro.umontreal.ca>
Tue, 25 Mar 2025 06:09:48 +0000 (02:09 -0400)
committerEshel Yaron <me@eshelyaron.com>
Tue, 25 Mar 2025 18:20:07 +0000 (19:20 +0100)
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.

(cherry picked from commit 7ec0ee742da17864b554e2cf4384d2a12baaf1e8)

lisp/emacs-lisp/cl-preloaded.el

index 7017fcd5b8360c7a026f36f264a3afe316e86eec..dfea8d6c8e38e184fb4177da843a6a24b7839106 100644 (file)
                (: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