message, csys: functions for accessing action and object keys in message heads
This commit is contained in:
parent
90fad03268
commit
429634dd82
2 changed files with 12 additions and 5 deletions
|
|
@ -6,7 +6,7 @@
|
|||
(:shape :scopes/shape)
|
||||
(:util :scopes/util))
|
||||
(:export #:message-meta #:message #:create
|
||||
#:head #:data))
|
||||
#:action-key #:object-key))
|
||||
|
||||
(in-package :scopes/core/message)
|
||||
|
||||
|
|
@ -28,3 +28,12 @@
|
|||
|
||||
(defmethod actor:content ((msg message))
|
||||
(list (shape:head-plist msg) (shape:data msg)))
|
||||
|
||||
(defun action-key (msg)
|
||||
(let ((head (shape:head msg)))
|
||||
(list (car head) (cadr head))))
|
||||
|
||||
(defun object-key (msg)
|
||||
(let ((head (shape:head msg)))
|
||||
(cons (car head) (cddr head))))
|
||||
|
||||
|
|
|
|||
|
|
@ -81,8 +81,7 @@
|
|||
(actor:send sn msg)))
|
||||
|
||||
(defun find-sensors (msg)
|
||||
(let* ((head (shape:head msg))
|
||||
(key (cons (car head) (cddr head)))
|
||||
(let* ((key (message:object-key msg))
|
||||
(sns (gethash key (sensors *environment*))))
|
||||
;(util:lgi key sns *environment*)
|
||||
sns))
|
||||
|
|
@ -99,8 +98,7 @@
|
|||
(funcall s msg)))
|
||||
|
||||
(defun handle-action (msg state syns &key (default #'no-op))
|
||||
(let* ((head (shape:head msg))
|
||||
(key (list (car head) (cadr head)))
|
||||
(let* ((key (message:action-key msg))
|
||||
(act (gethash key (actions *environment*) default)))
|
||||
(funcall act msg state syns)))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue