Client-Side Conversions
The UNO IDL description and the defined mappings indicate what to expect as a return value when a particular UNO function is called. However, the language used might apply yet another conversion after a value came over the bridge.
// UNO IDL
float func();
' VB
Dim ret As Single
ret= obj.func() 'no conversion by VB
Dim ret2 As String
ret2= obj.func() 'VB converts float to string
When the function returns, VB converts the float
value into a string
and assigns it to ret2
. Such a conversion comes in useful when functions return a character, and a string is preferred instead of a VB Integer value.
// UNO IDL
char func();
' VB
Dim ret As String
ret= obj.func()'VB converts the returned short into a string
Be aware of the different value spaces if taking advantage of these conversions. That is, if the value space of a variable that receives a return value is smaller than the UNO type, a runtime error might occur if the value does not fit into the provided variable. Refer to the documentation of your language for client-side conversions.
Client-side conversions only work with return values and not with out or inout parameters. The current bridge implementation is unable to transport an out or inout parameter back to Automation if it does not have the expected type according to the default mapping.
Another kind of conversion is done implicitly. The user has no influence on the kind of conversion. For example, the scripting engine used with the Windows Scripting Host or Internet Explorer uses double values for all floating point values. Therefore, when a UNO function returns a float value, then it is converted into a double which may cause a slightly different value. For example:
// UNO IDL
float func(); //returns 3.14
// JScript
var ret= obj.func(); // implicit conversion from float to double, ret= 3.14000010490417
Content on this page is licensed under the Public Documentation License (PDL). |