src/class-make-proto.lisp: Choose Lisp metaclass more cleverly.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 30 Aug 2015 09:58:38 +0000 (10:58 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 20 Sep 2015 10:01:54 +0000 (11:01 +0100)
Use the same algorithm as is used to choose the runtime metaclass:
if a property names a class explicitly then use that; otherwise, choose
the most specific metaclass of any of the direct superclasses.  If there
are no proper superclasses then default to `sod-class' because that's
what `builtin' needs.

src/class-make-proto.lisp

index c04727c..8b024bd 100644 (file)
 
   (with-default-error-location (location)
     (let* ((pset (property-set pset))
-          (class (make-instance (get-property pset :lisp-metaclass :symbol
-                                              'sod-class)
+          (best-class (or (get-property pset :lisp-metaclass :symbol nil)
+                          (if superclasses
+                              (maximum (mapcar #'class-of superclasses)
+                                       #'subtypep
+                                       (format nil "Lisp metaclass for ~A"
+                                               name))
+                              'sod-class)))
+          (class (make-instance best-class
                                 :name name
                                 :superclasses superclasses
                                 :location (file-location location)