Author:halw

Date:2009-01-05T19:34:30.000000Z


git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@152 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
halw
2009-01-05 19:34:30 +00:00
parent ffc468f138
commit 2fa0e9a0ae
7 changed files with 140 additions and 131 deletions

View File

@@ -13,7 +13,7 @@ For each interface listed in a type library, the EiffelCOM wizard generates a de
Different languages handle type coercion in different ways. C uses type cast; C++ introduces several type casting mechanisms; Eiffel uses assignment attempt, etc. Every COM interface exposes the <eiffel>QueryInterface</eiffel> function which allows clients to query the COM component for a pointer to another interface. Querying a component for an interface pointer is similar to using an assignment attempt in Eiffel. The Eiffel implementation of the assignment attempt relies on the runtime data. Since changing the Eiffel runtime and the implementation of the assignment attempt was not an option, EiffelCOM introduces a library class [[ref:libraries/com/reference/ecom_queriable_chart|ECOM_QUERIABLE]] , which has the creation routine
<code>
make_from_other (other: ECOM_INTERFACE)</code>
make_from_other (other: ECOM_INTERFACE)</code>
which queries a COM component internally. Every interface proxy class inherits from [[ref:libraries/com/reference/ecom_queriable_chart|ECOM_QUERIABLE]] . The one difference between this mechanism versus using assignment attempt is that upon failure an exception will be raised. An assignment attempt that fails simply returns <code>Void</code>.

View File

@@ -13,55 +13,55 @@ ECOM_EXCEPTION provides support for triggering and catching exceptions. Accordin
The status code is mapped by the EiffelCOM runtime to Eiffel exceptions. To raise COM-specific exceptions, the class ECOM_EXCEPTION provides the feature <eiffel>trigger</eiffel>:
<code>
trigger (code: INTEGER)
-- Raise exception with code `code'.
-- See class ECOM_EXCEPTION_CODES for possible values.
</code>
trigger (code: INTEGER)
-- Raise exception with code `code'.
-- See class ECOM_EXCEPTION_CODES for possible values.
</code>
The class also has several features that help analyzing exceptions and error codes received from the COM runtime.
<code>
hresult: INTEGER
-- Original HRESULT.
require
applicable: is_developer_exception
hresult: INTEGER
-- Original HRESULT.
require
applicable: is_developer_exception
hresult_code: INTEGER
-- Status code.
require
applicable: is_developer_exception
hresult_code: INTEGER
-- Status code.
require
applicable: is_developer_exception
hresult_facility: INTEGER
-- Facility code.
require
applicable: is_developer_exception
hresult_facility: INTEGER
-- Facility code.
require
applicable: is_developer_exception
hresult_message: STRING
-- Error message.
require
applicable: is_developer_exception
</code>
hresult_message: STRING
-- Error message.
require
applicable: is_developer_exception
</code>
Every call to COM should be wrapped into a <code> rescue </code> clause as follows:
<code>
some_feature is
local
retried: BOOLEAN
...
do
if not retried then
-- Call to COM.
end
rescue
if is_developer_exception then
-- Compare `hresult' to some predefined value
-- and handle various cases,
-- or display a dialog box with an error message
-- `hresult_message'.
end
retried := True
retry
end
</code>
some_feature
local
retried: BOOLEAN
...
do
if not retried then
-- Call to COM.
end
rescue
if is_developer_exception then
-- Compare `hresult' to some predefined value
-- and handle various cases,
-- or display a dialog box with an error message
-- `hresult_message'.
end
retried := True
retry
end
</code>
==ECOM_STRUCTURE==
@@ -73,9 +73,9 @@ ECOM_VARIANT is a wrapper of the VARIANT structure. VARIANT is the Visual Basic
This wrapper exposes the feature
<code>
variable_type: INTEGER
-- Variable type. See class ECOM_VAR_TYPE for possible values.
</code>
variable_type: INTEGER
-- Variable type. See class ECOM_VAR_TYPE for possible values.
</code>
which specifies the actual type of the variant. The class has multiple features for typed access and setting of variables.
@@ -83,9 +83,9 @@ which specifies the actual type of the variant. The class has multiple features
<eiffel>ECOM_VARIANT_ACCESS</eiffel> provides the feature:
<code>
missing: ECOM_VARIANT
-- Value representing the default value of a COM optional argument.
-- Equivalent to an omitted VB argument, or C++ vtMissing, or .NET System.Reflection.Missing.
missing: ECOM_VARIANT
-- Value representing the default value of a COM optional argument.
-- Equivalent to an omitted VB argument, or C++ vtMissing, or .NET System.Reflection.Missing.
</code>
Many COM Automation servers have routines that take arguments with default values. This is very common, for example, in Microsoft Office applications such as Excel and Word. In Visual Basic, such arguments are optional and, when omitted, the server uses the default value. In languages that cannot omit arguments, a special VARIANT value representing the omitted argument must be passed. EiffelCOM applications can pass missing for this purpose.
@@ -93,21 +93,22 @@ Many COM Automation servers have routines that take arguments with default value
For example, the following adds a new workbook to Excel. The default argument tells Excel to decide for itself how many worksheets to put in the new workbook:
<code>
class
MY_EXCEL_APPLICATION
MY_EXCEL_APPLICATION
inherit
APPLICATION_PROXY
APPLICATION_PROXY
ECOM_VARIANT_ACCESS
ECOM_VARIANT_ACCESS
feature
add_workbook is
local
workbook: WORKBOOK_PROXY
do
workbook := workbooks.add (missing, 0)
end
add_workbook
local
workbook: WORKBOOK_PROXY
do
workbook := workbooks.add (missing, 0)
end
</code>