comparison com.ibm.icu/src/com/ibm/icu/mangoicu/UResourceBundle.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 ebefa5c2eab4
children
comparison
equal deleted inserted replaced
119:d00e8db0a568 120:536e43f63c81
86 86
87 private import com.ibm.icu.mangoicu.ICU, 87 private import com.ibm.icu.mangoicu.ICU,
88 com.ibm.icu.mangoicu.UString; 88 com.ibm.icu.mangoicu.UString;
89 89
90 public import com.ibm.icu.mangoicu.ULocale; 90 public import com.ibm.icu.mangoicu.ULocale;
91 private import java.lang.util;
91 92
92 /******************************************************************************* 93 /*******************************************************************************
93 94
94 API representing a collection of resource information pertaining to 95 API representing a collection of resource information pertaining to
95 a given locale. A resource bundle provides a way of accessing locale- 96 a given locale. A resource bundle provides a way of accessing locale-
166 is for the target OS) for this class to work correctly. 167 is for the target OS) for this class to work correctly.
167 A null value will open the default ICU data-files 168 A null value will open the default ICU data-files
168 169
169 ***********************************************************************/ 170 ***********************************************************************/
170 171
171 this (inout ULocale locale, char[] path = null) 172 this (ref ULocale locale, char[] path = null)
172 { 173 {
173 UErrorCode e; 174 UErrorCode e;
174 175
175 handle = ures_open (toString(path), toString(locale.name), e); 176 handle = ures_open (toString(path), toString(locale.name), e);
176 testError (e, "failed to open resource bundle"); 177 testError (e, "failed to open resource bundle");
385 Return the version number associated with this ResourceBundle 386 Return the version number associated with this ResourceBundle
386 as a UVersionInfo array 387 as a UVersionInfo array
387 388
388 ***********************************************************************/ 389 ***********************************************************************/
389 390
390 void getVersion (inout Version info) 391 void getVersion (ref Version info)
391 { 392 {
392 ures_getVersion (handle, info); 393 ures_getVersion (handle, info);
393 } 394 }
394 395
395 /*********************************************************************** 396 /***********************************************************************
396 397
397 Return the ULocale associated with this ResourceBundle 398 Return the ULocale associated with this ResourceBundle
398 399
399 ***********************************************************************/ 400 ***********************************************************************/
400 401
401 void getLocale (inout ULocale locale) 402 void getLocale (ref ULocale locale)
402 { 403 {
403 UErrorCode e; 404 UErrorCode e;
404 405
405 locale.name = toArray (ures_getLocale (handle, e)); 406 locale.name = cast(String) toArray (ures_getLocale (handle, e));
406 testError (e, "failed to get resource locale"); 407 testError (e, "failed to get resource locale");
407 } 408 }
408 409
409 /*********************************************************************** 410 /***********************************************************************
410 411
436 Worker function for constructing internal ResourceBundle 437 Worker function for constructing internal ResourceBundle
437 instances. Returns null when the provided handle is null. 438 instances. Returns null when the provided handle is null.
438 439
439 ***********************************************************************/ 440 ***********************************************************************/
440 441
441 private static final UResourceBundle get (Handle handle, inout UErrorCode e) 442 private static final UResourceBundle get (Handle handle, ref UErrorCode e)
442 { 443 {
443 testError (e, "failed to create resource bundle"); 444 testError (e, "failed to create resource bundle");
444 if (handle) 445 if (handle)
445 return new UResourceBundle (handle); 446 return new UResourceBundle (handle);
446 return null; 447 return null;
453 complicated by the issues regarding D and DLLs on the 454 complicated by the issues regarding D and DLLs on the
454 Windows platform 455 Windows platform
455 456
456 ***********************************************************************/ 457 ***********************************************************************/
457 458
458 private static void* library; 459 mixin(genICUNative!("uc"
459 460 ,"Handle function (char*, char*, ref UErrorCode)", "ures_open"
460 /*********************************************************************** 461 ,"void function (Handle)", "ures_close"
461 462 ,"char* function (Handle, ref UErrorCode)", "ures_getLocale"
462 ***********************************************************************/ 463 ,"void function (Handle, ref Version)", "ures_getVersion"
463 464 ,"uint function (Handle)", "ures_getSize"
464 private static extern (C) 465 ,"int function (Handle, ref UErrorCode)", "ures_getInt"
465 { 466 ,"wchar* function (Handle, ref uint, ref UErrorCode)", "ures_getString"
466 Handle function (char*, char*, inout UErrorCode) ures_open; 467 ,"wchar* function (Handle, uint, ref uint, ref UErrorCode)", "ures_getStringByIndex"
467 void function (Handle) ures_close; 468 ,"wchar* function (Handle, char*, ref uint, ref UErrorCode)", "ures_getStringByKey"
468 char* function (Handle, inout UErrorCode) ures_getLocale; 469 ,"void* function (Handle, ref uint, ref UErrorCode)", "ures_getBinary"
469 void function (Handle, inout Version) ures_getVersion; 470 ,"int* function (Handle, ref uint, ref UErrorCode)", "ures_getIntVector"
470 uint function (Handle) ures_getSize; 471 ,"byte function (Handle)", "ures_hasNext"
471 int function (Handle, inout UErrorCode) ures_getInt; 472 ,"void function (Handle)", "ures_resetIterator"
472 wchar* function (Handle, inout uint, inout UErrorCode) ures_getString; 473 ,"wchar* function (Handle, ref uint, ref char*, ref UErrorCode)", "ures_getNextString"
473 wchar* function (Handle, uint, inout uint, inout UErrorCode) ures_getStringByIndex; 474 ,"char* function (Handle)", "ures_getKey"
474 wchar* function (Handle, char*, inout uint, inout UErrorCode) ures_getStringByKey; 475 ,"int function (Handle)", "ures_getType"
475 void* function (Handle, inout uint, inout UErrorCode) ures_getBinary; 476 ,"Handle function (Handle, Handle, ref UErrorCode)", "ures_getNextResource"
476 int* function (Handle, inout uint, inout UErrorCode) ures_getIntVector; 477 ,"Handle function (Handle, uint, Handle, ref UErrorCode)", "ures_getByIndex"
477 byte function (Handle) ures_hasNext; 478 ,"Handle function (Handle, char*, Handle, ref UErrorCode)", "ures_getByKey"
478 void function (Handle) ures_resetIterator; 479 ));
479 wchar* function (Handle, inout uint, inout char*, inout UErrorCode) ures_getNextString; 480
480 char* function (Handle) ures_getKey; 481 /***********************************************************************
481 int function (Handle) ures_getType; 482
482 Handle function (Handle, Handle, inout UErrorCode) ures_getNextResource; 483 ***********************************************************************/
483 Handle function (Handle, uint, Handle, inout UErrorCode) ures_getByIndex; 484
484 Handle function (Handle, char*, Handle, inout UErrorCode) ures_getByKey; 485 /*static void test()
485 }
486
487 /***********************************************************************
488
489 ***********************************************************************/
490
491 static FunctionLoader.Bind[] targets =
492 [
493 {cast(void**) &ures_open, "ures_open"},
494 {cast(void**) &ures_close, "ures_close"},
495 {cast(void**) &ures_getLocale, "ures_getLocale"},
496 {cast(void**) &ures_getVersion, "ures_getVersion"},
497 {cast(void**) &ures_getSize, "ures_getSize"},
498 {cast(void**) &ures_getInt, "ures_getInt"},
499 {cast(void**) &ures_getString, "ures_getString"},
500 {cast(void**) &ures_getStringByIndex, "ures_getStringByIndex"},
501 {cast(void**) &ures_getStringByKey, "ures_getStringByKey"},
502 {cast(void**) &ures_getBinary, "ures_getBinary"},
503 {cast(void**) &ures_hasNext, "ures_hasNext"},
504 {cast(void**) &ures_resetIterator, "ures_resetIterator"},
505 {cast(void**) &ures_getNextString, "ures_getNextString"},
506 {cast(void**) &ures_getKey, "ures_getKey"},
507 {cast(void**) &ures_getType, "ures_getType"},
508 {cast(void**) &ures_getNextResource, "ures_getNextResource"},
509 {cast(void**) &ures_getByIndex, "ures_getByIndex"},
510 {cast(void**) &ures_getByKey, "ures_getByKey"},
511 ];
512
513 /***********************************************************************
514
515 ***********************************************************************/
516
517 static this ()
518 {
519 library = FunctionLoader.bind (icuuc, targets);
520 //test ();
521 }
522
523 /***********************************************************************
524
525 ***********************************************************************/
526
527 static ~this ()
528 {
529 FunctionLoader.unbind (library);
530 }
531
532 /***********************************************************************
533
534 ***********************************************************************/
535
536 static void test()
537 { 486 {
538 UResourceBundle b = new UResourceBundle (ULocale.Default); 487 UResourceBundle b = new UResourceBundle (ULocale.Default);
539 UStringView t = b.getNextString(); 488 UStringView t = b.getNextString();
540 UResourceBundle b1 = b.getNextResource (); 489 UResourceBundle b1 = b.getNextResource ();
541 } 490 }*/
542 } 491 }
543 492
544 493