mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-08 07:42:33 +01:00
Author:admin
Date:2008-09-17T13:53:28.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@3 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
[[Property:title|EiffelCOM Content]]
|
||||
[[Property:link_title|EiffelCOM Interface Content]]
|
||||
[[Property:weight|-2]]
|
||||
The EiffelCOM library includes the following clusters:
|
||||
* A [[ref:libraries/com/reference/index|Constants]] cluster provides standard COM constants and enumerations.
|
||||
* A [[Interfaces|Interfaces]] cluster includes wrappers for standard interfaces that the EiffelCOM wizard does not generate and deferred classes: [[ref:libraries/com/reference/ecom_interface_chart|ECOM_INTERFACE]] , [[ref:libraries/com/reference/ecom_queriable_chart|ECOM_QUERIABLE]] , and [[ref:libraries/com/reference/ecom_stub_chart|ECOM_STUB]] .
|
||||
* A [[Structures|Structures]] cluster includes wrappers for COM structures and additional data structures.
|
||||
* A [[ref:libraries/com/reference/index|Support]] cluster provides access to helper classes.
|
||||
|
||||
{{seealso| '''See Also''' <br/>
|
||||
[[EiffelCOM|The Component Object Model]] <br/>
|
||||
[[EiffelCOM Wizard|EiffelCOM wizard]] }}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
[[Property:title|Interfaces]]
|
||||
[[Property:weight|0]]
|
||||
COM interfaces have several facets. First, an interface is a deferred, or an abstract, class. This means that an interface is a specification of a type. Second, an interface pointer represents a COM object, which is callable by a client application. An object can expose several interfaces, or represent several types.
|
||||
|
||||
==ECOM_INTERFACE==
|
||||
|
||||
For each interface listed in a type library, the EiffelCOM wizard generates a deferred class and two effective classes: a proxy of an interface pointer, or a client side class, and a stub of an interface pointer, or a server side class. The deferred interface class inherits from <eiffel>[libraries/com/reference/ecom_interface_chart.xml| ECOM_INTERFACE ]</eiffel> and has a deferred feature per each interface function. Both effective classes, or implemented interfaces, inherit from the deferred class and implement its functions. The functions of the interface proxy calls the underlying C layer, which in turn calls the COM component while the functions of the interface stub implement the component functionality.
|
||||
|
||||
[[ref:libraries/com/reference/ecom_interface_chart|ECOM_INTERFACE]] holds a pointer to the underlying COM interface.
|
||||
|
||||
==ECOM_QUERIABLE==
|
||||
|
||||
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>
|
||||
|
||||
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>.
|
||||
|
||||
==ECOM_STUB==
|
||||
|
||||
[[ref:libraries/com/reference/ecom_stub_chart|ECOM_STUB]] inherits from [[ref:libraries/com/reference/ecom_interface_chart|ECOM_INTERFACE]] , and exposes the feature <code> [[ref:libraries/com/reference/ecom_stub_chart|create_item]] </code> which allows creating the underlying COM object.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
[[Property:title|Structures]]
|
||||
[[Property:weight|1]]
|
||||
The [[ref:libraries/com/reference/index|Structures]] cluster includes wrappers for data structures useful when using the COM technology.
|
||||
|
||||
==ECOM_ARRAY==
|
||||
|
||||
ECOM_ARRAY is a multidimensional, resizable array. It is converted to SAFEARRAY at the COM runtime level. Most languages only support SAFEARRAYs of OLE automation types.
|
||||
|
||||
==ECOM_EXCEPTION==
|
||||
|
||||
ECOM_EXCEPTION provides support for triggering and catching exceptions. According to the COM specification, every feature of a COM interface should return a status code of type HRESULT. HRESULT is a 32 bit integer. The COM specification defines possible exception codes and corresponding human-readable descriptions.
|
||||
|
||||
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>
|
||||
|
||||
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_code: INTEGER
|
||||
-- Status 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>
|
||||
|
||||
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>
|
||||
|
||||
==ECOM_STRUCTURE==
|
||||
|
||||
ECOM_STRUCTURE is a deferred class which inherits from WEL_STRUCTURE. All wrappers of COM structures inherit from ECOM_STRUCTURE.
|
||||
|
||||
==ECOM_VARIANT==
|
||||
|
||||
ECOM_VARIANT is a wrapper of the VARIANT structure. VARIANT is the Visual Basic equivalent to Eiffel's <eiffel>ANY</eiffel>. In Visual Basic all variable types conform to VARIANT. Since the semantics and runtime architecture of Visual Basic are different from those of Eiffel, there is no simple way to map VARIANT to ANY. Instead, EiffelCOM provides an Eiffel wrapper around the VARIANT structure.
|
||||
|
||||
This wrapper exposes the feature
|
||||
<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.
|
||||
|
||||
==ECOM_VARIANT_ACCESS==
|
||||
|
||||
<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.
|
||||
</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.
|
||||
|
||||
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
|
||||
|
||||
inherit
|
||||
APPLICATION_PROXY
|
||||
|
||||
ECOM_VARIANT_ACCESS
|
||||
|
||||
feature
|
||||
|
||||
add_workbook is
|
||||
local
|
||||
workbook: WORKBOOK_PROXY
|
||||
do
|
||||
workbook := workbooks.add (missing, 0)
|
||||
end
|
||||
</code>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
[[Property:title|EiffelCOM Library]]
|
||||
[[Property:weight|8]]
|
||||
Type: Library <br/>
|
||||
Platform: Windows <br/>
|
||||
|
||||
|
||||
See:
|
||||
* [[EiffelCOM Introduction|Introduction]]
|
||||
* [[EiffelCOM Content|Content]]
|
||||
* [[ref:libraries/com/reference/index|Reference]]
|
||||
|
||||
{{seealso| '''See Also''' <br/>
|
||||
[[EiffelCOM|The Component Object Model]] <br/>
|
||||
[[EiffelCOM Wizard|EiffelCOM wizard]] }}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user