1 /***********************************************************************\
2 *                               basetsd.d                               *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *             Translated from MinGW API for MS-Windows 3.12             *
7 *                           by Stewart Gordon                           *
8 *                                                                       *
9 *                       Placed into public domain                       *
10 \***********************************************************************/
11 module windows.basetsd;
12 nothrow:
13 /*	This template is used in these modules to declare constant pointer types,
14  *	in order to support both D 1.x and 2.x.
15  *	Since removed - now supporting only D2
16  */
17 /*template CPtr(T) {
18 	version (D_Version2) {
19 		// must use mixin so that it doesn't cause a syntax error under D1
20 		mixin("alias const(T)* CPtr;");
21 	} else {
22 		alias T* CPtr;
23 	}
24 }*/
25 
26 /*	[CyberShadow VP 2011.12.22] typedef is now deprecated in D2.
27  */
28 template TypeDef(T) {
29 	version (D_Version2) {
30 		alias T TypeDef;
31 	} else {
32 		// must use mixin so that it doesn't cause a deprecation error under D2
33 		mixin("typedef T TypeDef;");
34 	}
35 }
36 
37 // [SnakE 2009-02-23] Moved HANDLE definition here from winnt.d to avoid
38 // 'forwatd template reference' to CPtr from winnt.d caused by a circular
39 // import.
40 
41 alias TypeDef!(void*) HANDLE;
42 /+struct HANDLE {
43     const(void)* h;
44     alias h this;
45 }+/
46 
47 package template DECLARE_HANDLE(string name, base = HANDLE) {
48     mixin ("alias " ~ base.stringof ~ " " ~ name ~ ";");
49 }
50 alias HANDLE* PHANDLE, LPHANDLE;
51 
52 version (Win64) {
53 	alias long __int3264;
54 	const ulong ADDRESS_TAG_BIT = 0x40000000000;
55 
56 	alias long INT_PTR, LONG_PTR;
57 	alias long* PINT_PTR, PLONG_PTR;
58 	alias ulong UINT_PTR, ULONG_PTR, HANDLE_PTR;
59 	alias ulong* PUINT_PTR, PULONG_PTR;
60 	alias int HALF_PTR;
61 	alias int* PHALF_PTR;
62 	alias uint UHALF_PTR;
63 	alias uint* PUHALF_PTR;
64 
65 	uint HandleToULong(void* h) { return(cast(uint) cast(ULONG_PTR) h); }
66 	int HandleToLong(void* h)   { return(cast(int) cast(LONG_PTR) h); }
67 	void* ULongToHandle(uint h) { return(cast(void*) cast(UINT_PTR) h); }
68 	void* LongToHandle(int h)   { return(cast(void*) cast(INT_PTR) h); }
69 	uint PtrToUlong(void* p)    { return(cast(uint) cast(ULONG_PTR) p); }
70 	uint PtrToUint(void* p)     { return(cast(uint) cast(UINT_PTR) p); }
71 	ushort PtrToUshort(void* p) { return(cast(ushort) cast(uint) cast(ULONG_PTR) p); }
72 	int PtrToLong(void* p)      { return(cast(int) cast(LONG_PTR) p); }
73 	int PtrToInt(void* p)       { return(cast(int) cast(INT_PTR) p); }
74 	short PtrToShort(void* p)   { return(cast(short) cast(int) cast(LONG_PTR) p); }
75 	void* IntToPtr(int i)       { return(cast(void*) cast(INT_PTR) i); }
76 	void* UIntToPtr(uint ui)    { return(cast(void*) cast(UINT_PTR) ui); }
77 	void* LongToPtr(int l)      { return(cast(void*) cast(LONG_PTR) l); }
78 	void* ULongToPtr(uint ul)   { return(cast(void*) cast(ULONG_PTR) ul); }
79 
80 } else {
81 	alias int __int3264;
82 	const uint ADDRESS_TAG_BIT = 0x80000000;
83 
84 	alias int INT_PTR, LONG_PTR;
85 	alias int* PINT_PTR, PLONG_PTR;
86 	alias uint UINT_PTR, ULONG_PTR, HANDLE_PTR;
87 	alias uint* PUINT_PTR, PULONG_PTR;
88 	alias short HALF_PTR;
89 	alias short* PHALF_PTR;
90 	alias ushort UHALF_PTR;
91 	alias ushort* PUHALF_PTR;
92 
93 	uint HandleToUlong(HANDLE h)      { return cast(uint) h; }
94 	int HandleToLong(HANDLE h)        { return cast(int) h; }
95 	HANDLE LongToHandle(LONG_PTR h)   { return cast(HANDLE)h; }
96 	uint PtrToUlong(const(void)* p)    { return cast(uint) p; }
97 	uint PtrToUint(const(void)* p)     { return cast(uint) p; }
98 	int PtrToInt(const(void)* p)       { return cast(int) p; }
99 	ushort PtrToUshort(const(void)* p) { return cast(ushort) p; }
100 	short PtrToShort(const(void)* p)   { return cast(short) p; }
101 	void* IntToPtr(int i)             { return cast(void*) i; }
102 	void* UIntToPtr(uint ui)          { return cast(void*) ui; }
103 	alias IntToPtr LongToPtr;
104 	alias UIntToPtr ULongToPtr;
105 }
106 
107 alias UIntToPtr UintToPtr, UlongToPtr;
108 
109 enum : UINT_PTR {
110 	MAXUINT_PTR = UINT_PTR.max
111 }
112 
113 enum : INT_PTR {
114 	MAXINT_PTR = INT_PTR.max,
115 	MININT_PTR = INT_PTR.min
116 }
117 
118 enum : ULONG_PTR {
119 	MAXULONG_PTR = ULONG_PTR.max
120 }
121 
122 enum : LONG_PTR {
123 	MAXLONG_PTR = LONG_PTR.max,
124 	MINLONG_PTR = LONG_PTR.min
125 }
126 
127 enum : UHALF_PTR {
128 	MAXUHALF_PTR = UHALF_PTR.max
129 }
130 
131 enum : HALF_PTR {
132 	MAXHALF_PTR = HALF_PTR.max,
133 	MINHALF_PTR = HALF_PTR.min
134 }
135 
136 alias byte INT8;
137 alias byte* PINT8;
138 alias ubyte UINT8;
139 alias ubyte* PUINT8;
140 
141 alias short INT16;
142 alias short* PINT16;
143 alias ushort UINT16;
144 alias ushort* PUINT16;
145 
146 alias int LONG32, INT32;
147 alias int* PLONG32, PINT32;
148 alias uint ULONG32, DWORD32, UINT32;
149 alias uint* PULONG32, PDWORD32, PUINT32;
150 
151 alias ULONG_PTR SIZE_T, DWORD_PTR;
152 alias ULONG_PTR* PSIZE_T, PDWORD_PTR;
153 alias LONG_PTR SSIZE_T;
154 alias LONG_PTR* PSSIZE_T;
155 
156 alias long LONG64, INT64;
157 alias long* PLONG64, PINT64;
158 alias ulong ULONG64, DWORD64, UINT64;
159 alias ulong* PULONG64, PDWORD64, PUINT64;