From 15b100506a61ccae6573e4969e525a981098344f Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 14 Jul 2020 10:36:40 +0200 Subject: 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 --- pyuno/source/loader/pythonloader.component | 5 ++-- pyuno/source/loader/pyuno_loader.cxx | 41 +++++------------------------- 2 files changed, 9 insertions(+), 37 deletions(-) (limited to 'pyuno') 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 @@ --> - + xmlns="http://openoffice.org/2010/uno-components"> + 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 CreateInstance(const Reference & ctx) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +pyuno_Loader_get_implementation( + css::uno::XComponentContext* ctx , css::uno::Sequence const&) { // tdf#114815 thread-safe static to init python only once static PythonInit s_Init; @@ -262,7 +254,7 @@ static Reference CreateInstance(const Reference & 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 CreateInstance(const Reference & 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(); } } -- cgit