src/class-output.lisp: Leave `*instance-class*' unbound at top-level.
[sod] / src / class-make-impl.lisp
index b96d830..02fd5f5 100644 (file)
 ;;; Slot initializers.
 
 (defmethod make-sod-instance-initializer
-    ((class sod-class) nick name value pset &key location inhibit-initargs)
+    ((class sod-class) nick name value pset
+     &key location inhibit-initargs (add-to-class t))
   (with-default-error-location (location)
     (let* ((slot (find-instance-slot-by-name class nick name))
           (initarg-name (get-property pset :initarg :id))
        (when (and initarg-name (not inhibit-initargs))
          (make-sod-slot-initarg-using-slot class initarg-name slot pset
                                            :location location))
-       (when initializer
+       (when (and initializer add-to-class)
          (setf instance-initializers
                (append instance-initializers (list initializer)))))
       initializer)))
 
 (defmethod make-sod-class-initializer
-    ((class sod-class) nick name value pset &key location)
+    ((class sod-class) nick name value pset &key location (add-to-class t))
   (with-default-error-location (location)
     (let* ((slot (find-class-slot-by-name class nick name))
           (initializer (make-sod-initializer-using-slot
                         class slot 'sod-class-initializer
                         value pset (file-location location))))
-      (with-slots (class-initializers) class
-       (setf class-initializers
-             (append class-initializers (list initializer))))
+      (when add-to-class
+       (with-slots (class-initializers) class
+         (setf class-initializers
+               (append class-initializers (list initializer)))))
       initializer)))
 
 (defmethod make-sod-initializer-using-slot
 
 (defmethod shared-initialize :after
     ((message sod-message) slot-names &key pset)
-  (declare (ignore slot-names pset))
   (with-slots ((type %type)) message
-    (check-message-type message type)))
+    (check-message-type message type))
+  (default-slot-from-property (message 'readonlyp slot-names)
+      (pset :readonly :boolean)
+    nil))
 
 (defmethod check-message-type ((message sod-message) (type c-function-type))
   nil)