summaryrefslogtreecommitdiff
path: root/unoidl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-05-23 12:30:00 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-05-23 13:44:03 +0200
commitd0322208bcbb35b9149b508ac2bffa667c38696f (patch)
treef324a25f9688163c9ae5d34d02aea1454e659010 /unoidl
parent8928a4f6dcacb1357d3b9b1a7a29cc62fede87d9 (diff)
Combine unoidl::loadProvider and unoidl::Manager::addProvider
Change-Id: I1240656cc2a4d713c838eb80fa90ce3485aad614
Diffstat (limited to 'unoidl')
-rw-r--r--unoidl/README4
-rw-r--r--unoidl/source/unoidl-check.cxx3
-rw-r--r--unoidl/source/unoidl-read.cxx3
-rw-r--r--unoidl/source/unoidl-write.cxx3
-rw-r--r--unoidl/source/unoidl.cxx60
5 files changed, 36 insertions, 37 deletions
diff --git a/unoidl/README b/unoidl/README
index 3c387e9038d9..9a2f9d263382 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 3a0dd36b8070..688a62ce64ba 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 1a7633535579..1deb4d75f376 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 8b3b3bf4b287..3ea09d3840a7 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 3eb36a8990ae..454638312928 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: */