I'm porting d2d1_1.h header file to Delphi and I'm stuck in an interface declaration. In the interface declaration, there are methods redeclared with actual implementation code which calls. Here is an example (I show only relevant part of the code):
// d2d1_1.h line 1522
interface DX_DECLARE_INTERFACE("e8f7fe7a-191c-466d-ad95-975678bda998") ID2D1DeviceContext : public ID2D1RenderTarget
{
// d2d1_1.h line 1715
STDMETHOD_(void, SetRenderingControls)(
_In_ CONST D2D1_RENDERING_CONTROLS *renderingControls
) PURE;
// Lot of declarations ommited for simplicity
// d2d1_1.h line 2149
COM_DECLSPEC_NOTHROW
void
SetRenderingControls(
CONST D2D1_RENDERING_CONTROLS &renderingControls
)
{
return SetRenderingControls(&renderingControls);
}
}; // interface ID2D1DeviceContext
I understand that the second version of the function is just to easy programming. Actually, the object implementating the given interface has no code for that second version. There is no slot in the interface at the binary level (An interface is implemented as an array of pointers to the methods). I can just ignore the second version when porting to Delphi. Can someone confirm my analysis?
Only the method marked with the PURE (defined as =0) attribute really exists in the final COM vtable.
The other methods are utility methods/wrappers that contain C/C++ code that can only be used in C/C++ (they will be compiled), so you must not declare them when using another language (delphi, .NET, etc.)
We are also investigating this in D2D1, because for example interface D2D1Svg.ID2D1SvgElement has about 20 of them declared.
You may follow these discussions/issues here: Translation of C headers, here: MfPack/D2D1. Until now, there is no final solution or exact reason found, why this would happen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With