chiark / gitweb /
src/method-impl.lisp: Initialize `suppliedp' flags properly.
[sod] / src / classes.lisp
index d403d109e60fdbe131a4428b983ecb15b804c237..9484141060402e97cee2514b46e51058bf3c3706 100644 (file)
@@ -48,7 +48,7 @@ (export '(sod-class sod-class-name sod-class-nickname
          sod-class-direct-superclasses sod-class-precedence-list
          sod-class-chain-link sod-class-chain-head
          sod-class-chain sod-class-chains
-         sod-class-slots
+         sod-class-slots sod-class-initfrags sod-class-tearfrags
          sod-class-instance-initializers sod-class-class-initializers
          sod-class-messages sod-class-methods
          sod-class-state
@@ -71,6 +71,12 @@ (defclass sod-class ()
                          :accessor sod-class-instance-initializers)
    (class-initializers :initarg :class-initializers :initform nil
                       :type list :accessor sod-class-class-initializers)
+   (initargs :initarg :initargs :initform nil
+            :type list :accessor sod-class-initargs)
+   (initfrags :initarg :initfrags :initform nil
+             :type list :accessor sod-class-initfrags)
+   (tearfrags :initarg :tearfrags :initform nil
+             :type list :accessor sod-class-tearfrags)
    (messages :initarg :messages :initform nil
             :type list :accessor sod-class-messages)
    (methods :initarg :methods :initform nil
@@ -254,16 +260,13 @@ (defmethod print-object ((slot sod-slot) stream)
                           (sod-slot-name slot)))))
 
 (export '(sod-initializer sod-initializer-slot sod-initializer-class
-         sod-initializer-value-kind sod-initializer-value-form))
+         sod-initializer-value))
 (defclass sod-initializer ()
   ((slot :initarg :slot :type sod-slot :reader sod-initializer-slot)
    (location :initarg :location :initform (file-location nil)
             :type file-location :reader file-location)
    (%class :initarg :class :type sod-class :reader sod-initializer-class)
-   (value-kind :initarg :value-kind :type keyword
-              :reader sod-initializer-value-kind)
-   (value-form :initarg :value-form :type c-fragment
-              :reader sod-initializer-value-form))
+   (value :initarg :value :type c-fragment :reader sod-initializer-value))
   (:documentation
    "Provides an initial value for a slot.
 
@@ -274,7 +277,7 @@ (defclass sod-initializer ()
      * The LOCATION states the position in the user's source file where the
        initializer was found.  This gets used in error messages.  (Depending
        on the source layout style, this might differ from the location in the
-       VALUE-FORM C fragment.)
+       VALUE C fragment.)
 
      * The CLASS states which class defined this initializer.  For instance
        slot initializers (`sod-instance-initializer'), this will be the same
@@ -282,23 +285,18 @@ (defclass sod-initializer ()
        initializers (`sod-class-initializer'), this will be an instance of
        the SLOT's class, or an instance of one of its descendants.
 
-     * The VALUE-KIND states what manner of initializer we have.  It can be
-       either `:single', indicating a standalone expression, or `:compound',
-       indicating a compound initializer which must be surrounded by braces
-       on output.
-
-     * The VALUE-FORM gives the text of the initializer, as a C fragment.
+     * The VALUE gives the text of the initializer, as a C fragment.
 
    Typically you'll see instances of subclasses of this class in the wild
    rather than instances of this class directly.  See `sod-class-initializer'
    and `sod-instance-initializer'."))
 
 (defmethod print-object ((initializer sod-initializer) stream)
-  (with-slots (slot value-kind value-form) initializer
+  (with-slots (slot value) initializer
     (if *print-escape*
        (print-unreadable-object (initializer stream :type t)
-         (format stream "~A = ~A" slot value-form))
-       (format stream "~:[{~A}~;~A~]" (eq value-kind :single) value-form))))
+         (format stream "~A = ~A" slot value))
+       (format stream "~A" value))))
 
 (export 'sod-class-initializer)
 (defclass sod-class-initializer (sod-initializer)
@@ -308,7 +306,7 @@ (defclass sod-class-initializer (sod-initializer)
 
    A class slot initializer provides an initial value for a slot in the class
    object (i.e., one of the slots defined by the class's metaclass).  Its
-   VALUE-FORM must have the syntax of an initializer, and its consituent
+   VALUE must have the syntax of an initializer, and its consituent
    expressions must be constant expressions.
 
    See `sod-initializer' for more details."))
@@ -320,13 +318,35 @@ (defclass sod-instance-initializer (sod-initializer)
    "Provides an initial value for a slot in all instances.
 
    An instance slot initializer provides an initial value for a slot in
-   instances of the class.  Its VALUE-FORM must have the syntax of an
-   initializer.  Furthermore, if the slot has aggregate type, then you'd
-   better be sure that your compiler supports compound literals (6.5.2.5)
-   because that's what the initializer gets turned into.
+   instances of the class.  Its VALUE must have the syntax of an initializer.
+   Furthermore, if the slot has aggregate type, then you'd better be sure
+   that your compiler supports compound literals (6.5.2.5) because that's
+   what the initializer gets turned into.
 
    See `sod-initializer' for more details."))
 
+(export 'sod-initarg)
+(defclass sod-initarg ()
+  ((%class :initarg :class :type sod-class :reader sod-initarg-class)
+   (location :initarg :location :initform (file-location nil)
+            :type file-location :reader file-location)
+   (name :initarg :name :type string :reader sod-initarg-name)
+   (%type :initarg :type :type c-type :reader sod-initarg-type))
+  (:documentation
+   "Describes a keyword argument accepted by the initialization function."))
+
+(export 'sod-user-initarg)
+(defclass sod-user-initarg (sod-initarg)
+  ((default :initarg :default :type t :reader sod-initarg-default))
+  (:documentation
+   "Describes an initialization argument defined by the user."))
+
+(export 'sod-slot-initarg)
+(defclass sod-slot-initarg (sod-initarg)
+  ((slot :initarg :slot :type sod-slot :reader sod-initarg-slot))
+  (:documentation
+   "Describes an initialization argument used to initialize a slot."))
+
 ;;;--------------------------------------------------------------------------
 ;;; Messages and methods.