comparison dwt/internal/c/callback.d @ 7:e831403a80a9

Add 'cast' to casts
author Frank Benoit <benoit@tionex.de>
date Wed, 27 Aug 2008 14:30:35 +0200
parents 8b48be5454ce
children 30a762abda2a
comparison
equal deleted inserted replaced
6:b903c16b6f48 7:e831403a80a9
19 import dwt.dwthelper.utils; 19 import dwt.dwthelper.utils;
20 import dwt.internal.Callback; 20 import dwt.internal.Callback;
21 21
22 /* Header */ 22 /* Header */
23 23
24 version (Win32) 24 version cast(Win32)
25 { 25 {
26 import tango.sys.win32.UserGdi; 26 import tango.sys.win32.UserGdi;
27 import tango.sys.win32.Types; 27 import tango.sys.win32.Types;
28 } 28 }
29 29
30 else version (Win32_WCE) 30 else version cast(Win32_WCE)
31 { 31 {
32 import tango.sys.win32.UserGdi; 32 import tango.sys.win32.UserGdi;
33 import tango.sys.win32.Types; 33 import tango.sys.win32.Types;
34 } 34 }
35 35
51 SWT_PTR errorResult; 51 SWT_PTR errorResult;
52 } 52 }
53 53
54 bool USE_ASSEMBLER = false; 54 bool USE_ASSEMBLER = false;
55 55
56 version (X86) 56 version cast(X86)
57 bool USE_ASSEMBLER = true; 57 bool USE_ASSEMBLER = true;
58 58
59 private 59 private
60 { 60 {
61 CALLBACK_DATA callbackData[MAX_CALLBACKS]; 61 CALLBACK_DATA callbackData[MAX_CALLBACKS];
66 66
67 SWT_PTR callback(int index, ...); 67 SWT_PTR callback(int index, ...);
68 68
69 static if (USE_ASSEMBLER) 69 static if (USE_ASSEMBLER)
70 { 70 {
71 version (Win32){} 71 version cast(Win32){}
72 else version (Win32_WCE){} 72 else version cast(Win32_WCE){}
73 else 73 else
74 import tango.stdc.posix.sys.mman; 74 import tango.stdc.posix.sys.mman;
75 75
76 ubyte* callbackCode = null; 76 ubyte* callbackCode = null;
77 int CALLBACK_THUNK_SIZE = 64; 77 int CALLBACK_THUNK_SIZE = 64;
145 int j = 0, k, pad = 0; 145 int j = 0, k, pad = 0;
146 ubyte* code; 146 ubyte* code;
147 147
148 if (callbackCode == null) 148 if (callbackCode == null)
149 { 149 {
150 version (Win32) 150 version cast(Win32)
151 { 151 {
152 callbackCode = VirtualAlloc(null, CALLBACK_THUNK_SIZE * MAX_CALLBACKS, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 152 callbackCode = VirtualAlloc(null, CALLBACK_THUNK_SIZE * MAX_CALLBACKS, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
153 if (callbackCode == null) 153 if (callbackCode == null)
154 return 0; 154 return 0;
155 } 155 }
156 156
157 else version (Win32_WCE) 157 else version cast(Win32_WCE)
158 { 158 {
159 callbackCode = VirtualAlloc(null, CALLBACK_THUNK_SIZE * MAX_CALLBACKS, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 159 callbackCode = VirtualAlloc(null, CALLBACK_THUNK_SIZE * MAX_CALLBACKS, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
160 if (callbackCode == null) 160 if (callbackCode == null)
161 return 0; 161 return 0;
162 } 162 }
235 code[j++] = cast(ubyte) ((argCount + 1) * SWT_PTR.sizeof); 235 code[j++] = cast(ubyte) ((argCount + 1) * SWT_PTR.sizeof);
236 236
237 //POP EBP - 1 byte 237 //POP EBP - 1 byte
238 code[j++] = 0x5d; 238 code[j++] = 0x5d;
239 239
240 version (Win32) 240 version cast(Win32)
241 { 241 {
242 // RETN argCount * SWT_PTR.sizeof - 3 bytes 242 // RETN argCount * SWT_PTR.sizeof - 3 bytes
243 code[j++] = 0xc2; 243 code[j++] = 0xc2;
244 code[j++] = cast(ubyte) (argCount * SWT_PTR.sizeof); 244 code[j++] = cast(ubyte) (argCount * SWT_PTR.sizeof);
245 code[j++] = 0x00; 245 code[j++] = 0x00;
246 } 246 }
247 247
248 else version (Win32_WCE) 248 else version cast(Win32_WCE)
249 { 249 {
250 // RETN argCount * SWT_PTR.sizeof - 3 bytes 250 // RETN argCount * SWT_PTR.sizeof - 3 bytes
251 code[j++] = 0xc2; 251 code[j++] = 0xc2;
252 code[j++] = cast(ubyte) (argCount * SWT_PTR.sizeof); 252 code[j++] = cast(ubyte) (argCount * SWT_PTR.sizeof);
253 code[j++] = 0x00; 253 code[j++] = 0x00;