[Libreoffice-commits] core.git: pyuno/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Tue Jul 14 13:50:11 UTC 2020


 pyuno/source/loader/pythonloader.component |    5 ++-
 pyuno/source/loader/pyuno_loader.cxx       |   41 ++++-------------------------
 2 files changed, 9 insertions(+), 37 deletions(-)

New commits:
commit 15b100506a61ccae6573e4969e525a981098344f
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Jul 14 10:36:40 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jul 14 15:49:24 2020 +0200

    pyuno: create instances with uno constructors
    
    See tdf#74608 for motivation.
    
    Change-Id: I4bdc09b4ba5c2f7ecc4fc8184f2d8230896aef01
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98716
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/pyuno/source/loader/pythonloader.component b/pyuno/source/loader/pythonloader.component
index b98b1cd57f36..4e22781a6e60 100644
--- a/pyuno/source/loader/pythonloader.component
+++ b/pyuno/source/loader/pythonloader.component
@@ -18,8 +18,9 @@
  -->
 
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
-    prefix="pythonloader" xmlns="http://openoffice.org/2010/uno-components">
-  <implementation name="org.openoffice.comp.pyuno.Loader">
+    xmlns="http://openoffice.org/2010/uno-components">
+  <implementation name="org.openoffice.comp.pyuno.Loader"
+    constructor="pyuno_Loader_get_implementation">
     <service name="com.sun.star.loader.Python"/>
   </implementation>
 </component>
diff --git a/pyuno/source/loader/pyuno_loader.cxx b/pyuno/source/loader/pyuno_loader.cxx
index 9df4ecfb770e..db6acb04dbd8 100644
--- a/pyuno/source/loader/pyuno_loader.cxx
+++ b/pyuno/source/loader/pyuno_loader.cxx
@@ -106,16 +106,6 @@ static PyRef getObjectFromLoaderModule( const char * func )
     return object;
 }
 
-static OUString getImplementationName()
-{
-    return "org.openoffice.comp.pyuno.Loader";
-}
-
-static Sequence< OUString > getSupportedServiceNames()
-{
-    return { "com.sun.star.loader.Python" };
-}
-
 static void setPythonHome ( const OUString & pythonHome )
 {
     OUString systemPythonHome;
@@ -242,7 +232,9 @@ PythonInit() {
 
 }
 
-static Reference<XInterface> CreateInstance(const Reference<XComponentContext> & ctx)
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+pyuno_Loader_get_implementation(
+    css::uno::XComponentContext* ctx , css::uno::Sequence<css::uno::Any> const&)
 {
     // tdf#114815 thread-safe static to init python only once
     static PythonInit s_Init;
@@ -262,7 +254,7 @@ static Reference<XInterface> CreateInstance(const Reference<XComponentContext> &
         Runtime runtime;
 
         PyRef pyCtx = runtime.any2PyObject(
-            css::uno::makeAny( ctx ) );
+            css::uno::makeAny( css::uno::Reference(ctx) ) );
 
         PyRef clazz = getObjectFromLoaderModule( "Loader" );
         PyRef args ( PyTuple_New( 1 ), SAL_NO_ACQUIRE, NOT_NULL );
@@ -270,29 +262,8 @@ static Reference<XInterface> CreateInstance(const Reference<XComponentContext> &
         PyRef pyInstance( PyObject_CallObject( clazz.get() , args.get() ), SAL_NO_ACQUIRE );
         runtime.pyObject2Any( pyInstance ) >>= ret;
     }
-    return ret;
-}
-
-}
-
-
-const struct cppu::ImplementationEntry g_entries[] =
-{
-    {
-        pyuno_loader::CreateInstance, pyuno_loader::getImplementationName,
-        pyuno_loader::getSupportedServiceNames, cppu::createSingleComponentFactory,
-        nullptr , 0
-    },
-    { nullptr, nullptr, nullptr, nullptr, nullptr, 0 }
-};
-
-extern "C"
-{
-
-SAL_DLLPUBLIC_EXPORT void * pythonloader_component_getFactory(
-    const char * pImplName, void * pServiceManager, void * pRegistryKey )
-{
-    return cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries );
+    ret->acquire();
+    return ret.get();
 }
 
 }


More information about the Libreoffice-commits mailing list