next up previous
Next: Example 1: prototyped Up: 3.2 Operator type specifications Previous: Union TypeSpec

3.2.2 Meta Operator TypeSpecs

For objects such as structures and unions, the sender knows at prototype specification time how many arguments the structuring operator has. For these objects, the type of each field is given quite easily within the prototype tree by specifying them through the prototype operator's arguments. Unfortunately, this approach does not work for objects which are a repetition of a single type specification (as in an array, for example), or for which the actual number of arguments is not known at prototype specification time or for which the number of arguments may be different for separate instances of the object within the tree (a pointer or ragged array, for example).

These cases are handled using a combination of the CommonMetaType and CommonOperator node packets: MP_MetaOperator (Mop) and MP_CommonMetaOperator (Cmop). Meta operator node packets may only meaningfully appear in a prototype tree where they serve as a ``place holder'' for an operator which otherwise would appear at data communication time. Meta operators have two defining characteristics which distinguish them from operator and meta type packets. First, unlike a meta type packet, a meta operator packet does not specify a leaf in the corresponding prototyped data tree. Instead, a meta operator specifies an inner node (operator) in the prototyped data tree where the communication of the node (operator) itself is shifted from data communication time to prototype specification time. Second, unlike an operator packet, a meta operator packet has no actual arguments. Instead, the number-of-arguments-field encodes information about the number of arguments which are communicated at the corresponding place in the prototyped data tree. There are two cases to consider:

A meta operator node packet with a non-zero number-of-arguments field. This is the number of arguments transmitted at data communication time.
A meta operator node packet with 0 in the number-of-arguments field. The number of arguments to the operator is delayed from prototype communication time to data communication time. The actual number of arguments is transmitted at data communication time by an IMP_Uint32 data limb before the arguments are transmitted (i.e., at the place where the operator would have appeared at data communication time).

Furthermore, annotations given to a meta operator at prototype specification time fullfill the role of the annotations which otherwise would have been given to the actual operator at data communication time. This applies in particular to the prototype annotation: If a meta operator appearing in a prototype tree has an attached prototype annotation, then the corresponding arguments appearing at data communication time are of the type specified by the prototype tree following the prototype annotation. An example where annotations are attached to meta operators is shown in figure 10.

The concept of type specifications based on meta operators is very powerful and flexible. It can be used, among others, to specify the structure and content of data structures built from pointers and (even- and uneven-length) arrays, which we illustrate in the following two examples.

next up previous
Next: Example 1: prototyped Up: 3.2 Operator type specifications Previous: Union TypeSpec
| ZCA Home | Reports |