diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 106 | ||||
-rw-r--r-- | cpp/test/Ice/operations/Test.ice | 22 | ||||
-rw-r--r-- | cpp/test/Ice/operations/TestAMD.ice | 26 | ||||
-rw-r--r-- | cpp/test/Ice/operations/TestI.cpp | 1 | ||||
-rw-r--r-- | cpp/test/Ice/operations/Twoways.cpp | 12 |
5 files changed, 124 insertions, 43 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 5df28c48df2..05de885e742 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -35,15 +35,50 @@ string u32CodePoint(unsigned int value) { ostringstream s; - s << "\\U"; - s << hex; - s.width(8); - s.fill('0'); - s << value; + // + // COMPILERFIX: + // With VC++ < 140 characters in the range of 0 to 0x9f cannot be represented + // with a universal character name (UCN). + // + if(value <= 0x9f) + { + switch(value) + { + case 0x22: + { + s << "\\\""; + break; + } + case 0x5c: + { + s << "\\\\"; + break; + } + default: + { + s << "\\"; + s << oct; + s.width(3); + s.fill('0'); + s << value; + break; + } + } + } + // + // UCN valid characters + // + else + { + s << "\\U"; + s << hex; + s.width(8); + s.fill('0'); + s << value; + } return s.str(); } - void writeU8Buffer(const vector<unsigned char>& u8buffer, ::IceUtilInternal::Output& out) { @@ -117,7 +152,6 @@ writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const Synt // Wide strings // vector<unsigned char> u8buffer; // Buffer to convert multibyte characters - out << "L\""; for(size_t i = 0; i < value.size();) { @@ -125,10 +159,7 @@ writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const Synt { if(static_cast<unsigned char>(value[i]) < 128) // Single byte character { - // - // Print as unicode if not in basic source character set - // - out << u32CodePoint(static_cast<unsigned int>(value[i])); + out << u32CodePoint(static_cast<unsigned char>(value[i])); } else { @@ -145,22 +176,65 @@ writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const Synt writeU8Buffer(u8buffer, out); u8buffer.clear(); } - + switch(value[i]) { + case '\\': + { + string s = "\\"; + size_t j = i + 1; + for(; j < value.size(); ++j) + { + if(value[j] != '\\') + { + break; + } + s += "\\"; + } + + // + // An even number of slash \ will escape the backslash and + // the codepoint will be interpreted as its charaters + // + // \\U00000041 - ['\\', 'U', '0', '0', '0', '0', '0', '0', '4', '1'] + // \\\U00000041 - ['\\', 'A'] (41 is the codepoint for 'A') + // + if(s.size() % 2 != 0 && (value[j] == 'U' || value[j] == 'u')) + { + // + // Convert codepoint to UTF8 bytes and write the escaped bytes + // + out << s.substr(0, s.size() - 1); + + size_t sz = value[j] == 'U' ? 8 : 4; + string codepoint = value.substr(j + 1, sz); + assert(codepoint.size() == sz); + + IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16); + out << u32CodePoint(static_cast<unsigned int>(v)); + + i = j + 1 + sz; + } + else + { + out << s; + i = j; + } + continue; + } case '"': { out << "\\"; break; } } - + out << value[i]; // Print normally if in basic source character set } i++; - + } - + // // Write any pedding characters in the utf8 buffer // @@ -273,7 +347,7 @@ writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const Synt break; } } - + out << value[i]; // Print normally if in basic source character set } ++i; diff --git a/cpp/test/Ice/operations/Test.ice b/cpp/test/Ice/operations/Test.ice index d7698951ca8..735bcb3b6a8 100644 --- a/cpp/test/Ice/operations/Test.ice +++ b/cpp/test/Ice/operations/Test.ice @@ -252,7 +252,7 @@ class MyClass ByteBoolD opByteBoolD1(ByteBoolD opByteBoolD1); StringS opStringS2(StringS stringS); ByteBoolD opByteBoolD2(ByteBoolD byteBoolD); - + StringS opStringLiterals(); WStringS opWStringLiterals(); }; @@ -329,6 +329,8 @@ const string ss4 = "\\\u0041\\"; /* \A\ */ const string ss5 = "\\u0041\\"; /* \u0041\ */ // +// Ĩ - Unicode Character 'LATIN CAPITAL LETTER I WITH TILDE' (U+0128) +// Ÿ - Unicode Character 'LATIN CAPITAL LETTER Y WITH DIAERESIS' (U+0178) // ÿ - Unicode Character 'LATIN SMALL LETTER Y WITH DIAERESIS' (U+00FF) // Ā - Unicode Character 'LATIN CAPITAL LETTER A WITH MACRON' (U+0100) // ἀ - Unicode Character 'GREEK SMALL LETTER ALPHA WITH PSILI' (U+1F00) @@ -339,9 +341,10 @@ const string ss5 = "\\u0041\\"; /* \u0041\ */ // 🍁 - Unicode Character 'MAPLE LEAF' (U+1F341) // 🍂 - Unicode Character 'FALLEN LEAF' (U+1F342) // 🍃 - Unicode Character 'LEAF FLUTTERING IN WIND' (U+1F343) -const string su0 = "ÿĀἀ𐆔𐅪𐆘🍀🍁🍂🍃"; -const string su1 = "\u00FF\u0100\u1F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; -const string su2 = "\U000000FF\U00000100\U00001F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; +// +const string su0 = "ĨŸÿĀἀ𐆔𐅪𐆘🍀🍁🍂🍃"; +const string su1 = "\u0128\u0178\u00FF\u0100\u1F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; +const string su2 = "\U00000128\U00000178\U000000FF\U00000100\U00001F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; // // Wide string literals @@ -384,7 +387,6 @@ const ["cpp:type:wstring"]string wsw10 = "\U00000DA7"; // Si \t horizontal tab byte 0x09 in ASCII encoding \v vertical tab byte 0x0b in ASCII encoding **/ - const ["cpp:type:wstring"]string wss0 = "\'\"\?\\\a\b\f\n\r\t\v"; const ["cpp:type:wstring"]string wss1 = "\u0027\u0022\u003f\u005c\u0007\u0008\u000c\u000a\u000d\u0009\u000b"; const ["cpp:type:wstring"]string wss2 = "\U00000027\U00000022\U0000003f\U0000005c\U00000007\U00000008\U0000000c\U0000000a\U0000000d\U00000009\U0000000b"; @@ -394,6 +396,8 @@ const ["cpp:type:wstring"]string wss4 = "\\\u0041\\"; /* \A\ */ const ["cpp:type:wstring"]string wss5 = "\\u0041\\"; /* \u0041\ */ // +// Ĩ - Unicode Character 'LATIN CAPITAL LETTER I WITH TILDE' (U+0128) +// Ÿ - Unicode Character 'LATIN CAPITAL LETTER Y WITH DIAERESIS' (U+0178) // ÿ - Unicode Character 'LATIN SMALL LETTER Y WITH DIAERESIS' (U+00FF) // Ā - Unicode Character 'LATIN CAPITAL LETTER A WITH MACRON' (U+0100) // ἀ - Unicode Character 'GREEK SMALL LETTER ALPHA WITH PSILI' (U+1F00) @@ -404,9 +408,9 @@ const ["cpp:type:wstring"]string wss5 = "\\u0041\\"; /* \u0041\ */ // 🍁 - Unicode Character 'MAPLE LEAF' (U+1F341) // 🍂 - Unicode Character 'FALLEN LEAF' (U+1F342) // 🍃 - Unicode Character 'LEAF FLUTTERING IN WIND' (U+1F343) -const ["cpp:type:wstring"]string wsu0 = "ÿĀἀ𐆔𐅪𐆘🍀🍁🍂🍃"; -const ["cpp:type:wstring"]string wsu1 = "\u00FF\u0100\u1F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; -const ["cpp:type:wstring"]string wsu2 = "\U000000FF\U00000100\U00001F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; +// +const ["cpp:type:wstring"]string wsu0 = "ĨŸÿĀἀ𐆔𐅪𐆘🍀🍁🍂🍃"; +const ["cpp:type:wstring"]string wsu1 = "\u0128\u0178\u00FF\u0100\u1F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; +const ["cpp:type:wstring"]string wsu2 = "\U00000128\U00000178\U000000FF\U00000100\U00001F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; }; - diff --git a/cpp/test/Ice/operations/TestAMD.ice b/cpp/test/Ice/operations/TestAMD.ice index ee26d1c1970..e4b31f53b4d 100644 --- a/cpp/test/Ice/operations/TestAMD.ice +++ b/cpp/test/Ice/operations/TestAMD.ice @@ -250,12 +250,12 @@ dictionary<MyEnum, MyEnumS> MyEnumMyEnumSD; string opString1(string opString1); StringS opStringS1(StringS opStringS1); ByteBoolD opByteBoolD1(ByteBoolD opByteBoolD1); - + StringS opStringS2(StringS stringS); ByteBoolD opByteBoolD2(ByteBoolD byteBoolD); - + StringS opStringLiterals(); - + WStringS opWStringLiterals(); }; @@ -333,6 +333,8 @@ const string ss4 = "\\\u0041\\"; /* \A\ */ const string ss5 = "\\u0041\\"; /* \u0041\ */ // +// Ĩ - Unicode Character 'LATIN CAPITAL LETTER I WITH TILDE' (U+0128) +// Ÿ - Unicode Character 'LATIN CAPITAL LETTER Y WITH DIAERESIS' (U+0178) // ÿ - Unicode Character 'LATIN SMALL LETTER Y WITH DIAERESIS' (U+00FF) // Ā - Unicode Character 'LATIN CAPITAL LETTER A WITH MACRON' (U+0100) // ἀ - Unicode Character 'GREEK SMALL LETTER ALPHA WITH PSILI' (U+1F00) @@ -343,9 +345,10 @@ const string ss5 = "\\u0041\\"; /* \u0041\ */ // 🍁 - Unicode Character 'MAPLE LEAF' (U+1F341) // 🍂 - Unicode Character 'FALLEN LEAF' (U+1F342) // 🍃 - Unicode Character 'LEAF FLUTTERING IN WIND' (U+1F343) -const string su0 = "ÿĀἀ𐆔𐅪𐆘🍀🍁🍂🍃"; -const string su1 = "\u00FF\u0100\u1F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; -const string su2 = "\U000000FF\U00000100\U00001F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; +// +const string su0 = "ĨŸÿĀἀ𐆔𐅪𐆘🍀🍁🍂🍃"; +const string su1 = "\u0128\u0178\u00FF\u0100\u1F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; +const string su2 = "\U00000128\U00000178\U000000FF\U00000100\U00001F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; // // Wide string literals @@ -398,6 +401,8 @@ const ["cpp:type:wstring"]string wss4 = "\\\u0041\\"; /* \A\ */ const ["cpp:type:wstring"]string wss5 = "\\u0041\\"; /* \u0041\ */ // +// Ĩ - Unicode Character 'LATIN CAPITAL LETTER I WITH TILDE' (U+0128) +// Ÿ - Unicode Character 'LATIN CAPITAL LETTER Y WITH DIAERESIS' (U+0178) // ÿ - Unicode Character 'LATIN SMALL LETTER Y WITH DIAERESIS' (U+00FF) // Ā - Unicode Character 'LATIN CAPITAL LETTER A WITH MACRON' (U+0100) // ἀ - Unicode Character 'GREEK SMALL LETTER ALPHA WITH PSILI' (U+1F00) @@ -408,10 +413,9 @@ const ["cpp:type:wstring"]string wss5 = "\\u0041\\"; /* \u0041\ */ // 🍁 - Unicode Character 'MAPLE LEAF' (U+1F341) // 🍂 - Unicode Character 'FALLEN LEAF' (U+1F342) // 🍃 - Unicode Character 'LEAF FLUTTERING IN WIND' (U+1F343) -const ["cpp:type:wstring"]string wsu0 = "ÿĀἀ𐆔𐅪𐆘🍀🍁🍂🍃"; -const ["cpp:type:wstring"]string wsu1 = "\u00FF\u0100\u1F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; -const ["cpp:type:wstring"]string wsu2 = "\U000000FF\U00000100\U00001F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; - +// +const ["cpp:type:wstring"]string wsu0 = "ĨŸÿĀἀ𐆔𐅪𐆘🍀🍁🍂🍃"; +const ["cpp:type:wstring"]string wsu1 = "\u0128\u0178\u00FF\u0100\u1F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; +const ["cpp:type:wstring"]string wsu2 = "\U00000128\U00000178\U000000FF\U00000100\U00001F00\U00010194\U0001016A\U00010198\U0001F340\U0001F341\U0001F342\U0001F343"; }; - diff --git a/cpp/test/Ice/operations/TestI.cpp b/cpp/test/Ice/operations/TestI.cpp index 84054ac8d45..1b5eae888cf 100644 --- a/cpp/test/Ice/operations/TestI.cpp +++ b/cpp/test/Ice/operations/TestI.cpp @@ -824,4 +824,3 @@ MyDerivedClassI::opWStringLiterals(const Ice::Current&) return data; } - diff --git a/cpp/test/Ice/operations/Twoways.cpp b/cpp/test/Ice/operations/Twoways.cpp index 379d808c520..6bcc714cba8 100644 --- a/cpp/test/Ice/operations/Twoways.cpp +++ b/cpp/test/Ice/operations/Twoways.cpp @@ -135,12 +135,12 @@ twoways(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p) test(Test::ss5 == "\\u0041\\" && Test::ss5 == literals[27]); - test(Test::su0 == Test::su1 && - Test::su0 == Test::su2 && - Test::su0 == literals[28] && - Test::su0 == literals[29] && - Test::su0 == literals[30]); - + test(Test::su0 == Test::su1); + test(Test::su0 == Test::su2); + test(Test::su0 == literals[28]); + test(Test::su0 == literals[29]); + test(Test::su0 == literals[30]); + // // Same but using wide strings // |