diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-09-14 16:44:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-09-15 17:44:21 +0200 |
commit | f7b1989503380bb83841b3b086e5cbc6f7ca750c (patch) | |
tree | 6768d5cb8d04afbf7b622d738840fbd2be7685f8 /stoc | |
parent | 417bcf6b3e46eb2b5b912fe1df35974a626eabe3 (diff) |
Convert com.sun.star.comp.stoc.CoreReflection to direct construction
Change-Id: Iac6f30dbb9173e2ccc38b236efc4715ba7f2b67f
Reviewed-on: https://gerrit.libreoffice.org/42289
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'stoc')
-rw-r--r-- | stoc/source/corereflection/crefl.cxx | 57 | ||||
-rw-r--r-- | stoc/source/corereflection/reflection.component | 5 |
2 files changed, 27 insertions, 35 deletions
diff --git a/stoc/source/corereflection/crefl.cxx b/stoc/source/corereflection/crefl.cxx index 434776be2abf..00c9429b3586 100644 --- a/stoc/source/corereflection/crefl.cxx +++ b/stoc/source/corereflection/crefl.cxx @@ -43,19 +43,6 @@ using namespace osl; namespace stoc_corefl { -#define IMPLNAME "com.sun.star.comp.stoc.CoreReflection" - -static Sequence< OUString > core_getSupportedServiceNames() -{ - Sequence< OUString > seqNames { "com.sun.star.reflection.CoreReflection" }; - return seqNames; -} - -static OUString core_getImplementationName() -{ - return OUString(IMPLNAME); -} - IdlReflectionServiceImpl::IdlReflectionServiceImpl( const Reference< XComponentContext > & xContext ) : OComponentHelper( _aComponentMutex ) @@ -140,7 +127,7 @@ void IdlReflectionServiceImpl::dispose() OUString IdlReflectionServiceImpl::getImplementationName() { - return core_getImplementationName(); + return OUString("com.sun.star.comp.stoc.CoreReflection"); } sal_Bool IdlReflectionServiceImpl::supportsService( const OUString & rServiceName ) @@ -150,7 +137,8 @@ sal_Bool IdlReflectionServiceImpl::supportsService( const OUString & rServiceNam Sequence< OUString > IdlReflectionServiceImpl::getSupportedServiceNames() { - return core_getSupportedServiceNames(); + Sequence< OUString > seqNames { "com.sun.star.reflection.CoreReflection" }; + return seqNames; } // XIdlReflection @@ -390,32 +378,35 @@ uno_Interface * IdlReflectionServiceImpl::mapToUno( static_cast<XWeak *>(static_cast<OWeakObject *>(this)) ); } -/// @throws css::uno::Exception -Reference< XInterface > SAL_CALL IdlReflectionServiceImpl_create( - const Reference< XComponentContext > & xContext ) -{ - return Reference< XInterface >( static_cast<XWeak *>(static_cast<OWeakObject *>(new IdlReflectionServiceImpl( xContext ))) ); } -} +namespace { -using namespace stoc_corefl; +struct Instance { + explicit Instance( + css::uno::Reference<css::uno::XComponentContext> const & context): + instance(new stoc_corefl::IdlReflectionServiceImpl(context)) + {} -static const struct ImplementationEntry g_entries[] = -{ - { - IdlReflectionServiceImpl_create, core_getImplementationName, - core_getSupportedServiceNames, createSingleComponentFactory, - nullptr, 0 - }, - { nullptr, nullptr, nullptr, nullptr, nullptr, 0 } + rtl::Reference<cppu::OWeakObject> instance; }; -extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL reflection_component_getFactory( - const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) +struct Singleton: + public rtl::StaticWithArg< + Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton> +{}; + +} + +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_stoc_CoreReflection_get_implementation( + css::uno::XComponentContext * context, + css::uno::Sequence<css::uno::Any> const & arguments) { - return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries ); + SAL_WARN_IF( + arguments.hasElements(), "stoc", "unexpected singleton arguments"); + return cppu::acquire(Singleton::get(context).instance.get()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/stoc/source/corereflection/reflection.component b/stoc/source/corereflection/reflection.component index b1ca1a3c77c2..6ebd541950bf 100644 --- a/stoc/source/corereflection/reflection.component +++ b/stoc/source/corereflection/reflection.component @@ -18,8 +18,9 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="reflection" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.stoc.CoreReflection"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.stoc.CoreReflection" + constructor="com_sun_star_comp_stoc_CoreReflection_get_implementation"> <service name="com.sun.star.reflection.CoreReflection"/> <singleton name="com.sun.star.reflection.theCoreReflection"/> </implementation> |