Creating a new component from an Eiffel project

The second tutorial describes creating a COM component from an Eiffel system. The tutorial example String is almost identical to StringManipulator of the previous tutorial. In the StringManipulator example the wizard starts from an IDL file and builds an Eiffel System; in contrast, the String example takes an Eiffel system and generates an IDL file and the required plumbing code to make the Eiffel project accessible to COM.

Step by step instructions

  1. Create a new Eiffel project in the directory $ISE_EIFFEL\examples\com\wizard\e2idl\eproject where $ISE_EIFFEL represents the path to the EiffelStudio installation directory.
  2. Select the ECF file located in the same directory and compile.
  3. Start the EiffelCOM Wizard
  4. In Project, in the Current project input field, type in string and press enter.
  5. In Project Type, choose Add a COM interface to an existing Eiffel project.
  6. In the field under Path to Eiffel project location enter $ISE_EIFFEL\examples\com\wizard\e2idl\eproject.
  7. Click the browse button under Path to system's configuration file (*.ecf) and open the file $ISE_EIFFEL\examples\com\wizard\e2idl\eproject\string.ecf.
  8. In the text field under Target to use, enter: string.
  9. In the text field under Name of Eiffel facade class, enter: string_manipulator.
  10. In the text field under Name of Eiffel facade class cluster, enter: root_cluster.
  11. Click Next.
  12. In Component Type, choose In-process (*.dll).
  13. In Generation Options, click the browse button and select the directory where the project should be created. Choose $ISE_EIFFEL\examples\com\wizard\e2idl\generated.
  14. Make sure both Compile C code and Compile Eiffel code are checked.
  15. Make sure Clean destination folder prior to generation is selected.
  16. Click Generate.
  17. Wait until the wizard is done.

First look at the generated code

The generated Eiffel classes include:

  • ISTRING_MANIPULATOR_INTERFACE: This class represents the only interface exposed by the COM component.
  • STRING_MANIPULATOR_PROXY_IMP: This class implements the coclass, it inherits from the interface and implements its members.
  • ECOM_STRING_REGISTRATION: This class contains the code required to register the component.

You do not need to modify or implement any classes. The wizard produces a ready-to-use component.

Tip:
In most Eiffel systems functionality is spread out throughout the system. No single class exposes the full functionality of the system and can serve as a Facade to the outside world. Running the wizard on any such class would not be practical. Before starting the wizard write an Eiffel class that acts as a Facade and forwards client calls to the appropriate subsystems. Enter the Facade class name into Name of Eiffel facade class field. The wizard generates an IDL file from this class.

See Also:
Creating a New COM Component
Accessing a COM Component.

cached: 03/19/2024 12:36:30.000 AM