diff options
author | Mark Spruiell <mes@zeroc.com> | 2007-06-26 10:22:44 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2007-06-26 10:22:44 -0700 |
commit | 3fea88eedf633aad4a7db9a9bea9ff83a2a7438e (patch) | |
tree | dbf1f42cabadea45cba9c7b5f3b6f8f15e4c4f3f /cpp/src/slice2cpp/Gen.cpp | |
parent | fixing NPE in IceSSL for Java & updating IceSSL test (diff) | |
parent | Merge branch 'master' of ssh://cvs.zeroc.com/home/git/ice (diff) | |
download | ice-3fea88eedf633aad4a7db9a9bea9ff83a2a7438e.tar.bz2 ice-3fea88eedf633aad4a7db9a9bea9ff83a2a7438e.tar.xz ice-3fea88eedf633aad4a7db9a9bea9ff83a2a7438e.zip |
Merge branch 'master' of ssh://cvs.zeroc.com/home/git/ice
Diffstat (limited to 'cpp/src/slice2cpp/Gen.cpp')
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 03d12816e44..986d5269f77 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -3158,41 +3158,47 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) // // Check if we need to generate ice_operationAttributes() // - - StringList freezeWriteOpNames; + map<string, int> attributesMap; for(OperationList::iterator r = allOps.begin(); r != allOps.end(); ++r) { - ClassDefPtr classDef = ClassDefPtr::dynamicCast((*r)->container()); - assert(classDef != 0); - - if((*r)->hasMetaData("freeze:write") || - (classDef->hasMetaData("freeze:write") && !(*r)->hasMetaData("freeze:read"))) + int attributes = (*r)->attributes(); + if(attributes != 0) { - freezeWriteOpNames.push_back((*r)->name()); + attributesMap.insert(map<string, int>::value_type((*r)->name(), attributes)); } } - if(!freezeWriteOpNames.empty()) + if(!attributesMap.empty()) { - freezeWriteOpNames.sort(); - H << sp; H << nl << "virtual ::Ice::Int ice_operationAttributes(const ::std::string&) const;"; - flatName = p->flattenedScope() + p->name() + "_freezeWriteOperations"; + string opAttrFlatName = p->flattenedScope() + p->name() + "_operationAttributes"; + C << sp; - C << nl << "static ::std::string " << flatName << "[] ="; + C << nl << "static int " << opAttrFlatName << "[] = "; C << sb; - q = freezeWriteOpNames.begin(); - while(q != freezeWriteOpNames.end()) + + q = allOpNames.begin(); + while(q != allOpNames.end()) { - C << nl << '"' << *q << '"'; - if(++q != freezeWriteOpNames.end()) + int attributes = 0; + string opName = *q; + map<string, int>::iterator it = attributesMap.find(opName); + if(it != attributesMap.end()) + { + attributes = it->second; + } + C << nl << attributes; + + if(++q != allOpNames.end()) { C << ','; } + C << " // " << opName; } + C << eb << ';'; C << sp; @@ -3200,10 +3206,15 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) << "::ice_operationAttributes(const ::std::string& opName) const"; C << sb; - C << nl << "::std::string* end = " << flatName << " + " << freezeWriteOpNames.size() << ";"; - C << nl << "::std::string* r = ::std::find(" << flatName << ", end, opName);"; - - C << nl << "return r == end ? 0 : 1;"; + C << nl << "::std::pair< ::std::string*, ::std::string*> r = " + << "::std::equal_range(" << flatName << ", " << flatName << " + " << allOpNames.size() + << ", opName);"; + C << nl << "if(r.first == r.second)"; + C << sb; + C << nl << "return -1;"; + C << eb; + + C << nl << "return " << opAttrFlatName << "[r.first - " << flatName << "];"; C << eb; } } |