Microsoft SDK for Java

iid_is and size_is Support

This section describes the mapping of Interface Definition Language (IDL) iid_is and size_is information to @com.parameters declarations.

The following sample code demonstrates this mapping and the use of the JTLBATTR_IID_IS and JTLBATTR_SIZE_IS macros defined in %SDKDIR%\include\javaax.h. These are custom data attribute macros for use in IDL parameter attribute lists.

JTLBATTR_IID_IS and JTLBATTR_SIZE_IS in javaax.h cause iid_is and size_is information to be propagated to type libraries generated by the Microsoft IDL compiler (MIDL). The Jactivex tool can then generate Java classes that carry the iid_is and size_is information.

In the sample code, note the use of type=CUSTOM and customMarshal= in the @com.parameters declarations.

Restrictions

JTLBATTR_SIZE_IS is the analog of IDL size_is. It can be specified only for parameters that will be Java arrays (generally, pointers).

JTLBATTR_IID_IS is the analog of IDL iid_is. It can be specified only for interface pointers and by-reference interface pointers that are also return values.

The dependent iid or size parameter must be the parameter before the size_is or iid_is parameter.

#include <javaax.h>

//IDL Code
[
uuid(AB16555B-F794-4de5-BA85-8326A40C6300),
]
interface IAttributed : IUnknown
{
HRESULT _stdcall CreateInstance(
  [in] REFIID riid,
  [out, retval, iid_is(riid), JTLBATTR_IID_IS("riid")] IUnknown **ppunk);

HRESULT _stdcall In(
  [in] REFIID riid,
  [in, iid_is(riid), JTLBATTR_IID_IS("riid")] IUnknown *punk);

HRESULT _stdcall Next(
  [in] ULONG celt,
  [out, size_is(celt), JTLBATTR_SIZE_IS("celt")] int *rgelt,
  [out] ULONG *pceltFetched);
}

//Mapping of IDL code to @com Declarations
/** @com.interface(iid=AB16555B-F794-4DE5-BA85-8326A40C6300, thread=AUTO)
*/
public interface IAttributed extends com.ms.com.IUnknown
{
  /** @com.method(vtoffset=0)
      @com.parameters([in,type=PTR] riid, [customMarshal="com.ms.com.IIDIsMarshaler",type=CUSTOM] return) */
  public com.ms.com.IUnknown CreateInstance(com.ms.com._Guid riid);

  /** @com.method(vtoffset=1)
      @com.parameters([in,type=PTR] riid, [in,customMarshal="com.ms.com.IIDIsMarshaler",type=CUSTOM] punk) */
  public void In(com.ms.com._Guid riid, com.ms.com.IUnknown punk);

  /** @com.method(vtoffset=2)
      @com.parameters([in,type=U4] celt,
[out,customMarshal="com.ms.com.SizeIsMarshaler",type=CUSTOM] rgelt,
[out,size=1,type=ARRAY] pceltFetched) */
  public void Next(int celt, int[] rgelt, int[] pceltFetched);
}

See Also

%SDKDIR%\Samples\COM\iid_is_size_is

© 1999 Microsoft Corporation. All rights reserved. Terms of use.