[Libreoffice-commits] core.git: 2 commits - cli_ure/source codemaker/source cppuhelper/source include/unoidl unoidl/README unoidl/source

Stephan Bergmann sbergman at redhat.com
Fri May 23 04:44:25 PDT 2014


 cli_ure/source/climaker/climaker_app.cxx   |    6 --
 codemaker/source/codemaker/typemanager.cxx |    4 -
 cppuhelper/source/typemanager.cxx          |    2 
 include/unoidl/unoidl.hxx                  |   10 ++--
 unoidl/README                              |    4 -
 unoidl/source/legacyprovider.cxx           |    7 +--
 unoidl/source/legacyprovider.hxx           |    5 --
 unoidl/source/sourcetreeprovider.cxx       |    5 --
 unoidl/source/sourcetreeprovider.hxx       |    5 --
 unoidl/source/unoidl-check.cxx             |    3 -
 unoidl/source/unoidl-read.cxx              |    3 -
 unoidl/source/unoidl-write.cxx             |    3 -
 unoidl/source/unoidl.cxx                   |   60 ++++++++++++++---------------
 13 files changed, 54 insertions(+), 63 deletions(-)

New commits:
commit 8949bcad4095008dc147c6fd6e633c177144dfa8
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri May 23 13:43:40 2014 +0200

    Remove circular references between unoidl::Manager and its providers
    
    Change-Id: Ic6ad3e2c7f69dd123077a913f35f1971f1e8ca13

diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx
index ac8ec69..9db8495 100644
--- a/unoidl/source/legacyprovider.cxx
+++ b/unoidl/source/legacyprovider.cxx
@@ -778,8 +778,7 @@ rtl::Reference< Entity > readEntity(
 
 }
 
-LegacyProvider::LegacyProvider(
-    rtl::Reference< Manager > const & manager, OUString const & uri):
+LegacyProvider::LegacyProvider(Manager & manager, OUString const & uri):
     manager_(manager)
 {
     Registry reg;
@@ -811,14 +810,14 @@ LegacyProvider::LegacyProvider(
 }
 
 rtl::Reference< MapCursor > LegacyProvider::createRootCursor() const {
-    return new Cursor(manager_, ucr_, ucr_);
+    return new Cursor(&manager_, ucr_, ucr_);
 }
 
 rtl::Reference< Entity > LegacyProvider::findEntity(OUString const & name)
     const
 {
     return ucr_.isValid()
-        ? readEntity(manager_, ucr_, ucr_, name.replace('.', '/'), true)
+        ? readEntity(&manager_, ucr_, ucr_, name.replace('.', '/'), true)
         : rtl::Reference< Entity >();
 }
 
diff --git a/unoidl/source/legacyprovider.hxx b/unoidl/source/legacyprovider.hxx
index bcb300d..c3ba6ef 100644
--- a/unoidl/source/legacyprovider.hxx
+++ b/unoidl/source/legacyprovider.hxx
@@ -21,8 +21,7 @@ namespace unoidl { namespace detail {
 class LegacyProvider: public Provider {
 public:
     // throws FileFormatException, NoSuchFileException:
-    LegacyProvider(
-        rtl::Reference< Manager > const & manager, OUString const & uri);
+    LegacyProvider(Manager & manager, OUString const & uri);
 
     // throws FileFormatException:
     virtual rtl::Reference< MapCursor > createRootCursor() const SAL_OVERRIDE;
@@ -34,7 +33,7 @@ public:
 private:
     virtual ~LegacyProvider() throw ();
 
-    rtl::Reference< Manager > manager_;
+    Manager & manager_;
     mutable RegistryKey ucr_;
 };
 
diff --git a/unoidl/source/sourcetreeprovider.cxx b/unoidl/source/sourcetreeprovider.cxx
index 5c203e4..246f6f0 100644
--- a/unoidl/source/sourcetreeprovider.cxx
+++ b/unoidl/source/sourcetreeprovider.cxx
@@ -120,8 +120,7 @@ private:
 
 }
 
-SourceTreeProvider::SourceTreeProvider(
-    rtl::Reference<Manager> const & manager, OUString const & uri):
+SourceTreeProvider::SourceTreeProvider(Manager & manager, OUString const & uri):
     manager_(manager), uri_(uri.endsWith("/") ? uri : uri + "/")
 {}
 
@@ -189,7 +188,7 @@ rtl::Reference<Entity> SourceTreeProvider::findEntity(OUString const & name)
         ent = new SourceModuleEntity;
     } else {
         uri += ".idl";
-        SourceProviderScannerData data(manager_);
+        SourceProviderScannerData data(&manager_);
         if (parse(uri, &data)) {
             std::map<OUString, SourceProviderEntity>::const_iterator j(
                 data.entities.find(name));
diff --git a/unoidl/source/sourcetreeprovider.hxx b/unoidl/source/sourcetreeprovider.hxx
index 57ae3d5..0c1d993 100644
--- a/unoidl/source/sourcetreeprovider.hxx
+++ b/unoidl/source/sourcetreeprovider.hxx
@@ -22,8 +22,7 @@ namespace unoidl { namespace detail {
 class SourceTreeProvider: public Provider {
 public:
     // throws FileFormatException, NoSuchFileException:
-    SourceTreeProvider(
-        rtl::Reference<Manager> const & manager, OUString const & uri);
+    SourceTreeProvider(Manager & manager, OUString const & uri);
 
     // throws FileFormatException:
     virtual rtl::Reference<MapCursor> createRootCursor() const SAL_OVERRIDE;
@@ -34,7 +33,7 @@ public:
 private:
     virtual ~SourceTreeProvider() throw ();
 
-    rtl::Reference<Manager> manager_;
+    Manager & manager_;
     OUString uri_;
     mutable std::map< OUString, rtl::Reference<Entity> > cache_; //TODO: at manager
 };
diff --git a/unoidl/source/unoidl.cxx b/unoidl/source/unoidl.cxx
index 4546383..e5573f0 100644
--- a/unoidl/source/unoidl.cxx
+++ b/unoidl/source/unoidl.cxx
@@ -206,7 +206,7 @@ rtl::Reference< Provider > Manager::loadProvider(OUString const & uri) {
         if (item.getFileStatus(status) == osl::FileBase::E_None
             && status.getFileType() == osl::FileStatus::Directory)
         {
-            return new detail::SourceTreeProvider(this, uri);
+            return new detail::SourceTreeProvider(*this, uri);
         }
     }
     if (uri.endsWith(".idl")) {
@@ -219,7 +219,7 @@ rtl::Reference< Provider > Manager::loadProvider(OUString const & uri) {
             "unoidl",
             "FileFormatException \"" << e.getDetail() << "\", retrying <" << uri
                 << "> as legacy format");
-        return new detail::LegacyProvider(this, uri);
+        return new detail::LegacyProvider(*this, uri);
     }
 }
 
commit d0322208bcbb35b9149b508ac2bffa667c38696f
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri May 23 12:30:00 2014 +0200

    Combine unoidl::loadProvider and unoidl::Manager::addProvider
    
    Change-Id: I1240656cc2a4d713c838eb80fa90ce3485aad614

diff --git a/cli_ure/source/climaker/climaker_app.cxx b/cli_ure/source/climaker/climaker_app.cxx
index 8c416d6..b47be93 100644
--- a/cli_ure/source/climaker/climaker_app.cxx
+++ b/cli_ure/source/climaker/climaker_app.cxx
@@ -423,15 +423,13 @@ SAL_IMPLEMENT_MAIN()
              i != extra_registries.end(); ++i)
         {
             xSet->insert(makeAny(*i));
-            unoidlMgr->addProvider(unoidl::loadProvider(unoidlMgr, *i));
+            unoidlMgr->addProvider(*i);
         }
         for (vector< OUString >::iterator i(mandatory_registries.begin());
              i != mandatory_registries.end(); ++i)
         {
             xSet->insert(makeAny(*i));
-            rtl::Reference< unoidl::Provider > prov(
-                unoidl::loadProvider(unoidlMgr, *i));
-            unoidlMgr->addProvider(prov);
+            rtl::Reference< unoidl::Provider > prov(unoidlMgr->addProvider(*i));
             unoidlMandatoryProvs.push_back(prov);
         }
 
diff --git a/codemaker/source/codemaker/typemanager.cxx b/codemaker/source/codemaker/typemanager.cxx
index 7779704..d2e346d 100644
--- a/codemaker/source/codemaker/typemanager.cxx
+++ b/codemaker/source/codemaker/typemanager.cxx
@@ -34,9 +34,7 @@ TypeManager::TypeManager(): manager_(new unoidl::Manager) {}
 TypeManager::~TypeManager() {}
 
 void TypeManager::loadProvider(OUString const & uri, bool primary) {
-    rtl::Reference< unoidl::Provider > prov(
-        unoidl::loadProvider(manager_, uri));
-    manager_->addProvider(prov);
+    rtl::Reference< unoidl::Provider > prov(manager_->addProvider(uri));
     if (primary) {
         primaryProviders_.push_back(prov);
     }
diff --git a/cppuhelper/source/typemanager.cxx b/cppuhelper/source/typemanager.cxx
index e3e38e5..459671a 100644
--- a/cppuhelper/source/typemanager.cxx
+++ b/cppuhelper/source/typemanager.cxx
@@ -2142,7 +2142,7 @@ void cppuhelper::TypeManager::readRdbFile(
     rtl::OUString const & uri, bool optional)
 {
     try {
-        manager_->addProvider(unoidl::loadProvider(manager_, uri));
+        manager_->addProvider(uri);
     } catch (unoidl::NoSuchFileException &) {
         if (!optional) {
             throw css::uno::DeploymentException(
diff --git a/include/unoidl/unoidl.hxx b/include/unoidl/unoidl.hxx
index 117ac87..9694be7 100644
--- a/include/unoidl/unoidl.hxx
+++ b/include/unoidl/unoidl.hxx
@@ -684,7 +684,8 @@ class LO_DLLPUBLIC_UNOIDL Manager: public salhelper::SimpleReferenceObject {
 public:
     Manager() {}
 
-    void addProvider(rtl::Reference< Provider > const & provider);
+    // throws FileFormatException, NoSuchFileException:
+    rtl::Reference< Provider > addProvider(rtl::OUString const & uri);
 
     // throws FileFormatException:
     rtl::Reference< Entity > findEntity(rtl::OUString const & name) const;
@@ -695,14 +696,13 @@ public:
 private:
     virtual SAL_DLLPRIVATE ~Manager() throw ();
 
+    SAL_DLLPRIVATE rtl::Reference< Provider > loadProvider(
+        rtl::OUString const & uri);
+
     mutable osl::Mutex mutex_;
     std::vector< rtl::Reference< Provider > > providers_;
 };
 
-// throws FileFormatException, NoSuchFileException:
-LO_DLLPUBLIC_UNOIDL rtl::Reference< Provider > loadProvider(
-    rtl::Reference< Manager > const & manager, rtl::OUString const & uri);
-
 }
 
 #endif
diff --git a/unoidl/README b/unoidl/README
index 3c387e9..9a2f9d2 100644
--- a/unoidl/README
+++ b/unoidl/README
@@ -14,8 +14,8 @@ for the following registry formats:
 
 (While .idl files still contain #include directives for legacy idlc, the source-
 based formats ignore any preprocessing directives starting with "#" in the .idl
-files.)  unoidl::loadProvider transparently detects the registry format for a
-given URI and instantiates the corresponding provider implementation.
+files.)  unoidl::Manager::addProvider transparently detects the registry format
+for a given URI and instantiates the corresponding provider implementation.
 
 Executable_unoidl-write is a helper tool to convert from any of the registry
 formats to the UNOIDL format.  It is used at build-time to compile UNOIDL format
diff --git a/unoidl/source/unoidl-check.cxx b/unoidl/source/unoidl-check.cxx
index 3a0dd36..688a62c 100644
--- a/unoidl/source/unoidl-check.cxx
+++ b/unoidl/source/unoidl-check.cxx
@@ -1176,13 +1176,12 @@ SAL_IMPLEMENT_MAIN() {
                 side = 1;
             } else {
                 try {
-                    prov[side] = unoidl::loadProvider(mgr[side], uri);
+                    prov[side] = mgr[side]->addProvider(uri);
                 } catch (unoidl::NoSuchFileException &) {
                     std::cerr
                         << "Input <" << uri << "> does not exist" << std::endl;
                     std::exit(EXIT_FAILURE);
                 }
-                mgr[side]->addProvider(prov[side]);
             }
         }
         if (side == 0 || !(prov[0].is() && prov[1].is())) {
diff --git a/unoidl/source/unoidl-read.cxx b/unoidl/source/unoidl-read.cxx
index 1a76335..1deb4d7 100644
--- a/unoidl/source/unoidl-read.cxx
+++ b/unoidl/source/unoidl-read.cxx
@@ -1112,13 +1112,12 @@ SAL_IMPLEMENT_MAIN() {
         for (sal_uInt32 i = (published ? 1 : 0); i != args; ++i) {
             OUString uri(getArgumentUri(i));
             try {
-                prov = unoidl::loadProvider(mgr, uri);
+                prov = mgr->addProvider(uri);
             } catch (unoidl::NoSuchFileException &) {
                 std::cerr
                     << "Input <" << uri << "> does not exist" << std::endl;
                 std::exit(EXIT_FAILURE);
             }
-            mgr->addProvider(prov);
         }
         std::map<OUString, Entity> ents;
         scanMap(mgr, prov->createRootCursor(), published, "", ents);
diff --git a/unoidl/source/unoidl-write.cxx b/unoidl/source/unoidl-write.cxx
index 8b3b3bf..3ea09d3 100644
--- a/unoidl/source/unoidl-write.cxx
+++ b/unoidl/source/unoidl-write.cxx
@@ -1038,13 +1038,12 @@ SAL_IMPLEMENT_MAIN() {
                 mapEntities(mgr, uri, map);
             } else {
                 try {
-                    prov = unoidl::loadProvider(mgr, uri);
+                    prov = mgr->addProvider(uri);
                 } catch (unoidl::NoSuchFileException &) {
                     std::cerr
                         << "Input <" << uri << "> does not exist" << std::endl;
                     std::exit(EXIT_FAILURE);
                 }
-                mgr->addProvider(prov);
             }
         }
         if (!entities) {
diff --git a/unoidl/source/unoidl.cxx b/unoidl/source/unoidl.cxx
index 3eb36a8..4546383 100644
--- a/unoidl/source/unoidl.cxx
+++ b/unoidl/source/unoidl.cxx
@@ -166,36 +166,14 @@ ServiceBasedSingletonEntity::~ServiceBasedSingletonEntity() throw () {}
 
 Provider::~Provider() throw () {}
 
-rtl::Reference< Provider > loadProvider(
-    rtl::Reference< Manager > const & manager, OUString const & uri)
-{
-    osl::DirectoryItem item;
-    if (osl::DirectoryItem::get(uri, item) == osl::FileBase::E_None) {
-        osl::FileStatus status(osl_FileStatus_Mask_Type);
-        if (item.getFileStatus(status) == osl::FileBase::E_None
-            && status.getFileType() == osl::FileStatus::Directory)
-        {
-            return new detail::SourceTreeProvider(manager, uri);
-        }
-    }
-    if (uri.endsWith(".idl")) {
-        return new detail::SourceFileProvider(manager, uri);
-    }
-    try {
-        return new detail::UnoidlProvider(uri);
-    } catch (FileFormatException & e) {
-        SAL_INFO(
-            "unoidl",
-            "FileFormatException \"" << e.getDetail() << "\", retrying <" << uri
-                << "> as legacy format");
-        return new detail::LegacyProvider(manager, uri);
+rtl::Reference< Provider > Manager::addProvider(OUString const & uri) {
+    rtl::Reference< Provider > p(loadProvider(uri));
+    assert(p.is());
+    {
+        osl::MutexGuard g(mutex_);
+        providers_.push_back(p);
     }
-}
-
-void Manager::addProvider(rtl::Reference< Provider > const & provider) {
-    assert(provider.is());
-    osl::MutexGuard g(mutex_);
-    providers_.push_back(provider);
+    return p;
 }
 
 rtl::Reference< Entity > Manager::findEntity(rtl::OUString const & name) const {
@@ -221,6 +199,30 @@ rtl::Reference< MapCursor > Manager::createCursor(rtl::OUString const & name)
 
 Manager::~Manager() throw () {}
 
+rtl::Reference< Provider > Manager::loadProvider(OUString const & uri) {
+    osl::DirectoryItem item;
+    if (osl::DirectoryItem::get(uri, item) == osl::FileBase::E_None) {
+        osl::FileStatus status(osl_FileStatus_Mask_Type);
+        if (item.getFileStatus(status) == osl::FileBase::E_None
+            && status.getFileType() == osl::FileStatus::Directory)
+        {
+            return new detail::SourceTreeProvider(this, uri);
+        }
+    }
+    if (uri.endsWith(".idl")) {
+        return new detail::SourceFileProvider(this, uri);
+    }
+    try {
+        return new detail::UnoidlProvider(uri);
+    } catch (FileFormatException & e) {
+        SAL_INFO(
+            "unoidl",
+            "FileFormatException \"" << e.getDetail() << "\", retrying <" << uri
+                << "> as legacy format");
+        return new detail::LegacyProvider(this, uri);
+    }
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list