A Vision for Open Hypermedia Systems |
Nürnberg and Leggett |
Appendix C. Sproc Specific Layer Rules
The Sproc Specific Layer sends sets of generic structural objects to
the Sproc Generic Layer. They must map arbitrary service requests
with arbitrary parameters to the generic structure object format.
This appendix explains how this can be done.
Assume that a message definition is given in Sproc Interface Format,
defined in Appendix D. The algorithm below handles only one message,
but is modified in a straightforward way to accomodate multiple
messages. Alias types are not explicitly handled below.
Let:
- a message msg be defined as {msg_name,
params};
- msg_name be a NULL-terminated string;
- Each element params, say paramsi, be
defined as {param_namei, valuei,
typei};
- param_namei be a NULL-terminated string; and,
- each element of typei be one of "simple",
"static array", "dyanmic array", "structure", "list", or "pointer".
Also, in the algorithm, let:
- stringify (value, type) be an operation that returns a
NULL-terminated string that corresponds to an ASCII representation of
value, interpreted as a parameter of type type; and,
- new_param (param_name) be an operation that tags the
head object with an attribute "param_param_name";
- add_val (i, param_name, value, type) be an operation
that either:
- Adds the value "vali_" + stringify (value, type) to the
attribute "param_param_name", or does the following:
- Allocates a new structural object;
- Generates an integer unique with respect to the message being processed;
- Tags the new object with an attribute index with the value
stringify (index, simple);
- Adds the value "indexi_index" to the attribute "param_param_name"; and,
- Sets the content of the new object to value.
Given msg, do:
1. Allocate a structural object, hereafter referred to as the
"head" object
2. Tag the head object with an attribute "message_name" with the
value msg_name
3. For each param paramsi, do:
3.1 add_param (0, param_namei,
valuei, typei) (defined below)
where add_param (num, param_name, value, type) is defined as:
1. new_param (param_name)
2. If type is "simple", then
2.1 add_val (num, param_name, value, type)
3. If type is "pointer", then
3.1 add_val (num, param_name, derefd_value, derefd_type),
where derefd_value is the value of the pointer dereferenced,
and derefd_type is the type of the variable to which this
parameter points.
4. If type is "static array" or "dyanmic array", then
4.1 For each element valuei of the array, do:
4.1.1 add_param (i, param_name, valuei,
base_type) (where base_type is the type of the elements in
the array
5. If type is "structure", then
5.1 For each field fieldi =
{field_namei, field_typei,
field_valuei} of the structure, do:
5.1.1 add_param (0, param_name+field_name,
field_valuei, field_type)
6. If type is "list", then
6.1 Set i to 0.
6.2 For each list node in the list:
6.2.1 add_param (i, param_name, valuei, "structure"), where valuei is a structure containing all but the next field of the type definition
6.2.2 Increment i
Contents
Peter J. Nürnberg,
John J. Leggett
HRL,
CSDL,
Texas A&M
original page URL: http://jodi.ecs.soton.ac.uk/Articles/v01/i02/Nurnberg/appc.html