From: Mark Wooding Date: Sun, 30 Aug 2015 10:07:21 +0000 (+0100) Subject: src/class-make-{proto,impl}.lisp: Better choice of default message class. X-Git-Tag: 0.2.0~40 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/commitdiff_plain/d145f6df86aca5c0b520f300ce8821e762a9707b?ds=inline src/class-make-{proto,impl}.lisp: Better choice of default message class. If a combination is specified, use the new `aggregating-message' by default. --- diff --git a/src/class-make-impl.lisp b/src/class-make-impl.lisp index 1daab39..28c1958 100644 --- a/src/class-make-impl.lisp +++ b/src/class-make-impl.lisp @@ -152,13 +152,16 @@ (defmethod shared-initialize :after (defmethod make-sod-message ((class sod-class) name type pset &optional location) (with-default-error-location (location) - (let ((message (make-instance (get-property pset :message-class :symbol - 'standard-message) - :class class - :name name - :type type - :location (file-location location) - :pset pset))) + (let* ((msg-class (or (get-property pset :message-class :symbol) + (and (get-property pset :combination :keyword) + 'aggregating-message) + 'standard-message)) + (message (make-instance msg-class + :class class + :name name + :type type + :location (file-location location) + :pset pset))) (with-slots (messages) class (setf messages (append messages (list message))))))) diff --git a/src/class-make-proto.lisp b/src/class-make-proto.lisp index 01e18eb..c04727c 100644 --- a/src/class-make-proto.lisp +++ b/src/class-make-proto.lisp @@ -136,12 +136,13 @@ (defgeneric make-sod-message (class name type pset &optional location) This is the main constructor function for messages. This is a generic function primarily so that the CLASS can intervene in the construction - process. The default method uses the `:message-class' property - (defaulting to `sod-message') to choose a (CLOS) class to instantiate. - The message is then constructed by `make-instance' passing the arguments - as initargs; further behaviour is left to the standard CLOS instance - construction protocol; for example, `sod-message' defines an - `:after'-method on `shared-initialize'.")) + process. The default method uses the `:message-class' property to choose + a (CLOS) class to instantiate; if no such property is provided but a + `combination' property is present, then `aggregating-message' is chosen; + otherwise `standard-message' is used. The message is then constructed by + `make-instance' passing the arguments as initargs; further behaviour is + left to the standard CLOS instance construction protocol; for example, + `sod-message' defines an `:after'-method on `shared-initialize'.")) (export 'make-sod-method) (defgeneric make-sod-method