summaryrefslogtreecommitdiff
path: root/pyuno
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-14 10:36:40 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-14 15:49:24 +0200
commit15b100506a61ccae6573e4969e525a981098344f (patch)
treebf7d81f28a23e043b6d8737e86ea9d7a0382226f /pyuno
parentcef5a2d780ad01105dae860f6293f6f137603027 (diff)
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@collabora.co.uk>
Diffstat (limited to 'pyuno')
-rw-r--r--pyuno/source/loader/pythonloader.component5
-rw-r--r--pyuno/source/loader/pyuno_loader.cxx41
2 files changed, 9 insertions, 37 deletions
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();
}
}