summaryrefslogtreecommitdiff
path: root/cpp/src/slice2freeze/Main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2freeze/Main.cpp')
-rw-r--r--cpp/src/slice2freeze/Main.cpp80
1 files changed, 19 insertions, 61 deletions
diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp
index 24b3cb70f1e..d4c2b9c8c8d 100644
--- a/cpp/src/slice2freeze/Main.cpp
+++ b/cpp/src/slice2freeze/Main.cpp
@@ -47,7 +47,6 @@ usage(const char* n)
" using KEY as key, and VALUE as value. This\n"
" option may be specified multiple times for\n"
" different names. NAME may be a scoped name.\n"
- "--binary Use the binary encoding.\n"
"--output-dir DIR Create files in the directory DIR.\n"
"-d, --debug Print debug messages.\n"
"--ice Permit `Ice' prefix (for building Ice source code only)\n"
@@ -105,64 +104,41 @@ writeCodecH(const TypePtr& type, const string& name, const string& freezeType, O
}
void
-writeCodecC(const TypePtr& type, const string& name, const string& freezeType, Output& C, bool binary)
+writeCodecC(const TypePtr& type, const string& name, const string& freezeType, Output& C)
{
string quotedFreezeType = "\"" + freezeType + "\"";
C << sp << nl << "void" << nl << name << "::write(" << inputTypeToString(type) << " v, "
<< "Freeze::" << freezeType << "& bytes, const ::Ice::CommunicatorPtr& communicator)";
C << sb;
- if(binary)
+ C << nl << "IceInternal::InstancePtr instance = IceInternal::getInstance(communicator);";
+ C << nl << "IceInternal::BasicStream stream(instance.get());";
+ writeMarshalUnmarshalCode(C, type, "v", true, "stream", false);
+ if(type->usesClasses())
{
- C << nl << "IceInternal::InstancePtr instance = IceInternal::getInstance(communicator);";
- C << nl << "IceInternal::BasicStream stream(instance.get());";
- writeMarshalUnmarshalCode(C, type, "v", true, "stream", false);
- C << nl << "bytes = stream.b;";
- }
- else
- {
- C << nl << "std::ostringstream ostr;";
- C << nl << "Ice::StreamPtr stream = new IceXML::StreamI(communicator, ostr);";
- writeGenericMarshalUnmarshalCode(C, type, "v", true, quotedFreezeType, "stream", true);
- C << nl << "const std::string& str = ostr.str();";
- C << nl << "bytes.resize(str.size());";
- C << nl << "std::copy(str.begin(), str.end(), bytes.begin());";
+ C << nl << "stream.writePendingObjects();";
}
+ C << nl << "bytes = stream.b;";
C << eb;
C << sp << nl << "void" << nl << name << "::read(" << typeToString(type) << "& v, "
<< "const Freeze::" << freezeType << "& bytes, const ::Ice::CommunicatorPtr& communicator)";
C << sb;
- if(binary)
- {
- C << nl << "IceInternal::InstancePtr instance = IceInternal::getInstance(communicator);";
- C << nl << "IceInternal::BasicStream stream(instance.get());";
- C << nl << "stream.b = bytes;";
- C << nl << "stream.i = stream.b.begin();";
- writeMarshalUnmarshalCode(C, type, "v", false, "stream", false);
- }
- else
+ C << nl << "IceInternal::InstancePtr instance = IceInternal::getInstance(communicator);";
+ C << nl << "IceInternal::BasicStream stream(instance.get());";
+ C << nl << "stream.b = bytes;";
+ C << nl << "stream.i = stream.b.begin();";
+ writeMarshalUnmarshalCode(C, type, "v", false, "stream", false);
+ if(type->usesClasses())
{
- //
- // COMPILERFIX: string data(bytes.begin(), bytes.end());
- //
- // This won't link with STLport 4.5.3 stldebug version.
- //
- C << nl << "std::string str;";
- C << nl << "str.append(\"<data>\");";
- C << nl << "str.append(reinterpret_cast<const char*>(&bytes[0]), bytes.size());";
- C << nl << "str.append(\"</data>\");";
- C << nl << "std::istringstream istr(str);";
- C << nl << "Ice::StreamPtr stream = new IceXML::StreamI(communicator, istr, false);";
- writeGenericMarshalUnmarshalCode(C, type, "v", false, quotedFreezeType, "stream", true);
+ C << nl << "stream.readPendingObjects();";
}
C << eb;
}
bool
-writeCodecs(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, const string& dllExport,
- bool binary)
+writeCodecs(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, const string& dllExport)
{
string absolute = dict.name;
if(absolute.find("::") == 0)
@@ -226,8 +202,8 @@ writeCodecs(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C,
H << nl << '}';
}
- writeCodecC(keyType, absolute + "KeyCodec", "Key", C, binary);
- writeCodecC(valueType, absolute + "ValueCodec", "Value", C, binary);
+ writeCodecC(keyType, absolute + "KeyCodec", "Key", C);
+ writeCodecC(valueType, absolute + "ValueCodec", "Value", C);
return true;
}
@@ -241,7 +217,6 @@ main(int argc, char* argv[])
vector<string> includePaths;
string include;
string dllExport;
- bool binary = false;
string output;
bool debug = false;
bool ice = false;
@@ -438,15 +413,6 @@ main(int argc, char* argv[])
}
argc -= 2;
}
- else if(strcmp(argv[idx], "--binary") == 0)
- {
- binary = true;
- for(int i = idx ; i + 1 < argc ; ++i)
- {
- argv[i] = argv[i + 1];
- }
- --argc;
- }
else if(strcmp(argv[idx], "--output-dir") == 0)
{
if(idx + 1 >= argc)
@@ -579,15 +545,7 @@ main(int argc, char* argv[])
}
}
- if(binary)
- {
- C << "\n#include <Ice/BasicStream.h>";
- }
- else
- {
- C << "\n#include <IceXML/StreamI.h>";
- C << "\n#include <algorithm>";
- }
+ C << "\n#include <Ice/BasicStream.h>";
C << "\n#include <";
if(include.size())
{
@@ -609,7 +567,7 @@ main(int argc, char* argv[])
{
try
{
- if(!writeCodecs(argv[0], u, *p, H, C, dllExport, binary))
+ if(!writeCodecs(argv[0], u, *p, H, C, dllExport))
{
u->destroy();
return EXIT_FAILURE;