represent_as attribute
The [represent_as] ACF attribute associates a named local type in the target language repr-type with a transfer type named-type that is transferred between client and server.
typedef [represent_as(repr-type) [[ , type-attribute-list ]] ] named-type;
void __RPC_USER named-type_from_local (
repr-type __RPC_FAR * ,
named-type __RPC_FAR * __RPC_FAR * );
void __RPC_USER named-type_to_local (
named-type __RPC_FAR * ,
repr-type __RPC_FAR * ); void __RPC_USER named-type _free_inst ( named-type __RPC_FAR * ); void __RPC_USER named-type _free_local ( repr-type __RPC_FAR * );
-
named-type
-
Specifies the named transfer data type that is transferred between client and server.
-
type-attribute-list
-
Specifies one or more attributes that apply to the type. Separate multiple attributes with commas.
-
repr-type
-
Specifies the represented local type in the target language that is presented to the client and server applications.
When using [represent_as], you must supply routines that convert between the local and the transfer types and that free memory used to hold the converted data. The [represent_as] attribute instructs the stubs to call the user-supplied conversion routines.
The transferred type named-type must resolve to a MIDL base type, predefined type, or to a type identifier. For more information, see MIDL Base Types.
You must supply the following routines:
Routine name | Description |
---|---|
named_type**_from_local** | Converts data from the local type to the network type. The routine allocates memory for the network data type, including memory for any data referenced by pointers in the network data type. |
named_type**_to_local** | Converts data from the network type to the local type. The routine is responsible for allocating memory for data referenced by pointers in the local type. RPC allocates memory for the local type itself. |
named_type**_free_local** | Frees memory allocated for data referenced by pointers in the local type. RPC frees memory for the type itself |
named_type**_free_inst** | Frees memory allocated for the data referenced by pointers in the network type and for the network type itself. |
The client stub calls named-type**_from_local** to allocate space for the transmitted type and to translate the data from the local type to the network type. The server stub allocates space for the original data type and calls named-type**_to_local** to translate the data from the network type to the local type.
Upon return from the application code, the client and server stubs call named-type**_free_inst** to deallocate the storage for network type. The client stub calls named-type**_free_local** to deallocate storage returned by the routine.
The following types cannot have a [represent_as] attribute:
- Conformant, varying, or conformant-varying arrays
- Structures in which the last member is a conformant array (a conformant structure)
- Pointers or types that contain a pointer
- Pipes or types that contain pipes
- Types that are used as the base type for a pipe
- Predefined types handle_t, void
- Types that have the [handle] attribute
//these data types defined in .IDL or elsewhere
typedef struct _lbox
{
long data;
struct _lbox *next;
} lbox;
typedef [ref] lbox *PBOX_LOC;
typedef long LONG4[4];
//in .ACF file :
interface iface
{
typedef [ represent_as(PBOX_LOC) ] LONG4;
}