Programming Windows D Examples are now Online!
Johannes Pfau
spam at example.com
Sat Jul 9 01:46:10 PDT 2011
Andrej Mitrovic wrote:
>Using std.c.windows.windows is going to be problematic because the
>WindowsAPI bindings have a void* handle typedef, and
>std.c.windows.windows has the same typedef.
>
>If your library has this function:
>foo(HDC hdc) { }
>
>I can't use it from my code if I use the WindowsAPI bindings:
>
>import win32.windef;
>import win32.winuser;
>
>{
> HDc hdc;
> foo(hdc); // compile error
>}
>
>See:
>
>test.d(21): Error: function test.Foo (HANDLE hdc) is not callable
>using argument types (HANDLE)
>test.d(21): Error: cannot implicitly convert expression (hdc) of type
>HANDLE to HANDLE
>
>Personally I wish we got totally rid of std.c.windows.windows and the
>ancient DLLs distributed with DMD.
Ok, would something like this work? (for cairo.c.win32)
-------------------------------
//Use Andrej Mitrovic's API from
//https://github.com/AndrejMitrovic/DWindowsProgramming/tree/master/win32
version(EXT_WIN32_BINDINGS)
{
import win32.windef;
import win32.wingdi;
}
else
{
import core.sys.windows.windows;
pragma(msg, "cairo.c.win32: LOGFONTW should move to druntime");
enum size_t LF_FACESIZE = 32;
struct LOGFONTW
{
LONG lfHeight;
LONG lfWidth;
LONG lfEscapement;
LONG lfOrientation;
LONG lfWeight;
BYTE lfItalic;
BYTE lfUnderline;
BYTE lfStrikeOut;
BYTE lfCharSet;
BYTE lfOutPrecision;
BYTE lfClipPrecision;
BYTE lfQuality;
BYTE lfPitchAndFamily;
WCHAR[LF_FACESIZE] lfFaceName;
}
}
-------------------------------
I guess win32.windef and win32.wingdi contain all needed types?
Regarding the LGPL clause in the bindings, that's a leftover from the
cairo c headers. Even if that counted as releasing the sources as LGPL I
could still relicense them as long as I'm the only contributor. I'll
just ask on the cairo mailing list, that seems to be the best solution.
--
Johannes Pfau
More information about the Digitalmars-d-announce
mailing list