Windows API Translation

Rainer Schuetze r.sagitario at gmx.de
Wed Feb 9 00:03:54 PST 2011


Matthias Pleh wrote:
> Am 08.02.2011 22:37, schrieb Stewart Gordon:
>> On 08/02/2011 12:25, Trass3r wrote:
>>>> I wonder if these bindings would be suitable for inclusion in the
>>>> core.sys.windows package?
>>>
>>> They definitely need to be merged.
>>
>> Merged? The whole point of the bindings project is that it will one day
>> be complete. As such, it needs to _replace_ the current std.c.windows.*
>> and core.sys.windows.*.
>>
>> Stewart.
> 
> VisualD has some code for automated winapi-conversion:
> 
> <quote>to build the necessary D translations from the Windows and Visual 
> Studio SDK</quote>
> 
> http://www.dsource.org/projects/visuald/wiki/Build_from_source

Yes, building Visual D uses a tool that machine translates about 40 
header and idl files from the Windows SDK (I tweaked it for versions 
6.0A and 7.1A) and the full Visual Studio SDK.

It filters out unused branches (mostly 64-bit), but tries to keep the 
rest similar to the original headers including comments. Preprocessor 
macros with arguments are translated to template functions. It uses 
"const" for most declaration including GUIDs, so you need to build a 
library and cannot simply import them in your project. Updating the 
import libraries needs coffimplib, implib32 does not work well enough.

How well does SWIG handle the Windows API headers?

Don wrote:
 > Andrej Mitrovic wrote:
 >> Btw, how up-to-date are the import libs in windows/lib that ships with
 >> DMD2? Can they be used with e.g. Win7?
 >
 > They are horribly outdated. But I have a vague recollection that Walter
 > has explicit permission from Microsoft to redistribute updated versions.

If Walter not only has permission to distribute import libraries, but 
also the API header files, I could tweak it to support more of the 1200 
header files (it often needs one or two special cases per file because 
of some preprocessor magic), so it could go into the dmd distribution. 
It is probably not perfectly compatible with core.sys.windows, though.

Assuming redistribution is a problem, I was planning to add some 
conversion wizard to Visual D to let the user create the files from the 
C headers and libraries.

Rainer


More information about the Digitalmars-d mailing list