[Libreoffice-commits] core.git: include/unoidl unoidl/source

Stephan Bergmann sbergman at redhat.com
Mon Sep 16 08:37:41 PDT 2013


 include/unoidl/legacyprovider.hxx |   48 --------------------
 include/unoidl/sourceprovider.hxx |   48 --------------------
 include/unoidl/unoidlprovider.hxx |   60 -------------------------
 unoidl/source/legacyprovider.cxx  |    7 +-
 unoidl/source/legacyprovider.hxx  |   45 +++++++++++++++++++
 unoidl/source/sourceprovider.cxx  |   10 ++--
 unoidl/source/sourceprovider.hxx  |   46 +++++++++++++++++++
 unoidl/source/unoidl.cxx          |   13 ++---
 unoidl/source/unoidlprovider.cxx  |   90 ++++++++++++++------------------------
 unoidl/source/unoidlprovider.hxx  |   48 ++++++++++++++++++++
 10 files changed, 189 insertions(+), 226 deletions(-)

New commits:
commit 0ff9244d8aa8ba46025d8ae9d2e0f83385793165
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Sep 16 17:36:42 2013 +0200

    Clean up the unoidl Providers (no need to have them exported)
    
    Change-Id: I96b99e96b44f12b7ad7f376e4b3a68d7e9531643

diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx
index b92302d..3b38215 100644
--- a/unoidl/source/legacyprovider.cxx
+++ b/unoidl/source/legacyprovider.cxx
@@ -19,10 +19,11 @@
 #include "rtl/ref.hxx"
 #include "rtl/ustring.hxx"
 #include "sal/types.h"
-#include "unoidl/legacyprovider.hxx"
 #include "unoidl/unoidl.hxx"
 
-namespace unoidl {
+#include "legacyprovider.hxx"
+
+namespace unoidl { namespace detail {
 
 namespace {
 
@@ -823,6 +824,6 @@ rtl::Reference< Entity > LegacyProvider::findEntity(OUString const & name)
 
 LegacyProvider::~LegacyProvider() throw () {}
 
-}
+} }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/unoidl/legacyprovider.hxx b/unoidl/source/legacyprovider.hxx
similarity index 84%
rename from include/unoidl/legacyprovider.hxx
rename to unoidl/source/legacyprovider.hxx
index cebdc1f..538b66f 100644
--- a/include/unoidl/legacyprovider.hxx
+++ b/unoidl/source/legacyprovider.hxx
@@ -14,14 +14,11 @@
 
 #include "registry/registry.hxx"
 #include "rtl/ref.hxx"
-#include "sal/types.h"
-#include "unoidl/detail/dllapi.hxx"
 #include "unoidl/unoidl.hxx"
 
+namespace unoidl { namespace detail {
 
-namespace unoidl {
-
-class LO_DLLPUBLIC_UNOIDL LegacyProvider: public Provider {
+class LegacyProvider: public Provider {
 public:
     // throws FileFormatException, NoSuchFileException:
     LegacyProvider(
@@ -35,13 +32,13 @@ public:
         const;
 
 private:
-    virtual SAL_DLLPRIVATE ~LegacyProvider() throw ();
+    virtual ~LegacyProvider() throw ();
 
     rtl::Reference< Manager > manager_;
     mutable RegistryKey ucr_;
 };
 
-}
+} }
 
 #endif
 
diff --git a/unoidl/source/sourceprovider.cxx b/unoidl/source/sourceprovider.cxx
index ea7f110..429f68f 100755
--- a/unoidl/source/sourceprovider.cxx
+++ b/unoidl/source/sourceprovider.cxx
@@ -20,14 +20,14 @@
 #include "rtl/ref.hxx"
 #include "rtl/ustrbuf.hxx"
 #include "rtl/ustring.hxx"
-#include "unoidl/sourceprovider.hxx"
 #include "unoidl/unoidl.hxx"
 
 #include "sourceprovider-parser-requires.hxx"
 #include "sourceprovider-parser.hxx"
 #include "sourceprovider-scanner.hxx"
+#include "sourceprovider.hxx"
 
-namespace unoidl {
+namespace unoidl { namespace detail {
 
 namespace {
 
@@ -35,7 +35,7 @@ rtl::Reference<Entity> parse(
     rtl::Reference<Manager> const & manager, OUString const & name,
     OUString const & uri, void const * address, sal_uInt64 size)
 {
-    detail::SourceProviderScannerData data(manager, address, size);
+    SourceProviderScannerData data(manager, address, size);
     yyscan_t yyscanner;
     if (yylex_init_extra(&data, &yyscanner) != 0) {
         // Checking errno for the specific EINVAL, ENOMEM documented for
@@ -50,7 +50,7 @@ rtl::Reference<Entity> parse(
     switch (e) {
     case 0:
         {
-            std::map<OUString, detail::SourceProviderEntity>::const_iterator i(
+            std::map<OUString, SourceProviderEntity>::const_iterator i(
                 data.entities.find(name));
             return i == data.entities.end()
                 ? rtl::Reference<Entity>() : i->second.entity;
@@ -230,6 +230,6 @@ rtl::Reference<Entity> SourceProvider::findEntity(OUString const & name) const {
 
 SourceProvider::~SourceProvider() throw () {}
 
-}
+} }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/unoidl/sourceprovider.hxx b/unoidl/source/sourceprovider.hxx
similarity index 85%
rename from include/unoidl/sourceprovider.hxx
rename to unoidl/source/sourceprovider.hxx
index e596711..e7ee92f 100644
--- a/include/unoidl/sourceprovider.hxx
+++ b/unoidl/source/sourceprovider.hxx
@@ -15,13 +15,11 @@
 #include <map>
 
 #include "rtl/ref.hxx"
-#include "sal/types.h"
-#include "unoidl/detail/dllapi.hxx"
 #include "unoidl/unoidl.hxx"
 
-namespace unoidl {
+namespace unoidl { namespace detail {
 
-class LO_DLLPUBLIC_UNOIDL SourceProvider: public Provider {
+class SourceProvider: public Provider {
 public:
     // throws FileFormatException, NoSuchFileException:
     SourceProvider(
@@ -34,14 +32,14 @@ public:
     virtual rtl::Reference<Entity> findEntity(OUString const & name) const;
 
 private:
-    virtual SAL_DLLPRIVATE ~SourceProvider() throw ();
+    virtual ~SourceProvider() throw ();
 
     rtl::Reference<Manager> manager_;
     OUString uri_;
     mutable std::map< OUString, rtl::Reference<Entity> > cache_; //TODO: at manager
 };
 
-}
+} }
 
 #endif
 
diff --git a/unoidl/source/unoidl.cxx b/unoidl/source/unoidl.cxx
index bdc7b98..e5c3c43 100644
--- a/unoidl/source/unoidl.cxx
+++ b/unoidl/source/unoidl.cxx
@@ -17,10 +17,11 @@
 #include "osl/mutex.hxx"
 #include "rtl/ref.hxx"
 #include "rtl/ustring.hxx"
-#include "unoidl/legacyprovider.hxx"
-#include "unoidl/sourceprovider.hxx"
 #include "unoidl/unoidl.hxx"
-#include "unoidl/unoidlprovider.hxx"
+
+#include "legacyprovider.hxx"
+#include "sourceprovider.hxx"
+#include "unoidlprovider.hxx"
 
 namespace unoidl {
 
@@ -113,17 +114,17 @@ rtl::Reference< Provider > loadProvider(
         if (item.getFileStatus(status) == osl::FileBase::E_None
             && status.getFileType() == osl::FileStatus::Directory)
         {
-            return new SourceProvider(manager, uri);
+            return new detail::SourceProvider(manager, uri);
         }
     }
     try {
-        return new UnoidlProvider(uri);
+        return new detail::UnoidlProvider(uri);
     } catch (FileFormatException & e) {
         SAL_INFO(
             "unoidl",
             "FileFormatException \"" << e.getDetail() << "\", retrying <" << uri
                 << "> as legacy format");
-        return new LegacyProvider(manager, uri);
+        return new detail::LegacyProvider(manager, uri);
     }
 }
 
diff --git a/unoidl/source/unoidlprovider.cxx b/unoidl/source/unoidlprovider.cxx
index 47b6f9e..b195f44 100644
--- a/unoidl/source/unoidlprovider.cxx
+++ b/unoidl/source/unoidlprovider.cxx
@@ -24,7 +24,10 @@
 #include "sal/types.h"
 #include "salhelper/simplereferenceobject.hxx"
 #include "unoidl/unoidl.hxx"
-#include "unoidl/unoidlprovider.hxx"
+
+#include "unoidlprovider.hxx"
+
+namespace unoidl { namespace detail {
 
 namespace {
 
@@ -114,10 +117,6 @@ struct Memory64 {
 
 }
 
-namespace unoidl {
-
-namespace detail {
-
 class MappedFile: public salhelper::SimpleReferenceObject {
 public:
     explicit MappedFile(OUString const & fileUrl);
@@ -365,15 +364,13 @@ struct MapEntry {
     Memory32 data;
 };
 
-}
-
 namespace {
 
 enum Compare { COMPARE_LESS, COMPARE_GREATER, COMPARE_EQUAL };
 
 Compare compare(
-    rtl::Reference< detail::MappedFile > const & file, OUString const & name,
-    sal_Int32 nameOffset, sal_Int32 nameLength, detail::MapEntry const * entry)
+    rtl::Reference< MappedFile > const & file, OUString const & name,
+    sal_Int32 nameOffset, sal_Int32 nameLength, MapEntry const * entry)
 {
     assert(file.is());
     assert(entry != 0);
@@ -411,15 +408,15 @@ Compare compare(
 }
 
 sal_uInt32 findInMap(
-    rtl::Reference< detail::MappedFile > const & file,
-    detail::MapEntry const * mapBegin, sal_uInt32 mapSize,
-    OUString const & name, sal_Int32 nameOffset, sal_Int32 nameLength)
+    rtl::Reference< MappedFile > const & file, MapEntry const * mapBegin,
+    sal_uInt32 mapSize, OUString const & name, sal_Int32 nameOffset,
+    sal_Int32 nameLength)
 {
     if (mapSize == 0) {
         return 0;
     }
     sal_uInt32 n = mapSize / 2;
-    detail::MapEntry const * p = mapBegin + n;
+    MapEntry const * p = mapBegin + n;
     switch (compare(file, name, nameOffset, nameLength, p)) {
     case COMPARE_LESS:
         return findInMap(file, mapBegin, n, name, nameOffset, nameLength);
@@ -438,7 +435,7 @@ sal_uInt32 findInMap(
 }
 
 std::vector< OUString > readAnnotations(
-    bool annotated, rtl::Reference< detail::MappedFile > const & file,
+    bool annotated, rtl::Reference< MappedFile > const & file,
     sal_uInt32 offset, sal_uInt32 * newOffset = 0)
 {
     std::vector< OUString > ans;
@@ -456,7 +453,7 @@ std::vector< OUString > readAnnotations(
 }
 
 ConstantValue readConstant(
-    rtl::Reference< detail::MappedFile > const & file, sal_uInt32 offset,
+    rtl::Reference< MappedFile > const & file, sal_uInt32 offset,
     sal_uInt32 * newOffset = 0, bool * annotated = 0)
 {
     assert(file.is());
@@ -546,13 +543,13 @@ ConstantValue readConstant(
 }
 
 rtl::Reference< Entity > readEntity(
-    rtl::Reference< detail::MappedFile > const & file, sal_uInt32 offset);
+    rtl::Reference< MappedFile > const & file, sal_uInt32 offset);
 
 class UnoidlCursor: public MapCursor {
 public:
     UnoidlCursor(
-        rtl::Reference< detail::MappedFile > file,
-        detail::MapEntry const * mapBegin, sal_uInt32 mapSize):
+        rtl::Reference< MappedFile > file, MapEntry const * mapBegin,
+        sal_uInt32 mapSize):
         file_(file), mapIndex_(mapBegin), mapEnd_(mapBegin + mapSize)
     {}
 
@@ -561,9 +558,9 @@ private:
 
     virtual rtl::Reference< Entity > getNext(OUString * name);
 
-    rtl::Reference< detail::MappedFile > file_;
-    detail::MapEntry const * mapIndex_;
-    detail::MapEntry const * mapEnd_;
+    rtl::Reference< MappedFile > file_;
+    MapEntry const * mapIndex_;
+    MapEntry const * mapEnd_;
 };
 
 rtl::Reference< Entity > UnoidlCursor::getNext(OUString * name) {
@@ -580,11 +577,11 @@ rtl::Reference< Entity > UnoidlCursor::getNext(OUString * name) {
 class UnoidlModuleEntity: public ModuleEntity {
 public:
     UnoidlModuleEntity(
-        rtl::Reference< detail::MappedFile > const & file, sal_uInt32 mapOffset,
+        rtl::Reference< MappedFile > const & file, sal_uInt32 mapOffset,
         sal_uInt32 mapSize):
         file_(file),
         mapBegin_(
-            reinterpret_cast< detail::MapEntry const * >(
+            reinterpret_cast< MapEntry const * >(
                 static_cast< char const * >(file_->address) + mapOffset)),
         mapSize_(mapSize)
     { assert(file.is()); }
@@ -597,8 +594,8 @@ private:
     virtual rtl::Reference< MapCursor > createCursor() const
     { return new UnoidlCursor(file_, mapBegin_, mapSize_); }
 
-    rtl::Reference< detail::MappedFile > file_;
-    detail::MapEntry const * mapBegin_;
+    rtl::Reference< MappedFile > file_;
+    MapEntry const * mapBegin_;
     sal_uInt32 mapSize_;
 };
 
@@ -611,7 +608,7 @@ std::vector< OUString > UnoidlModuleEntity::getMemberNames() const {
 }
 
 rtl::Reference< Entity > readEntity(
-    rtl::Reference< detail::MappedFile > const & file, sal_uInt32 offset)
+    rtl::Reference< MappedFile > const & file, sal_uInt32 offset)
 {
     assert(file.is());
     int v = file->read8(offset);
@@ -959,9 +956,8 @@ rtl::Reference< Entity > readEntity(
                     ("UNOIDL format: constant group map offset + size too"
                      " large"));
             }
-            detail::MapEntry const * p
-                = reinterpret_cast< detail::MapEntry const * >(
-                    static_cast< char const * >(file->address) + offset + 5);
+            MapEntry const * p = reinterpret_cast< MapEntry const * >(
+                static_cast< char const * >(file->address) + offset + 5);
             std::vector< ConstantGroupEntity::Member > mems;
             for (sal_uInt32 i = 0; i != n; ++i) {
                 sal_uInt32 off = p[i].data.getUnsigned32();
@@ -1179,8 +1175,7 @@ rtl::Reference< Entity > readEntity(
 
 }
 
-UnoidlProvider::UnoidlProvider(OUString const & uri):
-    file_(new detail::MappedFile(uri))
+UnoidlProvider::UnoidlProvider(OUString const & uri): file_(new MappedFile(uri))
 {
     if (file_->size < 8 || std::memcmp(file_->address, "UNOIDL\xFF\0", 8) != 0)
     {
@@ -1195,7 +1190,7 @@ UnoidlProvider::UnoidlProvider(OUString const & uri):
         throw FileFormatException(
             file_->uri, "UNOIDL format: root map offset + size too large");
     }
-    mapBegin_ = reinterpret_cast< detail::MapEntry const * >(
+    mapBegin_ = reinterpret_cast< MapEntry const * >(
         static_cast< char const * >(file_->address) + off);
 }
 
@@ -1205,13 +1200,7 @@ rtl::Reference< MapCursor > UnoidlProvider::createRootCursor() const {
 
 rtl::Reference< Entity > UnoidlProvider::findEntity(OUString const & name) const
 {
-    bool cnst;
-    sal_uInt32 off = find(name, &cnst);
-    return off == 0 || cnst ? rtl::Reference< Entity >() : getEntity(off);
-}
-
-sal_uInt32 UnoidlProvider::find(OUString const & name, bool * constant) const {
-    detail::MapEntry const * mapBegin = mapBegin_;
+    MapEntry const * mapBegin = mapBegin_;
     sal_uInt32 mapSize = mapSize_;
     bool cgroup = false;
     for (sal_Int32 i = 0;;) {
@@ -1221,16 +1210,13 @@ sal_uInt32 UnoidlProvider::find(OUString const & name, bool * constant) const {
         }
         sal_Int32 off = findInMap(file_, mapBegin, mapSize, name, i, j - i);
         if (off == 0) {
-            return 0;
+            return rtl::Reference< Entity >();
         }
         if (j == name.getLength()) {
-            if (constant != 0) {
-                *constant = cgroup;
-            }
-            return off;
+            return cgroup ? rtl::Reference< Entity >() : readEntity(file_, off);
         }
         if (cgroup) {
-            return 0;
+            return rtl::Reference< Entity >();
                 //TODO: throw an exception instead here, where the segments of a
                 // constant's name are a prefix of the requested name's
                 // segments?
@@ -1240,7 +1226,7 @@ sal_uInt32 UnoidlProvider::find(OUString const & name, bool * constant) const {
             if ((v & 0x3F) == 7) { // constant group
                 cgroup = true;
             } else {
-                return 0;
+                return rtl::Reference< Entity >();
                     //TODO: throw an exception instead here, where the segments
                     // of a non-module, non-constant-group entity's name are a
                     // prefix of the requested name's segments?
@@ -1251,22 +1237,14 @@ sal_uInt32 UnoidlProvider::find(OUString const & name, bool * constant) const {
             throw FileFormatException(
                 file_->uri, "UNOIDL format: map offset + size too large");
         }
-        mapBegin = reinterpret_cast< detail::MapEntry const * >(
+        mapBegin = reinterpret_cast< MapEntry const * >(
             static_cast< char const * >(file_->address) + off + 5);
         i = j + 1;
     }
 }
 
-rtl::Reference< Entity > UnoidlProvider::getEntity(sal_uInt32 offset) const {
-    return readEntity(file_, offset);
-}
-
-ConstantValue UnoidlProvider::getConstant(sal_uInt32 offset) const {
-    return readConstant(file_, offset);
-}
-
 UnoidlProvider::~UnoidlProvider() throw () {}
 
-}
+} }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/unoidl/unoidlprovider.hxx b/unoidl/source/unoidlprovider.hxx
similarity index 68%
rename from include/unoidl/unoidlprovider.hxx
rename to unoidl/source/unoidlprovider.hxx
index d7d4fbb..712282a 100644
--- a/include/unoidl/unoidlprovider.hxx
+++ b/unoidl/source/unoidlprovider.hxx
@@ -14,17 +14,14 @@
 
 #include "rtl/ref.hxx"
 #include "sal/types.h"
-#include "unoidl/detail/dllapi.hxx"
 #include "unoidl/unoidl.hxx"
 
 namespace unoidl { namespace detail {
-    class MappedFile;
-    struct MapEntry;
-} }
 
-namespace unoidl {
+class MappedFile;
+struct MapEntry;
 
-class LO_DLLPUBLIC_UNOIDL UnoidlProvider: public Provider {
+class UnoidlProvider: public Provider {
 public:
     // throws FileFormatException, NoSuchFileException:
     explicit UnoidlProvider(OUString const & uri);
@@ -36,24 +33,15 @@ public:
     virtual rtl::Reference< Entity > findEntity(OUString const & name)
         const;
 
-    // throws FileFormatException:
-    sal_uInt32 find(OUString const & name, bool * constant = 0) const;
-
-    // throws FileFormatException:
-    rtl::Reference< Entity > getEntity(sal_uInt32 offset) const;
-
-    // throws FileFormatException:
-    ConstantValue getConstant(sal_uInt32 offset) const;
-
 private:
-    virtual SAL_DLLPRIVATE ~UnoidlProvider() throw ();
+    virtual ~UnoidlProvider() throw ();
 
     rtl::Reference< detail::MappedFile > file_;
     detail::MapEntry const * mapBegin_;
     sal_uInt32 mapSize_;
 };
 
-}
+} }
 
 #endif
 


More information about the Libreoffice-commits mailing list