The MIDL compiler generates up to three functions for each type to which the encode or decode attribute is applied. For example, for a user-defined type named MyType, the compiler generates code for the MyType_Encode, MyType_Decode, and MyType_AlignSize functions. For these functions, the compiler writes prototypes to STUB.H and source code to STUB_C.C. Generally, you can encode a MyType object with MyType_Encode and decode an object from the buffer using MyType_Decode. MyType_AlignSize is used if you need to know the size of the marshalling buffer prior to allocating it.
The following encoding function is generated by the MIDL compiler. It serializes the data for the object pointed to by pObject and the buffer is obtained according to the method specified in the handle. After writing the serialized data to the buffer, you control the buffer. Note that the handle inherits the status from the previous calls and the buffers must be aligned at 8.
For an implicit handle:
void MyType_Encode (MyType __RPC_FAR * pObject);
For an explicit handle:
void MyType_Encode (handle_t Handle, MyType __RPC_FAR * pObject);
The following function deserializes the data from the application's storage into the object pointed to by pObject. You supply a marshalled buffer according to the method specified in the handle. Note that the handle may inherit the status from the previous calls and the buffers must be aligned at 8.
For an implicit handle:
void MyType_Decode (MyType __RPC_FAR * pObject);
For an explicit handle:
void MyType_Decode (handle_t Handle, MyType __RPC_FAR * pObject);
The following function returns the sum of the size in bytes of the type instance plus any padding bytes needed to align the data. This enables serializing a set of instances of the same or different types into a buffer while ensuring that the data for each object is appropriately aligned. MyType_AlignSize assumes that the instance pointed to by pObject will be marshalled into a buffer beginning at the offset aligned at 8.
For an implicit handle:
size_t MyType_AlignSize (MyType __RPC_FAR * pObject);
For an explicit handle:
size_t MyType_AlignSize (handle_t Handle, MyType __RPC_FAR * pObject);