summaryrefslogtreecommitdiff
path: root/cppuhelper
diff options
context:
space:
mode:
authorHerbert Dürr <hdu@apache.org>2013-03-20 15:33:52 +0000
committerHerbert Dürr <hdu@apache.org>2013-03-20 15:33:52 +0000
commitaf614d3f8358663879e086da1a3545f9f4fd10a2 (patch)
treeb93540c88f4f3241f57a13b45d1fdefd2a994019 /cppuhelper
parentde75173372c022c3004643d8978f76662261130b (diff)
Workaround bootstrap needing "comprehensive" type descriptions for stuff used in bootstrapping
Cppumaker and its brethren emit different implementations for the same symbol by design (!) which is quite... unfortunate and can confuse the heck out of dynamic linkers, debuggers, etc. For bootstrapping the so-called "comprehensive" type descriptions are needed. The workaround compels these descriptions to be registered in the so-called "WeakMap" before they are needed by the bootstrap operation. The proper and un-hacky solution would be to change cppumaker and its brethren to use different symbol names for different implementations. In particular "cppu_detail_getUnoType" should be divided into full, weak and mini implementations. For now there is no time to risk such a major overhaul of this system. Types that are candidates for this special workaround are the ones mentioned by the exceptions thrown from implbase_ex.cxx's __queryDeepNoXInterface() method. They also need to added to the makefile's UNOTYPES define so that the build magic requests the full type descriptions to be generated and used.
Notes
Diffstat (limited to 'cppuhelper')
-rw-r--r--cppuhelper/source/bootstrap.cxx5
-rw-r--r--cppuhelper/source/makefile.mk5
-rw-r--r--cppuhelper/source/primeweak.cxx128
3 files changed, 137 insertions, 1 deletions
diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx
index 24134863a023..07c111604c5c 100644
--- a/cppuhelper/source/bootstrap.cxx
+++ b/cppuhelper/source/bootstrap.cxx
@@ -48,6 +48,8 @@
#include "cppuhelper/access_control.hxx"
#include "cppuhelper/findsofficepath.h"
+#include <cppuhelper/com/sun/star/container/XElementAccess.hpp>
+
#include "com/sun/star/uno/XComponentContext.hpp"
#include "com/sun/star/uno/XCurrentContext.hpp"
@@ -67,6 +69,7 @@
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
#define ARLEN(x) sizeof (x) / sizeof *(x)
+void primeWeakMap( void); // as defined in primeweak.cxx
using namespace ::rtl;
using namespace ::osl;
@@ -376,6 +379,8 @@ SAL_CALL defaultBootstrap_InitialComponentContext(
Bootstrap const & bootstrap )
SAL_THROW( (Exception) )
{
+ primeWeakMap();
+
OUString bootstrapPath;
if (!bootstrap.getFrom(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URE_INTERNAL_LIB_DIR")),
diff --git a/cppuhelper/source/makefile.mk b/cppuhelper/source/makefile.mk
index 586ab06cedb2..9311ee4b77a1 100644
--- a/cppuhelper/source/makefile.mk
+++ b/cppuhelper/source/makefile.mk
@@ -78,6 +78,7 @@ UNOTYPES= \
com.sun.star.lang.XServiceInfo \
com.sun.star.lang.XSingleComponentFactory \
com.sun.star.lang.XSingleServiceFactory \
+ com.sun.star.lang.XUnoTunnel \
com.sun.star.lang.XTypeProvider \
com.sun.star.loader.XImplementationLoader \
com.sun.star.reflection.XArrayTypeDescription \
@@ -123,6 +124,7 @@ SLOFILES= \
$(SLO)$/exc_thrower.obj \
$(SLO)$/servicefactory.obj \
$(SLO)$/bootstrap.obj \
+ $(SLO)$/primeweak.obj \
$(SLO)$/implbase.obj \
$(SLO)$/implbase_ex.obj \
$(SLO)$/propshlp.obj \
@@ -174,7 +176,8 @@ SHL1VERSIONMAP=msvc_win32_intel.map
SHL1VERSIONMAP=cc5_solaris_sparc.map
.ELIF "$(GUI)$(COMNAME)"=="OS2gcc3"
SHL1VERSIONMAP=gcc3os2.map
-.ELIF "$(COMNAME)"=="gcc3"
+#.ELIF "$(COMNAME)"=="gcc3" || "$(COMNAME)"=="Clang"
+.ELSE
SHL1VERSIONMAP=gcc3.map
.ENDIF
diff --git a/cppuhelper/source/primeweak.cxx b/cppuhelper/source/primeweak.cxx
new file mode 100644
index 000000000000..c3bf7a9e4cc5
--- /dev/null
+++ b/cppuhelper/source/primeweak.cxx
@@ -0,0 +1,128 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_cppuhelper.hxx"
+
+// The only purpose of this file is to workaround a problem in UNO:
+// Cppumaker and its brethren emit different implementations for
+// the same symbol by design (!) which is quite... unfortunate
+// and can confuse the heck out of dynamic linkers, debuggers, etc.
+//
+// For bootstrapping comprehensive descriptions of some UNO types are needed.
+// The mechanism in this file makes sure that these comprehensive type
+// descriptions are used to prime the so-called "WeakMap".
+//
+// TODO: change cppumaker and its brethren to use different symbol names
+// for different implementations. In particular "cppu_detail_getUnoType"
+// should be divided into full, weak and mini implementations.
+
+// Types that are candidates for this special workaround are the ones mentioned
+// by the exceptions thrown from implbase_ex.cxx's __queryDeepNoXInterface()
+// that also need to added to the makefile's UNOTYPES define
+
+#define cppu_detail_getUnoType cppu_full_getUnoType
+#define InitTypeDesc(T) {(void)cppu_full_getUnoType(static_cast< T * >(NULL));}
+
+#include "cppuhelper/com/sun/star/lang/XComponent.hpp"
+#include "cppuhelper/com/sun/star/lang/XInitialization.hpp"
+#include "cppuhelper/com/sun/star/lang/XSingleServiceFactory.hpp"
+#include "cppuhelper/com/sun/star/lang/XSingleComponentFactory.hpp"
+#include "cppuhelper/com/sun/star/lang/XMultiServiceFactory.hpp"
+#include "cppuhelper/com/sun/star/lang/XMulticomponentFactory.hpp"
+#include "cppuhelper/com/sun/star/lang/XServiceInfo.hpp"
+#include "cppuhelper/com/sun/star/lang/XEventListener.hpp"
+#include "cppuhelper/com/sun/star/lang/XTypeProvider.hpp"
+#include "cppuhelper/com/sun/star/lang/XUnoTunnel.hpp"
+#include "cppuhelper/com/sun/star/uno/DeploymentException.hpp"
+#include "cppuhelper/com/sun/star/uno/XWeak.hpp"
+#include "cppuhelper/com/sun/star/uno/XCurrentContext.hpp"
+#include "cppuhelper/com/sun/star/uno/XComponentContext.hpp"
+#include "cppuhelper/com/sun/star/uno/RuntimeException.hpp"
+#include "cppuhelper/com/sun/star/beans/PropertyValue.hpp"
+#include "cppuhelper/com/sun/star/beans/XPropertySet.hpp"
+#include "cppuhelper/com/sun/star/beans/XMultiPropertySet.hpp"
+#include "cppuhelper/com/sun/star/container/XEnumerationAccess.hpp"
+#include "cppuhelper/com/sun/star/container/XEnumeration.hpp"
+#include "cppuhelper/com/sun/star/container/XHierarchicalNameAccess.hpp"
+#include "cppuhelper/com/sun/star/container/XSet.hpp"
+#include "cppuhelper/com/sun/star/bridge/XUnoUrlResolver.hpp"
+#include "cppuhelper/com/sun/star/bridge/XUnoUrlResolver.hpp"
+#include "cppuhelper/com/sun/star/io/IOException.hpp"
+#include "cppuhelper/com/sun/star/io/FilePermission.hpp"
+#include "cppuhelper/com/sun/star/security/RuntimePermission.hpp"
+#include "cppuhelper/com/sun/star/loader/XImplementationLoader.hpp"
+#include "cppuhelper/com/sun/star/security/XAccessController.hpp"
+#include "cppuhelper/com/sun/star/registry/XRegistryKey.hpp"
+#include "cppuhelper/com/sun/star/registry/XSimpleRegistry.hpp"
+#include "cppuhelper/com/sun/star/reflection/XTypeDescription.hpp"
+#include "cppuhelper/com/sun/star/reflection/XEnumTypeDescription.hpp"
+#include "cppuhelper/com/sun/star/reflection/XArrayTypeDescription.hpp"
+#include "cppuhelper/com/sun/star/reflection/XStructTypeDescription.hpp"
+#include "cppuhelper/com/sun/star/reflection/XUnionTypeDescription.hpp"
+#include "cppuhelper/com/sun/star/reflection/XCompoundTypeDescription.hpp"
+#include "cppuhelper/com/sun/star/reflection/XIndirectTypeDescription.hpp"
+#include "cppuhelper/com/sun/star/reflection/XMethodParameter.hpp"
+
+void primeWeakMap( void)
+{
+ InitTypeDesc( com::sun::star::lang::XComponent );
+ InitTypeDesc( com::sun::star::lang::XInitialization );
+ InitTypeDesc( com::sun::star::lang::XSingleServiceFactory );
+ InitTypeDesc( com::sun::star::lang::XSingleComponentFactory );
+ InitTypeDesc( com::sun::star::lang::XMultiServiceFactory );
+ InitTypeDesc( com::sun::star::lang::XMultiComponentFactory );
+ InitTypeDesc( com::sun::star::lang::XServiceInfo );
+ InitTypeDesc( com::sun::star::lang::XEventListener );
+ InitTypeDesc( com::sun::star::lang::XTypeProvider );
+ InitTypeDesc( com::sun::star::lang::XUnoTunnel );
+ InitTypeDesc( com::sun::star::uno::XWeak );
+ InitTypeDesc( com::sun::star::uno::DeploymentException );
+ InitTypeDesc( com::sun::star::uno::XCurrentContext );
+ InitTypeDesc( com::sun::star::uno::XComponentContext );
+ InitTypeDesc( com::sun::star::uno::RuntimeException );
+ InitTypeDesc( com::sun::star::beans::PropertyState );
+ InitTypeDesc( com::sun::star::beans::PropertyValue );
+ InitTypeDesc( com::sun::star::beans::XPropertySet );
+ InitTypeDesc( com::sun::star::beans::XMultiPropertySet );
+ InitTypeDesc( com::sun::star::container::XElementAccess );
+ InitTypeDesc( com::sun::star::container::XEnumeration );
+ InitTypeDesc( com::sun::star::container::XEnumerationAccess );
+ InitTypeDesc( com::sun::star::container::XHierarchicalNameAccess );
+ InitTypeDesc( com::sun::star::container::XSet );
+ InitTypeDesc( com::sun::star::io::IOException );
+ InitTypeDesc( com::sun::star::io::FilePermission );
+ InitTypeDesc( com::sun::star::security::XAccessController );
+ InitTypeDesc( com::sun::star::security::RuntimePermission);
+ InitTypeDesc( com::sun::star::loader::XImplementationLoader );
+ InitTypeDesc( com::sun::star::bridge::XUnoUrlResolver );
+ InitTypeDesc( com::sun::star::registry::XRegistryKey );
+ InitTypeDesc( com::sun::star::registry::XSimpleRegistry );
+ InitTypeDesc( com::sun::star::reflection::XTypeDescription );
+ InitTypeDesc( com::sun::star::reflection::XEnumTypeDescription );
+ InitTypeDesc( com::sun::star::reflection::XArrayTypeDescription );
+ InitTypeDesc( com::sun::star::reflection::XStructTypeDescription );
+ InitTypeDesc( com::sun::star::reflection::XUnionTypeDescription );
+ InitTypeDesc( com::sun::star::reflection::XCompoundTypeDescription );
+ InitTypeDesc( com::sun::star::reflection::XIndirectTypeDescription );
+ InitTypeDesc( com::sun::star::reflection::XMethodParameter );
+}
+