diff options
Diffstat (limited to 'cpp/src/slice2freeze/Main.cpp')
-rw-r--r-- | cpp/src/slice2freeze/Main.cpp | 143 |
1 files changed, 74 insertions, 69 deletions
diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index 1b9bff67efb..9cf0e4477e3 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -319,10 +319,10 @@ writeCodecH(const TypePtr& type, const StringList& metaData, const string& name, H << sp << nl << "public:"; H << sp; H.inc(); - H << nl << "static void write(" << inputTypeToString(type, metaData) - << ", Freeze::" << freezeType << "&, const ::Ice::CommunicatorPtr&);"; + H << nl << "static void write(" << inputTypeToString(type, false, metaData) + << ", Freeze::" << freezeType << "&, const ::Ice::CommunicatorPtr&, const Ice::EncodingVersion&);"; H << nl << "static void read(" << typeToString(type, metaData) << "&, const Freeze::" << freezeType << "&, " - << "const ::Ice::CommunicatorPtr&);"; + << "const ::Ice::CommunicatorPtr&, const Ice::EncodingVersion&);"; H << nl << "static const std::string& typeId();"; H << eb << ';'; } @@ -333,16 +333,17 @@ writeCodecC(const TypePtr& type, const StringList& metaData, const string& name, { string quotedFreezeType = "\"" + freezeType + "\""; - C << sp << nl << "void" << nl << name << "::write(" << inputTypeToString(type, metaData) << " v, " - << "Freeze::" << freezeType << "& bytes, const ::Ice::CommunicatorPtr& communicator)"; + C << sp << nl << "void" << nl << name << "::write(" << inputTypeToString(type, false, metaData) << " v, " + << "Freeze::" << freezeType << "& bytes, const ::Ice::CommunicatorPtr& communicator, " + << "const Ice::EncodingVersion& encoding)"; C << sb; C << nl << "IceInternal::InstancePtr instance = IceInternal::getInstance(communicator);"; - C << nl << "IceInternal::BasicStream stream(instance.get(), true);"; + C << nl << "IceInternal::BasicStream stream(instance.get(), encoding, true);"; if(encaps) { C << nl << "stream.startWriteEncaps();"; } - writeMarshalUnmarshalCode(C, type, "v", true, "stream", false, metaData); + writeMarshalUnmarshalCode(C, type, false, 0, "v", true, metaData, 0, "stream", false); if(type->usesClasses()) { C << nl << "stream.writePendingObjects();"; @@ -355,10 +356,11 @@ writeCodecC(const TypePtr& type, const StringList& metaData, const string& name, C << eb; C << sp << nl << "void" << nl << name << "::read(" << typeToString(type, metaData) << "& v, " - << "const Freeze::" << freezeType << "& bytes, const ::Ice::CommunicatorPtr& communicator)"; + << "const Freeze::" << freezeType << "& bytes, const ::Ice::CommunicatorPtr& communicator, " + << "const Ice::EncodingVersion& encoding)"; C << sb; C << nl << "IceInternal::InstancePtr instance = IceInternal::getInstance(communicator);"; - C << nl << "IceInternal::BasicStream stream(instance.get(), true);"; + C << nl << "IceInternal::BasicStream stream(instance.get(), encoding, true);"; if(type->usesClasses()) { C << nl << "stream.sliceObjects(false);"; @@ -370,7 +372,7 @@ writeCodecC(const TypePtr& type, const StringList& metaData, const string& name, { C << nl << "stream.startReadEncaps();"; } - writeMarshalUnmarshalCode(C, type, "v", false, "stream", false, metaData); + writeMarshalUnmarshalCode(C, type, false, 0, "v", false, metaData, 0, "stream", false); if(type->usesClasses()) { C << nl << "stream.readPendingObjects();"; @@ -499,12 +501,12 @@ writeDictWithIndicesH(const string& name, const Dict& dict, // // Codec // - H << nl << "static void write(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) - << ", Freeze::Key&, const Ice::CommunicatorPtr&);"; + H << nl << "static void write(" << inputTypeToString(indexTypes[i].type, 0, indexTypes[i].metaData) + << ", Freeze::Key&, const Ice::CommunicatorPtr&, const Ice::EncodingVersion&);"; H << nl << "static void read(" << typeToString(indexTypes[i].type, indexTypes[i].metaData) - << "&, const Freeze::Key&, const ::Ice::CommunicatorPtr&);"; + << "&, const Freeze::Key&, const ::Ice::CommunicatorPtr&, const Ice::EncodingVersion&);"; H.dec(); H << sp << nl << "protected:"; @@ -529,11 +531,11 @@ writeDictWithIndicesH(const string& name, const Dict& dict, << "_InputIterator __first, _InputIterator __last, " << "const " << compare << "& __compare = " << compare << "())"; H.inc(); - H << nl << ": Freeze::Map" << templateParams <<"(__connection->getCommunicator())"; + H << nl << ": Freeze::Map" << templateParams <<"(__connection->getCommunicator(), __connection->getEncoding())"; H.dec(); H << sb; H << nl << "Freeze::KeyCompareBasePtr __keyCompare = " - << "new Freeze::KeyCompare" << keyCompareParams << "(__compare, this->_communicator);"; + << "new Freeze::KeyCompare" << keyCompareParams << "(__compare, this->_communicator, this->_encoding);"; H << nl << "std::vector<Freeze::MapIndexBasePtr> __indices;"; for(i = 0; i < capitalizedMembers.size(); ++i) { @@ -570,9 +572,9 @@ writeDictWithIndicesH(const string& name, const Dict& dict, { H << sp; H << nl << "iterator findBy" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << ", bool = true);"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ", bool = true);"; H << nl << "const_iterator findBy" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << ", bool = true) const;"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ", bool = true) const;"; H << nl << "iterator beginFor" << capitalizedMembers[i] << "();"; H << nl << "const_iterator beginFor" << capitalizedMembers[i] << "() const;"; @@ -581,28 +583,28 @@ writeDictWithIndicesH(const string& name, const Dict& dict, H << nl << "const_iterator endFor" << capitalizedMembers[i] << "() const;"; H << nl << "iterator lowerBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << ");"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ");"; H << nl << "const_iterator lowerBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << ") const;"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ") const;"; H << nl << "iterator upperBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << ");"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ");"; H << nl << "const_iterator upperBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << ") const;"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ") const;"; H << nl << "std::pair<iterator, iterator> equalRangeFor" - << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) + << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ");"; H << nl << "std::pair<const_iterator, const_iterator> equalRangeFor" - << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) + << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ") const;"; string countFunction = dict.indices[i].member.empty() ? string("valueCount") : dict.indices[i].member + "Count"; H << nl << "int " << countFunction - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << ") const;"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ") const;"; } @@ -621,8 +623,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di + typeToString(valueType, valueMetaData) + ", " + name + "KeyCodec, " + name + "ValueCodec, " + compare + " >"; - string keyCompareParams = - string("< ") + typeToString(keyType, keyMetaData) + ", " + string keyCompareParams = string("< ") + typeToString(keyType, keyMetaData) + ", " + name + "KeyCodec, " + compare + " >"; vector<string> capitalizedMembers; @@ -686,7 +687,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di // Can't optimize // C << nl << typeToString(valueType, valueMetaData) << " __x;"; - C << nl << absolute << "ValueCodec::read(__x, __v, _communicator);"; + C << nl << absolute << "ValueCodec::read(__x, __v, _communicator, _encoding);"; string param = "__x"; if(!dict.indices[i].member.empty()) @@ -700,26 +701,27 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di param += "." + dict.indices[i].member; } } - C << nl << "write(" << param << ", __k, _communicator);"; + C << nl << "write(" << param << ", __k, _communicator, _encoding);"; } C << eb; C << sp << nl << "void" << nl << absolute << "::" << className << "::" - << "write(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) - << " __index, Freeze::Key& __bytes, const Ice::CommunicatorPtr& __communicator)"; + << "write(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) + << " __index, Freeze::Key& __bytes, const Ice::CommunicatorPtr& __communicator, " + << "const Ice::EncodingVersion& __encoding)"; C << sb; if(optimize) { - C << nl << absolute << "ValueCodec::write(__index, __bytes, __communicator);"; + C << nl << absolute << "ValueCodec::write(__index, __bytes, __communicator, __encoding);"; } else { assert(!indexTypes[i].type->usesClasses()); C << nl << "IceInternal::InstancePtr __instance = IceInternal::getInstance(__communicator);"; - C << nl << "IceInternal::BasicStream __stream(__instance.get(), true);"; + C << nl << "IceInternal::BasicStream __stream(__instance.get(), __encoding, true);"; string valueS; if(dict.indices[i].caseSensitive) @@ -733,7 +735,8 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di valueS = "__lowerCaseIndex"; } - writeMarshalUnmarshalCode(C, indexTypes[i].type, valueS, true, "__stream", false, indexTypes[i].metaData); + writeMarshalUnmarshalCode(C, indexTypes[i].type, false, 0, valueS, true, indexTypes[i].metaData, 0, + "__stream", false); C << nl << "::std::vector<Ice::Byte>(__stream.b.begin(), __stream.b.end()).swap(__bytes);"; } C << eb; @@ -741,23 +744,24 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << "void" << nl << absolute << "::" << className << "::" << "read(" << typeToString(indexTypes[i].type, indexTypes[i].metaData) - << "& __index, const Freeze::Key& __bytes, const Ice::CommunicatorPtr& __communicator)"; + << "& __index, const Freeze::Key& __bytes, const Ice::CommunicatorPtr& __communicator, " + << "const Ice::EncodingVersion& __encoding)"; C << sb; if(optimize) { - C << nl << absolute << "ValueCodec::read(__index, __bytes, __communicator);"; + C << nl << absolute << "ValueCodec::read(__index, __bytes, __communicator, __encoding);"; } else { C << nl << "IceInternal::InstancePtr __instance = IceInternal::getInstance(__communicator);"; - C << nl << "IceInternal::BasicStream __stream(__instance.get(), true);"; + C << nl << "IceInternal::BasicStream __stream(__instance.get(), __encoding, true);"; C << nl << "__stream.b.resize(__bytes.size());"; C << nl << "::memcpy(&__stream.b[0], &__bytes[0], __bytes.size());"; C << nl << "__stream.i = __stream.b.begin();"; - writeMarshalUnmarshalCode(C, indexTypes[i].type, "__index", false, "__stream", false, - indexTypes[i].metaData); + writeMarshalUnmarshalCode(C, indexTypes[i].type, false, 0, "__index", false, indexTypes[i].metaData, 0, + "__stream", false); } C << eb; } @@ -769,11 +773,11 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di << "(const Freeze::ConnectionPtr& __connection, const std::string& __dbName ," << "bool __createDb, const " << compare << "& __compare)"; C.inc(); - C << nl << ": Freeze::Map" << templateParams <<"(__connection->getCommunicator())"; + C << nl << ": Freeze::Map" << templateParams <<"(__connection->getCommunicator(), __connection->getEncoding())"; C.dec(); C << sb; C << nl << "Freeze::KeyCompareBasePtr __keyCompare = " - << "new Freeze::KeyCompare" << keyCompareParams << "(__compare, _communicator);"; + << "new Freeze::KeyCompare" << keyCompareParams << "(__compare, _communicator, _encoding);"; C << nl << "std::vector<Freeze::MapIndexBasePtr> __indices;"; for(i = 0; i < capitalizedMembers.size(); ++i) { @@ -800,7 +804,8 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di << " const " << compare << "& __compare)"; C << sb; C << nl << "Freeze::KeyCompareBasePtr __keyCompare = " - << "new Freeze::KeyCompare" << keyCompareParams << "(__compare, __connection->getCommunicator());"; + << "new Freeze::KeyCompare" << keyCompareParams << "(__compare, __connection->getCommunicator()" + <<", __connection->getEncoding());"; C << nl << "std::vector<Freeze::MapIndexBasePtr> __indices;"; for(i = 0; i < capitalizedMembers.size(); ++i) { @@ -834,36 +839,36 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << absolute << "::iterator" << nl << absolute << "::" << "findBy" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index, bool __onlyDups)"; C << sb; C << nl << "Freeze::Key __bytes;"; - C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);"; + C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator, _encoding);"; C << nl << "return iterator(_helper->index(" << indexName - << ")->untypedFind(__bytes, false, __onlyDups), _communicator);"; + << ")->untypedFind(__bytes, false, __onlyDups), _communicator, _encoding);"; C << eb; C << sp << nl << absolute << "::const_iterator" << nl << absolute << "::" << "findBy" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index, bool __onlyDups) const"; C << sb; C << nl << "Freeze::Key __bytes;"; - C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);"; + C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator, _encoding);"; C << nl << "return const_iterator(_helper->index(" << indexName - << ")->untypedFind(__bytes, true, __onlyDups), _communicator);"; + << ")->untypedFind(__bytes, true, __onlyDups), _communicator, _encoding);"; C << eb; C << sp << nl << absolute << "::iterator" << nl << absolute << "::" << "beginFor" << capitalizedMembers[i] << "()"; C << sb; - C << nl << "return iterator(_helper->index(" << indexName << ")->begin(false), _communicator);"; + C << nl << "return iterator(_helper->index(" << indexName << ")->begin(false), _communicator, _encoding);"; C << eb; C << sp << nl << absolute << "::const_iterator" << nl << absolute << "::" << "beginFor" << capitalizedMembers[i] << "() const"; C << sb; - C << nl << "return const_iterator(_helper->index(" << indexName << ")->begin(true), _communicator);"; + C << nl << "return const_iterator(_helper->index(" << indexName << ")->begin(true), _communicator, _encoding);"; C << eb; C << sp << nl << absolute << "::iterator" @@ -880,48 +885,48 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << absolute << "::iterator" << nl << absolute << "::" << "lowerBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << " __index)"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index)"; C << sb; C << nl << "Freeze::Key __bytes;"; - C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);"; + C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator, _encoding);"; C << nl << "return iterator(_helper->index(" << indexName - << ")->untypedLowerBound(__bytes, false), _communicator);"; + << ")->untypedLowerBound(__bytes, false), _communicator, _encoding);"; C << eb; C << sp << nl << absolute << "::const_iterator" << nl << absolute << "::" << "lowerBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << " __index) const"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const"; C << sb; C << nl << "Freeze::Key __bytes;"; - C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);"; + C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator, _encoding);"; C << nl << "return const_iterator(_helper->index(" << indexName - << ")->untypedLowerBound(__bytes, true), _communicator);"; + << ")->untypedLowerBound(__bytes, true), _communicator, _encoding);"; C << eb; C << sp << nl << absolute << "::iterator" << nl << absolute << "::" << "upperBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << " __index)"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index)"; C << sb; C << nl << "Freeze::Key __bytes;"; - C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);"; + C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator, _encoding);"; C << nl << "return iterator(_helper->index(" << indexName - << ")->untypedUpperBound(__bytes, false), _communicator);"; + << ")->untypedUpperBound(__bytes, false), _communicator, _encoding);"; C << eb; C << sp << nl << absolute << "::const_iterator" << nl << absolute << "::" << "upperBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << " __index) const"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const"; C << sb; C << nl << "Freeze::Key __bytes;"; - C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);"; + C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator, _encoding);"; C << nl << "return const_iterator(_helper->index(" << indexName - << ")->untypedUpperBound(__bytes, true), _communicator);"; + << ")->untypedUpperBound(__bytes, true), _communicator, _encoding);"; C << eb; C << sp << nl << "std::pair<" << absolute << "::iterator, " << absolute << "::iterator>" << nl << absolute << "::" << "equalRangeFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << " __index)"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index)"; C << sb; C << nl << "return std::make_pair(lowerBoundFor" << capitalizedMembers[i] << "(__index), upperBoundFor" << capitalizedMembers[i] << "(__index));"; @@ -930,7 +935,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << "std::pair<" << absolute << "::const_iterator, " << absolute << "::const_iterator>" << nl << absolute << "::" << "equalRangeFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << " __index) const"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const"; C << sb; C << nl << "return std::make_pair(lowerBoundFor" << capitalizedMembers[i] << "(__index), upperBoundFor" << capitalizedMembers[i] << "(__index));"; @@ -941,10 +946,10 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << "int" << nl << absolute << "::" << countFunction - << "(" << inputTypeToString(indexTypes[i].type, indexTypes[i].metaData) << " __index) const"; + << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const"; C << sb; C << nl << "Freeze::Key __bytes;"; - C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);"; + C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator, _encoding);"; C << nl << "return _helper->index(" << indexName << ")->untypedCount(__bytes);"; C << eb; @@ -1197,7 +1202,7 @@ void writeIndexC(const TypePtr& type, const TypePtr& memberType, const string& memberName, bool caseSensitive, const string& fullName, const string& name, Output& C) { - string inputType = inputTypeToString(memberType); + string inputType = inputTypeToString(memberType, false); C << sp << nl << fullName << "::" << name << "(const ::std::string& __name, const ::std::string& __facet)"; @@ -1252,7 +1257,7 @@ writeIndexC(const TypePtr& type, const TypePtr& memberType, const string& member C << nl << fullName << "::" << "marshalKey(" << inputType << " __index, Freeze::Key& __bytes) const"; C << sb; C << nl << "IceInternal::InstancePtr __instance = IceInternal::getInstance(_communicator);"; - C << nl << "IceInternal::BasicStream __stream(__instance.get(), true);"; + C << nl << "IceInternal::BasicStream __stream(__instance.get(), _encoding, true);"; string valueS; if(caseSensitive) @@ -1265,7 +1270,7 @@ writeIndexC(const TypePtr& type, const TypePtr& memberType, const string& member valueS = "__lowerCaseIndex"; } - writeMarshalUnmarshalCode(C, memberType, valueS, true, "__stream", false); + writeMarshalUnmarshalCode(C, memberType, false, 0, valueS, true, StringList(), 0, "__stream", false); if(memberType->usesClasses()) { C << nl << "__stream.writePendingObjects();"; @@ -1358,7 +1363,7 @@ writeIndex(const string& n, const UnitPtr& u, const Index& index, Output& H, Out H << nl << "namespace " << *q << nl << '{'; } - writeIndexH(inputTypeToString(dataMember->type()), name, H, dllExport); + writeIndexH(inputTypeToString(dataMember->type(), false), name, H, dllExport); for(q = scope.begin(); q != scope.end(); ++q) { |