The MCTypeDesc structure describes the type of a parameter or return value of a COM method.
TypeDesc_attribute { u1 Type; u1 Flags; union { u2 IIDIndex; u2 SizeIndex; u2 wSize; u2 wiHookClass; VARTYPE VarType; struct { u1 biParam; u1 bReserved; } a; } }
The C structure MCTypeDesc, declared in comattr.h, defines the layout of this attribute for use in C/C++ programs.
Type
This value indicates the type of the parameter or return value. Legal values are described in the MCTypeDesc enumerations table.
Flags
The flags are grouped into in/out, threading-model, and attribute flags. Legal values are described in the MCTypeDesc flags table.
IIDIndex
If the type is TD_INTF and TDF_USES_IID_IS is not set, IIDIndex must be set to a valid index into the GUID pool. The entry at this index indicates the IID of the interface. A null index (0xffff) is invalid.
SizeIndex
If the type is TD_STRUCT, SizeIndex must be set to an index into the constant pool. The constant pool item must be type CP_Integer and must indicate the size of the struct in bytes.
wSize
If the type is TD_SYSFIXEDSTRING, TD_FIXEDARRAY, or TD_JARR, wSize must be set to the number of elements in the array.
wiHookClass
If the type is TD_CUSTOM, TD_CUSTOMBYREF, or TD_CUSTOMBYVAL, wiHookClass must be set to an index into the constant pool. The constant pool item must be type CP_Class or CP_Utf8 (in which case the string is a class name) and specify the class that will perform the custom marshaling.
VarType
If the type is TD_SAFEARRAY, VarType must be set to a valid VarType that describes the element type. VT_ARRAY may not be set on this type. If VT_BYREF is set, this parameter will be interpreted as a SAFEARRAY** rather than a SAFEARRAY*.
biParam
If the type is TD_JARR and TDF_USES_SIZE_IS is specified in the flags, a.biParam is the zero-based index of the parameter that determines the dynamic (run time) size of this array parameter. The referenced parameter must be an integral or array of integral type. This is similar to the MIDL attribute "size_is." a.bReserved must be set to zero.
If the type is TD_INTF and TDF_USES_SIZE_IS is specified in the flags, a.biParam is the zero-based index of the parameter that determines the dynamic (run time) IID of this interface parameter. The referenced parameter must be of struct or array of struct type. This is similar to the MIDL attribute "iid_is." a.bReserved must be set to zero.
For types other than TD_STRUCT, TD_INTF, TD_SAFEARRAY, TD_SYSFIXEDSTRING, TD_FIXEDARRAY, TD_JARR, TD_CUSTOM, TD_CUSTOMBYREF, and TD_CUSTOMBYVAL, this union must be set to zero.
Name | Value | Comments |
TD_VOID | 0x00 | A void, used only for return types. |
TD_I1 | 0x01 | A signed 8-bit integer. |
TD_I2 | 0x02 | A signed 16-bit integer. |
TD_I4 | 0x03 | A signed 32-bit integer. |
TD_I8 | 0x04 | A signed 64-bit integer. |
TD_U1 | 0x05 | An unsigned 8-bit integer. |
TD_U2 | 0x06 | An unsigned 16-bit integer. |
TD_U4 | 0x07 | An unsigned 32-bit integer. |
TD_U8 | 0x08 | An unsigned 64-bit integer. |
TD_R4 | 0x09 | A 32-bit IEEE floating value. |
TD_R8 | 0x0a | A 64-bit IEEE floating value. |
TD_PTR | 0x0b | A pointer to some data structure. |
TD_STRUCT | 0x0c | A structure that is being passed by value. SizeIndex must specify the size of the structure. |
TD_INTF | 0x0d | A pointer to an interface (an IUnknown* derivative). |
TD_JSTR | 0x0e | A JString. |
TD_JARR | 0x0f | A JArray. |
TD_VARIANT | 0x10 | A variant. |
TD_CUSTOM | 0x11 | A custom data type. |
TD_CUSTOMBYREF | 0x12 | A custom data type passed by reference. |
TD_CUSTOMBYVAL | 0x13 | A custom data type passed by value. |
TD_SAFEARRAY | 0x14 | A SAFEARRAY. |
TD_SYSCHAR | 0x15 | Unicode or ANSI char, depending on platform setting. |
TD_SYSFIXEDSTRING | 0x16 | Fixed Unicode or ANSI string (for use inside structs: SizeIndex == #ofchars, including null terminator). |
TD_FIXEDARRAY | 0x17 | Fixed size array of scalars (for use inside structs: SizeIndex == # of elements). |
TD_OBJECT | 0x18 | Field type of "L<something>". Treat as embedded struct if JCDW; treat as COM interface if Object or interface. |
In/Out Flags: If MCTypeDesc or MCVarTypeDesc is used to describe a parameter, the flags must specify one of TDF_IN, TDF_OUT or TDF_INOUT.
MCTypeDesc: For all types other than TD_PTR, TD_SAFEARRAY and TD_JARR, the value of this subflag must be TD_IN. If the MCTypeDesc is used to describe a return value or a MapsTo type, this subflag must be set to zero. MCVarTypeDesc: If the type field does not have VTD_BYREF set, TDF_IN must be specified. TDF_INOUT is illegal in this case. If the MCVarTypeDesc is used to describe a return value, this subflag must be set to zero. |
||
Name | Value | Comments |
TDF_IN | 0x01 | The parameter is an [in] parameter to the method.
This option is only applicable to method parameters. |
TDF_OUT | 0x02 | The parameter is an [out] parameter to the method.
This option is only applicable to method parameters. |
TDF_INOUT | 0x03 | The parameter is an [in, out] parameter to the method.
This option is only applicable to method parameters. |
Threading-Model Flags: Indicates the expected threading model of the interface pointer. In certain cases, the VM may produce a Java object that assumes a less restrictive threading model than is indicated by this subflag. This can happen if the interface pointer had been previously marshaled to Java through another method whose parameter was flagged with the less restrictive threading model. It can also happen if the incoming interface pointer was created by the VM itself (these interface pointers are all free-threaded.)
MCTypeDesc: This subflag is meaningful only for the TD_INTF type. For all others, it must be set to zero. MCVarTypeDesc: This subflag is meaningful only for the VTD_DISPATCH and VTD_UNKNOWN types. For all others, it must be set to zero. |
||
Name | Value | Comments |
TDF_AUTOMARSHAL | 0x04 | If the VM creates a JCW to represent this COM interface, it will do the appropriate marshaling. |
TDF_NOMARSHAL | 0x08 | If this MCTypeDesc is being used to marshal to a Java class that is not a JCW, TDF_NOMARSHAL must be set. |
Attribute Flags: These flags are used only on method parameters and return values of type TD_JARR and TD_INTF. They must not be set in a COM_MapsTo attribute. These flags indicate that a second parameter will be used to dynamically describe this parameter in some way (similar to iid_is and size_is in MIDL). | ||
Name | Value | Comments |
TDF_USER2 | 0x40 | User-defined. |
TDF_USER1 | 0x80 | User-defined. |
TDF_USES_IIS_IS | TDF_PARAM_ DEPENDENCY |
This flag is meaningful only for the TD_INTF type, and signifies that the IID of the interface parameter is determined dynamically at runtime using the value of another parameter. |
TDF_USES_SIZE_IS | TDF_PARAM_ DEPENDENCY |
This flag is meaningful only for the TD_JARR type, and signifies that the size of the array parameter is determined dynamically at runtime using the value of another parameter. |
Name | Value | Comments |
VT_I2 | 2 | A signed 16-bit integer. |
VT_I4 | 3 | A signed 32-bit integer. |
VT_R4 | 4 | A 32-bit IEEE floating value. |
VT_R8 | 5 | A 64-bit IEEE floating value. |
VT_CURRENCY | 6 | A 64-bit fixed-point number used for a currency data type. |
VT_DATE | 7 | A 64-bit floating-point fractional number indicating the number of days since December 30, 1899. |
VT_BSTR | 8 | A BSTR, a length-prefixed automation string data type. |
VT_DISPATCH | 9 | A pointer to a dispatch interface. |
VT_ERROR | 10 | An HRESULT, a built-in error type. |
VT_BOOL | 11 | A data item that can have a value of true (0xff) or false (0). The size of this item corresponds to an unsigned character. |
VT_VARIANT | 12 | A VARIANT pointer. |
VT_UNKNOWN | 13 | A pointer to an interface that is not derived from IDispatch. Any interface can be represented by its IUnknown interface. |
VT_DECIMAL | 14 | A 128-bit fixed-point data type. |
VT_UI1 | 17 | An unsigned 8-bit character. |