Kaydet (Commit) 0ff9244d authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Clean up the unoidl Providers (no need to have them exported)

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