2.2.49.3 Automation-Compatible Types
The OLE Automation Protocol restricts the types of parameters that can be used in the definition of an automation interface (see section 2.2.49.4).
-
type-attribute = rpc-defined / uuid-attr / help-attr / custom-attr / kw-public / kw-restricted oa-type-spec = oa-base-type-spec / oa-safearray-type-spec / oa-ptr-type-spec / Identifier oa-base-type-spec = oa-base-nondecimal-type-spec / kw-Decimal oa-base-nondecimal-type-spec = kw-boolean / [kw-unsigned] LWSP kw-char / [kw-unsigned] LWSP kw-short / [kw-unsigned] LWSP kw-int / [kw-unsigned] LWSP kw-long / kw-double / kw-float / kw-BSTR / kw-CURRENCY / kw-DATE / kw-SCODE oa-safearray-type-spec = kw-SAFEARRAY "(" oa-base-nondecimal-type-spec ")" / kw-SAFEARRAY "(" oa-ptr-type-spec ")" / kw-SAFEARRAY "(" Identifier ")" oa-ptr-type-spec = oa-base-nondecimal-type-spec "*" / oa-safearray-type-spec "*" / Identifier "*"
In the preceding productions, <Identifier> MUST be a type that is defined as an enumeration type, a UDT, or an automation-compatible interface (see section 2.2.49.4.1 for details).
The restriction that defines the automation-compatible types is that they MUST be representable as a field in a VARIANT (section 2.2.29.2).
The following table specifies the mapping between the IDL keyword and the associated VARIANT type constant (see section 2.2.7) that MUST<37> be used when storing the type in a VARIANT. These are the only types that are legal in an automation-compatible interface (see section 2.2.49.4.1).
Type keyword |
VARIANT type constant |
---|---|
boolean |
VT_BOOL |
unsigned char |
VT_UI1 |
char |
VT_I1 |
double |
VT_R8 |
float |
VT_R4 |
unsigned int |
VT_UI4 |
int |
VT_I4 |
unsigned long |
VT_UI4 |
long |
VT_I4 |
unsigned short |
VT_UI2 |
short |
VT_I2 |
BSTR |
VT_BSTR |
CURRENCY |
VT_CY |
VARIANT |
VT_BYREF|VT_VARIANT |
DATE |
VT_DATE |
Decimal |
VT_DECIMAL |
SCODE |
VT_ERROR |
HRESULT |
VT_ERROR |
typedef enum myenum |
VT_I4 |
typedef struct myUDT |
VT_RECORD or VT_BYREF|VT_RECORD |
interface IDispatch* |
VT_DISPATCH |
interface IUnknown* |
VT_UNKNOWN |
dispinterface Typename* |
VT_DISPATCH |
[oleautomation] interface Typename* |
VT_UNKNOWN |
SAFEARRAY(Typename) |
VT_ARRAY |
Typename* |
VT_BYREF | the variant type associated with Typename |
[dual] interface Typename* |
VT_DISPATCH |
The methods of an Automation Interface Definition Language (AIDL) interface MUST return an HRESULT or SCODE. The methods and properties of an ODL dispinterface MUST return only the types that are specified in the previous table. Otherwise, an automation interface MUST use types from the previous table. See AIDL Interfaces and ODL Dispinterfaces (section 2.2.49.7) for more information.
uuid-attr: Specifies a GUID that MUST identify the type. Any automation-compatible constructed types (enums, structs, or unions) that are not declared with a specifying GUID cannot be retrieved using ITypeLib::GetTypeInfoOfGuid (section 3.11.4.4).
help-attr: Specifies information associated with the type that can be retrieved using ITypeLib::GetDocumentation (section 3.11.4.7) or ITypeInfo::GetDocumentation (section 3.7.4.8).
kw-public: Specifies that the element is an alias declared with the typedef keyword and explicitly included in an automation scope.
kw-restricted: Specifies that the element is not intended to be used under all conditions. Type browser clients MAY<38> place restrictions on the visibility or usability of elements that have this attribute. Elements with the [restricted] attribute MUST NOT also have the [default] attribute.
kw-hidden: Specifies that the type is not intended to be displayed to users. Type browser clients SHOULD NOT expose the functionality of elements that have this attribute.