diff --git a/.gitattributes b/.gitattributes index caccb217a1f..ad9bd4e7841 100644 --- a/.gitattributes +++ b/.gitattributes @@ -334,6 +334,8 @@ tools/multi/c/patch/3_2 -text tools/multi/c/patch/3_4_1 -text tools/multi/common/Makefile-multi.inc -text tools/multi/j/Makefile-j.inc -text +tools/multi/proj/provider/Makefile.local-sample -text +tools/multi/proj/provider/icu-config.sed -text tools/release/java/.classpath -text tools/release/java/.project -text tools/release/java/Makefile -text diff --git a/.gitignore b/.gitignore index 34aa2cb1a1f..9189ce3546d 100644 --- a/.gitignore +++ b/.gitignore @@ -785,6 +785,7 @@ icu4j/tools/misc/out tools/multi/packages/*.jar tools/multi/packages/*.tgz tools/multi/proj/chello/out +tools/multi/proj/provider/out tools/multi/tmp tools/release/java/APIChangeReport.html tools/release/java/Makefile.local diff --git a/tools/multi/Makefile b/tools/multi/Makefile new file mode 100644 index 00000000000..457dbe63299 --- /dev/null +++ b/tools/multi/Makefile @@ -0,0 +1,3 @@ +# Copyright (c) 2008-2009 IBM Corp. and Others. All Rights Reserved +clean: + -rm -rf ./tmp diff --git a/tools/multi/c/Makefile-c.inc b/tools/multi/c/Makefile-c.inc index 25d550da1cf..93d1f8da71b 100644 --- a/tools/multi/c/Makefile-c.inc +++ b/tools/multi/c/Makefile-c.inc @@ -4,7 +4,6 @@ include $(MULTICU_ROOT)/common/Makefile-multi.inc C_GOOD:=$(shell [ -d $(C_INS) ] && (cd $(C_INS) ; ls -d */$(S_INS) | cut -d/ -f1)) - C_CLEAN_TARGET=$(C_GOOD:%=$(C_INS)/%/bin/$(TARGET)) SOURCES=$(C_SOURCES) $(CXX_SOURCES) @@ -13,6 +12,12 @@ CXX_OBJECTS=$(CXX_SOURCES:%.cpp=%.o) OBJECTS=$(C_OBJECTS) $(CXX_OBJECTS) DEBUGOPT=-g +# list of ICUs to be built +ICU_TARBALLS=$(shell cd $(ICUS) ; ls icu4c-*-src.tgz) +# list of versions ( form "3_8 4_0" etc. ) +ICU_TARBALLS_VERS=$(ICU_TARBALLS:icu4c-%-src.tgz=%) + + $(C_INS)/%/bin/$(TARGET): $(SOURCES) $(HEADERS) -rm -rf $(C_INS)/$*/tmp mkdir $(C_INS)/$*/tmp diff --git a/tools/multi/c/patch/readme.txt b/tools/multi/c/patch/readme.txt new file mode 100644 index 00000000000..1e92395705e --- /dev/null +++ b/tools/multi/c/patch/readme.txt @@ -0,0 +1,5 @@ +#!/bin/cat +# Copyright (c) 2009 IBM Corp. and Others. All Rights Reserved +# + +Contains ICU4C patches to make old versions build. diff --git a/tools/multi/c/superconf.sh b/tools/multi/c/superconf.sh index a6e03befeb2..bc94b306615 100755 --- a/tools/multi/c/superconf.sh +++ b/tools/multi/c/superconf.sh @@ -7,6 +7,8 @@ # input variables; # $ICU_VER - the ICU version in underscore format (4_2_0_1) +ICU_SRC="$1" +ICU_VER="$2" U_HOST=`hostname` U_SYS=`uname || echo unknown` @@ -51,13 +53,13 @@ case $HOST in rcs='LinuxRedHat' ;; *) - echo sh ./configure + echo sh ${ICU_SRC}/configure #echo Unknown host $HOST, edit $0 exit 0 ;; esac -echo sh ./runConfigureICU "${rcs}" +echo sh ${ICU_SRC}/runConfigureICU "${rcs}" diff --git a/tools/multi/common/Makefile-multi.inc b/tools/multi/common/Makefile-multi.inc index 211d72942d4..bc3c16537ba 100644 --- a/tools/multi/common/Makefile-multi.inc +++ b/tools/multi/common/Makefile-multi.inc @@ -9,12 +9,14 @@ C_SRC=$(M_TMP)/src # C defs S_INS=include/unicode/utypes.h -S_BLD=icu/source/config.status -S_SRC=icu/source/configure +S_SRCDIR=icu/source +S_BLD=$(S_SRCDIR)/config.status +S_SRC=$(S_SRCDIR)/configure -include $(MULTICU_ROOT)/common/Makefile-local.inc ICUS=$(MULTICU_ROOT)/packages +TOP=$(shell pwd) # J defs diff --git a/tools/multi/proj/provider/Makefile b/tools/multi/proj/provider/Makefile new file mode 100644 index 00000000000..b410c730d8e --- /dev/null +++ b/tools/multi/proj/provider/Makefile @@ -0,0 +1,203 @@ +# +# Copyright (C) 2009 IBM Corporation and Others, All Rights Reserved. +# + +## configuration +# Absolute path to this dir. +# dir holding ICUs to be built +MULTICU_ROOT=../.. +include $(MULTICU_ROOT)/c/Makefile-c.inc +ICU_CONFIG=icu-config-nosanity +ICU_CONFIG_ORIG=icu-config + +# subdirs... +# prefix to distinguish it from non-provider builds +P_PREFIX=p +BUILD=$(M_TMP)/$(P_PREFIX)bld +INST=$(M_TMP)/$(P_PREFIX)ins +SRC=$(M_TMP)/$(P_PREFIX)src +OUT=$(TOP)/out +SOURCE=$(S_SRCDIR) +GLUE=glue +GLOUT=$(M_TMP)/$(P_PREFIX)glout +# header locations +INCGLUE=$(TOP)/$(GLUE)/include +# relative path to icuglue within glout +GLUREN=gluren/include/icuglue +# relative path to gluren.h +GLUREN_H=$(GLUREN)/gluren.h +# Special 'configure' caller +SUPERCONF=$(TOP)/$(MULTICU_ROOT)/c/superconf.sh +# options to compilation (such as, debug) +XOPTS=$(EXTRA_COMPILE_OPTS) +OK=ok +MOPTS= + +# directories that need to be built +ALLDIRS=$(INST) $(BUILD) $(SRC) $(GLOUT) $(OUT) +# The 'ok' flag file for installations +INST_ICU=$(ICU_TARBALLS_VERS:%=$(INST)/%/$(OK)) +BUILD_ICU=$(ICU_TARBALLS_VERS:%=$(BUILD)/%/$(OK)) +GLOUT_ICU=$(ICU_TARBALLS_VERS:%=$(GLOUT)/%/$(OK)) +SRC_ICU=$(ICU_TARBALLS_VERS:%=$(SRC)/%/$(OK)) +# gluren.h files for each version +GLUREN_ICU=$(ICU_TARBALLS_VERS:%=$(BUILD)/%/$(GLUREN_H)) +#? +CONFIGURE_CMD= +# Options passed to configure +CONFIGURE_OPTS=--enable-static --disable-shared --with-data-packaging=static --disable-extras --disable-icuio --disable-layout --disable-tests --disable-samples $(EXTRA_CONFIGURE_OPTS) +# additional options passed to make +MAKE_XTRA_OPTS="PKGDATA_MODE=static" +# additional options passed to make install +MAKE_INSTALL_XTRA_OPTS=$(MAKE_XTRA_OPTS) + +# Munged source names: list of C, C++, O etc files for Backend +GL_BE_C=$(shell cd $(GLUE) ; ls *_be.c) +GL_BE_CXX=$(shell cd $(GLUE) ; ls *_be.cpp) +GL_BE_O=$(GL_BE_C:%.c=%.o) $(GL_BE_CPP:%.cpp=%.o) +# Munged source names: list of C, C++, O etc files for Frontend +GL_FE_C=$(shell cd $(GLUE) ; ls *_fe.c) +GL_FE_CXX=$(shell cd $(GLUE) ; ls *_fe.cpp) +GL_FE_O=$(GL_FE_C:%.c=%.o) $(GL_FE_CPP:%.cpp=%.o) +# C flags used in Glue compilation +GLUE_CFLAGS=-I$(INCGLUE) + +# icu-config switches for compiling: C and C++ +ICU_CONFIG_COMMON=--cppflags +# icu-config switches for C +ICU_CONFIG_CC=--cc $(ICU_CONFIG_COMMON) --cflags +# icu-config switches for C++ +ICU_CONFIG_CXX=--cxx $(ICU_CONFIG_COMMON) --cxxflags + +## @build All installed ICUs +ii: $(GLOUT_ICU) + +# Don't delete these files +.PRECIOUS: $(INST_ICU) $(BUILD_ICU) $(SRC_ICU) BUILD_ICU=$(ICU_TARBALLS_VERS:%=$(BUILD)/%/config.status) + +# cleanup +clean: + -rm -rf $(ALLDIRS) + -mkdir $(ALLDIRS) + +# create all empty work dirs +$(ALLDIRS): + -mkdir -p $(@) + +# build the glue objects +$(GLOUT)/%/obj-$(OK): $(GLOUT) glurens $(INST)/%/$(OK) $(BUILD)/%/config/$(ICU_CONFIG) + -mkdir $(GLOUT)/$* +# $(shell $(BUILD)/$*/config/$(ICU_CONFIG) $(ICU_CONFIG_CC)) $(GLUE_CFLAGS) -c -DICUGLUE_VER=$* -o $(GLOUT)/$*/gl_be_c_$*.o $(GL_BE_C:%.c=$(GLUE)/%.c) +# $(shell $(BUILD)/$*/config/$(ICU_CONFIG) $(ICU_CONFIG_CXX)) $(GLUE_CFLAGS) -c -DICUGLUE_VER=$* -o $(GLOUT)/$*/gl_be_cxx_$*.o $(GL_BE_CXX:%.cpp=$(GLUE)/%.cpp) + -rm -rf $(GLOUT)/$*/include + mkdir -p $(GLOUT)/$*/include/icuglue/include + # for each version.. build all OTHER FE files + for ver in $(ICU_TARBALLS_VERS) ; \ + do \ + echo building $$ver for $* ; \ + if [ ! "$$ver" = "$*" ]; \ + then \ + echo $(GLOUT)/$*/gl_fe_c_$${ver}_x_$*.o \ + $(shell $(BUILD)/$*/config/$(ICU_CONFIG) $(ICU_CONFIG_CC)) $(GLUE_CFLAGS) -c -I$(TOP)/$(BUILD)/$$ver/gluren/include -DICUGLUE_VER=$$ver "-DICUGLUE_VER_STR=\"$$ver\"" "-DGLUE_SYM(x)=glue ## x ## $$ver" -o $(GLOUT)/$*/gl_fe_c_$${ver}_x_$*.o $(GL_FE_C:%.c=$(GLUE)/%.c) $(XOPTS) ; \ + $(shell $(BUILD)/$*/config/$(ICU_CONFIG) $(ICU_CONFIG_CXX)) $(GLUE_CFLAGS) -c -I$(TOP)/$(BUILD)/$$ver/gluren/include -DICUGLUE_VER=$$ver "-DICUGLUE_VER_STR=\"$$ver\"" "-DGLUE_SYM(x)=glue ## x ## $$ver" -o $(GLOUT)/$*/gl_fe_cxx_$${ver}_x_$*.o $(GL_FE_CXX:%.cpp=$(GLUE)/%.cpp) $(XOPTS) ; \ + echo " GLUE_VER( $$ver ) " >> $(GLOUT)/$*/include/icuglue/glver.h; \ + fi \ + done + # build 'this version' FE files + $(shell $(BUILD)/$*/config/$(ICU_CONFIG) $(ICU_CONFIG_CC)) $(GLUE_CFLAGS) -I$(GLOUT)/$*/include -c -o $(GLOUT)/$*/gl_fe_c_$*.o $(GL_FE_C:%.c=$(GLUE)/%.c) $(XOPTS) + $(shell $(BUILD)/$*/config/$(ICU_CONFIG) $(ICU_CONFIG_CXX)) $(GLUE_CFLAGS) -I$(GLOUT)/$*/include -c -o $(GLOUT)/$*/gl_fe_cxx_$*.o $(GL_FE_CXX:%.cpp=$(GLUE)/%.cpp) $(XOPTS) + # build 'this version' BE files (disabled for now) +# $(shell $(BUILD)/$*/config/$(ICU_CONFIG) $(ICU_CONFIG_CC)) $(GLUE_CFLAGS) -c -DICUGLUE_VER=$* -o $(GLOUT)/$*/gl_be_c_$*.o $(GL_BE_C:%.c=$(GLUE)/%.c) +# $(shell $(BUILD)/$*/config/$(ICU_CONFIG) $(ICU_CONFIG_CXX)) $(GLUE_CFLAGS) -c -DICUGLUE_VER=$* -o $(GLOUT)/$*/gl_be_cxx_$*.o $(GL_BE_CXX:%.cpp=$(GLUE)/%.cpp) + touch $@ + +# for now, glue is OK when the objects are OK. +# TODO: replace this with build of a specific lib. +$(GLOUT)/%/$(OK): $(GLOUT)/%/obj-$(OK) + touch $@ + +PROVIDER=provider +LIBPROVIDER=lib$(PROVIDER).a + +libs: $(ICU_TARBALLS_VERS:%=$(OUT)/%/lib/$(LIBPROVIDER)) + +#GLOUT_ICU=$(ICU_TARBALLS_VERS:%=$(GLOUT)/%/$(OK)) +$(OUT)/%/lib/$(LIBPROVIDER): $(GLOUT)/%/obj-$(OK) + -mkdir -p $(OUT)/$*/lib + echo copy includes + ar -rv $@ $(GLOUT)/$*/*.o + ranlib $@ + + +# -[ -d $(SRC)/$* ] && rm -rf $(SRC)/$* + +## @@ build glu rename files +glurens: $(GLUREN_ICU) + +# build single gluren.h +$(BUILD)/%/$(GLUREN_H): $(BUILD)/%/ok Makefile + -mkdir -p $(BUILD)/$*/$(GLUREN) + cat $(GLUE)/gluren-top.h > $@ + echo "#define GLUREN_VER" $* >> $@ + echo "#define GLUREN_TINY" $(shell echo $* | cut -d_ -f1-2) >> $@ + echo >> $@ + echo >> $@ + echo >> $@ + grep "^#define.*$(shell echo $* | cut -d_ -f1-2)$$" $(SRC)/$*/$(SOURCE)/common/unicode/urename.h | fgrep -v '*' | \ + sed -e "s@^#define \([^ ]*\) \([^ ]*\)@#define OICU_\1 \2@" >> $@ + cat $(GLUE)/gluren-bottom.h >> $@ + + +$(BUILD)/%/config/$(ICU_CONFIG): $(BUILD)/%/config/$(ICU_CONFIG_ORIG) icu-config.sed $(BUILD)/%/ok + sed -f icu-config.sed < $(BUILD)/$*/config/$(ICU_CONFIG_ORIG) > $(BUILD)/$*/config/$(ICU_CONFIG) && chmod a+rx $(BUILD)/$*/config/$(ICU_CONFIG) + +# smiling now. +# perform installation +$(INST)/%/ok: $(BUILD)/%/ok + echo "INST " "[" $* "]" + mkdir -p $(INST)/$* + -$(MAKE) $(MOPTS) -C $(BUILD)/$* install $(MAKE_INSTALL_XTRA_OPTS) + touch $@ + +# unpack ICU and patch +$(SRC)/%/ok: $(ICUS)/icu4c-%-src.tgz + -[ -d $(SRC)/$* ] && rm -rf $(SRC)/$* + @echo "Unpacking" $* + mkdir -p $(SRC)/$* + ( cd $(SRC)/$* && tar xfpz $(TOP)/$(ICUS)/icu4c-$*-src.tgz ) + @echo Should patch $* here + touch $@ + +# config +$(BUILD)/%/config.status: $(SRC)/%/ok + @echo "Configging" $* + -[ -d $(BUILD)/$* ] && rm -rf $(BUILD)/$* + mkdir -p $(BUILD)/$* + ( cd $(BUILD)/$* && $(shell $(SUPERCONF) $(TOP)/$(SRC)/$*/$(SOURCE) $*) $(CONFIGURE_OPTS) --srcdir=$(TOP)/$(SRC)/$*/$(SOURCE) --prefix=$(TOP)/$(INST)/$* ) + +# build +$(BUILD)/%/ok: $(BUILD)/%/config.status + @echo "Building" $* + ( $(MAKE) $(MOPTS) -C $(BUILD)/$* all $(MAKE_XTRA_OPTS) ) + touch $@ + +# ( cd $(BUILD_ICU)/% ; echo tar xvfpz $(ICUS)/icu4c-$*-src.tgz ) +# touch $@ + +# +help: + @echo ICU Provider Build + @echo Available ICU tarballs: $(ICU_TARBALLS) + @echo Available ICU versions: $(ICU_TARBALLS_VERS) + +# from makefoo: +#EYF+=g++ -g -dead_strip -o foo glout/4_2_0_1/*.o -Linst/4_2_0_1/lib/ -Lbuild/4_2_0_1/data/out/ -lsicuuc -lsicui18n -licudt42l build/3_8_1/*/*.ao build/4_0_1/*/*.ao build/4_0_1/data/out/tmp/icudt40l_dat.o build/3_8_1/data/out/tmp/icudt38l_dat.o + + + +# backup +#arch: +# cd .. ; tar cvfpj MI$$$$.tar.bz2 $(DIR)/Makefile $(DIR)/superconf.sh $(DIR)/glue $(DIR)/makefoo.sh $(DIR)/coldiff.cpp + +#-- for the prototype + diff --git a/tools/multi/proj/provider/Makefile.local-sample b/tools/multi/proj/provider/Makefile.local-sample new file mode 100644 index 00000000000..3028509e146 --- /dev/null +++ b/tools/multi/proj/provider/Makefile.local-sample @@ -0,0 +1,11 @@ +# Copyright (c) 2008-2009 IBM Corp. and Others. All Rights Reserved + +# local definitions can go in Makefile.local +# example: + +## debug options +EXTRA_COMPILE_OPTS=-g + +## configure options +#EXTRA_CONFIGURE_OPTS=--with-library-suffix=srl + diff --git a/tools/multi/proj/provider/glue/_versionlist_.cpp b/tools/multi/proj/provider/glue/_versionlist_.cpp new file mode 100644 index 00000000000..90106094e3c --- /dev/null +++ b/tools/multi/proj/provider/glue/_versionlist_.cpp @@ -0,0 +1,36 @@ +/* +******************************************************************************* +* +* Copyright (C) 2009, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + +#include +#include + + +#if defined ( ICUGLUE_VER ) +//#error DEFINED! +#else + +#define GLUE_VER(x) puts("Version " # x ); + +#include + +// generate list of versions +#include + +int main(int argc, const char *argv[]) { +printf("I'm on " U_ICU_VERSION " but i have modules for: \n"); + for(int i=0;fe_verlist[i];i++) { + printf("%d: %s\n", i, fe_verlist[i]); + } +} + +#endif + + + + diff --git a/tools/multi/proj/provider/glue/coll_be.c b/tools/multi/proj/provider/glue/coll_be.c new file mode 100644 index 00000000000..d0e2f222f69 --- /dev/null +++ b/tools/multi/proj/provider/glue/coll_be.c @@ -0,0 +1,10 @@ +/* +******************************************************************************* +* +* Copyright (C) 2009, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + +/* */ diff --git a/tools/multi/proj/provider/glue/coll_be.cpp b/tools/multi/proj/provider/glue/coll_be.cpp new file mode 100644 index 00000000000..a0ed27334d0 --- /dev/null +++ b/tools/multi/proj/provider/glue/coll_be.cpp @@ -0,0 +1,20 @@ +/* +******************************************************************************* +* +* Copyright (C) 2009, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + + + +#include +#include +XP_CPLUSPLUS + + + +extern "C" { + +} \ No newline at end of file diff --git a/tools/multi/proj/provider/glue/coll_fe.c b/tools/multi/proj/provider/glue/coll_fe.c new file mode 100644 index 00000000000..db672d6fea0 --- /dev/null +++ b/tools/multi/proj/provider/glue/coll_fe.c @@ -0,0 +1,19 @@ +/* +******************************************************************************* +* +* Copyright (C) 2009, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + +/* +not needed. +*/ + + +extern void not_needed () { + return; +} + + diff --git a/tools/multi/proj/provider/glue/coll_fe.cpp b/tools/multi/proj/provider/glue/coll_fe.cpp new file mode 100644 index 00000000000..ba76a295273 --- /dev/null +++ b/tools/multi/proj/provider/glue/coll_fe.cpp @@ -0,0 +1,508 @@ +/* +******************************************************************************* +* +* Copyright (C) 2009, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + +#define COLL_FE_DEBUG 1 + + +#include +#include +//#include +#include +#include +#include +#include "unicode/ustring.h" + +// these from tblcoll.h +static Collator::ECollationStrength _getECollationStrength( + const UCollationStrength &strength) +{ + switch (strength) + { + case UCOL_PRIMARY : + return Collator::PRIMARY; + case UCOL_SECONDARY : + return Collator::SECONDARY; + case UCOL_TERTIARY : + return Collator::TERTIARY; + case UCOL_QUATERNARY : + return Collator::QUATERNARY; + default : + return Collator::IDENTICAL; + } +} + +static UCollationStrength _getUCollationStrength( + const Collator::ECollationStrength &strength) +{ + switch (strength) + { + case Collator::PRIMARY : + return UCOL_PRIMARY; + case Collator::SECONDARY : + return UCOL_SECONDARY; + case Collator::TERTIARY : + return UCOL_TERTIARY; + case Collator::QUATERNARY : + return UCOL_QUATERNARY; + default : + return UCOL_IDENTICAL; + } +} + + +/** + * Macro to define the Collator_glue_4_2 class + */ +#define GLUE_VER(x) class GLUE_SYM_V( Collator, x ) : public Collator { \ + \ + public: static Collator *create(const Locale &loc, const char *ver); \ + private: UCollator *_this; GLUE_SYM_V( Collator, x ) ( UCollator* tn ) : _this(tn){} \ + virtual ~ GLUE_SYM_V ( Collator, x) (); \ + public: \ + virtual void* getDynamicClassID() const; \ + static void* getStaticClassID() ; \ + virtual Collator* clone() const; \ + virtual UCollationResult compare(const UnicodeString&, const UnicodeString&, UErrorCode&) const; \ + virtual UCollationResult compare(const UnicodeString&, const UnicodeString&, int32_t, UErrorCode&) const; \ + virtual UCollationResult compare(const UChar*, int32_t, const UChar*, int32_t, UErrorCode&) const; \ + virtual CollationKey& getCollationKey(const UnicodeString&, CollationKey&, UErrorCode&) const; \ + virtual CollationKey& getCollationKey(const UChar*, int32_t, CollationKey&, UErrorCode&) const; \ + virtual int32_t hashCode() const; \ + virtual const Locale getLocale(ULocDataLocaleType, UErrorCode&) const; \ + virtual ECollationStrength getStrength() const; \ + virtual void setStrength(ECollationStrength); \ + virtual void getVersion(uint8_t*) const; \ + virtual void setAttribute(UColAttribute, UColAttributeValue, UErrorCode&); \ + virtual UColAttributeValue getAttribute(UColAttribute, UErrorCode&); \ + virtual uint32_t setVariableTop(const UChar*, int32_t, UErrorCode&); \ + virtual uint32_t setVariableTop(UnicodeString, UErrorCode&); \ + virtual void setVariableTop(uint32_t, UErrorCode&); \ + virtual uint32_t getVariableTop(UErrorCode&) const; \ + virtual Collator* safeClone(); \ + virtual int32_t getSortKey(const UnicodeString&, uint8_t*, int32_t) const; \ + virtual int32_t getSortKey(const UChar*, int32_t, uint8_t*, int32_t) const; \ + public: static int32_t countAvailable(); \ + public: static int32_t appendAvailable(UnicodeString* strs, int32_t i, int32_t count); \ +}; + +#if defined ( ICUGLUE_VER ) + +/* code for some version */ +#include + +/** + ucol.h +*/ +U_STABLE UCollator* U_EXPORT2 +OICU_ucol_open(const char *loc, UErrorCode& status); + +U_STABLE void U_EXPORT2 +OICU_ucol_close(UCollator*); + +U_STABLE UCollationResult OICU_ucol_strcoll ( const UCollator * coll, +const UChar * source, +int32_t sourceLength, +const UChar * target, +int32_t targetLength +); + +U_STABLE int32_t U_EXPORT2 +OICU_ucol_countAvailable(); + +U_STABLE void U_EXPORT2 +OICU_ucol_setStrength(const UCollator *, UCollationStrength ); + +U_STABLE const char * U_EXPORT2 +OICU_ucol_getAvailable(int32_t i); + +U_STABLE UCollationStrength U_EXPORT2 +OICU_ucol_getStrength(UCollator *col); + +U_STABLE int32_t U_EXPORT2 +OICU_ucol_getSortKey(const UCollator *coll, + const UChar *source, + int32_t sourceLength, + uint8_t *result, + int32_t resultLength); + + +U_STABLE UCollator* U_EXPORT2 +OICU_ucol_safeClone(const UCollator *coll, + void *stackBuffer, + int32_t *pBufferSize, + UErrorCode *status); + + +/** + end ucol.h +*/ + +// define version +GLUE_VER( ICUGLUE_VER ) + +GLUE_SYM ( Collator ) :: ~ GLUE_SYM(Collator) () { +#if COLL_FE_DEBUG + fprintf(stderr, "VCF " ICUGLUE_VER_STR " ucol_close"); +#endif + OICU_ucol_close(_this); +} + +#if 0 +U_CFUNC int32_t U_CALLCONV +GLUE_SYM ( glue_calcSortKey) (const UCollator *coll, + const UChar *source, + int32_t sourceLength, + uint8_t **result, + uint32_t resultLength, + UBool allocateSKBuffer, + UErrorCode *status); + +#endif + +Collator * +GLUE_SYM ( Collator ) :: create (const Locale &loc, const char *ver) { + 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); + } + UCollator * uc = OICU_ucol_open( locBuf, status); + if(U_FAILURE(status)) return NULL; // TODO: ERR? + Collator *c = new GLUE_SYM( Collator ) ( uc ); +#if COLL_FE_DEBUG + fprintf(stderr, "VCF " ICUGLUE_VER_STR " ucol_open=%s ->> %p\n", locBuf, c); +#endif + return c; +} + +UOBJECT_DEFINE_RTTI_IMPLEMENTATION( GLUE_SYM( Collator ) ) + +Collator* GLUE_SYM ( Collator ) :: clone() const { + UErrorCode status; + UCollator *clc = OICU_ucol_safeClone( _this, NULL, 0, &status); + if(U_FAILURE(status)||clc==NULL) return NULL; + Collator *c = new GLUE_SYM( Collator ) ( clc ); +// c->setLocales(getLocale(ULOC_REQUESTED_LOCALE,status),getLocale(ULOC_VALID_LOCALE,status),getLocale(ULOC_ACTUAL_LOCALE,status)); + +// if(U_FAILURE(status)) { +// delete c; +// c = NULL; +// } + return c; +} + + +UCollationResult GLUE_SYM ( Collator ) :: compare(const UnicodeString&, const UnicodeString&, UErrorCode&) const { + return (UCollationResult)0; +} + + +UCollationResult GLUE_SYM ( Collator ) :: compare(const UnicodeString&, const UnicodeString&, int32_t, UErrorCode&) const { + return (UCollationResult)0; +} + + +UCollationResult GLUE_SYM ( Collator ) :: compare(const UChar* s, int32_t sl, const UChar* d , int32_t dl, UErrorCode&e ) const { + return OICU_ucol_strcoll(_this, s, sl, d, dl); +} + +#include "unicode/sortkey.h" + +static CollationKey kk; + +CollationKey& GLUE_SYM ( Collator ) :: getCollationKey(const UnicodeString&, CollationKey&, UErrorCode&) const { + fprintf(stderr, "VCF " ICUGLUE_VER_STR " GCK"); +return kk; +} + + +CollationKey& GLUE_SYM ( Collator ) :: getCollationKey(const UChar*, int32_t, CollationKey&, UErrorCode&) const { + fprintf(stderr, "VCF " ICUGLUE_VER_STR " GKK2"); +return kk; +} + + +int32_t GLUE_SYM ( Collator ) :: hashCode() const { + return 0; +} + + +const Locale GLUE_SYM ( Collator ) :: getLocale(ULocDataLocaleType, UErrorCode&) const { + return Locale(); +} + + +Collator::ECollationStrength + GLUE_SYM ( Collator ) :: getStrength() const { + return _getECollationStrength(OICU_ucol_getStrength(_this)); +} + + +void GLUE_SYM ( Collator ) :: setStrength(ECollationStrength s) { + OICU_ucol_setStrength(_this, _getUCollationStrength(s)); +} + + +void GLUE_SYM ( Collator ) :: getVersion(uint8_t*) const { +} + + +void GLUE_SYM ( Collator ) :: setAttribute(UColAttribute, UColAttributeValue, UErrorCode&) { +} + + +UColAttributeValue GLUE_SYM ( Collator ) :: getAttribute(UColAttribute, UErrorCode&) { +return (UColAttributeValue)0; +} + + +uint32_t GLUE_SYM ( Collator ) :: setVariableTop(const UChar*, int32_t, UErrorCode&) { +return 0; +} + + +uint32_t GLUE_SYM ( Collator ) :: setVariableTop(UnicodeString, UErrorCode&) { +return 0; +} + + +void GLUE_SYM ( Collator ) :: setVariableTop(uint32_t, UErrorCode&) { +} + + +uint32_t GLUE_SYM ( Collator ) :: getVariableTop(UErrorCode&) const { +return 0; +} + + +Collator* GLUE_SYM ( Collator ) :: safeClone() { + return clone(); +} + + +int32_t GLUE_SYM ( Collator ) :: getSortKey(const UnicodeString& s, uint8_t*buf, int32_t len) const { +// fprintf(stderr, "VCF " ICUGLUE_VER_STR " GSK"); + return getSortKey(s.getBuffer(),s.length(), buf, len); +} + + + + +int32_t GLUE_SYM ( Collator ) :: getSortKey(const UChar*s, int32_t l, uint8_t*d, int32_t b) const { + fprintf(stderr, "VCF " ICUGLUE_VER_STR " GKS"); + return OICU_ucol_getSortKey(_this, s,l,d,b); +} + + int32_t GLUE_SYM ( Collator ) :: countAvailable() { + int32_t count = OICU_ucol_countAvailable(); + return count; + } + + + int32_t GLUE_SYM ( Collator ) :: appendAvailable(UnicodeString* strs, int32_t i, int32_t count) { + for(int j=0;j>\n", i, j, i+j, foo); + } +#endif + } + return OICU_ucol_countAvailable(); + } + + + + +#else + +// define Collator_XX +#include "icuglue/glver.h" + +// generate list of versions +static +#include + +class VersionCollatorFactory : public CollatorFactory { +public: + virtual Collator *createCollator(const Locale &loc); + virtual const UnicodeString *getSupportedIDs(int32_t &count, UErrorCode &status); + virtual void* getDynamicClassID() const; + static void* getStaticClassID() ; +}; + +UOBJECT_DEFINE_RTTI_IMPLEMENTATION( VersionCollatorFactory ) + +Collator *VersionCollatorFactory::createCollator(const Locale &loc) { + // pull off provider # + char provider[200]; + UErrorCode status = U_ZERO_ERROR; +#if COLL_FE_DEBUG + fprintf(stderr, "VCF:CC %s\n", loc.getName()); +#endif + int32_t len = loc.getKeywordValue("provider", provider, 200, status); + if(U_FAILURE(status)||len==0) return NULL; +#if COLL_FE_DEBUG + fprintf(stderr, "VCF:KWV> %s/%d\n", u_errorName(status), len); +#endif + provider[len]=0; +#if COLL_FE_DEBUG + fprintf(stderr, "VCF:KWV %s\n", provider); +#endif + if(strncmp(provider,"ICU",3)) return NULL; + const char *icuver=provider+3; +#if 1 + fprintf(stderr, "VCF:ICUV %s\n", icuver); +#endif + +#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]) { return glue ## Collator ## x :: create(loc, icuver); } +#include "icuglue/glver.h" +#if 1 + fprintf(stderr, "VCF:CC %s failed\n", loc.getName()); +#endif + + return NULL; +} + + +static const UnicodeString *gLocales = NULL; +static int32_t gLocCount = 0; + +const UnicodeString +*VersionCollatorFactory::getSupportedIDs(int32_t &count, UErrorCode &status) { + if(gLocales==NULL) { + count = 0; + + + /* gather counts */ +#if defined(GLUE_VER) +#undef GLUE_VER +#endif +#define GLUE_VER(x) count += glue ## Collator ## x :: countAvailable(); +#include "icuglue/glver.h" + +printf("VCF: count=%d\n", count); +UnicodeString *strs = new UnicodeString[count]; +int32_t i = 0; + +#if defined(GLUE_VER) +#undef GLUE_VER +#endif +#define GLUE_VER(x) i += glue ## Collator ## x :: appendAvailable(strs, i, count); +#include "icuglue/glver.h" + +printf("VCF: appended count=%d\n", count); + + gLocCount = count; + gLocales = strs; +} +count = gLocCount; +return gLocales; +} + + +/* test main */ +#if 1 +#include + +void coll_provider_register(UErrorCode &status) { + URegistryKey rk = Collator::registerFactory(new VersionCollatorFactory(), status); +} + +#if 0 +void main(int argc, const char *argv[]) { + puts("hello"); + { + int32_t count; + UErrorCode status = U_ZERO_ERROR; + Collator::getAvailableLocales(count); + fprintf(stderr, "Old avail: %d\n", count); + StringEnumeration *se = Collator::getAvailableLocales(); + count = se->count(status); + fprintf(stderr, "Old count avail: %d, %s\n", count, u_errorName(status)); + } + + UErrorCode status = U_ZERO_ERROR; + coll_provider_register(status); + fprintf(stderr, "Registered VCF: %p, er %s\n", rk, u_errorName(status)); + { + int32_t count; + Collator::getAvailableLocales(count); + fprintf(stderr, "New avail: %d\n", count); + StringEnumeration *se = Collator::getAvailableLocales(); + count = se->count(status); + fprintf(stderr, "New count avail: %d, %s\n", count, u_errorName(status)); +#if 0 + const char *str; + for(;(str=se->next(NULL,status))!=NULL;) { + fprintf(stderr, "\t%s", str); + } +#endif +#if 1 + const UnicodeString *str; + for(;(str=se->snext(status))!=NULL;) { + { + char foo[999]; + UnicodeString id2 = UnicodeString(*(str)); + u_austrcpy(foo, id2.getTerminatedBuffer()); + fprintf(stderr, "\t%s", foo); + } +// fprintf(stderr, "\t%s", str); + } +#endif + puts("\n"); + + } + { + UErrorCode status = U_ZERO_ERROR; + UCollator *a; + UCollator *b; + UCollator *c; + UCollator *d; + + a = ucol_open("th", &status); + fprintf(stderr, "opena %s\n", u_errorName(status)); + b = ucol_open("ar_SA@provider=ICU40", &status); + fprintf(stderr, "opena %s\n", u_errorName(status)); + c = ucol_open("nn_NO@provider=ICU38", &status); + fprintf(stderr, "opena %s\n", u_errorName(status)); + d = ucol_open("de@provider=ICU38;collation=phonebook", &status); + fprintf(stderr, "opena %s\n", u_errorName(status)); + + + ucol_close(a); + ucol_close(b); + ucol_close(c); + ucol_close(d); + } +} + +#endif + +#endif + +#endif + + + + diff --git a/tools/multi/proj/provider/glue/gluren-bottom.h b/tools/multi/proj/provider/glue/gluren-bottom.h new file mode 100644 index 00000000000..7abfb68eda7 --- /dev/null +++ b/tools/multi/proj/provider/glue/gluren-bottom.h @@ -0,0 +1,12 @@ + +#endif + +/* +******************************************************************************* +* +* Copyright (C) 2009, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + diff --git a/tools/multi/proj/provider/glue/gluren-top.h b/tools/multi/proj/provider/glue/gluren-top.h new file mode 100644 index 00000000000..6128bf1b3ce --- /dev/null +++ b/tools/multi/proj/provider/glue/gluren-top.h @@ -0,0 +1,12 @@ +/* +******************************************************************************* +* +* Copyright (C) 2009, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + +#ifndef _GLUREN_H +#define _GLUREN_H + diff --git a/tools/multi/proj/provider/glue/include/icuglue/coll_be.h b/tools/multi/proj/provider/glue/include/icuglue/coll_be.h new file mode 100644 index 00000000000..08cc7d31e6c --- /dev/null +++ b/tools/multi/proj/provider/glue/include/icuglue/coll_be.h @@ -0,0 +1,29 @@ +/* +******************************************************************************* +* +* Copyright (C) 2009, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + +#ifndef _COLL_BE +#define _COLL_BE + +#include +#include /* for definitions */ + +#if defined(XP_CPLUSPLUS) +extern "C" { +#endif + +void * GLUE_SYM(ucol_open) (const char *locale); +void * GLUE_SYM(ucol_close) (void *coll); +void * GLUE_SYM( + + +#if defined(XP_CPLUSPLUS) +} +#endif + +#endif \ No newline at end of file diff --git a/tools/multi/proj/provider/glue/include/icuglue/coll_fe.h b/tools/multi/proj/provider/glue/include/icuglue/coll_fe.h new file mode 100644 index 00000000000..dbf2f85f136 --- /dev/null +++ b/tools/multi/proj/provider/glue/include/icuglue/coll_fe.h @@ -0,0 +1,24 @@ +/* +******************************************************************************* +* +* Copyright (C) 2009, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + +#ifndef _COLL_FE +#define _COLL_FE + +#include +#include + +#if defined(XP_CPLUSPLUS) + +class GLUE_SYM( GlueFECollator ) : public Collator { + +}; + +#endif /* XP_CPLUSPLUS */ + +#endif \ No newline at end of file diff --git a/tools/multi/proj/provider/glue/include/icuglue/fe_verlist.h b/tools/multi/proj/provider/glue/include/icuglue/fe_verlist.h new file mode 100644 index 00000000000..92273c3f86d --- /dev/null +++ b/tools/multi/proj/provider/glue/include/icuglue/fe_verlist.h @@ -0,0 +1,26 @@ +/* +******************************************************************************* +* +* Copyright (C) 2009, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + +/** + * Purpose: create local or static fe_verlist such as: + * + * const char *fe_verlist[] = { "4_2", "4_2_3", ..., NULL }; + */ + +#if defined(GLUE_VER) +#undef GLUE_VER +#endif + +const char *fe_verlist[] = { +#define GLUE_VER(x) #x , +#include "icuglue/glver.h" +#undef GLUE_VER + NULL +}; + diff --git a/tools/multi/proj/provider/glue/include/icuglue/icuglue.h b/tools/multi/proj/provider/glue/include/icuglue/icuglue.h new file mode 100644 index 00000000000..bbe7eca1819 --- /dev/null +++ b/tools/multi/proj/provider/glue/include/icuglue/icuglue.h @@ -0,0 +1,19 @@ +/* +******************************************************************************* +* +* Copyright (C) 2009, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + +#ifndef _ICUGLUE_H +#define _ICUGLUE_H + +/* Get utypes.h from whatever ICU we are under */ +#include + +//#define GLUE_SYM(x) glue ## x ## ICUGLUE_VER +#define GLUE_SYM_V(x, v) glue ## x ## v + +#endif \ No newline at end of file diff --git a/tools/multi/proj/provider/icu-config.sed b/tools/multi/proj/provider/icu-config.sed new file mode 100644 index 00000000000..349fe96ba8c --- /dev/null +++ b/tools/multi/proj/provider/icu-config.sed @@ -0,0 +1,4 @@ +# Copyright (c) 2008-2009 IBM Corp. and Others. All Rights Reserved +# munge +s%^sanity$%# sanity disabled.% + diff --git a/tools/multi/proj/provider/test/Makefile b/tools/multi/proj/provider/test/Makefile new file mode 100644 index 00000000000..03dd8978977 --- /dev/null +++ b/tools/multi/proj/provider/test/Makefile @@ -0,0 +1,15 @@ +# Copyright (c) 2008-2009 IBM Corp. and Others. All Rights Reserved + +# use version 4.2.0.1 +TESTER_VER=4_2_0_1 +TESTER=coldiff +TESTERS=$(TESTER)_$(TESTER_VER) +testers: $(TESTERS) + +$(TESTER)_$(TESTER_VER).o: $(TESTER).cpp + $(shell $(BUILD)/$(TESTER_VER)/config/icu-config $(ICU_CONFIG_CXX)) -c -I$(TOP)/$(BUILD)/$(TESTER_VER)/gluren/include -DICUGLUE_VER=$$ver -o $@ $< + +$(TESTER)_$(TESTER_VER): $(TESTER)_$(TESTER_VER).o glout/$(TESTER_VER)/*.o build/3_8_1/*/*.ao build/4_0_1/*/*.ao build/4_0_1/data/out/tmp/icudt40l_dat.o build/3_8_1/data/out/tmp/icudt38l_dat.o + g++ -g -dead_strip -o $@ $(TESTER)_$(TESTER_VER).o glout/$(TESTER_VER)/*.o -Linst/$(TESTER_VER)/lib/ -Lbuild/$(TESTER_VER)/data/out/ -lsicuuc -lsicui18n -licudt42l build/3_8_1/*/*.ao build/4_0_1/*/*.ao build/4_0_1/data/out/tmp/icudt40l_dat.o build/3_8_1/data/out/tmp/icudt38l_dat.o build/4_3_1/*/*.ao + + diff --git a/tools/multi/proj/provider/test/coldiff.cpp b/tools/multi/proj/provider/test/coldiff.cpp new file mode 100644 index 00000000000..e926d262cdf --- /dev/null +++ b/tools/multi/proj/provider/test/coldiff.cpp @@ -0,0 +1,111 @@ +/* +******************************************************************************* +* +* Copyright (C) 2009, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + +#include +#include +#include + +extern void coll_provider_register(UErrorCode &status); + +/* String to use. */ +const UChar stuff[] = { 0x30BB, 0x0d4c, 0x53, 0x74, 0x75, 0x66, 0x66, 0x00 }; /* Stuff */ + +#define VERS_COUNT 3 +const char *vers[VERS_COUNT] = { NULL, "40", "38" }; + +#define LOCALE_COUNT 4 +const char *locale[LOCALE_COUNT] = { "fi", "en_US", "ja", "ml" }; + +/** + * Set up the registered collators. + */ +void setup(UErrorCode &status) { + fprintf(stderr, "# ICU %s\n", U_ICU_VERSION); + { + int32_t count; + StringEnumeration *se = Collator::getAvailableLocales(); + count = se->count(status); + fprintf(stderr, "# Collators available: %d,\t%s\n", count, u_errorName(status)); + } + coll_provider_register(status); + fprintf(stderr, "# Registered providers: \t%s\n", u_errorName(status)); + { + int32_t count; + StringEnumeration *se = Collator::getAvailableLocales(); + count = se->count(status); + fprintf(stderr, "# Collators now available: %d,\t%s\n", count, u_errorName(status)); + } +} + +int main(int argc, const char *argv[]) { + UErrorCode status = U_ZERO_ERROR; + setup(status); + if(U_FAILURE(status)) return 1; + for(int l=0;lgetSortKey(stuff, -1, bytes, 200); +#endif + for(int i=0;i0&&i