diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Freeze/EvictorI.cpp | 4 | ||||
-rw-r--r-- | cpp/src/slice2freeze/Main.cpp | 23 | ||||
-rw-r--r-- | cpp/src/slice2freezej/Main.cpp | 22 |
3 files changed, 45 insertions, 4 deletions
diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp index 2136a9ad720..4ed65ed4863 100644 --- a/cpp/src/Freeze/EvictorI.cpp +++ b/cpp/src/Freeze/EvictorI.cpp @@ -188,8 +188,10 @@ marshal(const ObjectRecord& v, Value& bytes, const CommunicatorPtr& communicator IceInternal::InstancePtr instance = IceInternal::getInstance(communicator); IceInternal::BasicStream stream(instance.get()); stream.marshalFacets(false); + stream.startWriteEncaps(); v.__write(&stream); stream.writePendingObjects(); + stream.endWriteEncaps(); bytes.swap(stream.b); } @@ -200,8 +202,10 @@ unmarshal(ObjectRecord& v, const Value& bytes, const CommunicatorPtr& communicat IceInternal::BasicStream stream(instance.get()); stream.b = bytes; stream.i = stream.b.begin(); + stream.startReadEncaps(); v.__read(&stream); stream.readPendingObjects(); + stream.endReadEncaps(); } } diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index eccbe8b6fa4..8e6bfc0508c 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -104,7 +104,7 @@ writeCodecH(const TypePtr& type, const string& name, const string& freezeType, O } void -writeCodecC(const TypePtr& type, const string& name, const string& freezeType, Output& C) +writeCodecC(const TypePtr& type, const string& name, const string& freezeType, bool encaps, Output& C) { string quotedFreezeType = "\"" + freezeType + "\""; @@ -113,15 +113,22 @@ writeCodecC(const TypePtr& type, const string& name, const string& freezeType, O C << sb; C << nl << "IceInternal::InstancePtr instance = IceInternal::getInstance(communicator);"; C << nl << "IceInternal::BasicStream stream(instance.get());"; + if(encaps) + { + C << nl << "stream.startWriteEncaps();"; + } writeMarshalUnmarshalCode(C, type, "v", true, "stream", false); if(type->usesClasses()) { C << nl << "stream.writePendingObjects();"; } + if(encaps) + { + C << nl << "stream.endWriteEncaps();"; + } C << nl << "bytes.swap(stream.b);"; C << eb; - C << sp << nl << "void" << nl << name << "::read(" << typeToString(type) << "& v, " << "const Freeze::" << freezeType << "& bytes, const ::Ice::CommunicatorPtr& communicator)"; C << sb; @@ -129,11 +136,19 @@ writeCodecC(const TypePtr& type, const string& name, const string& freezeType, O C << nl << "IceInternal::BasicStream stream(instance.get());"; C << nl << "stream.b = bytes;"; C << nl << "stream.i = stream.b.begin();"; + if(encaps) + { + C << nl << "stream.startReadEncaps();"; + } writeMarshalUnmarshalCode(C, type, "v", false, "stream", false); if(type->usesClasses()) { C << nl << "stream.readPendingObjects();"; } + if(encaps) + { + C << nl << "stream.endReadEncaps();"; + } C << eb; } @@ -202,8 +217,8 @@ writeCodecs(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, H << nl << '}'; } - writeCodecC(keyType, absolute + "KeyCodec", "Key", C); - writeCodecC(valueType, absolute + "ValueCodec", "Value", C); + writeCodecC(keyType, absolute + "KeyCodec", "Key", false, C); + writeCodecC(valueType, absolute + "ValueCodec", "Value", true, C); return true; } diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index 72faa7cda5e..afc6a19f964 100644 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -124,16 +124,22 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) { string keyValue; TypePtr type; + bool encaps; if(i == 0) { keyValue = "Key"; type = keyType; + // + // Do not encapsulate keys. + // + encaps = false; } else { keyValue = "Value"; type = valueType; + encaps = true; } string typeS, valS; @@ -207,12 +213,20 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) << "new IceInternal.BasicStream(Ice.Util.getInstance(communicator));"; out << nl << "try"; out << sb; + if(encaps) + { + out << nl << "__os.startWriteEncaps();"; + } iter = 0; writeMarshalUnmarshalCode(out, "", type, valS, true, iter, false); if(type->usesClasses()) { out << nl << "__os.writePendingObjects();"; } + if(encaps) + { + out << nl << "__os.endWriteEncaps();"; + } out << nl << "java.nio.ByteBuffer __buf = __os.prepareWrite();"; out << nl << "byte[] __r = new byte[__buf.limit()];"; out << nl << "__buf.get(__r);"; @@ -239,6 +253,10 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) out << nl << "__buf.position(0);"; out << nl << "__buf.put(b);"; out << nl << "__buf.position(0);"; + if(encaps) + { + out << nl << "__is.startReadEncaps();"; + } iter = 0; list<string> metaData; string patchParams; @@ -308,6 +326,10 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) { out << nl << "__is.readPendingObjects();"; } + if(encaps) + { + out << nl << "__is.endReadEncaps();"; + } if((b && b->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(type)) { out << nl << "return __p.value;"; |