WinAPI for druntime and OpenGL for deimos.

Jonathan M Davis jmdavisProg at gmx.com
Sat Nov 24 13:31:51 PST 2012


On Saturday, November 24, 2012 22:18:23 Andrej Mitrovic wrote:
> On 11/24/12, Walter Bright <newshound2 at digitalmars.com> wrote:
> > I'd forget about the unicode macro, and call the A or W versions
> > explicitly.
> 
> People already use WindowsAPI
> (http://dsource.org/projects/bindings/wiki/WindowsApi) and Derelict
> for many projects, and introducing a new API that isn't compatible
> with this is going to create compatibility issues. Not to mention
> newbies which will be utterly confused as to what to use now, the new
> std.c.windows.windows (which will be what, a single module spanning
> 100000 lines?) or the WindowsAPI bindings.
> 
> The WinAPI project has been used and maintained for years (compared to
> the poorly maintainted std.c.windows.windows where people arbitrarily
> add stuff to it when they feel the need to).
> 
> Here we have a guy (Gor) who doesn't even know what declspec is, or
> what a def file is, or what an import libarary is, who thinks he can
> use regex to create bindings, and who refuses to use STABLE bindings
> that were maintained for years. And we're going to allow him to create
> new backward-incompatible bindings that will supposedly work out of
> the box (they most certainly won't)?
> 
> I used to be *for* putting WinAPI bindings into druntime/phobos. But
> seeing how some pull requests take months to be merged, and Walter's
> ultra stance on not adding any aliases that help with code readability
> (A vs W functions), and the obsessive requirement for Phobos to be
> composed out of massive single modules, I'm beginning to think that
> keeping the API out of Phobos might actually be a good idea.
> 
> Here's a crazy thought: if WinAPI is needed by Phobos functions why
> not just distribute WinAPI with the zipped distribution? You could put
> it in a special subfolder, e.g.:
> 
> dmd2/src/dmd
> dmd2/src/druntime
> dmd2/src/phobos
> dmd2/src/bindings <-- put it in here
> 
> And then in sc.ini or dmd.conf add an import to the bindings folder,
> and distribute a precompiled static library of the bindings alongside
> phobos.lib. The -version switches might have to be sorted out, but
> that has to be a simpler problem than rewriting bindings from scratch.

And why not just put the WindowsAPI bindings in druntime with the proper 
organization? What I would expect would be to have a .d or .di file for every 
Windows header file, and my initiali reaction would be that anything else would 
be foolish. IIRC, the Windows API bindings project does something similar to 
that. I believe that that's more or less how the POSIX bindings in druntime 
are laid out.Certainly, a single file with everything in it like you seem to be 
afraid of would be absurd.

And remember that druntime and Phobos _need_ to have at least some portion of 
the bindings to do their job, so having them in another project is 
counterproductive. And unless the WindowsAPI project doesn't depend on 
druntime at all (which I find doubtful), you end up with a circular dependency 
if druntime depends on it, so you'd be forced to duplicate bindings like we're 
doing now.

- jonathan M Davis


More information about the Digitalmars-d mailing list