[Libreoffice-commits] core.git: solenv/bin stoc/source

Caolán McNamara caolanm at redhat.com
Fri Sep 15 15:44:59 UTC 2017


 solenv/bin/native-code.py                       |    3 -
 stoc/source/corereflection/crefl.cxx            |   57 ++++++++++--------------
 stoc/source/corereflection/reflection.component |    5 +-
 3 files changed, 29 insertions(+), 36 deletions(-)

New commits:
commit f7b1989503380bb83841b3b086e5cbc6f7ca750c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Sep 14 16:44:17 2017 +0100

    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 at redhat.com>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index 4ca09fd2e1af..d0f1726dd65e 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -23,7 +23,6 @@ import xml.etree.ElementTree as ET
 core_factory_list = [
     ("libembobj.a", "embobj_component_getFactory"),
     ("libevtattlo.a", "evtatt_component_getFactory"),
-    ("libreflectionlo.a", "reflection_component_getFactory"),
     ("libcomphelper.a", "comphelp_component_getFactory"),
     ("libconfigmgrlo.a", "configmgr_component_getFactory"),
     ("libdrawinglayerlo.a", "drawinglayer_component_getFactory"),
@@ -190,6 +189,8 @@ core_constructor_list = [
     "com_sun_star_comp_embed_OLESimpleStorage",
 # stoc/source/inspect/introspection.component
     "com_sun_star_comp_stoc_Introspection_get_implementation",
+# stoc/source/corereflection/reflection.component
+    "com_sun_star_comp_stoc_CoreReflection_get_implementation",
 # stoc/util/stocservices.component
     "com_sun_star_comp_stoc_OServiceManagerWrapper_get_implementation",
     "com_sun_star_comp_stoc_TypeConverter_get_implementation",
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>


More information about the Libreoffice-commits mailing list