[Libreoffice-commits] .: 9 commits - codemaker/source io/source remotebridges/source sal/inc sal/osl sal/qa stoc/source
Caolán McNamara
caolan at kemper.freedesktop.org
Wed Jun 1 07:42:33 PDT 2011
codemaker/source/cppumaker/cpputype.cxx | 200 +++++++++++----
codemaker/source/cppumaker/includes.cxx | 5
codemaker/source/cppumaker/includes.hxx | 2
io/source/TextInputStream/TextInputStream.cxx | 15 -
io/source/TextOutputStream/TextOutputStream.cxx | 15 -
io/source/acceptor/acceptor.cxx | 15 -
io/source/connector/connector.cxx | 15 -
remotebridges/source/unourl_resolver/unourl_resolver.cxx | 28 --
sal/inc/rtl/instance.hxx | 118 ++++++++
sal/osl/all/debugbase.cxx | 4
sal/qa/rtl/doublelock/rtl_doublelocking.cxx | 6
stoc/source/corereflection/crefl.cxx | 27 --
stoc/source/defaultregistry/defaultregistry.cxx | 27 --
stoc/source/implementationregistration/implreg.cxx | 15 -
stoc/source/invocation/invocation.cxx | 27 --
stoc/source/invocation_adapterfactory/iafactory.cxx | 29 --
stoc/source/javaloader/javaloader.cxx | 35 --
stoc/source/loader/dllcomponentloader.cxx | 27 --
stoc/source/namingservice/namingservice.cxx | 27 --
stoc/source/registry_tdprovider/tdprovider.cxx | 27 --
stoc/source/security/access_controller.cxx | 6
stoc/source/security/file_policy.cxx | 6
stoc/source/servicemanager/servicemanager.cxx | 94 +------
stoc/source/tdmanager/tdmgr.cxx | 27 --
stoc/source/typeconv/convert.cxx | 27 --
25 files changed, 367 insertions(+), 457 deletions(-)
New commits:
commit bc77c1580725079b3226bc1070549f0872a110ec
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 1 15:34:41 2011 +0100
fix up
diff --git a/remotebridges/source/unourl_resolver/unourl_resolver.cxx b/remotebridges/source/unourl_resolver/unourl_resolver.cxx
index 4589b05..e9af6ae 100644
--- a/remotebridges/source/unourl_resolver/unourl_resolver.cxx
+++ b/remotebridges/source/unourl_resolver/unourl_resolver.cxx
@@ -63,34 +63,14 @@ namespace unourl_resolver
//--------------------------------------------------------------------------------------------------
Sequence< OUString > resolver_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
+ return seqNames;
}
OUString resolver_getImplementationName()
{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( ! pImplName )
- {
- static OUString implName(
- RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) );
- pImplName = &implName;
- }
- }
- return *pImplName;
+ return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME));
}
//==================================================================================================
diff --git a/stoc/source/corereflection/crefl.cxx b/stoc/source/corereflection/crefl.cxx
index 20629ad..29a4710 100644
--- a/stoc/source/corereflection/crefl.cxx
+++ b/stoc/source/corereflection/crefl.cxx
@@ -62,33 +62,14 @@ static rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
static Sequence< OUString > core_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) );
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(SERVICENAME) );
+ return seqNames;
}
static OUString core_getImplementationName()
{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( ! pImplName )
- {
- static OUString implName( RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) );
- pImplName = &implName;
- }
- }
- return *pImplName;
+ return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME));
}
//__________________________________________________________________________________________________
IdlReflectionServiceImpl::IdlReflectionServiceImpl(
diff --git a/stoc/source/defaultregistry/defaultregistry.cxx b/stoc/source/defaultregistry/defaultregistry.cxx
index 6bb9028..5ab6684 100644
--- a/stoc/source/defaultregistry/defaultregistry.cxx
+++ b/stoc/source/defaultregistry/defaultregistry.cxx
@@ -66,33 +66,14 @@ namespace stoc_bootstrap
{
Sequence< OUString > defreg_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
+ return seqNames;
}
OUString defreg_getImplementationName()
{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( ! pImplName )
- {
- static OUString implName( RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) );
- pImplName = &implName;
- }
- }
- return *pImplName;
+ return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME));
}
}
diff --git a/stoc/source/implementationregistration/implreg.cxx b/stoc/source/implementationregistration/implreg.cxx
index 0089992..485b9c2 100644
--- a/stoc/source/implementationregistration/implreg.cxx
+++ b/stoc/source/implementationregistration/implreg.cxx
@@ -141,18 +141,9 @@ namespace stoc_bootstrap
{
Sequence< OUString > impreg_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = stoc_impreg::spool().sServiceName;
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = stoc_impreg::spool().sServiceName;
+ return seqNames;
}
OUString impreg_getImplementationName()
diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx
index a1a853d..ca9731b 100644
--- a/stoc/source/invocation/invocation.cxx
+++ b/stoc/source/invocation/invocation.cxx
@@ -82,33 +82,14 @@ static rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
static Sequence< OUString > inv_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
+ return seqNames;
}
static OUString inv_getImplementationName()
{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( ! pImplName )
- {
- static OUString implName( RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) );
- pImplName = &implName;
- }
- }
- return *pImplName;
+ return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME));
}
// TODO: Zentral implementieren
diff --git a/stoc/source/invocation_adapterfactory/iafactory.cxx b/stoc/source/invocation_adapterfactory/iafactory.cxx
index e891b63..c315709 100644
--- a/stoc/source/invocation_adapterfactory/iafactory.cxx
+++ b/stoc/source/invocation_adapterfactory/iafactory.cxx
@@ -76,34 +76,15 @@ static rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
static Sequence< OUString > invadp_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] =
- OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] =
+ OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
+ return seqNames;
}
static OUString invadp_getImplementationName()
{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( ! pImplName )
- {
- static OUString implName( RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) );
- pImplName = &implName;
- }
- }
- return *pImplName;
+ return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME));
}
struct hash_ptr
diff --git a/stoc/source/javaloader/javaloader.cxx b/stoc/source/javaloader/javaloader.cxx
index 2c178e2..22452ac 100644
--- a/stoc/source/javaloader/javaloader.cxx
+++ b/stoc/source/javaloader/javaloader.cxx
@@ -86,37 +86,18 @@ static Mutex & getInitMutex();
static Sequence< OUString > loader_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(2);
- seqNames.getArray()[0] = OUString(
- RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.loader.Java") );
- seqNames.getArray()[1] = OUString(
- RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.loader.Java2") );
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(2);
+ seqNames.getArray()[0] = OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.loader.Java") );
+ seqNames.getArray()[1] = OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.loader.Java2") );
+ return seqNames;
}
static OUString loader_getImplementationName()
{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( ! pImplName )
- {
- static OUString implName(
- RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.stoc.JavaComponentLoader" ) );
- pImplName = &implName;
- }
- }
- return *pImplName;
+ return OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.stoc.JavaComponentLoader" ) );
}
class JavaComponentLoader : public WeakImplHelper2<XImplementationLoader, XServiceInfo>
diff --git a/stoc/source/loader/dllcomponentloader.cxx b/stoc/source/loader/dllcomponentloader.cxx
index 215b0a9..78aca34 100644
--- a/stoc/source/loader/dllcomponentloader.cxx
+++ b/stoc/source/loader/dllcomponentloader.cxx
@@ -73,33 +73,14 @@ namespace stoc_bootstrap
{
Sequence< OUString > loader_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
+ return seqNames;
}
OUString loader_getImplementationName()
{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( ! pImplName )
- {
- static OUString implName( RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) );
- pImplName = &implName;
- }
- }
- return *pImplName;
+ return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME));
}
}
diff --git a/stoc/source/namingservice/namingservice.cxx b/stoc/source/namingservice/namingservice.cxx
index 5165d92..39e1528 100644
--- a/stoc/source/namingservice/namingservice.cxx
+++ b/stoc/source/namingservice/namingservice.cxx
@@ -63,33 +63,14 @@ static rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
static Sequence< OUString > ns_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
+ return seqNames;
}
static OUString ns_getImplementationName()
{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( ! pImplName )
- {
- static OUString implName( RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) );
- pImplName = &implName;
- }
- }
- return *pImplName;
+ return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME));
}
struct equalOWString_Impl
diff --git a/stoc/source/registry_tdprovider/tdprovider.cxx b/stoc/source/registry_tdprovider/tdprovider.cxx
index 0f79081..6c0ef2c 100644
--- a/stoc/source/registry_tdprovider/tdprovider.cxx
+++ b/stoc/source/registry_tdprovider/tdprovider.cxx
@@ -68,33 +68,14 @@ namespace stoc_bootstrap
{
uno::Sequence< OUString > rdbtdp_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
+ return seqNames;
}
OUString rdbtdp_getImplementationName()
{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( ! pImplName )
- {
- static OUString implName( RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) );
- pImplName = &implName;
- }
- }
- return *pImplName;
+ return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME));
}
}
diff --git a/stoc/source/security/access_controller.cxx b/stoc/source/security/access_controller.cxx
index 405546c..b42ab0e 100644
--- a/stoc/source/security/access_controller.cxx
+++ b/stoc/source/security/access_controller.cxx
@@ -1043,9 +1043,9 @@ Reference< XInterface > SAL_CALL ac_create(
//--------------------------------------------------------------------------------------------------
Sequence< OUString > ac_getSupportedServiceNames() SAL_THROW( () )
{
- static OUString s_serviceName = OUSTR(SERVICE_NAME);
- static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceName, 1 );
- return s_serviceNames;
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICE_NAME));
+ return aSNS;
}
//--------------------------------------------------------------------------------------------------
OUString ac_getImplementationName() SAL_THROW( () )
diff --git a/stoc/source/security/file_policy.cxx b/stoc/source/security/file_policy.cxx
index 1288881..109fecc 100644
--- a/stoc/source/security/file_policy.cxx
+++ b/stoc/source/security/file_policy.cxx
@@ -589,9 +589,9 @@ Reference< XInterface > SAL_CALL filepolicy_create(
//--------------------------------------------------------------------------------------------------
Sequence< OUString > filepolicy_getSupportedServiceNames() SAL_THROW( () )
{
- static OUString s_serviceName = OUSTR(SERVICE_NAME);
- static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceName, 1 );
- return s_serviceNames;
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICE_NAME));
+ return aSNS;
}
//--------------------------------------------------------------------------------------------------
OUString filepolicy_getImplementationName() SAL_THROW( () )
diff --git a/stoc/source/tdmanager/tdmgr.cxx b/stoc/source/tdmanager/tdmgr.cxx
index 2351751..6366818 100644
--- a/stoc/source/tdmanager/tdmgr.cxx
+++ b/stoc/source/tdmanager/tdmgr.cxx
@@ -86,33 +86,14 @@ namespace stoc_bootstrap
{
Sequence< OUString > SAL_CALL tdmgr_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
+ return seqNames;
}
OUString SAL_CALL tdmgr_getImplementationName()
{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( ! pImplName )
- {
- static OUString implName( RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) );
- pImplName = &implName;
- }
- }
- return *pImplName;
+ return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME));
}
}
diff --git a/stoc/source/typeconv/convert.cxx b/stoc/source/typeconv/convert.cxx
index b572086..9d07c1f 100644
--- a/stoc/source/typeconv/convert.cxx
+++ b/stoc/source/typeconv/convert.cxx
@@ -68,33 +68,14 @@ namespace stoc_services
{
Sequence< OUString > tcv_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
+ return seqNames;
}
OUString tcv_getImplementationName()
{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( ! pImplName )
- {
- static OUString implName( RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) );
- pImplName = &implName;
- }
- }
- return *pImplName;
+ return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME));
}
}
commit 4060d5a59af082993e47aae625db024e8f5ac872
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 1 12:20:38 2011 +0100
remove const to allow alternative template
diff --git a/sal/qa/rtl/doublelock/rtl_doublelocking.cxx b/sal/qa/rtl/doublelock/rtl_doublelocking.cxx
index 9ccaf5a..2690091 100644
--- a/sal/qa/rtl/doublelock/rtl_doublelocking.cxx
+++ b/sal/qa/rtl/doublelock/rtl_doublelocking.cxx
@@ -54,9 +54,9 @@
#define CONST_TEST_STRING "gregorian"
namespace {
-struct Gregorian : public ::rtl::StaticWithInit<const ::rtl::OUString, Gregorian> {
- const ::rtl::OUString operator () () {
- return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( CONST_TEST_STRING ));
+struct Gregorian : public rtl::StaticWithInit<rtl::OUString, Gregorian> {
+ const rtl::OUString operator () () {
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( CONST_TEST_STRING ));
}
};
}
commit 6be8f7a1cee45bd99da81f523c9873bc08c4b7ae
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jun 1 12:17:03 2011 +0100
drop const for alternative template
diff --git a/sal/osl/all/debugbase.cxx b/sal/osl/all/debugbase.cxx
index 1269324..15d6a60 100644
--- a/sal/osl/all/debugbase.cxx
+++ b/sal/osl/all/debugbase.cxx
@@ -51,8 +51,8 @@ namespace {
typedef std::vector<rtl::OString, rtl::Allocator<rtl::OString> > OStringVec;
struct StaticDebugBaseAddressFilter
- : rtl::StaticWithInit<OStringVec const, StaticDebugBaseAddressFilter> {
- OStringVec const operator()() const {
+ : rtl::StaticWithInit<OStringVec, StaticDebugBaseAddressFilter> {
+ OStringVec operator()() const {
OStringVec vec;
rtl_uString * pStr = 0;
rtl::OUString const name(
commit 0c63f147223cd74f30ec8f830575b3c3e64460ca
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue May 31 13:03:18 2011 +0100
this is overly static + double check lock for little gain
diff --git a/io/source/TextInputStream/TextInputStream.cxx b/io/source/TextInputStream/TextInputStream.cxx
index 1f3c358..229731d 100644
--- a/io/source/TextInputStream/TextInputStream.cxx
+++ b/io/source/TextInputStream/TextInputStream.cxx
@@ -458,18 +458,9 @@ OUString TextInputStream_getImplementationName()
Sequence< OUString > TextInputStream_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
+ return seqNames;
}
OUString OTextInputStream::getImplementationName() throw()
diff --git a/io/source/TextOutputStream/TextOutputStream.cxx b/io/source/TextOutputStream/TextOutputStream.cxx
index 56ede0b..79a06d7 100644
--- a/io/source/TextOutputStream/TextOutputStream.cxx
+++ b/io/source/TextOutputStream/TextOutputStream.cxx
@@ -255,18 +255,9 @@ OUString TextOutputStream_getImplementationName() SAL_THROW( () )
Sequence< OUString > TextOutputStream_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
+ return seqNames;
}
OUString OTextOutputStream::getImplementationName() throw()
diff --git a/io/source/acceptor/acceptor.cxx b/io/source/acceptor/acceptor.cxx
index e4ef83d..65770df 100644
--- a/io/source/acceptor/acceptor.cxx
+++ b/io/source/acceptor/acceptor.cxx
@@ -301,18 +301,9 @@ namespace io_acceptor
Sequence< OUString > acceptor_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICE_NAME));
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICE_NAME));
+ return seqNames;
}
OUString OAcceptor::getImplementationName() throw()
diff --git a/io/source/connector/connector.cxx b/io/source/connector/connector.cxx
index 5fdb26a..67eea93 100644
--- a/io/source/connector/connector.cxx
+++ b/io/source/connector/connector.cxx
@@ -204,18 +204,9 @@ namespace stoc_connector
Sequence< OUString > connector_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICE_NAME));
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICE_NAME));
+ return seqNames;
}
OUString connector_getImplementationName()
commit ac0e691bb0cead4f4c9d5b402803391729170b1a
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue May 31 11:58:17 2011 +0100
Interfaces are recursive into themselves
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index 3a22352..c4f6ed2 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -1622,6 +1622,36 @@ void InterfaceType::dumpComprehensiveGetCppuType(FileStream& o)
o << indent() << "::com::sun::star::uno::Type the_staticType( "
<< getTypeClass(m_typeName) << ", sTypeName );\n";
+ o << indent() << "return the_staticType;\n";
+
+ dec();
+
+ o << indent() << "}\n";
+ dec();
+ o << indent() << "};\n\n";
+
+ if (!isPolymorphic())
+ codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false);
+ else
+ o << " }";
+ o << " }\n\n";
+
+ dumpGetCppuTypePreamble(o);
+ o << indent() << "const ::com::sun::star::uno::Type &rRet = detail::" << sStaticTypeClass << "::get();\n";
+
+ o << indent() << "// End inline typedescription generation\n";
+
+ o << indent() << "static bool bInitStarted = false;\n";
+ o << indent() << "if (!bInitStarted)\n";
+ o << indent() << "{\n";
+ inc();
+ o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n";
+ o << indent() << "if (!bInitStarted)\n";
+ o << indent() << "{\n";
+ inc();
+ o << indent() << "OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();\n";
+ o << indent() << "bInitStarted = true;\n";
+
StringSet aTypes;
// type for RuntimeException is always needed
OString sRunTimeExceptionType("com/sun/star/uno/RuntimeException");
@@ -1638,24 +1668,18 @@ void InterfaceType::dumpComprehensiveGetCppuType(FileStream& o)
dumpCppuMethods(o, index);
}
- o << indent() << "// End inline typedescription generation\n";
-
- o << indent() << "return the_staticType;\n";
-
dec();
-
- o << indent() << "}\n";
+ o << indent() << "}\n";
dec();
- o << indent() << "};\n\n";
-
- if (!isPolymorphic())
- codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false);
- else
- o << " }";
- o << " }\n\n";
+ o << indent() << "}\n";
+ o << indent() << "else\n";
+ o << indent() << "{\n";
+ inc();
+ o << indent() << "OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();\n";
+ dec();
+ o << indent() << "}\n";
- dumpGetCppuTypePreamble(o);
- o << indent() << "return detail::" << sStaticTypeClass << "::get();\n";
+ o << indent() << "return rRet;\n";
dumpGetCppuTypePostamble(o);
}
@@ -1864,6 +1888,10 @@ void InterfaceType::dumpCppuAttributes(FileStream& o, sal_uInt32& index)
inc();
o << indent() << "::rtl::OUString sAttributeType" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
<< fieldType.replace('/', '.') << "\") );\n";
+
+ o << indent() << "::rtl::OUString sAttributeName" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << scope.replace('/', '.') << "::" << fieldName << "\") );\n";
+
sal_Int32 getExceptions = dumpAttributeExceptionTypeNames(
o, "get", name, RT_MODE_ATTRIBUTE_GET);
sal_Int32 setExceptions = dumpAttributeExceptionTypeNames(
@@ -1906,6 +1934,7 @@ void InterfaceType::dumpCppuMethods(FileStream& o, sal_uInt32& index)
if (m_hasMethods)
{
o << "\n" << indent() << "typelib_InterfaceMethodTypeDescription * pMethod = 0;\n";
+ OString scope = m_typeName.replace('/', '.');
for (sal_uInt16 i=0; i < methodCount; i++)
{
@@ -1975,6 +2004,9 @@ void InterfaceType::dumpCppuMethods(FileStream& o, sal_uInt32& index)
o << indent() << "::rtl::OUString sReturnType" << i << "( RTL_CONSTASCII_USTRINGPARAM(\""
<< returnType.replace('/', '.') << "\") );\n";
+ o << indent() << "::rtl::OUString sMethodName" << i <<
+ "( RTL_CONSTASCII_USTRINGPARAM(\""
+ << scope.replace('/', '.') << "::" << methodName << "\") );\n";
o << indent() << "typelib_typedescription_newInterfaceMethod( &pMethod,\n";
inc();
o << indent() << absoluteIndex++ << ", ";
@@ -1982,6 +2014,7 @@ void InterfaceType::dumpCppuMethods(FileStream& o, sal_uInt32& index)
o << "sal_True,\n";
else
o << "sal_False,\n";
+
o << indent() << "sMethodName" << i << ".pData,\n";
o << indent() << "(typelib_TypeClass)" << getTypeClass(returnType)
<< ", sReturnType" << i << ".pData,\n";
commit 27414c809df3bf099d44d9814d027399c9a2e011
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon May 30 23:29:36 2011 +0100
this is overly static + double check lock for little gain
diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx
index 848ca9e..5c20e95 100644
--- a/stoc/source/servicemanager/servicemanager.cxx
+++ b/stoc/source/servicemanager/servicemanager.cxx
@@ -95,102 +95,44 @@ namespace stoc_bootstrap
{
Sequence< OUString > smgr_wrapper_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(1);
- seqNames.getArray()[0] = OUString(
- RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.MultiServiceFactory") );
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.MultiServiceFactory") );
+ return seqNames;
}
OUString smgr_wrapper_getImplementationName()
{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( ! pImplName )
- {
- static OUString implName(
- RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.stoc.OServiceManagerWrapper" ) );
- pImplName = &implName;
- }
- }
- return *pImplName;
+ return OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.OServiceManagerWrapper"));
}
Sequence< OUString > smgr_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(2);
- seqNames.getArray()[0] = OUString(
- RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.MultiServiceFactory") );
- seqNames.getArray()[1] = OUString(
- RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.ServiceManager") );
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(2);
+ seqNames.getArray()[0] = OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.MultiServiceFactory") );
+ seqNames.getArray()[1] = OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.ServiceManager") );
+ return seqNames;
}
OUString smgr_getImplementationName()
{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( ! pImplName )
- {
- static OUString implName(
- RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.stoc.OServiceManager" ) );
- pImplName = &implName;
- }
- }
- return *pImplName;
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.OServiceManager"));
}
Sequence< OUString > regsmgr_getSupportedServiceNames()
{
- static Sequence < OUString > *pNames = 0;
- if( ! pNames )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !pNames )
- {
- static Sequence< OUString > seqNames(2);
- seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.MultiServiceFactory"));
- seqNames.getArray()[1] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.RegistryServiceManager"));
- pNames = &seqNames;
- }
- }
- return *pNames;
+ Sequence< OUString > seqNames(2);
+ seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.MultiServiceFactory"));
+ seqNames.getArray()[1] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.RegistryServiceManager"));
+ return seqNames;
}
OUString regsmgr_getImplementationName()
{
- static OUString *pImplName = 0;
- if( ! pImplName )
- {
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( ! pImplName )
- {
- static OUString implName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.stoc.ORegistryServiceManager" ) );
- pImplName = &implName;
- }
- }
- return *pImplName;
+ return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.stoc.ORegistryServiceManager" ) );
}
}
commit ca6273c75a79a34f2f7935190a94b3c4c44e85a9
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon May 30 17:11:31 2011 +0100
add polymorphic support
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index 404d063..3a22352 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -594,9 +594,11 @@ void CppuType::dumpNormalGetCppuType(FileStream& o)
void CppuType::dumpComprehensiveGetCppuType(FileStream& o)
{
- if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) {
- o << " namespace detail {\n\n";
- }
+ if (!isPolymorphic())
+ codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false);
+ else
+ o << "namespace cppu { ";
+ o << " namespace detail {\n\n";
OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1);
OString sStaticTypeClass = "the" + sType + "Type";
@@ -701,9 +703,12 @@ void CppuType::dumpComprehensiveGetCppuType(FileStream& o)
dec();
o << indent() << "};\n\n";
- if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) {
- o << " }\n\n";
- }
+ if (!isPolymorphic())
+ codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false);
+ else
+ o << " }";
+
+ o << " }\n\n";
dumpGetCppuTypePreamble(o);
o << indent() << "return detail::" << sStaticTypeClass << "::get();\n";
@@ -1529,9 +1534,11 @@ void InterfaceType::dumpNormalGetCppuType(FileStream& o)
void InterfaceType::dumpComprehensiveGetCppuType(FileStream& o)
{
- if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) {
- o << " namespace detail {\n\n";
- }
+ if (!isPolymorphic())
+ codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false);
+ else
+ o << "namespace cppu { ";
+ o << " namespace detail {\n\n";
OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1);
OString sStaticTypeClass = "the" + sType + "Type";
@@ -1641,9 +1648,11 @@ void InterfaceType::dumpComprehensiveGetCppuType(FileStream& o)
dec();
o << indent() << "};\n\n";
- if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) {
- o << " }\n\n";
- }
+ if (!isPolymorphic())
+ codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false);
+ else
+ o << " }";
+ o << " }\n\n";
dumpGetCppuTypePreamble(o);
o << indent() << "return detail::" << sStaticTypeClass << "::get();\n";
@@ -2803,13 +2812,23 @@ void StructureType::dumpNormalGetCppuType(FileStream & out) {
void StructureType::dumpComprehensiveGetCppuType(FileStream & out)
{
- if (codemaker::cppumaker::dumpNamespaceOpen(out, m_typeName, false)) {
- out << " namespace detail {\n\n";
- }
+ if (!isPolymorphic())
+ codemaker::cppumaker::dumpNamespaceOpen(out, m_typeName, false);
+ else
+ out << "namespace cppu { ";
+ out << " namespace detail {\n\n";
OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1);
OString sStaticTypeClass = "the" + sType + "Type";
- out << indent() << "struct " << sStaticTypeClass << " : public rtl::StaticWithInit< ::com::sun::star::uno::Type, " << sStaticTypeClass << " >\n";
+ out << indent();
+ if (isPolymorphic())
+ dumpTemplateHead(out);
+ out << "struct " << sStaticTypeClass << " : public rtl::StaticWithInit< ::com::sun::star::uno::Type, ";
+ out << sStaticTypeClass;
+ if (isPolymorphic())
+ dumpTemplateParameters(out);
+ out << " >\n";
+
out << indent() << "{\n";
inc();
out << indent() << "::com::sun::star::uno::Type operator()() const\n";
@@ -2947,12 +2966,17 @@ void StructureType::dumpComprehensiveGetCppuType(FileStream & out)
dec();
out << indent() << "};\n";
- if (codemaker::cppumaker::dumpNamespaceClose(out, m_typeName, false)) {
- out << " }\n\n";
- }
+ if (!isPolymorphic())
+ codemaker::cppumaker::dumpNamespaceClose(out, m_typeName, false);
+ else
+ out << " }";
+ out << " }\n\n";
dumpGetCppuTypePreamble(out);
- out << indent() << "return detail::" << sStaticTypeClass << "::get();\n";
+ out << indent() << "return detail::" << sStaticTypeClass;
+ if (isPolymorphic())
+ dumpTemplateParameters(out);
+ out << "::get();\n";
dumpGetCppuTypePostamble(out);
}
@@ -3046,7 +3070,7 @@ void StructureType::addComprehensiveGetCppuTypeIncludes(
{
includes.addType();
includes.addCppuUnotypeHxx();
- includes.addOslDoublecheckedlockingH();
+ includes.addRtlInstanceHxx();
includes.addOslMutexHxx();
includes.addRtlUstringH();
includes.addRtlUstringHxx();
@@ -3613,9 +3637,11 @@ void EnumType::dumpNormalGetCppuType(FileStream& o)
void EnumType::dumpComprehensiveGetCppuType(FileStream& o)
{
- if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) {
- o << " namespace detail {\n\n";
- }
+ if (!isPolymorphic())
+ codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false);
+ else
+ o << "namespace cppu { ";
+ o << " namespace detail {\n\n";
OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1);
OString sStaticTypeClass = "the" + sType + "Type";
@@ -3685,9 +3711,11 @@ void EnumType::dumpComprehensiveGetCppuType(FileStream& o)
dec();
o << indent() << "};\n\n";
- if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) {
- o << " }\n\n";
- }
+ if (!isPolymorphic())
+ codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false);
+ else
+ o << " }";
+ o << " }\n\n";
dumpGetCppuTypePreamble(o);
o << indent() << "return detail::" << sStaticTypeClass << "::get();\n";
commit 674a910206c82711c7f3a9eda1e7f99ff1beeacd
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon May 30 15:29:32 2011 +0100
add a StaticWithArg to make its use easier
diff --git a/sal/inc/rtl/instance.hxx b/sal/inc/rtl/instance.hxx
index 61f7ba0..f5f6e63 100644
--- a/sal/inc/rtl/instance.hxx
+++ b/sal/inc/rtl/instance.hxx
@@ -323,6 +323,31 @@ public:
return p;
}
+ static inline Inst * create(InstCtor aInstCtor, GuardCtor aGuardCtor,
+ const Data &rData)
+ {
+#if defined _MSC_VER
+ static Inst * m_pInstance = 0;
+#endif // _MSC_VER
+ Inst * p = m_pInstance;
+ if (!p)
+ {
+ Guard aGuard(aGuardCtor());
+ p = m_pInstance;
+ if (!p)
+ {
+ p = aInstCtor(rData);
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ m_pInstance = p;
+ }
+ }
+ else
+ {
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+ }
+ return p;
+ }
+
private:
#if !defined _MSC_VER
static Inst * m_pInstance;
@@ -402,6 +427,99 @@ private:
};
#endif
+/** Helper base class for a late-initialized (default-constructed)
+ static variable, implementing the double-checked locking pattern correctly.
+
+ @derive
+ Derive from this class (common practice), e.g.
+ <pre>
+ struct MyStatic : public rtl::Static<MyType, MyStatic> {};
+ ...
+ MyType & rStatic = MyStatic::get();
+ ...
+ </pre>
+
+ @tplparam T
+ variable's type
+ @tplparam Unique
+ Implementation trick to make the inner static holder unique,
+ using the outer class
+ (the one that derives from this base class)
+*/
+#if (__GNUC__ >= 4)
+template<typename T, typename Data, typename Unique>
+class StaticWithArg {
+public:
+ /** Gets the static. Mutual exclusion is implied by a functional
+ -fthreadsafe-statics
+
+ @return
+ static variable
+ */
+ static T & get(const Data& rData) {
+ static T instance(rData);
+ return instance;
+ }
+
+ /** Gets the static. Mutual exclusion is implied by a functional
+ -fthreadsafe-statics
+
+ @return
+ static variable
+ */
+ static T & get(Data& rData) {
+ static T instance(rData);
+ return instance;
+ }
+};
+#else
+template<typename T, typename Data, typename Unique>
+class StaticWithArg {
+public:
+ /** Gets the static. Mutual exclusion is performed using the
+ osl global mutex.
+
+ @return
+ static variable
+ */
+ static T & get(const Data& rData) {
+ return *rtl_Instance<
+ T, StaticInstanceWithArg,
+ ::osl::MutexGuard, ::osl::GetGlobalMutex,
+ Data >::create( StaticInstanceWithArg(),
+ ::osl::GetGlobalMutex(),
+ rData );
+ }
+
+ /** Gets the static. Mutual exclusion is performed using the
+ osl global mutex.
+
+ @return
+ static variable
+ */
+ static T & get(Data& rData) {
+ return *rtl_Instance<
+ T, StaticInstanceWithArg,
+ ::osl::MutexGuard, ::osl::GetGlobalMutex,
+ Data >::create( StaticInstanceWithArg(),
+ ::osl::GetGlobalMutex(),
+ rData );
+ }
+private:
+ struct StaticInstanceWithArg {
+ T * operator () (const Data& rData) {
+ static T instance(rData);
+ return &instance;
+ }
+
+ T * operator () (Data& rData) {
+ static T instance(rData);
+ return &instance;
+ }
+ };
+};
+#endif
+
/** Helper class for a late-initialized static aggregate, e.g. an array,
implementing the double-checked locking pattern correctly.
commit d2695e4761b961dc289dcdb3a0e7592bd580a29c
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon May 30 15:17:54 2011 +0100
use rtl_Instance for the auto-generated local statics
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index dac22a4..404d063 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -363,6 +363,7 @@ void CppuType::addDefaultHxxIncludes(codemaker::cppumaker::Includes & includes)
const
{
//TODO: Only include what is really needed
+ includes.addRtlInstanceHxx();
includes.addOslMutexHxx();
includes.addType();
if (m_typeMgr.getTypeClass(m_typeName) == RT_TYPE_INTERFACE) {
@@ -593,16 +594,19 @@ void CppuType::dumpNormalGetCppuType(FileStream& o)
void CppuType::dumpComprehensiveGetCppuType(FileStream& o)
{
- dumpGetCppuTypePreamble(o);
-
- o << indent() << "static ::com::sun::star::uno::Type * the_pType = 0;\n";
+ if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) {
+ o << " namespace detail {\n\n";
+ }
- o << indent() << "if (the_pType == 0)\n" << indent() << "{\n";
+ OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1);
+ OString sStaticTypeClass = "the" + sType + "Type";
+ o << indent() << "struct " << sStaticTypeClass << " : public rtl::StaticWithInit< ::com::sun::star::uno::Type, " << sStaticTypeClass << " >\n";
+ o << indent() << "{\n";
inc();
- o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n";
-
- o << indent() << "if (the_pType == 0)\n" << indent() << "{\n";
+ o << indent() << "::com::sun::star::uno::Type operator()() const\n";
+ o << indent() << "{\n";
inc();
+
o << indent() << "::rtl::OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM(\""
<< m_typeName.replace('/', '.') << "\") );\n\n";
@@ -679,8 +683,8 @@ void CppuType::dumpComprehensiveGetCppuType(FileStream& o)
} else {
o << indent() << count << ",\n" << indent() << "0 );\n\n";
}
-
dec();
+
o << indent()
<< ("typelib_typedescription_register( (typelib_TypeDescription**)&pTD"
" );\n\n");
@@ -688,15 +692,21 @@ void CppuType::dumpComprehensiveGetCppuType(FileStream& o)
o << indent() << "typelib_typedescription_release( pTD );\n"
<< indent() << "// End inline typedescription generation\n\n";
- o << indent() << "static ::com::sun::star::uno::Type the_staticType( "
+ o << indent() << "::com::sun::star::uno::Type the_staticType( "
<< getTypeClass(m_typeName) << ", sTypeName );\n";
- o << indent() << "the_pType = &the_staticType;\n";
+ o << indent() << "return the_staticType;\n";
dec();
o << indent() << "}\n";
dec();
- o << indent() << "}\n\n";
- o << indent() << "return *the_pType;\n";
+ o << indent() << "};\n\n";
+
+ if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) {
+ o << " }\n\n";
+ }
+
+ dumpGetCppuTypePreamble(o);
+ o << indent() << "return detail::" << sStaticTypeClass << "::get();\n";
dumpGetCppuTypePostamble(o);
}
@@ -1519,15 +1529,18 @@ void InterfaceType::dumpNormalGetCppuType(FileStream& o)
void InterfaceType::dumpComprehensiveGetCppuType(FileStream& o)
{
- dumpGetCppuTypePreamble(o);
-
- o << indent() << "static ::com::sun::star::uno::Type * the_pType = 0;\n";
+ if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) {
+ o << " namespace detail {\n\n";
+ }
- o << indent() << "if (the_pType == 0)\n" << indent() << "{\n";
+ OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1);
+ OString sStaticTypeClass = "the" + sType + "Type";
+ o << indent() << "struct " << sStaticTypeClass << " : public rtl::StaticWithInit< ::com::sun::star::uno::Type, " << sStaticTypeClass << " >\n";
+ o << indent() << "{\n";
inc();
- o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n";
+ o << indent() << "::com::sun::star::uno::Type operator()() const\n";
+ o << indent() << "{\n";
- o << indent() << "if (the_pType == 0)\n" << indent() << "{\n";
inc();
o << indent() << "::rtl::OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM(\""
<< m_typeName.replace('/', '.') << "\") );\n\n";
@@ -1599,9 +1612,8 @@ void InterfaceType::dumpComprehensiveGetCppuType(FileStream& o)
<< ("typelib_typedescription_release( (typelib_TypeDescription*)pTD"
" );\n\n");
- o << indent() << "static ::com::sun::star::uno::Type the_staticType( "
+ o << indent() << "::com::sun::star::uno::Type the_staticType( "
<< getTypeClass(m_typeName) << ", sTypeName );\n";
- o << indent() << "the_pType = &the_staticType;\n";
StringSet aTypes;
// type for RuntimeException is always needed
@@ -1621,12 +1633,20 @@ void InterfaceType::dumpComprehensiveGetCppuType(FileStream& o)
o << indent() << "// End inline typedescription generation\n";
+ o << indent() << "return the_staticType;\n";
+
dec();
+
o << indent() << "}\n";
dec();
- o << indent() << "}\n\n"
- << indent() << "return *the_pType;\n";
+ o << indent() << "};\n\n";
+
+ if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) {
+ o << " }\n\n";
+ }
+ dumpGetCppuTypePreamble(o);
+ o << indent() << "return detail::" << sStaticTypeClass << "::get();\n";
dumpGetCppuTypePostamble(o);
}
@@ -2781,14 +2801,20 @@ void StructureType::dumpNormalGetCppuType(FileStream & out) {
dumpGetCppuTypePostamble(out);
}
-void StructureType::dumpComprehensiveGetCppuType(FileStream & out) {
- dumpGetCppuTypePreamble(out);
- out << indent() << "static ::com::sun::star::uno::Type * the_pType = 0;\n"
- << indent() << "if (the_pType == 0) {\n";
+void StructureType::dumpComprehensiveGetCppuType(FileStream & out)
+{
+ if (codemaker::cppumaker::dumpNamespaceOpen(out, m_typeName, false)) {
+ out << " namespace detail {\n\n";
+ }
+
+ OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1);
+ OString sStaticTypeClass = "the" + sType + "Type";
+ out << indent() << "struct " << sStaticTypeClass << " : public rtl::StaticWithInit< ::com::sun::star::uno::Type, " << sStaticTypeClass << " >\n";
+ out << indent() << "{\n";
inc();
- out << indent()
- << "::osl::MutexGuard the_guard(::osl::Mutex::getGlobalMutex());\n"
- << indent() << "if (the_pType == 0) {\n";
+ out << indent() << "::com::sun::star::uno::Type operator()() const\n";
+ out << indent() << "{\n";
+
inc();
if (isPolymorphic()) {
out << indent() << "::rtl::OUStringBuffer the_buffer;\n" << indent()
@@ -2912,18 +2938,21 @@ void StructureType::dumpComprehensiveGetCppuType(FileStream & out) {
out << ", " << fields << ", the_members);\n";
out << indent() << "::typelib_typedescription_register(&the_newType);\n";
out << indent() << "::typelib_typedescription_release(the_newType);\n";
- out << indent() << "static ::com::sun::star::uno::Type the_staticType("
+
+ out << indent() << "::com::sun::star::uno::Type the_staticType("
<< getTypeClass(m_typeName) << ", the_name);\n";
- out << indent() << "OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();\n";
- out << indent() << "the_pType = &the_staticType;\n";
+ out << indent() << "return the_staticType;\n";
dec();
out << indent() << "}\n";
dec();
- out << indent() << "} else {\n";
- inc();
- out << indent() << "OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();\n";
- dec();
- out << indent() << "}\n" << indent() << "return *the_pType;\n";
+ out << indent() << "};\n";
+
+ if (codemaker::cppumaker::dumpNamespaceClose(out, m_typeName, false)) {
+ out << " }\n\n";
+ }
+
+ dumpGetCppuTypePreamble(out);
+ out << indent() << "return detail::" << sStaticTypeClass << "::get();\n";
dumpGetCppuTypePostamble(out);
}
@@ -3584,15 +3613,18 @@ void EnumType::dumpNormalGetCppuType(FileStream& o)
void EnumType::dumpComprehensiveGetCppuType(FileStream& o)
{
- dumpGetCppuTypePreamble(o);
-
- o << indent() << "static ::com::sun::star::uno::Type * the_pType = 0;\n";
+ if (codemaker::cppumaker::dumpNamespaceOpen(o, m_typeName, false)) {
+ o << " namespace detail {\n\n";
+ }
- o << indent() << "if (the_pType == 0)\n" << indent() << "{\n";
+ OString sType = m_typeName.copy(m_typeName.lastIndexOf('/') + 1);
+ OString sStaticTypeClass = "the" + sType + "Type";
+ o << indent() << "struct " << sStaticTypeClass << " : public rtl::StaticWithInit< ::com::sun::star::uno::Type, " << sStaticTypeClass << " >\n";
+ o << indent() << "{\n";
inc();
- o << indent() << "::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );\n";
+ o << indent() << "::com::sun::star::uno::Type operator()() const\n";
+ o << indent() << "{\n";
- o << indent() << "if (the_pType == 0)\n" << indent() << "{\n";
inc();
o << indent() << "::rtl::OUString sTypeName( RTL_CONSTASCII_USTRINGPARAM(\""
<< m_typeName.replace('/', '.') << "\") );\n\n";
@@ -3644,16 +3676,21 @@ void EnumType::dumpComprehensiveGetCppuType(FileStream& o)
o << indent() << "typelib_typedescription_release( pTD );\n"
<< indent() << "// End inline typedescription generation\n\n";
- o << indent() << "static ::com::sun::star::uno::Type the_staticType( "
+ o << indent() << "::com::sun::star::uno::Type the_staticType( "
<< getTypeClass(m_typeName) << ", sTypeName );\n";
- o << indent() << "the_pType = &the_staticType;\n";
+ o << indent() << "return the_staticType;\n";
dec();
o << indent() << "}\n";
dec();
- o << indent() << "}\n\n"
- << indent() << "return *the_pType;\n";
+ o << indent() << "};\n\n";
+ if (codemaker::cppumaker::dumpNamespaceClose(o, m_typeName, false)) {
+ o << " }\n\n";
+ }
+
+ dumpGetCppuTypePreamble(o);
+ o << indent() << "return detail::" << sStaticTypeClass << "::get();\n";
dumpGetCppuTypePostamble(o);
}
diff --git a/codemaker/source/cppumaker/includes.cxx b/codemaker/source/cppumaker/includes.cxx
index 10e58a2..52baf22 100644
--- a/codemaker/source/cppumaker/includes.cxx
+++ b/codemaker/source/cppumaker/includes.cxx
@@ -60,6 +60,7 @@ Includes::Includes(
m_includeRtlTextencH(false), m_includeRtlUstrbufHxx(false),
m_includeRtlUstringH(false),
m_includeRtlUstringHxx(dependencies.hasStringDependency()),
+ m_includeRtlInstanceHxx(false),
m_includeSalTypesH(
dependencies.hasBooleanDependency() || dependencies.hasByteDependency()
|| dependencies.hasShortDependency()
@@ -250,6 +251,10 @@ void Includes::dump(FileStream & out, rtl::OString const * companionHdl) {
dumpEmptyLineBeforeFirst(out, &first);
out << ("#include \"rtl/ustring.hxx\"\n");
}
+ if (m_includeRtlInstanceHxx) {
+ dumpEmptyLineBeforeFirst(out, &first);
+ out << "#include \"rtl/instance.hxx\"\n";
+ }
if (m_includeSalTypesH) {
dumpEmptyLineBeforeFirst(out, &first);
out << "#include \"sal/types.h\"\n";
diff --git a/codemaker/source/cppumaker/includes.hxx b/codemaker/source/cppumaker/includes.hxx
index 3d209bf..50caac0 100644
--- a/codemaker/source/cppumaker/includes.hxx
+++ b/codemaker/source/cppumaker/includes.hxx
@@ -61,6 +61,7 @@ public:
void addRtlUstrbufHxx() { m_includeRtlUstrbufHxx = true; }
void addRtlUstringH() { m_includeRtlUstringH = true; }
void addRtlUstringHxx() { m_includeRtlUstringHxx = true; }
+ void addRtlInstanceHxx() { m_includeRtlInstanceHxx = true; }
void addSalTypesH() { m_includeSalTypesH = true; }
void addTypelibTypeclassH() { m_includeTypelibTypeclassH = true; }
void addTypelibTypedescriptionH()
@@ -94,6 +95,7 @@ private:
bool m_includeRtlUstrbufHxx;
bool m_includeRtlUstringH;
bool m_includeRtlUstringHxx;
+ bool m_includeRtlInstanceHxx;
bool m_includeSalTypesH;
bool m_includeTypelibTypeclassH;
bool m_includeTypelibTypedescriptionH;
More information about the Libreoffice-commits
mailing list