|
|
Line 48: |
Line 48: |
| </source> | | </source> |
| | | |
− | === 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.
| |
− | <source lang="idl">
| |
− | // UNO IDL
| |
− | float func();
| |
− | </source>
| |
− | <source lang="vb">
| |
− | ' VB
| |
− | Dim ret As Single
| |
− | ret= obj.func() 'no conversion by VB
| |
− |
| |
− | Dim ret2 As String
| |
− | ret2= obj.func() 'VB converts float to string
| |
− | </source>
| |
− |
| |
− | When the function returns, VB converts the <code>float</code> value into a <code>string</code> and assigns it to <code>ret2</code>. Such a conversion comes in useful when functions return a character, and a string is preferred instead of a VB Integer value.
| |
− | <source lang="idl">
| |
− | // UNO IDL
| |
− | char func();
| |
− | </source>
| |
− | <source lang="vb">
| |
− | ' VB
| |
− | Dim ret As String
| |
− | ret= obj.func()'VB converts the returned short into a string
| |
− | </source>
| |
− |
| |
− | 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:
| |
− | <source lang="idl">
| |
− | // UNO IDL
| |
− | float func(); //returns 3.14
| |
− | </source>
| |
− | <source lang="javascript">
| |
− | // JScript
| |
− | var ret= obj.func(); // implicit conversion from float to double, ret= 3.14000010490417
| |
− | </source>
| |
− |
| |
− | === 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.
| |
− | <source lang="idl">
| |
− | // UNO IDL
| |
− | float func();
| |
− | </source>
| |
− | <source lang="vb">
| |
− | ' VB
| |
− | Dim ret As Single
| |
− | ret= obj.func() 'no conversion by VB
| |
− |
| |
− | Dim ret2 As String
| |
− | ret2= obj.func() 'VB converts float to string
| |
− | </source>
| |
− |
| |
− | When the function returns, VB converts the <code>float</code> value into a <code>string</code> and assigns it to <code>ret2</code>. Such a conversion comes in useful when functions return a character, and a string is preferred instead of a VB Integer value.
| |
− | <source lang="idl">
| |
− | // UNO IDL
| |
− | char func();
| |
− | </source>
| |
− | <source lang="vb">
| |
− | ' VB
| |
− | Dim ret As String
| |
− | ret= obj.func()'VB converts the returned short into a string
| |
− | </source>
| |
− |
| |
− | 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:
| |
− | <source lang="idl">
| |
− | // UNO IDL
| |
− | float func(); //returns 3.14
| |
− | </source>
| |
− | <source lang="javascript">
| |
− | // JScript
| |
− | var ret= obj.func(); // implicit conversion from float to double, ret= 3.14000010490417
| |
− | </source>
| |
| | | |
| {{PDL1}} | | {{PDL1}} |
| | | |
| [[Category:Documentation/Developer's Guide/Professional UNO]] | | [[Category:Documentation/Developer's Guide/Professional UNO]] |
Revision as of 08:21, 29 March 2011
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.
' 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.
' 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