From 992a33313046f4a4d322db9464c474e7429a019a Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 6 Apr 2017 10:47:24 +0200 Subject: 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 Tested-by: Noel Grandin --- cppuhelper/source/shlib.cxx | 128 ++++++++++++++++++++++---------------------- 1 file changed, 63 insertions(+), 65 deletions(-) (limited to 'cppuhelper/source/shlib.cxx') 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 invokeComponentFactory( static_cast( (*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()); - } - void * smgr = mapTo.mapInterface( - serviceManager.get(), - cppu::UnoType::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::Reference res; - mapFrom.mapInterface( - reinterpret_cast(&res), factory, - cppu::UnoType::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()); + } + void * smgr = mapTo.mapInterface( + serviceManager.get(), + cppu::UnoType::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::Reference res; + mapFrom.mapInterface( + reinterpret_cast(&res), factory, + cppu::UnoType::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()); - } - return [mapFrom, mapTo, target, constructorFunction] - (css::uno::XComponentContext *const context, css::uno::Sequence const& args) - { - void *const ctxt = mapTo.mapInterface( - context, - cppu::UnoType::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(&res), instance, - cppu::UnoType::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()); + } + return [mapFrom, mapTo, target, constructorFunction] + (css::uno::XComponentContext *const context, css::uno::Sequence const& args) + { + void *const ctxt = mapTo.mapInterface( + context, + cppu::UnoType::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(&res), instance, + cppu::UnoType::get()); + (*target.get()->pExtEnv->releaseInterface)( + target.get()->pExtEnv, instance); + return res; + }; } #endif -- cgit