diff options
author | Jose <jose@zeroc.com> | 2017-01-30 16:18:28 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2017-01-30 16:18:28 +0100 |
commit | bf40a15c3f99db731b7ac7370b9e2326fabe6170 (patch) | |
tree | e9d73ec5dad67ddaae0541fe77ced8a6ad194623 /cpp | |
parent | Fixed ICE-7493 - Support for java try-with and Python with statements for the... (diff) | |
download | ice-bf40a15c3f99db731b7ac7370b9e2326fabe6170.tar.bz2 ice-bf40a15c3f99db731b7ac7370b9e2326fabe6170.tar.xz ice-bf40a15c3f99db731b7ac7370b9e2326fabe6170.zip |
Fixed bug in CSharp Stack sequence mapping
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/slice2cs/CsUtil.cpp | 175 | ||||
-rw-r--r-- | cpp/src/slice2cs/CsUtil.h | 1 |
2 files changed, 93 insertions, 83 deletions
diff --git a/cpp/src/slice2cs/CsUtil.cpp b/cpp/src/slice2cs/CsUtil.cpp index 85e121c1967..251b910f473 100644 --- a/cpp/src/slice2cs/CsUtil.cpp +++ b/cpp/src/slice2cs/CsUtil.cpp @@ -2355,6 +2355,7 @@ Slice::CsGenerator::MetaDataVisitor::visitUnitStart(const UnitPtr& p) DefinitionContextPtr dc = p->findDefinitionContext(file); assert(dc); StringList globalMetaData = dc->getMetaData(); + StringList newGlobalMetaData; static const string csPrefix = "cs:"; static const string clrPrefix = "clr:"; @@ -2369,22 +2370,19 @@ Slice::CsGenerator::MetaDataVisitor::visitUnitStart(const UnitPtr& p) s.replace(0, clrPrefix.size(), csPrefix); } - if(_history.count(s) == 0) + if(s.find(csPrefix) == 0) { - if(s.find(csPrefix) == 0) + static const string csAttributePrefix = csPrefix + "attribute:"; + if(s.find(csAttributePrefix) != 0 || s.size() == csAttributePrefix.size()) { - static const string csAttributePrefix = csPrefix + "attribute:"; - if(s.find(csAttributePrefix) == 0 && s.size() > csAttributePrefix.size()) - { - continue; - } emitWarning(file, -1, "ignoring invalid global metadata `" + oldS + "'"); - _history.insert(s); + continue; } } + newGlobalMetaData.push_back(oldS); } - dc->setMetaData(globalMetaData); + dc->setMetaData(newGlobalMetaData); } return true; } @@ -2497,6 +2495,7 @@ Slice::CsGenerator::MetaDataVisitor::validate(const ContainedPtr& cont) const string msg = "ignoring invalid metadata"; StringList localMetaData = cont->getMetaData(); + StringList newLocalMetaData; for(StringList::iterator p = localMetaData.begin(); p != localMetaData.end(); ++p) { @@ -2511,113 +2510,125 @@ Slice::CsGenerator::MetaDataVisitor::validate(const ContainedPtr& cont) s.replace(0, clrPrefix.size(), csPrefix); } - if(_history.count(s) == 0) + + if(s.find(csPrefix) == 0) { - if(s.find(csPrefix) == 0) + SequencePtr seq = SequencePtr::dynamicCast(cont); + if(seq) { - SequencePtr seq = SequencePtr::dynamicCast(cont); - if(seq) + static const string csGenericPrefix = csPrefix + "generic:"; + if(s.find(csGenericPrefix) == 0) { - static const string csGenericPrefix = csPrefix + "generic:"; - if(s.find(csGenericPrefix) == 0) + string type = s.substr(csGenericPrefix.size()); + if(type == "LinkedList" || type == "Queue" || type == "Stack") { - string type = s.substr(csGenericPrefix.size()); - if(type == "LinkedList" || type == "Queue" || type == "Stack") - { - if(!isClassType(seq->type())) - { - continue; - } - } - else if(!type.empty()) - { - continue; // Custom type or List<T> - } - } - static const string csSerializablePrefix = csPrefix + "serializable:"; - if(s.find(csSerializablePrefix) == 0) - { - string meta; - if(cont->findMetaData(csPrefix + "generic:", meta)) - { - emitWarning(cont->file(), cont->line(), msg + " `" + meta + "':\n" + - "serialization can only be used with the array mapping for byte sequences"); - } - string type = s.substr(csSerializablePrefix.size()); - BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); - if(!type.empty() && builtin && builtin->kind() == Builtin::KindByte) + if(!isClassType(seq->type())) { + newLocalMetaData.push_back(s); continue; } } - } - else if(StructPtr::dynamicCast(cont)) - { - if(s.substr(csPrefix.size()) == "class") - { - continue; - } - if(s.substr(csPrefix.size()) == "property") + else if(!type.empty()) { - continue; - } - static const string csImplementsPrefix = csPrefix + "implements:"; - if(s.find(csImplementsPrefix) == 0) - { - continue; + newLocalMetaData.push_back(s); + continue; // Custom type or List<T> } } - else if(ClassDefPtr::dynamicCast(cont)) + static const string csSerializablePrefix = csPrefix + "serializable:"; + if(s.find(csSerializablePrefix) == 0) { - if(s.substr(csPrefix.size()) == "property") + string meta; + if(cont->findMetaData(csPrefix + "generic:", meta)) { + emitWarning(cont->file(), cont->line(), msg + " `" + meta + "':\n" + + "serialization can only be used with the array mapping for byte sequences"); continue; } - static const string csImplementsPrefix = csPrefix + "implements:"; - if(s.find(csImplementsPrefix) == 0) + string type = s.substr(csSerializablePrefix.size()); + BuiltinPtr builtin = BuiltinPtr::dynamicCast(seq->type()); + if(!type.empty() && builtin && builtin->kind() == Builtin::KindByte) { + newLocalMetaData.push_back(s); continue; } } - else if(DictionaryPtr::dynamicCast(cont)) + } + else if(StructPtr::dynamicCast(cont)) + { + if(s.substr(csPrefix.size()) == "class") { - static const string csGenericPrefix = csPrefix + "generic:"; - if(s.find(csGenericPrefix) == 0) - { - string type = s.substr(csGenericPrefix.size()); - if(type == "SortedDictionary" || type == "SortedList") - { - continue; - } - } + newLocalMetaData.push_back(s); + continue; } - - static const string csAttributePrefix = csPrefix + "attribute:"; - static const string csTie = csPrefix + "tie"; - if(s.find(csAttributePrefix) == 0 && s.size() > csAttributePrefix.size()) + if(s.substr(csPrefix.size()) == "property") { + newLocalMetaData.push_back(s); continue; } - else if(s.find(csTie) == 0 && s.size() == csTie.size()) + static const string csImplementsPrefix = csPrefix + "implements:"; + if(s.find(csImplementsPrefix) == 0) { + newLocalMetaData.push_back(s); continue; } - - emitWarning(cont->file(), cont->line(), msg + " `" + oldS + "'"); - _history.insert(s); } - else if(s == "delegate") + else if(ClassDefPtr::dynamicCast(cont)) { - ClassDefPtr cl = ClassDefPtr::dynamicCast(cont); - if(cl && cl->isDelegate()) + if(s.substr(csPrefix.size()) == "property") + { + newLocalMetaData.push_back(s); + continue; + } + static const string csImplementsPrefix = csPrefix + "implements:"; + if(s.find(csImplementsPrefix) == 0) { + newLocalMetaData.push_back(s); continue; } - emitWarning(cont->file(), cont->line(), msg + " `" + s + "'"); - _history.insert(s); } + else if(DictionaryPtr::dynamicCast(cont)) + { + static const string csGenericPrefix = csPrefix + "generic:"; + if(s.find(csGenericPrefix) == 0) + { + string type = s.substr(csGenericPrefix.size()); + if(type == "SortedDictionary" || type == "SortedList") + { + newLocalMetaData.push_back(s); + continue; + } + } + } + + static const string csAttributePrefix = csPrefix + "attribute:"; + static const string csTie = csPrefix + "tie"; + if(s.find(csAttributePrefix) == 0 && s.size() > csAttributePrefix.size()) + { + newLocalMetaData.push_back(s); + continue; + } + else if(s.find(csTie) == 0 && s.size() == csTie.size()) + { + newLocalMetaData.push_back(s); + continue; + } + + emitWarning(cont->file(), cont->line(), msg + " `" + oldS + "'"); + continue; + } + else if(s == "delegate") + { + ClassDefPtr cl = ClassDefPtr::dynamicCast(cont); + if(cl && cl->isDelegate()) + { + newLocalMetaData.push_back(s); + continue; + } + emitWarning(cont->file(), cont->line(), msg + " `" + s + "'"); + continue; } + newLocalMetaData.push_back(s); } - cont->setMetaData(localMetaData); + cont->setMetaData(newLocalMetaData); } diff --git a/cpp/src/slice2cs/CsUtil.h b/cpp/src/slice2cs/CsUtil.h index b25c6a3dd2f..16ebd8a3c54 100644 --- a/cpp/src/slice2cs/CsUtil.h +++ b/cpp/src/slice2cs/CsUtil.h @@ -88,7 +88,6 @@ private: void validate(const ContainedPtr&); std::string _fileName; - StringSet _history; }; }; |