C++ type mapping for argument passing

Argument type mappings are discussed in this topic and summarized in the two tables that follow. For the rules that must be observed when passing parameters (in , inout, out, or return value) to a CORBA object implementation, see "Argument passing considerations for C++ bindings".

For primitive types and enumerations, the type mapping is straightforward. For in parameters and return values, the type mapping is the C++ type representation (abbreviated as "T" in the text that follows) of the Interface Definition List (IDL) specified type. For inout and out parameters the type mapping is a reference to the C++ type representation (abbreviated as "T&" in the text that follows).

For object references, the type mapping uses _ptr for in parameters and return values and _ptr& for inout and out parameters. That is, for a declared interface A, an object reference parameter is passed as type A_ptr or A_ptr&. The conversion functions on the _var type permit the client (caller) the option of using _var type rather than the _ptr for object reference parameters. Using the _var type can have an advantage because it relieves the client (caller) of the responsibility to deallocate a returned object reference (out parm or return value) between successive calls. This is because changing the assignment operator of a _ptr to a _var automatically releases the embedded reference.

The type mapping of parameters for aggregate types (also referred to as complex types) are complicated by when and how the parameter memory is allocated and deallocated. Mapping in parameters is straightforward because the parameter storage is caller-allocated and read-only. For an aggregate IDL type t with a C++ type representation of T, the in parameter mapping is const T&. The mapping of out and inout parameters is slightly more complex. To preserve the client capability to stack allocate fixed length types, Object Management Group (OMG) has defined the mappings for fixed-length and variable-length aggregates differently. The inout and out mapping of an aggregate type represented in C++ as T is T& for fixed-length aggregates and as T*& for variable-length aggregates.


Basic argument and result passing
Data Type In Inout Out Return
short Short Short& Short& Short
long Long Long& Long& Long
long long LongLong LongLong& LongLong& LongLong
unsigned short UShort UShort& Ushort& Ushort
unsigned long ULong ULong& Ulong& Ulong
unsigned long long ULongLong ULongLong& ULongLong& ULongLong
float Float Float& Float& Float
double Double Double& Double& Double
long double LongDouble LongDouble& LongDouble& LongDouble
boolean Boolean Boolean& Boolean& Boolean
char Char Char& Char& Char
wchar Wchar Wchar& Wchar& Wchar
octet Octet Octet& Octet& Octet
enum enum enum& enum& enum
object reference ptr objref_ptr objref_ptr& objref_ptr& objref_ptr
struct, fixed const struct& struct& struct& struct
struct, variable const struct& struct& struct*& struct*
union, fixed const union& union& union& union
union, variable const union& union*& union*& union*
string const char* char*& char*& char*
wstring const Wchar* Wchar*& Wchar*& Wchar*
sequence const sequence& sequence& sequence*& sequence*
array, fixed const array array array array slice*
array, variable const array array array slice*& array slice*
any const any& any& any*& any*
valuetype valuetype* valuetype*& valuetype*& valuetype*


For an aggregate type represented by the C++ type T, the T_var type also is defined. The conversion operations on each T_var type allows the client (caller) to use the T_var type directly for any directionality, instead of using the required form of the T type ( T, T& or T*&) The emitted bindings define the operation signatures in terms of the parameter passing modes shown in the T_var argument and result passing table and the T_var types provide the necessary conversion operators to allow them to be passed directly.


T_var argument and result passing
Data Type In Inout Out Return
object reference_var const object_var& objref_var& objref_var& objref_var
struct_var const struct_var& struct_var& struct_var& struct_var
union_var const union_var& union_var& union_var& union_var
string_var const string_var& string_var& string_var& string_var
sequence_var const sequence_var& sequence_var& sequence_var& sequence_var
array_var const array_var& array_var& array_var& array_var
any_var const any_var& any_var& any_var& any_var
valuetype_var const valuetype_var& valuetype_var& valuetype_var& valuetype_var


Do not pass or return a null pointer for parameters that are passed or returned as a pointer type (T*) or reference to pointer(T*&). However, this cannot be enforced by the bindings.


Related reference
Argument passing considerations for C++ bindings



Searchable topic ID:   rcor_coptma
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/corba/ref/rcor_coptma.html

Library | Support | Terms of Use | Feedback