diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2006-03-29 17:30:19 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2006-03-29 17:30:19 +0000 |
commit | dc15f759734848a12e9cf55110c2f34dd510f91d (patch) | |
tree | 54d16f67b41576f98d40933cd6f235868970f520 /cpp/src | |
parent | Include fixes (diff) | |
download | ice-dc15f759734848a12e9cf55110c2f34dd510f91d.tar.bz2 ice-dc15f759734848a12e9cf55110c2f34dd510f91d.tar.xz ice-dc15f759734848a12e9cf55110c2f34dd510f91d.zip |
Added support for wstring slice metadata
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Freeze/SharedDb.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/BasicStream.cpp | 37 | ||||
-rw-r--r-- | cpp/src/Ice/StreamI.cpp | 35 | ||||
-rw-r--r-- | cpp/src/Ice/StreamI.h | 6 | ||||
-rw-r--r-- | cpp/src/Slice/CPlusPlusUtil.cpp | 144 | ||||
-rw-r--r-- | cpp/src/Slice/Grammar.y | 63 | ||||
-rw-r--r-- | cpp/src/Slice/Parser.cpp | 55 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 299 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.h | 25 | ||||
-rw-r--r-- | cpp/src/slice2cppe/Gen.cpp | 174 | ||||
-rw-r--r-- | cpp/src/slice2cppe/Gen.h | 16 | ||||
-rw-r--r-- | cpp/src/slice2freeze/Main.cpp | 98 |
12 files changed, 670 insertions, 286 deletions
diff --git a/cpp/src/Freeze/SharedDb.cpp b/cpp/src/Freeze/SharedDb.cpp index 6f65787b453..a6ba6aff82d 100644 --- a/cpp/src/Freeze/SharedDb.cpp +++ b/cpp/src/Freeze/SharedDb.cpp @@ -49,9 +49,9 @@ extern "C" static int customCompare(DB* db, const DBT* dbt1, const DBT* dbt2) { SharedDb* me = static_cast<SharedDb*>(db->app_private); - Byte* first = static_cast<Byte*>(dbt1->data); + Ice::Byte* first = static_cast<Ice::Byte*>(dbt1->data); Key k1(first, first + dbt1->size); - first = static_cast<Byte*>(dbt2->data); + first = static_cast<Ice::Byte*>(dbt2->data); Key k2(first, first + dbt2->size); return me->getKeyCompare()->compare(k1, k2); diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index fe9737f7dea..cbbc015b925 100644 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -1355,6 +1355,43 @@ IceInternal::BasicStream::read(vector<string>& v) } void +IceInternal::BasicStream::write(const wstring* begin, const wstring* end) +{ + Int sz = static_cast<Int>(end - begin); + writeSize(sz); + if(sz > 0) + { + for(int i = 0; i < sz; ++i) + { + write(begin[i]); + } + } +} + +void +IceInternal::BasicStream::read(vector<wstring>& v) +{ + Int sz; + readSize(sz); + if(sz > 0) + { + startSeq(sz, 1); + v.resize(sz); + for(int j = 0; j < sz; ++j) + { + read(v[j]); + checkSeq(); + endElement(); + } + endSeq(sz); + } + else + { + v.clear(); + } +} + +void IceInternal::BasicStream::write(const ObjectPrx& v) { _instance->proxyFactory()->proxyToStream(v, this); diff --git a/cpp/src/Ice/StreamI.cpp b/cpp/src/Ice/StreamI.cpp index b59d9a1d834..05cb4c44c3a 100644 --- a/cpp/src/Ice/StreamI.cpp +++ b/cpp/src/Ice/StreamI.cpp @@ -184,6 +184,22 @@ Ice::InputStreamI::readStringSeq() return v; } +wstring +Ice::InputStreamI::readWstring() +{ + wstring v; + _is.read(v); + return v; +} + +vector<wstring> +Ice::InputStreamI::readWstringSeq() +{ + vector<wstring> v; + _is.read(v); + return v; +} + Int Ice::InputStreamI::readSize() { @@ -429,6 +445,25 @@ Ice::OutputStreamI::writeStringSeq(const vector<string>& v) } void +Ice::OutputStreamI::writeWstring(const wstring& v) +{ + _os.write(v); +} + +void +Ice::OutputStreamI::writeWstringSeq(const vector<wstring>& v) +{ + if(v.size() == 0) + { + _os.writeSize(0); + } + else + { + _os.write(&v[0], &v[0] + v.size()); + } +} + +void Ice::OutputStreamI::writeSize(Int sz) { _os.writeSize(sz); diff --git a/cpp/src/Ice/StreamI.h b/cpp/src/Ice/StreamI.h index e7004e290b4..971f3072335 100644 --- a/cpp/src/Ice/StreamI.h +++ b/cpp/src/Ice/StreamI.h @@ -84,6 +84,9 @@ public: virtual ::std::string readString(); virtual ::std::vector< ::std::string > readStringSeq(); + virtual ::std::wstring readWstring(); + virtual ::std::vector< ::std::wstring > readWstringSeq(); + virtual ::Ice::Int readSize(); virtual ::Ice::ObjectPrx readProxy(); @@ -147,6 +150,9 @@ public: virtual void writeString(const ::std::string&); virtual void writeStringSeq(const ::std::vector< ::std::string >&); + virtual void writeWstring(const ::std::wstring&); + virtual void writeWstringSeq(const ::std::vector< ::std::wstring >&); + virtual void writeSize(::Ice::Int); virtual void writeProxy(const ::Ice::ObjectPrx&); diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index d68c0c2117a..001419d817d 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -120,7 +120,7 @@ Slice::printDllExportStuff(Output& out, const string& dllExport) } string -Slice::typeToString(const TypePtr& type, const StringList& metaData, bool inParam) +Slice::typeToString(const TypePtr& type, bool useWstring, const StringList& metaData, bool inParam) { static const char* builtinTable[] = { @@ -140,6 +140,14 @@ Slice::typeToString(const TypePtr& type, const StringList& metaData, bool inPara BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); if(builtin) { + if(builtin->kind() == Builtin::KindString) + { + string strType = findMetaData(metaData, true); + if(useWstring || strType == "wstring") + { + return "::std::wstring"; + } + } return builtinTable[builtin->kind()]; } @@ -166,7 +174,7 @@ Slice::typeToString(const TypePtr& type, const StringList& metaData, bool inPara if(inParam) { TypePtr elemType = seq->type(); - string s = typeToString(elemType); + string s = typeToString(elemType, inWstringModule(seq), seq->typeMetaData()); return "::std::pair<const " + s + "*, const " + s + "*>"; } else @@ -225,18 +233,18 @@ Slice::typeToString(const TypePtr& type, const StringList& metaData, bool inPara } string -Slice::returnTypeToString(const TypePtr& type, const StringList& metaData) +Slice::returnTypeToString(const TypePtr& type, bool useWstring, const StringList& metaData) { if(!type) { return "void"; } - return typeToString(type, metaData, false); + return typeToString(type, useWstring, metaData, false); } string -Slice::inputTypeToString(const TypePtr& type, const StringList& metaData, bool allowArray) +Slice::inputTypeToString(const TypePtr& type, bool useWstring, const StringList& metaData, bool allowArray) { static const char* inputBuiltinTable[] = { @@ -256,6 +264,14 @@ Slice::inputTypeToString(const TypePtr& type, const StringList& metaData, bool a BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); if(builtin) { + if(builtin->kind() == Builtin::KindString) + { + string strType = findMetaData(metaData, true); + if(useWstring || strType == "wstring") + { + return "const ::std::wstring&"; + } + } return inputBuiltinTable[builtin->kind()]; } @@ -289,7 +305,7 @@ Slice::inputTypeToString(const TypePtr& type, const StringList& metaData, bool a if(allowArray) { TypePtr elemType = seq->type(); - string s = typeToString(elemType); + string s = typeToString(elemType, inWstringModule(seq), seq->typeMetaData()); return "const ::std::pair<const " + s + "*, const " + s + "*>&"; } else @@ -342,7 +358,7 @@ Slice::inputTypeToString(const TypePtr& type, const StringList& metaData, bool a } string -Slice::outputTypeToString(const TypePtr& type, const StringList& metaData) +Slice::outputTypeToString(const TypePtr& type, bool useWstring, const StringList& metaData) { static const char* outputBuiltinTable[] = { @@ -362,6 +378,14 @@ Slice::outputTypeToString(const TypePtr& type, const StringList& metaData) BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); if(builtin) { + if(builtin->kind() == Builtin::KindString) + { + string strType = findMetaData(metaData, true); + if(useWstring || strType == "wstring") + { + return "::std::wstring&"; + } + } return outputBuiltinTable[builtin->kind()]; } @@ -732,13 +756,13 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& seqType = findMetaData(l, false); if(seqType.empty()) { - out << nl << typeToString(type) << " ___" << fixedParam << ";"; + out << nl << typeToString(type, false) << " ___" << fixedParam << ";"; out << nl << scope << "___" << func << (pointer ? "" : "&") << stream << ", ___" << fixedParam << ", " << scope << "__U__" << fixKwd(seq->name()) << "());"; } else { - seqType = "::std::vector< " + typeToString(seq->type()) + ">"; + seqType = "::std::vector< " + typeToString(seq->type(), false) + ">"; StringList l; l.push_back("cpp:type:" + seqType); out << nl << seqType << " ___" << fixedParam << ";"; @@ -752,7 +776,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& else if(builtin->kind() != Builtin::KindString && builtin->kind() != Builtin::KindObject && builtin->kind() != Builtin::KindObjectProxy) { - string s = typeToString(builtin); + string s = typeToString(builtin, false); if(s[0] == ':') { s = " " + s; @@ -762,7 +786,9 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& } else { - out << nl << "::std::vector< " << typeToString(seq->type()) << "> ___" << fixedParam << ";"; + out << nl << "::std::vector< " + << typeToString(seq->type(), inWstringModule(seq), seq->typeMetaData()) << "> ___" + << fixedParam << ";"; out << nl << stream << deref << func << "___" << fixedParam << ");"; } @@ -856,7 +882,7 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& { tmpParam += fixedParam; } - out << nl << typeToString(type, md) << " " << tmpParam << ";"; + out << nl << typeToString(type, false, md) << " " << tmpParam << ";"; out << nl << stream << deref << func << tmpParam << ");"; out << nl << "::std::vector< ::Ice::Byte>(" << tmpParam << ".first, " << tmpParam << ".second).swap(" << fixedParam << ");"; @@ -941,18 +967,19 @@ writeRangeAllocateCode(Output& out, const TypePtr& type, const string& fixedName { md.push_back("cpp:type:" + seqType.substr(strlen("range:"))); } - out << nl << typeToString(seq, md, false) << " ___" << fixedName << ";"; + out << nl << typeToString(seq, false, md, false) << " ___" << fixedName << ";"; } } } void Slice::writeAllocateCode(Output& out, const ParamDeclList& params, const TypePtr& ret, const StringList& metaData, - bool inParam) + bool useWstring, bool inParam) { for(ParamDeclList::const_iterator p = params.begin(); p != params.end(); ++p) { - out << nl << typeToString((*p)->type(), (*p)->getMetaData(), inParam) << ' ' << fixKwd((*p)->name()) << ';'; + out << nl << typeToString((*p)->type(), useWstring, (*p)->getMetaData(), inParam) << ' ' << fixKwd((*p)->name()) + << ';'; // // If using a range we need to allocate the range container as well now to ensure they // are always in the same scope. @@ -961,7 +988,7 @@ Slice::writeAllocateCode(Output& out, const ParamDeclList& params, const TypePtr } if(ret) { - out << nl << typeToString(ret, metaData, inParam) << " __ret;"; + out << nl << typeToString(ret, useWstring, metaData, inParam) << " __ret;"; // // If using a range we need to allocate the range container as well now to ensure they // are always in the same scope. @@ -972,7 +999,7 @@ Slice::writeAllocateCode(Output& out, const ParamDeclList& params, const TypePtr void Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& param, bool marshal, - const string& str, const StringList& metaData) + const string& str, bool useWstring, const StringList& metaData) { string fixedParam = fixKwd(param); @@ -1077,14 +1104,29 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s } case Builtin::KindString: { - if(marshal) - { - out << nl << stream << "->writeString(" << fixedParam << ");"; - } - else - { - out << nl << fixedParam << " = " << stream << "->readString();"; - } + string strType = findMetaData(metaData, true); + if(useWstring || strType == "wstring") + { + if(marshal) + { + out << nl << stream << "->writeWstring(" << fixedParam << ");"; + } + else + { + out << nl << fixedParam << " = " << stream << "->readWstring();"; + } + } + else + { + if(marshal) + { + out << nl << stream << "->writeString(" << fixedParam << ");"; + } + else + { + out << nl << fixedParam << " = " << stream << "->readString();"; + } + } break; } case Builtin::KindObject: @@ -1289,14 +1331,29 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s } case Builtin::KindString: { - if(marshal) - { - out << nl << stream << "->writeStringSeq(" << fixedParam << ");"; - } - else - { - out << nl << fixedParam << " = " << stream << "->readStringSeq();"; - } + string strType = findMetaData(seq->typeMetaData(), true); + if(useWstring || strType == "wstring") + { + if(marshal) + { + out << nl << stream << "->writeWstringSeq(" << fixedParam << ");"; + } + else + { + out << nl << fixedParam << " = " << stream << "->readWstringSeq();"; + } + } + else + { + if(marshal) + { + out << nl << stream << "->writeStringSeq(" << fixedParam << ");"; + } + else + { + out << nl << fixedParam << " = " << stream << "->readStringSeq();"; + } + } break; } case Builtin::KindObject: @@ -1401,3 +1458,24 @@ Slice::findMetaData(const StringList& metaData, bool inParam) return ""; } + +bool +Slice::inWstringModule(const SequencePtr& seq) +{ + ContainerPtr cont = seq->container(); + while(cont) + { + ModulePtr mod = ModulePtr::dynamicCast(cont); + if(!mod) + { + break; + } + StringList metaData = mod->getMetaData(); + if(find(metaData.begin(), metaData.end(), "cpp:type:wstring") != metaData.end()) + { + return true; + } + cont = mod->container(); + } + return false; +} diff --git a/cpp/src/Slice/Grammar.y b/cpp/src/Slice/Grammar.y index 8a34d51ef89..88bed0b0216 100644 --- a/cpp/src/Slice/Grammar.y +++ b/cpp/src/Slice/Grammar.y @@ -1120,21 +1120,23 @@ exception // ---------------------------------------------------------------------- sequence_def // ---------------------------------------------------------------------- -: local_qualifier ICE_SEQUENCE '<' type '>' ICE_IDENTIFIER +: local_qualifier ICE_SEQUENCE '<' meta_data type '>' ICE_IDENTIFIER { BoolTokPtr local = BoolTokPtr::dynamicCast($1); - StringTokPtr ident = StringTokPtr::dynamicCast($6); - TypePtr type = TypePtr::dynamicCast($4); + StringTokPtr ident = StringTokPtr::dynamicCast($7); + StringListTokPtr metaData = StringListTokPtr::dynamicCast($4); + TypePtr type = TypePtr::dynamicCast($5); ContainerPtr cont = unit->currentContainer(); - $$ = cont->createSequence(ident->v, type, local->v); + $$ = cont->createSequence(ident->v, type, metaData->v, local->v); } -| local_qualifier ICE_SEQUENCE '<' type '>' keyword +| local_qualifier ICE_SEQUENCE '<' meta_data type '>' keyword { BoolTokPtr local = BoolTokPtr::dynamicCast($1); - StringTokPtr ident = StringTokPtr::dynamicCast($6); - TypePtr type = TypePtr::dynamicCast($4); + StringTokPtr ident = StringTokPtr::dynamicCast($7); + StringListTokPtr metaData = StringListTokPtr::dynamicCast($4); + TypePtr type = TypePtr::dynamicCast($5); ContainerPtr cont = unit->currentContainer(); - $$ = cont->createSequence(ident->v, type, local->v); + $$ = cont->createSequence(ident->v, type, metaData->v, local->v); unit->error("keyword `" + ident->v + "' cannot be used as sequence name"); } ; @@ -1142,23 +1144,27 @@ sequence_def // ---------------------------------------------------------------------- dictionary_def // ---------------------------------------------------------------------- -: local_qualifier ICE_DICTIONARY '<' type ',' type '>' ICE_IDENTIFIER +: local_qualifier ICE_DICTIONARY '<' meta_data type ',' meta_data type '>' ICE_IDENTIFIER { BoolTokPtr local = BoolTokPtr::dynamicCast($1); - StringTokPtr ident = StringTokPtr::dynamicCast($8); - TypePtr keyType = TypePtr::dynamicCast($4); - TypePtr valueType = TypePtr::dynamicCast($6); + StringTokPtr ident = StringTokPtr::dynamicCast($10); + StringListTokPtr keyMetaData = StringListTokPtr::dynamicCast($4); + TypePtr keyType = TypePtr::dynamicCast($5); + StringListTokPtr valueMetaData = StringListTokPtr::dynamicCast($7); + TypePtr valueType = TypePtr::dynamicCast($8); ContainerPtr cont = unit->currentContainer(); - $$ = cont->createDictionary(ident->v, keyType, valueType, local->v); + $$ = cont->createDictionary(ident->v, keyType, keyMetaData->v, valueType, valueMetaData->v, local->v); } -| local_qualifier ICE_DICTIONARY '<' type ',' type '>' keyword +| local_qualifier ICE_DICTIONARY '<' meta_data type ',' meta_data type '>' keyword { BoolTokPtr local = BoolTokPtr::dynamicCast($1); - StringTokPtr ident = StringTokPtr::dynamicCast($8); - TypePtr keyType = TypePtr::dynamicCast($4); - TypePtr valueType = TypePtr::dynamicCast($6); + StringTokPtr ident = StringTokPtr::dynamicCast($10); + StringListTokPtr keyMetaData = StringListTokPtr::dynamicCast($4); + TypePtr keyType = TypePtr::dynamicCast($5); + StringListTokPtr valueMetaData = StringListTokPtr::dynamicCast($7); + TypePtr valueType = TypePtr::dynamicCast($8); ContainerPtr cont = unit->currentContainer(); - $$ = cont->createDictionary(ident->v, keyType, valueType, local->v); + $$ = cont->createDictionary(ident->v, keyType, keyMetaData->v, valueType, valueMetaData->v, local->v); unit->error("keyword `" + ident->v + "' cannot be used as dictionary name"); } ; @@ -1626,19 +1632,22 @@ const_initializer // ---------------------------------------------------------------------- const_def // ---------------------------------------------------------------------- -: ICE_CONST type ICE_IDENTIFIER '=' const_initializer +: ICE_CONST meta_data type ICE_IDENTIFIER '=' const_initializer { - TypePtr const_type = TypePtr::dynamicCast($2); - StringTokPtr ident = StringTokPtr::dynamicCast($3); - SyntaxTreeBaseStringTokPtr value = SyntaxTreeBaseStringTokPtr::dynamicCast($5); - $$ = unit->currentContainer()->createConst(ident->v, const_type, value->v.first, value->v.second); + StringListTokPtr metaData = StringListTokPtr::dynamicCast($2); + TypePtr const_type = TypePtr::dynamicCast($3); + StringTokPtr ident = StringTokPtr::dynamicCast($4); + SyntaxTreeBaseStringTokPtr value = SyntaxTreeBaseStringTokPtr::dynamicCast($6); + $$ = unit->currentContainer()->createConst(ident->v, const_type, metaData->v, value->v.first, value->v.second); } -| ICE_CONST type '=' const_initializer +| ICE_CONST meta_data type '=' const_initializer { - TypePtr const_type = TypePtr::dynamicCast($2); - SyntaxTreeBaseStringTokPtr value = SyntaxTreeBaseStringTokPtr::dynamicCast($4); + StringListTokPtr metaData = StringListTokPtr::dynamicCast($2); + TypePtr const_type = TypePtr::dynamicCast($3); + SyntaxTreeBaseStringTokPtr value = SyntaxTreeBaseStringTokPtr::dynamicCast($5); unit->error("missing constant name"); - $$ = unit->currentContainer()->createConst(IceUtil::generateUUID(), const_type, value->v.first, value->v.second); + $$ = unit->currentContainer()->createConst(IceUtil::generateUUID(), const_type, metaData->v, value->v.first, + value->v.second); } ; diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 260e6a8ffe7..5b54e2a0c38 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -765,7 +765,7 @@ Slice::Container::createStruct(const string& name, bool local) } SequencePtr -Slice::Container::createSequence(const string& name, const TypePtr& type, bool local) +Slice::Container::createSequence(const string& name, const TypePtr& type, const StringList& metaData, bool local) { checkPrefix(name); @@ -819,13 +819,14 @@ Slice::Container::createSequence(const string& name, const TypePtr& type, bool l _unit->error(msg); } - SequencePtr p = new Sequence(this, name, type, local); + SequencePtr p = new Sequence(this, name, type, metaData, local); _contents.push_back(p); return p; } DictionaryPtr -Slice::Container::createDictionary(const string& name, const TypePtr& keyType, const TypePtr& valueType, bool local) +Slice::Container::createDictionary(const string& name, const TypePtr& keyType, const StringList& keyMetaData, + const TypePtr& valueType, const StringList& valueMetaData, bool local) { checkPrefix(name); @@ -890,7 +891,7 @@ Slice::Container::createDictionary(const string& name, const TypePtr& keyType, c } } - DictionaryPtr p = new Dictionary(this, name, keyType, valueType, local); + DictionaryPtr p = new Dictionary(this, name, keyType, keyMetaData, valueType, valueMetaData, local); _contents.push_back(p); return p; } @@ -974,7 +975,7 @@ Slice::Container::createEnumerator(const string& name) } ConstPtr -Slice::Container::createConst(const string name, const TypePtr& constType, +Slice::Container::createConst(const string name, const TypePtr& constType, const StringList& metaData, const SyntaxTreeBasePtr& literalType, const string& value) { checkPrefix(name); @@ -1033,7 +1034,7 @@ Slice::Container::createConst(const string name, const TypePtr& constType, return 0; } - ConstPtr p = new Const(this, name, constType, value); + ConstPtr p = new Const(this, name, constType, metaData, value); _contents.push_back(p); return p; } @@ -3591,6 +3592,12 @@ Slice::Sequence::type() const return _type; } +StringList +Slice::Sequence::typeMetaData() const +{ + return _typeMetaData; +} + Contained::ContainedType Slice::Sequence::containedType() const { @@ -3650,12 +3657,14 @@ Slice::Sequence::recDependencies(set<ConstructedPtr>& dependencies) } } -Slice::Sequence::Sequence(const ContainerPtr& container, const string& name, const TypePtr& type, bool local) : +Slice::Sequence::Sequence(const ContainerPtr& container, const string& name, const TypePtr& type, + const StringList& typeMetaData, bool local) : SyntaxTreeBase(container->unit()), Type(container->unit()), Contained(container, name), Constructed(container, name, local), - _type(type) + _type(type), + _typeMetaData(typeMetaData) { } @@ -3675,6 +3684,18 @@ Slice::Dictionary::valueType() const return _valueType; } +StringList +Slice::Dictionary::keyMetaData() const +{ + return _keyMetaData; +} + +StringList +Slice::Dictionary::valueMetaData() const +{ + return _valueMetaData; +} + Contained::ContainedType Slice::Dictionary::containedType() const { @@ -3821,13 +3842,16 @@ Slice::Dictionary::legalKeyType(const TypePtr& type) } Slice::Dictionary::Dictionary(const ContainerPtr& container, const string& name, const TypePtr& keyType, - const TypePtr& valueType, bool local) : + const StringList& keyMetaData, const TypePtr& valueType, + const StringList& valueMetaData, bool local) : SyntaxTreeBase(container->unit()), Type(container->unit()), Contained(container, name), Constructed(container, name, local), _keyType(keyType), - _valueType(valueType) + _valueType(valueType), + _keyMetaData(keyMetaData), + _valueMetaData(valueMetaData) { } @@ -3967,6 +3991,12 @@ Slice::Const::type() const return _type; } +StringList +Slice::Const::typeMetaData() const +{ + return _typeMetaData; +} + string Slice::Const::value() const { @@ -4195,11 +4225,12 @@ Slice::Const::isInRange(const string& name, const TypePtr& constType, const stri return true; // Everything else is either in range or doesn't need checking. } -Slice::Const::Const(const ContainerPtr& container, const string& name, - const TypePtr& type, const string& value) : +Slice::Const::Const(const ContainerPtr& container, const string& name, const TypePtr& type, + const StringList& typeMetaData, const string& value) : SyntaxTreeBase(container->unit()), Contained(container, name), _type(type), + _typeMetaData(typeMetaData), _value(value) { } diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index c256f58c8da..9d9d59b8ae5 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -408,13 +408,15 @@ Slice::Gen::GlobalIncludeVisitor::visitModuleStart(const ModulePtr& p) } Slice::Gen::TypesVisitor::TypesVisitor(Output& h, Output& c, const string& dllExport, bool stream) : - H(h), C(c), _dllExport(dllExport), _stream(stream), _doneStaticSymbol(false) + H(h), C(c), _dllExport(dllExport), _stream(stream), _doneStaticSymbol(false), _useWstring(false) { } bool Slice::Gen::TypesVisitor::visitModuleStart(const ModulePtr& p) { + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -426,6 +428,8 @@ void Slice::Gen::TypesVisitor::visitModuleEnd(const ModulePtr& p) { H << sp << nl << '}'; + + _useWstring = resetUseWstring(_useWstringHist); } bool @@ -437,6 +441,8 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr&) bool Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) { + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); string scoped = fixKwd(p->scoped()); ExceptionPtr base = p->base(); @@ -457,7 +463,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q) { - string typeName = inputTypeToString((*q)->type(), (*q)->getMetaData()); + string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData()); allTypes.push_back(typeName); allParamDecls.push_back(typeName + " __ice_" + (*q)->name()); } @@ -685,7 +691,8 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) C << nl << "__outS->startSlice();"; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", (*q)->getMetaData()); + writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", _useWstring, + (*q)->getMetaData()); } C << nl << "__outS->endSlice();"; if(base) @@ -704,7 +711,8 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) C << nl << "__inS->startSlice();"; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", (*q)->getMetaData()); + writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", _useWstring, + (*q)->getMetaData()); } C << nl << "__inS->endSlice();"; if(base) @@ -804,11 +812,15 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) H << sp << nl << "static " << name << " __" << p->name() << "_init;"; } } + + _useWstring = resetUseWstring(_useWstringHist); } bool Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) { + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "struct " << name; @@ -916,7 +928,8 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) C << sb; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", (*q)->getMetaData()); + writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", _useWstring, + (*q)->getMetaData()); } C << eb; @@ -924,7 +937,8 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) C << sb; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", (*q)->getMetaData()); + writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", _useWstring, + (*q)->getMetaData()); } C << eb; } @@ -950,13 +964,15 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) C << nl << "__v.__read(__inS);"; C << eb; } + + _useWstring = resetUseWstring(_useWstringHist); } void Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) { string name = fixKwd(p->name()); - string s = typeToString(p->type(), p->getMetaData()); + string s = typeToString(p->type(), _useWstring, p->getMetaData()); H << nl << s << ' ' << name << ';'; } @@ -965,7 +981,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) { string name = fixKwd(p->name()); TypePtr type = p->type(); - string s = typeToString(type); + string s = typeToString(type, _useWstring, p->typeMetaData()); StringList metaData = p->getMetaData(); string seqType = findMetaData(metaData, false); if(!seqType.empty()) @@ -1066,7 +1082,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) C << nl << scoped << "::const_iterator p;"; C << nl << "for(p = v.begin(); p != v.end(); ++p)"; C << sb; - writeStreamMarshalUnmarshalCode(C, type, "(*p)", true); + writeStreamMarshalUnmarshalCode(C, type, "(*p)", true, "", _useWstring); C << eb; C << eb; @@ -1078,7 +1094,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) C << nl << scoped << "::iterator p;"; C << nl << "for(p = v.begin(); p != v.end(); ++p)"; C << sb; - writeStreamMarshalUnmarshalCode(C, type, "(*p)", false); + writeStreamMarshalUnmarshalCode(C, type, "(*p)", false, "", _useWstring); C << eb; C << eb; } @@ -1164,7 +1180,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) C << nl << scoped << "::const_iterator p;"; C << nl << "for(p = v.begin(); p != v.end(); ++p)"; C << sb; - writeStreamMarshalUnmarshalCode(C, type, "(*p)", true); + writeStreamMarshalUnmarshalCode(C, type, "(*p)", true, "", _useWstring); C << eb; C << eb; @@ -1175,7 +1191,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) C << nl << "v.resize(sz);"; C << nl << "for(int i = 0; i < sz; ++i)"; C << sb; - writeStreamMarshalUnmarshalCode(C, type, "v[i]", false); + writeStreamMarshalUnmarshalCode(C, type, "v[i]", false, "", _useWstring); C << eb; C << eb; } @@ -1189,12 +1205,12 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) string name = fixKwd(p->name()); TypePtr keyType = p->keyType(); TypePtr valueType = p->valueType(); - string ks = typeToString(keyType); + string ks = typeToString(keyType, _useWstring, p->keyMetaData()); if(ks[0] == ':') { ks.insert(0, " "); } - string vs = typeToString(valueType); + string vs = typeToString(valueType, _useWstring, p->valueMetaData()); H << sp << nl << "typedef ::std::map<" << ks << ", " << vs << "> " << name << ';'; if(!p->isLocal()) @@ -1251,8 +1267,8 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) C << nl << scoped << "::const_iterator p;"; C << nl << "for(p = v.begin(); p != v.end(); ++p)"; C << sb; - writeStreamMarshalUnmarshalCode(C, keyType, "p->first", true); - writeStreamMarshalUnmarshalCode(C, valueType, "p->second", true); + writeStreamMarshalUnmarshalCode(C, keyType, "p->first", true, "", _useWstring, p->keyMetaData()); + writeStreamMarshalUnmarshalCode(C, valueType, "p->second", true, "", _useWstring, p->valueMetaData()); C << eb; C << eb; @@ -1263,9 +1279,9 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) C << nl << "while(sz--)"; C << sb; C << nl << "::std::pair<const " << ks << ", " << vs << "> pair;"; - writeStreamMarshalUnmarshalCode(C, keyType, pf, false); + writeStreamMarshalUnmarshalCode(C, keyType, pf, false, "", _useWstring, p->keyMetaData()); C << nl << scoped << "::iterator __i = v.insert(v.end(), pair);"; - writeStreamMarshalUnmarshalCode(C, valueType, "__i->second", false); + writeStreamMarshalUnmarshalCode(C, valueType, "__i->second", false, "", _useWstring, p->valueMetaData()); C << eb; C << eb; } @@ -1394,7 +1410,8 @@ void Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) { H << sp; - H << nl << "const " << typeToString(p->type()) << " " << fixKwd(p->name()) << " = "; + H << nl << "const " << typeToString(p->type(), _useWstring, p->typeMetaData()) << " " << fixKwd(p->name()) + << " = "; BuiltinPtr bp = BuiltinPtr::dynamicCast(p->type()); if(bp && bp->kind() == Builtin::KindString) @@ -1409,6 +1426,10 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) "_{}[]#()<>%:;.?*+-/^&|~!=,\\\"' "; static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end()); + if(_useWstring || findMetaData(p->typeMetaData(), true) == "wstring") + { + H << 'L'; + } H << "\""; // Opening " const string val = p->value(); @@ -1531,7 +1552,7 @@ Slice::Gen::ProxyDeclVisitor::visitClassDecl(const ClassDeclPtr& p) } Slice::Gen::ProxyVisitor::ProxyVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport) + H(h), C(c), _dllExport(dllExport), _useWstring(false) { } @@ -1562,6 +1583,8 @@ Slice::Gen::ProxyVisitor::visitModuleStart(const ModulePtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -1573,6 +1596,8 @@ void Slice::Gen::ProxyVisitor::visitModuleEnd(const ModulePtr& p) { H << sp << nl << '}'; + + _useWstring = resetUseWstring(_useWstringHist); } bool @@ -1583,6 +1608,8 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); string scoped = fixKwd(p->scoped()); ClassList bases = p->bases(); @@ -1668,6 +1695,8 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p) C << nl << "return static_cast<const ::IceProxy::Ice::Object&>(l) < " << "static_cast<const ::IceProxy::Ice::Object&>(r);"; C << eb; + + _useWstring = resetUseWstring(_useWstringHist); } void @@ -1678,7 +1707,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) string scope = fixKwd(p->scope()); TypePtr ret = p->returnType(); - string retS = returnTypeToString(ret, p->getMetaData()); + string retS = returnTypeToString(ret, _useWstring, p->getMetaData()); vector<string> params; vector<string> paramsDecl; @@ -1701,15 +1730,15 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) string typeString; if((*q)->isOutParam()) { - typeString = outputTypeToString((*q)->type(), metaData); + typeString = outputTypeToString((*q)->type(), _useWstring, metaData); } else { - typeString = inputTypeToString((*q)->type(), metaData); + typeString = inputTypeToString((*q)->type(), _useWstring, metaData); } #else - string typeString = (*q)->isOutParam() ? - outputTypeToString((*q)->type(), metaData) : inputTypeToString((*q)->type(), metaData); + string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), _useWstring, metaData) + : inputTypeToString((*q)->type(), _useWstring, metaData); #endif params.push_back(typeString); @@ -1718,7 +1747,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) if(!(*q)->isOutParam()) { - string inputTypeString = inputTypeToString((*q)->type(), metaData); + string inputTypeString = inputTypeToString((*q)->type(), _useWstring, metaData); paramsAMI.push_back(inputTypeString); paramsDeclAMI.push_back(inputTypeString + ' ' + paramName); @@ -1791,9 +1820,9 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) string classScope = fixKwd(cl->scope()); string classScopedAMI = classScope + classNameAMI; - H << nl << "void " << name << "_async" << spar << ("const" + classScopedAMI + '_' + name + "Ptr&") + H << nl << "void " << name << "_async" << spar << ("const " + classScopedAMI + '_' + name + "Ptr&") << paramsAMI << epar << ';'; - H << nl << "void " << name << "_async" << spar << ("const" + classScopedAMI + '_' + name + "Ptr&") + H << nl << "void " << name << "_async" << spar << ("const " + classScopedAMI + '_' + name + "Ptr&") << paramsAMI << "const ::Ice::Context&" << epar << ';'; C << sp << nl << "void" << nl << "IceProxy" << scope << name << "_async" << spar @@ -1812,7 +1841,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) } Slice::Gen::DelegateVisitor::DelegateVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport) + H(h), C(c), _dllExport(dllExport), _useWstring(false) { } @@ -1843,6 +1872,8 @@ Slice::Gen::DelegateVisitor::visitModuleStart(const ModulePtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -1854,6 +1885,8 @@ void Slice::Gen::DelegateVisitor::visitModuleEnd(const ModulePtr& p) { H << sp << nl << '}'; + + _useWstring = resetUseWstring(_useWstringHist); } bool @@ -1864,6 +1897,8 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); ClassList bases = p->bases(); @@ -1898,6 +1933,8 @@ void Slice::Gen::DelegateVisitor::visitClassDefEnd(const ClassDefPtr& p) { H << eb << ';'; + + _useWstring = resetUseWstring(_useWstringHist); } void @@ -1906,7 +1943,7 @@ Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p) string name = fixKwd(p->name()); TypePtr ret = p->returnType(); - string retS = returnTypeToString(ret, p->getMetaData()); + string retS = returnTypeToString(ret, _useWstring, p->getMetaData()); vector<string> params; @@ -1921,15 +1958,15 @@ Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p) string typeString; if((*q)->isOutParam()) { - typeString = outputTypeToString((*q)->type(), metaData); + typeString = outputTypeToString((*q)->type(), _useWstring, metaData); } else { - typeString = inputTypeToString((*q)->type(), metaData); + typeString = inputTypeToString((*q)->type(), _useWstring, metaData); } #else - string typeString = (*q)->isOutParam() ? - outputTypeToString((*q)->type(), metaData) : inputTypeToString((*q)->type(), metaData); + string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), _useWstring, metaData) + : inputTypeToString((*q)->type(), _useWstring, metaData); #endif params.push_back(typeString); @@ -1941,7 +1978,7 @@ Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p) } Slice::Gen::DelegateMVisitor::DelegateMVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport) + H(h), C(c), _dllExport(dllExport), _useWstring(false) { } @@ -1972,6 +2009,8 @@ Slice::Gen::DelegateMVisitor::visitModuleStart(const ModulePtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -1983,6 +2022,8 @@ void Slice::Gen::DelegateMVisitor::visitModuleEnd(const ModulePtr& p) { H << sp << nl << '}'; + + _useWstring = resetUseWstring(_useWstringHist); } bool @@ -1993,6 +2034,8 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); string scoped = fixKwd(p->scoped()); ClassList bases = p->bases(); @@ -2029,6 +2072,8 @@ void Slice::Gen::DelegateMVisitor::visitClassDefEnd(const ClassDefPtr& p) { H << eb << ';'; + + _useWstring = resetUseWstring(_useWstringHist); } void @@ -2038,7 +2083,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) string scoped = fixKwd(p->scoped()); TypePtr ret = p->returnType(); - string retS = returnTypeToString(ret, p->getMetaData()); + string retS = returnTypeToString(ret, _useWstring, p->getMetaData()); vector<string> params; vector<string> paramsDecl; @@ -2056,12 +2101,12 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) if(isOutParam) { outParams.push_back(*q); - typeString = outputTypeToString(type, metaData); + typeString = outputTypeToString(type, _useWstring, metaData); } else { inParams.push_back(*q); - typeString = inputTypeToString(type, metaData); + typeString = inputTypeToString(type, _useWstring, metaData); } params.push_back(typeString); @@ -2150,7 +2195,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) C << eb; C << eb; - writeAllocateCode(C, ParamDeclList(), ret, p->getMetaData()); + writeAllocateCode(C, ParamDeclList(), ret, p->getMetaData(), _useWstring); writeUnmarshalCode(C, outParams, ret, p->getMetaData()); if(p->returnsClasses()) { @@ -2169,7 +2214,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) } Slice::Gen::DelegateDVisitor::DelegateDVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport) + H(h), C(c), _dllExport(dllExport), _useWstring(false) { } @@ -2200,6 +2245,8 @@ Slice::Gen::DelegateDVisitor::visitModuleStart(const ModulePtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -2211,6 +2258,8 @@ void Slice::Gen::DelegateDVisitor::visitModuleEnd(const ModulePtr& p) { H << sp << nl << '}'; + + _useWstring = resetUseWstring(_useWstringHist); } bool @@ -2221,6 +2270,8 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); string scoped = fixKwd(p->scoped()); ClassList bases = p->bases(); @@ -2257,6 +2308,8 @@ void Slice::Gen::DelegateDVisitor::visitClassDefEnd(const ClassDefPtr& p) { H << eb << ';'; + + _useWstring = resetUseWstring(_useWstringHist); } void @@ -2266,7 +2319,7 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) string scoped = fixKwd(p->scoped()); TypePtr ret = p->returnType(); - string retS = returnTypeToString(ret, p->getMetaData()); + string retS = returnTypeToString(ret, _useWstring, p->getMetaData()); vector<string> params; vector<string> paramsDecl; @@ -2285,15 +2338,15 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) string typeString; if((*q)->isOutParam()) { - typeString = outputTypeToString((*q)->type(), metaData); + typeString = outputTypeToString((*q)->type(), _useWstring, metaData); } else { - typeString = inputTypeToString((*q)->type(), metaData); + typeString = inputTypeToString((*q)->type(), _useWstring, metaData); } #else - string typeString = (*q)->isOutParam() ? - outputTypeToString((*q)->type(), metaData) : inputTypeToString((*q)->type(), metaData); + string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), _useWstring, metaData) + : inputTypeToString((*q)->type(), _useWstring, metaData); #endif params.push_back(typeString); @@ -2403,7 +2456,7 @@ Slice::Gen::ObjectDeclVisitor::visitClassDecl(const ClassDeclPtr& p) } Slice::Gen::ObjectVisitor::ObjectVisitor(Output& h, Output& c, const string& dllExport, bool stream) : - H(h), C(c), _dllExport(dllExport), _stream(stream), _doneStaticSymbol(false) + H(h), C(c), _dllExport(dllExport), _stream(stream), _doneStaticSymbol(false), _useWstring(false) { } @@ -2415,6 +2468,8 @@ Slice::Gen::ObjectVisitor::visitModuleStart(const ModulePtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -2427,11 +2482,15 @@ Slice::Gen::ObjectVisitor::visitModuleEnd(const ModulePtr& p) { H << sp; H << nl << '}'; + + _useWstring = resetUseWstring(_useWstringHist); } bool Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) { + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); string scoped = fixKwd(p->scoped()); ClassList bases = p->bases(); @@ -2493,7 +2552,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q) { - string typeName = inputTypeToString((*q)->type(), (*q)->getMetaData()); + string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData()); allTypes.push_back(typeName); allParamDecls.push_back(typeName + " __ice_" + (*q)->name()); } @@ -2869,7 +2928,8 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) C << nl << "__outS->startSlice();"; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", (*q)->getMetaData()); + writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", _useWstring, + (*q)->getMetaData()); } C << nl << "__outS->endSlice();"; emitUpcall(base, "::__write(__outS);"); @@ -2884,7 +2944,8 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) C << nl << "__inS->startSlice();"; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", (*q)->getMetaData()); + writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", _useWstring, + (*q)->getMetaData()); } C << nl << "__inS->endSlice();"; emitUpcall(base, "::__read(__inS, true);"); @@ -3043,6 +3104,8 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) C << nl << "return static_cast<const ::Ice::Object&>(l) < static_cast<const ::Ice::Object&>(r);"; C << eb; } + + _useWstring = resetUseWstring(_useWstringHist); } bool @@ -3065,7 +3128,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) string scope = fixKwd(p->scope()); TypePtr ret = p->returnType(); - string retS = returnTypeToString(ret, p->getMetaData()); + string retS = returnTypeToString(ret, _useWstring, p->getMetaData()); string params = "("; string paramsDecl = "("; @@ -3093,12 +3156,12 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) if(isOutParam) { outParams.push_back(*q); - typeString = outputTypeToString(type, (*q)->getMetaData()); + typeString = outputTypeToString(type, _useWstring, (*q)->getMetaData()); } else { inParams.push_back(*q); - typeString = inputTypeToString((*q)->type(), (*q)->getMetaData()); + typeString = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData()); } if(q != paramList.begin()) @@ -3209,13 +3272,13 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) { C << nl << "::IceInternal::BasicStream* __os = __inS.os();"; } - writeAllocateCode(C, inParams, 0, StringList(), true); + writeAllocateCode(C, inParams, 0, StringList(), _useWstring, true); writeUnmarshalCode(C, inParams, 0, StringList(), true); if(p->sendsClasses()) { C << nl << "__is->readPendingObjects();"; } - writeAllocateCode(C, outParams, 0, StringList()); + writeAllocateCode(C, outParams, 0, StringList(), _useWstring); if(!throws.empty()) { C << nl << "try"; @@ -3255,7 +3318,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) { C << nl << "::IceInternal::BasicStream* __is = __inS.is();"; } - writeAllocateCode(C, inParams, 0, StringList(), true); + writeAllocateCode(C, inParams, 0, StringList(), _useWstring, true); writeUnmarshalCode(C, inParams, 0, StringList(), true); if(p->sendsClasses()) { @@ -3289,7 +3352,7 @@ void Slice::Gen::ObjectVisitor::visitDataMember(const DataMemberPtr& p) { string name = fixKwd(p->name()); - string s = typeToString(p->type(), p->getMetaData()); + string s = typeToString(p->type(), _useWstring, p->getMetaData()); H << nl << s << ' ' << name << ';'; } @@ -3588,7 +3651,7 @@ Slice::Gen::ObjectVisitor::emitOneShotConstructor(const ClassDefPtr& p) for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q) { - string typeName = inputTypeToString((*q)->type(), (*q)->getMetaData()); + string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData()); allParamDecls.push_back(typeName + " __ice_" + (*q)->name()); } @@ -3886,14 +3949,14 @@ Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p) Slice::Gen::ImplVisitor::ImplVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport) + H(h), C(c), _dllExport(dllExport), _useWstring(false) { } void Slice::Gen::ImplVisitor::writeDecl(Output& out, const string& name, const TypePtr& type, const StringList& metaData) { - out << nl << typeToString(type, metaData) << ' ' << name; + out << nl << typeToString(type, _useWstring, metaData) << ' ' << name; BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); if(builtin) @@ -4014,7 +4077,7 @@ Slice::Gen::ImplVisitor::writeReturn(Output& out, const TypePtr& type, const Str SequencePtr seq = SequencePtr::dynamicCast(type); if(seq) { - out << nl << "return " << typeToString(seq, metaData) << "();"; + out << nl << "return " << typeToString(seq, _useWstring, metaData) << "();"; } else { @@ -4037,6 +4100,8 @@ Slice::Gen::ImplVisitor::visitModuleStart(const ModulePtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -4049,6 +4114,8 @@ Slice::Gen::ImplVisitor::visitModuleEnd(const ModulePtr& p) { H << sp; H << nl << '}'; + + _useWstring = resetUseWstring(_useWstringHist); } bool @@ -4059,6 +4126,8 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = p->name(); string scope = fixKwd(p->scope()); string cls = scope.substr(2) + name + "I"; @@ -4103,7 +4172,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) string opName = op->name(); TypePtr ret = op->returnType(); - string retS = returnTypeToString(ret, op->getMetaData()); + string retS = returnTypeToString(ret, _useWstring, op->getMetaData()); if(!p->isLocal() && (p->hasMetaData("amd") || op->hasMetaData("amd"))) { @@ -4116,7 +4185,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) { if(!(*q)->isOutParam()) { - H << ',' << nl << inputTypeToString((*q)->type(), (*q)->getMetaData()); + H << ',' << nl << inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData()); } } H << ',' << nl << "const Ice::Current&"; @@ -4133,7 +4202,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) { if(!(*q)->isOutParam()) { - C << ',' << nl << inputTypeToString((*q)->type(), (*q)->getMetaData()) << ' ' + C << ',' << nl << inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData()) << ' ' << fixKwd((*q)->name()); } } @@ -4203,15 +4272,15 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) string typeString; if((*q)->isOutParam()) { - typeString = outputTypeToString((*q)->type(), metaData); + typeString = outputTypeToString((*q)->type(), _useWstring, metaData); } else { - typeString = inputTypeToString((*q)->type(), metaData); + typeString = inputTypeToString((*q)->type(), _useWstring, metaData); } #else - string typeString = (*q)->isOutParam() ? - outputTypeToString((*q)->type(), metaData) : inputTypeToString((*q)->type(), metaData); + string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), _useWstring, metaData) + : inputTypeToString((*q)->type(), _useWstring, metaData); #endif H << typeString; } @@ -4246,15 +4315,15 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) string typeString; if((*q)->isOutParam()) { - typeString = outputTypeToString((*q)->type(), metaData); + typeString = outputTypeToString((*q)->type(), _useWstring, metaData); } else { - typeString = inputTypeToString((*q)->type(), metaData); + typeString = inputTypeToString((*q)->type(), _useWstring, metaData); } #else - string typeString = (*q)->isOutParam() ? - outputTypeToString((*q)->type(), metaData) : inputTypeToString((*q)->type(), metaData); + string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), _useWstring, metaData) + : inputTypeToString((*q)->type(), _useWstring, metaData); #endif C << typeString << ' ' << fixKwd((*q)->name()); } @@ -4282,11 +4351,13 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) H << eb << ';'; + _useWstring = resetUseWstring(_useWstringHist); + return true; } Slice::Gen::AsyncVisitor::AsyncVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport) + H(h), C(c), _dllExport(dllExport), _useWstring(false) { } @@ -4298,6 +4369,8 @@ Slice::Gen::AsyncVisitor::visitModuleStart(const ModulePtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -4309,6 +4382,21 @@ void Slice::Gen::AsyncVisitor::visitModuleEnd(const ModulePtr& p) { H << sp << nl << '}'; + + _useWstring = resetUseWstring(_useWstringHist); +} + +bool +Slice::Gen::AsyncVisitor::visitClassDefStart(const ClassDefPtr& p) +{ + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + return true; +} + +void +Slice::Gen::AsyncVisitor::visitClassDefEnd(const ClassDefPtr&) +{ + _useWstring = resetUseWstring(_useWstringHist); } void @@ -4345,12 +4433,12 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) paramsDeclInvoke.push_back("const " + proxyName + "& __prx"); TypePtr ret = p->returnType(); - string retS = inputTypeToString(ret, p->getMetaData()); + string retS = inputTypeToString(ret, _useWstring, p->getMetaData()); if(ret) { params.push_back(retS); - paramsAMD.push_back(inputTypeToString(ret, p->getMetaData(), false)); + paramsAMD.push_back(inputTypeToString(ret, _useWstring, p->getMetaData(), false)); paramsDecl.push_back(retS + " __ret"); args.push_back("__ret"); } @@ -4362,12 +4450,12 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) { string paramName = fixKwd((*q)->name()); TypePtr type = (*q)->type(); - string typeString = inputTypeToString(type, (*q)->getMetaData()); + string typeString = inputTypeToString(type, _useWstring, (*q)->getMetaData()); if((*q)->isOutParam()) { params.push_back(typeString); - paramsAMD.push_back(inputTypeToString(type, (*q)->getMetaData(), false)); + paramsAMD.push_back(inputTypeToString(type, _useWstring, (*q)->getMetaData(), false)); paramsDecl.push_back(typeString + ' ' + paramName); args.push_back(paramName); @@ -4435,7 +4523,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) C << sp << nl << "void" << nl << classScopedAMI.substr(2) << '_' << name << "::__response(bool __ok)"; C << sb; - writeAllocateCode(C, outParams, ret, p->getMetaData(), true); + writeAllocateCode(C, outParams, ret, p->getMetaData(), _useWstring, true); C << nl << "try"; C << sb; C << nl << "if(!__ok)"; @@ -4510,7 +4598,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) } Slice::Gen::AsyncImplVisitor::AsyncImplVisitor(Output& h, Output& c, const string& dllExport) : - H(h), C(c), _dllExport(dllExport) + H(h), C(c), _dllExport(dllExport), _useWstring(false) { } @@ -4541,6 +4629,8 @@ Slice::Gen::AsyncImplVisitor::visitModuleStart(const ModulePtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -4552,6 +4642,21 @@ void Slice::Gen::AsyncImplVisitor::visitModuleEnd(const ModulePtr& p) { H << sp << nl << '}'; + + _useWstring = resetUseWstring(_useWstringHist); +} + +bool +Slice::Gen::AsyncImplVisitor::visitClassDefStart(const ClassDefPtr& p) +{ + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + return true; +} + +void +Slice::Gen::AsyncImplVisitor::visitClassDefEnd(const ClassDefPtr&) +{ + _useWstring = resetUseWstring(_useWstringHist); } void @@ -4592,7 +4697,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) #endif TypePtr ret = p->returnType(); - string retS = inputTypeToString(ret, p->getMetaData(), false); + string retS = inputTypeToString(ret, _useWstring, p->getMetaData(), false); if(ret) { @@ -4611,7 +4716,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p) { string paramName = fixKwd((*q)->name()); TypePtr type = (*q)->type(); - string typeString = inputTypeToString(type, (*q)->getMetaData(), false); + string typeString = inputTypeToString(type, _useWstring, (*q)->getMetaData(), false); if(ret || !outParams.empty()) { @@ -4898,9 +5003,21 @@ Slice::Gen::MetaDataVisitor::validate(const SyntaxTreeBasePtr& cont, const Strin { if(s.find(prefix) == 0) { + string ss = s.substr(prefix.size()); + if(ss.find("type:wstring") == 0) + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(cont); + ModulePtr module = ModulePtr::dynamicCast(cont); + ClassDefPtr clss = ClassDefPtr::dynamicCast(cont); + StructPtr strct = StructPtr::dynamicCast(cont); + ExceptionPtr exception = ExceptionPtr::dynamicCast(cont); + if((builtin && builtin->kind() == Builtin::KindString) || module || clss || strct || exception) + { + continue; + } + } if(SequencePtr::dynamicCast(cont)) { - string ss = s.substr(prefix.size()); if(ss.find("type:") == 0 || (inParam && (ss == "array" || ss.find("range") == 0))) { continue; @@ -4912,3 +5029,23 @@ Slice::Gen::MetaDataVisitor::validate(const SyntaxTreeBasePtr& cont, const Strin } } } + +bool +Slice::Gen::setUseWstring(ContainedPtr p, list<bool>& hist, bool use) +{ + hist.push_back(use); + if(!use) + { + StringList metaData = p->getMetaData(); + use = find(metaData.begin(), metaData.end(), "cpp:type:wstring") != metaData.end(); + } + return use; +} + +bool +Slice::Gen::resetUseWstring(list<bool>& hist) +{ + bool use = hist.back(); + hist.pop_back(); + return use; +} diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index dd7958ae37d..bcbf8fae9ae 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -37,6 +37,9 @@ public: bool operator!() const; // Returns true if there was a constructor error void generate(const UnitPtr&); + + static bool setUseWstring(ContainedPtr, std::list<bool>&, bool); + static bool resetUseWstring(std::list<bool>&); private: @@ -103,6 +106,8 @@ private: std::string _dllExport; bool _stream; bool _doneStaticSymbol; + bool _useWstring; + std::list<bool> _useWstringHist; }; class ProxyDeclVisitor : private ::IceUtil::noncopyable, public ParserVisitor @@ -145,6 +150,8 @@ private: ::IceUtil::Output& C; std::string _dllExport; + bool _useWstring; + std::list<bool> _useWstringHist; }; class DelegateVisitor : private ::IceUtil::noncopyable, public ParserVisitor @@ -167,6 +174,8 @@ private: ::IceUtil::Output& C; std::string _dllExport; + bool _useWstring; + std::list<bool> _useWstringHist; }; class DelegateMVisitor : private ::IceUtil::noncopyable, public ParserVisitor @@ -189,6 +198,8 @@ private: ::IceUtil::Output& C; std::string _dllExport; + bool _useWstring; + std::list<bool> _useWstringHist; }; class DelegateDVisitor : private ::IceUtil::noncopyable, public ParserVisitor @@ -211,6 +222,8 @@ private: ::IceUtil::Output& C; std::string _dllExport; + bool _useWstring; + std::list<bool> _useWstringHist; }; class ObjectDeclVisitor : private ::IceUtil::noncopyable, public ParserVisitor @@ -261,6 +274,8 @@ private: std::string _dllExport; bool _stream; bool _doneStaticSymbol; + bool _useWstring; + std::list<bool> _useWstringHist; }; class IceInternalVisitor : private ::IceUtil::noncopyable, public ParserVisitor @@ -318,6 +333,8 @@ private: ::IceUtil::Output& C; std::string _dllExport; + bool _useWstring; + std::list<bool> _useWstringHist; // // Generate code to emit a local variable declaration and initialize it @@ -339,6 +356,8 @@ private: virtual bool visitModuleStart(const ModulePtr&); virtual void visitModuleEnd(const ModulePtr&); + virtual bool visitClassDefStart(const ClassDefPtr&); + virtual void visitClassDefEnd(const ClassDefPtr&); virtual void visitOperation(const OperationPtr&); private: @@ -347,6 +366,8 @@ private: ::IceUtil::Output& C; std::string _dllExport; + bool _useWstring; + std::list<bool> _useWstringHist; }; class AsyncImplVisitor : private ::IceUtil::noncopyable, public ParserVisitor @@ -359,6 +380,8 @@ private: virtual void visitUnitEnd(const UnitPtr&); virtual bool visitModuleStart(const ModulePtr&); virtual void visitModuleEnd(const ModulePtr&); + virtual bool visitClassDefStart(const ClassDefPtr&); + virtual void visitClassDefEnd(const ClassDefPtr&); virtual void visitOperation(const OperationPtr&); private: @@ -367,6 +390,8 @@ private: ::IceUtil::Output& C; std::string _dllExport; + bool _useWstring; + std::list<bool> _useWstringHist; }; private: diff --git a/cpp/src/slice2cppe/Gen.cpp b/cpp/src/slice2cppe/Gen.cpp index 0c18079979b..49b9cd0de4e 100644 --- a/cpp/src/slice2cppe/Gen.cpp +++ b/cpp/src/slice2cppe/Gen.cpp @@ -375,6 +375,8 @@ Slice::Gen::TypesVisitor::TypesVisitor(Output& h, Output& c, const string& dllEx bool Slice::Gen::TypesVisitor::visitModuleStart(const ModulePtr& p) { + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -386,6 +388,8 @@ void Slice::Gen::TypesVisitor::visitModuleEnd(const ModulePtr& p) { H << sp << nl << '}'; + + _useWstring = resetUseWstring(_useWstringHist); } bool @@ -397,6 +401,8 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr&) bool Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) { + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); string scoped = fixKwd(p->scoped()); ExceptionPtr base = p->base(); @@ -417,7 +423,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q) { - string typeName = inputTypeToString((*q)->type(), (*q)->getMetaData()); + string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData()); allTypes.push_back(typeName); allParamDecls.push_back(typeName + " __ice_" + (*q)->name()); } @@ -689,11 +695,15 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) H << sp << nl << "static " << name << " __" << p->name() << "_init;"; } } + + _useWstring = resetUseWstring(_useWstringHist); } bool Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) { + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "struct " << name; @@ -790,13 +800,15 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) } H << eb << ';'; + + _useWstring = resetUseWstring(_useWstringHist); } void Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p) { string name = fixKwd(p->name()); - string s = typeToString(p->type(), p->getMetaData()); + string s = typeToString(p->type(), _useWstring, p->getMetaData()); H << nl << s << ' ' << name << ';'; } @@ -805,7 +817,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p) { string name = fixKwd(p->name()); TypePtr type = p->type(); - string s = typeToString(type); + string s = typeToString(type, _useWstring, p->typeMetaData()); StringList metaData = p->getMetaData(); string seqType = findMetaData(metaData, true); if(!seqType.empty() && seqType != "array" && seqType.find("range") != 0) @@ -962,12 +974,12 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p) string name = fixKwd(p->name()); TypePtr keyType = p->keyType(); TypePtr valueType = p->valueType(); - string ks = typeToString(keyType); + string ks = typeToString(keyType, _useWstring, p->keyMetaData()); if(ks[0] == ':') { ks.insert(0, " "); } - string vs = typeToString(valueType); + string vs = typeToString(valueType, _useWstring, p->valueMetaData()); H << sp << nl << "typedef ::std::map<" << ks << ", " << vs << "> " << name << ';'; if(!p->isLocal()) @@ -1085,7 +1097,8 @@ void Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) { H << sp; - H << nl << "const " << typeToString(p->type()) << " " << fixKwd(p->name()) << " = "; + H << nl << "const " << typeToString(p->type(), _useWstring, p->typeMetaData()) << " " << fixKwd(p->name()) + << " = "; BuiltinPtr bp = BuiltinPtr::dynamicCast(p->type()); if(bp && bp->kind() == Builtin::KindString) @@ -1100,6 +1113,10 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) "_{}[]#()<>%:;.?*+-/^&|~!=,\\\"' "; static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end()); + if(_useWstring || findMetaData(p->typeMetaData(), true) == "wstring") + { + H << 'L'; + } H << "\""; // Opening " const string val = p->value(); @@ -1253,6 +1270,8 @@ Slice::Gen::ProxyVisitor::visitModuleStart(const ModulePtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -1264,6 +1283,8 @@ void Slice::Gen::ProxyVisitor::visitModuleEnd(const ModulePtr& p) { H << sp << nl << '}'; + + _useWstring = resetUseWstring(_useWstringHist); } bool @@ -1274,6 +1295,8 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); string scoped = fixKwd(p->scoped()); ClassList bases = p->bases(); @@ -1352,6 +1375,8 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p) C << nl << "return static_cast<const ::IceProxy::Ice::Object&>(l) < " << "static_cast<const ::IceProxy::Ice::Object&>(r);"; C << eb; + + _useWstring = resetUseWstring(_useWstringHist); } void @@ -1362,7 +1387,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) string scope = fixKwd(p->scope()); TypePtr ret = p->returnType(); - string retS = returnTypeToString(ret, p->getMetaData()); + string retS = returnTypeToString(ret, _useWstring, p->getMetaData()); vector<string> params; vector<string> paramsDecl; @@ -1381,12 +1406,12 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) if((*q)->isOutParam()) { outParams.push_back(*q); - typeString = outputTypeToString((*q)->type(), metaData); + typeString = outputTypeToString((*q)->type(), _useWstring, metaData); } else { inParams.push_back(*q); - typeString = inputTypeToString((*q)->type(), metaData); + typeString = inputTypeToString((*q)->type(), _useWstring, metaData); } params.push_back(typeString); @@ -1495,7 +1520,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) C << eb; C << eb; - writeAllocateCode(C, ParamDeclList(), ret, p->getMetaData()); + writeAllocateCode(C, ParamDeclList(), ret, p->getMetaData(), _useWstring); writeUnmarshalCode(C, outParams, ret, p->getMetaData()); if(ret) { @@ -1614,6 +1639,8 @@ Slice::Gen::ObjectVisitor::visitModuleStart(const ModulePtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -1626,11 +1653,15 @@ Slice::Gen::ObjectVisitor::visitModuleEnd(const ModulePtr& p) { H << sp; H << nl << '}'; + + _useWstring = resetUseWstring(_useWstringHist); } bool Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) { + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); string scoped = fixKwd(p->scoped()); ClassList bases = p->bases(); @@ -1697,7 +1728,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q) { - string typeName = inputTypeToString((*q)->type(), (*q)->getMetaData()); + string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData()); allTypes.push_back(typeName); allParamDecls.push_back(typeName + " __ice_" + (*q)->name()); } @@ -2049,6 +2080,8 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) C << sp << nl << "#endif // ICEE_PURE_CLIENT"; } + + _useWstring = resetUseWstring(_useWstringHist); } bool @@ -2071,7 +2104,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) string scope = fixKwd(p->scope()); TypePtr ret = p->returnType(); - string retS = returnTypeToString(ret, p->getMetaData()); + string retS = returnTypeToString(ret, _useWstring, p->getMetaData()); string params = "("; string paramsDecl = "("; @@ -2095,12 +2128,12 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) if(isOutParam) { outParams.push_back(*q); - typeString = outputTypeToString(type, metaData); + typeString = outputTypeToString(type, _useWstring, metaData); } else { inParams.push_back(*q); - typeString = inputTypeToString(type, metaData); + typeString = inputTypeToString(type, _useWstring, metaData); } if(q != paramList.begin()) @@ -2180,9 +2213,9 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) C << nl << "::IceInternal::BasicStream* __os = __inS.os();"; } - writeAllocateCode(C, inParams, 0, StringList(), true); + writeAllocateCode(C, inParams, 0, StringList(), _useWstring, true); writeUnmarshalCode(C, inParams, 0, StringList(), true); - writeAllocateCode(C, outParams, 0, StringList()); + writeAllocateCode(C, outParams, 0, StringList(), _useWstring); if(!throws.empty()) { C << nl << "try"; @@ -2217,7 +2250,7 @@ void Slice::Gen::ObjectVisitor::visitDataMember(const DataMemberPtr& p) { string name = fixKwd(p->name()); - string s = typeToString(p->type(), p->getMetaData()); + string s = typeToString(p->type(), _useWstring, p->getMetaData()); H << nl << s << ' ' << name << ';'; } @@ -2266,7 +2299,7 @@ Slice::Gen::ObjectVisitor::emitOneShotConstructor(const ClassDefPtr& p) for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q) { - string typeName = inputTypeToString((*q)->type()); + string typeName = inputTypeToString((*q)->type(), _useWstring); allParamDecls.push_back(typeName + " __ice_" + (*q)->name()); } @@ -2530,55 +2563,6 @@ Slice::Gen::ImplVisitor::ImplVisitor(Output& h, Output& c, } void -Slice::Gen::ImplVisitor::writeDecl(Output& out, const string& name, const TypePtr& type) -{ - out << nl << typeToString(type) << ' ' << name; - - BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if(builtin) - { - switch(builtin->kind()) - { - case Builtin::KindBool: - { - out << " = false"; - break; - } - case Builtin::KindByte: - case Builtin::KindShort: - case Builtin::KindInt: - case Builtin::KindLong: - { - out << " = 0"; - break; - } - case Builtin::KindFloat: - case Builtin::KindDouble: - { - out << " = 0.0"; - break; - } - case Builtin::KindObject: - case Builtin::KindString: - case Builtin::KindObjectProxy: - case Builtin::KindLocalObject: - { - break; - } - } - } - - EnumPtr en = EnumPtr::dynamicCast(type); - if(en) - { - EnumeratorList enumerators = en->getEnumerators(); - out << " = " << fixKwd(en->scope()) << fixKwd(enumerators.front()->name()); - } - - out << ';'; -} - -void Slice::Gen::ImplVisitor::writeReturn(Output& out, const TypePtr& type, const StringList& metaData) { BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); @@ -2653,7 +2637,7 @@ Slice::Gen::ImplVisitor::writeReturn(Output& out, const TypePtr& type, const Str SequencePtr seq = SequencePtr::dynamicCast(type); if(seq) { - out << nl << "return " << typeToString(seq, metaData) << "();"; + out << nl << "return " << typeToString(seq, _useWstring, metaData) << "();"; } else { @@ -2676,6 +2660,8 @@ Slice::Gen::ImplVisitor::visitModuleStart(const ModulePtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = fixKwd(p->name()); H << sp << nl << "namespace " << name << nl << '{'; @@ -2688,6 +2674,8 @@ Slice::Gen::ImplVisitor::visitModuleEnd(const ModulePtr& p) { H << sp; H << nl << '}'; + + _useWstring = resetUseWstring(_useWstringHist); } bool @@ -2698,6 +2686,8 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } + _useWstring = setUseWstring(p, _useWstringHist, _useWstring); + string name = p->name(); string scope = fixKwd(p->scope()); string cls = scope.substr(2) + name + "I"; @@ -2741,7 +2731,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) string opName = op->name(); TypePtr ret = op->returnType(); - string retS = returnTypeToString(ret, op->getMetaData()); + string retS = returnTypeToString(ret, _useWstring, op->getMetaData()); H << sp << nl << "virtual " << retS << ' ' << fixKwd(opName) << '('; H.useCurrentPosAsIndent(); @@ -2762,15 +2752,15 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) string typeString; if((*q)->isOutParam()) { - typeString = outputTypeToString((*q)->type(), metaData); + typeString = outputTypeToString((*q)->type(), _useWstring, metaData); } else { - typeString = inputTypeToString((*q)->type(), metaData); + typeString = inputTypeToString((*q)->type(), _useWstring, metaData); } #else string typeString = (*q)->isOutParam() ? - outputTypeToString((*q)->type(), metaData) : inputTypeToString((*q)->type(), metaData); + outputTypeToString((*q)->type(), _useWstring, metaData) : inputTypeToString((*q)->type(), _useWstring, metaData); #endif H << typeString; } @@ -2806,15 +2796,15 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) string typeString; if((*q)->isOutParam()) { - typeString = outputTypeToString((*q)->type(), metaData); + typeString = outputTypeToString((*q)->type(), _useWstring, metaData); } else { - typeString = inputTypeToString((*q)->type(), metaData); + typeString = inputTypeToString((*q)->type(), _useWstring, metaData); } #else string typeString = (*q)->isOutParam() ? - outputTypeToString((*q)->type(), metaData) : inputTypeToString((*q)->type(), metaData); + outputTypeToString((*q)->type(), _useWstring, metaData) : inputTypeToString((*q)->type(), _useWstring, metaData); #endif C << typeString << ' ' << fixKwd((*q)->name()); } @@ -3005,9 +2995,21 @@ Slice::Gen::MetaDataVisitor::validate(const SyntaxTreeBasePtr& cont, const Strin { if(s.find(prefix) == 0) { + string ss = s.substr(prefix.size()); + if(ss.find("type:wstring") == 0) + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(cont); + ModulePtr module = ModulePtr::dynamicCast(cont); + ClassDefPtr clss = ClassDefPtr::dynamicCast(cont); + StructPtr strct = StructPtr::dynamicCast(cont); + ExceptionPtr exception = ExceptionPtr::dynamicCast(cont); + if((builtin && builtin->kind() == Builtin::KindString) || module || clss || strct || exception) + { + continue; + } + } if(SequencePtr::dynamicCast(cont)) { - string ss = s.substr(prefix.size()); if(ss.find("type:") == 0 || (inParam && (ss == "array" || ss.find("range") == 0))) { continue; @@ -3027,6 +3029,26 @@ Slice::Gen::validateMetaData(const UnitPtr& u) u->visit(&visitor, false); } +bool +Slice::Gen::setUseWstring(ContainedPtr p, list<bool>& hist, bool use) +{ + hist.push_back(use); + if(!use) + { + StringList metaData = p->getMetaData(); + use = find(metaData.begin(), metaData.end(), "cpp:type:wstring") != metaData.end(); + } + return use; +} + +bool +Slice::Gen::resetUseWstring(list<bool>& hist) +{ + bool use = hist.back(); + hist.pop_back(); + return use; +} + void Slice::Gen::printHeader(Output& out) { diff --git a/cpp/src/slice2cppe/Gen.h b/cpp/src/slice2cppe/Gen.h index 286e206b020..172942b04be 100644 --- a/cpp/src/slice2cppe/Gen.h +++ b/cpp/src/slice2cppe/Gen.h @@ -104,6 +104,8 @@ private: std::string _dllExport; bool _doneStaticSymbol; + bool _useWstring; + std::list<bool> _useWstringHist; }; class ProxyDeclVisitor : private ::IceUtil::noncopyable, public ParserVisitor @@ -146,6 +148,8 @@ private: ::IceUtil::Output& C; std::string _dllExport; + bool _useWstring; + std::list<bool> _useWstringHist; }; class ObjectDeclVisitor : private ::IceUtil::noncopyable, public ParserVisitor @@ -191,6 +195,8 @@ private: ::IceUtil::Output& C; std::string _dllExport; + bool _useWstring; + std::list<bool> _useWstringHist; }; class IceInternalVisitor : private ::IceUtil::noncopyable, public ParserVisitor @@ -247,12 +253,8 @@ private: ::IceUtil::Output& C; std::string _dllExport; - - // - // Generate code to emit a local variable declaration and initialize it - // if necessary. - // - void writeDecl(::IceUtil::Output&, const std::string&, const TypePtr&); + bool _useWstring; + std::list<bool> _useWstringHist; // // Generate code to return a dummy value @@ -290,6 +292,8 @@ private: }; static void validateMetaData(const UnitPtr&); + static bool setUseWstring(ContainedPtr, std::list<bool>&, bool); + static bool resetUseWstring(std::list<bool>&); static void printHeader(IceUtil::Output&); static void printVersionCheck(IceUtil::Output&); static void printDllExportStuff(IceUtil::Output&, const std::string&); diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index 0de8fe0c8c4..26f634b2ad9 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -180,9 +180,9 @@ writeCodecH(const TypePtr& type, const string& name, const string& freezeType, O H << sp << nl << "public:"; H << sp; H.inc(); - H << nl << "static void write(" << inputTypeToString(type) + H << nl << "static void write(" << inputTypeToString(type, false) << ", Freeze::" << freezeType << "&, const ::Ice::CommunicatorPtr&);"; - H << nl << "static void read(" << typeToString(type) << "&, const Freeze::" << freezeType << "&, " + H << nl << "static void read(" << typeToString(type, false) << "&, const Freeze::" << freezeType << "&, " << "const ::Ice::CommunicatorPtr&);"; H << nl << "static const std::string& typeId();"; H << eb << ';'; @@ -193,7 +193,7 @@ writeCodecC(const TypePtr& type, const string& name, const string& freezeType, b { string quotedFreezeType = "\"" + freezeType + "\""; - C << sp << nl << "void" << nl << name << "::write(" << inputTypeToString(type) << " v, " + C << sp << nl << "void" << nl << name << "::write(" << inputTypeToString(type, false) << " v, " << "Freeze::" << freezeType << "& bytes, const ::Ice::CommunicatorPtr& communicator)"; C << sb; C << nl << "IceInternal::InstancePtr instance = IceInternal::getInstance(communicator);"; @@ -214,7 +214,7 @@ writeCodecC(const TypePtr& type, const string& name, const string& freezeType, b C << nl << "::std::vector<Ice::Byte>(stream.b.begin(), stream.b.end()).swap(bytes);"; C << eb; - C << sp << nl << "void" << nl << name << "::read(" << typeToString(type) << "& v, " + C << sp << nl << "void" << nl << name << "::read(" << typeToString(type, false) << "& v, " << "const Freeze::" << freezeType << "& bytes, const ::Ice::CommunicatorPtr& communicator)"; C << sb; C << nl << "IceInternal::InstancePtr instance = IceInternal::getInstance(communicator);"; @@ -270,14 +270,14 @@ writeDictWithIndicesH(const string& name, const Dict& dict, const TypePtr& keyType, const TypePtr& valueType, Output& H, const string& dllExport) { - string compare = getCompare(dict, typeToString(keyType)); + string compare = getCompare(dict, typeToString(keyType, false)); - string templateParams = string("< ") + typeToString(keyType) + ", " - + typeToString(valueType) + ", " + name + "KeyCodec, " + string templateParams = string("< ") + typeToString(keyType, false) + ", " + + typeToString(valueType, false) + ", " + name + "KeyCodec, " + name + "ValueCodec, " + compare + " >"; string keyCompareParams = - string("< ") + typeToString(keyType) + ", " + string("< ") + typeToString(keyType, false) + ", " + name + "KeyCodec, " + compare + " >"; vector<string> capitalizedMembers; @@ -309,8 +309,8 @@ writeDictWithIndicesH(const string& name, const Dict& dict, // Typedefs // /* - H << nl << "typedef std::pair<const " << typeToString(keyType) - << ", const" << typeToString(valueType) << "> value_type;"; + H << nl << "typedef std::pair<const " << typeToString(keyType, false) + << ", const" << typeToString(valueType, false) << "> value_type;"; H << nl << "typedef Freeze::Iterator" << templateParams << " iterator;"; H << nl << "typedef Freeze::ConstIterator" << templateParams << " const_iterator;"; @@ -326,10 +326,10 @@ writeDictWithIndicesH(const string& name, const Dict& dict, { string className = capitalizedMembers[i] + "Index"; - string indexCompare = getCompare(dict.indices[i], typeToString(indexTypes[i])); + string indexCompare = getCompare(dict.indices[i], typeToString(indexTypes[i], false)); string indexCompareParams = - string("< ") + typeToString(indexTypes[i]) + ", " + string("< ") + typeToString(indexTypes[i], false) + ", " + className + ", " + indexCompare + " >"; H << sp << nl << "class " << dllExport << className @@ -348,11 +348,11 @@ writeDictWithIndicesH(const string& name, const Dict& dict, // // Codec // - H << nl << "static void write(" << inputTypeToString(indexTypes[i]) + H << nl << "static void write(" << inputTypeToString(indexTypes[i], false) << ", Freeze::Key&, const Ice::CommunicatorPtr&);"; H << nl << "static void read(" - << typeToString(indexTypes[i]) + << typeToString(indexTypes[i], false) << "&, const Freeze::Key&, const ::Ice::CommunicatorPtr&);"; H.dec(); @@ -412,31 +412,31 @@ writeDictWithIndicesH(const string& name, const Dict& dict, { H << sp; H << nl << "iterator findBy" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i]) << ", bool = true);"; + << "(" << inputTypeToString(indexTypes[i], false) << ", bool = true);"; H << nl << "const_iterator findBy" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i]) << ", bool = true) const;"; + << "(" << inputTypeToString(indexTypes[i], false) << ", bool = true) const;"; H << nl << "iterator lowerBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i]) << ");"; + << "(" << inputTypeToString(indexTypes[i], false) << ");"; H << nl << "const_iterator lowerBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i]) << ") const;"; + << "(" << inputTypeToString(indexTypes[i], false) << ") const;"; H << nl << "iterator upperBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i]) << ");"; + << "(" << inputTypeToString(indexTypes[i], false) << ");"; H << nl << "const_iterator upperBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i]) << ") const;"; + << "(" << inputTypeToString(indexTypes[i], false) << ") const;"; H << nl << "std::pair<iterator, iterator> equalRangeFor" - << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i]) << ");"; + << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i], false) << ");"; H << nl << "std::pair<const_iterator, const_iterator> equalRangeFor" - << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i]) << ") const;"; + << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i], false) << ") const;"; string countFunction = dict.indices[i].member.empty() ? "valueCount" : dict.indices[i].member + "Count"; H << nl << "int " << countFunction - << "(" << inputTypeToString(indexTypes[i]) << ") const;"; + << "(" << inputTypeToString(indexTypes[i], false) << ") const;"; } H << eb << ';'; @@ -448,14 +448,14 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di const TypePtr& keyType, const TypePtr& valueType, Output& C) { - string compare = getCompare(dict, typeToString(keyType)); + string compare = getCompare(dict, typeToString(keyType, false)); - string templateParams = string("< ") + typeToString(keyType) + ", " - + typeToString(valueType) + ", " + name + "KeyCodec, " + string templateParams = string("< ") + typeToString(keyType, false) + ", " + + typeToString(valueType, false) + ", " + name + "KeyCodec, " + name + "ValueCodec, " + compare + " >"; string keyCompareParams = - string("< ") + typeToString(keyType) + ", " + string("< ") + typeToString(keyType, false) + ", " + name + "KeyCodec, " + compare + " >"; vector<string> capitalizedMembers; @@ -484,10 +484,10 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di string className = capitalizedMembers[i] + "Index"; string indexCompare = - getCompare(dict.indices[i], typeToString(indexTypes[i])); + getCompare(dict.indices[i], typeToString(indexTypes[i], false)); string indexCompareParams = - string("< ") + typeToString(indexTypes[i]) + ", " + string("< ") + typeToString(indexTypes[i], false) + ", " + className + ", " + indexCompare + " >"; C << sp << nl << absolute << "::" << className << "::" << className @@ -518,7 +518,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di // // Can't optimize // - C << nl << typeToString(valueType) << " __x;"; + C << nl << typeToString(valueType, false) << " __x;"; C << nl << absolute << "ValueCodec::read(__x, __v, _communicator);"; string param = "__x"; @@ -539,7 +539,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << "void" << nl << absolute << "::" << className << "::" - << "write(" << inputTypeToString(indexTypes[i]) + << "write(" << inputTypeToString(indexTypes[i], false) << " __index, Freeze::Key& __bytes, const Ice::CommunicatorPtr& __communicator)"; C << sb; @@ -561,7 +561,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di } else { - C << nl << typeToString(indexTypes[i]) << " __lowerCaseIndex = __index;"; + C << nl << typeToString(indexTypes[i], false) << " __lowerCaseIndex = __index;"; C << nl << "std::transform(__lowerCaseIndex.begin(), __lowerCaseIndex.end(), __lowerCaseIndex.begin(), tolower);"; valueS = "__lowerCaseIndex"; } @@ -573,7 +573,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << "void" << nl << absolute << "::" << className << "::" - << "read(" << typeToString(indexTypes[i]) + << "read(" << typeToString(indexTypes[i], false) << "& __index, const Freeze::Key& __bytes, const Ice::CommunicatorPtr& __communicator)"; C << sb; @@ -640,7 +640,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << absolute << "::iterator" << nl << absolute << "::" << "findBy" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i]) << " __index, bool __onlyDups)"; + << "(" << inputTypeToString(indexTypes[i], false) << " __index, bool __onlyDups)"; C << sb; C << nl << "Freeze::Key __bytes;"; C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);"; @@ -650,7 +650,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << absolute << "::const_iterator" << nl << absolute << "::" << "findBy" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i]) << " __index, bool __onlyDups) const"; + << "(" << inputTypeToString(indexTypes[i], false) << " __index, bool __onlyDups) const"; C << sb; C << nl << "Freeze::Key __bytes;"; C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);"; @@ -660,7 +660,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << absolute << "::iterator" << nl << absolute << "::" << "lowerBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i]) << " __index)"; + << "(" << inputTypeToString(indexTypes[i], false) << " __index)"; C << sb; C << nl << "Freeze::Key __bytes;"; C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);"; @@ -670,7 +670,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << absolute << "::const_iterator" << nl << absolute << "::" << "lowerBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i]) << " __index) const"; + << "(" << inputTypeToString(indexTypes[i], false) << " __index) const"; C << sb; C << nl << "Freeze::Key __bytes;"; C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);"; @@ -680,7 +680,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << absolute << "::iterator" << nl << absolute << "::" << "upperBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i]) << " __index)"; + << "(" << inputTypeToString(indexTypes[i], false) << " __index)"; C << sb; C << nl << "Freeze::Key __bytes;"; C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);"; @@ -690,7 +690,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << absolute << "::const_iterator" << nl << absolute << "::" << "upperBoundFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i]) << " __index) const"; + << "(" << inputTypeToString(indexTypes[i], false) << " __index) const"; C << sb; C << nl << "Freeze::Key __bytes;"; C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);"; @@ -701,7 +701,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << "std::pair<" << absolute << "::iterator, " << absolute << "::iterator>" << nl << absolute << "::" << "equalRangeFor" << capitalizedMembers[i] - << "(" << inputTypeToString(indexTypes[i]) << " __index)"; + << "(" << inputTypeToString(indexTypes[i], false) << " __index)"; C << sb; C << nl << "return std::make_pair(lowerBoundFor" << capitalizedMembers[i] << "(__index), upperBoundFor" << capitalizedMembers[i] << "(__index));"; @@ -710,7 +710,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]) << " __index) const"; + << "(" << inputTypeToString(indexTypes[i], false) << " __index) const"; C << sb; C << nl << "return std::make_pair(lowerBoundFor" << capitalizedMembers[i] << "(__index), upperBoundFor" << capitalizedMembers[i] << "(__index));"; @@ -721,7 +721,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di C << sp << nl << "int" << nl << absolute << "::" << countFunction - << "(" << inputTypeToString(indexTypes[i]) << " __index) const"; + << "(" << inputTypeToString(indexTypes[i], false) << " __index) const"; C << sb; C << nl << "Freeze::Key __bytes;"; C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);"; @@ -792,10 +792,10 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c if(dict.indices.size() == 0) { - string compare = getCompare(dict, typeToString(keyType)); + string compare = getCompare(dict, typeToString(keyType, false)); - H << sp << nl << "typedef Freeze::Map< " << typeToString(keyType) - << ", " << typeToString(valueType) << ", " + H << sp << nl << "typedef Freeze::Map< " << typeToString(keyType, false) + << ", " << typeToString(valueType, false) << ", " << name << "KeyCodec, " << name << "ValueCodec, " << compare << " > " << name << ";"; } @@ -961,7 +961,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)"; @@ -995,7 +995,7 @@ writeIndexC(const TypePtr& type, const TypePtr& memberType, const string& member C << nl << "return untypedCount(__bytes);"; C << eb; - string typeString = typeToString(type); + string typeString = typeToString(type, false); C << sp << nl << "bool"; C << nl << fullName << "::" << "marshalKey(const Ice::ObjectPtr& __servant, Freeze::Key& __bytes) const"; @@ -1025,7 +1025,7 @@ writeIndexC(const TypePtr& type, const TypePtr& memberType, const string& member } else { - C << nl << typeToString(memberType) << " __lowerCaseIndex = __index;"; + C << nl << typeToString(memberType, false) << " __lowerCaseIndex = __index;"; C << nl << "std::transform(__lowerCaseIndex.begin(), __lowerCaseIndex.end(), __lowerCaseIndex.begin(), tolower);"; valueS = "__lowerCaseIndex"; } @@ -1125,7 +1125,7 @@ writeIndex(const string& n, UnitPtr& u, const Index& index, Output& H, Output& C 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) { |