Updated Message Payload Syntax: Difference between revisions
No edit summary |
|||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
==Introduction== | ==Introduction== | ||
In [[STRIDE_3.0. | In [[STRIDE_3.0.01xx|STRIDE version 3.0.01xx]], we are unifying the payload syntax across messages and functions. | ||
To make migration easier for existing users of STRIDE messaging, we continue to support the existing legacy syntax as well as the new unified syntax. This legacy syntax has been deprecated and all new scripting code should use the new message payload syntax given below. | To make migration easier for existing users of STRIDE messaging, we continue to support the existing legacy syntax as well as the new unified syntax. This legacy syntax has been deprecated and all new scripting code should use the new message payload syntax given below. | ||
Line 117: | Line 117: | ||
</pre> | </pre> | ||
[[Category: | [[Category:Studio:Reference]] |
Latest revision as of 17:48, 30 September 2009
Introduction
In STRIDE version 3.0.01xx, we are unifying the payload syntax across messages and functions.
To make migration easier for existing users of STRIDE messaging, we continue to support the existing legacy syntax as well as the new unified syntax. This legacy syntax has been deprecated and all new scripting code should use the new message payload syntax given below.
Legacy Support
The following sections utilize the following structure declaration for illustration of supported legacy payload and scripting syntax.
typedef struct s{ int x; } S;
One Way Command Message
- For any one-way message
scl_msg(M, S)
the following scripting expressions are allowed in accessing the command payload from both the User and Owner object. Both expression designate the same “x” instance and value.
M.User.S.x M.Owner.S.x
- If the payload is empty as in
scl_msg(M)
, thenM.User.S
orM.Owner.S
does not exist.
Two Way Command Message
- Any two-way command message with only a command payload is treated the same as a one-way command message.
- For any two-way message with both a command and response payload if the command and response payload have the same typedef name as in scl_msg(M, S, S), the legacy behavior is undefined.
Example
Assume we have a two-way message with command payload defined with typedef name S1 and response payload defined with typedef name S2
, as follows:
typedef struct S1{int x;} S1; typedef struct S2{int y;} S2; scl_msg(M, S1, S2)
Then the following scripting expressions are allowed in accessing the command and response payloads from both user and owner object.
Access to command payload:
M.User.S1.x M.Owner.S1.x
Access to response payload:
M.User.S2.x M.Owner.S2.x
If the payload is empty as in scl_msg(M)
, then neither of the properties S1 or S2 exist.
Broadcast Message
- For any broadcast message
scl_msg(M, S)
then the following scripting expressions are allowed for accessing the response payload.
M.User.S.x M.Owner.S.x
- If the payload is empty as in
scl_msg(M)
, then S does not exist.
One Way Response
- For any one-way response message
scl_msg(M, S)
then the following scripting expressions are allowed for accessing the response payload.
M.User.S.x M.Owner.S.x
- If the payload is empty as in
scl_msg(M)
, then S does not exist.
New Messaging support
The strategy of the new messaging support is to unify the syntax between messaging and functions. The new support is based on the following:
- All messages that take a command payload are similar to functions that take a single unnamed argument.
- Message response payload and function return values are the same.
Thus for all messages that have a command payload we create:
M.User.Command M.Owner.Command
where Command is to a message what the name “p1” is to a function with a single unnamed parameter. It is a synthesized name whose type is that of the payload type. If there is no payload, the Command property does not exist. Given the struct S
used in earlier examples the following expression allows access to command payload values:
M.User.Command.x M.Owner.Command.x
Likewise for all messages that have a response payload, the name Response is synthesized to represent it. Response is to messages what ReturnValue is to functions.
Again assuming a message whose response payload contains S as a return value the following expression allows access:
M.User.Response.x M.Owner.Response.x