diff --git a/core/core.lisp b/core/core.lisp index 49d2f84..9189a80 100644 --- a/core/core.lisp +++ b/core/core.lisp @@ -29,16 +29,24 @@ (timestamp) (data))) +;;;; actions + +(defclass action-spec () + ((pattern :initarg :pattern :initform nil) + (handlers :reader handlers :initarg :handlers))) + ;;;; context (defclass context () ((name :reader name :initarg :name) - (action-handlers :accessor action-handlers :initform nil))) + (actions :accessor actions :initform nil))) (defgeneric send (rcvr msg) (:method ((rcvr context) msg) - (let ((hdlrs (action-handlers rcvr))) - (funcall (car hdlrs) msg)))) + (let* ((acts (actions rcvr)) + (selected (car acts)) + (hdlr (car (handlers selected)))) + (funcall hdlr msg)))) (defvar *context* nil) @@ -48,7 +56,9 @@ (format t "~&~s~%" msg)) (defclass printer (context) - ((action-handlers :initform (list #'do-print)))) + ((actions :initform + (list (make-instance 'action-spec + :handlers (list #'do-print)))))) (defun printer (name) (make-instance 'printer :name name)) diff --git a/test/test-core.lisp b/test/test-core.lisp index 1c6e9f2..e671983 100644 --- a/test/test-core.lisp +++ b/test/test-core.lisp @@ -16,7 +16,7 @@ (defclass test-suite (t:test-suite) ((receiver :reader receiver :initform (core:printer :test-rcvr)))) - ;:initform (make-instance 'core:context :name :test-rcvr)))) + ;:initform (make-instance 't:test-rcvr)))) (defun run () (let ((*config* nil)