Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
musm committed Jul 23, 2020
1 parent ad3e29f commit 923e8f1
Show file tree
Hide file tree
Showing 9 changed files with 632 additions and 2 deletions.
31 changes: 31 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Documentation: https://github.com/JuliaCI/Appveyor.jl
environment:
matrix:
- julia_version: 1.0
- julia_version: 1.5
- julia_version: nightly
platform:
- x64
- x86
cache:
- '%USERPROFILE%\.julia\artifacts'
matrix:
allow_failures:
- julia_version: nightly
branches:
only:
- master
- /release-.*/
notifications:
- provider: Email
on_build_success: false
on_build_failure: false
on_build_status_changed: false
install:
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
build_script:
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
test_script:
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Documentation
on:
- push
- pull_request
jobs:
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Documentation: http://docs.travis-ci.com/user/languages/julia
language: julia
notifications:
email: false
julia:
- 1.0
- 1.5
- nightly
os:
- linux
- osx
- windows
arch:
- x64
cache:
directories:
- ~/.julia/artifacts
jobs:
fast_finish: true
allow_failures:
- julia: nightly
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,53 @@
# WinTypes

This package defines aliases to [Windows Data types](https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types).


## Why?

This makes it easier to translate Windows function from MSDN documentation and
increases readability.

Here's an example comparing calling Windows API functions with and without `WinTypes`:

With `WinTypes` a Windows API call would look something like:
```julia
using WinTypes: HANDLE, DWORD, BOOL

function get_console_mode()
STD_OUTPUT_HANDLE = -11
hOutput = ccall(:GetStdHandle, stdcall, HANDLE, (DWORD,), STD_OUTPUT_HANDLE % DWORD)
dwMode = Ref{DWORD}()
ccall(:GetConsoleMode, stdcall, BOOL, (HANDLE, Ref{DWORD}), hOutput, dwMode)
return dwMode[]
end
```
Now, compare this to the call without this package:
```julia

function get_console_mode()
STD_OUTPUT_HANDLE = -11
hOutput = ccall(:GetStdHandle, stdcall, Ptr{Cvoid}, (UInt32,), STD_OUTPUT_HANDLE % UInt32)
dwMode = Ref{UInt32}()
ccall(:GetConsoleMode, stdcall, Int32, (Ref{Cvoid}, Ref{UInt32}), hOutput, dwMode)
return dwMode[]
end
```

Finally, here are the corresponding Windows API function syntax definitions in `C`:

```
HANDLE WINAPI GetStdHandle(
_In_ DWORD nStdHandle
);
```

```
BOOL WINAPI GetConsoleMode(
_In_ HANDLE hConsoleHandle,
_Out_ LPDWORD lpMode
);
```

As you can see, the call to these APIs using `WinTypes` is easier to translate and
directly translatable without manually looking up the myriad Windows data types.
1 change: 0 additions & 1 deletion _git2_a16356

This file was deleted.

3 changes: 3 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
WinTypes = "7ce832dc-6953-4c0f-9163-51fbd0dcbc24"
21 changes: 21 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using WinTypes
using Documenter

makedocs(;
modules=[WinTypes],
authors="Mustafa Mohamad <[email protected]> and contributors",
repo="https://github.com/musm/WinTypes.jl/blob/{commit}{path}#L{line}",
sitename="WinTypes.jl",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://musm.github.io/WinTypes.jl",
assets=String[],
),
pages=[
"Home" => "index.md",
],
)

deploydocs(;
repo="github.com/musm/WinTypes.jl.git",
)
152 changes: 152 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
```@meta
CurrentModule = WinTypes
```

# WinTypes

## Usage

First install the package:
```julia
]add WinTypes
```

Here's an example comparing calling Windows API functions with and without `WinTypes`:

With `WinTypes` a Windows API call would look something like:
```julia
using WinTypes: HANDLE, DWORD, BOOL

function get_console_mode()
STD_OUTPUT_HANDLE = -11
hOutput = ccall(:GetStdHandle, stdcall, HANDLE, (DWORD,), STD_OUTPUT_HANDLE % DWORD)
dwMode = Ref{DWORD}()
ccall(:GetConsoleMode, stdcall, BOOL, (HANDLE, Ref{DWORD}), hOutput, dwMode)
return dwMode[]
end
```
Now, compare this to the call without this package:
```julia

function get_console_mode()
STD_OUTPUT_HANDLE = -11
hOutput = ccall(:GetStdHandle, stdcall, Ptr{Cvoid}, (UInt32,), STD_OUTPUT_HANDLE % UInt32)
dwMode = Ref{UInt32}()
ccall(:GetConsoleMode, stdcall, Int32, (Ref{Cvoid}, Ref{UInt32}), hOutput, dwMode)
return dwMode[]
end
```

Finally, here are the corresponding Windows API function syntax definitions in `C`:

```
HANDLE WINAPI GetStdHandle(
_In_ DWORD nStdHandle
);
```

```
BOOL WINAPI GetConsoleMode(
_In_ HANDLE hConsoleHandle,
_Out_ LPDWORD lpMode
);
```

As you can see, the call to these APIs using `WinTypes` is easier to translate and
directly translatable without manually looking up the myriad Windows data types.


## Alias List

The following aliases are defined:
```
FALSE = Cint(0)
TRUE = Cint(1)
BOOL = Cint
BOOLEAN = BYTE
BYTE = Cuchar
CCHAR = Cchar
CHAR = Cchar
COLORREF = DWORD
DWORD = Culong
DWORDLONG = UInt64
DWORD32 = UInt32
DWORD64 = UInt64
FLOAT = Cfloat
HACCEL = HANDLE
HANDLE = Ptr{Cvoid}
HBITMAP = HANDLE
HBRUSH = HANDLE
HCOLORSPACE = HANDLE
HCONV = HANDLE
HCONVLIST = HANDLE
HCURSOR = HICON
HDC = HANDLE
HDDEDATA = HANDLE
HDESK = HANDLE
HDROP = HANDLE
HDWP = HANDLE
HENHMETAFILE = HANDLE
HFILE = Cint
HFONT = HANDLE
HGDIOBJ = HANDLE
HGLOBAL = HANDLE
HHOOK = HANDLE
HICON = HANDLE
HINSTANCE = HANDLE
HKEY = HANDLE
HKL = HANDLE
HLOCAL = HANDLE
HMENU = HANDLE
HMETAFILE = HANDLE
HMODULE = HANDLE
HMONITOR = HANDLE
HPALETTE = HANDLE
HPEN = HANDLE
HRESULT = Clong
HRGN = HANDLE
HRSRC = HANDLE
HSZ = HANDLE
HWINSTA = HANDLE
HWND = HANDLE
INT = Cint
PHANDLE = Ptr{HANDLE}
PVOID = Ptr{Cvoid}
LPVOID = Ptr{Cvoid}
SHORT = Cshort
UCHAR = Cuchar
USHORT = Cushort
VOID = Cvoid
WCHAR = Cwchar_t
WORD = Cushort
PWCHAR = Ptr{WCHAR}
PWORD = Ptr{WORD}
LPWORD = Ptr{WORD}
PDWORD = Ptr{DWORD}
LPDWORD = Ptr{DWORD}
PSTR = Ptr{CHAR} # char*
LPSTR = Ptr{CHAR} # char*
PCSTR = Ptr{CHAR} # char*
LPCSTR = Ptr{CHAR} # char*
PWSTR = Ptr{WCHAR} # wchar_t*
LPWSTR = Ptr{WCHAR} # wchar_t*
PCWSTR = Ptr{WCHAR} # wchar_t*
LPCWSTR = Ptr{WCHAR} # const wchar_t*
```


# Detailed References

Below we include detailed documentation for some of the aliases defined in this package.
We refer to
[https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types](https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types)
for those not included below.

```@autodocs
Modules = [WinTypes]
```
Loading

0 comments on commit 923e8f1

Please sign in to comment.