[hydra-commits] beagles: branch ice/slice-translator-versioning r668 - in /ice/branches/slice...

SVN commits to the Hydra project hydra-commits at lists.digium.com
Thu Jun 10 07:32:29 CDT 2010


Author: beagles
Date: Thu Jun 10 07:32:29 2010
New Revision: 668

URL: https://origsvn.digium.com/svn-view/hydra?view=rev&rev=668
Log:
Try out a different approach to the versioning mods (C++ only so far) with a
C++ test program to verify operation. Seems to work ok, with fewer mods to the
generator code.

Standard Ice tests have been run successfully except IceGrid, which hasn't been
working properly on my system for some reason.


Added:
    ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/
    ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/.depend   (with props)
    ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/AllTests.cpp   (with props)
    ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/Client.cpp   (with props)
    ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/Makefile   (with props)
    ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/Test.ice   (with props)
    ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/TestI.cpp   (with props)
    ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/TestI.h   (with props)
    ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/version1/
    ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/version1/.depend   (with props)
    ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/version1/Makefile   (with props)
    ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/version2/
    ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/version2/.depend   (with props)
    ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/version2/Makefile   (with props)
Modified:
    ice/branches/slice-translator-versioning/cpp/include/Slice/Parser.h
    ice/branches/slice-translator-versioning/cpp/src/Slice/Parser.cpp
    ice/branches/slice-translator-versioning/cpp/src/slice2cpp/Gen.cpp
    ice/branches/slice-translator-versioning/cpp/src/slice2cs/Gen.cpp
    ice/branches/slice-translator-versioning/cpp/src/slice2java/Gen.cpp

Modified: ice/branches/slice-translator-versioning/cpp/include/Slice/Parser.h
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/slice-translator-versioning/cpp/include/Slice/Parser.h?view=diff&rev=668&r1=667&r2=668
==============================================================================
--- ice/branches/slice-translator-versioning/cpp/include/Slice/Parser.h (original)
+++ ice/branches/slice-translator-versioning/cpp/include/Slice/Parser.h Thu Jun 10 07:32:29 2010
@@ -332,6 +332,18 @@
 // Contained
 // ----------------------------------------------------------------------
 
+class SLICE_API ScopeGeneratorPolicy : public ::IceUtil::SimpleShared
+{
+public:
+    virtual ~ScopeGeneratorPolicy() {}
+    virtual std::string scopedName(ContainedPtr) const  = 0;
+    virtual std::string scope(ContainedPtr) const = 0;
+};
+
+typedef ::IceUtil::Handle<ScopeGeneratorPolicy> ScopeGeneratorPolicyPtr;
+
+SLICE_API ScopeGeneratorPolicyPtr createSuppressorGenerator();
+
 class SLICE_API Contained : virtual public SyntaxTreeBase
 {
 public:
@@ -341,9 +353,14 @@
     std::string scoped() const;
     std::string scope() const;
     std::string flattenedScope() const;
+    std::string scoped(bool) const;
+    std::string scope(bool) const;
+    std::string flattenedScope(bool) const;
     std::string file() const;
     std::string line() const;
     std::string comment() const;
+
+    void setScopeGeneratorPolicy(const ScopeGeneratorPolicyPtr&);
 
     int includeLevel() const;
     void updateIncludeLevel();
@@ -391,6 +408,7 @@
     std::string _comment;
     int _includeLevel;
     std::list<std::string> _metaData;
+    ScopeGeneratorPolicyPtr _scopeGeneratorPolicy;
 };
 
 // ----------------------------------------------------------------------
@@ -1002,6 +1020,8 @@
 
     BuiltinPtr builtin(Builtin::Kind); // Not const, as builtins are created on the fly. (Lazy initialization.)
 
+    void setScopeGeneratorPolicy(const ScopeGeneratorPolicyPtr&);
+
 private:
 
     Unit(bool, bool, bool, const StringList&);

Modified: ice/branches/slice-translator-versioning/cpp/src/Slice/Parser.cpp
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/slice-translator-versioning/cpp/src/Slice/Parser.cpp?view=diff&rev=668&r1=667&r2=668
==============================================================================
--- ice/branches/slice-translator-versioning/cpp/src/Slice/Parser.cpp (original)
+++ ice/branches/slice-translator-versioning/cpp/src/Slice/Parser.cpp Thu Jun 10 07:32:29 2010
@@ -315,6 +315,39 @@
     _definitionContext = 0;
 }
 
+class SuppressorGeneratorPolicy : public ScopeGeneratorPolicy
+{
+public:
+    string scopedName(Slice::ContainedPtr c) const
+    {
+	string result = scope(c) + c->name();
+	return result;
+    }
+
+    string scope(Slice::ContainedPtr c) const
+    {
+	std::string newScope = c->scope(false);
+	for(Slice::ContainedPtr contained = c; contained; contained = Slice::ContainedPtr::dynamicCast(contained->container())) 
+	{
+	    Slice::ModulePtr mod = Slice::ModulePtr::dynamicCast(contained);
+	    if(mod && mod->hasMetaData("suppress")) 
+	    {
+		string scopeToSuppress = "::" + mod->name();
+		string::size_type pos = newScope.rfind(scopeToSuppress);
+		newScope.replace(pos, scopeToSuppress.length(), "");
+	    }
+	}
+	return newScope;
+    }
+};
+
+Slice::ScopeGeneratorPolicyPtr 
+Slice::createSuppressorGenerator()
+{
+    return new SuppressorGeneratorPolicy;
+}
+
+
 // ----------------------------------------------------------------------
 // Contained
 // ----------------------------------------------------------------------
@@ -334,12 +367,20 @@
 string
 Slice::Contained::scoped() const
 {
+    if(_scopeGeneratorPolicy)
+    {
+	return _scopeGeneratorPolicy->scopedName(const_cast<Slice::Contained*>(this));
+    }
     return _scoped;
 }
 
 string
 Slice::Contained::scope() const
 {
+    if(_scopeGeneratorPolicy)
+    {
+	return _scopeGeneratorPolicy->scope(const_cast<Slice::Contained*>(this));
+    }
     string::size_type idx = _scoped.rfind("::");
     assert(idx != string::npos);
     return string(_scoped, 0, idx + 2);
@@ -358,6 +399,40 @@
 }
 
 string
+Slice::Contained::scoped(bool usePolicy) const
+{
+    if(usePolicy)
+    {
+	return scoped();
+    }
+    return _scoped;
+}
+
+string
+Slice::Contained::scope(bool usePolicy) const
+{
+    if(usePolicy)
+    {
+	return scope();
+    }
+    string::size_type idx = _scoped.rfind("::");
+    assert(idx != string::npos);
+    return string(_scoped, 0, idx + 2);
+}
+
+string
+Slice::Contained::flattenedScope(bool usePolicy) const
+{
+    string s = scope(usePolicy);
+    string flattenedScope;
+    for(string::const_iterator r = s.begin(); r != s.end(); ++r)
+    {
+        flattenedScope += ((*r) == ':') ? '_' : *r;
+    }
+    return flattenedScope;
+}
+
+string
 Slice::Contained::file() const
 {
     return _file;
@@ -373,6 +448,12 @@
 Slice::Contained::comment() const
 {
     return _comment;
+}
+
+void 
+Slice::Contained::setScopeGeneratorPolicy(const Slice::ScopeGeneratorPolicyPtr& policy)
+{
+    _scopeGeneratorPolicy = policy;
 }
 
 int
@@ -5665,6 +5746,18 @@
     return builtin;
 }
 
+void
+Slice::Unit::setScopeGeneratorPolicy(const ScopeGeneratorPolicyPtr& policy)
+{
+    for(map<string, Slice::ContainedList>::iterator i = _contentMap.begin(); i != _contentMap.end(); ++i)
+    {
+	for(Slice::ContainedList::iterator j = i->second.begin(); j != i->second.end(); ++ j)
+	{
+	    (*j)->setScopeGeneratorPolicy(policy);
+	}
+    }
+}
+
 Slice::Unit::Unit(bool ignRedefs, bool all, bool allowIcePrefix, const StringList& defaultGlobalMetadata) :
     SyntaxTreeBase(0),
     Container(0),

Modified: ice/branches/slice-translator-versioning/cpp/src/slice2cpp/Gen.cpp
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/slice-translator-versioning/cpp/src/slice2cpp/Gen.cpp?view=diff&rev=668&r1=667&r2=668
==============================================================================
--- ice/branches/slice-translator-versioning/cpp/src/slice2cpp/Gen.cpp (original)
+++ ice/branches/slice-translator-versioning/cpp/src/slice2cpp/Gen.cpp Thu Jun 10 07:32:29 2010
@@ -25,44 +25,6 @@
 using namespace Slice;
 using namespace IceUtil;
 using namespace IceUtilInternal;
-
-static string
-suppressedflattenedScope(const ContainerPtr& cp, string flattenedScope, bool _suppress)
-{
-    string suppressed_scope = flattenedScope;
-
-    if (_suppress) {
-	for (ContainedPtr contained = ContainedPtr::dynamicCast(cp); contained; contained = ContainedPtr::dynamicCast(contained->container())) {
-	    ModulePtr mod = ModulePtr::dynamicCast(contained);
-	    if (mod && mod->hasMetaData("suppress")) {
-		string suppress_string = mod->name() + "__";
-		string::size_type pos = suppressed_scope.rfind(suppress_string);
-		suppressed_scope.replace(pos, suppress_string.length(), "");
-	    }
-	}
-    }
-
-    return suppressed_scope;
-}
-
-static string
-suppressedscoped(const ContainerPtr& cp, string scope, bool _suppress)
-{
-    string suppressed_scope = scope;
-
-    if (_suppress) {
-	for (ContainedPtr contained = ContainedPtr::dynamicCast(cp); contained; contained = ContainedPtr::dynamicCast(contained->container())) {
-	    ModulePtr mod = ModulePtr::dynamicCast(contained);
-	    if (mod && mod->hasMetaData("suppress")) {
-		string suppress_string = "::" + mod->name();
-		string::size_type pos = suppressed_scope.rfind(suppress_string);
-		suppressed_scope.replace(pos, suppress_string.length(), "");
-	    }
-	}
-    }
-
-    return suppressed_scope;
-}
 
 static string
 getDeprecateSymbol(const ContainedPtr& p1, const ContainedPtr& p2)
@@ -211,6 +173,12 @@
 {
     string file = p->topLevelFile();
 
+    if(_suppress)
+    {
+	p->setScopeGeneratorPolicy(createSuppressorGenerator());
+    }
+    
+
     //
     // Give precedence to header-ext global metadata.
     //
@@ -631,7 +599,7 @@
     _useWstring = setUseWstring(p, _useWstringHist, _useWstring);
 
     string name = fixKwd(p->name());
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
+    string scoped = fixKwd(p->scoped());
     ExceptionPtr base = p->base();
     DataMemberList dataMembers = p->dataMembers();
     DataMemberList allDataMembers = p->allDataMembers();
@@ -673,7 +641,7 @@
     }
     else
     {
-        H << fixKwd(suppressedscoped(base->container(), base->scoped(), _suppress));
+        H << fixKwd(base->scoped());
     }
     H.restoreIndent();
     H << sb;
@@ -798,7 +766,7 @@
 
     H << nl << "virtual ::std::string ice_name() const;";
 
-    string flatName = suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + p->name() + "_name";
+    string flatName = p->flattenedScope() + p->name() + "_name";
 
     C << sp << nl << "static const char* " << flatName << " = \"" << p->scoped().substr(2) << "\";";
     C << sp << nl << "::std::string" << nl << scoped.substr(2) << "::ice_name() const";
@@ -838,8 +806,8 @@
 Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
 {
     string name = fixKwd(p->name());
-    string scope = fixKwd(suppressedscoped(p->container(), p->scope(), _suppress));
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
+    string scope = fixKwd(p->scope());
+    string scoped = fixKwd(p->scoped());
     DataMemberList dataMembers = p->dataMembers();
     DataMemberList::const_iterator q;
 
@@ -906,7 +874,7 @@
             C << nl << "void" << nl << scoped.substr(2)
               << "::__write(const ::Ice::OutputStreamPtr& __outS) const";
             C << sb;
-            C << nl << "__outS->write(::std::string(\"" << suppressedscoped(p->container(), p->scoped(), _suppress) << "\"));";
+            C << nl << "__outS->write(::std::string(\"" << p->scoped() << "\"));";
             C << nl << "__outS->startSlice();";
             for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
             {
@@ -987,7 +955,7 @@
             }
         }
 
-        factoryName = "__F" + suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + p->name();
+        factoryName = "__F" + p->flattenedScope() + p->name();
 
         C << sp << nl << "struct " << factoryName << " : public ::IceInternal::UserExceptionFactory";
         C << sb;
@@ -1025,7 +993,7 @@
         C << sp << nl << "static " << factoryName << "__Init "<< factoryName << "__i;";
         C << sp << nl << "#ifdef __APPLE__";
 
-        string initfuncname = "__F" + suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + p->name() + "__initializer";
+        string initfuncname = "__F" + p->flattenedScope() + p->name() + "__initializer";
         C << nl << "extern \"C\" { void " << initfuncname << "() {} }";
         C << nl << "#endif";
     }
@@ -1068,7 +1036,7 @@
         {
             H << nl << name << "();";
 
-            C << sp << nl << fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress)).substr(2) << "::" << fixKwd(p->name()) << "() :";
+            C << sp << nl << fixKwd(p->scoped()).substr(2) << "::" << fixKwd(p->name()) << "() :";
             C.inc();
             writeDataMemberInitializers(C, dataMembers, _useWstring);
             C.dec();
@@ -1099,7 +1067,7 @@
             }
             H << name << spar << types << epar << ';';
 
-            C << sp << nl << fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress)).substr(2) << "::"
+            C << sp << nl << fixKwd(p->scoped()).substr(2) << "::"
               << fixKwd(p->name()) << spar << paramDecls << epar << " :";
             C.inc();
 
@@ -1126,7 +1094,7 @@
         {
             H << nl << name << "();";
 
-            C << sp << nl << fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress)).substr(2) << "::" << fixKwd(p->name()) << "() :";
+            C << sp << nl << fixKwd(p->scoped()).substr(2) << "::" << fixKwd(p->name()) << "() :";
             C.inc();
             writeDataMemberInitializers(C, dataMembers, _useWstring);
             C.dec();
@@ -1142,8 +1110,8 @@
 Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
 {
     string name = fixKwd(p->name());
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
-    string scope = fixKwd(suppressedscoped(p->container(), p->scope(), _suppress));
+    string scoped = fixKwd(p->scoped());
+    string scope = fixKwd(p->scope());
 
     DataMemberList dataMembers = p->dataMembers();
     DataMemberList::const_iterator q;
@@ -1308,13 +1276,13 @@
             C << nl << "#if !defined(_MSC_VER) || (_MSC_VER >= 1300)";
             C.restoreIndent();
             C << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
-              << "(const ::Ice::OutputStreamPtr& __outS, const " << fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress) + "Ptr") << "& __v)";
+              << "(const ::Ice::OutputStreamPtr& __outS, const " << fixKwd(p->scoped() + "Ptr") << "& __v)";
             C << sb;
             C << nl << "__v->ice_write(__outS);";
             C << eb;
 
             C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
-              << "(const ::Ice::InputStreamPtr& __inS, " << fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress) + "Ptr") << "& __v)";
+              << "(const ::Ice::InputStreamPtr& __inS, " << fixKwd(p->scoped() + "Ptr") << "& __v)";
             C << sb;
             C << nl << "__v->ice_read(__inS);";
             C << eb;
@@ -1418,8 +1386,8 @@
     BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
     if(!p->isLocal())
     {
-        string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
-        string scope = fixKwd(suppressedscoped(p->container(), p->scope(), _suppress));
+        string scoped = fixKwd(p->scoped());
+        string scope = fixKwd(p->scope());
 
         if(protobuf || !seqType.empty())
         {
@@ -1673,8 +1641,8 @@
 
     if(!p->isLocal())
     {
-        string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
-        string scope = fixKwd(suppressedscoped(p->container(), p->scope(), _suppress));
+        string scoped = fixKwd(p->scoped());
+        string scope = fixKwd(p->scope());
 
         H << nl << _dllExport << "void __write" << name << "(::IceInternal::BasicStream*, const " << name << "&);";
         H << nl << _dllExport << "void __read" << name << "(::IceInternal::BasicStream*, " << name << "&);";
@@ -1778,8 +1746,8 @@
 
     if(!p->isLocal())
     {
-        string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
-        string scope = fixKwd(suppressedscoped(p->container(), p->scope(), _suppress));
+        string scoped = fixKwd(p->scoped());
+        string scope = fixKwd(p->scope());
 
         size_t sz = enumerators.size();
         assert(sz <= 0x7fffffff); // 64-bit enums are not supported
@@ -1880,7 +1848,7 @@
     C.zeroIndent();
     C << nl << "#else";
     C.restoreIndent();
-    C << nl << (base ? fixKwd(suppressedscoped(base->container(), base->scoped(), _suppress)) : string(isLocal ? "::Ice::LocalException" : "::Ice::UserException"))
+    C << nl << (base ? fixKwd(base->scoped()) : string(isLocal ? "::Ice::LocalException" : "::Ice::UserException"))
       << call;
     C.zeroIndent();
     C << nl << "#endif";
@@ -2013,7 +1981,7 @@
     _useWstring = setUseWstring(p, _useWstringHist, _useWstring);
 
     string name = fixKwd(p->name());
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
+    string scoped = fixKwd(p->scoped());
     ClassList bases = p->bases();
 
     H << sp << nl << "class " << name << " : ";
@@ -2060,8 +2028,8 @@
 Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p)
 {
     string name = fixKwd(p->name());
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
-    string scope = fixKwd(suppressedscoped(p->container(), p->scope(), _suppress));
+    string scoped = fixKwd(p->scoped());
+    string scope = fixKwd(p->scope());
 
     //
     // "Overwrite" various non-virtual functions in ::IceProxy::Ice::Object that return an ObjectPrx and
@@ -2410,8 +2378,8 @@
 Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
 {
     string name = p->name();
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
-    string scope = fixKwd(suppressedscoped(p->container(), p->scope(), _suppress));
+    string scoped = fixKwd(p->scoped());
+    string scope = fixKwd(p->scope());
 
     TypePtr ret = p->returnType();
     string retS = returnTypeToString(ret, p->getMetaData(), _useWstring | TypeContextAMIEnd);
@@ -2419,7 +2387,7 @@
 
     ContainerPtr container = p->container();
     ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
-    string clScope = fixKwd(suppressedscoped(container, cl->scope(), _suppress));
+    string clScope = fixKwd(cl->scope());
     string delName = "Callback_" + cl->name() + "_" + name;
     string delNameScoped = clScope + delName;
 
@@ -2590,7 +2558,7 @@
 
     if(p->returnsData())
     {
-        C << nl << "__checkTwowayOnly(" << suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + p->name() + "_name);";
+        C << nl << "__checkTwowayOnly(" << p->flattenedScope() + p->name() + "_name);";
     }
     C << nl << "__delBase = __getDelegate(false);";
     C << nl << "::IceDelegate" << thisPointer << " __del = dynamic_cast< ::IceDelegate"
@@ -2628,7 +2596,7 @@
       << "const ::Ice::Context* __ctx" << "const ::IceInternal::CallbackBasePtr& __del"
       << "const ::Ice::LocalObjectPtr& __cookie" << epar;
     C << sb;
-    string flatName = suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + name + "_name";
+    string flatName = p->flattenedScope() + name + "_name";
     if(p->returnsData())
     {
 	C << nl << "__checkAsyncTwowayOnly(" << flatName <<  ");";
@@ -2786,7 +2754,7 @@
     if(cl->hasMetaData("ami") || p->hasMetaData("ami"))
     {
         string classNameAMI = "AMI_" + cl->name();
-        string classScope = fixKwd(suppressedscoped(container, cl->scope(), _suppress));
+        string classScope = fixKwd(cl->scope());
         string classScopedAMI = classScope + classNameAMI;
         string opScopedAMI = classScopedAMI + "_" + name;
 
@@ -3110,7 +3078,7 @@
     _useWstring = setUseWstring(p, _useWstringHist, _useWstring);
 
     string name = fixKwd(p->name());
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
+    string scoped = fixKwd(p->scoped());
     ClassList bases = p->bases();
 
     H << sp << nl << "class " << _dllExport << name << " : ";
@@ -3153,7 +3121,7 @@
 Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
 {
     string name = fixKwd(p->name());
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
+    string scoped = fixKwd(p->scoped());
 
     TypePtr ret = p->returnType();
     string retS = returnTypeToString(ret, p->getMetaData(), _useWstring);
@@ -3189,7 +3157,7 @@
     params.push_back("const ::Ice::Context*");
     paramsDecl.push_back("const ::Ice::Context* __context");
 
-    string flatName = suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + p->name() + "_name";
+    string flatName = p->flattenedScope() + p->name() + "_name";
 
     H << sp << nl << "virtual " << retS << ' ' << name << spar << params << epar << ';';
     C << sp << nl << retS << nl << "IceDelegateM" << scoped << spar << paramsDecl << epar;
@@ -3388,7 +3356,7 @@
     _useWstring = setUseWstring(p, _useWstringHist, _useWstring);
 
     string name = fixKwd(p->name());
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
+    string scoped = fixKwd(p->scoped());
     ClassList bases = p->bases();
 
     H << sp << nl << "class " << _dllExport << name << " : ";
@@ -3431,7 +3399,7 @@
 Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
 {
     string name = fixKwd(p->name());
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
+    string scoped = fixKwd(p->scoped());
 
     TypePtr ret = p->returnType();
     string retS = returnTypeToString(ret, p->getMetaData(), _useWstring);
@@ -3477,7 +3445,7 @@
 
     ContainerPtr container = p->container();
     ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
-    string thisPointer = fixKwd(suppressedscoped(container, cl->scoped(), _suppress)) + "*";
+    string thisPointer = fixKwd(cl->scoped()) + "*";
 
     H << sp;
 
@@ -3603,7 +3571,7 @@
         C << eb << ";";
 
         C << nl << nl << "::Ice::Current __current;";
-        C << nl << "__initCurrent(__current, " << suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + p->name() + "_name, "
+        C << nl << "__initCurrent(__current, " << p->flattenedScope() + p->name() + "_name, "
           << operationModeToString(p->sendMode()) << ", __context);";
 
         if(ret)
@@ -3721,7 +3689,7 @@
 void
 Slice::Gen::ObjectDeclVisitor::visitOperation(const OperationPtr& p)
 {
-    string flatName = suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + p->name() + "_name";
+    string flatName = p->flattenedScope() + p->name() + "_name";
     C << sp << nl << "static const ::std::string " << flatName << " = \"" << p->name() << "\";";
 }
 
@@ -3766,7 +3734,7 @@
     _useWstring = setUseWstring(p, _useWstringHist, _useWstring);
 
     string name = fixKwd(p->name());
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
+    string scoped = fixKwd(p->scoped());
     ClassList bases = p->bases();
     ClassDefPtr base;
     if(!bases.empty() && !bases.front()->isInterface())
@@ -4002,7 +3970,7 @@
         C << sb;
         if(!p->isAbstract())
         {
-            C << nl << fixKwd(suppressedscoped(p->container(), p->scope(), _suppress)) << p->name() << "Ptr __p = new " << scoped << "(*this);";
+            C << nl << fixKwd(p->scope()) << p->name() << "Ptr __p = new " << scoped << "(*this);";
             C << nl << "return __p;";
         }
         else
@@ -4025,13 +3993,13 @@
         transform(allBases.begin(), allBases.end(), back_inserter(ids), ::IceUtil::constMemFun(&Contained::scoped));
 #endif
         StringList other;
-        other.push_back(p->scoped());
+        other.push_back(p->scoped(false));
         other.push_back("::Ice::Object");
         other.sort();
         ids.merge(other);
         ids.unique();
         StringList::const_iterator firstIter = ids.begin();
-        StringList::const_iterator scopedIter = find(ids.begin(), ids.end(), p->scoped());
+        StringList::const_iterator scopedIter = find(ids.begin(), ids.end(), p->scoped(false));
         assert(scopedIter != ids.end());
         StringList::difference_type scopedPos = IceUtilInternal::distance(firstIter, scopedIter);
 
@@ -4047,7 +4015,7 @@
             H << sp;
         }
 
-        string flatName = suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + p->name() + "_ids";
+        string flatName = p->flattenedScope() + p->name() + "_ids";
 
         C << sp;
         C << nl << "static const ::std::string " << flatName << '[' << ids.size() << "] =";
@@ -4101,8 +4069,8 @@
 void
 Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
 {
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
-    string scope = fixKwd(suppressedscoped(p->container(), p->scope(), _suppress));
+    string scoped = fixKwd(p->scoped());
+    string scope = fixKwd(p->scope());
 
     if(!p->isLocal())
     {
@@ -4140,7 +4108,7 @@
             H << nl
               << "virtual ::Ice::DispatchStatus __dispatch(::IceInternal::Incoming&, const ::Ice::Current&);";
 
-            string flatName = suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + p->name() + "_all";
+            string flatName = p->flattenedScope() + p->name() + "_all";
             C << sp;
             C << nl << "static ::std::string " << flatName << "[] =";
             C << sb;
@@ -4205,7 +4173,7 @@
                 H << nl
                   << "virtual ::Ice::Int ice_operationAttributes(const ::std::string&) const;";
 
-                string opAttrFlatName = suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + p->name() + "_operationAttributes";
+                string opAttrFlatName = p->flattenedScope() + p->name() + "_operationAttributes";
 
                 C << sp;
                 C << nl << "static int " << opAttrFlatName << "[] = ";
@@ -4368,7 +4336,7 @@
         {
             H << sp << nl << "static const ::Ice::ObjectFactoryPtr& ice_factory();";
 
-            string factoryName = "__F" + suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + p->name();
+            string factoryName = "__F" +  p->flattenedScope() + p->name();
             C << sp;
             C << nl << "class " << factoryName << " : public ::Ice::ObjectFactory";
             C << sb;
@@ -4414,7 +4382,7 @@
             C << sp;
             C << nl << "static " << factoryName << "__Init " << factoryName << "__i;";
             C << sp << nl << "#ifdef __APPLE__";
-            std::string initfuncname = "__F" + suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + p->name() + "__initializer";
+            std::string initfuncname = "__F" +  p->flattenedScope() + p->name() + "__initializer";
             C << nl << "extern \"C\" { void " << initfuncname << "() {} }";
             C << nl << "#endif";
         }
@@ -4573,8 +4541,8 @@
 Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
 {
     string name = p->name();
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
-    string scope = fixKwd(suppressedscoped(p->container(), p->scope(), _suppress));
+    string scoped = fixKwd(p->scoped());
+    string scope = fixKwd(p->scope());
 
     TypePtr ret = p->returnType();
     string retS = returnTypeToString(ret, p->getMetaData(), _useWstring);
@@ -4586,7 +4554,7 @@
     ContainerPtr container = p->container();
     ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
     string classNameAMD = "AMD_" + cl->name();
-    string classScope = fixKwd(suppressedscoped(container, cl->scope(), _suppress));
+    string classScope = fixKwd(cl->scope());
     string classScopedAMD = classScope + classNameAMD;
 
     string paramsAMD = "(const " + classScopedAMD + '_' + name + "Ptr&, ";
@@ -4842,7 +4810,7 @@
           << "const ::Ice::CallbackPtr& __del"
           << "const ::Ice::LocalObjectPtr& __cookie = 0" << epar << " = 0;";
 
-        string clScope = fixKwd(suppressedscoped(container, cl->scope(), _suppress));
+        string clScope = fixKwd(cl->scope());
         string delName = "Callback_" + cl->name() + "_" + name;
         string delNameScoped = clScope + delName;
 
@@ -4858,7 +4826,7 @@
 void
 Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p)
 {
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
+    string scoped = fixKwd(p->scoped());
     ClassList bases = p->bases();
     DataMemberList dataMembers = p->dataMembers();
 
@@ -5120,7 +5088,7 @@
     C.zeroIndent();
     C << nl << "#else";
     C.restoreIndent();
-    C << nl << fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress)) << upcall;
+    C << nl << fixKwd(p->scoped()) << upcall;
     C.zeroIndent();
     C << nl << "#endif";
     C << nl;
@@ -5145,7 +5113,7 @@
 
     if(!allDataMembers.empty())
     {
-        C << sp << nl << fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress)).substr(2) << "::" << fixKwd(p->name())
+        C << sp << nl << fixKwd(p->scoped()).substr(2) << "::" << fixKwd(p->name())
 	  << spar << allParamDecls << epar << " :";
         C.inc();
 
@@ -5194,7 +5162,7 @@
     C.zeroIndent();
     C << nl << "#else";
     C.restoreIndent();
-    C << nl << (base ? fixKwd(suppressedscoped(base->container(), base->scoped(), _suppress)) : string("::Ice::Object")) << call;
+    C << nl << (base ? fixKwd(base->scoped()) : string("::Ice::Object")) << call;
     C.zeroIndent();
     C << nl << "#endif";
     C.restoreIndent();
@@ -5367,7 +5335,7 @@
     }
 
     string clName = cl->name();
-    string clScope = fixKwd(suppressedscoped(p->container(), cl->scope(), _suppress));
+    string clScope = fixKwd(cl->scope());
     string delName = "Callback_" + clName + "_" + p->name();
     string delTmplName = (withCookie ? "Callback_" : "CallbackNC_") + clName + "_" + p->name();
 
@@ -5656,7 +5624,7 @@
 void
 Slice::Gen::IceInternalVisitor::visitClassDecl(const ClassDeclPtr& p)
 {
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
+    string scoped = fixKwd(p->scoped());
 
     H << sp;
 
@@ -5674,7 +5642,7 @@
 bool
 Slice::Gen::IceInternalVisitor::visitClassDefStart(const ClassDefPtr& p)
 {
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
+    string scoped = fixKwd(p->scoped());
 
     C << sp;
     if(!p->isLocal())
@@ -5733,7 +5701,7 @@
 Slice::Gen::HandleVisitor::visitClassDecl(const ClassDeclPtr& p)
 {
     string name = p->name();
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
+    string scoped = fixKwd(p->scoped());
 
     H << sp;
     H << nl << "typedef ::IceInternal::Handle< " << scoped << "> " << name << "Ptr;";
@@ -5773,8 +5741,8 @@
     if(!p->isLocal())
     {
         string name = p->name();
-        string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
-        string scope = fixKwd(suppressedscoped(p->container(), p->scope(), _suppress));
+        string scoped = fixKwd(p->scoped());
+        string scope = fixKwd(p->scope());
 
         string factory;
         string type;
@@ -6053,7 +6021,7 @@
     _useWstring = setUseWstring(p, _useWstringHist, _useWstring);
 
     string name = p->name();
-    string scope = fixKwd(suppressedscoped(p->container(), p->scope(), _suppress));
+    string scope = fixKwd(p->scope());
     string cls = scope.substr(2) + name + "I";
     string classScopedAMD = scope + "AMD_" + name;
     ClassList bases = p->bases();
@@ -6338,7 +6306,7 @@
     string className = cl->name();
     string classNameAMI = "AMI_" + className;
     string classNameAMD = "AMD_" + className;
-    string classScope = fixKwd(suppressedscoped(container, cl->scope(), _suppress));
+    string classScope = fixKwd(cl->scope());
     string classScopedAMI = classScope + classNameAMI;
     string classScopedAMD = classScope + classNameAMD;
     string proxyName = classScope + className + "Prx";
@@ -6528,7 +6496,7 @@
     string name = p->name();
 
     string classNameAMD = "AMD_" + cl->name();
-    string classScope = fixKwd(suppressedscoped(container, cl->scope(), _suppress));
+    string classScope = fixKwd(cl->scope());
     string classScopedAMD = classScope + classNameAMD;
 
     string params;
@@ -6738,7 +6706,7 @@
 {
     if(!p->isLocal())
     {
-        string scoped = suppressedscoped(p->container(), p->scoped(), _suppress);
+        string scoped = p->scoped();
         H << nl << "template<>";
         H << nl << "struct StreamTrait< " << fixKwd(scoped) << ">";
         H << sb;
@@ -6759,7 +6727,7 @@
     if(!p->isLocal())
     {
         bool classMetaData = findMetaData(p->getMetaData(), false) == "class";
-        string scoped = suppressedscoped(p->container(), p->scoped(), _suppress);
+        string scoped = p->scoped();
         H << nl << "template<>";
         if(classMetaData)
         {
@@ -6792,7 +6760,7 @@
 void
 Slice::Gen::StreamVisitor::visitEnum(const EnumPtr& p)
 {
-    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
+    string scoped = fixKwd(p->scoped());
     H << nl << "template<>";
     H << nl << "struct StreamTrait< " << scoped << ">";
     H << sb;

Modified: ice/branches/slice-translator-versioning/cpp/src/slice2cs/Gen.cpp
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/slice-translator-versioning/cpp/src/slice2cs/Gen.cpp?view=diff&rev=668&r1=667&r2=668
==============================================================================
--- ice/branches/slice-translator-versioning/cpp/src/slice2cs/Gen.cpp (original)
+++ ice/branches/slice-translator-versioning/cpp/src/slice2cs/Gen.cpp Thu Jun 10 07:32:29 2010
@@ -42,25 +42,6 @@
 using IceUtilInternal::spar;
 using IceUtilInternal::epar;
 using IceUtilInternal::trim;
-
-static string
-suppressedscoped(const ContainerPtr& cp, string scope, bool _suppress)
-{
-    string suppressed_scope = scope;
-
-    if (_suppress) {
-	for (ContainedPtr contained = ContainedPtr::dynamicCast(cp); contained; contained = ContainedPtr::dynamicCast(contained->container())) {
-	    ModulePtr mod = ModulePtr::dynamicCast(contained);
-	    if (mod && mod->hasMetaData("suppress")) {
-		string suppress_string = "::" + mod->name();
-		string::size_type pos = suppressed_scope.rfind(suppress_string);
-		suppressed_scope.replace(pos, suppress_string.length(), "");
-	    }
-	}
-    }
-
-    return suppressed_scope;
-}
 
 static string // Should be an anonymous namespace, but VC++ 6 can't handle that.
 sliceModeToIceMode(Operation::Mode opMode)
@@ -1823,6 +1804,10 @@
 void
 Slice::Gen::generate(const UnitPtr& p)
 {
+    if(_suppress)
+    {
+	p->setScopeGeneratorPolicy(createSuppressorGenerator());
+    }
     CsGenerator::validateMetaData(p);
 
     UnitVisitor unitVisitor(_out);
@@ -3735,7 +3720,7 @@
     // Write the operations for the new async mapping.
     //
     vector<string> paramsNewAsync = getParamsAsync(p, false, true);
-    string clScope = fixId(suppressedscoped(p->container(), cl->scope(), _suppress));
+    string clScope = fixId(cl->scope());
     string delType = clScope + "Callback_" + cl->name() + "_" + p->name();
 
     _out << sp;
@@ -4193,7 +4178,7 @@
         // Write the begin_ methods.
         //
         ClassDefPtr cl = ClassDefPtr::dynamicCast(op->container());
-        string clScope = fixId(suppressedscoped(op->container(), cl->scope(), _suppress));
+        string clScope = fixId(cl->scope());
         string delType = clScope + "Callback_" + cl->name() + "_" + op->name();
 
         _out << sp;

Modified: ice/branches/slice-translator-versioning/cpp/src/slice2java/Gen.cpp
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/slice-translator-versioning/cpp/src/slice2java/Gen.cpp?view=diff&rev=668&r1=667&r2=668
==============================================================================
--- ice/branches/slice-translator-versioning/cpp/src/slice2java/Gen.cpp (original)
+++ ice/branches/slice-translator-versioning/cpp/src/slice2java/Gen.cpp Thu Jun 10 07:32:29 2010
@@ -1756,6 +1756,10 @@
 void
 Slice::Gen::generate(const UnitPtr& p, bool stream)
 {
+    if(_suppress)
+    {
+	p->setScopeGeneratorPolicy(createSuppressorGenerator());
+    }
     JavaGenerator::validateMetaData(p);
 
     OpsVisitor opsVisitor(_dir, _suppress);

Added: ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/.depend
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/.depend?view=auto&rev=668
==============================================================================
--- ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/.depend (added)
+++ ice/branches/slice-translator-versioning/cpp/test/Ice/versioning/.depend Thu Jun 10 07:32:29 2010
@@ -1,0 +1,4 @@
+Test$(OBJEXT): Test.cpp Test.h $(includedir)/Ice/LocalObjectF.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/Ice/Handle.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/Ice/Config.h $(includedir)/Ice/ProxyHandle.h $(includedir)/Ice/ProxyF.h $(includedir)/Ice/ObjectF.h $(includedir)/Ice/Exception.h $(includedir)/Ice/LocalObject.h $(includedir)/Ice/Proxy.h $(includedir)/IceUtil/Mutex.h $(includedir)/IceUtil/Lock.h $(includedir)/IceUtil/ThreadException.h $(includedir)/IceUtil/Time.h $(includedir)/IceUtil/MutexProtocol.h $(includedir)/Ice/ProxyFactoryF.h $(includedir)/Ice/ConnectionIF.h $(includedir)/Ice/RequestHandlerF.h $(includedir)/Ice/EndpointIF.h $(includedir)/Ice/EndpointF.h $(includedir)/IceUtil/ScopedArray.h $(includedir)/Ice/UndefSysMacros.h $(includedir)/Ice/EndpointTypes.h $(includedir)/Ice/ObjectAdapterF.h $(includedir)/Ice/ReferenceF.h $(includedir)/Ice/OutgoingAsync.h $(includedir)/IceUtil/Monitor.h $(includedir)/IceUtil/Cond.h $(includedir)/IceUtil/Timer.h $(includedir)/IceUtil/Thread.h $(includedir)/Ice/OutgoingAsyncF.h $(includedir)/Ice/InstanceF.h $(includedir)/Ice/CommunicatorF.h $(includedir)/Ice/Current.h $(includedir)/Ice/ConnectionF.h $(includedir)/Ice/Identity.h $(includedir)/Ice/BasicStream.h $(includedir)/Ice/ObjectFactoryF.h $(includedir)/Ice/Buffer.h $(includedir)/Ice/Protocol.h $(includedir)/Ice/StreamF.h $(includedir)/Ice/Object.h $(includedir)/Ice/GCShared.h $(includedir)/Ice/GCCountMap.h $(includedir)/Ice/IncomingAsyncF.h $(includedir)/Ice/Outgoing.h $(includedir)/Ice/Incoming.h $(includedir)/Ice/ServantLocatorF.h $(includedir)/Ice/ServantManagerF.h $(includedir)/Ice/Direct.h $(includedir)/Ice/FactoryTableInit.h $(includedir)/Ice/FactoryTable.h $(includedir)/Ice/UserExceptionFactory.h $(includedir)/Ice/LocalException.h $(includedir)/Ice/BuiltinSequences.h $(includedir)/Ice/Stream.h $(includedir)/Ice/ObjectFactory.h $(includedir)/IceUtil/Iterator.h

[... 583 lines stripped ...]




More information about the asterisk-scf-commits mailing list