comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/internal/Compatibility.d @ 120:536e43f63c81

Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661 ===D2=== * added [Try]Immutable/Const/Shared templates to work with differenses in D1/D2 instead of version statements used these templates to work with strict type storage rules of dmd-2.053 * com.ibm.icu now also compilable with D2, but not tested yet * small fixes Snippet288 - shared data is in TLS ===Phobos=== * fixed critical bugs in Phobos implemention completely incorrect segfault prone fromStringz (Linux's port ruthless killer) terrible, incorrect StringBuffer realization (StyledText killer) * fixed small bugs as well Snippet72 - misprint in the snippet * implemented missed functionality for Phobos ByteArrayOutputStream implemented (image loading available) formatting correctly works for all DWT's cases As a result, folowing snippets now works with Phobos (Snippet### - what is fixed): Snippet24, 42, 111, 115, 130, 235, 276 - bad string formatting Snippet48, 282 - crash on image loading Snippet163, 189, 211, 213, 217, 218, 222 - crash on copy/cut in StyledText Snippet244 - hang-up ===Tango=== * few changes for the latest Tango trunc-r5661 * few small performance improvments ===General=== * implMissing-s for only one version changed to implMissingInTango/InPhobos * incorrect calls to Format in toString-s fixed * fixed loading \uXXXX characters in ResourceBundle * added good UTF-8 support for StyledText, TextLayout (Win32) and friends UTF functions revised and tested. It is now in java.nonstandard.*Utf modules StyledText and TextLayout (Win32) modules revised for UTF-8 support * removed small diferences in most identical files in *.swt.* folders *.swt.internal.image, *.swt.events and *.swt.custom are identical in Win32/Linux32 now 179 of 576 (~31%) files in *.swt.* folders are fully identical * Win32: snippets now have right subsystem, pretty icons and native system style controls * small fixes in snippets Snippet44 - it's not Snippet44 Snippet212 - functions work with different images and offsets arrays Win32: Snippet282 - crash on close if the button has an image Snippet293 - setGrayed is commented and others Win32: As a result, folowing snippets now works Snippet68 - color doesn't change Snippet163, 189, 211, 213, 217, 218, 222 - UTF-8 issues (see above) Snippet193 - no tabel headers
author Denis Shelomovskij <verylonglogin.reg@gmail.com>
date Sat, 09 Jul 2011 15:50:20 +0300
parents 70388b0e6dad
children
comparison
equal deleted inserted replaced
119:d00e8db0a568 120:536e43f63c81
115 * 115 *
116 * @param parent the file's parent directory 116 * @param parent the file's parent directory
117 * @param child the file's name 117 * @param child the file's name
118 * @return true if the file exists 118 * @return true if the file exists
119 */ 119 */
120 public static bool fileExists(CString parent, CString child) { 120 public static bool fileExists(String parent, String child) {
121 return (new File (parent, child)).exists(); 121 scope f = new File(parent, child);
122 return f.exists();
122 } 123 }
123 124
124 /** 125 /**
125 * Answers the most positive (i.e. closest to positive infinity) 126 * Answers the most positive (i.e. closest to positive infinity)
126 * integer value which is less than the number obtained by dividing 127 * integer value which is less than the number obtained by dividing
190 * 191 *
191 * @param filename the name of the file to open 192 * @param filename the name of the file to open
192 * @return a stream on the file if it could be opened. 193 * @return a stream on the file if it could be opened.
193 * @exception IOException 194 * @exception IOException
194 */ 195 */
195 public static InputStream newFileInputStream(CString filename) { 196 public static InputStream newFileInputStream(String filename) {
196 return new FileInputStream(filename._idup()); 197 return new FileInputStream(filename);
197 } 198 }
198 199
199 /** 200 /**
200 * Open a file if such things are supported. 201 * Open a file if such things are supported.
201 * 202 *
202 * @param filename the name of the file to open 203 * @param filename the name of the file to open
203 * @return a stream on the file if it could be opened. 204 * @return a stream on the file if it could be opened.
204 * @exception IOException 205 * @exception IOException
205 */ 206 */
206 public static OutputStream newFileOutputStream(CString filename) { 207 public static OutputStream newFileOutputStream(String filename) {
207 return new FileOutputStream(filename._idup()); 208 return new FileOutputStream(filename);
208 } 209 }
209 210
210 /** 211 /**
211 * Create an InflaterInputStream if such things are supported. 212 * Create an InflaterInputStream if such things are supported.
212 * 213 *
270 * @param prog the name of the program to execute 271 * @param prog the name of the program to execute
271 * 272 *
272 * @exception ProcessException 273 * @exception ProcessException
273 * if the program cannot be executed 274 * if the program cannot be executed
274 */ 275 */
275 public static void exec(CString prog) { 276 public static void exec(String prog) {
276 version(Tango){ 277 version(Tango){
277 auto proc = new Process( prog ); 278 auto proc = new Process( prog );
278 proc.execute; 279 proc.execute;
279 } else { // Phobos 280 } else { // Phobos
280 implMissing( __FILE__, __LINE__ ); 281 implMissingInPhobos();
281 } 282 }
282 } 283 }
283 284
284 /** 285 /**
285 * Execute progArray[0] in a separate platform process if the 286 * Execute progArray[0] in a separate platform process if the
291 * @param progArray array containing the program to execute and its arguments 292 * @param progArray array containing the program to execute and its arguments
292 * 293 *
293 * @exception ProcessException 294 * @exception ProcessException
294 * if the program cannot be executed 295 * if the program cannot be executed
295 */ 296 */
296 public static void exec(CString[] progArray) { 297 public static void exec(String[] progArray) {
297 version(Tango){ 298 version(Tango){
298 auto proc = new Process( progArray ); 299 auto proc = new Process( progArray );
299 proc.execute; 300 proc.execute;
300 } else { // Phobos 301 } else { // Phobos
301 implMissing( __FILE__, __LINE__ ); 302 implMissingInPhobos();
302 } 303 }
303 } 304 }
304 305
305 const ImportData[] SWTMessagesBundleData = [ 306 const ImportData[] SWTMessagesBundleData = [
306 getImportData!( "org.eclipse.swt.internal.SWTMessages.properties" ), 307 getImportData!( "org.eclipse.swt.internal.SWTMessages.properties" ),
339 * @param key the key to look up 340 * @param key the key to look up
340 * @return the message for the given key 341 * @return the message for the given key
341 * 342 *
342 * @see SWT#getMessage(String) 343 * @see SWT#getMessage(String)
343 */ 344 */
344 public static String getMessage(CString key) { 345 public static String getMessage(String key) {
345 String answer = key._idup(); 346 String answer = key;
346 347
347 if (key is null) { 348 if (key is null) {
348 SWT.error (SWT.ERROR_NULL_ARGUMENT); 349 SWT.error (SWT.ERROR_NULL_ARGUMENT);
349 } 350 }
350 if (msgs is null) { 351 if (msgs is null) {
351 try { 352 try {
352 msgs = ResourceBundle.getBundle(SWTMessagesBundleData); //$NON-NLS-1$ 353 msgs = ResourceBundle.getBundle(SWTMessagesBundleData); //$NON-NLS-1$
353 } catch (MissingResourceException ex) { 354 } catch (MissingResourceException ex) {
354 answer = cast(String)(key ~ " (no resource bundle)"); //$NON-NLS-1$ 355 answer = key ~ " (no resource bundle)"; //$NON-NLS-1$
355 } 356 }
356 } 357 }
357 if (msgs !is null) { 358 if (msgs !is null) {
358 try { 359 try {
359 answer = msgs.getString(key); 360 answer = msgs.getString(key);
360 } catch (MissingResourceException ex2) {} 361 } catch (MissingResourceException ex2) {}
361 } 362 }
362 return answer; 363 return answer;
363 } 364 }
364 365
365 public static String getMessage(CString key, Object[] args) { 366 public static String getMessage(String key, Object[] args) {
366 String answer = key._idup(); 367 String answer = key;
367 368
368 if (key is null || args is null) { 369 if (key is null || args is null) {
369 SWT.error (SWT.ERROR_NULL_ARGUMENT); 370 SWT.error (SWT.ERROR_NULL_ARGUMENT);
370 } 371 }
371 if (msgs is null) { 372 if (msgs is null) {
372 try { 373 try {
373 msgs = ResourceBundle.getBundle(SWTMessagesBundleData); //$NON-NLS-1$ 374 msgs = ResourceBundle.getBundle(SWTMessagesBundleData); //$NON-NLS-1$
374 } catch (MissingResourceException ex) { 375 } catch (MissingResourceException ex) {
375 answer = cast(String)(key ~ " (no resource bundle)"); //$NON-NLS-1$ 376 answer = key ~ " (no resource bundle)"; //$NON-NLS-1$
376 } 377 }
377 } 378 }
378 if (msgs !is null) { 379 if (msgs !is null) {
379 try { 380 try {
380 String frmt = msgs.getString(key); 381 String frmt = msgs.getString(key);
411 * 412 *
412 * @param s1 string 413 * @param s1 string
413 * @param s2 string 414 * @param s2 string
414 * @return true if the two instances of class String are equal 415 * @return true if the two instances of class String are equal
415 */ 416 */
416 public static bool equalsIgnoreCase(CString s1, CString s2) { 417 public static bool equalsIgnoreCase(in char[] s1, in char[] s2) {
417 version(Tango){ 418 return .equalsIgnoreCase(s1, s2);
418 String s1b = new char[ s1.length ]; 419 }
419 String s2b = new char[ s1.length ]; 420
420 scope(exit){ 421 }
421 delete s1b;
422 delete s2b;
423 }
424 String s1c = Unicode.toFold( s1, s1b );
425 String s2c = Unicode.toFold( s2, s2b );
426 return s1c == s2c;
427 } else { // Phobos
428 return std.string.icmp( s1, s2 ) is 0;
429 }
430 }
431
432 }