[Next] [Previous] [Top]

2. External Data Representation

2.1 UTS Library
The external data representation aspect of UTS allows data to be represented in a machine- and language-independent manner. It includes most common data types found in languages, plus full support for array and record types. Library calls are provided that convert data from the host machine's native format to and from UTS format.

In general, the representation of a data item contains both the data value and a tag indicating the type and, where needed, the length of the datum. The type tag may be thought of as an indication of which procedure was used to encode the value, and hence which procedure should be used to invert the encoding to produce a usable value.

Values of the variable-length types, string and byte, contain as part of the tag a length field, which holds the length of the value including the tag in standard UTS integer representation. A similar length field is present in the record and array representations. The array representation also holds an indication of the shape of the array. First the number of dimensions is given, then the size of the array along each dimension. Records and arrays also have end-markers. These are useful, for example, in data streaming, where the length may not be known at the start of the data stream. In this case, the value -1 is encoded for the length.

2.1 UTS Library

These routines are used by the stub compilers when automatically handling conversion of data.
      void  UTS_encode_bool(int, char *)
       int  UTS_decode_bool(char *)
      void  UTS_encode_float(float, char *)
     float  UTS_decode_float(char *)
      void  UTS_encode_double(double, char *)
    double  UTS_decode_double(char *)
      void  UTS_encode_int(long, char *)
      long  UTS_decode_int(char *)
      void  UTS_encode_short(int, char *)
       int  UTS_decode_short(char *)
       int  UTS_encode_string(char *src, char **dst)
      char *UTS_decode_string(char **)
The following are used primarily by the runtime support code (the first four functions return the length of the encoded/decoded object in bytes):
 
          int UTS_encode_comp(Component *, char **)
          int UTS_decode_comp(Component *, char **)
          int UTS_encode_prog(Prog *, char **)
          int UTS_decode_prog(Prog *, char *)
         void UTS_encode_sig(Signature, char **)
    Signature UTS_decode_sig(char **)\fP\s+2

[Next] [Previous] [Top]