diff --git a/tools/unicode/c/genprops/CMakeLists.txt b/tools/unicode/c/genprops/CMakeLists.txt index b959e9472d..b459a4096f 100644 --- a/tools/unicode/c/genprops/CMakeLists.txt +++ b/tools/unicode/c/genprops/CMakeLists.txt @@ -5,5 +5,5 @@ # created by: Markus W. Scherer # edited on: 2010jul20 # edited by: Stuart G. Gill -add_executable(genprops genprops.cpp corepropswriter.cpp pnameswriter.cpp) +add_executable(genprops genprops.cpp corepropsbuilder.cpp pnamesbuilder.cpp) target_link_libraries(genprops icuuc icutu) diff --git a/tools/unicode/c/genprops/corepropswriter.cpp b/tools/unicode/c/genprops/corepropsbuilder.cpp similarity index 96% rename from tools/unicode/c/genprops/corepropswriter.cpp rename to tools/unicode/c/genprops/corepropsbuilder.cpp index 7c0dbce3d7..0facdfa080 100644 --- a/tools/unicode/c/genprops/corepropswriter.cpp +++ b/tools/unicode/c/genprops/corepropsbuilder.cpp @@ -5,7 +5,7 @@ * Corporation and others. All Rights Reserved. * ******************************************************************************* -* file name: corepropswriter.cpp (was store.c & props2.cpp) +* file name: corepropsbuilder.cpp (was store.c & props2.cpp) * encoding: US-ASCII * tab size: 8 (not used) * indentation:4 @@ -255,14 +255,14 @@ static UDataInfo dataInfo={ { 6, 0, 0, 0 } /* dataVersion */ }; -class CorePropsWriter : public PropsWriter { +class CorePropsBuilder : public PropsBuilder { public: - CorePropsWriter(UErrorCode &errorCode); - virtual ~CorePropsWriter(); + CorePropsBuilder(UErrorCode &errorCode); + virtual ~CorePropsBuilder(); virtual void setUnicodeVersion(const UVersionInfo version); virtual void setProps(const UniProps &, const UnicodeSet &newValues, UErrorCode &errorCode); - virtual void finalizeData(UErrorCode &errorCode); + virtual void build(UErrorCode &errorCode); virtual void writeCSourceFile(const char *path, UErrorCode &errorCode); virtual void writeBinaryData(const char *path, UBool withCopyright, UErrorCode &errorCode); @@ -275,28 +275,28 @@ private: UnicodeString scriptExtensions; }; -CorePropsWriter::CorePropsWriter(UErrorCode &errorCode) +CorePropsBuilder::CorePropsBuilder(UErrorCode &errorCode) : pTrie(NULL), props2Trie(NULL), pv(NULL) { pTrie=utrie2_open(0, 0, &errorCode); if(U_FAILURE(errorCode)) { - fprintf(stderr, "genprops error: corepropswriter utrie2_open() failed - %s\n", + fprintf(stderr, "genprops error: corepropsbuilder utrie2_open() failed - %s\n", u_errorName(errorCode)); } pv=upvec_open(UPROPS_VECTOR_WORDS, &errorCode); if(U_FAILURE(errorCode)) { - fprintf(stderr, "genprops error: corepropswriter upvec_open() failed - %s\n", + fprintf(stderr, "genprops error: corepropsbuilder upvec_open() failed - %s\n", u_errorName(errorCode)); } } -CorePropsWriter::~CorePropsWriter() { +CorePropsBuilder::~CorePropsBuilder() { utrie2_close(pTrie); utrie2_close(props2Trie); upvec_close(pv); } void -CorePropsWriter::setUnicodeVersion(const UVersionInfo version) { +CorePropsBuilder::setUnicodeVersion(const UVersionInfo version) { uprv_memcpy(dataInfo.dataVersion, version, 4); } @@ -383,8 +383,8 @@ encodeNumericValue(UChar32 start, const char *s, UErrorCode &errorCode) { } void -CorePropsWriter::setGcAndNumeric(const UniProps &props, const UnicodeSet &newValues, - UErrorCode &errorCode) { +CorePropsBuilder::setGcAndNumeric(const UniProps &props, const UnicodeSet &newValues, + UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return; } UChar32 start=props.start; UChar32 end=props.end; @@ -523,8 +523,8 @@ propToEnums[]={ }; void -CorePropsWriter::setProps(const UniProps &props, const UnicodeSet &newValues, - UErrorCode &errorCode) { +CorePropsBuilder::setProps(const UniProps &props, const UnicodeSet &newValues, + UErrorCode &errorCode) { setGcAndNumeric(props, newValues, errorCode); if(U_FAILURE(errorCode)) { return; } @@ -637,7 +637,7 @@ static int32_t props2TrieSize; static int32_t totalSize; void -CorePropsWriter::finalizeData(UErrorCode &errorCode) { +CorePropsBuilder::build(UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return; } utrie2_freeze(pTrie, UTRIE2_16_VALUE_BITS, &errorCode); @@ -718,7 +718,7 @@ CorePropsWriter::finalizeData(UErrorCode &errorCode) { } void -CorePropsWriter::writeCSourceFile(const char *path, UErrorCode &errorCode) { +CorePropsBuilder::writeCSourceFile(const char *path, UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return; } int32_t pvRows; @@ -726,7 +726,7 @@ CorePropsWriter::writeCSourceFile(const char *path, UErrorCode &errorCode) { int32_t pvCount=pvRows*UPROPS_VECTOR_WORDS; FILE *f=usrc_createFromGenerator(path, "uchar_props_data.h", - "icu/tools/src/unicode/c/genprops/corepropswriter.cpp"); + "icu/tools/src/unicode/c/genprops/corepropsbuilder.cpp"); if(f==NULL) { errorCode=U_FILE_ACCESS_ERROR; return; @@ -776,7 +776,7 @@ CorePropsWriter::writeCSourceFile(const char *path, UErrorCode &errorCode) { } void -CorePropsWriter::writeBinaryData(const char *path, UBool withCopyright, UErrorCode &errorCode) { +CorePropsBuilder::writeBinaryData(const char *path, UBool withCopyright, UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return; } int32_t pvRows; @@ -810,10 +810,10 @@ CorePropsWriter::writeBinaryData(const char *path, UBool withCopyright, UErrorCo } } -PropsWriter * -createCorePropsWriter(UErrorCode &errorCode) { +PropsBuilder * +createCorePropsBuilder(UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return NULL; } - PropsWriter *pw=new CorePropsWriter(errorCode); + PropsBuilder *pw=new CorePropsBuilder(errorCode); if(pw==NULL) { errorCode=U_MEMORY_ALLOCATION_ERROR; } diff --git a/tools/unicode/c/genprops/genprops.cpp b/tools/unicode/c/genprops/genprops.cpp index 92be699b6f..de86a440eb 100644 --- a/tools/unicode/c/genprops/genprops.cpp +++ b/tools/unicode/c/genprops/genprops.cpp @@ -35,13 +35,13 @@ U_NAMESPACE_USE UBool beVerbose=FALSE; -PropsWriter::PropsWriter() {} -PropsWriter::~PropsWriter() {} -void PropsWriter::setUnicodeVersion(const UVersionInfo) {} -void PropsWriter::setProps(const UniProps &, const UnicodeSet &, UErrorCode &) {} -void PropsWriter::finalizeData(UErrorCode &) {} -void PropsWriter::writeCSourceFile(const char *, UErrorCode &) {} -void PropsWriter::writeBinaryData(const char *, UBool, UErrorCode &) {} +PropsBuilder::PropsBuilder() {} +PropsBuilder::~PropsBuilder() {} +void PropsBuilder::setUnicodeVersion(const UVersionInfo) {} +void PropsBuilder::setProps(const UniProps &, const UnicodeSet &, UErrorCode &) {} +void PropsBuilder::build(UErrorCode &) {} +void PropsBuilder::writeCSourceFile(const char *, UErrorCode &) {} +void PropsBuilder::writeBinaryData(const char *, UBool, UErrorCode &) {} enum { HELP_H, @@ -95,10 +95,10 @@ main(int argc, char* argv[]) { /* initialize */ IcuToolErrorCode errorCode("genprops"); - LocalPointer pnamesWriter(createPNamesWriter(errorCode)); - LocalPointer corePropsWriter(createCorePropsWriter(errorCode)); + LocalPointer pnamesBuilder(createPNamesBuilder(errorCode)); + LocalPointer corePropsBuilder(createCorePropsBuilder(errorCode)); if(errorCode.isFailure()) { - fprintf(stderr, "genprops: unable to create PropsWriters - %s\n", errorCode.errorName()); + fprintf(stderr, "genprops: unable to create PropsBuilders - %s\n", errorCode.errorName()); return errorCode.reset(); } @@ -121,24 +121,24 @@ main(int argc, char* argv[]) { return errorCode.reset(); } - // The PNamesWriter uses preparsed pnames_data.h. - pnamesWriter->finalizeData(errorCode); + // The PNamesBuilder uses preparsed pnames_data.h. + pnamesBuilder->build(errorCode); if(U_FAILURE(errorCode)) { - fprintf(stderr, "genprops: PNamesWriter::finalizeData() failed - %s\n", + fprintf(stderr, "genprops: PNamesBuilder::build() failed - %s\n", errorCode.errorName()); return errorCode.reset(); } - ppucd.setPropertyNames(pnamesWriter->getPropertyNames()); + ppucd.setPropertyNames(pnamesBuilder->getPropertyNames()); PreparsedUCD::LineType lineType; UnicodeSet newValues; while((lineType=ppucd.readLine(errorCode))!=PreparsedUCD::NO_LINE) { if(ppucd.lineHasPropertyValues()) { const UniProps *props=ppucd.getProps(newValues, errorCode); - corePropsWriter->setProps(*props, newValues, errorCode); + corePropsBuilder->setProps(*props, newValues, errorCode); } else if(lineType==PreparsedUCD::UNICODE_VERSION_LINE) { const UVersionInfo &version=ppucd.getUnicodeVersion(); - corePropsWriter->setUnicodeVersion(version); + corePropsBuilder->setUnicodeVersion(version); } if(errorCode.isFailure()) { fprintf(stderr, @@ -148,7 +148,7 @@ main(int argc, char* argv[]) { } } - corePropsWriter->finalizeData(errorCode); + corePropsBuilder->build(errorCode); if(errorCode.isFailure()) { fprintf(stderr, "genprops error: failure finalizing the data - %s\n", errorCode.errorName()); @@ -164,10 +164,10 @@ main(int argc, char* argv[]) { UBool withCopyright=options[COPYRIGHT].doesOccur; - pnamesWriter->writeCSourceFile(sourceCommon.data(), errorCode); - pnamesWriter->writeBinaryData(sourceDataIn.data(), withCopyright, errorCode); - corePropsWriter->writeCSourceFile(sourceCommon.data(), errorCode); - corePropsWriter->writeBinaryData(sourceDataIn.data(), withCopyright, errorCode); + pnamesBuilder->writeCSourceFile(sourceCommon.data(), errorCode); + pnamesBuilder->writeBinaryData(sourceDataIn.data(), withCopyright, errorCode); + corePropsBuilder->writeCSourceFile(sourceCommon.data(), errorCode); + corePropsBuilder->writeBinaryData(sourceDataIn.data(), withCopyright, errorCode); return errorCode; } diff --git a/tools/unicode/c/genprops/genprops.h b/tools/unicode/c/genprops/genprops.h index e598ed7278..7e27dd9607 100644 --- a/tools/unicode/c/genprops/genprops.h +++ b/tools/unicode/c/genprops/genprops.h @@ -23,24 +23,24 @@ #include "ppucd.h" #include "unewdata.h" -class PropsWriter { +class PropsBuilder { public: - PropsWriter(); - virtual ~PropsWriter(); + PropsBuilder(); + virtual ~PropsBuilder(); virtual void setUnicodeVersion(const UVersionInfo version); virtual void setProps(const icu::UniProps &props, const icu::UnicodeSet &newValues, UErrorCode &errorCode); - virtual void finalizeData(UErrorCode &errorCode); + virtual void build(UErrorCode &errorCode); virtual void writeCSourceFile(const char *path, UErrorCode &errorCode); virtual void writeBinaryData(const char *path, UBool withCopyright, UErrorCode &errorCode); }; -class PNamesWriter : public PropsWriter { +class PNamesBuilder : public PropsBuilder { public: virtual const PropertyNames *getPropertyNames() = 0; }; -PropsWriter *createCorePropsWriter(UErrorCode &errorCode); -PNamesWriter *createPNamesWriter(UErrorCode &errorCode); +PNamesBuilder *createPNamesBuilder(UErrorCode &errorCode); +PropsBuilder *createCorePropsBuilder(UErrorCode &errorCode); /* global flags */ U_CFUNC UBool beVerbose; diff --git a/tools/unicode/c/genprops/pnameswriter.cpp b/tools/unicode/c/genprops/pnamesbuilder.cpp similarity index 97% rename from tools/unicode/c/genprops/pnameswriter.cpp rename to tools/unicode/c/genprops/pnamesbuilder.cpp index 6b0e5d4260..971bb5c984 100644 --- a/tools/unicode/c/genprops/pnameswriter.cpp +++ b/tools/unicode/c/genprops/pnamesbuilder.cpp @@ -6,7 +6,7 @@ * Date Name Description * 10/11/02 aliu Creation. * 2010nov19 Markus Scherer Rewrite for formatVersion 2. -* 2011dec18 Markus Scherer Moved genpname/genpname.cpp to genprops/pnameswriter.cpp. +* 2011dec18 Markus Scherer Moved genpname/genpname.cpp to genprops/pnamesbuilder.cpp. ********************************************************************** */ @@ -176,11 +176,11 @@ int32_t Alias::getUniqueNames(int32_t* stringIndices) const { // END DATA //---------------------------------------------------------------------- -class PNamesWriterImpl; +class PNamesBuilderImpl; class PNamesPropertyNames : public PropertyNames { public: - PNamesPropertyNames(const PNamesWriterImpl &pnwi) + PNamesPropertyNames(const PNamesBuilderImpl &pnwi) : impl(pnwi), valueMaps(NULL), bytesTries(NULL) {} void init(); virtual int32_t getPropertyEnum(const char *name) const; @@ -190,18 +190,18 @@ private: UBool containsName(BytesTrie &trie, const char *name) const; int32_t getPropertyOrValueEnum(int32_t bytesTrieOffset, const char *alias) const; - const PNamesWriterImpl &impl; + const PNamesBuilderImpl &impl; const int32_t *valueMaps; const uint8_t *bytesTries; }; -class PNamesWriterImpl : public PNamesWriter { +class PNamesBuilderImpl : public PNamesBuilder { public: - PNamesWriterImpl(UErrorCode &errorCode) + PNamesBuilderImpl(UErrorCode &errorCode) : valueMaps(errorCode), btb(errorCode), maxNameLength(0), pnames(*this) {} - virtual void finalizeData(UErrorCode &errorCode) { + virtual void build(UErrorCode &errorCode) { // Build main property aliases value map at value map offset 0, // so that we need not store another offset for it. UVector32 propEnums(errorCode); @@ -465,7 +465,7 @@ static const UDataInfo dataInfo = { }; void -PNamesWriterImpl::writeBinaryData(const char *path, UBool withCopyright, UErrorCode &errorCode) { +PNamesBuilderImpl::writeBinaryData(const char *path, UBool withCopyright, UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return; } UNewDataMemory *pdata=udata_create(path, PNAME_DATA_TYPE, PNAME_DATA_NAME, &dataInfo, withCopyright ? U_COPYRIGHT_STRING : 0, &errorCode); @@ -490,10 +490,10 @@ PNamesWriterImpl::writeBinaryData(const char *path, UBool withCopyright, UErrorC } void -PNamesWriterImpl::writeCSourceFile(const char *path, UErrorCode &errorCode) { +PNamesBuilderImpl::writeCSourceFile(const char *path, UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return; } FILE *f=usrc_createFromGenerator(path, "propname_data.h", - "icu/tools/src/unicode/c/genprops/pnameswriter.cpp"); + "icu/tools/src/unicode/c/genprops/pnamesbuilder.cpp"); if(f==NULL) { errorCode=U_FILE_ACCESS_ERROR; return; // usrc_create() reported an error. @@ -524,10 +524,10 @@ PNamesWriterImpl::writeCSourceFile(const char *path, UErrorCode &errorCode) { fclose(f); } -PNamesWriter * -createPNamesWriter(UErrorCode &errorCode) { +PNamesBuilder * +createPNamesBuilder(UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return NULL; } - PNamesWriter *pw=new PNamesWriterImpl(errorCode); + PNamesBuilder *pw=new PNamesBuilderImpl(errorCode); if(pw==NULL) { errorCode=U_MEMORY_ALLOCATION_ERROR; }