summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/BasicStream.cpp216
-rw-r--r--cpp/src/Slice/CPlusPlusUtil.cpp63
2 files changed, 251 insertions, 28 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp
index f5d47b2ca0a..fb764309bb0 100644
--- a/cpp/src/Ice/BasicStream.cpp
+++ b/cpp/src/Ice/BasicStream.cpp
@@ -908,6 +908,46 @@ IceInternal::BasicStream::read(vector<Short>& v)
}
void
+IceInternal::BasicStream::read(pair<const Short*, const Short*>& v, IceUtil::auto_array<Short>& b)
+{
+ Int sz;
+ readSize(sz);
+ if(sz > 0)
+ {
+ checkFixedSeq(sz, static_cast<int>(sizeof(Short)));
+#if defined(__i386) || defined(_M_IX86)
+ v.first = reinterpret_cast<Short*>(i);
+ i += sz * static_cast<int>(sizeof(Short));
+ v.second = reinterpret_cast<Short*>(i);
+#else
+ Short* array = new Short[sz];
+ v.first = array;
+ v.second = array + sz;
+ b.reset(array);
+
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Short));
+# ifdef ICE_BIG_ENDIAN
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&array[0]) + sizeof(Short) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Short);
+ }
+# else
+ copy(begin, i, reinterpret_cast<Byte*>(&array[0]));
+# endif
+#endif
+ }
+ else
+ {
+ v.first = v.second = 0;
+ }
+}
+
+void
IceInternal::BasicStream::write(Int v)
{
Container::size_type pos = b.size();
@@ -1011,6 +1051,48 @@ IceInternal::BasicStream::read(vector<Int>& v)
}
void
+IceInternal::BasicStream::read(pair<const Int*, const Int*>& v, IceUtil::auto_array<Int>& b)
+{
+ Int sz;
+ readSize(sz);
+ if(sz > 0)
+ {
+ checkFixedSeq(sz, static_cast<int>(sizeof(Int)));
+#if defined(__i386) || defined(_M_IX86)
+ v.first = reinterpret_cast<Int*>(i);
+ i += sz * static_cast<int>(sizeof(Int));
+ v.second = reinterpret_cast<Int*>(i);
+#else
+ Int* array = new Int[sz];
+ v.first = array;
+ v.second = array + sz;
+ b.reset(array);
+
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Int));
+# ifdef ICE_BIG_ENDIAN
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&array[0]) + sizeof(Int) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Int);
+ }
+# else
+ copy(begin, i, reinterpret_cast<Byte*>(&array[0]));
+# endif
+#endif
+ }
+ else
+ {
+ v.first = v.second = 0;
+ }
+}
+
+void
IceInternal::BasicStream::write(Long v)
{
Container::size_type pos = b.size();
@@ -1138,6 +1220,52 @@ IceInternal::BasicStream::read(vector<Long>& v)
}
void
+IceInternal::BasicStream::read(pair<const Long*, const Long*>& v, IceUtil::auto_array<Long>& b)
+{
+ Int sz;
+ readSize(sz);
+ if(sz > 0)
+ {
+ checkFixedSeq(sz, static_cast<int>(sizeof(Long)));
+#if defined(__i386) || defined(_M_IX86)
+ v.first = reinterpret_cast<Long*>(i);
+ i += sz * static_cast<int>(sizeof(Long));
+ v.second = reinterpret_cast<Long*>(i);
+#else
+ Long* array = new Long[sz];
+ v.first = array;
+ v.second = array + sz;
+ b.reset(array);
+
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Long));
+# ifdef ICE_BIG_ENDIAN
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&array[0]) + sizeof(Long) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Long);
+ }
+# else
+ copy(begin, i, reinterpret_cast<Byte*>(&array[0]));
+# endif
+#endif
+ }
+ else
+ {
+ v.first = v.second = 0;
+ }
+}
+
+void
IceInternal::BasicStream::write(Float v)
{
Container::size_type pos = b.size();
@@ -1241,6 +1369,48 @@ IceInternal::BasicStream::read(vector<Float>& v)
}
void
+IceInternal::BasicStream::read(pair<const Float*, const Float*>& v, IceUtil::auto_array<Float>& b)
+{
+ Int sz;
+ readSize(sz);
+ if(sz > 0)
+ {
+ checkFixedSeq(sz, static_cast<int>(sizeof(Float)));
+#if defined(__i386) || defined(_M_IX86)
+ v.first = reinterpret_cast<Float*>(i);
+ i += sz * static_cast<int>(sizeof(Float));
+ v.second = reinterpret_cast<Float*>(i);
+#else
+ Float* array = new Float[sz];
+ v.first = array;
+ v.second = array + sz;
+ b.reset(array);
+
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Float));
+# ifdef ICE_BIG_ENDIAN
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&array[0]) + sizeof(Float) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Float);
+ }
+# else
+ copy(begin, i, reinterpret_cast<Byte*>(&array[0]));
+# endif
+#endif
+ }
+ else
+ {
+ v.first = v.second = 0;
+ }
+}
+
+void
IceInternal::BasicStream::write(Double v)
{
Container::size_type pos = b.size();
@@ -1367,6 +1537,52 @@ IceInternal::BasicStream::read(vector<Double>& v)
}
}
+void
+IceInternal::BasicStream::read(pair<const Double*, const Double*>& v, IceUtil::auto_array<Double>& b)
+{
+ Int sz;
+ readSize(sz);
+ if(sz > 0)
+ {
+ checkFixedSeq(sz, static_cast<int>(sizeof(Double)));
+#if defined(__i386) || defined(_M_IX86)
+ v.first = reinterpret_cast<Double*>(i);
+ i += sz * static_cast<int>(sizeof(Double));
+ v.second = reinterpret_cast<Double*>(i);
+#else
+ Double* array = new Double[sz];
+ v.first = array;
+ v.second = array + sz;
+ b.reset(array);
+
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Double));
+# ifdef ICE_BIG_ENDIAN
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&array[0]) + sizeof(Double) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Double);
+ }
+# else
+ copy(begin, i, reinterpret_cast<Byte*>(&array[0]));
+# endif
+#endif
+ }
+ else
+ {
+ v.first = v.second = 0;
+ }
+}
+
//
// NOTE: This member function is intentionally omitted in order to
// cause a link error if it is used. This is for efficiency reasons:
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp
index af5f4be10c2..401efc6535d 100644
--- a/cpp/src/Slice/CPlusPlusUtil.cpp
+++ b/cpp/src/Slice/CPlusPlusUtil.cpp
@@ -642,11 +642,11 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string&
}
out << nl << stream << deref << "writeSize(static_cast< ::Ice::Int>(ice_distance("
<< fixedParam << ".first, " << fixedParam << ".second)));";
- out << nl << "for(" << seqType << "::const_iterator __" << fixedParam << " = "
- << fixedParam << ".first; __" << fixedParam << " != " << fixedParam << ".second; ++__"
+ out << nl << "for(" << seqType << "::const_iterator ___" << fixedParam << " = "
+ << fixedParam << ".first; ___" << fixedParam << " != " << fixedParam << ".second; ++___"
<< fixedParam << ")";
out << sb;
- writeMarshalUnmarshalCode(out, seq->type(), "(*__" + fixedParam + ")", true, "", true, l, false);
+ writeMarshalUnmarshalCode(out, seq->type(), "(*___" + fixedParam + ")", true, "", true, l, false);
out << eb;
}
else if(!seqType.empty())
@@ -717,8 +717,8 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string&
seqType = findMetaData(l, false);
if(seqType.empty())
{
- out << nl << typeToString(type) << " __" << fixedParam << ";";
- out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", __"
+ out << nl << typeToString(type) << " ___" << fixedParam << ";";
+ out << nl << scope << "___" << func << (pointer ? "" : "&") << stream << ", ___"
<< fixedParam << ", " << scope << "__U__" << fixKwd(seq->name()) << "());";
}
else
@@ -726,29 +726,36 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string&
seqType = "::std::vector< " + typeToString(seq->type()) + ">";
StringList l;
l.push_back("cpp:type:" + seqType);
- out << nl << seqType << " __" << fixedParam << ";";
- writeMarshalUnmarshalCode(out, seq, "__" + fixedParam, false, "", true, l, false);
+ out << nl << seqType << " ___" << fixedParam << ";";
+ writeMarshalUnmarshalCode(out, seq, "___" + fixedParam, false, "", true, l, false);
}
}
else if(builtin->kind() == Builtin::KindByte)
{
out << nl << stream << deref << func << fixedParam << ");";
}
- else if(builtin->kind() == Builtin::KindBool)
+ else if(builtin->kind() != Builtin::KindString && builtin->kind() != Builtin::KindObject &&
+ builtin->kind() != Builtin::KindObjectProxy)
{
- out << nl << "::IceUtil::auto_array<bool> __" << fixedParam << ";";
- out << nl << stream << deref << func << fixedParam << ", __" << fixedParam << ");";
+ string s = typeToString(builtin);
+ if(s[0] == ':')
+ {
+ s = " " + s;
+ }
+ out << nl << "::IceUtil::auto_array<" << s << "> ___" << fixedParam << ";";
+ out << nl << stream << deref << func << fixedParam << ", ___" << fixedParam << ");";
}
else
{
- out << nl << "::std::vector< " << typeToString(seq->type()) << "> __" << fixedParam << ";";
- out << nl << stream << deref << func << "__" << fixedParam << ");";
+ out << nl << "::std::vector< " << typeToString(seq->type()) << "> ___" << fixedParam << ";";
+ out << nl << stream << deref << func << "___" << fixedParam << ");";
}
- if(!builtin || (builtin->kind() != Builtin::KindByte && builtin->kind() != Builtin::KindBool))
+ if(!builtin || builtin->kind() == Builtin::KindString || builtin->kind() == Builtin::KindObject ||
+ builtin->kind() == Builtin::KindObjectProxy)
{
- out << nl << fixedParam << ".first" << " = &__" << fixedParam << "[0];";
- out << nl << fixedParam << ".second" << " = " << fixedParam << ".first + " << "__"
+ out << nl << fixedParam << ".first" << " = &___" << fixedParam << "[0];";
+ out << nl << fixedParam << ".second" << " = " << fixedParam << ".first + " << "___"
<< fixedParam << ".size();";
}
}
@@ -763,10 +770,10 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string&
{
l.push_back("cpp:type:" + seqType.substr(strlen("range:")));
}
- out << nl << typeToString(seq, l, false) << " __" << fixedParam << ";";
- writeMarshalUnmarshalCode(out, seq, "__" + fixedParam, false, "", true, l, false);
- out << nl << fixedParam << ".first = __" << fixedParam << ".begin();";
- out << nl << fixedParam << ".second = __" << fixedParam << ".end();";
+ out << nl << typeToString(seq, l, false) << " ___" << fixedParam << ";";
+ writeMarshalUnmarshalCode(out, seq, "___" + fixedParam, false, "", true, l, false);
+ out << nl << fixedParam << ".first = ___" << fixedParam << ".begin();";
+ out << nl << fixedParam << ".second = ___" << fixedParam << ".end();";
}
else if(!seqType.empty())
{
@@ -822,7 +829,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string&
{
StringList md;
md.push_back("cpp:array");
- string tmpParam = "__";
+ string tmpParam = "___";
if(fixedParam.find("(*") == 0)
{
tmpParam += fixedParam.substr(2, fixedParam.length() - 3);
@@ -1107,22 +1114,22 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s
if(marshal)
{
out << nl << stream << "->writeSize(static_cast< ::Ice::Int>(" << fixedParam << ".size()));";
- out << nl << seqType << "::const_iterator __" << fixedParam << ";";
- out << nl << "for(__" << fixedParam << " = " << fixedParam << ".begin(); __" << fixedParam << " != "
- << fixedParam << ".end(); ++__" << fixedParam << ")";
+ out << nl << seqType << "::const_iterator ___" << fixedParam << ";";
+ out << nl << "for(___" << fixedParam << " = " << fixedParam << ".begin(); ___" << fixedParam << " != "
+ << fixedParam << ".end(); ++___" << fixedParam << ")";
out << sb;
- writeStreamMarshalUnmarshalCode(out, seq->type(), "(*__" + fixedParam + ")", true);
+ writeStreamMarshalUnmarshalCode(out, seq->type(), "(*___" + fixedParam + ")", true);
out << eb;
}
else
{
out << nl << seqType << "(static_cast< ::Ice::Int>(" << stream << "->readSize())).swap("
<< fixedParam << ");";
- out << nl << seqType << "::iterator __" << fixedParam << ";";
- out << nl << "for(__" << fixedParam << " = " << fixedParam << ".begin(); __" << fixedParam << " != "
- << fixedParam << ".end(); ++__" << fixedParam << ")";
+ out << nl << seqType << "::iterator ___" << fixedParam << ";";
+ out << nl << "for(___" << fixedParam << " = " << fixedParam << ".begin(); ___" << fixedParam << " != "
+ << fixedParam << ".end(); ++___" << fixedParam << ")";
out << sb;
- writeStreamMarshalUnmarshalCode(out, seq->type(), "(*__" + fixedParam + ")", false);
+ writeStreamMarshalUnmarshalCode(out, seq->type(), "(*___" + fixedParam + ")", false);
out << eb;
}
}