1module Fiddle
2  # Adds Windows type aliases to the including class for use with
3  # Fiddle::Importer.
4  #
5  # The aliases added are:
6  # * ATOM
7  # * BOOL
8  # * BYTE
9  # * DWORD
10  # * DWORD32
11  # * DWORD64
12  # * HANDLE
13  # * HDC
14  # * HINSTANCE
15  # * HWND
16  # * LPCSTR
17  # * LPSTR
18  # * PBYTE
19  # * PDWORD
20  # * PHANDLE
21  # * PVOID
22  # * PWORD
23  # * UCHAR
24  # * UINT
25  # * ULONG
26  # * WORD
27  module Win32Types
28    def included(m) # :nodoc:
29      m.module_eval{
30        typealias "DWORD", "unsigned long"
31        typealias "PDWORD", "unsigned long *"
32        typealias "DWORD32", "unsigned long"
33        typealias "DWORD64", "unsigned long long"
34        typealias "WORD", "unsigned short"
35        typealias "PWORD", "unsigned short *"
36        typealias "BOOL", "int"
37        typealias "ATOM", "int"
38        typealias "BYTE", "unsigned char"
39        typealias "PBYTE", "unsigned char *"
40        typealias "UINT", "unsigned int"
41        typealias "ULONG", "unsigned long"
42        typealias "UCHAR", "unsigned char"
43        typealias "HANDLE", "uintptr_t"
44        typealias "PHANDLE", "void*"
45        typealias "PVOID", "void*"
46        typealias "LPCSTR", "char*"
47        typealias "LPSTR", "char*"
48        typealias "HINSTANCE", "unsigned int"
49        typealias "HDC", "unsigned int"
50        typealias "HWND", "unsigned int"
51      }
52    end
53    module_function :included
54  end
55
56  # Adds basic type aliases to the including class for use with Fiddle::Importer.
57  #
58  # The aliases added are +uint+ and +u_int+ (<tt>unsigned int</tt>) and
59  # +ulong+ and +u_long+ (<tt>unsigned long</tt>)
60  module BasicTypes
61    def included(m) # :nodoc:
62      m.module_eval{
63        typealias "uint", "unsigned int"
64        typealias "u_int", "unsigned int"
65        typealias "ulong", "unsigned long"
66        typealias "u_long", "unsigned long"
67      }
68    end
69    module_function :included
70  end
71end
72