[hydra-commits] beagles: branch ice/hydra-modified-ice r664 - in /ice/branches/hydra-modified...

SVN commits to the Hydra project hydra-commits at lists.digium.com
Mon Jun 7 09:00:53 CDT 2010


Author: beagles
Date: Mon Jun  7 09:00:52 2010
New Revision: 664

URL: https://origsvn.digium.com/svn-view/hydra?view=rev&rev=664
Log:
Merging changes from 645:660 slice-translator-versioning.

Modified:
    ice/branches/hydra-modified-ice/   (props changed)
    ice/branches/hydra-modified-ice/Makefile.mak   (props changed)
    ice/branches/hydra-modified-ice/cpp/include/Slice/PythonUtil.h
    ice/branches/hydra-modified-ice/cpp/include/Slice/RubyUtil.h
    ice/branches/hydra-modified-ice/cpp/src/IceBox/ServiceManagerI.cpp   (props changed)
    ice/branches/hydra-modified-ice/cpp/src/IceBox/ServiceManagerI.h   (props changed)
    ice/branches/hydra-modified-ice/cpp/src/Slice/PythonUtil.cpp
    ice/branches/hydra-modified-ice/cpp/src/Slice/RubyUtil.cpp
    ice/branches/hydra-modified-ice/cpp/src/slice2cpp/Gen.cpp
    ice/branches/hydra-modified-ice/cpp/src/slice2cpp/Gen.h
    ice/branches/hydra-modified-ice/cpp/src/slice2cpp/Main.cpp
    ice/branches/hydra-modified-ice/cpp/src/slice2cs/Gen.cpp
    ice/branches/hydra-modified-ice/cpp/src/slice2cs/Gen.h
    ice/branches/hydra-modified-ice/cpp/src/slice2cs/Main.cpp
    ice/branches/hydra-modified-ice/cpp/src/slice2java/Gen.cpp
    ice/branches/hydra-modified-ice/cpp/src/slice2java/Gen.h
    ice/branches/hydra-modified-ice/cpp/src/slice2java/Main.cpp
    ice/branches/hydra-modified-ice/cpp/src/slice2py/Main.cpp
    ice/branches/hydra-modified-ice/cpp/src/slice2rb/Main.cpp
    ice/branches/hydra-modified-ice/cs/src/IceBox/ServiceManagerI.cs   (props changed)
    ice/branches/hydra-modified-ice/java/src/IceBox/ServiceManagerI.java   (props changed)
    ice/branches/hydra-modified-ice/py/modules/IcePy/Slice.cpp
    ice/branches/hydra-modified-ice/rb/src/IceRuby/Slice.cpp
    ice/branches/hydra-modified-ice/scripts/TestUtil.py   (props changed)
    ice/branches/hydra-modified-ice/slice/IceBox/IceBox.ice   (props changed)

Propchange: ice/branches/hydra-modified-ice/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun  7 09:00:52 2010
@@ -1,2 +1,3 @@
 /ice/branches/icebox-local:149-423
+/ice/branches/slice-translator-versioning:645-663
 /ice/upstream/3.4.0:509-510,607

Propchange: ice/branches/hydra-modified-ice/Makefile.mak
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun  7 09:00:52 2010
@@ -1,4 +1,5 @@
 /ice/branches/icebox-local/Makefile.mak:149-423
 /ice/branches/skipped-slice-recovery/Makefile.mak:565-582
 /ice/branches/slice-preserving-translators/Makefile.mak:583-599
+/ice/branches/slice-translator-versioning/Makefile.mak:645-663
 /ice/upstream/3.4.0/Makefile.mak:509-510

Modified: ice/branches/hydra-modified-ice/cpp/include/Slice/PythonUtil.h
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/hydra-modified-ice/cpp/include/Slice/PythonUtil.h?view=diff&rev=664&r1=663&r2=664
==============================================================================
--- ice/branches/hydra-modified-ice/cpp/include/Slice/PythonUtil.h (original)
+++ ice/branches/hydra-modified-ice/cpp/include/Slice/PythonUtil.h Mon Jun  7 09:00:52 2010
@@ -21,7 +21,7 @@
 //
 // Generate Python code for a translation unit.
 //
-SLICE_API void generate(const Slice::UnitPtr&, bool, bool, const std::vector<std::string>&, IceUtilInternal::Output&);
+SLICE_API void generate(const Slice::UnitPtr&, bool, bool, const std::vector<std::string>&, IceUtilInternal::Output&, bool);
 
 //
 // Convert a scoped name into a Python name.
@@ -49,7 +49,7 @@
 // COMPILERFIX: MSVC 6 seems to have a problem with const std::string
 // = std::string(), const std::string = std::string().
 //
-SLICE_API std::string getAbsolute(const Slice::ContainedPtr&, const std::string& = "", const std::string& = "");
+SLICE_API std::string getAbsolute(const Slice::ContainedPtr&, bool suppress, const std::string& = "", const std::string& = "");
 
 //
 // Emit a comment header.

Modified: ice/branches/hydra-modified-ice/cpp/include/Slice/RubyUtil.h
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/hydra-modified-ice/cpp/include/Slice/RubyUtil.h?view=diff&rev=664&r1=663&r2=664
==============================================================================
--- ice/branches/hydra-modified-ice/cpp/include/Slice/RubyUtil.h (original)
+++ ice/branches/hydra-modified-ice/cpp/include/Slice/RubyUtil.h Mon Jun  7 09:00:52 2010
@@ -21,7 +21,7 @@
 //
 // Generate Ruby code for a translation unit.
 //
-SLICE_API void generate(const Slice::UnitPtr&, bool, bool, const std::vector<std::string>&, IceUtilInternal::Output&);
+SLICE_API void generate(const Slice::UnitPtr&, bool, bool, const std::vector<std::string>&, IceUtilInternal::Output&, bool);
 
 //
 // Check the given identifier against Ruby's list of reserved words. If it matches
@@ -39,7 +39,7 @@
 // Get the fully-qualified name of the given definition. If a prefix is provided,
 // it is prepended to the definition's unqualified name.
 //
-SLICE_API std::string getAbsolute(const Slice::ContainedPtr&, IdentStyle, const std::string& = std::string());
+SLICE_API std::string getAbsolute(const Slice::ContainedPtr&, bool, IdentStyle, const std::string& = std::string());
 
 //
 // Emit a comment header.

Propchange: ice/branches/hydra-modified-ice/cpp/src/IceBox/ServiceManagerI.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun  7 09:00:52 2010
@@ -1,3 +1,4 @@
 /ice/branches/icebox-local/cpp/src/IceBox/ServiceManagerI.cpp:149-423
+/ice/branches/slice-translator-versioning/cpp/src/IceBox/ServiceManagerI.cpp:645-663
 /ice/trunk/cpp/src/IceBox/ServiceManagerI.cpp:57-149
 /ice/upstream/3.4.0/cpp/src/IceBox/ServiceManagerI.cpp:509-510

Propchange: ice/branches/hydra-modified-ice/cpp/src/IceBox/ServiceManagerI.h
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jun  7 09:00:52 2010
@@ -1,3 +1,4 @@
 /ice/branches/icebox-local/cpp/src/IceBox/ServiceManagerI.h:149-423
+/ice/branches/slice-translator-versioning/cpp/src/IceBox/ServiceManagerI.h:645-663
 /ice/trunk/cpp/src/IceBox/ServiceManagerI.h:57-149
 /ice/upstream/3.4.0/cpp/src/IceBox/ServiceManagerI.h:509-510

Modified: ice/branches/hydra-modified-ice/cpp/src/Slice/PythonUtil.cpp
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/hydra-modified-ice/cpp/src/Slice/PythonUtil.cpp?view=diff&rev=664&r1=663&r2=664
==============================================================================
--- ice/branches/hydra-modified-ice/cpp/src/Slice/PythonUtil.cpp (original)
+++ ice/branches/hydra-modified-ice/cpp/src/Slice/PythonUtil.cpp Mon Jun  7 09:00:52 2010
@@ -73,7 +73,7 @@
 {
 public:
 
-    ModuleVisitor(Output&, set<string>&);
+    ModuleVisitor(Output&, set<string>&, bool);
 
     virtual bool visitModuleStart(const ModulePtr&);
 
@@ -81,6 +81,8 @@
 
     Output& _out;
     set<string>& _history;
+
+    bool _suppress;
 };
 
 //
@@ -90,7 +92,7 @@
 {
 public:
 
-    CodeVisitor(IceUtilInternal::Output&, set<string>&);
+    CodeVisitor(IceUtilInternal::Output&, set<string>&, bool);
 
     virtual bool visitModuleStart(const ModulePtr&);
     virtual void visitModuleEnd(const ModulePtr&);
@@ -172,9 +174,30 @@
     set<string>& _moduleHistory;
     list<string> _moduleStack;
     set<string> _classHistory;
+
+    bool _suppress;
 };
 
 }
+}
+
+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
@@ -231,9 +254,9 @@
 }
 
 static string
-getDictLookup(const ContainedPtr& cont, const string& suffix = string())
-{
-    string scope = Slice::Python::scopedToName(cont->scope());
+getDictLookup(const ContainedPtr& cont, bool suppress, const string& suffix = string())
+{
+    string scope = Slice::Python::scopedToName(suppressedscoped(cont->container(), cont->scope(), suppress));
     assert(!scope.empty());
 
     string package = Slice::Python::getPackageMetadata(cont);
@@ -248,17 +271,17 @@
 //
 // ModuleVisitor implementation.
 //
-Slice::Python::ModuleVisitor::ModuleVisitor(Output& out, set<string>& history) :
-    _out(out), _history(history)
+Slice::Python::ModuleVisitor::ModuleVisitor(Output& out, set<string>& history, bool suppress) :
+    _out(out), _history(history), _suppress(suppress)
 {
 }
 
 bool
 Slice::Python::ModuleVisitor::visitModuleStart(const ModulePtr& p)
 {
-    if(p->includeLevel() > 0)
-    {
-        string abs = getAbsolute(p);
+    if(p->includeLevel() > 0 && (!p->hasMetaData("suppress") || !_suppress))
+    {
+        string abs = getAbsolute(p, _suppress);
         if(_history.count(abs) == 0)
         {
             //
@@ -298,8 +321,8 @@
 //
 // CodeVisitor implementation.
 //
-Slice::Python::CodeVisitor::CodeVisitor(Output& out, set<string>& moduleHistory) :
-    _out(out), _moduleHistory(moduleHistory)
+Slice::Python::CodeVisitor::CodeVisitor(Output& out, set<string>& moduleHistory, bool suppress) :
+    _out(out), _moduleHistory(moduleHistory), _suppress(suppress)
 {
 }
 
@@ -320,7 +343,11 @@
     //
     // This allows us to create types in the module Foo.
     //
-    string abs = getAbsolute(p);
+    if (p->hasMetaData("suppress") && _suppress) {
+	return true;
+    }
+
+    string abs = getAbsolute(p, _suppress);
     _out << sp << nl << "# Start of module " << abs;
     if(_moduleHistory.count(abs) == 0) // Don't emit this more than once for each module.
     {
@@ -366,13 +393,15 @@
 void
 Slice::Python::CodeVisitor::visitModuleEnd(const ModulePtr& p)
 {
-    assert(!_moduleStack.empty());
-    _out << sp << nl << "# End of module " << _moduleStack.front();
-    _moduleStack.pop_front();
-
-    if(!_moduleStack.empty())
-    {
-        _out << sp << nl << "__name__ = '" << _moduleStack.front() << "'";
+    if (!p->hasMetaData("suppress") || !_suppress) {
+	assert(!_moduleStack.empty());
+	_out << sp << nl << "# End of module " << _moduleStack.front();
+	_moduleStack.pop_front();
+
+	if(!_moduleStack.empty())
+	    {
+		_out << sp << nl << "__name__ = '" << _moduleStack.front() << "'";
+	    }
     }
 }
 
@@ -385,13 +414,13 @@
     string scoped = p->scoped();
     if(_classHistory.count(scoped) == 0)
     {
-        _out << sp << nl << "if not " << getDictLookup(p) << ':';
+        _out << sp << nl << "if not " << getDictLookup(p, _suppress) << ':';
         _out.inc();
-        string type = getAbsolute(p, "_t_");
+        string type = getAbsolute(p, _suppress, "_t_");
         _out << nl << "_M_" << type << " = IcePy.declareClass('" << scoped << "')";
         if(!p->isLocal())
         {
-            _out << nl << "_M_" << getAbsolute(p, "_t_", "Prx") << " = IcePy.declareProxy('" << scoped << "')";
+            _out << nl << "_M_" << getAbsolute(p, _suppress, "_t_", "Prx") << " = IcePy.declareProxy('" << scoped << "')";
         }
         _out.dec();
         _classHistory.insert(scoped); // Avoid redundant declarations.
@@ -402,12 +431,12 @@
 Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
 {
     string scoped = p->scoped();
-    string type = getAbsolute(p, "_t_");
-    string abs = getAbsolute(p);
+    string type = getAbsolute(p, _suppress, "_t_");
+    string abs = getAbsolute(p, _suppress);
     string name = fixIdent(p->name());
-    string prxAbs = getAbsolute(p, "", "Prx");
+    string prxAbs = getAbsolute(p, _suppress, "", "Prx");
     string prxName = fixIdent(p->name() + "Prx");
-    string prxType = getAbsolute(p, "_t_", "Prx");
+    string prxType = getAbsolute(p, _suppress, "_t_", "Prx");
     ClassList bases = p->bases();
     ClassDefPtr base;
     OperationList ops = p->operations();
@@ -417,7 +446,7 @@
     //
     // Define the class.
     //
-    _out << sp << nl << "if not " << getDictLookup(p) << ':';
+    _out << sp << nl << "if not " << getDictLookup(p, _suppress) << ':';
     _out.inc();
     _out << nl << "_M_" << abs << " = Ice.createTempClass()";
     _out << nl << "class " << name << '(';
@@ -627,7 +656,7 @@
     //
     _out << sp << nl << "def __str__(self):";
     _out.inc();
-    _out << nl << "return IcePy.stringify(self, _M_" << getAbsolute(p, "_t_") << ")";
+    _out << nl << "return IcePy.stringify(self, _M_" << getAbsolute(p, _suppress, "_t_") << ")";
     _out.dec();
     _out << sp << nl << "__repr__ = __str__";
 
@@ -805,7 +834,7 @@
     }
     else
     {
-        _out << "_M_" << getAbsolute(base, "_t_");
+        _out << "_M_" << getAbsolute(base, _suppress, "_t_");
     }
     _out << ", (";
     //
@@ -820,7 +849,7 @@
             {
                 _out << ", ";
             }
-            _out << "_M_" << getAbsolute(*q, "_t_");
+            _out << "_M_" << getAbsolute(*q, _suppress, "_t_");
             ++interfaceCount;
         }
     }
@@ -957,7 +986,7 @@
                 {
                     _out << ", ";
                 }
-                _out << "_M_" << getAbsolute(*u, "_t_");
+                _out << "_M_" << getAbsolute(*u, _suppress, "_t_");
             }
             if(exceptions.size() == 1)
             {
@@ -1000,10 +1029,10 @@
 Slice::Python::CodeVisitor::visitExceptionStart(const ExceptionPtr& p)
 {
     string scoped = p->scoped();
-    string abs = getAbsolute(p);
+    string abs = getAbsolute(p, _suppress);
     string name = fixIdent(p->name());
 
-    _out << sp << nl << "if not " << getDictLookup(p) << ':';
+    _out << sp << nl << "if not " << getDictLookup(p, _suppress) << ':';
     _out.inc();
     _out << nl << "_M_" << abs << " = Ice.createTempClass()";
     _out << nl << "class " << name << '(';
@@ -1090,7 +1119,7 @@
     //
     // Emit the type information.
     //
-    string type = getAbsolute(p, "_t_");
+    string type = getAbsolute(p, _suppress, "_t_");
     _out << sp << nl << "_M_" << type << " = IcePy.defineException('" << scoped << "', " << name << ", ";
     writeMetaData(p->getMetaData());
     _out << ", ";
@@ -1100,7 +1129,7 @@
     }
     else
     {
-         _out << "_M_" << getAbsolute(base, "_t_");
+	_out << "_M_" << getAbsolute(base, _suppress, "_t_");
     }
     _out << ", (";
     if(members.size() > 1)
@@ -1150,7 +1179,7 @@
 Slice::Python::CodeVisitor::visitStructStart(const StructPtr& p)
 {
     string scoped = p->scoped();
-    string abs = getAbsolute(p);
+    string abs = getAbsolute(p, _suppress);
     string name = fixIdent(p->name());
     MemberInfoList memberList;
     MemberInfoList::iterator r;
@@ -1166,7 +1195,7 @@
         }
     }
 
-    _out << sp << nl << "if not " << getDictLookup(p) << ':';
+    _out << sp << nl << "if not " << getDictLookup(p, _suppress) << ':';
     _out.inc();
     _out << nl << "_M_" << abs << " = Ice.createTempClass()";
     _out << nl << "class " << name << "(object):";
@@ -1257,7 +1286,7 @@
     //
     _out << sp << nl << "def __str__(self):";
     _out.inc();
-    _out << nl << "return IcePy.stringify(self, _M_" << getAbsolute(p, "_t_") << ")";
+    _out << nl << "return IcePy.stringify(self, _M_" << getAbsolute(p, _suppress, "_t_") << ")";
     _out.dec();
     _out << sp << nl << "__repr__ = __str__";
 
@@ -1266,7 +1295,7 @@
     //
     // Emit the type information.
     //
-    _out << sp << nl << "_M_" << getAbsolute(p, "_t_") << " = IcePy.defineStruct('" << scoped << "', " << name << ", ";
+    _out << sp << nl << "_M_" << getAbsolute(p, _suppress, "_t_") << " = IcePy.defineStruct('" << scoped << "', " << name << ", ";
     writeMetaData(p->getMetaData());
     _out << ", (";
     //
@@ -1337,18 +1366,18 @@
     // Emit the type information.
     //
     string scoped = p->scoped();
-    _out << sp << nl << "if not " << getDictLookup(p, "_t_") << ':';
+    _out << sp << nl << "if not " << getDictLookup(p, _suppress, "_t_") << ':';
     _out.inc();
     if(isCustom)
     {
         string package = customType.substr(0, customType.find('.'));
         _out << nl << "import " << package;
-        _out << nl << "_M_" << getAbsolute(p, "_t_")
+        _out << nl << "_M_" << getAbsolute(p, _suppress, "_t_")
              << " = IcePy.defineCustom('" << scoped << "', " << customType << ")";
     }
     else
     {
-        _out << nl << "_M_" << getAbsolute(p, "_t_") << " = IcePy.defineSequence('" << scoped << "', ";
+        _out << nl << "_M_" << getAbsolute(p, _suppress, "_t_") << " = IcePy.defineSequence('" << scoped << "', ";
         writeMetaData(metaData);
         _out << ", ";
         writeType(p->type());
@@ -1364,9 +1393,9 @@
     // Emit the type information.
     //
     string scoped = p->scoped();
-    _out << sp << nl << "if not " << getDictLookup(p, "_t_") << ':';
+    _out << sp << nl << "if not " << getDictLookup(p, _suppress, "_t_") << ':';
     _out.inc();
-    _out << nl << "_M_" << getAbsolute(p, "_t_") << " = IcePy.defineDictionary('" << scoped << "', ";
+    _out << nl << "_M_" << getAbsolute(p, _suppress, "_t_") << " = IcePy.defineDictionary('" << scoped << "', ";
     writeMetaData(p->getMetaData());
     _out << ", ";
     writeType(p->keyType());
@@ -1380,13 +1409,13 @@
 Slice::Python::CodeVisitor::visitEnum(const EnumPtr& p)
 {
     string scoped = p->scoped();
-    string abs = getAbsolute(p);
+    string abs = getAbsolute(p, _suppress);
     string name = fixIdent(p->name());
     EnumeratorList enums = p->getEnumerators();
     EnumeratorList::iterator q;
     int i;
 
-    _out << sp << nl << "if not " << getDictLookup(p) << ':';
+    _out << sp << nl << "if not " << getDictLookup(p, _suppress) << ':';
     _out.inc();
     _out << nl << "_M_" << abs << " = Ice.createTempClass()";
     _out << nl << "class " << name << "(object):";
@@ -1476,7 +1505,7 @@
     //
     // Emit the type information.
     //
-    _out << sp << nl << "_M_" << getAbsolute(p, "_t_") << " = IcePy.defineEnum('" << scoped << "', " << name
+    _out << sp << nl << "_M_" << getAbsolute(p, _suppress, "_t_") << " = IcePy.defineEnum('" << scoped << "', " << name
          << ", ";
     writeMetaData(p->getMetaData());
     _out << ", (";
@@ -1507,7 +1536,7 @@
     string value = p->value();
     string name = fixIdent(p->name());
 
-    _out << sp << nl << "_M_" << getAbsolute(p) << " = ";
+    _out << sp << nl << "_M_" << getAbsolute(p, _suppress) << " = ";
     writeConstantValue(type, value);
 }
 
@@ -1517,7 +1546,7 @@
     //
     // An explicit reference to another type must always be prefixed with "_M_".
     //
-    return "_M_" + getAbsolute(p, "", nameSuffix);
+    return "_M_" + getAbsolute(p, _suppress, "", nameSuffix);
 }
 
 void
@@ -1598,13 +1627,13 @@
     ProxyPtr prx = ProxyPtr::dynamicCast(p);
     if(prx)
     {
-        _out << "_M_" << getAbsolute(prx->_class(), "_t_", "Prx");
+        _out << "_M_" << getAbsolute(prx->_class(), _suppress, "_t_", "Prx");
         return;
     }
 
     ContainedPtr cont = ContainedPtr::dynamicCast(p);
     assert(cont);
-    _out << "_M_" << getAbsolute(cont, "_t_");
+    _out << "_M_" << getAbsolute(cont, _suppress, "_t_");
 }
 
 void
@@ -2189,7 +2218,7 @@
 }
 
 void
-Slice::Python::generate(const UnitPtr& un, bool all, bool checksum, const vector<string>& includePaths, Output& out)
+Slice::Python::generate(const UnitPtr& un, bool all, bool checksum, const vector<string>& includePaths, Output& out, bool suppress)
 {
     Slice::Python::MetaDataVisitor visitor;
     un->visit(&visitor, false);
@@ -2215,10 +2244,10 @@
 
     set<string> moduleHistory;
 
-    ModuleVisitor moduleVisitor(out, moduleHistory);
+    ModuleVisitor moduleVisitor(out, moduleHistory, suppress);
     un->visit(&moduleVisitor, true);
 
-    CodeVisitor codeVisitor(out, moduleHistory);
+    CodeVisitor codeVisitor(out, moduleHistory, suppress);
     un->visit(&codeVisitor, false);
 
     if(checksum)
@@ -2299,9 +2328,9 @@
 }
 
 string
-Slice::Python::getAbsolute(const ContainedPtr& cont, const string& suffix, const string& nameSuffix)
-{
-    string scope = scopedToName(cont->scope());
+Slice::Python::getAbsolute(const ContainedPtr& cont, bool suppress, const string& suffix, const string& nameSuffix)
+{
+    string scope = scopedToName(suppressedscoped(cont->container(), cont->scope(), suppress));
 
     string package = getPackageMetadata(cont);
     if(!package.empty())

Modified: ice/branches/hydra-modified-ice/cpp/src/Slice/RubyUtil.cpp
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/hydra-modified-ice/cpp/src/Slice/RubyUtil.cpp?view=diff&rev=664&r1=663&r2=664
==============================================================================
--- ice/branches/hydra-modified-ice/cpp/src/Slice/RubyUtil.cpp (original)
+++ ice/branches/hydra-modified-ice/cpp/src/Slice/RubyUtil.cpp Mon Jun  7 09:00:52 2010
@@ -34,7 +34,7 @@
 {
 public:
 
-    CodeVisitor(IceUtilInternal::Output&);
+    CodeVisitor(IceUtilInternal::Output&, bool);
 
     virtual bool visitModuleStart(const ModulePtr&);
     virtual void visitModuleEnd(const ModulePtr&);
@@ -98,9 +98,30 @@
 
     Output& _out;
     set<string> _classHistory;
+
+    bool _suppress;
 };
 
 }
+}
+
+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
@@ -163,24 +184,28 @@
 //
 // CodeVisitor implementation.
 //
-Slice::Ruby::CodeVisitor::CodeVisitor(Output& out) :
-    _out(out)
+Slice::Ruby::CodeVisitor::CodeVisitor(Output& out, bool suppress) :
+    _out(out), _suppress(suppress)
 {
 }
 
 bool
 Slice::Ruby::CodeVisitor::visitModuleStart(const ModulePtr& p)
 {
-    _out << sp << nl << "module " << fixIdent(p->name(), IdentToUpper);
-    _out.inc();
+    if (!p->hasMetaData("suppress") || !_suppress) {
+	_out << sp << nl << "module " << fixIdent(p->name(), IdentToUpper);
+	_out.inc();
+    }
     return true;
 }
 
 void
 Slice::Ruby::CodeVisitor::visitModuleEnd(const ModulePtr& p)
 {
-    _out.dec();
-    _out << nl << "end";
+    if (!p->hasMetaData("suppress") || !_suppress) {
+	_out.dec();
+	_out << nl << "end";
+    }
 }
 
 void
@@ -193,7 +218,7 @@
     if(_classHistory.count(scoped) == 0)
     {
         string name = "T_" + fixIdent(p->name(), IdentToUpper);
-        _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper, "T_") << ')';
+        _out << sp << nl << "if not defined?(" << getAbsolute(p, _suppress, IdentToUpper, "T_") << ')';
         _out.inc();
         if(p->isLocal())
         {
@@ -223,7 +248,7 @@
     //
     // Define a mix-in module for the class.
     //
-    _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper) << "_mixin)";
+    _out << sp << nl << "if not defined?(" << getAbsolute(p, _suppress, IdentToUpper) << "_mixin)";
     _out.inc();
     _out << nl << "module " << name << "_mixin";
     _out.inc();
@@ -233,7 +258,7 @@
         if(!bases.empty() && !bases.front()->isInterface())
         {
             base = bases.front();
-            _out << nl << "include " << getAbsolute(bases.front(), IdentToUpper) << "_mixin";
+            _out << nl << "include " << getAbsolute(bases.front(), _suppress, IdentToUpper) << "_mixin";
         }
         else
         {
@@ -434,7 +459,7 @@
         _out << nl << "class " << name;
         if(base)
         {
-            _out << " < " << getAbsolute(base, IdentToUpper);
+            _out << " < " << getAbsolute(base, _suppress, IdentToUpper);
         }
         _out.inc();
         _out << nl << "include " << name << "_mixin";
@@ -507,7 +532,7 @@
         _out.inc();
         for(ClassList::iterator cli = bases.begin(); cli != bases.end(); ++cli)
         {
-            _out << nl << "include " << getAbsolute(*cli, IdentToUpper) << "Prx_mixin";
+            _out << nl << "include " << getAbsolute(*cli, _suppress, IdentToUpper) << "Prx_mixin";
         }
         for(oli = ops.begin(); oli != ops.end(); ++oli)
         {
@@ -591,7 +616,7 @@
     //
     // Emit type descriptions.
     //
-    _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper, "T_") << ')';
+    _out << sp << nl << "if not defined?(" << getAbsolute(p, _suppress, IdentToUpper, "T_") << ')';
     _out.inc();
     if(p->isLocal())
     {
@@ -614,7 +639,7 @@
     }
     else
     {
-        _out << getAbsolute(base, IdentToUpper, "T_");
+        _out << getAbsolute(base, _suppress, IdentToUpper, "T_");
     }
     _out << ", [";
     //
@@ -632,7 +657,7 @@
                 {
                     _out << ", ";
                 }
-                _out << getAbsolute(*q, IdentToUpper, "T_");
+                _out << getAbsolute(*q, _suppress, IdentToUpper, "T_");
                 ++interfaceCount;
             }
         }
@@ -766,7 +791,7 @@
                 {
                     _out << ", ";
                 }
-                _out << getAbsolute(*u, IdentToUpper, "T_");
+                _out << getAbsolute(*u, _suppress, IdentToUpper, "T_");
             }
             _out << "])";
 
@@ -796,14 +821,14 @@
     string scoped = p->scoped();
     string name = fixIdent(p->name(), IdentToUpper);
 
-    _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper) << ')';
+    _out << sp << nl << "if not defined?(" << getAbsolute(p, _suppress, IdentToUpper) << ')';
     _out.inc();
     _out << nl << "class " << name << " < ";
     ExceptionPtr base = p->base();
     string baseName;
     if(base)
     {
-        baseName = getAbsolute(base, IdentToUpper);
+        baseName = getAbsolute(base, _suppress, IdentToUpper);
         _out << baseName;
     }
     else if(p->isLocal())
@@ -903,7 +928,7 @@
     }
     else
     {
-         _out << getAbsolute(base, IdentToUpper, "T_");
+	_out << getAbsolute(base, _suppress, IdentToUpper, "T_");
     }
     _out << ", [";
     if(members.size() > 1)
@@ -962,7 +987,7 @@
         }
     }
 
-    _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper) << ')';
+    _out << sp << nl << "if not defined?(" << getAbsolute(p, _suppress, IdentToUpper) << ')';
     _out.inc();
     _out << nl << "class " << name;
     _out.inc();
@@ -1101,7 +1126,7 @@
     //
     string name = fixIdent(p->name(), IdentToUpper);
     string scoped = p->scoped();
-    _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper, "T_") << ')';
+    _out << sp << nl << "if not defined?(" << getAbsolute(p, _suppress, IdentToUpper, "T_") << ')';
     _out.inc();
     _out << nl << "T_" << name << " = ::Ice::__defineSequence('" << scoped << "', ";
     writeType(p->type());
@@ -1118,7 +1143,7 @@
     //
     string name = fixIdent(p->name(), IdentToUpper);
     string scoped = p->scoped();
-    _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper, "T_") << ')';
+    _out << sp << nl << "if not defined?(" << getAbsolute(p, _suppress, IdentToUpper, "T_") << ')';
     _out.inc();
     _out << nl << "T_" << name << " = ::Ice::__defineDictionary('" << scoped << "', ";
     writeType(p->keyType());
@@ -1138,7 +1163,7 @@
     EnumeratorList::iterator q;
     int i;
 
-    _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper) << ')';
+    _out << sp << nl << "if not defined?(" << getAbsolute(p, _suppress, IdentToUpper) << ')';
     _out.inc();
     _out << nl << "class " << name;
     _out.inc();
@@ -1364,13 +1389,13 @@
     ProxyPtr prx = ProxyPtr::dynamicCast(p);
     if(prx)
     {
-        _out << getAbsolute(prx->_class(), IdentToUpper, "T_") << "Prx";
+        _out << getAbsolute(prx->_class(), _suppress, IdentToUpper, "T_") << "Prx";
         return;
     }
 
     ContainedPtr cont = ContainedPtr::dynamicCast(p);
     assert(cont);
-    _out << getAbsolute(cont, IdentToUpper, "T_");
+    _out << getAbsolute(cont, _suppress, IdentToUpper, "T_");
 }
 
 string
@@ -1414,13 +1439,13 @@
     if(en)
     {
         EnumeratorList enums = en->getEnumerators();
-        return getAbsolute(en, IdentToUpper) + "::" + fixIdent(enums.front()->name(), IdentToUpper);
+        return getAbsolute(en, _suppress, IdentToUpper) + "::" + fixIdent(enums.front()->name(), IdentToUpper);
     }
 
     StructPtr st = StructPtr::dynamicCast(p);
     if(st)
     {
-        return getAbsolute(st, IdentToUpper) + ".new";
+        return getAbsolute(st, _suppress, IdentToUpper) + ".new";
     }
 
     return "nil";
@@ -1545,7 +1570,7 @@
     }
     else if(en)
     {
-        _out << getAbsolute(en, IdentToUpper) << "::";
+        _out << getAbsolute(en, _suppress, IdentToUpper) << "::";
         string::size_type colon = value.rfind(':');
         if(colon != string::npos)
         {
@@ -1629,7 +1654,7 @@
 }
 
 void
-Slice::Ruby::generate(const UnitPtr& un, bool all, bool checksum, const vector<string>& includePaths, Output& out)
+Slice::Ruby::generate(const UnitPtr& un, bool all, bool checksum, const vector<string>& includePaths, Output& out, bool suppress)
 {
     out << nl << "require 'Ice'";
 
@@ -1649,7 +1674,7 @@
         }
     }
 
-    CodeVisitor codeVisitor(out);
+    CodeVisitor codeVisitor(out, suppress);
     un->visit(&codeVisitor, false);
 
     if(checksum)
@@ -1736,9 +1761,9 @@
 }
 
 string
-Slice::Ruby::getAbsolute(const ContainedPtr& cont, IdentStyle style, const string& prefix)
-{
-    string scope = fixIdent(cont->scope(), IdentToUpper);
+Slice::Ruby::getAbsolute(const ContainedPtr& cont, bool suppress, IdentStyle style, const string& prefix)
+{
+    string scope = fixIdent(suppressedscoped(cont->container(), cont->scope(), suppress), IdentToUpper);
 
     if(prefix.empty())
     {

Modified: ice/branches/hydra-modified-ice/cpp/src/slice2cpp/Gen.cpp
URL: https://origsvn.digium.com/svn-view/hydra/ice/branches/hydra-modified-ice/cpp/src/slice2cpp/Gen.cpp?view=diff&rev=664&r1=663&r2=664
==============================================================================
--- ice/branches/hydra-modified-ice/cpp/src/slice2cpp/Gen.cpp (original)
+++ ice/branches/hydra-modified-ice/cpp/src/slice2cpp/Gen.cpp Mon Jun  7 09:00:52 2010
@@ -25,6 +25,44 @@
 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)
@@ -128,7 +166,7 @@
 Slice::Gen::Gen(const string& base, const string& headerExtension, const string& sourceExtension,
                 const vector<string>& extraHeaders, const string& include,
                 const vector<string>& includePaths, const string& dllExport, const string& dir,
-                bool imp, bool checksum, bool stream, bool ice) :
+                bool imp, bool checksum, bool stream, bool ice, bool suppress) :
     _base(base),
     _headerExtension(headerExtension),
     _implHeaderExtension(headerExtension),
@@ -141,7 +179,8 @@
     _impl(imp),
     _checksum(checksum),
     _stream(stream),
-    _ice(ice)
+    _ice(ice),
+    _suppress(suppress)
 {
     for(vector<string>::iterator p = _includePaths.begin(); p != _includePaths.end(); ++p)
     {
@@ -400,25 +439,25 @@
         _dllExport += " ";
     }
 
-    ProxyDeclVisitor proxyDeclVisitor(H, C, _dllExport);
+    ProxyDeclVisitor proxyDeclVisitor(H, C, _dllExport, _suppress);
     p->visit(&proxyDeclVisitor, false);
 
-    ObjectDeclVisitor objectDeclVisitor(H, C, _dllExport);
+    ObjectDeclVisitor objectDeclVisitor(H, C, _dllExport, _suppress);
     p->visit(&objectDeclVisitor, false);
 
-    IceInternalVisitor iceInternalVisitor(H, C, _dllExport);
+    IceInternalVisitor iceInternalVisitor(H, C, _dllExport, _suppress);
     p->visit(&iceInternalVisitor, false);
 
-    HandleVisitor handleVisitor(H, C, _dllExport, _stream);
+    HandleVisitor handleVisitor(H, C, _dllExport, _stream, _suppress);
     p->visit(&handleVisitor, false);
 
-    TypesVisitor typesVisitor(H, C, _dllExport, _stream);
+    TypesVisitor typesVisitor(H, C, _dllExport, _stream, _suppress);
     p->visit(&typesVisitor, false);
 
-    AsyncVisitor asyncVisitor(H, C, _dllExport);
+    AsyncVisitor asyncVisitor(H, C, _dllExport, _suppress);
     p->visit(&asyncVisitor, false);
 
-    AsyncImplVisitor asyncImplVisitor(H, C, _dllExport);
+    AsyncImplVisitor asyncImplVisitor(H, C, _dllExport, _suppress);
     p->visit(&asyncImplVisitor, false);
 
     //
@@ -427,27 +466,27 @@
     // the proxy relies on knowing the hierarchy to make the begin_
     // methods type-safe.
     //
-    AsyncCallbackVisitor asyncCallbackVisitor(H, C, _dllExport);
+    AsyncCallbackVisitor asyncCallbackVisitor(H, C, _dllExport, _suppress);
     p->visit(&asyncCallbackVisitor, false);
 
-    ProxyVisitor proxyVisitor(H, C, _dllExport);
+    ProxyVisitor proxyVisitor(H, C, _dllExport, _suppress);
     p->visit(&proxyVisitor, false);
 
-    DelegateVisitor delegateVisitor(H, C, _dllExport);
+    DelegateVisitor delegateVisitor(H, C, _dllExport, _suppress);
     p->visit(&delegateVisitor, false);
 
-    DelegateMVisitor delegateMVisitor(H, C, _dllExport);
+    DelegateMVisitor delegateMVisitor(H, C, _dllExport, _suppress);
     p->visit(&delegateMVisitor, false);
 
-    DelegateDVisitor delegateDVisitor(H, C, _dllExport);
+    DelegateDVisitor delegateDVisitor(H, C, _dllExport, _suppress);
     p->visit(&delegateDVisitor, false);
 
-    ObjectVisitor objectVisitor(H, C, _dllExport, _stream);
+    ObjectVisitor objectVisitor(H, C, _dllExport, _stream, _suppress);
     p->visit(&objectVisitor, false);
 
     if(_stream)
     {
-        StreamVisitor streamVistor(H, C);
+        StreamVisitor streamVistor(H, C, _suppress);
         p->visit(&streamVistor, false);
     }
 
@@ -456,7 +495,7 @@
     // definition, because __completed calls the begin_ method in the
     // proxy.
     //
-    AsyncCallbackTemplateVisitor asyncCallbackTemplateVisitor(H, C, _dllExport);
+    AsyncCallbackTemplateVisitor asyncCallbackTemplateVisitor(H, C, _dllExport, _suppress);
     p->visit(&asyncCallbackTemplateVisitor, false);
 
     if(_impl)
@@ -477,7 +516,7 @@
         }
         implC << _base << "I." << _implHeaderExtension << ">";
 
-        ImplVisitor implVisitor(implH, implC, _dllExport);
+        ImplVisitor implVisitor(implH, implC, _dllExport, _suppress);
         p->visit(&implVisitor, false);
     }
 
@@ -547,8 +586,9 @@
     }
 }
 
-Slice::Gen::TypesVisitor::TypesVisitor(Output& h, Output& c, const string& dllExport, bool stream) :
-    H(h), C(c), _dllExport(dllExport), _stream(stream), _doneStaticSymbol(false), _useWstring(false)
+Slice::Gen::TypesVisitor::TypesVisitor(Output& h, Output& c, const string& dllExport, bool stream, bool suppress) :
+    H(h), C(c), _dllExport(dllExport), _stream(stream), _doneStaticSymbol(false), _useWstring(false),
+    _suppress(suppress)
 {
 }
 
@@ -560,9 +600,11 @@
         return false;
     }
 
-    _useWstring = setUseWstring(p, _useWstringHist, _useWstring);
-
-    H << sp << nl << "namespace " << fixKwd(p->name()) << nl << '{';
+    if (!p->hasMetaData("suppress") || !_suppress) {
+	_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
+
+	H << sp << nl << "namespace " << fixKwd(p->name()) << nl << '{';
+    }
 
     return true;
 }
@@ -570,9 +612,11 @@
 void
 Slice::Gen::TypesVisitor::visitModuleEnd(const ModulePtr& p)
 {
-    H << sp << nl << '}';
-
-    _useWstring = resetUseWstring(_useWstringHist);
+    if (!p->hasMetaData("suppress") || !_suppress) {
+	H << sp << nl << '}';
+
+	_useWstring = resetUseWstring(_useWstringHist);
+    }
 }
 
 bool
@@ -587,7 +631,7 @@
     _useWstring = setUseWstring(p, _useWstringHist, _useWstring);
 
     string name = fixKwd(p->name());
-    string scoped = fixKwd(p->scoped());
+    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
     ExceptionPtr base = p->base();
     DataMemberList dataMembers = p->dataMembers();
     DataMemberList allDataMembers = p->allDataMembers();
@@ -629,7 +673,7 @@
     }
     else
     {
-        H << fixKwd(base->scoped());
+        H << fixKwd(suppressedscoped(base->container(), base->scoped(), _suppress));
     }
     H.restoreIndent();
     H << sb;
@@ -754,7 +798,7 @@
 
     H << nl << "virtual ::std::string ice_name() const;";
 
-    string flatName = p->flattenedScope() + p->name() + "_name";
+    string flatName = suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + 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";
@@ -794,8 +838,8 @@
 Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
 {
     string name = fixKwd(p->name());
-    string scope = fixKwd(p->scope());
-    string scoped = fixKwd(p->scoped());
+    string scope = fixKwd(suppressedscoped(p->container(), p->scope(), _suppress));
+    string scoped = fixKwd(suppressedscoped(p->container(), p->scoped(), _suppress));
     DataMemberList dataMembers = p->dataMembers();
     DataMemberList::const_iterator q;
 
@@ -862,7 +906,7 @@
             C << nl << "void" << nl << scoped.substr(2)
               << "::__write(const ::Ice::OutputStreamPtr& __outS) const";
             C << sb;
-            C << nl << "__outS->write(::std::string(\"" << p->scoped() << "\"));";
+            C << nl << "__outS->write(::std::string(\"" << suppressedscoped(p->container(), p->scoped(), _suppress) << "\"));";
             C << nl << "__outS->startSlice();";
             for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
             {
@@ -943,7 +987,7 @@
             }
         }
 
-        factoryName = "__F" + p->flattenedScope() + p->name();
+        factoryName = "__F" + suppressedflattenedScope(p->container(), p->flattenedScope(), _suppress) + p->name();
 

[... 3413 lines stripped ...]




More information about the asterisk-scf-commits mailing list