Kaydet (Commit) 25d114ee authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Initial experiments with static linking of (some) components / services

Start with the first service needed when running sc's filters_test:
the UniversalContentBroker. It might not be typical as ucb uses the
deprecated XSingleServiceFactory.

This commit is not at all a complete solution, far from it, just an
initial hack. Naturally once I come up with some generic enough way to
do the static linking the necessary macros etc will be added to some
general header.

The macro XSERVICEINFO_IMPL_1 (local to ucbhelper and ucb) is amended
so that it in the disable-dynamic-linking case also emits a function
whose assembler name equal contains the service name. This function
returns the XSingleServiceFactory for the service. Where the service
is instantiated we link directly to that function.

But probably this will be reworked a couple of times... Maybe it would
be better to simply have the service name specific entry point be a
pointer to the component's component_getFactory() function? Those all
have the same prototype.
üst 9423429a
......@@ -30,7 +30,7 @@ SRCS = filters-test.m
CFLAGS = $(SOLARINC)
LIBS = -Wl,$(OUTDIR)/bin/cppunit/cppunittester.a -Wl,$(WORKDIR)/LinkTarget/CppunitTest/libtest_sc_filters_test.a -Wl,$(OUTDIR)/lib/bootstrap.uno.a -Wl,$(OUTDIR)/lib/unoexceptionprotector.a $(SOLARLIB) -lavmedialo -lbasegfxlo -lcanvastoolslo -lcomphelpgcc3 -lcppcanvaslo -lcppunit -ldrawinglayerlo -leditenglo -lforlo -lforuilo -lfwelo -lfwilo -lfwklo -lgcc3_uno -li18nisolang1gcc3 -li18npaperlo -li18nutilgcc3 -licuuc -ljpeg -ljvmfwk -llnglo -lreg -lsal_textenc -lsalcpprt -lsaxlo -lsclo -lsfxlo -lstore -lsvllo -lsvtlo -lsvxlo -lsvxcorelo -lsotlo -ltest -ltklo -ltllo -lucbhelper4gcc3 -luno_cppuhelpergcc3 -luno_cppu -luno_sal -luno_salhelpergcc3 -lunotest -lutllo -lvcllo -lxml2 -lxmlreader -lxolo -lz $(addprefix -framework , $(gb_Library__FRAMEWORKS)) -liconv -lobjc
LIBS = -Wl,$(OUTDIR)/bin/cppunit/cppunittester.a -Wl,$(WORKDIR)/LinkTarget/CppunitTest/libtest_sc_filters_test.a -Wl,$(OUTDIR)/lib/bootstrap.uno.a -Wl,$(OUTDIR)/lib/unoexceptionprotector.a $(SOLARLIB) -lavmedialo -lbasegfxlo -lcanvastoolslo -lcomphelpgcc3 -lcppcanvaslo -lcppunit -ldrawinglayerlo -leditenglo -lforlo -lforuilo -lfwelo -lfwilo -lfwklo -lgcc3_uno -li18nisolang1gcc3 -li18npaperlo -li18nutilgcc3 -licuuc -ljpeg -ljvmfwk -llnglo -lreg -lsal_textenc -lsalcpprt -lsaxlo -lsclo -lsfxlo -lstore -lsvllo -lsvtlo -lsvxlo -lsvxcorelo -lsotlo -ltest -ltklo -ltllo -lucb1 -lucbhelper4gcc3 -luno_cppuhelpergcc3 -luno_cppu -luno_sal -luno_salhelpergcc3 -lunotest -lutllo -lvcllo -lxml2 -lxmlreader -lxolo -lz $(addprefix -framework , $(gb_Library__FRAMEWORKS)) -liconv -lobjc
all: $(APPDIR)/$(APP) stuff
......
......@@ -2200,10 +2200,8 @@ XTYPEPROVIDER_IMPL_3( CachedContentResultSetFactory,
//--------------------------------------------------------------------------
XSERVICEINFO_IMPL_1( CachedContentResultSetFactory,
OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.ucb.CachedContentResultSetFactory" )),
OUString(RTL_CONSTASCII_USTRINGPARAM(
CACHED_CONTENT_RESULTSET_FACTORY_NAME )) );
"com.sun.star.comp.ucb.CachedContentResultSetFactory",
CACHED_CONTENT_RESULTSET_FACTORY_NAME );
//--------------------------------------------------------------------------
// Service factory implementation.
......
......@@ -531,10 +531,8 @@ XTYPEPROVIDER_IMPL_3( CachedContentResultSetStubFactory,
//--------------------------------------------------------------------------
XSERVICEINFO_IMPL_1( CachedContentResultSetStubFactory,
OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.ucb.CachedContentResultSetStubFactory" )),
OUString(RTL_CONSTASCII_USTRINGPARAM(
CACHED_CRS_STUB_FACTORY_NAME )) );
"com.sun.star.comp.ucb.CachedContentResultSetStubFactory",
CACHED_CRS_STUB_FACTORY_NAME );
//--------------------------------------------------------------------------
// Service factory implementation.
......
......@@ -176,10 +176,8 @@ XTYPEPROVIDER_IMPL_3( CachedDynamicResultSetFactory,
//--------------------------------------------------------------------------
XSERVICEINFO_IMPL_1( CachedDynamicResultSetFactory,
OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.ucb.CachedDynamicResultSetFactory" )),
OUString(RTL_CONSTASCII_USTRINGPARAM(
CACHED_DRS_FACTORY_NAME )) );
"com.sun.star.comp.ucb.CachedDynamicResultSetFactory",
CACHED_DRS_FACTORY_NAME );
//--------------------------------------------------------------------------
// Service factory implementation.
......
......@@ -166,10 +166,8 @@ XTYPEPROVIDER_IMPL_3( CachedDynamicResultSetStubFactory,
//--------------------------------------------------------------------------
XSERVICEINFO_IMPL_1( CachedDynamicResultSetStubFactory,
OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.ucb.CachedDynamicResultSetStubFactory" )),
OUString(RTL_CONSTASCII_USTRINGPARAM(
CACHED_DRS_STUB_FACTORY_NAME )) );
"com.sun.star.comp.ucb.CachedDynamicResultSetStubFactory",
CACHED_DRS_STUB_FACTORY_NAME );
//--------------------------------------------------------------------------
// Service factory implementation.
......
......@@ -87,10 +87,8 @@ XTYPEPROVIDER_IMPL_3( UcbContentProviderProxyFactory,
//=========================================================================
XSERVICEINFO_IMPL_1( UcbContentProviderProxyFactory,
OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.ucb.UcbContentProviderProxyFactory" )),
OUString(RTL_CONSTASCII_USTRINGPARAM(
PROVIDER_FACTORY_SERVICE_NAME )) );
"com.sun.star.comp.ucb.UcbContentProviderProxyFactory",
PROVIDER_FACTORY_SERVICE_NAME );
//=========================================================================
//
......
......@@ -347,10 +347,8 @@ void SAL_CALL UniversalContentBroker::removeEventListener(
//=========================================================================
XSERVICEINFO_IMPL_1( UniversalContentBroker,
OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.ucb.UniversalContentBroker" )),
OUString(RTL_CONSTASCII_USTRINGPARAM(
UCB_SERVICE_NAME )) );
"com.sun.star.comp.ucb.UniversalContentBroker",
UCB_SERVICE_NAME );
//=========================================================================
//
......
......@@ -357,10 +357,8 @@ XTYPEPROVIDER_IMPL_3( UcbPropertiesManager,
//=========================================================================
XSERVICEINFO_IMPL_1( UcbPropertiesManager,
OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.ucb.UcbPropertiesManager" )),
OUString(RTL_CONSTASCII_USTRINGPARAM(
PROPERTIES_MANAGER_SERVICE_NAME )) );
"com.sun.star.comp.ucb.UcbPropertiesManager",
PROPERTIES_MANAGER_SERVICE_NAME );
//=========================================================================
//
......
......@@ -244,10 +244,8 @@ XTYPEPROVIDER_IMPL_4( UcbStore,
//=========================================================================
XSERVICEINFO_IMPL_1( UcbStore,
OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.ucb.UcbStore" )),
OUString(RTL_CONSTASCII_USTRINGPARAM(
STORE_SERVICE_NAME )) );
"com.sun.star.comp.ucb.UcbStore",
STORE_SERVICE_NAME );
//=========================================================================
//
......
......@@ -511,10 +511,8 @@ XTYPEPROVIDER_IMPL_3( SortedDynamicResultSetFactory,
//--------------------------------------------------------------------------
XSERVICEINFO_IMPL_1( SortedDynamicResultSetFactory,
OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.ucb.SortedDynamicResultSetFactory" )),
OUString(RTL_CONSTASCII_USTRINGPARAM(
DYNAMIC_RESULTSET_FACTORY_NAME )) );
"com.sun.star.comp.ucb.SortedDynamicResultSetFactory",
DYNAMIC_RESULTSET_FACTORY_NAME );
//--------------------------------------------------------------------------
// Service factory implementation.
......
......@@ -94,10 +94,8 @@ XTYPEPROVIDER_IMPL_3( ContentProvider,
com::sun::star::ucb::XContentProvider );
XSERVICEINFO_IMPL_1( ContentProvider,
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.CmisContentProvider" )),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.ucb.CmisContentProvider" )) );
"com.sun.star.comp.CmisContentProvider",
"com.sun.star.ucb.CmisContentProvider" );
ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider );
......
......@@ -174,11 +174,12 @@ XTYPEPROVIDER_IMPL_6( FTPContent,
#undef XSERVICEINFO_CREATE_INSTANCE_IMPL
#define XSERVICEINFO_CREATE_INSTANCE_IMPL( Class )
#undef STATICALLY_LINKED_SERVICE
#define STATICALLY_LINKED_SERVICE( Class, ImplName, Service, Num )
XSERVICEINFO_IMPL_1( FTPContent,
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.FTPContent")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.ucb.FTPContent")));
"com.sun.star.comp.FTPContent",
"com.sun.star.ucb.FTPContent" );
......
......@@ -103,8 +103,8 @@ XTYPEPROVIDER_IMPL_3(FTPContentProvider,
XSERVICEINFO_IMPL_1(
FTPContentProvider,
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.FTPContentProvider")),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(FTP_CONTENT_PROVIDER_SERVICE_NAME)));
"com.sun.star.comp.FTPContentProvider",
FTP_CONTENT_PROVIDER_SERVICE_NAME);
//=========================================================================
//
......
......@@ -100,10 +100,8 @@ XTYPEPROVIDER_IMPL_4( HierarchyContentProvider,
//=========================================================================
XSERVICEINFO_IMPL_1( HierarchyContentProvider,
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.ucb.HierarchyContentProvider" )),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
HIERARCHY_CONTENT_PROVIDER_SERVICE_NAME )) );
"com.sun.star.comp.ucb.HierarchyContentProvider",
HIERARCHY_CONTENT_PROVIDER_SERVICE_NAME );
//=========================================================================
//
......
......@@ -181,10 +181,8 @@ XTYPEPROVIDER_IMPL_3( ContentProvider,
//=========================================================================
XSERVICEINFO_IMPL_1( ContentProvider,
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.ucb.PackageContentProvider" )),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
PACKAGE_CONTENT_PROVIDER_SERVICE_NAME )) );
"com.sun.star.comp.ucb.PackageContentProvider",
PACKAGE_CONTENT_PROVIDER_SERVICE_NAME );
//=========================================================================
//
......
......@@ -105,10 +105,8 @@ XTYPEPROVIDER_IMPL_4( ContentProvider,
XSERVICEINFO_IMPL_1(
ContentProvider,
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.ucb.TransientDocumentsContentProvider" ) ),
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
TDOC_CONTENT_PROVIDER_SERVICE_NAME ) ) );
"com.sun.star.comp.ucb.TransientDocumentsContentProvider",
TDOC_CONTENT_PROVIDER_SERVICE_NAME );
//=========================================================================
//
......
......@@ -93,10 +93,8 @@ XTYPEPROVIDER_IMPL_3( ContentProvider,
//=========================================================================
XSERVICEINFO_IMPL_1( ContentProvider,
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.WebDAVContentProvider" )),
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
WEBDAV_CONTENT_PROVIDER_SERVICE_NAME )) );
"com.sun.star.comp.WebDAVContentProvider",
WEBDAV_CONTENT_PROVIDER_SERVICE_NAME );
//=========================================================================
//
......
......@@ -732,19 +732,40 @@ XSERVICEINFO_CREATE_INSTANCE_IMPL( Class ) \
com::sun::star::uno::Sequence< rtl::OUString > \
Class::getSupportedServiceNames_Static()
// 1 service name
#define XSERVICEINFO_IMPL_1( Class, ImplName, Service1 ) \
XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \
XSERVICEINFO_CREATE_INSTANCE_IMPL( Class ) \
#ifdef DISABLE_DYNLOADING
#define STATICALLY_LINKED_SERVICE( Class, ImplName, Service, Num ) \
extern com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > service##Num( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &rSMgr ) \
__asm("SSF:" Service); \
\
com::sun::star::uno::Sequence< rtl::OUString > \
Class::getSupportedServiceNames_Static() \
com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > service##Num( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &rSMgr ) \
{ \
com::sun::star::uno::Sequence< rtl::OUString > aSNS( 1 ); \
aSNS.getArray()[ 0 ] = Service1; \
return aSNS; \
com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > xFactory( Class::createServiceFactory( rSMgr ) ); \
xFactory->acquire(); \
return xFactory; \
}
#else
#define STATICALLY_LINKED_SERVICE( Class, ImplName, Service, Num ) // empty
#endif
// 1 service name
#define XSERVICEINFO_IMPL_1( Class, ImplName, Service1 ) \
XSERVICEINFO_COMMOM_IMPL( Class, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ImplName )) ) \
XSERVICEINFO_CREATE_INSTANCE_IMPL( Class ) \
\
com::sun::star::uno::Sequence< rtl::OUString > \
Class::getSupportedServiceNames_Static() \
{ \
com::sun::star::uno::Sequence< rtl::OUString > aSNS( 1 ); \
aSNS.getArray()[ 0 ] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( Service1 )); \
return aSNS; \
} \
\
STATICALLY_LINKED_SERVICE( Class, ImplName, Service1, 1 )
#endif /* !_UCBHELPER_MACROS_HXX */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -34,6 +34,7 @@
*************************************************************************/
#include <osl/diagnose.h>
#include <osl/mutex.hxx>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
......@@ -42,6 +43,30 @@
#include <com/sun/star/ucb/XCommandProcessor.hpp>
#include <ucbhelper/contentbroker.hxx>
#ifdef DISABLE_DYNLOADING
#define MSF_CREATEINSTANCE(Msf, Service) \
({ \
extern com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > service( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &rSMgr ) __asm("SSF:" Service); \
com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > xFactory( service( Msf ) ); \
xFactory->createInstance(); \
})
#define MSF_CREATEINSTANCE_WITHARGUMENTS(Msf, Service, Args) \
({ \
extern com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > service( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &rSMgr ) __asm("SSF:" Service); \
com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory > xFactory( service( Msf ) ); \
xFactory->createInstanceWithArguments( Args ); \
})
#else
#define MSF_CREATEINSTANCE(Msf, Service) Msf->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( Service )) )
#define MSF_CREATEINSTANCE_WITHARGUMENTS(Msf, Service, Args) Msf->createInstanceWithArguments( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( Service )), Args )
#endif
using namespace com::sun::star::lang;
using namespace com::sun::star::ucb;
using namespace com::sun::star::uno;
......@@ -248,9 +273,7 @@ bool ContentBroker_Impl::initialize()
{
try
{
xIfc = m_xSMgr->createInstance(
OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.ucb.UniversalContentBroker" )) );
xIfc = MSF_CREATEINSTANCE( m_xSMgr, "com.sun.star.ucb.UniversalContentBroker" );
}
catch ( Exception const & )
{
......@@ -282,10 +305,7 @@ bool ContentBroker_Impl::initialize()
{
try
{
xIfc = m_xSMgr->createInstanceWithArguments(
OUString(RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.ucb.UniversalContentBroker" )),
m_aArguments );
xIfc = MSF_CREATEINSTANCE_WITHARGUMENTS( m_xSMgr, "com.sun.star.ucb.UniversalContentBroker", m_aArguments );
}
catch ( Exception const & )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment