summaryrefslogtreecommitdiff
path: root/cppuhelper/source
diff options
context:
space:
mode:
authorDaniel Boelzle <dbo@openoffice.org>2002-12-06 09:12:29 +0000
committerDaniel Boelzle <dbo@openoffice.org>2002-12-06 09:12:29 +0000
commit21721abc1b476ccfc60b0eba871c909dc086a087 (patch)
treed2f78b59977e1bf87499c50aa991a5ab026aa20b /cppuhelper/source
parent12c6c3ada21e557c5151c275b845efe06c1d9eb2 (diff)
#105077# singleton order; minor changes
Diffstat (limited to 'cppuhelper/source')
-rw-r--r--cppuhelper/source/bootstrap.cxx44
-rw-r--r--cppuhelper/source/component_context.cxx65
-rw-r--r--cppuhelper/source/macro_expander.cxx8
-rw-r--r--cppuhelper/source/makefile.mk6
-rw-r--r--cppuhelper/source/servicefactory.cxx60
5 files changed, 68 insertions, 115 deletions
diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx
index a3cae102527c..31fdcab99758 100644
--- a/cppuhelper/source/bootstrap.cxx
+++ b/cppuhelper/source/bootstrap.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: bootstrap.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: dbo $ $Date: 2002-07-08 10:23:12 $
+ * last change: $Author: dbo $ $Date: 2002-12-06 10:12:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -74,9 +74,6 @@
#include <osl/file.hxx>
#include <osl/module.hxx>
#include <osl/security.hxx>
-#include <osl/thread.h>
-
-#include <uno/current_context.h>
#include <cppuhelper/shlib.hxx>
#include <cppuhelper/bootstrap.hxx>
@@ -106,28 +103,6 @@ using namespace ::com::sun::star::uno;
namespace cppu
{
-static OUString str_envType = OUSTR(CPPU_CURRENT_LANGUAGE_BINDING_NAME);
-
-//==================================================================================================
-void * SAL_CALL parentThreadCallback(void) SAL_THROW_EXTERN_C()
-{
- OSL_TRACE( "+> thread creation..." );
- XCurrentContext * xContext = 0;
- ::uno_getCurrentContext( (void **)&xContext, str_envType.pData, 0 );
- return xContext; // return acquired context
-}
-//==================================================================================================
-void SAL_CALL childThreadCallback( void * pParentData ) SAL_THROW_EXTERN_C()
-{
- OSL_TRACE( "++> child thread running." );
- XCurrentContext * xContext = (XCurrentContext *)pParentData;
- if (xContext)
- {
- ::uno_setCurrentContext( xContext, str_envType.pData, 0 );
- xContext->release();
- }
-}
-
//==================================================================================================
void addFactories(
char const * const * ppNames /* lib, implname, ..., 0 */,
@@ -290,10 +265,7 @@ static Reference< registry::XSimpleRegistry > nestRegistries(
try
{
- OSL_TRACE("opening xxxxx");
lastRegistry->open(write_rdb, sal_False, forceWrite_rdb);
- OSL_TRACE("opening yyyy");
-
}
catch (registry::InvalidRegistryException & invalidRegistryException)
{
@@ -377,12 +349,10 @@ static Reference< registry::XSimpleRegistry > nestRegistries(
}
//--------------------------------------------------------------------------------------------------
-static Reference< XComponentContext > SAL_CALL __defaultBootstrap_InitialComponentContext(
+static Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext(
Bootstrap const & bootstrap )
SAL_THROW( (Exception) )
{
-// osl_registerThreadCallbacks( parentThreadCallback, childThreadCallback );
-
OUString bootstrapPath;
OUString iniDir;
@@ -507,7 +477,7 @@ static Reference< XComponentContext > SAL_CALL __defaultBootstrap_InitialCompone
Reference< XComponentContext > xContext( bootstrapInitialContext(
smgr_XMultiComponentFactory, types_xRegistry,
Reference< registry::XSimpleRegistry >(),
- bootstrapPath, bootstrap ) );
+ bootstrapPath, bootstrap, pEntries, nEntries ) );
xContext = createInitialCfgComponentContext(
&context_values[ 0 ], context_values.size(), xContext );
@@ -565,7 +535,7 @@ static Reference< XComponentContext > SAL_CALL __defaultBootstrap_InitialCompone
static void MyDummySymbolWithinLibrary(){}
//--------------------------------------------------------------------------------------------------
-Bootstrap const & __get_unorc() SAL_THROW( () )
+Bootstrap const & get_unorc() SAL_THROW( () )
{
static rtlBootstrapHandle s_bstrap = 0;
if (! s_bstrap)
@@ -596,13 +566,13 @@ Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext
SAL_THROW( (Exception) )
{
Bootstrap bootstrap( iniFile );
- return __defaultBootstrap_InitialComponentContext( bootstrap );
+ return defaultBootstrap_InitialComponentContext( bootstrap );
}
//==================================================================================================
Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext()
SAL_THROW( (Exception) )
{
- return __defaultBootstrap_InitialComponentContext( __get_unorc() );
+ return defaultBootstrap_InitialComponentContext( get_unorc() );
}
} // namespace cppu
diff --git a/cppuhelper/source/component_context.cxx b/cppuhelper/source/component_context.cxx
index a03db7c00ef2..d3a0452e9e6a 100644
--- a/cppuhelper/source/component_context.cxx
+++ b/cppuhelper/source/component_context.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: component_context.cxx,v $
*
- * $Revision: 1.16 $
+ * $Revision: 1.17 $
*
- * last change: $Author: hr $ $Date: 2002-08-15 12:19:53 $
+ * last change: $Author: dbo $ $Date: 2002-12-06 10:12:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,16 +59,16 @@
*
************************************************************************/
-// #if (__DIAGNOSE == all) || (__DIAGNOSE == context)
-// #define __CONTEXT_DIAG
-// #endif
+#if (DIAG == all) || (DIAG == context)
+#define CONTEXT_DIAG
+#endif
#ifdef _DEBUG
#include <stdio.h>
#endif
#include <vector>
-#ifdef __CONTEXT_DIAG
+#ifdef CONTEXT_DIAG
#include <map>
#endif
@@ -82,6 +82,7 @@
#include <cppuhelper/component_context.hxx>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XSingleComponentFactory.hpp>
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/registry/XSimpleRegistry.hpp>
@@ -106,7 +107,7 @@ using namespace ::com::sun::star;
namespace cppu
{
-#ifdef __CONTEXT_DIAG
+#ifdef CONTEXT_DIAG
//--------------------------------------------------------------------------------------------------
static OUString val2str( void const * pVal, typelib_TypeDescriptionReference * pTypeRef )
{
@@ -310,7 +311,7 @@ static inline beans::PropertyValue createPropertyValue(
return beans::PropertyValue( name, -1, makeAny( value ), beans::PropertyState_DIRECT_VALUE );
}
//--------------------------------------------------------------------------------------------------
-static inline void __dispose( Reference< XInterface > const & xInstance )
+static inline void try_dispose( Reference< XInterface > const & xInstance )
SAL_THROW( (RuntimeException) )
{
Reference< lang::XComponent > xComp( xInstance, UNO_QUERY );
@@ -320,7 +321,7 @@ static inline void __dispose( Reference< XInterface > const & xInstance )
}
}
//--------------------------------------------------------------------------------------------------
-static inline void __dispose( Reference< lang::XComponent > const & xComp )
+static inline void try_dispose( Reference< lang::XComponent > const & xComp )
SAL_THROW( (RuntimeException) )
{
if (xComp.is())
@@ -489,7 +490,7 @@ Sequence< Any > ComponentContext::readInitialArguments(
Any ComponentContext::lookupMap( OUString const & rName )
SAL_THROW( (RuntimeException) )
{
-#ifdef __CONTEXT_DIAG
+#ifdef CONTEXT_DIAG
if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dump_maps") ))
{
::fprintf( stderr, ">>> dumping out ComponentContext %p m_map:\n", this );
@@ -580,7 +581,7 @@ Any ComponentContext::lookupMap( OUString const & rName )
guard.clear();
// service has entered the context in the meantime
// => try to dispose this object
- __dispose( xInstance );
+ try_dispose( xInstance );
}
}
@@ -612,14 +613,14 @@ Reference< lang::XMultiComponentFactory > ComponentContext::getServiceManager()
ComponentContext::~ComponentContext()
SAL_THROW( () )
{
-#ifdef __CONTEXT_DIAG
+#ifdef CONTEXT_DIAG
::fprintf( stderr, "> destructed context %p\n", this );
#endif
}
//__________________________________________________________________________________________________
void ComponentContext::disposing()
{
-#ifdef __CONTEXT_DIAG
+#ifdef CONTEXT_DIAG
::fprintf( stderr, "> disposing context %p\n", this );
#endif
@@ -673,14 +674,14 @@ void ComponentContext::disposing()
}
// dispose service manager
- __dispose( m_xSMgr );
+ try_dispose( m_xSMgr );
m_xSMgr.clear();
// dispose ac
- __dispose( xAC );
+ try_dispose( xAC );
// dispose policy
- __dispose( xPolicy );
+ try_dispose( xPolicy );
// dispose tdmgr; revokes callback from cppu runtime
- __dispose( xTDMgr );
+ try_dispose( xTDMgr );
// everything is disposed, hopefully nobody accesses the context anymore...
iPos = m_map.begin();
@@ -699,9 +700,9 @@ ComponentContext::ComponentContext(
: WeakComponentImplHelper1< XComponentContext >( m_mutex )
, m_xDelegate( xDelegate )
{
- while (nEntries--)
+ for ( sal_Int32 nPos = 0; nPos < nEntries; ++nPos )
{
- ContextEntry_Init const & rEntry = pEntries[ nEntries ];
+ ContextEntry_Init const & rEntry = pEntries[ nPos ];
if (rEntry.name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(SMGR_SINGLETON) ))
{
@@ -816,7 +817,7 @@ Reference< container::XNameAccess > ConfigurationComponentContext::getCfgNode(
else
{
guard.clear();
- __dispose( xCfgProvider );
+ try_dispose( xCfgProvider );
}
}
else
@@ -837,7 +838,7 @@ Reference< container::XNameAccess > ConfigurationComponentContext::getCfgNode(
}
catch (Exception & exc)
{
-#ifdef __CONTEXT_DIAG
+#ifdef CONTEXT_DIAG
OString str( OUStringToOString( rName, RTL_TEXTENCODING_ASCII_US ) );
OString str2( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
::fprintf( stderr, "### accessing node %s from cfg failed: %s\n", str.getStr(), str2.getStr() );
@@ -942,7 +943,7 @@ Any ConfigurationComponentContext::getValueByName( OUString const & rName )
return ret;
}
-#ifdef __CONTEXT_DIAG
+#ifdef CONTEXT_DIAG
if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dump_maps") ))
{
::fprintf( stderr, ">>> dumping out ConfigurationComponentContext %p m_singletons:\n", this );
@@ -1002,7 +1003,7 @@ Any ConfigurationComponentContext::getValueByName( OUString const & rName )
{
guard.clear();
// => try to dispose created object
- __dispose( xInstance );
+ try_dispose( xInstance );
return makeAny( iFind->second );
}
}
@@ -1021,7 +1022,7 @@ Any ConfigurationComponentContext::getValueByName( OUString const & rName )
}
catch (Exception & exc)
{
-#ifdef __CONTEXT_DIAG
+#ifdef CONTEXT_DIAG
OString str( OUStringToOString( rName, RTL_TEXTENCODING_ASCII_US ) );
OString str2( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) );
::fprintf( stderr, "### accessing node %s from cfg failed: %s\n", str.getStr(), str2.getStr() );
@@ -1041,7 +1042,7 @@ Any ConfigurationComponentContext::getValueByName( OUString const & rName )
//__________________________________________________________________________________________________
void ConfigurationComponentContext::disposing()
{
-#ifdef __CONTEXT_DIAG
+#ifdef CONTEXT_DIAG
::fprintf( stderr, "> disposing cfg context %p\n", this );
#endif
@@ -1071,20 +1072,20 @@ void ConfigurationComponentContext::disposing()
}
else // dispose immediately
{
- __dispose( iPos->second );
+ try_dispose( iPos->second );
}
++iPos;
}
m_singletons.clear();
// dispose service manager
- __dispose( xSMgr );
+ try_dispose( xSMgr );
// dispose ac
- __dispose( xAC );
+ try_dispose( xAC );
// dispose policy
- __dispose( xPolicy );
+ try_dispose( xPolicy );
// dispose tdmgr; revokes callback from cppu runtime
- __dispose( xTDMgr );
+ try_dispose( xTDMgr );
// dispose context values map
ComponentContext::disposing();
@@ -1096,8 +1097,8 @@ Reference< XComponentContext > SAL_CALL createInitialCfgComponentContext(
Reference< XComponentContext > const & xDelegate )
SAL_THROW( () )
{
- ConfigurationComponentContext * p = new ConfigurationComponentContext(
- pEntries, nEntries, xDelegate );
+ ConfigurationComponentContext * p =
+ new ConfigurationComponentContext( pEntries, nEntries, xDelegate );
Reference< XComponentContext > xContext( p );
// listen delegate for disposing, to dispose this (wrapping) context first.
DisposingForwarder::listen( Reference< lang::XComponent >::query( xDelegate ), p );
diff --git a/cppuhelper/source/macro_expander.cxx b/cppuhelper/source/macro_expander.cxx
index 1c71716f8000..7509b65d0f75 100644
--- a/cppuhelper/source/macro_expander.cxx
+++ b/cppuhelper/source/macro_expander.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: macro_expander.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: vg $ $Date: 2002-09-05 16:13:52 $
+ * last change: $Author: dbo $ $Date: 2002-12-06 10:12:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -84,7 +84,7 @@ using namespace ::com::sun::star::uno;
namespace cppu
{
//---- private forward -----------------------------------------------------------------------------
-Bootstrap const & __get_unorc() SAL_THROW( () );
+Bootstrap const & get_unorc() SAL_THROW( () );
}
namespace
@@ -255,7 +255,7 @@ OUString Bootstrap_MacroExpander::expandMacros( OUString const & exp )
}
else
{
- bstrap = ::cppu::__get_unorc().getHandle();
+ bstrap = ::cppu::get_unorc().getHandle();
}
// expand
diff --git a/cppuhelper/source/makefile.mk b/cppuhelper/source/makefile.mk
index 5f2cc1aed17b..e2b07df40dd6 100644
--- a/cppuhelper/source/makefile.mk
+++ b/cppuhelper/source/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.27 $
+# $Revision: 1.28 $
#
-# last change: $Author: sb $ $Date: 2002-10-02 15:35:03 $
+# last change: $Author: dbo $ $Date: 2002-12-06 10:12:29 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -198,7 +198,7 @@ SHL1VERSIONMAP=gcc3_linux_intel.map
# --- Targets ------------------------------------------------------
.IF "$(diag)"!=""
-CFLAGS += -D__DIAGNOSE=$(diag)
+CFLAGS += -DDIAG=$(diag)
.ENDIF
.INCLUDE : target.mk
diff --git a/cppuhelper/source/servicefactory.cxx b/cppuhelper/source/servicefactory.cxx
index ca685158e185..19da61fb20da 100644
--- a/cppuhelper/source/servicefactory.cxx
+++ b/cppuhelper/source/servicefactory.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: servicefactory.cxx,v $
*
- * $Revision: 1.32 $
+ * $Revision: 1.33 $
*
- * last change: $Author: dbo $ $Date: 2002-11-11 16:50:43 $
+ * last change: $Author: dbo $ $Date: 2002-12-06 10:12:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,7 +64,6 @@
#endif
#include <vector>
-#include <rtl/process.h>
#include <rtl/string.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/bootstrap.hxx>
@@ -72,7 +71,6 @@
#include <osl/diagnose.h>
#include <osl/file.h>
#include <osl/module.h>
-#include <osl/thread.h>
#include <osl/process.h>
#include <cppuhelper/shlib.hxx>
@@ -117,10 +115,6 @@ void addFactories(
//--------------------------------------------------------------------------------------------------
Reference< security::XAccessController > createDefaultAccessController() SAL_THROW( () );
//--------------------------------------------------------------------------------------------------
-void * SAL_CALL parentThreadCallback(void) SAL_THROW_EXTERN_C();
-//--------------------------------------------------------------------------------------------------
-void SAL_CALL childThreadCallback( void * xParentContext ) SAL_THROW_EXTERN_C();
-//--------------------------------------------------------------------------------------------------
Reference< lang::XSingleComponentFactory > create_boostrap_macro_expander_factory() SAL_THROW( () );
//==================================================================================================
@@ -350,8 +344,7 @@ Reference< XComponentContext > bootstrapInitialContext(
Reference< lang::XMultiComponentFactory > const & xSF,
Reference< registry::XSimpleRegistry > const & types_xRegistry,
Reference< registry::XSimpleRegistry > const & services_xRegistry,
- OUString const & rBootstrapPath,
- Bootstrap const & bootstrap )
+ OUString const & rBootstrapPath, Bootstrap const & bootstrap )
SAL_THROW( (Exception) )
{
Reference< lang::XInitialization > xSFInit( xSF, UNO_QUERY );
@@ -367,6 +360,18 @@ Reference< XComponentContext > bootstrapInitialContext(
::std::vector< ContextEntry_Init > context_values;
context_values.reserve( 14 );
+ // macro expander singleton for loader
+ entry.bLateInitService = true;
+ entry.name = OUSTR("/singletons/com.sun.star.util.theMacroExpander");
+ entry.value <<= create_boostrap_macro_expander_factory();
+ context_values.push_back( entry );
+
+ // tdmgr singleton
+ entry.bLateInitService = true;
+ entry.name = OUSTR("/singletons/com.sun.star.reflection.theTypeDescriptionManager");
+ entry.value <<= OUSTR("com.sun.star.comp.stoc.TypeDescriptionManager");
+ context_values.push_back( entry );
+
// read out singleton infos from registry
if (services_xRegistry.is())
{
@@ -400,7 +405,7 @@ Reference< XComponentContext > bootstrapInitialContext(
xKey->getKeyName().copy( 11 ), RTL_TEXTENCODING_ASCII_US ) );
OString aStr2( OUStringToOString(
rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
- ::fprintf( stderr, "### failed reading singleton [%s] service name from registry: %s\n", aStr.getStr(), aStr2.getStr() );
+ fprintf( stderr, "### failed reading singleton [%s] service name from registry: %s\n", aStr.getStr(), aStr2.getStr() );
#endif
}
}
@@ -408,36 +413,15 @@ Reference< XComponentContext > bootstrapInitialContext(
}
}
- // smgr:
- // - smgr singleton
- entry.bLateInitService = false;
- entry.name = OUSTR("/singletons/com.sun.star.lang.theServiceManager");
- entry.value <<= xSF;
- context_values.push_back( entry );
-
- // macro expander singleton for loader
- entry.bLateInitService = true;
- entry.name = OUSTR("/singletons/com.sun.star.util.theMacroExpander");
- entry.value <<= create_boostrap_macro_expander_factory();
- context_values.push_back( entry );
-
// ac, policy:
add_access_control_entries( &context_values, bootstrap );
- // tdmgr:
- // - tdmgr prop: cache size
+ // smgr singleton
entry.bLateInitService = false;
- entry.name = OUSTR("/implementations/com.sun.star.comp.stoc.TypeDescriptionManager/CacheSize");
- entry.value <<= (sal_Int32)512;
- context_values.push_back( entry );
- // - tdmgr singleton
- entry.bLateInitService = true;
- entry.name = OUSTR("/singletons/com.sun.star.reflection.theTypeDescriptionManager");
- entry.value <<= OUSTR("com.sun.star.comp.stoc.TypeDescriptionManager");
+ entry.name = OUSTR("/singletons/com.sun.star.lang.theServiceManager");
+ entry.value <<= xSF;
context_values.push_back( entry );
- Reference< container::XHierarchicalNameAccess > xTDMgr;
-
Reference< XComponentContext > xContext(
createComponentContext(
&context_values[ 0 ], context_values.size(),
@@ -451,6 +435,8 @@ Reference< XComponentContext > bootstrapInitialContext(
OUSTR("DefaultContext"), makeAny( xContext ) );
}
+ Reference< container::XHierarchicalNameAccess > xTDMgr;
+
// get tdmgr singleton
if (xContext->getValueByName(
OUSTR("/singletons/com.sun.star.reflection.theTypeDescriptionManager") ) >>= xTDMgr)
@@ -497,8 +483,6 @@ static Reference< lang::XMultiComponentFactory > createImplServiceFactory(
const OUString & rBootstrapPath )
SAL_THROW( (Exception) )
{
-// osl_registerThreadCallbacks( parentThreadCallback, childThreadCallback );
-
Reference< lang::XMultiComponentFactory > xSF( bootstrapInitialSF( rBootstrapPath ) );
Reference< registry::XSimpleRegistry > xRegistry;
@@ -606,8 +590,6 @@ Reference< XComponentContext > SAL_CALL bootstrap_InitialComponentContext(
{
Bootstrap bootstrap;
-// osl_registerThreadCallbacks( parentThreadCallback, childThreadCallback );
-
Reference< lang::XMultiComponentFactory > xSF(
bootstrapInitialSF( rBootstrapPath ) );
Reference< XComponentContext > xContext(