Previous Table of Contents Next


19.9.10 A Complete OMG IDL to ODL Mapping for the Basic Data Types


   As previously stated, there is no requirement that the ODL code expressing the mapped Automation interface actually exist. Other equivalent expressions of Automation interfaces, such as the contents of a Type Library, may be used. Moreover, there is no requirement that OMG IDL code corresponding to the CORBA View Interface be generated.

   However, ODL is the appropriate medium for describing an Automation interface, and OMG IDL is the appropriate medium for describing a CORBA View Interface. Therefore, we provide the following ODL code to describe an Automation interface, that exercises all of the Automation base data types in the roles of properties, method [in] parameter, method [out] parameter, method [inout] parameter, and return value. The ODL code is followed by OMG IDL code describing the CORBA View Interface, which would result from a conformant mapping.

   // ODL[odl, dual, uuid(...)]interface DIMyModule_TypesTest: IForeignObject {

   [propput] HRESULT boolTest([in] VARIANT BOOL boolTest);[propget] HRESULT boolTest([retval,out] short *val);[propput] HRESULT doubleTest([in] double doubleTest);[propget] HRESULT doubleTest([retval,out] double *val);[propput] HRESULT floatTest([in] float floatTest);[propget] HRESULT floatTest([retval,out] float *val);[propput] HRESULT longTest([in] long longTest);[propget] HRESULT longTest([retval,out] long *val);[propput] HRESULT shortTest([in] short shortTest);[propget] HRESULT shortTest([retval,out] short *val);[propput] HRESULT stringTest([in] BSTR stringTest);[propget] HRESULT stringTest([retval,out] BSTR *val);[propput] HRESULT dateTest([in] DATE stringTest);[propget] HRESULT dateTest([retval,out] DATE *val);[propput] HRESULT currencyTest([in] CURRENCY stringTest);[propget] HRESULT currencyTest([retval,out] CURRENCY *val);[propget] HRESULT readonlyShortTest([retval,out] short

*val);

HRESULT setAll(

HRESULT getAll(

[in] VARIANT BOOL boolTest,
[in] double doubleTest,
[in] float floatTest,
[in] long longTest,
[in] short shortTest,
[in] BSTR stringTest,
[in] DATE dateTest,
[in] CURRENCY currencyTest,
[retval,out] short * val);
[out] VARIANT BOOL *boolTest,
[out] double *doubleTest,
[out] float *floatTest,
[out] long *longTest,
[out] short *shortTest,
[out] BSTR stringTest,
[out] DATE * dateTest,
[out] CURRENCY *currencyTest,

   [retval,out] short * val);

HRESULT setAndIncrement( [in,out] VARIANT BOOL *boolTest,
[in,out] double *doubleTest,
[in,out] float *floatTest,
[in,out] long *longTest,
[in,out] short *shortTest,
[in,out] BSTR *stringTest,
[in,out] DATE * dateTest,
[in,out] CURRENCY * currencyTest,
[retval,out] short *val);
HRESULT boolReturn( [retval,out] VARIANT BOOL *val);
HRESULT doubleReturn( [retval,out] double *val);
HRESULT floatReturn( [retval,out] float *val);
HRESULT longReturn( [retval,out] long *val);
HRESULT shortReturn( [retval,out] short *val);
HRESULT stringReturn( [retval,out] BSTR *val);
HRESULT octetReturn( [retval,out] DATE *val);
HRESULT currencyReturn( [retval,out] CURRENCY *val);
}

   The corresponding OMG IDL is as follows.

   // OMG IDL interface MyModule_TypesTest

   {

   attribute boolean boolTest; attribute double doubleTest; attribute float floatTest; attribute long longTest; attribute short shortTest; attribute string stringTest; attribute double dateTest; attribute COM::Currency currencyTest;

   readonly attribute short readonlyShortTest;

   // Sets all the attributes

   boolean setAll (in boolean boolTest, in double doubleTest, in float floatTest, in long longTest, in short shortTest, in string stringTest, in double dateTest, in COM::Currency currencyTest);

   // Gets all the attributes

   boolean getAll (out boolean boolTest, out double doubleTest, out float floatTest, out long longTest, out short shortTest, out string stringTest, out double dateTest, out COM::Currency currencyTest);

   boolean setAndIncrement ( inout boolean boolTest, inout double doubleTest, inout float floatTest, inout long longTest, inout short shortTest, inout string stringTest, inout double dateTest, inout COM::Currency currencyTest);

   boolean boolReturn (); double doubleReturn(); float floatReturn(); long longReturn (); short shortReturn (); string stringReturn(); double dateReturn (); COM::CurrencycurrencyReturn();

   }; // End of Interface TypesTest

   19.9.11 Mapping for Object References

   The mapping of an object reference as a parameter or return value can be fully expressed by the following OMG IDL and ODL code. The ODL code defines an interface “Simple? and another interface that references Simple as an “in? parameter, an “out? parameter, an “inout? parameter, and as a return value. The OMG IDL code describes the CORBA View Interface that results from a proper mapping.

   // ODL[odl, dual, uuid(...)]interface DIMyModule_Simple: IDispatch{

   [propget] HRESULT shortTest([retval, out] short * val);[propput] HRESULT shortTest([in] short sshortTest);}

   [odl, dual, uuid(...)]interface DIMyModule_ObjRefTest: IDispatch{

   [propget] HRESULT simpleTest([retval, out]DIMyModule_Simple ** val); [propput] HRESULT simpleTest([in] DIMyModule_Simple*pSimpleTest);

   HRESULT simpleOp([in] DIMyModule_Simple *inTest, [out] DIMyModule_Simple **outTest, [in,out]DIMyModule_Simple **inoutTest,[retval, out] DIMyModule_Simple **val);

   }

   The OMG IDL code for the CORBA View Dispatch Interface is as follows.

   // OMG IDL // A simple object we can use for testing object references interface MyModule_Simple {

   attribute short shortTest;};

   interface MyModule_ObjRefTest

   { attribute MyModule_Simple simpleTest; MyModule_Simple simpleOp(in MyModule_Simple inTest,

   out MyModule_Simple outTest, inout MyModule_Simple inoutTest); };