summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2016-03-10 09:33:14 +0100
committerJose <jose@zeroc.com>2016-03-10 09:33:14 +0100
commit709f8a26f7ac03bed5a4d1a0b9de6c4e9d14f806 (patch)
tree0665aa227fce4c4c369619fb2ea1d9f718979655 /cpp
parentWindows PHP build fixes (diff)
downloadice-709f8a26f7ac03bed5a4d1a0b9de6c4e9d14f806.tar.bz2
ice-709f8a26f7ac03bed5a4d1a0b9de6c4e9d14f806.tar.xz
ice-709f8a26f7ac03bed5a4d1a0b9de6c4e9d14f806.zip
String literals fixes
- Fixed escape sequences in C++ wide strings - Fixed objetive-c escape sequences - Update ruby to use magic comments to set the file encoding
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/IceUtil/Unicode.cpp18
-rw-r--r--cpp/src/IceUtil/Unicode.h4
-rw-r--r--cpp/src/Slice/Ruby.cpp5
-rw-r--r--cpp/src/Slice/RubyUtil.cpp2
-rw-r--r--cpp/src/slice2cpp/Gen.cpp255
-rw-r--r--cpp/src/slice2objc/Gen.cpp100
-rw-r--r--cpp/test/Ice/operations/Test.ice67
-rw-r--r--cpp/test/Ice/operations/TestAMD.ice68
-rw-r--r--cpp/test/Ice/operations/TestAMDI.cpp45
-rw-r--r--cpp/test/Ice/operations/TestAMDI.h3
-rw-r--r--cpp/test/Ice/operations/TestI.cpp43
-rw-r--r--cpp/test/Ice/operations/TestI.h2
-rw-r--r--cpp/test/Ice/operations/Twoways.cpp92
13 files changed, 609 insertions, 95 deletions
diff --git a/cpp/src/IceUtil/Unicode.cpp b/cpp/src/IceUtil/Unicode.cpp
index 7bad1d67c17..ca36a912b47 100644
--- a/cpp/src/IceUtil/Unicode.cpp
+++ b/cpp/src/IceUtil/Unicode.cpp
@@ -147,6 +147,24 @@ IceUtilInternal::convertUTF8ToUTF16(const vector<unsigned char>& source, vector<
}
ConversionResult
+IceUtilInternal::convertUTF8ToUTF32(const vector<unsigned char>& source, vector<unsigned int>& target, ConversionFlags flags)
+{
+ target.resize(source.size());
+ const unsigned char* sourceStart = &source[0];
+ const unsigned char* sourceEnd = &source[0] + source.size();
+
+ unsigned int* targetStart = &target[0];
+ unsigned int* targetEnd = &target[0] + target.size();
+ ConversionResult result = ConvertUTF8toUTF32(&sourceStart, sourceEnd, &targetStart, targetEnd, flags);
+
+ if(result == conversionOK)
+ {
+ target.resize(targetStart - &target[0]);
+ }
+ return result;
+}
+
+ConversionResult
IceUtilInternal::convertUTF32ToUTF8(const vector<unsigned int>& source, vector<unsigned char>& target, ConversionFlags flags)
{
target.resize(source.size() * 4);
diff --git a/cpp/src/IceUtil/Unicode.h b/cpp/src/IceUtil/Unicode.h
index 2c96d6c6448..d5c3b235ddb 100644
--- a/cpp/src/IceUtil/Unicode.h
+++ b/cpp/src/IceUtil/Unicode.h
@@ -50,6 +50,10 @@ convertUTF8ToUTF16(const std::vector<unsigned char>&, std::vector<unsigned short
IceUtil::ConversionFlags);
ICE_UTIL_API ConversionResult
+convertUTF8ToUTF32(const std::vector<unsigned char>&, std::vector<unsigned int>&,
+ IceUtil::ConversionFlags);
+
+ICE_UTIL_API ConversionResult
convertUTF32ToUTF8(const std::vector<unsigned int>&, std::vector<unsigned char>&,
IceUtil::ConversionFlags);
diff --git a/cpp/src/Slice/Ruby.cpp b/cpp/src/Slice/Ruby.cpp
index 62daa345cbf..209711a679d 100644
--- a/cpp/src/Slice/Ruby.cpp
+++ b/cpp/src/Slice/Ruby.cpp
@@ -301,7 +301,10 @@ Slice::Ruby::compile(int argc, char* argv[])
throw FileException(__FILE__, __LINE__, os.str());
}
FileTracker::instance()->addFile(file);
-
+ //
+ // Ruby magic comment to set the file encoding, it must be first or second line
+ //
+ out << "# encoding: utf-8\n";
printHeader(out);
printGeneratedHeader(out, base + ".ice", "#");
diff --git a/cpp/src/Slice/RubyUtil.cpp b/cpp/src/Slice/RubyUtil.cpp
index 38bbeb5da19..3639a53b185 100644
--- a/cpp/src/Slice/RubyUtil.cpp
+++ b/cpp/src/Slice/RubyUtil.cpp
@@ -1601,7 +1601,7 @@ Slice::Ruby::CodeVisitor::writeConstantValue(const TypePtr& type, const SyntaxTr
++i;
}
- _out << "\".force_encoding(\"utf-8\")"; // Closing "
+ _out << "\""; // Closing "
break;
}
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index d93c457bf9e..5df28c48df2 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -32,6 +32,45 @@ namespace
{
string
+u32CodePoint(unsigned int value)
+{
+ ostringstream s;
+ 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)
+{
+ vector<unsigned int> u32buffer;
+ IceUtilInternal::ConversionResult result = convertUTF8ToUTF32(u8buffer, u32buffer, IceUtil::lenientConversion);
+ switch(result)
+ {
+ case conversionOK:
+ break;
+ case sourceExhausted:
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source exhausted");
+ case sourceIllegal:
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source illegal");
+ default:
+ {
+ assert(0);
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
+ }
+ }
+
+ for(vector<unsigned int>::const_iterator c = u32buffer.begin(); c != u32buffer.end(); ++c)
+ {
+ out << u32CodePoint(*c);
+ }
+}
+
+string
getDeprecateSymbol(const ContainedPtr& p1, const ContainedPtr& p2)
{
string deprecateMetadata, deprecateSymbol;
@@ -74,115 +113,173 @@ writeConstantValue(IceUtilInternal::Output& out, const TypePtr& type, const Synt
if((useWstring & TypeContextUseWstring) || findMetaData(metaData) == "wstring")
{
- out << 'L';
- }
- out << "\""; // Opening "
+ //
+ // Wide strings
+ //
+ vector<unsigned char> u8buffer; // Buffer to convert multibyte characters
- for(size_t i = 0; i < value.size();)
- {
- if(charSet.find(value[i]) == charSet.end())
+ out << "L\"";
+ for(size_t i = 0; i < value.size();)
+ {
+ if(charSet.find(value[i]) == charSet.end())
+ {
+ 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]));
+ }
+ else
+ {
+ u8buffer.push_back(value[i]);
+ }
+ }
+ else
+ {
+ //
+ // Write any pedding characters in the utf8 buffer
+ //
+ if(!u8buffer.empty())
+ {
+ writeU8Buffer(u8buffer, out);
+ u8buffer.clear();
+ }
+
+ switch(value[i])
+ {
+ case '"':
+ {
+ out << "\\";
+ break;
+ }
+ }
+
+ out << value[i]; // Print normally if in basic source character set
+ }
+ i++;
+
+ }
+
+ //
+ // Write any pedding characters in the utf8 buffer
+ //
+ if(!u8buffer.empty())
{
- unsigned char uc = value[i]; // char may be signed, so make it positive
- ostringstream s;
- s << "\\"; // Print as octal if not in basic source character set
- s.width(3);
- s.fill('0');
- s << oct;
- s << static_cast<unsigned>(uc);
- out << s.str();
+ writeU8Buffer(u8buffer, out);
+ u8buffer.clear();
}
- else
+ out << "\"";
+ }
+ else // narrow strings
+ {
+ out << "\""; // Opening "
+
+ for(size_t i = 0; i < value.size();)
{
- switch(value[i])
+ if(charSet.find(value[i]) == charSet.end())
+ {
+ unsigned char uc = value[i]; // char may be signed, so make it positive
+ ostringstream s;
+ s << "\\"; // Print as octal if not in basic source character set
+ s.width(3);
+ s.fill('0');
+ s << oct;
+ s << static_cast<unsigned>(uc);
+ out << s.str();
+ }
+ else
{
- case '\\':
+ switch(value[i])
{
- string s = "\\";
- size_t j = i + 1;
- for(; j < value.size(); ++j)
+ case '\\':
{
- if(value[j] != '\\')
+ string s = "\\";
+ size_t j = i + 1;
+ for(; j < value.size(); ++j)
{
- break;
+ if(value[j] != '\\')
+ {
+ break;
+ }
+ s += "\\";
}
- 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
+ // 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')
//
- out << s.substr(0, s.size() - 1);
+ 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);
+ 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);
+ IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16);
- vector<unsigned int> u32buffer;
- u32buffer.push_back(static_cast<unsigned int>(v));
+ vector<unsigned int> u32buffer;
+ u32buffer.push_back(static_cast<unsigned int>(v));
- vector<unsigned char> u8buffer;
+ vector<unsigned char> u8buffer;
- IceUtilInternal::ConversionResult result = convertUTF32ToUTF8(u32buffer, u8buffer, IceUtil::lenientConversion);
- switch(result)
- {
- case conversionOK:
- break;
- case sourceExhausted:
- throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source exhausted");
- case sourceIllegal:
- throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source illegal");
- default:
+ IceUtilInternal::ConversionResult result = convertUTF32ToUTF8(u32buffer, u8buffer, IceUtil::lenientConversion);
+ switch(result)
{
- assert(0);
- throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
+ case conversionOK:
+ break;
+ case sourceExhausted:
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source exhausted");
+ case sourceIllegal:
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source illegal");
+ default:
+ {
+ assert(0);
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
+ }
}
- }
- ostringstream s;
- for(vector<unsigned char>::const_iterator q = u8buffer.begin(); q != u8buffer.end(); ++q)
+ ostringstream s;
+ for(vector<unsigned char>::const_iterator q = u8buffer.begin(); q != u8buffer.end(); ++q)
+ {
+ s << "\\";
+ s.fill('0');
+ s.width(3);
+ s << oct;
+ s << static_cast<unsigned int>(*q);
+ }
+ out << s.str();
+
+ i = j + 1 + sz;
+ }
+ else
{
- s << "\\";
- s.fill('0');
- s.width(3);
- s << oct;
- s << static_cast<unsigned int>(*q);
+ out << s;
+ i = j;
}
- out << s.str();
-
- i = j + 1 + sz;
+ continue;
}
- else
+ case '"':
{
- out << s;
- i = j;
+ out << "\\";
+ break;
}
- continue;
- }
- case '"':
- {
- out << "\\";
- break;
}
+
+ out << value[i]; // Print normally if in basic source character set
}
-
- out << value[i]; // Print normally if in basic source character set
+ ++i;
}
- ++i;
+ out << "\""; // Closing "
}
-
- out << "\""; // Closing "
}
else if(bp && bp->kind() == Builtin::KindLong)
{
diff --git a/cpp/src/slice2objc/Gen.cpp b/cpp/src/slice2objc/Gen.cpp
index 283efc935e3..1363779f8e9 100644
--- a/cpp/src/slice2objc/Gen.cpp
+++ b/cpp/src/slice2objc/Gen.cpp
@@ -17,6 +17,8 @@
#include <direct.h>
#endif
#include <IceUtil/Iterator.h>
+#include <IceUtil/Unicode.h>
+#include <IceUtil/InputUtil.h>
#include <IceUtil/UUID.h>
#include <Slice/Checksum.h>
#include <Slice/FileTracker.h>
@@ -1492,13 +1494,13 @@ Slice::Gen::TypesVisitor::writeConstantValue(IceUtilInternal::Output& out, const
out << "@\""; // Opening @"
- for(string::const_iterator c = val.begin(); c != val.end(); ++c)
+ for(size_t i = 0; i < val.size();)
{
- if(charSet.find(*c) == charSet.end())
+ if(charSet.find(val[i]) == charSet.end())
{
- unsigned char uc = *c; // char may be signed, so make it positive
+ unsigned char uc = val[i]; // char may be signed, so make it positive
ostringstream s;
- s << "\\"; // Print as octal if not in basic source character set
+ s << "\\"; // Print as octal if not in basic source character set
s.width(3);
s.fill('0');
s << oct;
@@ -1507,11 +1509,95 @@ Slice::Gen::TypesVisitor::writeConstantValue(IceUtilInternal::Output& out, const
}
else
{
- out << *c; // Print normally if in basic source character set
+ switch(val[i])
+ {
+ case '\\':
+ {
+ string s = "\\";
+ size_t j = i + 1;
+ for(; j < val.size(); ++j)
+ {
+ if(val[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 && (val[j] == 'U' || val[j] == 'u'))
+ {
+ //
+ // Convert codepoint to UTF8 bytes and write the escaped bytes
+ //
+ out << s.substr(0, s.size() - 1);
+
+ size_t sz = val[j] == 'U' ? 8 : 4;
+ string codepoint = val.substr(j + 1, sz);
+ assert(codepoint.size() == sz);
+
+ IceUtil::Int64 v = IceUtilInternal::strToInt64(codepoint.c_str(), 0, 16);
+
+
+ vector<unsigned int> u32buffer;
+ u32buffer.push_back(static_cast<unsigned int>(v));
+
+ vector<unsigned char> u8buffer;
+
+ IceUtilInternal::ConversionResult result = convertUTF32ToUTF8(u32buffer, u8buffer, IceUtil::lenientConversion);
+ switch(result)
+ {
+ case conversionOK:
+ break;
+ case sourceExhausted:
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source exhausted");
+ case sourceIllegal:
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__, "string source illegal");
+ default:
+ {
+ assert(0);
+ throw IceUtil::IllegalConversionException(__FILE__, __LINE__);
+ }
+ }
+
+ ostringstream s;
+ for(vector<unsigned char>::const_iterator q = u8buffer.begin(); q != u8buffer.end(); ++q)
+ {
+ s << "\\";
+ s.fill('0');
+ s.width(3);
+ s << oct;
+ s << static_cast<unsigned int>(*q);
+ }
+ out << s.str();
+
+ i = j + 1 + sz;
+ }
+ else
+ {
+ out << s;
+ i = j;
+ }
+ continue;
+ }
+ case '"':
+ {
+ out << "\\";
+ break;
+ }
+ }
+
+ out << val[i]; // Print normally if in basic source character set
}
+ ++i;
}
-
- out << "\""; // Closing "
+ out << "\""; // Closing "
}
else
{
diff --git a/cpp/test/Ice/operations/Test.ice b/cpp/test/Ice/operations/Test.ice
index cf44e14a50d..d7698951ca8 100644
--- a/cpp/test/Ice/operations/Test.ice
+++ b/cpp/test/Ice/operations/Test.ice
@@ -43,6 +43,7 @@ sequence<long> LongS;
sequence<float> FloatS;
sequence<double> DoubleS;
sequence<string> StringS;
+sequence<["cpp:type:wstring"]string> WStringS;
sequence<MyEnum> MyEnumS;
sequence<MyClass*> MyClassS;
@@ -253,6 +254,7 @@ class MyClass
ByteBoolD opByteBoolD2(ByteBoolD byteBoolD);
StringS opStringLiterals();
+ WStringS opWStringLiterals();
};
struct MyStruct1
@@ -341,5 +343,70 @@ 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";
+//
+// Wide string literals
+//
+
+const ["cpp:type:wstring"]string ws0 = "\u005c"; // backslash
+const ["cpp:type:wstring"]string ws1 = "\u0041"; // A
+const ["cpp:type:wstring"]string ws2 = "\u0049\u0063\u0065"; // Ice
+const ["cpp:type:wstring"]string ws3 = "\u004121"; // A21
+const ["cpp:type:wstring"]string ws4 = "\\u0041 \\U00000041"; // \\u0041 \\U00000041
+const ["cpp:type:wstring"]string ws5 = "\u00FF"; // ÿ
+const ["cpp:type:wstring"]string ws6 = "\u03FF"; // GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL (U+03FF)
+const ["cpp:type:wstring"]string ws7 = "\u05F0"; // HEBREW LIGATURE YIDDISH DOUBLE VAV (U+05F0)
+const ["cpp:type:wstring"]string ws8 = "\U00010000"; // LINEAR B SYLLABLE B008 A (U+10000)
+const ["cpp:type:wstring"]string ws9 = "\U0001F34C"; // BANANA (U+1F34C)
+const ["cpp:type:wstring"]string ws10 = "\u0DA7"; // Sinhala Letter Alpapraana Ttayanna
+
+const ["cpp:type:wstring"]string wsw0 = "\U0000005c"; // backslash
+const ["cpp:type:wstring"]string wsw1 = "\U00000041"; // A
+const ["cpp:type:wstring"]string wsw2 = "\U00000049\U00000063\U00000065"; // Ice
+const ["cpp:type:wstring"]string wsw3 = "\U0000004121"; // A21
+const ["cpp:type:wstring"]string wsw4 = "\\u0041 \\U00000041"; // \\u0041 \\U00000041
+const ["cpp:type:wstring"]string wsw5 = "\U000000FF"; // ÿ
+const ["cpp:type:wstring"]string wsw6 = "\U000003FF"; // GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL (U+03FF)
+const ["cpp:type:wstring"]string wsw7 = "\U000005F0"; // HEBREW LIGATURE YIDDISH DOUBLE VAV (U+05F0)
+const ["cpp:type:wstring"]string wsw8 = "\U00010000"; // LINEAR B SYLLABLE B008 A (U+10000)
+const ["cpp:type:wstring"]string wsw9 = "\U0001F34C"; // BANANA (U+1F34C)
+const ["cpp:type:wstring"]string wsw10 = "\U00000DA7"; // Sinhala Letter Alpapraana Ttayanna
+
+/**
+\' single quote byte 0x27 in ASCII encoding
+\" double quote byte 0x22 in ASCII encoding
+\? question mark byte 0x3f in ASCII encoding
+\\ backslash byte 0x5c in ASCII encoding
+\a audible bell byte 0x07 in ASCII encoding
+\b backspace byte 0x08 in ASCII encoding
+\f form feed - new page byte 0x0c in ASCII encoding
+\n line feed - new line byte 0x0a in ASCII encoding
+\r carriage return byte 0x0d in ASCII encoding
+\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";
+
+const ["cpp:type:wstring"]string wss3 = "\\\\U\\u\\"; /* \\U\u\ */
+const ["cpp:type:wstring"]string wss4 = "\\\u0041\\"; /* \A\ */
+const ["cpp:type:wstring"]string wss5 = "\\u0041\\"; /* \u0041\ */
+
+//
+// ÿ - 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)
+// 𐆔 - Unicode Character 'ROMAN DIMIDIA SEXTULA SIGN' (U+10194)
+// 𐅪 - Unicode Character 'GREEK ACROPHONIC THESPIAN ONE HUNDRED' (U+1016A)
+// 𐆘 - Unicode Character 'ROMAN SESTERTIUS SIGN' (U+10198)
+// 🍀 - Unicode Character 'FOUR LEAF CLOVER' (U+1F340)
+// 🍁 - 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";
+
};
diff --git a/cpp/test/Ice/operations/TestAMD.ice b/cpp/test/Ice/operations/TestAMD.ice
index a65608ea4c7..ee26d1c1970 100644
--- a/cpp/test/Ice/operations/TestAMD.ice
+++ b/cpp/test/Ice/operations/TestAMD.ice
@@ -43,6 +43,7 @@ sequence<long> LongS;
sequence<float> FloatS;
sequence<double> DoubleS;
sequence<string> StringS;
+sequence<["cpp:type:wstring"] string> WStringS;
sequence<MyEnum> MyEnumS;
sequence<MyClass*> MyClassS;
@@ -254,6 +255,8 @@ dictionary<MyEnum, MyEnumS> MyEnumMyEnumSD;
ByteBoolD opByteBoolD2(ByteBoolD byteBoolD);
StringS opStringLiterals();
+
+ WStringS opWStringLiterals();
};
struct MyStruct1
@@ -344,6 +347,71 @@ 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";
+//
+// Wide string literals
+//
+
+const ["cpp:type:wstring"]string ws0 = "\u005c"; // backslash
+const ["cpp:type:wstring"]string ws1 = "\u0041"; // A
+const ["cpp:type:wstring"]string ws2 = "\u0049\u0063\u0065"; // Ice
+const ["cpp:type:wstring"]string ws3 = "\u004121"; // A21
+const ["cpp:type:wstring"]string ws4 = "\\u0041 \\U00000041"; // \\u0041 \\U00000041
+const ["cpp:type:wstring"]string ws5 = "\u00FF"; // ÿ
+const ["cpp:type:wstring"]string ws6 = "\u03FF"; // GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL (U+03FF)
+const ["cpp:type:wstring"]string ws7 = "\u05F0"; // HEBREW LIGATURE YIDDISH DOUBLE VAV (U+05F0)
+const ["cpp:type:wstring"]string ws8 = "\U00010000"; // LINEAR B SYLLABLE B008 A (U+10000)
+const ["cpp:type:wstring"]string ws9 = "\U0001F34C"; // BANANA (U+1F34C)
+const ["cpp:type:wstring"]string ws10 = "\u0DA7"; // Sinhala Letter Alpapraana Ttayanna
+
+const ["cpp:type:wstring"]string wsw0 = "\U0000005c"; // backslash
+const ["cpp:type:wstring"]string wsw1 = "\U00000041"; // A
+const ["cpp:type:wstring"]string wsw2 = "\U00000049\U00000063\U00000065"; // Ice
+const ["cpp:type:wstring"]string wsw3 = "\U0000004121"; // A21
+const ["cpp:type:wstring"]string wsw4 = "\\u0041 \\U00000041"; // \\u0041 \\U00000041
+const ["cpp:type:wstring"]string wsw5 = "\U000000FF"; // ÿ
+const ["cpp:type:wstring"]string wsw6 = "\U000003FF"; // GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL (U+03FF)
+const ["cpp:type:wstring"]string wsw7 = "\U000005F0"; // HEBREW LIGATURE YIDDISH DOUBLE VAV (U+05F0)
+const ["cpp:type:wstring"]string wsw8 = "\U00010000"; // LINEAR B SYLLABLE B008 A (U+10000)
+const ["cpp:type:wstring"]string wsw9 = "\U0001F34C"; // BANANA (U+1F34C)
+const ["cpp:type:wstring"]string wsw10 = "\U00000DA7"; // Sinhala Letter Alpapraana Ttayanna
+
+/**
+\' single quote byte 0x27 in ASCII encoding
+\" double quote byte 0x22 in ASCII encoding
+\? question mark byte 0x3f in ASCII encoding
+\\ backslash byte 0x5c in ASCII encoding
+\a audible bell byte 0x07 in ASCII encoding
+\b backspace byte 0x08 in ASCII encoding
+\f form feed - new page byte 0x0c in ASCII encoding
+\n line feed - new line byte 0x0a in ASCII encoding
+\r carriage return byte 0x0d in ASCII encoding
+\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";
+
+const ["cpp:type:wstring"]string wss3 = "\\\\U\\u\\"; /* \\U\u\ */
+const ["cpp:type:wstring"]string wss4 = "\\\u0041\\"; /* \A\ */
+const ["cpp:type:wstring"]string wss5 = "\\u0041\\"; /* \u0041\ */
+
+//
+// ÿ - 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)
+// 𐆔 - Unicode Character 'ROMAN DIMIDIA SEXTULA SIGN' (U+10194)
+// 𐅪 - Unicode Character 'GREEK ACROPHONIC THESPIAN ONE HUNDRED' (U+1016A)
+// 𐆘 - Unicode Character 'ROMAN SESTERTIUS SIGN' (U+10198)
+// 🍀 - Unicode Character 'FOUR LEAF CLOVER' (U+1F340)
+// 🍁 - 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";
+
};
diff --git a/cpp/test/Ice/operations/TestAMDI.cpp b/cpp/test/Ice/operations/TestAMDI.cpp
index df030eb030d..419320fdcc4 100644
--- a/cpp/test/Ice/operations/TestAMDI.cpp
+++ b/cpp/test/Ice/operations/TestAMDI.cpp
@@ -780,7 +780,6 @@ MyDerivedClassI::opMyClass1_async(const Test::AMD_MyDerivedClass_opMyClass1Ptr&
cb->ice_response(c);
}
-
void
MyDerivedClassI::opStringLiterals_async(const Test::AMD_MyClass_opStringLiteralsPtr& cb,
const Ice::Current&)
@@ -821,4 +820,46 @@ MyDerivedClassI::opStringLiterals_async(const Test::AMD_MyClass_opStringLiterals
data.push_back(Test::su1);
data.push_back(Test::su2);
cb->ice_response(data);
-} \ No newline at end of file
+}
+
+void
+MyDerivedClassI::opWStringLiterals_async(const Test::AMD_MyClass_opWStringLiteralsPtr& cb,
+ const Ice::Current&)
+{
+ Test::WStringS data;
+ data.push_back(Test::ws0);
+ data.push_back(Test::ws1);
+ data.push_back(Test::ws2);
+ data.push_back(Test::ws3);
+ data.push_back(Test::ws4);
+ data.push_back(Test::ws5);
+ data.push_back(Test::ws6);
+ data.push_back(Test::ws7);
+ data.push_back(Test::ws8);
+ data.push_back(Test::ws9);
+ data.push_back(Test::ws10);
+
+ data.push_back(Test::wsw0);
+ data.push_back(Test::wsw1);
+ data.push_back(Test::wsw2);
+ data.push_back(Test::wsw3);
+ data.push_back(Test::wsw4);
+ data.push_back(Test::wsw5);
+ data.push_back(Test::wsw6);
+ data.push_back(Test::wsw7);
+ data.push_back(Test::wsw8);
+ data.push_back(Test::wsw9);
+ data.push_back(Test::wsw10);
+
+ data.push_back(Test::wss0);
+ data.push_back(Test::wss1);
+ data.push_back(Test::wss2);
+ data.push_back(Test::wss3);
+ data.push_back(Test::wss4);
+ data.push_back(Test::wss5);
+
+ data.push_back(Test::wsu0);
+ data.push_back(Test::wsu1);
+ data.push_back(Test::wsu2);
+ cb->ice_response(data);
+}
diff --git a/cpp/test/Ice/operations/TestAMDI.h b/cpp/test/Ice/operations/TestAMDI.h
index 418d0a2aa36..686a76f00cd 100644
--- a/cpp/test/Ice/operations/TestAMDI.h
+++ b/cpp/test/Ice/operations/TestAMDI.h
@@ -278,6 +278,9 @@ public:
virtual void opStringLiterals_async(const Test::AMD_MyClass_opStringLiteralsPtr&,
const Ice::Current&);
+
+ virtual void opWStringLiterals_async(const Test::AMD_MyClass_opWStringLiteralsPtr&,
+ const Ice::Current&);
private:
IceUtil::ThreadPtr _opVoidThread;
diff --git a/cpp/test/Ice/operations/TestI.cpp b/cpp/test/Ice/operations/TestI.cpp
index 29e6728047b..84054ac8d45 100644
--- a/cpp/test/Ice/operations/TestI.cpp
+++ b/cpp/test/Ice/operations/TestI.cpp
@@ -782,3 +782,46 @@ MyDerivedClassI::opStringLiterals(const Ice::Current&)
return data;
}
+
+Test::WStringS
+MyDerivedClassI::opWStringLiterals(const Ice::Current&)
+{
+ Test::WStringS data;
+ data.push_back(Test::ws0);
+ data.push_back(Test::ws1);
+ data.push_back(Test::ws2);
+ data.push_back(Test::ws3);
+ data.push_back(Test::ws4);
+ data.push_back(Test::ws5);
+ data.push_back(Test::ws6);
+ data.push_back(Test::ws7);
+ data.push_back(Test::ws8);
+ data.push_back(Test::ws9);
+ data.push_back(Test::ws10);
+
+ data.push_back(Test::wsw0);
+ data.push_back(Test::wsw1);
+ data.push_back(Test::wsw2);
+ data.push_back(Test::wsw3);
+ data.push_back(Test::wsw4);
+ data.push_back(Test::wsw5);
+ data.push_back(Test::wsw6);
+ data.push_back(Test::wsw7);
+ data.push_back(Test::wsw8);
+ data.push_back(Test::wsw9);
+ data.push_back(Test::wsw10);
+
+ data.push_back(Test::wss0);
+ data.push_back(Test::wss1);
+ data.push_back(Test::wss2);
+ data.push_back(Test::wss3);
+ data.push_back(Test::wss4);
+ data.push_back(Test::wss5);
+
+ data.push_back(Test::wsu0);
+ data.push_back(Test::wsu1);
+ data.push_back(Test::wsu2);
+
+ return data;
+}
+
diff --git a/cpp/test/Ice/operations/TestI.h b/cpp/test/Ice/operations/TestI.h
index 4f31f7eecfe..8f8b0b1b573 100644
--- a/cpp/test/Ice/operations/TestI.h
+++ b/cpp/test/Ice/operations/TestI.h
@@ -270,6 +270,8 @@ public:
virtual Test::MyClass1Ptr opMyClass1(const Test::MyClass1Ptr&, const Ice::Current&);
virtual Test::StringS opStringLiterals(const Ice::Current&);
+
+ virtual Test::WStringS opWStringLiterals(const Ice::Current&);
private:
diff --git a/cpp/test/Ice/operations/Twoways.cpp b/cpp/test/Ice/operations/Twoways.cpp
index 54d2d2d439a..379d808c520 100644
--- a/cpp/test/Ice/operations/Twoways.cpp
+++ b/cpp/test/Ice/operations/Twoways.cpp
@@ -135,11 +135,93 @@ twoways(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p)
test(Test::ss5 == "\\u0041\\" &&
Test::ss5 == literals[27]);
- 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]);
+ test(Test::su0 == Test::su1 &&
+ Test::su0 == Test::su2 &&
+ Test::su0 == literals[28] &&
+ Test::su0 == literals[29] &&
+ Test::su0 == literals[30]);
+
+ //
+ // Same but using wide strings
+ //
+ Test::WStringS wliterals = p->opWStringLiterals();
+
+ test(Test::ws0 == L"\\" &&
+ Test::ws0 == Test::wsw0 &&
+ Test::ws0 == wliterals[0] &&
+ Test::ws0 == wliterals[11]);
+
+ test(Test::ws1 == L"A" &&
+ Test::ws1 == Test::wsw1 &&
+ Test::ws1 == wliterals[1] &&
+ Test::ws1 == wliterals[12]);
+
+ test(Test::ws2 == L"Ice" &&
+ Test::ws2 == Test::wsw2 &&
+ Test::ws2 == wliterals[2] &&
+ Test::ws2 == wliterals[13]);
+
+ test(Test::ws3 == L"A21" &&
+ Test::ws3 == Test::wsw3 &&
+ Test::ws3 == wliterals[3] &&
+ Test::ws3 == wliterals[14]);
+
+ test(Test::ws4 == L"\\u0041 \\U00000041" &&
+ Test::ws4 == Test::wsw4 &&
+ Test::ws4 == wliterals[4] &&
+ Test::ws4 == wliterals[15]);
+
+ test(Test::ws5 == L"\u00FF" &&
+ Test::ws5 == Test::wsw5 &&
+ Test::ws5 == wliterals[5] &&
+ Test::ws5 == wliterals[16]);
+
+ test(Test::ws6 == L"\u03FF" &&
+ Test::ws6 == Test::wsw6 &&
+ Test::ws6 == wliterals[6] &&
+ Test::ws6 == wliterals[17]);
+
+ test(Test::ws7 == L"\u05F0" &&
+ Test::ws7 == Test::wsw7 &&
+ Test::ws7 == wliterals[7] &&
+ Test::ws7 == wliterals[18]);
+
+ test(Test::ws8 == L"\U00010000" &&
+ Test::ws8 == Test::wsw8 &&
+ Test::ws8 == wliterals[8] &&
+ Test::ws8 == wliterals[19]);
+
+ test(Test::ws9 == L"\U0001F34C" &&
+ Test::ws9 == Test::wsw9 &&
+ Test::ws9 == wliterals[9] &&
+ Test::ws9 == wliterals[20]);
+
+ test(Test::ws10 == L"\u0DA7" &&
+ Test::ws10 == Test::wsw10 &&
+ Test::ws10 == wliterals[10] &&
+ Test::ws10 == wliterals[21]);
+
+ test(Test::wss0 == L"\'\"\?\\\a\b\f\n\r\t\v" &&
+ Test::wss0 == Test::wss1 &&
+ Test::wss0 == Test::wss2 &&
+ Test::wss0 == wliterals[22] &&
+ Test::wss0 == wliterals[23] &&
+ Test::wss0 == wliterals[24]);
+
+ test(Test::wss3 == L"\\\\U\\u\\" &&
+ Test::wss3 == wliterals[25]);
+
+ test(Test::wss4 == L"\\A\\" &&
+ Test::wss4 == wliterals[26]);
+
+ test(Test::wss5 == L"\\u0041\\" &&
+ Test::wss5 == wliterals[27]);
+
+ test(Test::wsu0 == Test::wsu1 &&
+ Test::wsu0 == Test::wsu2 &&
+ Test::wsu0 == wliterals[28] &&
+ Test::wsu0 == wliterals[29] &&
+ Test::wsu0 == wliterals[30]);
{
p->ice_ping();