summaryrefslogtreecommitdiff
path: root/unoidl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-09-16 17:36:42 +0200
committerStephan Bergmann <sbergman@redhat.com>2013-09-16 17:37:15 +0200
commit0ff9244d8aa8ba46025d8ae9d2e0f83385793165 (patch)
tree632bd80cde465b35d6acbf338bff321101837d5a /unoidl
parent69f08eda0bd999c827c76d3bf0b9c925b7eb25f7 (diff)
Clean up the unoidl Providers (no need to have them exported)
Change-Id: I96b99e96b44f12b7ad7f376e4b3a68d7e9531643
Diffstat (limited to 'unoidl')
-rw-r--r--unoidl/source/legacyprovider.cxx7
-rw-r--r--unoidl/source/legacyprovider.hxx45
-rwxr-xr-xunoidl/source/sourceprovider.cxx10
-rw-r--r--unoidl/source/sourceprovider.hxx46
-rw-r--r--unoidl/source/unoidl.cxx13
-rw-r--r--unoidl/source/unoidlprovider.cxx90
-rw-r--r--unoidl/source/unoidlprovider.hxx48
7 files changed, 189 insertions, 70 deletions
diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx
index b92302d40ab5..3b3821566ff0 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/unoidl/source/legacyprovider.hxx b/unoidl/source/legacyprovider.hxx
new file mode 100644
index 000000000000..538b66f02ca6
--- /dev/null
+++ b/unoidl/source/legacyprovider.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_UNOIDL_LEGACYPROVIDER_HXX
+#define INCLUDED_UNOIDL_LEGACYPROVIDER_HXX
+
+#include "sal/config.h"
+
+#include "registry/registry.hxx"
+#include "rtl/ref.hxx"
+#include "unoidl/unoidl.hxx"
+
+namespace unoidl { namespace detail {
+
+class LegacyProvider: public Provider {
+public:
+ // throws FileFormatException, NoSuchFileException:
+ LegacyProvider(
+ rtl::Reference< Manager > const & manager, OUString const & uri);
+
+ // throws FileFormatException:
+ virtual rtl::Reference< MapCursor > createRootCursor() const;
+
+ // throws FileFormatException:
+ virtual rtl::Reference< Entity > findEntity(OUString const & name)
+ const;
+
+private:
+ virtual ~LegacyProvider() throw ();
+
+ rtl::Reference< Manager > manager_;
+ mutable RegistryKey ucr_;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unoidl/source/sourceprovider.cxx b/unoidl/source/sourceprovider.cxx
index ea7f1103db5e..429f68f41898 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/unoidl/source/sourceprovider.hxx b/unoidl/source/sourceprovider.hxx
new file mode 100644
index 000000000000..e7ee92f64a0f
--- /dev/null
+++ b/unoidl/source/sourceprovider.hxx
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_UNOIDL_SOURCEPROVIDER_HXX
+#define INCLUDED_UNOIDL_SOURCEPROVIDER_HXX
+
+#include "sal/config.h"
+
+#include <map>
+
+#include "rtl/ref.hxx"
+#include "unoidl/unoidl.hxx"
+
+namespace unoidl { namespace detail {
+
+class SourceProvider: public Provider {
+public:
+ // throws FileFormatException, NoSuchFileException:
+ SourceProvider(
+ rtl::Reference<Manager> const & manager, OUString const & uri);
+
+ // throws FileFormatException:
+ virtual rtl::Reference<MapCursor> createRootCursor() const;
+
+ // throws FileFormatException:
+ virtual rtl::Reference<Entity> findEntity(OUString const & name) const;
+
+private:
+ virtual ~SourceProvider() throw ();
+
+ rtl::Reference<Manager> manager_;
+ OUString uri_;
+ mutable std::map< OUString, rtl::Reference<Entity> > cache_; //TODO: at manager
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unoidl/source/unoidl.cxx b/unoidl/source/unoidl.cxx
index bdc7b98ed0d4..e5c3c434a357 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 47b6f9eb0399..b195f4473c0c 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/unoidl/source/unoidlprovider.hxx b/unoidl/source/unoidlprovider.hxx
new file mode 100644
index 000000000000..712282a239fd
--- /dev/null
+++ b/unoidl/source/unoidlprovider.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef INCLUDED_UNOIDL_UNOIDLPROVIDER_HXX
+#define INCLUDED_UNOIDL_UNOIDLPROVIDER_HXX
+
+#include "sal/config.h"
+
+#include "rtl/ref.hxx"
+#include "sal/types.h"
+#include "unoidl/unoidl.hxx"
+
+namespace unoidl { namespace detail {
+
+class MappedFile;
+struct MapEntry;
+
+class UnoidlProvider: public Provider {
+public:
+ // throws FileFormatException, NoSuchFileException:
+ explicit UnoidlProvider(OUString const & uri);
+
+ // throws FileFormatException:
+ virtual rtl::Reference< MapCursor > createRootCursor() const;
+
+ // throws FileFormatException:
+ virtual rtl::Reference< Entity > findEntity(OUString const & name)
+ const;
+
+private:
+ virtual ~UnoidlProvider() throw ();
+
+ rtl::Reference< detail::MappedFile > file_;
+ detail::MapEntry const * mapBegin_;
+ sal_uInt32 mapSize_;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */