home *** CD-ROM | disk | FTP | other *** search
- //*************************************************************************
- // (C)Copyright 1995-1999 Microsoft Corporation, All rights reserved.
- //
- // Note: This document is an early release of the final specification. It is
- // meant to specify and accompany software that is still in development. Some
- // of the information in this documentation may be inaccurate or may not be an
- // accurate representation of the functionality of the final specification
- // or software. Microsoft assumes no responsibility for any damages that might
- // occur either directly or indirectly from these inaccuracies. Microsoft may
- // have trademarks, copyrights, patents or pending patent applications, or
- // other intellectual property rights covering subject matter in this document.
- // The furnishing of this document does not give you a license to these
- // trademarks, copyrights, patents, or other intellectual property rights
- //
- // This header file describes the _Java Class File Attributes_ that must
- // be present in any class file that is to be used to invoke a COM object
- // from Java, or expose a Java object as a COM object.
- //
- // Data type sizes:
- //
- // BYTE - 8 bits
- // WORD - 16 bits
- // DWORD - 32 bits
- //
- // BYTEs, WORDs and DWORDs are all unsigned and stored in the .class
- // in _Big-Endian_ format.
- //
- //
- // Alignment:
- // There is no implicit padding between the fields of the structures,
- // or any padding after the last field of any structure.
- //
- //
- // Attribute List:
- // ---------------
- //
- // Level Name Description
- // ----- ---- -----------
- // Class COM_Class_Type Denotes the implementation language
- // Class COM_GuidPool Stores IID's and CLSID's.
- // Class COM_CustData Stores typelib custom data (CUSTDATA)
- // Class COM_MethodPool Stores distilled typelib information
- // Method COM_ExposedAs_Group Exposes a Java method to COM.
- // Method COM_ProxiesTo Exposes a COM method to Java.
- // Field COM_MapsTo Exposes external data to Java
- //
- //
- //
- // All unused bits in Flag fields must be zero.
- //
- //*************************************************************************
-
-
- #ifndef COMATTR_H
- #define COMATTR_H
-
- #include <pshpack1.h>
-
-
- //========================================================================
- // Attribute Name: COM_Class_Type
- // Attribute Level: Class
- // Restrictions:
- // If the class type is MCCTCT_JCW, the access flags for the
- // class must be a subset of:
- //
- // ACC_PUBLIC
- // ACC_FINAL
- // ACC_ABSTRACT
- //
- // If the class type is MCCTCT_JCDW, the access flags for the
- // class must be a subset of:
- //
- // ACC_PUBLIC
- // ACC_FINAL (required)
- //
- // The class's superclass must be java.lang.Object or a JCDW class.
- //
- //
- //
- // Attribute elements:
- //
- // WORD Flags
- // CCTF_NODYNAMICIFCCASTS:
- // This bit is legal only if the ClassType is MCCTCT_JCW.
- //
- // If on, instances of this class can only be legally
- // casts to interfaces explicitly implemented by either
- // the instance's class or one of its ancestors.
- //
- // If off, instances of this class can be cast at runtime
- // to any interface which contains a methodpool item,
- // provided that the underlying COM object returns a valid
- // interface for the IID of the interface.
- //
- //
- // CCTF_CHARSIZEMASK
- //
- // These bits must be zero unless ClassType is MCCTCT_JCDW.
- //
- // Otherwise, these bits indicate the treatment of certain
- // string and character array types:
- //
- // CCTF_CHARSIZEDUAL -- dual mode
- // CCTF_CHARSIZEANSI -- ansi
- // CCTF_CHARSIZEUNICODE -- unicode
- //
- //
- // WORD ClassType
- // The only legal values are MCCTCT_JCW and MCCTCT_JCDW.
- //
- // The actual type of a class is determined as follows:
- //
- // If no ancestor class (including the class itself) has a
- // COM_Class_Type attribute, the type is "pure".
- //
- // If the class has no COM_Class_Type attribute but a single ancestor
- // (which must be a direct descendant of java.lang.Object) has a
- // COM_Class_Type attribute JCW, the type is "Derived from JCW."
- //
- // If the class has a COM_Class_Type attribute, of type "MCCTCT_JCW",
- // the class type is "JCW."
- //
- // If the class has a COM_Class_Type attribute, of type
- // "MCCTCT_JCDW", the class type is "JCDW."
- //
- // All other situations are illegal.
- //
- //
- // WORD CLSIDIndex
- //
- // If ClassType is not MCCTCT_JCW, the contents of the field
- // must 0xffff.
- //
- // If the ClassType is MCCTCT_JCW, and the CLSIDIndex is
- // not 0xffff, it must indicate a valid index into the
- // GuidPool. The GUID corresponding to this index will be
- // used as the CLSID of the COM object to load when
- // an instance of this class is created using the "new"
- // operator.
- //========================================================================
-
- #define CCTF_NODYNAMICIFCCASTS 0x0001
-
- #define CCTF_CHARSIZEMASK 0x0006
- #define CCTF_CHARSIZEDUAL 0x0000
- #define CCTF_CHARSIZEANSI 0x0002
- #define CCTF_CHARSIZEUNICODE 0x0004
-
- #define MCCTCT_JCW ((WORD)1)
- #define MCCTCT_JCDW ((WORD)2)
-
- typedef struct {
- WORD Flags; // CCTF_* value.
- WORD Classtype; // MCCTCT_JCW or MCCTCT_JCDW
- union {
- WORD CLSIDIndex; // Optional index to CLSID (-1 for none)
- struct {
- BYTE packing; //1,2,4 or 8 (0xff defaults to 4 for backward compatibility)
- BYTE reserved1; // must set to 0xff
- } jcdw;
- };
- } MCClassType;
-
- // for compatibility with users of older headers.
- typedef MCClassType MCCT_Attr;
-
-
- //========================================================================
- // Attribute Name: COM_GuidPool
- // Attribute Level: Class
- //
- // Restrictions:
- // The class access flags must be a subset of:
- // ACC_PUBLIC
- // ACC_FINAL
- // ACC_INTERFACE
- // ACC_ABSTRACT
- //
- //
- // This attribute stores the IID's and CLSID's that are referenced by index
- // from the MethodPool. Valid indices range from 0 inclusive to nGuids
- // exclusive. The index 0xffff is reserved to indicate the "null" index.
- // Hence, the GuidPool can contain a maximum of 65535 guids.
- //
- // Attribute elements:
- //
- // WORD nGuids
- //
- // This field indicates the number of GUID's defined in this
- // table.
- //
- //
- // GUID aGuid[nGuids]
- //
- // This array stores the actual GUID representations.
- //========================================================================
- typedef struct {
- WORD nGuids; // # of guids in table
- // GUID aGuid[nGuids];
- } MCGuidPool;
-
- // for compatibility with users of older headers.
- typedef MCGuidPool MCGP_Attr;
-
-
- //========================================================================
- // Attribute Name: COM_CustData
- // Attribute Level: Class
- //
- // Restrictions:
- // The class access flags must be a subset of:
- // ACC_PUBLIC
- // ACC_FINAL
- // ACC_INTERFACE
- // ACC_ABSTRACT
- //
- // This attribute exposes type library CUSTDATA elements. Callers may
- // query a classes type library at runtime (such as through
- // IProvideClassInfo) for these attributes using methods like
- // ITypeInfo2::GetCustData.
- //
- // Attribute elements:
- //
- // WORD nCustDatas
- //
- // This field indicates the number of aCustData's defined in this
- // table.
- //
- // WORD aCustData[].GuidIndex
- //
- // Index into the COM_GuidPool table. Represents the GUID
- // identity for this custom data element.
- //
- // WORD aCustData[].DataIndex
- //
- // Index into this classes constant pool. Only certain types of
- // constant pool entries are supported (currently CP_Utf8 and
- // CP_Integer).
- //
- //========================================================================
- typedef struct {
- WORD nCustDatas; // # of elements in table
- // {
- // WORD GuidIndex;
- // WORD DataIndex;
- // } aCustData[nCustDatas];
- } MCCustData;
-
- // for compatibility with users of older headers.
- typedef MCCustData MCCDP_Attr;
-
-
- //========================================================================
- // Attribute Name: COM_MethodPool
- // Attribute Level: Class
- //
- // Restrictions:
- // The class access flags must be a subset of:
- // ACC_PUBLIC
- // ACC_FINAL
- // ACC_INTERFACE
- // ACC_ABSTRACT
- //
- // Though the MCFuncDesc structure allows you to specify an IID for
- // individual MCFuncDesc, the Virtual Machine requires that all MCFuncDesc's
- // in a .class file reference the same IID in the GuidPool.
- //
- // (This restriction does not apply to IID's embedded in the MCTypeDesc's
- // within the parameter arrays and return types of the MCFuncDesc's.)
- //
- //
- // This attributes stores the "method signatures" of the COM methods
- // that are invoked by and implemented by the Java methods in the .class
- // file. These "signatures" (MCFuncDesc's) are referenced by index by
- // other attributes in the class. Valid indices range from 0 inclusive to
- // nFuncs exclusive. The index 0xffff is reserved to indicate
- // the "null" index.
- //
- //
- // Attribute elements:
- //
- // WORD nFuncs;
- //
- // This field indicates the number of MCFuncDesc's defined in this
- // table.
- //
- // MCFuncDesc aFuncDesc[nFuncs]
- //
- // This array stores the actual MCFuncDesc's. MCFuncDesc's
- // are variable-sized structure.
- //========================================================================
- typedef struct {
- WORD nFuncs; // # of functions in table
- // MCFuncDesc aMCFunc[nFuncs]
- } MCMethodPool;
-
- // for compatibility with users of older headers.
- typedef MCMethodPool MCMP_Attr;
-
-
- //========================================================================
- // Structure: MCTypeDesc
- //
- // This structure describes the type of a parameter or return value
- // of a COM method.
- //
- // Structure elements:
- //
- // BYTE Type
- //
- // See the TD_* enumeration below.
- //
- // TD_VOID is permitted only as the return type of a function.
- //
- //
- //
- // BYTE Flags
- //
- // The flags are grouped into in/out flags, thread-model flags,
- // and attribute flags.
- //
- // In/Out:
- // If the MCTypeDesc is used to describe a parameter, the flags
- // must specify one of TDF_IN, TDF_OUT or TDF_INOUT. 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.
- //
- //
- // Threading Model:
- // This subflag is meaningful only for the TD_INTF type.
- // For all others, it must be set to zero.
- // This subflag indicates the expected Threading Model of
- // of the interface pointer. If the Virtual Machine creates
- // a JCW to represent this COM interface, it will do the
- // appropriate marshaling. If this TypeDesc is being
- // used to marshal to a Java class that is not a JCW,
- // this subflag must be have the value TDF_NOMARSHAL.
- //
- // In certain cases, the Virtual Machine 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
- // Virtual Machine itself (these interface pointers are all
- // free-threaded.)
- //
- // *** NEW FOR SDK 3.2 ***
- // Attributes:
- // These flags are used only on method parameters and return
- // values of type TD_JARR and TD_INTF- they should not be set
- // in a 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).
- // There are currently two supported flags:
- // TDF_USES_IID_IS:
- // 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:
- // 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.
- // *** END NEW ***
- //
- //
- // union {
- // WORD IIDIndex; // for TD_INTF, if TDF_USES_IID_IS is not set.
- // WORD SizeIndex; // for TD_STRUCT
- // WORD wSize; // for TD_SYSFIXEDSTRING, TD_FIXEDARRAY, and TD_JARR
- // WORD wiHookClass; // for TD_CUSTOM, TD_CUSTOMBYREF, and TD_CUSTOMBYVAL
- // VARTYPE VarType; // for TD_SAFEARRAY
- // struct {
- // BYTE biParam; // for TD_JARR, if TDF_USES_SIZE_IS is set,
- // // and TD_INTF, if TDF_USES_IID_IS is set
- // BYTE bReserved;
- // } a;
- // }
- //
- // 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.
- //
- // If the type is TD_STRUCT, this field 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.
- //
- // If the type is TD_SYSFIXEDSTRING, TD_FIXEDARRAY, or
- // TD_JARR, this field must be set to the number of elements
- // in the array.
- //
- // *** NEW FOR SDK 3.2 ***
- // If the type is TD_JARR, and TDF_USES_SIZE_IS is specified
- // in the flags, this field (a.biParam) is the zero-based index
- // of the parameter that determines the dynamic (runtime) size
- // of this array parameter. The referenced parameter must be of
- // integral or array of integral type. This is similar to the
- // MIDL attribute/concept "size_is". a.bReserved must be set
- // to zero.
- // *** END NEW ***
- //
- // If the type is TD_INTF, this field must be set to a valid
- // index into the GuidPool. 0xffff (the "null" index) is not
- // valid.
- //
- // *** NEW FOR SDK 3.2 ***
- // If the type is TD_INTF, and TDF_USES_IID_IS is specified
- // in the flags, this field (a.biParam) is the zero-based index
- // of a parameter that determines the dynamic (runtime) IID
- // of this interface parameter. The referenced parameter must
- // be of "struct" or array of "struct" type. This is similar to
- // the MIDL attribute/concept "iid_is". a.bReserved must be set
- // to zero.
- // *** END NEW ***
- //
- // If the type is TD_CUSTOM, TD_CUSTOMBYREF, or TD_CUSTOMBYVAL,
- // this field 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 specifies the class
- // that will perform the custom marshaling.
- //
- // If the type is TD_SAFEARRAY, this field 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*.
- //
- //========================================================================
-
- // MCTypeDesc enums
- #define TD_VOID 0x00
- #define TD_I1 0x01 //signed 8-bit
- #define TD_I2 0x02 //signed 16-bit
- #define TD_I4 0x03 //signed 32-bit
- #define TD_I8 0x04 //signed 64-bit
- #define TD_U1 0x05 //unsgnd 8-bit
- #define TD_U2 0x06 //unsgnd 16-bit
- #define TD_U4 0x07 //unsgnd 32-bit
- #define TD_U8 0x08 //unsgnd 64-bit
- #define TD_R4 0x09 //32-bit float
- #define TD_R8 0x0a //64-bit float
- #define TD_PTR 0x0b //ptr to data
- #define TD_STRUCT 0x0c //byval struct (requires size)
- #define TD_INTF 0x0d //IUnknown* derivative
- #define TD_JSTR 0x0e //JString
- #define TD_JARR 0x0f //JArray
- #define TD_VARIANT 0x10 //Variant
- #define TD_CUSTOM 0x11 //custom type
- #define TD_CUSTOMBYREF 0x12 //custom type byref
- #define TD_CUSTOMBYVAL 0x13 //custom type byval
- #define TD_SAFEARRAY 0x14 //SafeArray
- #define TD_SYSCHAR 0x15 //Unicode char or ansi char, depending on platform setting
- #define TD_SYSFIXEDSTRING 0x16 //Fixed ansi/unicode string (for use inside structs: SizeIndex == #ofchars, including null terminator)
- #define TD_FIXEDARRAY 0x17 //Fixed size array of scalares (for use inside structs: SizeIndex == # of elements)
- #define TD_OBJECT 0x18 //Field type of "L<something>". Treat as embedded struct if JCDW; treat as COM ifc if Object or Ifc.
-
- // MCTypeDesc flags
- #define TDF_INOUTMASK (TDF_IN|TDF_OUT)
- #define TDF_IN 0x01
- #define TDF_OUT 0x02
- #define TDF_INOUT (TDF_IN|TDF_OUT)
-
-
- // Note: We overload TDF_LCID with TDF_AUTOMARSHAL - since TDF_LCID
- // is only valid on integer types, and TDF_AUTOMARSHAL is only valid
- // on interface types.
- #define TDF_LCID 0x04
-
- #define TDF_AUTOMARSHAL 0x04
- #define TDF_NOMARSHAL 0x08
- #define TDF_THREADMODELMASK (TDF_AUTOMARSHAL|TDF_NOMARSHAL)
-
- // attributes- valid only for interfaces (TD_INTF) and arrays (TD_JARR).
- #define TDF_PARAM_DEPENDENCY 0x10
- #define TDF_USES_IID_IS TDF_PARAM_DEPENDENCY // for TD_INTF
- #define TDF_USES_SIZE_IS TDF_PARAM_DEPENDENCY // for TD_JARR
-
- #define TDF_USER1 0x80
- #define TDF_USER2 0x40
- #define TDF_USERMASK (TDF_USER1|TDF_USER2)
-
-
- // Describes a single parameter or return value or type of field.
- typedef struct {
- BYTE Type; // TD_* value
- BYTE Flags; // TDF_* flags
- union {
- WORD IIDIndex; // for TD_INTF, if TDF_USES_IID_IS is not set.
- WORD SizeIndex; // for TD_STRUCT
- WORD wSize; // for TD_SYSFIXEDSTRING, TD_FIXEDARRAY, and TD_JARR
- WORD wiHookClass; // for TD_CUSTOM, TD_CUSTOMBYREF, and TD_CUSTOMBYVAL
- VARTYPE VarType; // for TD_SAFEARRAY
- struct {
- BYTE biParam; // for TD_JARR, if TDF_USES_SIZE_IS is set,
- // and TD_INTF, if TDF_USES_IID_IS is set
- BYTE bReserved;
- } a;
- };
- } MCTypeDesc;
-
-
- //========================================================================
- // Structure: MCVtblMethod
- //
- // This structure describes a vtable-based method in a COM interface.
- // References to this structure can appear in both ExposedAs_Group
- // attributes and ProxiesTo attributes.
- //
- // Elements:
- // WORD IIDIndex
- //
- // A valid index into the GuidPool that describes the IID of
- // the COM interface that implements this method.
- // 0xffff is not valid here.
- //
- //
- // WORD VtblIndex
- //
- // Denotes which vtable element the method occupies.
- // The values 0, 1 and 2 are not legal here since these correspond
- // to the IUnknown* methods which cannot be overridden.
- // In addition, if the methodpool contains MCDispMethod's
- // using the same IID, values 3,4,5,6 must be avoided (as
- // they correspond to IDispatch* methods which are supplied
- // by the Virtual Machine.)
- //
- //
- // WORD nArguments
- // The number of parameters in the aParamType[] element. This
- // count does not include the automatic "this" parameter passed
- // to all COM methods.
- //
- // If the wRetValParameter element is 0xffff, this count must match
- // the number of parameters in the corresponding Java signature
- // exactly. Otherwise, the count must be exactly one greater than
- // the corresponding Java signature.
- //
- //
- // WORD wRetValParameter
- // If this element contains a value other than 0xffff, it must
- // contains a value between 0 (inclusive) and nArguments (exclusive).
- // This indicates that the parameter whose index is equal to
- // wRetValParameter is actually a pointer through which the
- // method returns its "true" return value. The aParamType for
- // this parameter must indicate the type of the buffer (the
- // "pointer to" is implicit), and the RetType must be TD_VOID.
- // In addition, the return type of the Java method sig must
- // be compatible with the retval parameter.
- //
- // If this COM method is invoked from Java, the Virtual Machine
- // will supply a return value buffer of the appropriate type
- // to the COM method. Upon a successful return from the COM method,
- // (see MCFuncDesc.Flags for what constitutes a successful return).
- //
- // If Java is used to implement this COM method, the Virtual Machine
- // will remove the retval pointer parameter from the list of arguments
- // presented to the Java method. When the Java method returns,
- // the Virtual Machine will convert the Java method's return value
- // to COM representation, then write it to the retval buffer
- // passed in from COM. The Virtual Machine will then create
- // a COM return value that indicates success (see MCFuncDesc.Flags for
- // what constitutes a successful return.)
- //
- // MCTypeDesc RetType
- // Describes the return type. This type must be TD_VOID if
- // wRetValParameter contains a value other than 0xffff, or
- // if MCFuncDesc.Flags has the MCMDF_HRESULT_RETVAL bit set.
- //
- // MCTypeDesc aParamType[nArguments]
- // Describes the parameter of each COM method.
- //
- // *** NEW FOR VERSION 4.0 ***
- // If MCMDF_HRESULT_RETVAL|MCMDF_IGNORE_NONFAILING_HRESULTS are both
- // set and wRetValParameter == -1 and the Java method's return type
- // is 'Z' (boolean), the VM will transform:
- //
- // true <--> S_OK
- // false <--> S_FALSE
- // throw ComException <--> other
- //
- //
- //========================================================================
- typedef struct {
- WORD IIDIndex;
- WORD VtblIndex;
- WORD nArguments;
- WORD wRetValParameter; // -1 means none
- MCTypeDesc RetType;
- // Followed by array of MCTypeDesc's for parameters
- MCTypeDesc aParamType[1];
- } MCVtblMethod;
-
-
-
- // These values intentionally match the VT_* enum values that are allowed
- // in a VARIANT.
- #define VTD_EMPTY ((BYTE)0)
- #define VTD_NULL ((BYTE)1)
- #define VTD_I2 ((BYTE)2)
- #define VTD_I4 ((BYTE)3)
- #define VTD_R4 ((BYTE)4)
- #define VTD_R8 ((BYTE)5)
- #define VTD_CY ((BYTE)6)
- #define VTD_DATE ((BYTE)7)
- #define VTD_BSTR ((BYTE)8)
- #define VTD_DISPATCH ((BYTE)9)
- #define VTD_ERROR ((BYTE)10)
- #define VTD_BOOL ((BYTE)11)
- #define VTD_VARIANT ((BYTE)12)
- #define VTD_UNKNOWN ((BYTE)13)
- #define VTD_UI1 ((BYTE)17)
-
- // Modifiers to VTD_ types. These do not have the same values as their VT_*
- // equivalents because those values don't fit in a byte.
- #define VTD_BYREF ((BYTE)0x80)
- #define VTD_ARRAY ((BYTE)0x40)
-
-
- //========================================================================
- // Structure: MCVarTypeDesc
- //
- // Describes the type of a single parameter or return value to an
- // IDispatch method.
- //
- // Elements:
- //
- // BYTE type
- // This field contains a "compressed VARTYPE" value, defined
- // by the VTD_* values.
- //
- // WORD optname
- // If non-zero, this field must be a constant-pool index to
- // a CP_Utf8 which gives the name of the parameter.
- // This field is optional.
- //
- // BYTE Flags
- //
- // The flags are grouped into in/out and thread-model flags.
- //
- // In/Out:
- // If the MCVarTypeDesc is used to describe a parameter, the flags
- // must specify one of TDF_IN, TDF_OUT or TDF_INOUT. If "type" 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.
- //
- //
- // Threading Model:
- // This subflag is meaningful only for the VTD_DISPATCH and
- // VTD_UNKNOWN types. For all others, it must be set to zero.
- // See the description for MCTypeDesc.Flags- the same values
- // and semantics apply.
- //
- //========================================================================
- typedef struct {
- BYTE type; //VTD_* value
- WORD optname; //(0 or constant-pool index to utf8)
- BYTE Flags; // TDF_* values
- } MCVarTypeDesc;
-
-
- //========================================================================
- // Structure: MCDispMethod
- //
- // This structure describes an Ole Automation method or property.
- //
- // Elements:
- // WORD IIDIndex
- // This field must be a valid index into the GUID pool and
- // denotes the IID (typically IID_IDispatch, but can be any
- // interface that derives from IDispatch.) through which
- // this method is exposed.
- //
- // DWORD Dispid
- // Specifies the DISPID of this method or property.
- //
- // WORD disptype
- // Describes the dispmember type. One of:
- // DISPATCH_PROPERTYGET
- // DISPATCH_PROPERTYPUT
- // DISPATCH_PROPERTYPUTREF
- // DISPATCH_METHOD
- //
- // WORD dispname
- // If this field is non-zero, it must be a valid index into
- // constant-pool and the index must reference a CP_Utf8 which
- // provides the name of the method. This field is required
- // only if the MCDispMethod is referenced by an ExposedAs_Group
- // attribute.
- //
- // WORD nArguments
- // The number of arguments.
- //
- // MCVarTypeDesc RetType
- // Describes the type of the return value.
- //
- // MCVarTypeDesc aParamType[nArguments]
- // Describes the type of each parameter.
- //========================================================================
- typedef struct {
- WORD IIDIndex;
- DWORD Dispid;
- WORD disptype;
- WORD dispname;
- WORD nArguments;
- MCVarTypeDesc RetType;
- // Followed by array of MCVarTypeDesc's for parameters
- MCVarTypeDesc aParamType[1];
- } MCDispMethod;
-
-
- //========================================================================
- // Structure: MCCustomMethod
- //
- // This structure describes a COM vtable method that uses a custom
- // method marshaling hook (Dispatch and dual methods cannot be
- // custom marshaled.) This feature is only supported in IE4 or later.
- //
- // Elements:
- // WORD IIDIndex
- // This field must be a valid index into the GUID pool and
- // denotes the IID through which this method is exposed.
- //
- // WORD VtblIndex
- //
- // Denotes which vtable element the method occupies.
- // The values 0, 1 and 2 are not legal here since these correspond
- // to the IUnknown* methods which cannot be overridden.
- // In addition, if the methodpool contains MCDispMethod's
- // using the same IID, values 3,4,5,6 must be avoided (as
- // they correspond to IDispatch* methods which are supplied
- // by the Virtual Machine.)
- //
- //
- // WORD hookclsIndex
- //
- // Index of a CONSTANT_Class constant-pool item which
- // denotes the Java class that holds the hook methods.
- // This class should derive directly from java.lang.Object
- // to avoid circular loading problems.
- //
- //
- // WORD j2cmethodIndex
- //
- // Index of a CONSTANT_Utf8 constant-pool item which
- // denotes the method within the hook class that is to
- // handle Java->COM calls. The method should have the prototype:
- //
- // public static JTYPE j2chook(int)
- //
- // where JTYPE must be identical to the return type of
- // the associated Java method, with one exception: if the
- // associated Java method returns a reference type (object
- // or array), JTYPE can be declared as "java.lang.Object".
- //
- //
- // WORD c2jmethodIndex
- //
- // Index of a CONSTANT_Utf8 constant-pool item which
- // denotes the method within the hook class that is to
- // handle COM->Java calls. The method should have the prototype:
- //
- // public static void c2jhook(int)
- //
- //
- // WORD cbUserData
- //
- // Number of bytes of user data following the paramFlavor[] array.
- // The VM will not interpret this data but will make it available
- // to the hook methods. This allows one hook method to handle
- // multiple methods.
- //
- //
- // DWORD reserved
- // Reserved for future use. Must set to 0.
- //
- //
- // BYTE bRetFlavor
- // Certain platforms have calling conventions that require
- // distinguishing between normal and floating point values.
- // See the MCARGF_* values for the possible flavors.
- // Because COM methods almost universally return HRESULT's,
- // this field will usually be set to MCARGF_I4. This field
- // cannot be used to indicate the flavor of an [out,retval]
- // parameter (these need to be set in the paramFlavor[] array -
- // the flavor is MCARGF_PTR).
- //
- // BYTE cbSpecialComArgs
- // Indicates the size of the paramFlavor[] array.
- //
- //
- // MCSpecialArgumentEntry paramFlavor[cbSpecialComArgs]
- // Note: This is a variable length array and is not
- // indicated in the struct definition. It follows the
- // cbSpecialComArgs field.
- //
- // Indicates the flavor of all parameters that are *not*
- // type MCARGF_I4, *or* the final parameter. The final parameter
- // must always be declared because on some platforms, the
- // total size of the argument stack is needed to implement
- // stdcall calling correctly. The fields of an MCSpecialArgumentEntry
- // are:
- // bArgIndex:
- // where 0 denotes the first 4-byte argument after the "this"
- // pointer, 1 denotes the second 4-byte argument after the'
- // "this" pointer and so forth. The "this" pointer is
- // implicitly MCARGF_PTR, so it's flavor need not (and cannot)
- // be indicated in this table.
- //
- // bArgFlavor:
- // Must be one of the MCARGF_* values.
- //
- // BYTE userData[cbUserData]
- // Note: This is a variable length array and is not
- // indicated in the struct definition. It follows the
- // cbSpecialComArgs field.
- //
- // Any userdata associated with this method. The VM does
- // not interpret this data but hook methods can access it.
- //
- //
- //========================================================================
-
- #define MCARGF_I4 0 // 4-byte integer
- #define MCARGF_R4 1 // 4-byte floating point
- #define MCARGF_R8 2 // 8-byte floating point
- #define MCARGF_I8 3 // 8-byte integer
- #define MCARGF_PTR 4 // machine address
- #define MCARGF_STRUCT 5 // structure (takes up two slots: slot following
- // is the size of the structure in bytes.)
-
-
- typedef struct {
- BYTE bArgIndex; // index of argument
- BYTE bArgFlavor; // See MCARGF_* constants
- } MCSpecialArgumentEntry;
-
- typedef struct {
- WORD IIDIndex;
- WORD VtblIndex;
- WORD hookclsIndex; //hook class
- WORD j2cmethodIndex; //name of method for Java->COM marshaling
- WORD c2jmethodIndex; //name of method for COM->Java marshaling
- WORD cbUserData; // # of bytes of user data
- DWORD reserved; // must be 0: reserved for future use.
- BYTE bRetFlavor; // see MCARGF_* constants
- BYTE cbSpecialComArgs; // # of non-I4 com arguments
-
- // Following this is the paramFlavor[] array.
- // Following that are bytes of user data ("cbUserData" bytes in all.)
- } MCCustomMethod;
-
-
- //========================================================================
- // Structure: MCFuncDesc
- //
- // This structure describes a single method in the method pool.
- //
- // Elements:
- // WORD cbSize
- // The size of the entire MCFuncDesc (including the cbSize field)
- // in bytes.
- //
- // WORD Flags
- // MCMDF_DISPATCH
- // This flag indicates that the function is a Dispatch method.
- //
- // MCMDF_HRESULT_RETVAL
- // This flag may not be used together with MCMDF_DISPATCH.
- // This flag indicates that the return type of the
- // method is an HRESULT and that it is to be mapped to
- // an exception on the Java side.
- //
- // If this flag is used, the declared type of the RetVal
- // must be TD_VOID.
- //
- // When this flag is on, the Virtual Machine will treat
- // all return values from COM objects as hresults and
- // will throw a Java exception (details TBD) if the hresult
- // is not S_OK.
- //
- // Conversely, the Virtual Machine will map all uncaught
- // exceptions from Java code into a failing HRESULT,
- // and will supply a return value of S_OK otherwise.
- //
- // *** NEW FOR VERSION 4.0 ***
- // MCMDF_IGNORE_NONFAILING_HRESULTS
- // This flag may not be used together with MCMDF_DISPATCH.
- //
- // This flag works in conjunction with MCMDF_HRESULT_RETVAL.
- // If set, only HRESULT's that have the high bit (FAIL)
- // set will generate a Java exception. Non-zero HRESULT's
- // that do not set the bit (such as S_FALSE) will not
- // generate an exception.
- //
- //
- //
- //
- //========================================================================
-
- // Structure name: MCFuncDesc.
- #define MCMDF_DISPATCH 0x0001
- #define MCMDF_HRESULT_RETVAL 0x0002 // legal only if !MCMDF_DISPATCH
- #define MCMDF_IGNORE_NONFAILING_HRESULTS 0x0004 // legal only if !MCMDF_DISPATCH
-
- #define MCMDF_CUSTOM 0x0008 // legal only if !(MCMDF_DISPATCH|MCMDF_HRESULT_RETVAL|MCMDF_IGNORE_NONFAILING_HRESULTS)
-
- typedef struct {
- WORD cbSize; // size of entire MCFuncDesc in bytes
- WORD Flags; // MCMCDF_* values
- union {
- MCVtblMethod mvm;
- MCDispMethod mdm;
- MCCustomMethod mcm;
- };
- } MCFuncDesc;
-
-
- //========================================================================
- // Attribute Name: COM_ExposedAs_Group
- // Attribute Level: Method
- // Restrictions:
- // The access flags for the method must be a subset of:
- //
- // ACC_PUBLIC
- // ACC_PRIVATE
- // ACC_PROTECTED
- // ACC_FINAL
- // ACC_SYNCHRONIZED
- // ACC_NATIVE
- // ACC_ABSTRACT
- //
- // The ExposedAs_Group is a collection of ExposedAs structures, each
- // of which causes the Java method to be exposed as a COM method.
- //
- // Attribute Elements:
- // WORD Flags
- // Must be 0.
- //
- // WORD nExposedAs
- // # of ExposedAs attributes that follow.
- //
- // MCEA ExposedAs[nExposedAs]
- // Array of exposed as.
- //========================================================================
-
- typedef struct _Microsoft_COM_ExposedAs_Group {
- WORD Flags; //none defined
- WORD nExposedAs;
- // followed by array of MCExposedAs's.
- } MCExposedAsGroup;
-
- // for compatibility with users of older headers.
- typedef MCExposedAsGroup MCEAG_Attr;
-
-
- //========================================================================
- // Structure: _Microsoft_COM_ExposedAs
- //
- // Each ExposedAs structure causes the Java method to be exposed as a COM
- // method.
- // Elements:
- // WORD Flags
- // Must be 0.
- //
- // WORD MethodPoolIndex
- // Must be a valid index into the MethodPool.
- //========================================================================
- typedef struct _Microsoft_COM_ExposedAs {
- WORD Flags;
- WORD MethodPoolIndex;
- } MCExposedAs;
-
- // for compatibility with users of older headers.
- typedef MCExposedAs MCEA;
-
-
- //========================================================================
- // Attribute Name: COM_ProxiesTo
- // Attribute Level: Method
- // Restrictions:
- // The access flags for the method must be a subset of:
- //
- // ACC_PUBLIC
- // ACC_PRIVATE
- // ACC_PROTECTED
- // ACC_FINAL
- // ACC_NATIVE (required)
- // ACC_ABSTRACT (on interfaces only)
- //
- //
- // The ProxiesTo attribute denotes that the Java method is implemented
- // using COM.
- //
- // Attribute Elements:
- // WORD MCP_Flags
- // Must be 0.
- //
- // WORD MethodPoolIndex
- // Must be a valid index into the MethodPool.
- //========================================================================
- typedef struct _Microsoft_COM_ProxiesTo {
- WORD MCP_Flags;
- WORD MethodPoolIndex;
- } MCProxiesTo;
-
- // for compatibility with users of older headers.
- typedef MCProxiesTo MCPT_Attr;
-
-
- //========================================================================
- // Attribute Name: COM_MapsTo
- // Attribute Level: Field
- // Restrictions:
- // The access flags for the field must be a subset of:
- //
- // ACC_PUBLIC
- // ACC_PRIVATE
- // ACC_PROTECTED
- // ACC_FINAL
- //
- //
- // The MapsTo attribute denotes that the data for the field is actually
- // stored in externally allocated memory.
- //
- // Attribute Elements:
- // WORD Flags
- // MTF_AUTOOFFSET:
- // If this flag is set, dwOffset must be 0 and the offset will
- // be computed by the Virtual Machine for the hosting platform.
- // This allows the structure definition to move freely between
- // platforms.
- //
- // Every MapsTo in a .class file must use the same setting
- // for MTF_AUTOOFFSET.
- //
- // The auto-packing algorithm for the x86 platform is ???.
- //
- // WORD wPad
- // Must be 0
- //
- // DWORD dwOffset
- // The offset in bytes within the external data structure.
- // If MTF_AUTOOFFSET is on, this field has no meaning and must be
- // set to 0.
- //
- // MCTypeDesc typedesc
- // Describes the native type of the field..
- //========================================================================
- typedef struct _Microsoft_COM_MapsTo {
- WORD Flags; // MTF_* values
- WORD wPad;
- DWORD dwOffset;
- MCTypeDesc typedesc;
- } MCMapsTo;
-
- // for compatibility with users of older headers.
- typedef MCMapsTo MCMT_Attr;
-
-
- #define MTF_AUTOOFFSET 0x0001
-
-
- // These are defined only for backward compatibility with older sources.
- // New code should not use these names.
- #define TDF_SINGLE 0x00
- #define TDF_APARTMENT TDF_AUTOMARSHAL
- #define TDF_FREE TDF_NOMARSHAL
-
-
- #include <poppack.h>
-
- #endif // COMATTR_H
-