【发布时间】:2020-12-03 07:47:16
【问题描述】:
我正在将 d2d1_1.h 头文件移植到 Delphi,但我陷入了接口声明。 在接口声明中,有一些方法用实际调用的实现代码重新声明。 这是一个例子(我只展示了代码的相关部分):
// 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
我知道该功能的第二个版本只是为了方便编程。 实际上,实现给定接口的对象没有第二个版本的代码。 二进制级别的接口中没有槽(一个接口实现为 指向方法的指针数组)。移植到 Delphi 时,我可以忽略第二个版本。 有人可以证实我的分析吗?
【问题讨论】:
-
当然,只需使用标记为 PURE 的方法。其他的则是一些有用的包装器。
-
@SimonMourier 谢谢!您可以将您的评论改写为答案。我会接受的。
标签: c++ delphi interface direct2d