|
Non-generic interfaces |
Top Previous Next |
|
What is translated > Types > Records, Classes, Interfaces > Interfaces > Non-generic interfaces Non-generic interfaces in Delphi provide a mechanism to separate implementation details from their usage. Historically, they are based on the Component Object Model (COM) and are COM-compatible by default—that is, they inherit from IUnknown and implement reference counting via AddRef and Release.
In Delphi, these methods are typically declared as _AddRef and _Release to distinguish them from regular members, although the underlying COM behavior remains consistent. Each interface is associated with a GUID, which enables runtime type resolution through QueryInterface, Supports, and the as<T> operator.
Unlike classes, Delphi interfaces support multiple inheritance, making them particularly well-suited for component-based architectures with high levels of abstraction.
Scope of translation
In Delphi2Cpp, non-generic interfaces are translated into COM-style C++ interfaces with deterministic GUIDs. They are managed using DelphiInterface<T> smart pointers, which automatically handle reference counting and ensure RAII-style memory safety.
The translation focuses exclusively on v-table-based interfaces (i.e., standard Delphi/COM interfaces). It does not support:
Instead, the objective is to provide a Delphi-compatible C++ representation, with:
Interface table generation
Delphi2Cpp offers two strategies for generating interface tables:
Note The choice between explicit and automatic interface table generation is controlled by a checkbox in the Delphi2Cpp options.
Required adjustments in C++
Because C++ lacks a built-in interface system comparable to Delphi, specific adjustments are required. Delphi2Cpp provides:
Topics covered in this section
This section explains how Delphi2Cpp reproduces the full semantics of non-generic interfaces:
|
|
This page belongs to the Delphi2Cpp Documentation |
Delphi2Cpp home Content |