]> granicus.if.org Git - icu/commitdiff
ICU-11003 Delete cmutex.h; change files using it to from plain C to C++.
authorAndy Heninger <andy.heninger@gmail.com>
Thu, 17 Jul 2014 20:16:27 +0000 (20:16 +0000)
committerAndy Heninger <andy.heninger@gmail.com>
Thu, 17 Jul 2014 20:16:27 +0000 (20:16 +0000)
X-SVN-Rev: 36050

icu4c/source/common/cmutex.h [deleted file]
icu4c/source/common/common.vcxproj
icu4c/source/common/common.vcxproj.filters
icu4c/source/common/ucnvmbcs.cpp [moved from icu4c/source/common/ucnvmbcs.c with 99% similarity]
icu4c/source/common/ustr_cnv.cpp [moved from icu4c/source/common/ustr_cnv.c with 98% similarity]

diff --git a/icu4c/source/common/cmutex.h b/icu4c/source/common/cmutex.h
deleted file mode 100644 (file)
index a3814dd..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-**********************************************************************
-*   Copyright (C) 2013, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-**********************************************************************
-*
-* File cmutex.h
-*
-*     Minimal plain C declarations for ICU mutex functions.
-*     This header provides a transition path for plain C files that 
-*     formerly included mutex.h, which is now a C++ only header.
-*
-*     This header should not be used for new code.
-*
-*     C++ files should include umutex.h, not this header.
-*
-*/
-
-#ifndef __CMUTEX_H__
-#define __CMUTEX_H__
-
-typedef struct UMutex UMutex;
-
-
-/* Lock a mutex.
- * @param mutex The given mutex to be locked.  Pass NULL to specify
- *              the global ICU mutex.  Recursive locks are an error
- *              and may cause a deadlock on some platforms.
- */
-U_INTERNAL void U_EXPORT2 umtx_lock(UMutex* mutex); 
-
-/* Unlock a mutex.
- * @param mutex The given mutex to be unlocked.  Pass NULL to specify
- *              the global ICU mutex.
- */
-U_INTERNAL void U_EXPORT2 umtx_unlock (UMutex* mutex);
-
-#endif
-
index 3d12b5a1c077ded93110666e1e770a86e52b0fe5..9a1a5d10b7e6e090671b16a6ab84e379df40500a 100644 (file)
     <ClCompile Include="ucnvhz.c" />\r
     <ClCompile Include="ucnvisci.c" />\r
     <ClCompile Include="ucnvlat1.c" />\r
-    <ClCompile Include="ucnvmbcs.c" />\r
+    <ClCompile Include="ucnvmbcs.cpp" />\r
     <ClCompile Include="ucnvscsu.c" />\r
     <ClCompile Include="ucnvsel.cpp">\r
     </ClCompile>\r
     <ClCompile Include="unistr_cnv.cpp" />\r
     <ClCompile Include="unistr_props.cpp" />\r
     <ClCompile Include="unistr_titlecase_brkiter.cpp" />\r
-    <ClCompile Include="ustr_cnv.c" />\r
+    <ClCompile Include="ustr_cnv.cpp" />\r
     <ClCompile Include="ustr_titlecase_brkiter.cpp" />\r
     <ClCompile Include="ustr_wcs.cpp" />\r
     <ClCompile Include="ustrcase.cpp" />\r
index de082990c38d740d0e574a4370977664a9e5506a..5082ac19ea56fc216a700d03192bd3749b1078ba 100644 (file)
     <ClCompile Include="ucnvlat1.c">\r
       <Filter>conversion</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="ucnvmbcs.c">\r
+    <ClCompile Include="ucnvmbcs.cpp">\r
       <Filter>conversion</Filter>\r
     </ClCompile>\r
     <ClCompile Include="ucnvscsu.c">\r
     <ClCompile Include="unistr_titlecase_brkiter.cpp">\r
       <Filter>strings</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="ustr_cnv.c">\r
+    <ClCompile Include="ustr_cnv.cpp">\r
       <Filter>strings</Filter>\r
     </ClCompile>\r
     <ClCompile Include="ustr_titlecase_brkiter.cpp">\r
similarity index 99%
rename from icu4c/source/common/ucnvmbcs.c
rename to icu4c/source/common/ucnvmbcs.cpp
index 143daf69af7a1ae9557408edc556eae83fee3462..da143d79a01dfbaffd1f10cb20de6d6b3d0288f6 100644 (file)
@@ -1,11 +1,11 @@
 /*
 ******************************************************************************
 *
-*   Copyright (C) 2000-2013, International Business Machines
+*   Copyright (C) 2000-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ******************************************************************************
-*   file name:  ucnvmbcs.c
+*   file name:  ucnvmbcs.cpp
 *   encoding:   US-ASCII
 *   tab size:   8 (not used)
 *   indentation:4
@@ -56,7 +56,9 @@
 #include "ucnv_cnv.h"
 #include "cmemory.h"
 #include "cstring.h"
-#include "cmutex.h"
+#include "umutex.h"
+
+#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
 
 /* control optimizations according to the platform */
 #define MBCS_UNROLL_SINGLE_TO_BMP 1
  * adding new ones without crashing an unaware converter
  */
 
-static const UConverterImpl _SBCSUTF8Impl;
-static const UConverterImpl _DBCSUTF8Impl;
+/**
+ * Callback from ucnv_MBCSEnumToUnicode(), takes 32 mappings from
+ * consecutive sequences of bytes, starting from the one encoded in value,
+ * to Unicode code points. (Multiple mappings to reduce per-function call overhead.)
+ * Does not currently support m:n mappings or reverse fallbacks.
+ * This function will not be called for sequences of bytes with leading zeros.
+ *
+ * @param context an opaque pointer, as passed into ucnv_MBCSEnumToUnicode()
+ * @param value contains 1..4 bytes of the first byte sequence, right-aligned
+ * @param codePoints resulting Unicode code points, or negative if a byte sequence does
+ *        not map to anything
+ * @return TRUE to continue enumeration, FALSE to stop
+ */
+typedef UBool U_CALLCONV
+UConverterEnumToUCallback(const void *context, uint32_t value, UChar32 codePoints[32]);
+
+static void
+ucnv_MBCSLoad(UConverterSharedData *sharedData,
+          UConverterLoadArgs *pArgs,
+          const uint8_t *raw,
+          UErrorCode *pErrorCode);
+
+static void
+ucnv_MBCSUnload(UConverterSharedData *sharedData);
+
+static void
+ucnv_MBCSOpen(UConverter *cnv,
+              UConverterLoadArgs *pArgs,
+              UErrorCode *pErrorCode);
+
+static UChar32
+ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs,
+                  UErrorCode *pErrorCode);
+
+static void
+ucnv_MBCSGetStarters(const UConverter* cnv,
+                 UBool starters[256],
+                 UErrorCode *pErrorCode);
+
+static const char *
+ucnv_MBCSGetName(const UConverter *cnv);
+
+static void
+ucnv_MBCSWriteSub(UConverterFromUnicodeArgs *pArgs,
+              int32_t offsetIndex,
+              UErrorCode *pErrorCode);
+
+static UChar32
+ucnv_MBCSGetNextUChar(UConverterToUnicodeArgs *pArgs,
+                  UErrorCode *pErrorCode);
+
+static void
+ucnv_SBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
+                  UConverterToUnicodeArgs *pToUArgs,
+                  UErrorCode *pErrorCode);
+
+static void
+ucnv_MBCSGetUnicodeSet(const UConverter *cnv,
+                   const USetAdder *sa,
+                   UConverterUnicodeSet which,
+                   UErrorCode *pErrorCode);
+
+static void
+ucnv_DBCSFromUTF8(UConverterFromUnicodeArgs *pFromUArgs,
+                  UConverterToUnicodeArgs *pToUArgs,
+                  UErrorCode *pErrorCode);
+
+static const UConverterImpl _SBCSUTF8Impl={
+    UCNV_MBCS,
+
+    ucnv_MBCSLoad,
+    ucnv_MBCSUnload,
+
+    ucnv_MBCSOpen,
+    NULL,
+    NULL,
+
+    ucnv_MBCSToUnicodeWithOffsets,
+    ucnv_MBCSToUnicodeWithOffsets,
+    ucnv_MBCSFromUnicodeWithOffsets,
+    ucnv_MBCSFromUnicodeWithOffsets,
+    ucnv_MBCSGetNextUChar,
+
+    ucnv_MBCSGetStarters,
+    ucnv_MBCSGetName,
+    ucnv_MBCSWriteSub,
+    NULL,
+    ucnv_MBCSGetUnicodeSet,
+
+    NULL,
+    ucnv_SBCSFromUTF8
+};
+
+static const UConverterImpl _DBCSUTF8Impl={
+    UCNV_MBCS,
+
+    ucnv_MBCSLoad,
+    ucnv_MBCSUnload,
+
+    ucnv_MBCSOpen,
+    NULL,
+    NULL,
+
+    ucnv_MBCSToUnicodeWithOffsets,
+    ucnv_MBCSToUnicodeWithOffsets,
+    ucnv_MBCSFromUnicodeWithOffsets,
+    ucnv_MBCSFromUnicodeWithOffsets,
+    ucnv_MBCSGetNextUChar,
+
+    ucnv_MBCSGetStarters,
+    ucnv_MBCSGetName,
+    ucnv_MBCSWriteSub,
+    NULL,
+    ucnv_MBCSGetUnicodeSet,
+
+    NULL,
+    ucnv_DBCSFromUTF8
+};
+
+static const UConverterImpl _MBCSImpl={
+    UCNV_MBCS,
+
+    ucnv_MBCSLoad,
+    ucnv_MBCSUnload,
+
+    ucnv_MBCSOpen,
+    NULL,
+    NULL,
+
+    ucnv_MBCSToUnicodeWithOffsets,
+    ucnv_MBCSToUnicodeWithOffsets,
+    ucnv_MBCSFromUnicodeWithOffsets,
+    ucnv_MBCSFromUnicodeWithOffsets,
+    ucnv_MBCSGetNextUChar,
+
+    ucnv_MBCSGetStarters,
+    ucnv_MBCSGetName,
+    ucnv_MBCSWriteSub,
+    NULL,
+    ucnv_MBCSGetUnicodeSet,
+    NULL,
+    NULL
+};
+
+
+/* Static data is in tools/makeconv/ucnvstat.c for data-based
+ * converters. Be sure to update it as well.
+ */
+
+const UConverterSharedData _MBCSData={
+    sizeof(UConverterSharedData), 1,
+    NULL, NULL, NULL, FALSE, &_MBCSImpl, 
+    0, {}
+};
+
 
 /* GB 18030 data ------------------------------------------------------------ */
 
@@ -473,22 +628,6 @@ static int32_t getSISOBytes(SISO_Option option, uint32_t cnvOption, uint8_t *val
 
 /* Miscellaneous ------------------------------------------------------------ */
 
-/**
- * Callback from ucnv_MBCSEnumToUnicode(), takes 32 mappings from
- * consecutive sequences of bytes, starting from the one encoded in value,
- * to Unicode code points. (Multiple mappings to reduce per-function call overhead.)
- * Does not currently support m:n mappings or reverse fallbacks.
- * This function will not be called for sequences of bytes with leading zeros.
- *
- * @param context an opaque pointer, as passed into ucnv_MBCSEnumToUnicode()
- * @param value contains 1..4 bytes of the first byte sequence, right-aligned
- * @param codePoints resulting Unicode code points, or negative if a byte sequence does
- *        not map to anything
- * @return TRUE to continue enumeration, FALSE to stop
- */
-typedef UBool U_CALLCONV
-UConverterEnumToUCallback(const void *context, uint32_t value, UChar32 codePoints[32]);
-
 /* similar to ucnv_MBCSGetNextUChar() but recursive */
 static UBool
 enumToU(UConverterMBCSTable *mbcsTable, int8_t stateProps[],
@@ -987,7 +1126,7 @@ _extFromU(UConverter *cnv, const UConverterSharedData *sharedData,
         int32_t i;
 
         range=gb18030Ranges[0];
-        for(i=0; i<sizeof(gb18030Ranges)/sizeof(gb18030Ranges[0]); range+=4, ++i) {
+        for(i=0; i<LENGTHOF(gb18030Ranges); range+=4, ++i) {
             if(range[0]<=(uint32_t)cp && (uint32_t)cp<=range[1]) {
                 /* found the Unicode code point, output the four-byte sequence for it */
                 uint32_t linear;
@@ -1054,7 +1193,7 @@ _extToU(UConverter *cnv, const UConverterSharedData *sharedData,
 
         linear=LINEAR_18030(cnv->toUBytes[0], cnv->toUBytes[1], cnv->toUBytes[2], cnv->toUBytes[3]);
         range=gb18030Ranges[0];
-        for(i=0; i<sizeof(gb18030Ranges)/sizeof(gb18030Ranges[0]); range+=4, ++i) {
+        for(i=0; i<LENGTHOF(gb18030Ranges); range+=4, ++i) {
             if(range[2]<=linear && linear<=range[3]) {
                 /* found the sequence, output the Unicode code point for it */
                 *pErrorCode=U_ZERO_ERROR;
@@ -1443,7 +1582,7 @@ ucnv_MBCSLoad(UConverterSharedData *sharedData,
     }
 
     if(mbcsTable->outputType==MBCS_OUTPUT_EXT_ONLY) {
-        UConverterLoadArgs args={ 0 };
+        UConverterLoadArgs args={};
         UConverterSharedData *baseSharedData;
         const int32_t *extIndexes;
         const char *baseName;
@@ -5479,7 +5618,7 @@ unassigned:
 static void
 ucnv_MBCSGetStarters(const UConverter* cnv,
                  UBool starters[256],
-                 UErrorCode *pErrorCode) {
+                 UErrorCode *) {
     const int32_t *state0;
     int i;
 
@@ -5572,90 +5711,4 @@ ucnv_MBCSGetType(const UConverter* converter) {
     return (UConverterType)UCNV_MBCS;
 }
 
-static const UConverterImpl _SBCSUTF8Impl={
-    UCNV_MBCS,
-
-    ucnv_MBCSLoad,
-    ucnv_MBCSUnload,
-
-    ucnv_MBCSOpen,
-    NULL,
-    NULL,
-
-    ucnv_MBCSToUnicodeWithOffsets,
-    ucnv_MBCSToUnicodeWithOffsets,
-    ucnv_MBCSFromUnicodeWithOffsets,
-    ucnv_MBCSFromUnicodeWithOffsets,
-    ucnv_MBCSGetNextUChar,
-
-    ucnv_MBCSGetStarters,
-    ucnv_MBCSGetName,
-    ucnv_MBCSWriteSub,
-    NULL,
-    ucnv_MBCSGetUnicodeSet,
-
-    NULL,
-    ucnv_SBCSFromUTF8
-};
-
-static const UConverterImpl _DBCSUTF8Impl={
-    UCNV_MBCS,
-
-    ucnv_MBCSLoad,
-    ucnv_MBCSUnload,
-
-    ucnv_MBCSOpen,
-    NULL,
-    NULL,
-
-    ucnv_MBCSToUnicodeWithOffsets,
-    ucnv_MBCSToUnicodeWithOffsets,
-    ucnv_MBCSFromUnicodeWithOffsets,
-    ucnv_MBCSFromUnicodeWithOffsets,
-    ucnv_MBCSGetNextUChar,
-
-    ucnv_MBCSGetStarters,
-    ucnv_MBCSGetName,
-    ucnv_MBCSWriteSub,
-    NULL,
-    ucnv_MBCSGetUnicodeSet,
-
-    NULL,
-    ucnv_DBCSFromUTF8
-};
-
-static const UConverterImpl _MBCSImpl={
-    UCNV_MBCS,
-
-    ucnv_MBCSLoad,
-    ucnv_MBCSUnload,
-
-    ucnv_MBCSOpen,
-    NULL,
-    NULL,
-
-    ucnv_MBCSToUnicodeWithOffsets,
-    ucnv_MBCSToUnicodeWithOffsets,
-    ucnv_MBCSFromUnicodeWithOffsets,
-    ucnv_MBCSFromUnicodeWithOffsets,
-    ucnv_MBCSGetNextUChar,
-
-    ucnv_MBCSGetStarters,
-    ucnv_MBCSGetName,
-    ucnv_MBCSWriteSub,
-    NULL,
-    ucnv_MBCSGetUnicodeSet
-};
-
-
-/* Static data is in tools/makeconv/ucnvstat.c for data-based
- * converters. Be sure to update it as well.
- */
-
-const UConverterSharedData _MBCSData={
-    sizeof(UConverterSharedData), 1,
-    NULL, NULL, NULL, FALSE, &_MBCSImpl, 
-    0
-};
-
 #endif /* #if !UCONFIG_NO_LEGACY_CONVERSION */
similarity index 98%
rename from icu4c/source/common/ustr_cnv.c
rename to icu4c/source/common/ustr_cnv.cpp
index f46d937daed753e34a5da954c38b518fea5d798b..b33c6a5ea351b2db8cd25f295377d706de2218a7 100644 (file)
@@ -1,11 +1,11 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 1998-2013, International Business Machines
+*   Copyright (C) 1998-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
-*   file name:  ustr_cnv.c
+*   file name:  ustr_cnv.cpp
 *   encoding:   US-ASCII
 *   tab size:   8 (not used)
 *   indentation:4
@@ -24,7 +24,7 @@
 #include "unicode/ucnv.h"
 #include "cstring.h"
 #include "cmemory.h"
-#include "cmutex.h"
+#include "umutex.h"
 #include "ustr_cnv.h"
 
 /* mutexed access to a shared default converter ----------------------------- */