godmyoh / windows-win32-d

Win32 API definitions for D

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Win32 API definitions for D

Win32 API definitions generated by Windows.Win32.winmd. (from win32metadata project)

This project aims to replace core.sys.windows.

Usage

Clone this repository and build windows-win32.lib (or windows-win32-debug.lib) from windows-win32-d\windows-win32\source.

git clone https://github.com/godmyoh/windows-win32-d.git
cd windows-win32-d\windows-win32
dub build --build=release --config=release --force
dub build --build=debug --config=debug --force

Instead of dub build, dub-build.bat in windows-win32-d folder can be used.

You can import windows-win32-d\windows-win32\source and link windows-win32-d\windows-win32\windows-win32.lib instead of using core.sys.windows. Try following command to run an example program. (See dub.sdl in windows-win32-d\example)

cd ..\example
dub run

If you want to generate files under windows-win32-d\windows-win32\source, dub run in windows-win32-d\windows-win32-generator.

cd ..\windows-win32-generator
dub run

Also the following commands can be used.

dub run -- usePackageModule
dub run -- appendUnderscore

dub run -- usePackageModule is same as dub run. See Naming rules for packages and modules

Instead of dub run, dub-run-usePackageModule.bat or dub-run-appendUnderscore.bat in windows-win32-d folder can be used.

Naming rules for packages and modules

  • Common rules
    • Packages and modules are lowercase of namespaces.
      • Windows.Win32.System.Console -> windows.win32.system.console.
    • Append an underscore to the module name if the module conflicts with a keyword.
      • Windows.Win32.System.Diagnostics.Debug.WebApp -> windows.win32.system.diagnostics.debug_.webapp
    • Namespaces other than Windows.Win32 are not supported. However, only System.Guid type is supported as windows.win32.guid.GUID.
  • In usePackageModule mode (default)
    • No additional rules. However, debug builds have limitations. See Limitations.
  • In appendUnderscore mode
    • Append an underscore to the module name if the module conflicts with a package.
      • Windows.Win32.Media -> windows.win32.media_ (Windows.Win32.Media.* exists)

Policies

  • Not all CLI specifications are supported.
    • assert(0) means This pattern of data does not appear in Windows.Win32.winmd.
  • HANDLE and GDI objects are NOT strongly-typed structs. (see Principles in win32metadata)
  • If two declarations has the same name, comment out one declaration with /+ [CONFLICTED] ... +/.
  • If the declaration cannot be compiled for some reason, comment out with /+ [UNSUPPORTED] ... +/

Limitations

  • When a field in a struct has the same name as the type name, an underscore is added to the field name to avoid compile errors.
  • Bitfields are not translated.
  • Windows.Win32.Foundation.Metadata is excluded.
  • Using windows-win32-debug.lib generated in usePackageModule mode causes unexplained linker errors.

References

About

Win32 API definitions for D

License:MIT License


Languages

Language:D 100.0%Language:Batchfile 0.0%