Combine unoidl::loadProvider and unoidl::Manager::addProvider
Change-Id: I1240656cc2a4d713c838eb80fa90ce3485aad614
This commit is contained in:
@@ -423,15 +423,13 @@ SAL_IMPLEMENT_MAIN()
|
|||||||
i != extra_registries.end(); ++i)
|
i != extra_registries.end(); ++i)
|
||||||
{
|
{
|
||||||
xSet->insert(makeAny(*i));
|
xSet->insert(makeAny(*i));
|
||||||
unoidlMgr->addProvider(unoidl::loadProvider(unoidlMgr, *i));
|
unoidlMgr->addProvider(*i);
|
||||||
}
|
}
|
||||||
for (vector< OUString >::iterator i(mandatory_registries.begin());
|
for (vector< OUString >::iterator i(mandatory_registries.begin());
|
||||||
i != mandatory_registries.end(); ++i)
|
i != mandatory_registries.end(); ++i)
|
||||||
{
|
{
|
||||||
xSet->insert(makeAny(*i));
|
xSet->insert(makeAny(*i));
|
||||||
rtl::Reference< unoidl::Provider > prov(
|
rtl::Reference< unoidl::Provider > prov(unoidlMgr->addProvider(*i));
|
||||||
unoidl::loadProvider(unoidlMgr, *i));
|
|
||||||
unoidlMgr->addProvider(prov);
|
|
||||||
unoidlMandatoryProvs.push_back(prov);
|
unoidlMandatoryProvs.push_back(prov);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,9 +34,7 @@ TypeManager::TypeManager(): manager_(new unoidl::Manager) {}
|
|||||||
TypeManager::~TypeManager() {}
|
TypeManager::~TypeManager() {}
|
||||||
|
|
||||||
void TypeManager::loadProvider(OUString const & uri, bool primary) {
|
void TypeManager::loadProvider(OUString const & uri, bool primary) {
|
||||||
rtl::Reference< unoidl::Provider > prov(
|
rtl::Reference< unoidl::Provider > prov(manager_->addProvider(uri));
|
||||||
unoidl::loadProvider(manager_, uri));
|
|
||||||
manager_->addProvider(prov);
|
|
||||||
if (primary) {
|
if (primary) {
|
||||||
primaryProviders_.push_back(prov);
|
primaryProviders_.push_back(prov);
|
||||||
}
|
}
|
||||||
|
@@ -2142,7 +2142,7 @@ void cppuhelper::TypeManager::readRdbFile(
|
|||||||
rtl::OUString const & uri, bool optional)
|
rtl::OUString const & uri, bool optional)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
manager_->addProvider(unoidl::loadProvider(manager_, uri));
|
manager_->addProvider(uri);
|
||||||
} catch (unoidl::NoSuchFileException &) {
|
} catch (unoidl::NoSuchFileException &) {
|
||||||
if (!optional) {
|
if (!optional) {
|
||||||
throw css::uno::DeploymentException(
|
throw css::uno::DeploymentException(
|
||||||
|
@@ -684,7 +684,8 @@ class LO_DLLPUBLIC_UNOIDL Manager: public salhelper::SimpleReferenceObject {
|
|||||||
public:
|
public:
|
||||||
Manager() {}
|
Manager() {}
|
||||||
|
|
||||||
void addProvider(rtl::Reference< Provider > const & provider);
|
// throws FileFormatException, NoSuchFileException:
|
||||||
|
rtl::Reference< Provider > addProvider(rtl::OUString const & uri);
|
||||||
|
|
||||||
// throws FileFormatException:
|
// throws FileFormatException:
|
||||||
rtl::Reference< Entity > findEntity(rtl::OUString const & name) const;
|
rtl::Reference< Entity > findEntity(rtl::OUString const & name) const;
|
||||||
@@ -695,14 +696,13 @@ public:
|
|||||||
private:
|
private:
|
||||||
virtual SAL_DLLPRIVATE ~Manager() throw ();
|
virtual SAL_DLLPRIVATE ~Manager() throw ();
|
||||||
|
|
||||||
|
SAL_DLLPRIVATE rtl::Reference< Provider > loadProvider(
|
||||||
|
rtl::OUString const & uri);
|
||||||
|
|
||||||
mutable osl::Mutex mutex_;
|
mutable osl::Mutex mutex_;
|
||||||
std::vector< rtl::Reference< Provider > > providers_;
|
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
|
#endif
|
||||||
|
@@ -14,8 +14,8 @@ for the following registry formats:
|
|||||||
|
|
||||||
(While .idl files still contain #include directives for legacy idlc, the source-
|
(While .idl files still contain #include directives for legacy idlc, the source-
|
||||||
based formats ignore any preprocessing directives starting with "#" in the .idl
|
based formats ignore any preprocessing directives starting with "#" in the .idl
|
||||||
files.) unoidl::loadProvider transparently detects the registry format for a
|
files.) unoidl::Manager::addProvider transparently detects the registry format
|
||||||
given URI and instantiates the corresponding provider implementation.
|
for a given URI and instantiates the corresponding provider implementation.
|
||||||
|
|
||||||
Executable_unoidl-write is a helper tool to convert from any of the registry
|
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
|
formats to the UNOIDL format. It is used at build-time to compile UNOIDL format
|
||||||
|
@@ -1176,13 +1176,12 @@ SAL_IMPLEMENT_MAIN() {
|
|||||||
side = 1;
|
side = 1;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
prov[side] = unoidl::loadProvider(mgr[side], uri);
|
prov[side] = mgr[side]->addProvider(uri);
|
||||||
} catch (unoidl::NoSuchFileException &) {
|
} catch (unoidl::NoSuchFileException &) {
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "Input <" << uri << "> does not exist" << std::endl;
|
<< "Input <" << uri << "> does not exist" << std::endl;
|
||||||
std::exit(EXIT_FAILURE);
|
std::exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
mgr[side]->addProvider(prov[side]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (side == 0 || !(prov[0].is() && prov[1].is())) {
|
if (side == 0 || !(prov[0].is() && prov[1].is())) {
|
||||||
|
@@ -1112,13 +1112,12 @@ SAL_IMPLEMENT_MAIN() {
|
|||||||
for (sal_uInt32 i = (published ? 1 : 0); i != args; ++i) {
|
for (sal_uInt32 i = (published ? 1 : 0); i != args; ++i) {
|
||||||
OUString uri(getArgumentUri(i));
|
OUString uri(getArgumentUri(i));
|
||||||
try {
|
try {
|
||||||
prov = unoidl::loadProvider(mgr, uri);
|
prov = mgr->addProvider(uri);
|
||||||
} catch (unoidl::NoSuchFileException &) {
|
} catch (unoidl::NoSuchFileException &) {
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "Input <" << uri << "> does not exist" << std::endl;
|
<< "Input <" << uri << "> does not exist" << std::endl;
|
||||||
std::exit(EXIT_FAILURE);
|
std::exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
mgr->addProvider(prov);
|
|
||||||
}
|
}
|
||||||
std::map<OUString, Entity> ents;
|
std::map<OUString, Entity> ents;
|
||||||
scanMap(mgr, prov->createRootCursor(), published, "", ents);
|
scanMap(mgr, prov->createRootCursor(), published, "", ents);
|
||||||
|
@@ -1038,13 +1038,12 @@ SAL_IMPLEMENT_MAIN() {
|
|||||||
mapEntities(mgr, uri, map);
|
mapEntities(mgr, uri, map);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
prov = unoidl::loadProvider(mgr, uri);
|
prov = mgr->addProvider(uri);
|
||||||
} catch (unoidl::NoSuchFileException &) {
|
} catch (unoidl::NoSuchFileException &) {
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "Input <" << uri << "> does not exist" << std::endl;
|
<< "Input <" << uri << "> does not exist" << std::endl;
|
||||||
std::exit(EXIT_FAILURE);
|
std::exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
mgr->addProvider(prov);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!entities) {
|
if (!entities) {
|
||||||
|
@@ -166,36 +166,14 @@ ServiceBasedSingletonEntity::~ServiceBasedSingletonEntity() throw () {}
|
|||||||
|
|
||||||
Provider::~Provider() throw () {}
|
Provider::~Provider() throw () {}
|
||||||
|
|
||||||
rtl::Reference< Provider > loadProvider(
|
rtl::Reference< Provider > Manager::addProvider(OUString const & uri) {
|
||||||
rtl::Reference< Manager > const & manager, OUString const & uri)
|
rtl::Reference< Provider > p(loadProvider(uri));
|
||||||
{
|
assert(p.is());
|
||||||
osl::DirectoryItem item;
|
{
|
||||||
if (osl::DirectoryItem::get(uri, item) == osl::FileBase::E_None) {
|
osl::MutexGuard g(mutex_);
|
||||||
osl::FileStatus status(osl_FileStatus_Mask_Type);
|
providers_.push_back(p);
|
||||||
if (item.getFileStatus(status) == osl::FileBase::E_None
|
|
||||||
&& status.getFileType() == osl::FileStatus::Directory)
|
|
||||||
{
|
|
||||||
return new detail::SourceTreeProvider(manager, uri);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (uri.endsWith(".idl")) {
|
return p;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Manager::addProvider(rtl::Reference< Provider > const & provider) {
|
|
||||||
assert(provider.is());
|
|
||||||
osl::MutexGuard g(mutex_);
|
|
||||||
providers_.push_back(provider);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rtl::Reference< Entity > Manager::findEntity(rtl::OUString const & name) const {
|
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 () {}
|
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: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
Reference in New Issue
Block a user