]> granicus.if.org Git - icu/commitdiff
ICU-8157 update to glue code
authorSteven R. Loomis <srl@icu-project.org>
Sat, 18 Feb 2012 21:45:19 +0000 (21:45 +0000)
committerSteven R. Loomis <srl@icu-project.org>
Sat, 18 Feb 2012 21:45:19 +0000 (21:45 +0000)
X-SVN-Rev: 31433

tools/multi/c/Makefile-c.inc
tools/multi/proj/provider/datediff.cpp
tools/multi/proj/provider/glue/date_fe.cpp
tools/multi/proj/provider/readme.txt

index dde7755fb0645f45194466653875987e39a7364d..df29b1fe7211687417608a934db8c1eafc9ea12d 100644 (file)
@@ -1,8 +1,9 @@
-# Copyright (c) 2008-2010 IBM Corp. and Others. All Rights Reserved
+# Copyright (c) 2008-2012 IBM Corp. and Others. All Rights Reserved
 
 include $(MULTICU_ROOT)/common/Makefile-multi.inc
 
 C_GOOD:=$(shell [ -d $(C_INS) ] && (cd $(C_INS) ; ls -d */$(S_INS) 2>/dev/null | cut -d/ -f1))
+C_REL:=$(shell [ -d $(C_INS) ] && (cd $(C_INS) ; ls -d r*/$(S_INS) 2>/dev/null | cut -d/ -f1))
 
 C_CLEAN_TARGET=$(C_GOOD:%=$(C_INS)/%/bin/$(TARGET))
 
@@ -10,7 +11,7 @@ SOURCES=$(C_SOURCES) $(CXX_SOURCES)
 C_OBJECTS=$(C_SOURCES:%.c=%.o)
 CXX_OBJECTS=$(CXX_SOURCES:%.cpp=%.o)
 OBJECTS=$(C_OBJECTS) $(CXX_OBJECTS)
-DEBUGOPT=-g
+#DEBUGOPT=-g
 
 # list of ICUs to be built     
 ICU_TARBALLS=$(shell cd $(ICUS) ; ls icu4c-*-src.tgz)
index 78bbc9541cfd65a98ab3e2a63a9e0cb9b70d64ff..0a21997772d86d60b412a9862cbf473a6e1a08e9 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2009-2011, International Business Machines
+*   Copyright (C) 2009-2012, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -42,67 +42,70 @@ int main(int /* argc*/ , const char * /*argv*/ []) {
     UErrorCode status = U_ZERO_ERROR;
     int diffs = 0;
     int gbaddiffs =0;
+    UDateFormatStyle styles[] = { UDAT_FULL, UDAT_SHORT };
     setup(status);
     if(U_FAILURE(status)) return 1;
 
     int expected = PROVIDER_COUNT;
 
-    for(int l=0;l<LOCALE_COUNT;l++) {
+    for(int s=0;s<sizeof(styles)/sizeof(styles[0]);s++) {
+      for(int l=0;l<LOCALE_COUNT;l++) {
         printf("\n");
         UChar oldChars[200];
         int32_t oldLen = -1;
         for(int v=0;v<=expected;v++) {
-
-            // Construct the locale ID
-            char locID[200];
-            strcpy(locID, locale[l]);
-            if((v!=expected)) { // -1 = no version
-                strcat(locID, "@sp=icu");
-                strcat(locID, provider_version[v]);
-            }
-            
-            printf("%18s : ", locID);
-            
-            UErrorCode subStatus = U_ZERO_ERROR;
-            UChar outchars[200];
-
-            UDateFormat *dat = udat_open(UDAT_FULL, UDAT_FULL, locID, NULL, -1, NULL, 0, &subStatus);
-
-            if(U_FAILURE(subStatus)) {
-                printf("ERR: %s\n", u_errorName(subStatus));
-                continue;
-            }
-
-            int32_t len = udat_format(dat, stuff, outchars, 200, NULL, &subStatus); 
-
-            //printf("\n");
-            char utf8[200];
-            u_strToUTF8(utf8, 200, NULL, outchars, len, &subStatus);
-            if(oldLen!=len || memcmp(outchars,oldChars,len*sizeof(outchars[0]))) {
-              putchar ('!');
-              diffs++;
-            } else {
-              putchar ('=');
-            }
-            printf(" %s ", utf8); 
-
-            // for(int i=0;i<len;i++) {
-           //   if((i<oldLen)&&(outchars[i]!=oldChars[i])) {
-            //       diffs++;
-            //       printf("*", oldChars[i]);
-            //     } else {
-            //       printf(" ");
-            //     }
-            //   //                printf("U+%04X", (outchars[i]));
-            // }
-            putchar('\n');
-            udat_close(dat);
-
-            oldLen = len;
-            memcpy(oldChars, outchars, len*sizeof(oldChars[0]));
+          
+          // Construct the locale ID
+          char locID[200];
+          strcpy(locID, locale[l]);
+          if((v!=expected)) { // -1 = no version
+            strcat(locID, "@sp=icu");
+            strcat(locID, provider_version[v]);
+          }
+          
+          printf("%18s : ", locID);
+          
+          UErrorCode subStatus = U_ZERO_ERROR;
+          UChar outchars[200];
+          
+          UDateFormat *dat = udat_open(styles[s],styles[s], locID, NULL, -1, NULL, 0, &subStatus);
+          
+          if(U_FAILURE(subStatus)) {
+            printf("ERR: %s\n", u_errorName(subStatus));
+            continue;
+          }
+          
+          int32_t len = udat_format(dat, stuff, outchars, 200, NULL, &subStatus); 
+          
+          //printf("\n");
+          char utf8[200];
+          u_strToUTF8(utf8, 200, NULL, outchars, len, &subStatus);
+          if(oldLen!=len || memcmp(outchars,oldChars,len*sizeof(outchars[0]))) {
+            putchar ('!');
+            diffs++;
+          } else {
+            putchar ('=');
+          }
+          printf(" %s ", utf8); 
+          
+          // for(int i=0;i<len;i++) {
+          //   if((i<oldLen)&&(outchars[i]!=oldChars[i])) {
+          //       diffs++;
+          //       printf("*", oldChars[i]);
+          //     } else {
+          //       printf(" ");
+          //     }
+          //   //                printf("U+%04X", (outchars[i]));
+          // }
+          putchar('\n');
+          udat_close(dat);
+          
+          oldLen = len;
+          memcpy(oldChars, outchars, len*sizeof(oldChars[0]));
         }
+      }
     }
-
+      
     if(diffs==0) {
       printf("ERROR: 0 differences found between platforms.. are the platforms installed? Try 'icuinfo -L'\n");
       return 1;
index 495bf2ca838c6858126b994267e5c0f521b96a31..7042b22adc4463baa1dfaa5e336f2806e4fa0518 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2009-2011, International Business Machines
+*   Copyright (C) 2009-2012, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
 #endif
 
 #define GLUE_VER(x) class GLUE_SYM_V( DateFormat, x ) : public DateFormat {  \
-  public:  static DateFormat *create(const Locale &loc, const char *ver); \
+  public:  static DateFormat *create(UDateFormatStyle  timeStyle, \
+                                                    UDateFormatStyle  dateStyle, \
+                                                    const char        *locale, \
+                                                    const UChar       *tzID, \
+                                                    int32_t           tzIDLength, \
+                                                    const UChar       *pattern,  \
+                                                    int32_t           patternLength,  \
+                                                      UErrorCode        *status, const Locale &loc, const char *ver); \
   private: UDateFormat *_this; GLUE_SYM_V( DateFormat, x ) ( UDateFormat* tn ); \
     virtual ~ GLUE_SYM_V ( DateFormat, x) ();                             \
   public:                                                               \
@@ -75,24 +82,25 @@ GLUE_SYM ( DateFormat ) :: ~ GLUE_SYM(DateFormat) () {
 }
 
 DateFormat *
-GLUE_SYM ( DateFormat ) :: create(const Locale &loc, const char */*ver*/) {
-  // TODO: save 'ver' off.
-    UErrorCode status = U_ZERO_ERROR;
-    char locBuf[200];
-    char kwvBuf[200];
-    // int32_t len = loc.getKeywordValue("collation", kwvBuf, 200, status);
-    //strcpy(locBuf,loc.getBaseName());
-    // if(len>0) {
-    //     strcat(locBuf,"@collator=");
-    //     strcat(locBuf,kwvBuf);
-    // }
-    UDateFormat * uc =  OICU_udat_open( UDAT_FULL, UDAT_FULL, loc.getName(),
-                                        NULL,
-                                        -1,
-                                        NULL,
-                                        -1,
-                                        &status);
-    if(U_FAILURE(status)) return NULL; // TODO: ERR?
+GLUE_SYM ( DateFormat ) :: create(UDateFormatStyle  timeStyle,
+                                                    UDateFormatStyle  dateStyle,
+                                                    const char        *locale,
+                                                    const UChar       *tzID,
+                                                    int32_t           tzIDLength,
+                                                    const UChar       *pattern,
+                                                    int32_t           patternLength,
+                                                    UErrorCode        *status,
+                                                    const Locale &loc, const char */*ver*/) {
+  // TODO: save version
+  char locBuf[200];
+  char kwvBuf[200];
+  UDateFormat * uc =  OICU_udat_open( timeStyle, dateStyle, locale,
+                                      tzID,
+                                      tzIDLength,
+                                      pattern,
+                                      patternLength,
+                                      status);
+    if(U_FAILURE(*status)) return NULL; // TODO: ERR?
     DateFormat *c =  new GLUE_SYM( DateFormat ) ( uc );
 #if DATE_FE_DEBUG
     fprintf(stderr, "VCF " ICUGLUE_VER_STR " udat_open=%s ->> %p\n", loc.getName(), (void*)c);
@@ -186,7 +194,14 @@ static
 
 class VersionDateFormatFactory : public UObject  {
 public:
-  virtual DateFormat *createFormat(const Locale &loc);
+  virtual DateFormat *createFormat(UDateFormatStyle  timeStyle,
+                                   UDateFormatStyle  dateStyle,
+                                   const char        *locale,
+                                   const UChar       *tzID,
+                                   int32_t           tzIDLength,
+                                   const UChar       *pattern,
+                                   int32_t           patternLength,
+                                   UErrorCode        *status);
   virtual const UnicodeString *getSupportedIDs(int32_t &count, UErrorCode &status);
   virtual void* getDynamicClassID() const; 
   static void* getStaticClassID() ; 
@@ -194,17 +209,24 @@ public:
 
 UOBJECT_DEFINE_RTTI_IMPLEMENTATION( VersionDateFormatFactory )
 
-DateFormat *VersionDateFormatFactory::createFormat(const Locale &loc) {
+DateFormat *VersionDateFormatFactory::createFormat(UDateFormatStyle  timeStyle,
+                                                    UDateFormatStyle  dateStyle,
+                                                    const char        *locale,
+                                                    const UChar       *tzID,
+                                                    int32_t           tzIDLength,
+                                                    const UChar       *pattern,
+                                                    int32_t           patternLength,
+                                                       UErrorCode        *status) {
+    Locale loc(locale);
     // pull off provider #
     char provider[200];
-    UErrorCode status = U_ZERO_ERROR;
 #if DATE_FE_DEBUG
     fprintf(stderr,  "VCF:CC %s\n", loc.getName());
 #endif
-    int32_t len = loc.getKeywordValue("sp", provider, 200, status);
-    if(U_FAILURE(status)||len==0) return NULL;
+    int32_t len = loc.getKeywordValue("sp", provider, 200, *status);
+    if(U_FAILURE(*status)||len==0) return NULL;
 #if DATE_FE_DEBUG
-    fprintf(stderr,  "VCF:KWV> %s/%d\n", u_errorName(status), len);
+    fprintf(stderr,  "VCF:KWV> %s/%d\n", u_errorName(*status), len);
 #endif
     provider[len]=0;
 #if DATE_FE_DEBUG
@@ -219,7 +241,7 @@ DateFormat *VersionDateFormatFactory::createFormat(const Locale &loc) {
 #if defined(GLUE_VER)
 #undef GLUE_VER
 #endif
-#define GLUE_VER(x) /*printf("%c/%c|%c/%c\n", icuver[0],(#x)[0],icuver[1],(#x)[2]);*/  if(icuver[0]== (#x)[0] && icuver[1]==(#x)[2]) { DateFormat *c = glue ## DateFormat ## x :: create(loc, icuver); /*fprintf(stderr, "VCF::CC %s -> %p\n", loc.getName(), c);*/ return c; }
+#define GLUE_VER(x) /*printf("%c/%c|%c/%c\n", icuver[0],(#x)[0],icuver[1],(#x)[2]);*/  if(icuver[0]== (#x)[0] && icuver[1]==(#x)[2]) { DateFormat *c = glue ## DateFormat ## x :: create(timeStyle,dateStyle,locale,tzID,tzIDLength,pattern,patternLength,status,loc,icuver); /*fprintf(stderr, "VCF::CC %s -> %p\n", loc.getName(), c);*/ return c; }
 #include "icuglue/glver.h"
 #if DATE_FE_DEBUG
     fprintf(stderr,  "VCF:CC %s failed\n", loc.getName());
@@ -288,8 +310,7 @@ extern "C" UDateFormat *versionDateFormatOpener(UDateFormatStyle  timeStyle,
                                                     const UChar       *pattern,
                                                     int32_t           patternLength,
                                                        UErrorCode        *status) {
-  Locale loc(locale);
-  DateFormat *df = vdf.createFormat(loc);
+  DateFormat *df = vdf.createFormat(timeStyle,dateStyle,locale,tzID,tzIDLength,pattern,patternLength,status);
   // printf("Hey! I got: %s -> %p\n", locale, df);
   return (UDateFormat*)df;
 }
index b0e256507fc7d9b7c9e5e67fcc6ec2ae383f8802..91f36a7b33cfcb87fdefcfe78b220d1a71665dc9 100644 (file)
@@ -1,8 +1,10 @@
 #!/bin/cat
-# Copyright (c) 2009-2011 IBM Corp. and Others. All Rights Reserved
+# Copyright (c) 2009-2012 IBM Corp. and Others. All Rights Reserved
 
 # ICU Provider Feature. - $Id$
 
+* Note, as of ICU49 this is a technology preview.
+
 BUILDING:
 
 1a. Download the ICU source (.tgz) you wish to TARGET (i.e. link your
@@ -11,7 +13,7 @@ http://source.icu-project.org/repos/icu/icu/branches/srl/ucol8157 at
 this writing.
 
 1b. Download one or more ICUs (.tgz) you wish to have AVAILABLE (via
-the provider interface).  As of this writing, 49, 4.6.x, 4.4.x, 4.2.0.1, 3.8.1, 3.6, 3.4.1, and 3.2.1 have been tested.
+the provider interface).  As of this writing, 49, 4.8.1.1, 4.6.x, 4.4.x, 4.2.0.1, 3.8.1, 3.6, 3.4.1, and 3.2.1 have been tested.
 
    Note that the MAJOR+MINOR version numbers must not conflict between the TARGET  and AVAILABLE ICUs. Only one ICU of each major+minor is allowed. 
    So, only one 4.4.X, one 3.8.X, etc.  This is due to ICU binary compatibility rules.
@@ -73,3 +75,5 @@ Date Formats opened (udat_open) will also load a different date
 format, but only through 'udat_open'.
 
 
+
+