Type Attributes

Type attributes are the MIDL attributes that can be applied to type declarations: transmit_as, represent_as, user_marshal, wire_marshal, handle, context_handle, switch_type, and the pointer type attributes.

The switch_type attribute designates the type of a union discriminator. This attribute applies only to a nonencapsulated union.

A context handle is a pointer with a context_handle attribute. The context_handle attribute allows you to write procedures that maintain state information between remote procedure calls. A context handle with a non-null value represents saved context and serves two purposes. On the client side, it contains the information needed by the RPC run-time library to direct the call to the server. On the server side, it serves as a handle on active context.

The handle attribute specifies that a type can occur as a user-defined, (generic) handle. This feature permits the design of handles that are meaningful to the application. The user must provide binding and unbinding routines to convert between the user-defined handle type and the RPC primitive handle type, handle_t. A primitive handle contains destination information meaningful to the RPC run-time libraries. A user-defined handle can only be defined in a type declaration, not in a function declaration. A parameter with the handle attribute has a double purpose. It is used to determine the binding for the call, and it is transmitted to the called procedure as a normal data parameter.

The transmit_as and represent_as attributes instruct the compiler to associate a transmissible type which the stub passes between client and server, with a user type which the client and server applications use. You must supply the routines that carry out the conversion between the user type and the transmissible type, and the routines to release the memory that was used to hold the converted data. Using the transmit_as IDL attribute or the represent_as ACF attribute instructs the stub to call these conversion routines before and after transmission.

The wire_marshal and user_marshal attributes are Microsoft extensions to the OSF-DCE IDL. Their syntax and functionality are similar to that of the DCE-specified transmit_as and represent_as attributes, respectively. The difference is that, instead of converting the data from one type to another, you marshal the data directly.To do this, you must supply the external routines for sizing the data buffer on the client and server sides, marshaling and unmarshaling the data on the client and server sides, and freeing the data on the server side. The MIDL compiler generates format codes that instruct the NDR engine to call these external routines when needed.

The wire_marshal and user_marshal attributes make it possible to marshal data types that otherwise could not be transmitted across process boundaries. Also, because there is less overhead associated with the type conversion, wire_marshal and user_marshal provide improved performance at run time, when compared to transmit_as and represent_as.

The wire_marshal and user_marshal attributes are mutually exclusive in respect to each other and with the transmit_as and represent_as attributes for a given type.