summaryrefslogtreecommitdiff
path: root/cppuhelper/source/shlib.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-04-06 10:47:24 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-04-12 10:11:34 +0200
commit992a33313046f4a4d322db9464c474e7429a019a (patch)
tree494143e3070af872027ecaca840516d3101a881c /cppuhelper/source/shlib.cxx
parent77c1431ee88ab04a9ff48b849acedee6d455bafb (diff)
clang-tidy: readability-else-after-return
run it against sal,cppu,cppuhelper I had to run this multiple times to catch all the cases in each module, and it requires some hand-tweaking of the resulting output - clang-tidy is not very good about cleaning up trailing spaces, and aligning things nicely. Change-Id: I00336345f5f036e12422b98d66526509380c497a Reviewed-on: https://gerrit.libreoffice.org/36194 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cppuhelper/source/shlib.cxx')
-rw-r--r--cppuhelper/source/shlib.cxx128
1 files changed, 63 insertions, 65 deletions
diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx
index e3791ac12a00..e78071bb4774 100644
--- a/cppuhelper/source/shlib.cxx
+++ b/cppuhelper/source/shlib.cxx
@@ -127,37 +127,36 @@ css::uno::Reference<css::uno::XInterface> invokeComponentFactory(
static_cast<css::uno::XInterface *>(
(*function)(impl.getStr(), serviceManager.get(), nullptr)),
SAL_NO_ACQUIRE);
- } else {
- css::uno::Mapping mapTo(source, target);
- css::uno::Mapping mapFrom(target, source);
- if (!(mapTo.is() && mapFrom.is())) {
- throw css::loader::CannotActivateFactoryException(
- "cannot get mappings",
- css::uno::Reference<css::uno::XInterface>());
- }
- void * smgr = mapTo.mapInterface(
- serviceManager.get(),
- cppu::UnoType<css::lang::XMultiServiceFactory>::get());
- void * factory = nullptr;
- target.invoke(getFactory, function, &impl, smgr, &factory);
- if (smgr != nullptr) {
- (*target.get()->pExtEnv->releaseInterface)(
- target.get()->pExtEnv, smgr);
- }
- if (factory == nullptr) {
- throw css::loader::CannotActivateFactoryException(
- ("calling factory function for \"" + implementation + "\" in <"
- + uri + "> returned null"),
- css::uno::Reference<css::uno::XInterface>());
- }
- css::uno::Reference<css::uno::XInterface> res;
- mapFrom.mapInterface(
- reinterpret_cast<void **>(&res), factory,
- cppu::UnoType<css::uno::XInterface>::get());
+ }
+ css::uno::Mapping mapTo(source, target);
+ css::uno::Mapping mapFrom(target, source);
+ if (!(mapTo.is() && mapFrom.is())) {
+ throw css::loader::CannotActivateFactoryException(
+ "cannot get mappings",
+ css::uno::Reference<css::uno::XInterface>());
+ }
+ void * smgr = mapTo.mapInterface(
+ serviceManager.get(),
+ cppu::UnoType<css::lang::XMultiServiceFactory>::get());
+ void * factory = nullptr;
+ target.invoke(getFactory, function, &impl, smgr, &factory);
+ if (smgr != nullptr) {
(*target.get()->pExtEnv->releaseInterface)(
- target.get()->pExtEnv, factory);
- return res;
+ target.get()->pExtEnv, smgr);
+ }
+ if (factory == nullptr) {
+ throw css::loader::CannotActivateFactoryException(
+ ("calling factory function for \"" + implementation + "\" in <"
+ + uri + "> returned null"),
+ css::uno::Reference<css::uno::XInterface>());
}
+ css::uno::Reference<css::uno::XInterface> res;
+ mapFrom.mapInterface(
+ reinterpret_cast<void **>(&res), factory,
+ cppu::UnoType<css::uno::XInterface>::get());
+ (*target.get()->pExtEnv->releaseInterface)(
+ target.get()->pExtEnv, factory);
+ return res;
}
#if !defined DISABLE_DYNLOADING
@@ -186,44 +185,43 @@ cppuhelper::WrapperConstructorFn mapConstructorFn(
}
if (source.get() == target.get()) {
return cppuhelper::WrapperConstructorFn(constructorFunction);
- } else {
- // note: it should be valid to capture these mappings because they are
- // ref-counted, and the returned closure will always be invoked in the
- // "source" environment
- css::uno::Mapping mapTo(source, target);
- css::uno::Mapping mapFrom(target, source);
- if (!(mapTo.is() && mapFrom.is())) {
- throw css::loader::CannotActivateFactoryException(
- "cannot get mappings",
- css::uno::Reference<css::uno::XInterface>());
- }
- return [mapFrom, mapTo, target, constructorFunction]
- (css::uno::XComponentContext *const context, css::uno::Sequence<css::uno::Any> const& args)
- {
- void *const ctxt = mapTo.mapInterface(
- context,
- cppu::UnoType<css::uno::XComponentContext>::get());
- if (args.getLength() > 0) {
- std::abort(); // TODO map args
- }
- void * instance = nullptr;
- target.invoke(getInstance, constructorFunction, ctxt, &args, &instance);
- if (ctxt != nullptr) {
- (*target.get()->pExtEnv->releaseInterface)(
- target.get()->pExtEnv, ctxt);
- }
- css::uno::XInterface * res = nullptr;
- if (instance == nullptr) {
- return res;
- }
- mapFrom.mapInterface(
- reinterpret_cast<void **>(&res), instance,
- cppu::UnoType<css::uno::XInterface>::get());
+ }
+ // note: it should be valid to capture these mappings because they are
+ // ref-counted, and the returned closure will always be invoked in the
+ // "source" environment
+ css::uno::Mapping mapTo(source, target);
+ css::uno::Mapping mapFrom(target, source);
+ if (!(mapTo.is() && mapFrom.is())) {
+ throw css::loader::CannotActivateFactoryException(
+ "cannot get mappings",
+ css::uno::Reference<css::uno::XInterface>());
+ }
+ return [mapFrom, mapTo, target, constructorFunction]
+ (css::uno::XComponentContext *const context, css::uno::Sequence<css::uno::Any> const& args)
+ {
+ void *const ctxt = mapTo.mapInterface(
+ context,
+ cppu::UnoType<css::uno::XComponentContext>::get());
+ if (args.getLength() > 0) {
+ std::abort(); // TODO map args
+ }
+ void * instance = nullptr;
+ target.invoke(getInstance, constructorFunction, ctxt, &args, &instance);
+ if (ctxt != nullptr) {
(*target.get()->pExtEnv->releaseInterface)(
- target.get()->pExtEnv, instance);
+ target.get()->pExtEnv, ctxt);
+ }
+ css::uno::XInterface * res = nullptr;
+ if (instance == nullptr) {
return res;
- };
- }
+ }
+ mapFrom.mapInterface(
+ reinterpret_cast<void **>(&res), instance,
+ cppu::UnoType<css::uno::XInterface>::get());
+ (*target.get()->pExtEnv->releaseInterface)(
+ target.get()->pExtEnv, instance);
+ return res;
+ };
}
#endif