summaryrefslogtreecommitdiff
path: root/salhelper
diff options
context:
space:
mode:
Diffstat (limited to 'salhelper')
-rw-r--r--salhelper/inc/salhelper/condition.hxx124
-rw-r--r--salhelper/inc/salhelper/dynload.hxx206
-rw-r--r--salhelper/inc/salhelper/future.hxx120
-rw-r--r--salhelper/inc/salhelper/futurequeue.hxx108
-rw-r--r--salhelper/inc/salhelper/monitor.hxx288
-rw-r--r--salhelper/inc/salhelper/queue.hxx186
-rw-r--r--salhelper/inc/salhelper/refobj.hxx110
-rwxr-xr-xsalhelper/inc/salhelper/simplereferenceobject.hxx136
-rw-r--r--salhelper/inc/salhelper/singletonref.hxx210
-rw-r--r--salhelper/prj/build.lst3
-rw-r--r--salhelper/prj/d.lst21
-rw-r--r--salhelper/qa/makefile.mk52
-rw-r--r--salhelper/qa/test_api.cxx250
-rwxr-xr-xsalhelper/qa/version.map6
-rw-r--r--salhelper/source/condition.cxx142
-rw-r--r--salhelper/source/dynload.cxx110
-rw-r--r--salhelper/source/gcc3.map73
-rw-r--r--salhelper/source/gcc3os2.map73
-rw-r--r--salhelper/source/makefile.mk82
-rw-r--r--salhelper/source/msci.map38
-rwxr-xr-xsalhelper/source/simplereferenceobject.cxx74
-rw-r--r--salhelper/source/sols.map76
-rw-r--r--salhelper/test/Symbols/loader.cxx37
-rw-r--r--salhelper/test/Symbols/makefile.mk97
-rw-r--r--salhelper/test/Symbols/samplelib.cxx37
-rw-r--r--salhelper/test/Symbols/samplelib.hxx22
-rw-r--r--salhelper/test/dynamicloader/loader.cxx37
-rw-r--r--salhelper/test/dynamicloader/makefile.mk117
-rw-r--r--salhelper/test/dynamicloader/samplelib.cxx37
-rw-r--r--salhelper/test/dynamicloader/samplelib.hxx22
-rw-r--r--salhelper/test/rtti/exports.dxp8
-rw-r--r--salhelper/test/rtti/makefile.mk107
-rw-r--r--salhelper/test/rtti/rttitest.cxx29
-rw-r--r--salhelper/test/rtti/samplelibrtti.cxx39
-rw-r--r--salhelper/test/rtti/samplelibrtti.hxx28
-rw-r--r--salhelper/test/rtti/sols.map34
-rw-r--r--salhelper/version.mk44
37 files changed, 3183 insertions, 0 deletions
diff --git a/salhelper/inc/salhelper/condition.hxx b/salhelper/inc/salhelper/condition.hxx
new file mode 100644
index 000000000000..de0664cd197d
--- /dev/null
+++ b/salhelper/inc/salhelper/condition.hxx
@@ -0,0 +1,124 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SALHELPER_CONDITION_HXX_
+#define _SALHELPER_CONDITION_HXX_
+
+
+#include <osl/conditn.h>
+#include <osl/mutex.hxx>
+
+
+namespace salhelper
+{
+ class ConditionModifier;
+ class ConditionWaiter;
+
+
+ class Condition
+ {
+ friend class ConditionModifier;
+ friend class ConditionWaiter;
+
+ public:
+
+ Condition(osl::Mutex& aMutex);
+
+ virtual ~Condition();
+
+
+ protected:
+
+ virtual bool applies() const = 0;
+
+
+ private:
+ Condition(Condition &); // not defined
+ void operator =(Condition &); // not defined
+
+ osl::Mutex& m_aMutex;
+ oslCondition m_aCondition;
+ };
+
+
+
+ class ConditionModifier
+ {
+ public:
+
+ ConditionModifier(Condition& aCond);
+
+ ~ConditionModifier();
+
+
+ private:
+ ConditionModifier(ConditionModifier &); // not defined
+ void operator =(ConditionModifier &); // not defined
+
+ Condition& m_aCond;
+ };
+
+
+
+ class ConditionWaiter
+ {
+ public:
+
+ ConditionWaiter(Condition& aCond);
+
+ struct timedout {
+ timedout();
+
+ timedout(timedout const &);
+
+ virtual ~timedout();
+
+ timedout & operator =(timedout const &);
+ };
+
+ ConditionWaiter(Condition& aCond,sal_uInt32 milliSec)
+ throw(
+ timedout
+ );
+
+
+ ~ConditionWaiter();
+
+
+ private:
+ ConditionWaiter(ConditionWaiter &); // not defined
+ void operator =(ConditionWaiter &); // not defined
+
+ Condition& m_aCond;
+ };
+
+
+} // namespace salhelper
+
+
+#endif
diff --git a/salhelper/inc/salhelper/dynload.hxx b/salhelper/inc/salhelper/dynload.hxx
new file mode 100644
index 000000000000..cb657ec72ff1
--- /dev/null
+++ b/salhelper/inc/salhelper/dynload.hxx
@@ -0,0 +1,206 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SALHELPER_DYNLOAD_HXX_
+#define _SALHELPER_DYNLOAD_HXX_
+
+#include <sal/types.h>
+#include <rtl/ustring.hxx>
+#include <osl/module.h>
+
+namespace salhelper
+{
+
+/** The ORealDynamicLoader is an implementation helper class for the template loader ODynamicLoader.
+ */
+class ORealDynamicLoader
+{
+public:
+ /** initializes the loader, loads the library and call the initialization fucntion.
+
+ @param ppSetToZeroInDestructor points to the loader instance which must be set to NULL
+ if the loader will be destroyed.
+ @param strModuleName specifies the library name.
+ @param strInitFunction specifies the name of the initialization function.
+ */
+ static ORealDynamicLoader* SAL_CALL newInstance(
+ ORealDynamicLoader ** ppSetToZeroInDestructor,
+ const ::rtl::OUString& strModuleName,
+ const ::rtl::OUString& strInitFunction );
+
+ /// increase the reference count.
+ sal_uInt32 SAL_CALL acquire();
+ /// decrease the reference count and delete the last instance.
+ sal_uInt32 SAL_CALL release();
+
+ /// returns a poiner to the initialized API function structure.
+ void* SAL_CALL getApi() const;
+
+protected:
+ /** Constructor.
+
+ @param ppSetToZeroInDestructor points to the loader instance which must be set to NULL
+ if the loader will be destroyed.
+ @param strModuleName specifies the library name.
+ @param strInitFunction specifies the name of the initialization function.
+ @param pApi points to a structure with the initialized API function pointers.
+ @param pModule points to the loaded library handle.
+ */
+ ORealDynamicLoader( ORealDynamicLoader ** ppSetToZeroInDestructor,
+ const ::rtl::OUString& strModuleName,
+ const ::rtl::OUString& strInitFunction,
+ void* pApi,
+ oslModule pModule );
+
+ /// Destructor, try to unload the library.
+ virtual ~ORealDynamicLoader();
+
+ /// points to the structure with the initialzed API function pointers.
+ void* m_pApi;
+ /// stores the reference count.
+ sal_uInt32 m_refCount;
+ /// stores the library handle.
+ oslModule m_pModule;
+ /// stores the library name.
+ ::rtl::OUString m_strModuleName;
+ /// stores the name of the initialization function.
+ ::rtl::OUString m_strInitFunction;
+ /** stores a pointer to itself, which must be reset in the destructor to signal
+ that the loader is invalid.
+ */
+ ORealDynamicLoader ** ppSetToZeroInDestructor;
+};
+
+
+/** The ODynmaicLoader provides a special load on call mechanism for dynamic libraries
+ which support a C-API.
+
+ The libraries must provide a struct with function pointers for all supported C functions.
+ The loader loads the specified library and call the specified initialization function
+ to initialize the function pointers with the real functions. Furthermore provides the
+ loader a reference counter for the library. When the last instance of the laoder will
+ be destroyed the loader will unload the library.
+
+ @deprecated
+ Do not use.
+ */
+template<class API>
+class ODynamicLoader
+{
+public:
+ /// Default constructor
+ ODynamicLoader() SAL_THROW(())
+ {
+ m_pLoader = 0;
+ }
+
+ /** Constructor, loads the library if necessary otherwise the refernece count will
+ be increased.
+
+ @param strModuleName specifies the library name.
+ @param strInitFunction specifies the name of the initialization function.
+ */
+ ODynamicLoader( const ::rtl::OUString& strModuleName,
+ const ::rtl::OUString& strInitFunction ) SAL_THROW(())
+ {
+ if (!m_pStaticLoader)
+ {
+ m_pStaticLoader = ORealDynamicLoader::newInstance(
+ &m_pStaticLoader,
+ strModuleName,
+ strInitFunction);
+ }
+ else
+ {
+ m_pStaticLoader->acquire();
+ }
+
+ m_pLoader = m_pStaticLoader;
+ }
+
+ /// Copy constructor
+ ODynamicLoader(const ODynamicLoader<API>& toCopy) SAL_THROW(())
+ {
+ m_pLoader = toCopy.m_pLoader;
+ if( m_pLoader )
+ m_pLoader->acquire();
+ }
+
+ /// Destructor, decrease the reference count and unload the library if it is tha last instance.
+ ~ODynamicLoader() SAL_THROW(())
+ {
+ if( m_pLoader )
+ m_pLoader->release();
+ }
+
+ /// Assign operator
+ ODynamicLoader<API>& SAL_CALL operator = (const ODynamicLoader<API>& toAssign) SAL_THROW(())
+ {
+ if( m_pLoader != toAssign.m_pLoader )
+ {
+ if( toAssign.m_pLoader )
+ toAssign.m_pLoader->acquire();
+ if( m_pLoader )
+ m_pLoader->release();
+ m_pLoader = toAssign.m_pLoader;
+ }
+
+ return (*this);
+ }
+
+ /// returns a poiner to the initialized API function structure.
+ API* SAL_CALL getApi() const SAL_THROW(())
+ {
+ return (API*)m_pLoader->getApi();
+ }
+
+ /// cast operator, which cast to a poiner with the initialized API function structure.
+ API* SAL_CALL operator->() const SAL_THROW(())
+ {
+ return (API*)m_pLoader->getApi();
+ }
+
+ /// checks if the loader works on a loaded and initialized library.
+ sal_Bool SAL_CALL isLoaded() const SAL_THROW(())
+ {
+ return (m_pLoader != NULL);
+ }
+
+protected:
+ /// stores the real loader helper instance
+ static ORealDynamicLoader* m_pStaticLoader;
+ ORealDynamicLoader* m_pLoader;
+};
+
+
+template<class API>
+ORealDynamicLoader* ODynamicLoader<API>::m_pStaticLoader = NULL;
+
+}
+
+#endif
+
diff --git a/salhelper/inc/salhelper/future.hxx b/salhelper/inc/salhelper/future.hxx
new file mode 100644
index 000000000000..a16b9c8815d6
--- /dev/null
+++ b/salhelper/inc/salhelper/future.hxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SALHELPER_FUTURE_HXX_
+#define _SALHELPER_FUTURE_HXX_
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <osl/conditn.hxx>
+#include <salhelper/refobj.hxx>
+
+namespace salhelper
+{
+
+//----------------------------------------------------------------------------
+
+#ifndef SALHELPER_COPYCTOR_API
+#define SALHELPER_COPYCTOR_API(C) C (const C&); C& operator= (const C&)
+#endif
+
+//----------------------------------------------------------------------------
+
+template<class value_type>
+class FutureValue : protected osl::Condition
+{
+ /** Representation.
+ */
+ value_type m_aValue;
+
+ /** Not implemented.
+ */
+ SALHELPER_COPYCTOR_API(FutureValue<value_type>);
+
+public:
+ inline FutureValue (const value_type& value = value_type()) SAL_THROW(())
+ : m_aValue (value)
+ {
+ Condition::reset();
+ }
+
+ inline ~FutureValue() SAL_THROW(())
+ {}
+
+ inline sal_Bool is() const SAL_THROW(())
+ {
+ return const_cast<FutureValue*>(this)->check();
+ }
+
+ inline void set (const value_type& value) SAL_THROW(())
+ {
+ m_aValue = value;
+ Condition::set();
+ }
+
+ inline value_type& get() SAL_THROW(())
+ {
+ Condition::wait();
+ return m_aValue;
+ }
+};
+
+//----------------------------------------------------------------------------
+
+template<class value_type>
+class Future : public salhelper::ReferenceObject
+{
+ /** Representation.
+ */
+ FutureValue<value_type> m_aValue;
+
+ /** Not implemented.
+ */
+ SALHELPER_COPYCTOR_API(Future<value_type>);
+
+public:
+ inline Future (const value_type& value = value_type()) SAL_THROW(())
+ : m_aValue (value)
+ {}
+
+ inline void set (const value_type& value) SAL_THROW(())
+ {
+ OSL_PRECOND(!m_aValue.is(), "Future::set(): value already set");
+ m_aValue.set (value);
+ }
+
+ inline value_type& get() SAL_THROW(())
+ {
+ return m_aValue.get();
+ }
+};
+
+//----------------------------------------------------------------------------
+
+} // namespace salhelper
+
+#endif /* !_SALHELPER_FUTURE_HXX_ */
diff --git a/salhelper/inc/salhelper/futurequeue.hxx b/salhelper/inc/salhelper/futurequeue.hxx
new file mode 100644
index 000000000000..64915317440b
--- /dev/null
+++ b/salhelper/inc/salhelper/futurequeue.hxx
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SALHELPER_FUTUREQUEUE_HXX_
+#define _SALHELPER_FUTUREQUEUE_HXX_
+
+#include <sal/types.h>
+#include <rtl/ref.hxx>
+#include <osl/mutex.hxx>
+#include <salhelper/future.hxx>
+#include <salhelper/queue.hxx>
+
+namespace salhelper
+{
+
+//----------------------------------------------------------------------------
+
+#ifndef SALHELPER_COPYCTOR_API
+#define SALHELPER_COPYCTOR_API(C) C (const C&); C& operator= (const C&)
+#endif
+
+//----------------------------------------------------------------------------
+
+template<class element_type>
+class FutureQueue : protected osl::Mutex
+{
+ /** Representation.
+ */
+ typedef salhelper::Future<element_type> future_type;
+
+ salhelper::QueueBase< rtl::Reference<future_type> > m_aDelayed;
+ salhelper::QueueBase< rtl::Reference<future_type> > m_aPresent;
+
+ /** Not implemented.
+ */
+ SALHELPER_COPYCTOR_API(FutureQueue<element_type>);
+
+public:
+ /** Construction.
+ */
+ inline FutureQueue()
+ {}
+
+ /** Destruction.
+ */
+ inline ~FutureQueue()
+ {}
+
+ /** Enqueue element at queue tail.
+ */
+ inline void put (const element_type& element)
+ {
+ osl::MutexGuard aGuard (*this);
+
+ rtl::Reference<future_type> xFuture (m_aDelayed.get());
+ if (!xFuture.is())
+ {
+ xFuture = new future_type();
+ m_aPresent.put (xFuture);
+ }
+ xFuture->set (element);
+ }
+
+ /** Dequeue a future to element at queue head.
+ */
+ inline rtl::Reference< salhelper::Future<element_type> > get()
+ {
+ osl::MutexGuard aGuard (*this);
+
+ rtl::Reference<future_type> xFuture (m_aPresent.get());
+ if (!xFuture.is())
+ {
+ xFuture = new future_type();
+ m_aDelayed.put (xFuture);
+ }
+ return (xFuture);
+ }
+};
+
+//----------------------------------------------------------------------------
+
+} // namespace salhelper
+
+#endif /* !_SALHELPER_FUTUREQUEUE */
diff --git a/salhelper/inc/salhelper/monitor.hxx b/salhelper/inc/salhelper/monitor.hxx
new file mode 100644
index 000000000000..5c683d386570
--- /dev/null
+++ b/salhelper/inc/salhelper/monitor.hxx
@@ -0,0 +1,288 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SALHELPER_MONITOR_HXX_
+#define _SALHELPER_MONITOR_HXX_
+
+#include <sal/types.h>
+#include <osl/conditn.hxx>
+#include <osl/diagnose.h>
+#include <osl/interlck.h>
+#include <rtl/ref.hxx>
+#include <salhelper/refobj.hxx>
+#include <salhelper/future.hxx>
+#include <salhelper/futurequeue.hxx>
+
+namespace salhelper
+{
+
+//----------------------------------------------------------------------------
+
+#ifndef SALHELPER_COPYCTOR_API
+#define SALHELPER_COPYCTOR_API(C) C (const C&); C& operator= (const C&)
+#endif
+
+//----------------------------------------------------------------------------
+
+class MonitorCondition : protected osl::Condition
+{
+ /** Representation.
+ */
+ oslInterlockedCount m_nReferenceCount;
+
+ /** Not implemented.
+ */
+ SALHELPER_COPYCTOR_API(MonitorCondition);
+
+public:
+ /** Construction.
+ */
+ inline MonitorCondition() SAL_THROW(()) : m_nReferenceCount (0)
+ {
+ Condition::set();
+ }
+
+ /** Destruction.
+ */
+ inline ~MonitorCondition() SAL_THROW(())
+ {
+ OSL_ASSERT(m_nReferenceCount == 0);
+ }
+
+ /** Acquire or enter the monitor.
+ */
+ inline void acquire() SAL_THROW(())
+ {
+ if (osl_incrementInterlockedCount (&m_nReferenceCount) == 1)
+ {
+ Condition::reset();
+ }
+ }
+
+ /** Release or leave the monitor.
+ */
+ inline void release() SAL_THROW(())
+ {
+ if (osl_decrementInterlockedCount (&m_nReferenceCount) == 0)
+ {
+ Condition::set();
+ }
+ }
+
+ /** Wait until all references are released.
+ */
+ inline void wait() SAL_THROW(())
+ {
+ Condition::wait();
+ }
+};
+
+//----------------------------------------------------------------------------
+
+class QueuedReaderWriterMonitor : public salhelper::ReferenceObject
+{
+ /** Representation.
+ */
+ typedef salhelper::Future<sal_Int32> future_type;
+
+ salhelper::FutureQueue<sal_Int32> m_aQueue;
+ salhelper::MonitorCondition m_aMonitor;
+
+ /** Not implemented.
+ */
+ SALHELPER_COPYCTOR_API(QueuedReaderWriterMonitor);
+
+public:
+ /** Construction.
+ */
+ inline QueuedReaderWriterMonitor()
+ {
+ // Insert the token.
+ m_aQueue.put(0);
+ }
+
+ /** Acquire read access.
+ */
+ inline void acquireReader()
+ {
+ // Obtain the token.
+ rtl::Reference<future_type> xFuture (m_aQueue.get());
+ xFuture->get();
+
+ // Enter the monitor.
+ m_aMonitor.acquire();
+
+ // Push back the token.
+ m_aQueue.put(0);
+ }
+
+ /** Release read access.
+ */
+ inline void releaseReader()
+ {
+ // Leave the monitor.
+ m_aMonitor.release();
+ }
+
+ /** Acquire write access.
+ */
+ inline void acquireWriter()
+ {
+ // Obtain the token.
+ rtl::Reference<future_type> xFuture (m_aQueue.get());
+ xFuture->get();
+
+ // Wait until all readers have left.
+ m_aMonitor.wait();
+ }
+
+ /** Release write access.
+ */
+ inline void releaseWriter()
+ {
+ // Push back the token.
+ m_aQueue.put(0);
+ }
+
+protected:
+ /** Destruction.
+ */
+ virtual ~QueuedReaderWriterMonitor()
+ {}
+};
+
+//----------------------------------------------------------------------------
+
+template<class monitor_type>
+class ReaderGuard
+{
+ /** Representation.
+ */
+ monitor_type *m_pMonitor;
+
+ /** Not implemented.
+ */
+ SALHELPER_COPYCTOR_API(ReaderGuard<monitor_type>);
+
+public:
+ /** Construction. Acquire monitor read access.
+ */
+ inline ReaderGuard (monitor_type & rMonitor) : m_pMonitor (&rMonitor)
+ {
+ m_pMonitor->acquireReader();
+ }
+
+ /** Construction. Acquire monitor read access.
+ */
+ inline ReaderGuard (monitor_type * pMonitor) : m_pMonitor (pMonitor)
+ {
+ OSL_PRECOND(m_pMonitor, "ReaderGuard::ReaderGuard(): No Monitor");
+ m_pMonitor->acquireReader();
+ }
+
+ /** Destruction. Release monitor read access.
+ */
+ inline ~ReaderGuard()
+ {
+ if (m_pMonitor)
+ m_pMonitor->releaseReader();
+ }
+
+ /** Release monitor read access.
+ */
+ inline void clear()
+ {
+ if (m_pMonitor)
+ {
+ m_pMonitor->releaseReader();
+ m_pMonitor = 0;
+ }
+ }
+};
+
+//----------------------------------------------------------------------------
+
+typedef ReaderGuard<QueuedReaderWriterMonitor> QueuedReaderGuard;
+
+//----------------------------------------------------------------------------
+
+template<class monitor_type>
+class WriterGuard
+{
+ /** Representation.
+ */
+ monitor_type *m_pMonitor;
+
+ /** Not implemented.
+ */
+ SALHELPER_COPYCTOR_API(WriterGuard<monitor_type>);
+
+public:
+ /** Construction. Acquire monitor write access.
+ */
+ inline WriterGuard (monitor_type & rMonitor) : m_pMonitor (&rMonitor)
+ {
+ m_pMonitor->acquireWriter();
+ }
+
+ /** Construction. Acquire monitor write access.
+ */
+ inline WriterGuard (monitor_type * pMonitor) : m_pMonitor (pMonitor)
+ {
+ OSL_PRECOND(m_pMonitor, "WriterGuard::WriterGuard(): No Monitor");
+ m_pMonitor->acquireWriter();
+ }
+
+ /** Destruction. Release monitor write access.
+ */
+ inline ~WriterGuard()
+ {
+ if (m_pMonitor)
+ m_pMonitor->releaseWriter();
+ }
+
+ /** Release monitor write access.
+ */
+ inline void clear()
+ {
+ if (m_pMonitor)
+ {
+ m_pMonitor->releaseWriter();
+ m_pMonitor = 0;
+ }
+ }
+};
+
+//----------------------------------------------------------------------------
+
+typedef WriterGuard<QueuedReaderWriterMonitor> QueuedWriterGuard;
+
+//----------------------------------------------------------------------------
+
+} // namespace salhelper
+
+#endif /* !_SALHELPER_MONITOR_HXX_ */
diff --git a/salhelper/inc/salhelper/queue.hxx b/salhelper/inc/salhelper/queue.hxx
new file mode 100644
index 000000000000..445cc5f32da1
--- /dev/null
+++ b/salhelper/inc/salhelper/queue.hxx
@@ -0,0 +1,186 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SALHELPER_QUEUE_HXX_
+#define _SALHELPER_QUEUE_HXX_
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <osl/mutex.hxx>
+#ifndef _OSL_SEMAPHOR_HXX_
+#include <osl/semaphor.hxx>
+#endif
+
+#ifndef __LIST__
+#include <list>
+#endif
+
+namespace salhelper
+{
+
+//----------------------------------------------------------------------------
+
+#ifndef SALHELPER_COPYCTOR_API
+#define SALHELPER_COPYCTOR_API(C) C (const C&); C& operator= (const C&)
+#endif
+
+//----------------------------------------------------------------------------
+
+template<class element_type>
+class QueueBase : protected std::list<element_type>
+{
+ /** Representation.
+ */
+ osl::Mutex m_aMutex;
+
+ /** Not implemented.
+ */
+ SALHELPER_COPYCTOR_API(QueueBase<element_type>);
+
+public:
+ inline QueueBase()
+ {}
+
+ inline ~QueueBase()
+ {
+ erase (this->begin(), this->end());
+ }
+
+ inline void put (const element_type& element)
+ {
+ osl::MutexGuard aGuard (m_aMutex);
+ push_back (element);
+ }
+
+ inline element_type get()
+ {
+ element_type element;
+
+ osl::MutexGuard aGuard (m_aMutex);
+ if (!this->empty())
+ {
+ element = this->front();
+ this->pop_front();
+ }
+
+ return (element);
+ }
+};
+
+//----------------------------------------------------------------------------
+
+/** Queue.
+
+ @deprecated
+ Must not be used, as it internally uses unnamed semaphores, which are not
+ supported on Mac OS X.
+*/
+template<class element_type>
+class Queue : protected QueueBase<element_type>
+{
+ /** Representation.
+ */
+ osl::Semaphore m_aNotEmpty;
+
+ /** Not implemented.
+ */
+ SALHELPER_COPYCTOR_API(Queue<element_type>);
+
+public:
+ inline Queue() : m_aNotEmpty (static_cast< sal_uInt32 >(0))
+ {}
+
+ inline ~Queue()
+ {}
+
+ inline void put (const element_type& element)
+ {
+ QueueBase<element_type>::put (element);
+ m_aNotEmpty.release();
+ }
+
+ inline element_type get()
+ {
+ element_type element;
+
+ m_aNotEmpty.acquire();
+ element = QueueBase<element_type>::get();
+
+ return (element);
+ }
+};
+
+//----------------------------------------------------------------------------
+
+/** Bounded queue.
+
+ @deprecated
+ Must not be used, as it internally uses unnamed semaphores, which are not
+ supported on Mac OS X.
+*/
+template<class element_type>
+class BoundedQueue : protected Queue<element_type>
+{
+ /** Representation.
+ */
+ osl::Semaphore m_aNotFull;
+
+ /** Not implemented.
+ */
+ SALHELPER_COPYCTOR_API(BoundedQueue<element_type>);
+
+public:
+ inline BoundedQueue (sal_uInt32 capacity) : m_aNotFull (capacity)
+ {
+ OSL_POSTCOND(capacity, "BoundedQueue:BoundedQueue(): no capacity");
+ }
+
+ inline ~BoundedQueue()
+ {}
+
+ inline void put (const element_type& element)
+ {
+ m_aNotFull.acquire();
+ Queue<element_type>::put (element);
+ }
+
+ inline element_type get()
+ {
+ element_type element;
+
+ element = Queue<element_type>::get();
+ m_aNotFull.release();
+
+ return (element);
+ }
+};
+
+//----------------------------------------------------------------------------
+
+} // namespace salhelper
+
+#endif /* !_SALHELPER_QUEUE_HXX_ */
diff --git a/salhelper/inc/salhelper/refobj.hxx b/salhelper/inc/salhelper/refobj.hxx
new file mode 100644
index 000000000000..a1851eb84259
--- /dev/null
+++ b/salhelper/inc/salhelper/refobj.hxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SALHELPER_REFOBJ_HXX_
+#define _SALHELPER_REFOBJ_HXX_
+
+#include <sal/types.h>
+#include <rtl/alloc.h>
+#include <rtl/ref.hxx>
+#include <osl/diagnose.h>
+#include <osl/interlck.h>
+
+namespace salhelper
+{
+
+//----------------------------------------------------------------------------
+
+class ReferenceObject : public rtl::IReference
+{
+ /** Representation.
+ */
+ oslInterlockedCount m_nReferenceCount;
+
+ /** Not implemented.
+ */
+ ReferenceObject (const ReferenceObject&);
+ ReferenceObject& operator= (const ReferenceObject&);
+
+public:
+ /** Allocation.
+ */
+ static void* operator new (size_t n) SAL_THROW(())
+ {
+ return ::rtl_allocateMemory (n);
+ }
+ static void operator delete (void* p) SAL_THROW(())
+ {
+ ::rtl_freeMemory (p);
+ }
+ static void* operator new (size_t, void* p) SAL_THROW(())
+ {
+ return (p);
+ }
+ static void operator delete (void*, void*) SAL_THROW(())
+ {}
+
+public:
+ /** Construction.
+ */
+ inline ReferenceObject() SAL_THROW(()) : m_nReferenceCount (0)
+ {}
+
+
+ /** IReference.
+ */
+ virtual oslInterlockedCount SAL_CALL acquire() SAL_THROW(())
+ {
+ return ::osl_incrementInterlockedCount (&m_nReferenceCount);
+ }
+
+ virtual oslInterlockedCount SAL_CALL release() SAL_THROW(())
+ {
+ oslInterlockedCount result;
+ result = ::osl_decrementInterlockedCount (&m_nReferenceCount);
+ if (result == 0)
+ {
+ // Last reference released.
+ delete this;
+ }
+ return (result);
+ }
+
+protected:
+ /** Destruction.
+ */
+ virtual ~ReferenceObject() SAL_THROW(())
+ {
+ OSL_ASSERT(m_nReferenceCount == 0);
+ }
+};
+
+//----------------------------------------------------------------------------
+
+} // namespace salhelper
+
+#endif /* !_SALHELPER_REFOBJ_HXX_ */
diff --git a/salhelper/inc/salhelper/simplereferenceobject.hxx b/salhelper/inc/salhelper/simplereferenceobject.hxx
new file mode 100755
index 000000000000..4d2c60b733aa
--- /dev/null
+++ b/salhelper/inc/salhelper/simplereferenceobject.hxx
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SALHELPER_SIMPLEREFERENCEOBJECT_HXX_
+#define _SALHELPER_SIMPLEREFERENCEOBJECT_HXX_
+
+#include "osl/interlck.h"
+#include "sal/types.h"
+
+#ifndef INCLUDED_CSTDDEF
+#include <cstddef>
+#define INCLUDED_CSTDDEF
+#endif
+#ifndef INCLUDED_NEW
+#include <new>
+#define INCLUDED_NEW
+#endif
+
+namespace salhelper {
+
+/** A simple base implementation for reference-counted objects.
+
+ Classes that want to implement a reference-counting mechanism based on the
+ acquire()/release() interface should derive from this class.
+
+ The reason to have class local operators new and delete here is technical.
+ Imagine a class D derived from SimpleReferenceObject, but implemented in
+ another shared library that happens to use different global operators new
+ and delete from those used in this shared library (which, sadly, seems to
+ be possible with shared libraries). Now, without the class local
+ operators new and delete here, a code sequence like "new D" would use the
+ global operator new as found in the other shared library, while the code
+ sequence "delete this" in release() would use the global operator delete
+ as found in this shared library---and these two operators would not be
+ guaranteed to match.
+
+ There are no overloaded operators new and delete for placement new here,
+ because it is felt that the concept of placement new does not work well
+ with the concept of reference-counted objects; so it seems best to simply
+ leave those operators out.
+
+ The same problem as with operators new and delete would also be there with
+ operators new[] and delete[]. But since arrays of reference-counted
+ objects are of no use, anyway, it seems best to simply declare and not
+ define (private) operators new[] and delete[].
+ */
+class SimpleReferenceObject
+{
+public:
+ inline SimpleReferenceObject() SAL_THROW(()): m_nCount(0) {}
+
+ /** @ATTENTION
+ The results are undefined if, for any individual instance of
+ SimpleReferenceObject, the total number of calls to acquire() exceeds
+ the total number of calls to release() by a plattform dependent amount
+ (which, hopefully, is quite large).
+ */
+ inline void acquire() SAL_THROW(())
+ { osl_incrementInterlockedCount(&m_nCount); }
+
+ inline void release() SAL_THROW(())
+ { if (osl_decrementInterlockedCount(&m_nCount) == 0) delete this; }
+
+ /** see general class documentation
+ */
+ static void * operator new(std::size_t nSize) SAL_THROW((std::bad_alloc));
+
+ /** see general class documentation
+ */
+ static void * operator new(std::size_t nSize,
+ std::nothrow_t const & rNothrow)
+ SAL_THROW(());
+
+ /** see general class documentation
+ */
+ static void operator delete(void * pPtr) SAL_THROW(());
+
+ /** see general class documentation
+ */
+ static void operator delete(void * pPtr, std::nothrow_t const & rNothrow)
+ SAL_THROW(());
+
+protected:
+ virtual ~SimpleReferenceObject() SAL_THROW(());
+
+private:
+ oslInterlockedCount m_nCount;
+
+ /** not implemented
+ @internal
+ */
+ SimpleReferenceObject(SimpleReferenceObject &);
+
+ /** not implemented
+ @internal
+ */
+ void operator =(SimpleReferenceObject);
+
+ /** not implemented (see general class documentation)
+ @internal
+ */
+ static void * operator new[](std::size_t);
+
+ /** not implemented (see general class documentation)
+ @internal
+ */
+ static void operator delete[](void * pPtr);
+};
+
+}
+
+#endif // _SALHELPER_SIMPLEREFERENCEOBJECT_HXX_
diff --git a/salhelper/inc/salhelper/singletonref.hxx b/salhelper/inc/salhelper/singletonref.hxx
new file mode 100644
index 000000000000..9a62be5dfe92
--- /dev/null
+++ b/salhelper/inc/salhelper/singletonref.hxx
@@ -0,0 +1,210 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SALHELPER_SINGLETONREF_HXX_
+#define _SALHELPER_SINGLETONREF_HXX_
+
+//_______________________________________________
+// includes
+
+#include <osl/mutex.hxx>
+#include "rtl/instance.hxx"
+#include "osl/diagnose.h"
+#include "osl/getglobalmutex.hxx"
+
+//_______________________________________________
+// namespace
+
+namespace salhelper{
+
+//_______________________________________________
+// definitions
+
+/** @short template for implementing singleton classes.
+
+ @descr Such classes can be instanciated everytimes they
+ are needed. But the internal wrapped object will
+ be created one times only. Of course its used
+ resources are referenced one times only too.
+ This template hold it alive till the last
+ reference is gone. Further all operations
+ on this reference are threadsafe. Only
+ calls directly to the internal object (which modify
+ its state) must be made threadsafe by the object itself
+ or from outside.
+
+ @attention To prevent the code against race conditions, its not
+ allowed to start operations inside the ctor
+ of the internal wrapped object - especialy operations
+ which needs a reference to the same singleton too.
+
+ The only chance to supress such strange constellations
+ is a lazy-init mechanism.
+
+ <ul>
+ <li>a) The singleton class can provide a special init()
+ method, which must be called as first after creation.</li>
+ <li>b) The singleton class can call a special impl_init()
+ method implicit for every called interface method.</li>
+ </ul>
+
+ Note further that this singleton pattern can work only, if
+ all user of such singleton are located inside the same library!
+ Because static values cant be exported - e.g. from windows libraries.
+ */
+template< class SingletonClass >
+class SingletonRef
+{
+ //-------------------------------------------
+ // member
+
+ private :
+
+ /** @short pointer to the internal wrapped singleton. */
+ static SingletonClass* m_pInstance;
+
+ /** @short ref count, which regulate creation and removing of m_pInstance. */
+ static sal_Int32 m_nRef;
+
+ //-------------------------------------------
+ // interface
+
+ public :
+
+ //---------------------------------------
+
+ /** @short standard ctor.
+
+ @descr The internal wrapped object is created only,
+ if its ref count was 0. Otherwhise this method
+ does nothing ... except increasing of the internal
+ ref count!
+ */
+ SingletonRef()
+ {
+ // GLOBAL SAFE ->
+ ::osl::MutexGuard aLock(SingletonRef::ownStaticLock());
+
+ // must be increased before(!) the check is done.
+ // Otherwhise this check can fail inside the same thread ...
+ ++m_nRef;
+ if (m_nRef == 1)
+ m_pInstance = new SingletonClass();
+
+ OSL_ENSURE(m_nRef>0 && m_pInstance, "Race? Ref count of singleton >0, but instance is NULL!");
+ // <- GLOBAL SAFE
+ }
+
+ //---------------------------------------
+
+ /** @short standard dtor.
+
+ @descr The internal wrapped object is removed only,
+ if its ref count wil be 0. Otherwhise this method
+ does nothing ... except decreasing of the internal
+ ref count!
+ */
+ ~SingletonRef()
+ {
+ // GLOBAL SAFE ->
+ ::osl::MutexGuard aLock(SingletonRef::ownStaticLock());
+
+ // must be decreased before(!) the check is done.
+ // Otherwhise this check can fail inside the same thread ...
+ --m_nRef;
+ if (m_nRef == 0)
+ {
+ delete m_pInstance;
+ m_pInstance = 0;
+ }
+ // <- GLOBAL SAFE
+ }
+
+ //---------------------------------------
+
+ /** @short Allows rSingle->someBodyOp().
+ */
+ SingletonClass* operator->() const
+ {
+ // GLOBAL SAFE ->
+ ::osl::MutexGuard aLock(SingletonRef::ownStaticLock());
+ return m_pInstance;
+ // <- GLOBAL SAFE
+ }
+
+ //---------------------------------------
+
+ /** @short Allows (*rSingle).someBodyOp().
+ */
+ SingletonClass& operator*() const
+ {
+ // GLOBAL SAFE ->
+ ::osl::MutexGuard aLock(SingletonRef::ownStaticLock());
+ return *m_pInstance;
+ // <- GLOBAL SAFE
+ }
+
+ //-------------------------------------------
+ // helper
+
+ private :
+
+ //---------------------------------------
+
+ /** @short creates an own mutex for guarding static contents.
+
+ @descr The global mutex the osl library is used one times
+ only to create an own static mutex, which can be used
+ next time to guard own static member operations.
+ */
+ struct SingletonLockInit
+ {
+ ::osl::Mutex* operator()()
+ {
+ static ::osl::Mutex aInstance;
+ return &aInstance;
+ }
+ };
+
+ ::osl::Mutex& ownStaticLock() const
+ {
+ return *rtl_Instance< ::osl::Mutex,
+ SingletonLockInit,
+ ::osl::MutexGuard,
+ ::osl::GetGlobalMutex >::create(SingletonLockInit(), ::osl::GetGlobalMutex());
+ }
+};
+
+template< class SingletonClass >
+SingletonClass* SingletonRef< SingletonClass >::m_pInstance = 0;
+
+template< class SingletonClass >
+sal_Int32 SingletonRef< SingletonClass >::m_nRef = 0;
+
+} // namespace salhelper
+
+#endif // _SALHELPER_SINGLETONREF_HXX_
diff --git a/salhelper/prj/build.lst b/salhelper/prj/build.lst
new file mode 100644
index 000000000000..9a21849507ff
--- /dev/null
+++ b/salhelper/prj/build.lst
@@ -0,0 +1,3 @@
+shp salhelper : sal NULL
+shp salhelper usr1 - all shp_mkout NULL
+shp salhelper\source nmake - all shp_source NULL
diff --git a/salhelper/prj/d.lst b/salhelper/prj/d.lst
new file mode 100644
index 000000000000..9cf9e3ad8ebb
--- /dev/null
+++ b/salhelper/prj/d.lst
@@ -0,0 +1,21 @@
+mkdir: %_DEST%\inc%_EXT%\salhelper
+
+..\inc\salhelper\condition.hxx %_DEST%\inc%_EXT%\salhelper\condition.hxx
+..\inc\salhelper\dynload.hxx %_DEST%\inc%_EXT%\salhelper\dynload.hxx
+..\inc\salhelper\future.hxx %_DEST%\inc%_EXT%\salhelper\future.hxx
+..\inc\salhelper\futurequeue.hxx %_DEST%\inc%_EXT%\salhelper\futurequeue.hxx
+..\inc\salhelper\monitor.hxx %_DEST%\inc%_EXT%\salhelper\monitor.hxx
+..\inc\salhelper\queue.hxx %_DEST%\inc%_EXT%\salhelper\queue.hxx
+..\inc\salhelper\refobj.hxx %_DEST%\inc%_EXT%\salhelper\refobj.hxx
+..\inc\salhelper\simplereferenceobject.hxx %_DEST%\inc%_EXT%\salhelper\simplereferenceobject.hxx
+..\inc\salhelper\singletonref.hxx %_DEST%\inc%_EXT%\salhelper\singletonref.hxx
+
+..\%__SRC%\bin\salhelp*.dll %_DEST%\bin%_EXT%\salhelp*.dll
+..\%__SRC%\lib\*salhelper*.lib %_DEST%\lib%_EXT%\*
+
+..\%__SRC%\lib\libuno_salhelper*.*.* %_DEST%\lib%_EXT%\*
+
+..\%__SRC%\lib\libsalhelper*.a %_DEST%\lib%_EXT%\*
+..\%__SRC%\lib\salhelper*.lib %_DEST%\lib%_EXT%\*
+
+linklib: libuno_salhelper*.*.*
diff --git a/salhelper/qa/makefile.mk b/salhelper/qa/makefile.mk
new file mode 100644
index 000000000000..fe2aff7453be
--- /dev/null
+++ b/salhelper/qa/makefile.mk
@@ -0,0 +1,52 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ := ..
+PRJNAME := salhelper
+TARGET := qa
+
+ENABLE_EXCEPTIONS := TRUE
+
+.INCLUDE: settings.mk
+
+CFLAGSCXX += $(CPPUNIT_CFLAGS)
+
+SHL1TARGET = $(TARGET)
+SHL1OBJS = $(SLO)$/test_api.obj
+SHL1STDLIBS = $(CPPUNITLIB) $(SALLIB) $(SALHELPERLIB) $(TESTSHL2LIB)
+SHL1IMPLIB = i$(SHL1TARGET)
+SHL1VERSIONMAP = version.map
+DEF1NAME = $(SHL1TARGET)
+
+SLOFILES = $(SHL1OBJS)
+
+.INCLUDE: target.mk
+
+ALLTAR: test
+
+test .PHONY: $(SHL1TARGETN)
+ cd $(SHL1TARGETN:d) && $(TESTSHL2) $(SHL1TARGETN:f)
diff --git a/salhelper/qa/test_api.cxx b/salhelper/qa/test_api.cxx
new file mode 100644
index 000000000000..fff66f8d1cd2
--- /dev/null
+++ b/salhelper/qa/test_api.cxx
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sal/config.h"
+
+#include <typeinfo>
+
+namespace salhelper {
+ class Condition;
+ class ConditionModifier;
+ class ConditionWaiter;
+ class ORealDynamicLoader;
+ class SimpleReferenceObject;
+}
+
+namespace {
+
+std::type_info const & getConditionTypeInfo()
+{ return typeid (salhelper::Condition *); }
+
+std::type_info const & getConditionModifierTypeInfo()
+{ return typeid (salhelper::ConditionModifier *); }
+
+std::type_info const & getConditionWaiterTypeInfo()
+{ return typeid (salhelper::ConditionWaiter *); }
+
+std::type_info const & getORealDynamicLoaderTypeInfo()
+{ return typeid (salhelper::ORealDynamicLoader *); }
+
+std::type_info const & getSimpleReferenceObjectTypeInfo()
+{ return typeid (salhelper::SimpleReferenceObject *); }
+
+}
+
+#include "testshl/simpleheader.hxx"
+#include "osl/mutex.hxx"
+#include "salhelper/condition.hxx"
+#include "salhelper/dynload.hxx"
+#include "salhelper/simplereferenceobject.hxx"
+
+#include <memory>
+
+namespace {
+
+class DerivedCondition: public salhelper::Condition {
+public:
+ explicit DerivedCondition(osl::Mutex & mutex): Condition(mutex) {}
+
+protected:
+ virtual bool applies() const { return false; }
+};
+
+class DerivedConditionWaiterTimedout:
+ public salhelper::ConditionWaiter::timedout
+{};
+
+class DerivedSimpleReferenceObject: public salhelper::SimpleReferenceObject {};
+
+class Test: public CppUnit::TestFixture {
+public:
+ void testCondition();
+
+ void testConditionModifier();
+
+ void testConditionWaiter();
+
+ void testConditionWaiterTimedout();
+
+ void testORealDynamicLoader();
+
+ void testSimpleReferenceObject();
+
+ void testDerivedCondition();
+
+ void testDerivedConditionWaiterTimedout();
+
+ void testDerivedSimpleReferenceObject();
+
+ CPPUNIT_TEST_SUITE(Test);
+ CPPUNIT_TEST(testCondition);
+ CPPUNIT_TEST(testConditionModifier);
+ CPPUNIT_TEST(testConditionWaiter);
+ CPPUNIT_TEST(testConditionWaiterTimedout);
+ CPPUNIT_TEST(testORealDynamicLoader);
+ CPPUNIT_TEST(testSimpleReferenceObject);
+ CPPUNIT_TEST(testDerivedCondition);
+ CPPUNIT_TEST(testDerivedConditionWaiterTimedout);
+ CPPUNIT_TEST(testDerivedSimpleReferenceObject);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void Test::testCondition() {
+ osl::Mutex mutex;
+ std::auto_ptr< salhelper::Condition > p(new DerivedCondition(mutex));
+ CPPUNIT_ASSERT(typeid (*p.get()) != typeid (salhelper::Condition));
+ CPPUNIT_ASSERT(typeid (p.get()) == typeid (salhelper::Condition *));
+ CPPUNIT_ASSERT(
+ typeid (const_cast< salhelper::Condition const * >(p.get()))
+ == typeid (salhelper::Condition const *));
+ CPPUNIT_ASSERT(
+ typeid (const_cast< salhelper::Condition volatile * >(p.get()))
+ == typeid (salhelper::Condition volatile *));
+ CPPUNIT_ASSERT(typeid (salhelper::Condition *) == getConditionTypeInfo());
+}
+
+void Test::testConditionModifier() {
+ salhelper::ConditionModifier * p = 0;
+ CPPUNIT_ASSERT(typeid (*p) == typeid (salhelper::ConditionModifier));
+ CPPUNIT_ASSERT(typeid (p) == typeid (salhelper::ConditionModifier *));
+ CPPUNIT_ASSERT(
+ typeid (const_cast< salhelper::ConditionModifier const * >(p))
+ == typeid (salhelper::ConditionModifier const *));
+ CPPUNIT_ASSERT(
+ typeid (const_cast< salhelper::ConditionModifier volatile * >(p))
+ == typeid (salhelper::ConditionModifier volatile *));
+ CPPUNIT_ASSERT(
+ typeid (salhelper::ConditionModifier *)
+ == getConditionModifierTypeInfo());
+}
+
+void Test::testConditionWaiter() {
+ salhelper::ConditionWaiter * p = 0;
+ CPPUNIT_ASSERT(typeid (*p) == typeid (salhelper::ConditionWaiter));
+ CPPUNIT_ASSERT(typeid (p) == typeid (salhelper::ConditionWaiter *));
+ CPPUNIT_ASSERT(
+ typeid (const_cast< salhelper::ConditionWaiter const * >(p))
+ == typeid (salhelper::ConditionWaiter const *));
+ CPPUNIT_ASSERT(
+ typeid (const_cast< salhelper::ConditionWaiter volatile * >(p))
+ == typeid (salhelper::ConditionWaiter volatile *));
+ CPPUNIT_ASSERT(
+ typeid (salhelper::ConditionWaiter *) == getConditionWaiterTypeInfo());
+}
+
+void Test::testConditionWaiterTimedout() {
+ salhelper::ConditionWaiter::timedout x;
+ CPPUNIT_ASSERT(typeid (x) == typeid (salhelper::ConditionWaiter::timedout));
+ CPPUNIT_ASSERT(
+ typeid (&x) == typeid (salhelper::ConditionWaiter::timedout *));
+ CPPUNIT_ASSERT(
+ typeid (const_cast< salhelper::ConditionWaiter::timedout const * >(&x))
+ == typeid (salhelper::ConditionWaiter::timedout const *));
+ CPPUNIT_ASSERT(
+ (typeid
+ (const_cast< salhelper::ConditionWaiter::timedout volatile * >(&x)))
+ == typeid (salhelper::ConditionWaiter::timedout volatile *));
+ try {
+ throw salhelper::ConditionWaiter::timedout();
+ } catch (salhelper::ConditionWaiter::timedout &) {
+ } catch (...) {
+ CPPUNIT_FAIL("not caught");
+ }
+}
+
+void Test::testORealDynamicLoader() {
+ salhelper::ORealDynamicLoader * p = 0;
+ CPPUNIT_ASSERT(typeid (p) != typeid (salhelper::ORealDynamicLoader));
+ CPPUNIT_ASSERT(typeid (p) == typeid (salhelper::ORealDynamicLoader *));
+ CPPUNIT_ASSERT(
+ typeid (const_cast< salhelper::ORealDynamicLoader const * >(p))
+ == typeid (salhelper::ORealDynamicLoader const *));
+ CPPUNIT_ASSERT(
+ typeid (const_cast< salhelper::ORealDynamicLoader volatile * >(p))
+ == typeid (salhelper::ORealDynamicLoader volatile *));
+ CPPUNIT_ASSERT(
+ typeid (salhelper::ORealDynamicLoader *)
+ == getORealDynamicLoaderTypeInfo());
+}
+
+void Test::testSimpleReferenceObject() {
+ salhelper::SimpleReferenceObject * p = new DerivedSimpleReferenceObject;
+ try {
+ CPPUNIT_ASSERT(
+ typeid (*p) != typeid (salhelper::SimpleReferenceObject));
+ CPPUNIT_ASSERT(
+ typeid (p) == typeid (salhelper::SimpleReferenceObject *));
+ CPPUNIT_ASSERT(
+ typeid (const_cast< salhelper::SimpleReferenceObject const * >(p))
+ == typeid (salhelper::SimpleReferenceObject const *));
+ CPPUNIT_ASSERT(
+ (typeid
+ (const_cast< salhelper::SimpleReferenceObject volatile * >(p)))
+ == typeid (salhelper::SimpleReferenceObject volatile *));
+ CPPUNIT_ASSERT(
+ typeid (salhelper::SimpleReferenceObject *)
+ == getSimpleReferenceObjectTypeInfo());
+ } catch (...) {
+ delete static_cast< DerivedSimpleReferenceObject * >(p);
+ throw;
+ }
+}
+
+void Test::testDerivedCondition() {
+ osl::Mutex mutex;
+ std::auto_ptr< salhelper::Condition > p(new DerivedCondition(mutex));
+ CPPUNIT_ASSERT(dynamic_cast< DerivedCondition * >(p.get()) != 0);
+}
+
+void Test::testDerivedConditionWaiterTimedout() {
+ std::auto_ptr< salhelper::ConditionWaiter::timedout > p(
+ new DerivedConditionWaiterTimedout);
+ CPPUNIT_ASSERT(
+ dynamic_cast< DerivedConditionWaiterTimedout * >(p.get()) != 0);
+ try {
+ throw DerivedConditionWaiterTimedout();
+ } catch (salhelper::ConditionWaiter::timedout &) {
+ } catch (...) {
+ CPPUNIT_FAIL("not caught");
+ }
+}
+
+void Test::testDerivedSimpleReferenceObject() {
+ salhelper::SimpleReferenceObject * p = new DerivedSimpleReferenceObject;
+ try {
+ CPPUNIT_ASSERT(dynamic_cast< DerivedSimpleReferenceObject * >(p) != 0);
+ } catch (...) {
+ delete static_cast< DerivedSimpleReferenceObject * >(p);
+ throw;
+ }
+}
+
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test, "alltests");
+
+}
+
+NOADDITIONAL;
diff --git a/salhelper/qa/version.map b/salhelper/qa/version.map
new file mode 100755
index 000000000000..de41d83b562b
--- /dev/null
+++ b/salhelper/qa/version.map
@@ -0,0 +1,6 @@
+UDK_3_0_0 {
+ global:
+ registerAllTestFunction;
+ local:
+ *;
+};
diff --git a/salhelper/source/condition.cxx b/salhelper/source/condition.cxx
new file mode 100644
index 000000000000..87f0c2e50509
--- /dev/null
+++ b/salhelper/source/condition.cxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include <salhelper/condition.hxx>
+#include <osl/time.h>
+
+
+using namespace salhelper;
+
+
+/******************************************************************
+ * *
+ * Condition *
+ * *
+ ******************************************************************/
+
+Condition::Condition(osl::Mutex& aMutex)
+ : m_aMutex(aMutex),
+ m_aCondition(osl_createCondition())
+{
+}
+
+
+Condition::~Condition()
+{
+ osl_destroyCondition(m_aCondition);
+}
+
+
+/******************************************************************
+ * *
+ * ConditionModifier *
+ * *
+ ******************************************************************/
+
+ConditionModifier::ConditionModifier(Condition& aCond)
+ : m_aCond(aCond)
+{
+ m_aCond.m_aMutex.acquire();
+}
+
+
+ConditionModifier::~ConditionModifier()
+{
+ if(m_aCond.applies())
+ osl_setCondition(m_aCond.m_aCondition);
+
+ m_aCond.m_aMutex.release();
+}
+
+
+
+/******************************************************************
+ * *
+ * ConditionWaiter *
+ * *
+ ******************************************************************/
+
+ConditionWaiter::timedout::timedout() {}
+
+ConditionWaiter::timedout::timedout(timedout const &) {}
+
+ConditionWaiter::timedout::~timedout() {}
+
+ConditionWaiter::timedout &
+ConditionWaiter::timedout::operator =(timedout const &) { return *this; }
+
+ConditionWaiter::ConditionWaiter(Condition& aCond)
+ : m_aCond(aCond)
+{
+ while(true) {
+ osl_waitCondition(m_aCond.m_aCondition,0);
+ m_aCond.m_aMutex.acquire();
+
+ if(m_aCond.applies())
+ break;
+ else {
+ osl_resetCondition(m_aCond.m_aCondition);
+ m_aCond.m_aMutex.release();
+ }
+ }
+}
+
+
+ConditionWaiter::ConditionWaiter(Condition& aCond,sal_uInt32 milliSec)
+ throw(
+ ConditionWaiter::timedout
+ )
+ : m_aCond(aCond)
+{
+ TimeValue aTime;
+ aTime.Seconds = milliSec / 1000;
+ aTime.Nanosec = 1000000 * ( milliSec % 1000 );
+
+ while(true) {
+ if( osl_waitCondition(m_aCond.m_aCondition,&aTime) ==
+ osl_cond_result_timeout )
+ throw timedout();
+
+ m_aCond.m_aMutex.acquire();
+
+ if(m_aCond.applies())
+ break;
+ else {
+ osl_resetCondition(m_aCond.m_aCondition);
+ m_aCond.m_aMutex.release();
+ }
+ }
+}
+
+
+ConditionWaiter::~ConditionWaiter()
+{
+ if(! m_aCond.applies())
+ osl_resetCondition(m_aCond.m_aCondition);
+ m_aCond.m_aMutex.release();
+}
diff --git a/salhelper/source/dynload.cxx b/salhelper/source/dynload.cxx
new file mode 100644
index 000000000000..09a228719286
--- /dev/null
+++ b/salhelper/source/dynload.cxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <salhelper/dynload.hxx>
+#include <rtl/ustrbuf.hxx>
+
+namespace salhelper
+{
+
+typedef void* (SAL_CALL *ApiInitFunction) (void);
+
+ORealDynamicLoader::ORealDynamicLoader(ORealDynamicLoader ** ppSetToZeroInDestructor_,
+ const rtl::OUString& moduleName,
+ const rtl::OUString& initFunction,
+ void* pApi,
+ oslModule pModule)
+ : m_pApi(pApi)
+ , m_refCount(1)
+ , m_pModule(pModule)
+ , m_strModuleName(moduleName)
+ , m_strInitFunction(initFunction)
+ , ppSetToZeroInDestructor( ppSetToZeroInDestructor_ )
+{
+}
+
+ORealDynamicLoader* ORealDynamicLoader::newInstance(ORealDynamicLoader ** ppSetToZeroInDestructor,
+ const rtl::OUString& moduleName,
+ const rtl::OUString& initFunction)
+{
+ ApiInitFunction initFunc;
+ oslModule pModule = osl_loadModule(moduleName.pData, SAL_LOADMODULE_DEFAULT);
+
+ if ( !pModule )
+ {
+ return NULL;
+ }
+
+ initFunc = (ApiInitFunction)osl_getFunctionSymbol(
+ pModule, initFunction.pData);
+
+ if ( !initFunc )
+ {
+ osl_unloadModule(pModule);
+ return NULL;
+ }
+
+ return(new ORealDynamicLoader(ppSetToZeroInDestructor, moduleName,
+ initFunction,
+ initFunc(),
+ pModule));
+}
+
+ORealDynamicLoader::~ORealDynamicLoader()
+{
+ // set the address to zero
+ if( ppSetToZeroInDestructor )
+ *ppSetToZeroInDestructor = 0;
+
+ if (m_pModule)
+ {
+ osl_unloadModule(m_pModule);
+ m_pModule = NULL;
+ }
+}
+
+sal_uInt32 ORealDynamicLoader::acquire()
+{
+ return ++m_refCount;
+}
+
+sal_uInt32 ORealDynamicLoader::release()
+{
+ sal_uInt32 nRet = --m_refCount;
+ if( nRet == 0 )
+ delete this;
+ return nRet;
+}
+
+
+void* ORealDynamicLoader::getApi() const
+{
+ return m_pApi;
+}
+
+} // namespace salhelper
+
diff --git a/salhelper/source/gcc3.map b/salhelper/source/gcc3.map
new file mode 100644
index 000000000000..cfd3b7e40bf2
--- /dev/null
+++ b/salhelper/source/gcc3.map
@@ -0,0 +1,73 @@
+UDK_3_0_0 { # should have been UDK_3.0
+ global:
+ GetVersionInfo;
+ _ZN9salhelper18ORealDynamicLoader11newInstanceEPPS0_RKN3rtl8OUStringES6_;
+ _ZN9salhelper18ORealDynamicLoader7acquireEv;
+ _ZN9salhelper18ORealDynamicLoader7releaseEv;
+ _ZN9salhelper18ORealDynamicLoaderC1EPPS0_RKN3rtl8OUStringES6_PvS7_;
+ _ZN9salhelper18ORealDynamicLoaderC2EPPS0_RKN3rtl8OUStringES6_PvS7_;
+ _ZN9salhelper18ORealDynamicLoaderD0Ev;
+ _ZN9salhelper18ORealDynamicLoaderD1Ev;
+ _ZN9salhelper18ORealDynamicLoaderD2Ev;
+ _ZN9salhelper21SimpleReferenceObjectD0Ev;
+ _ZN9salhelper21SimpleReferenceObjectD1Ev;
+ _ZN9salhelper21SimpleReferenceObjectD2Ev;
+ _ZN9salhelper21SimpleReferenceObjectdlEPv;
+
+ # Introducing a question mark at the end because of
+ # marginal type discrepancy there is a difference in the
+ # mangled name between Linux and Mac OS X, see #i69351#
+ _ZN9salhelper21SimpleReferenceObjectnwE?; # salhelper::SimpleReferenceObject::operator new (std::size_t)
+
+ _ZNK9salhelper18ORealDynamicLoader6getApiEv;
+ # _ZTIN9salhelper18ORealDynamicLoaderE;
+ # _ZTSN9salhelper18ORealDynamicLoaderE;
+ _ZTVN9salhelper18ORealDynamicLoaderE;
+ # _ZTIN9salhelper21SimpleReferenceObjectE;
+ # _ZTSN9salhelper21SimpleReferenceObjectE;
+ _ZTVN9salhelper21SimpleReferenceObjectE;
+
+ local:
+ *;
+};
+
+UDK_3.1 {
+ global:
+ _ZN9salhelper21SimpleReferenceObjectdlEPvRKSt9nothrow_t;
+
+ # Introducing a wildcard right in the middle because due to
+ # marginal type discrepancy there is a difference in the
+ # mangled name between Linux and Mac OS X see #i69351#
+ _ZN9salhelper21SimpleReferenceObjectnwE?RKSt9nothrow_t; # salhelper::SimpleReferenceObject::operator new (std::size_t, std::nothrow_t const&)
+
+ _ZN9salhelper9ConditionC1ERN3osl5MutexE;
+ _ZN9salhelper9ConditionC2ERN3osl5MutexE;
+ _ZN9salhelper9ConditionD0Ev;
+ _ZN9salhelper9ConditionD1Ev;
+ _ZN9salhelper9ConditionD2Ev;
+ # _ZTIN9salhelper9ConditionE;
+ # _ZTIS9salhelper9ConditionE;
+
+ _ZN9salhelper17ConditionModifierC1ERNS_9ConditionE;
+ _ZN9salhelper17ConditionModifierC2ERNS_9ConditionE;
+ _ZN9salhelper17ConditionModifierD1Ev;
+ _ZN9salhelper17ConditionModifierD2Ev;
+
+ _ZN9salhelper15ConditionWaiterC1ERNS_9ConditionE;
+ _ZN9salhelper15ConditionWaiterC1ERNS_9ConditionE?;
+ _ZN9salhelper15ConditionWaiterC2ERNS_9ConditionE;
+ _ZN9salhelper15ConditionWaiterC2ERNS_9ConditionE?;
+ _ZN9salhelper15ConditionWaiterD1Ev;
+ _ZN9salhelper15ConditionWaiterD2Ev;
+
+ _ZN9salhelper15ConditionWaiter8timedoutaSERKS1_;
+ _ZN9salhelper15ConditionWaiter8timedoutC1ERKS1_;
+ _ZN9salhelper15ConditionWaiter8timedoutC1Ev;
+ _ZN9salhelper15ConditionWaiter8timedoutC2ERKS1_;
+ _ZN9salhelper15ConditionWaiter8timedoutC2Ev;
+ _ZN9salhelper15ConditionWaiter8timedoutD0Ev;
+ _ZN9salhelper15ConditionWaiter8timedoutD1Ev;
+ _ZN9salhelper15ConditionWaiter8timedoutD2Ev;
+ # _ZTIN9salhelper15ConditionWaiter8timedoutE;
+ # _ZTSN9salhelper15ConditionWaiter8timedoutE;
+} UDK_3_0_0;
diff --git a/salhelper/source/gcc3os2.map b/salhelper/source/gcc3os2.map
new file mode 100644
index 000000000000..b3fec5d45a21
--- /dev/null
+++ b/salhelper/source/gcc3os2.map
@@ -0,0 +1,73 @@
+UDK_3_0_0 { # should have been UDK_3.0
+ global:
+ GetVersionInfo;
+ _ZN9salhelper18ORealDynamicLoader11newInstanceEPPS0_RKN3rtl8OUStringES6_;
+ _ZN9salhelper18ORealDynamicLoader7acquireEv;
+ _ZN9salhelper18ORealDynamicLoader7releaseEv;
+ _ZN9salhelper18ORealDynamicLoaderC1EPPS0_RKN3rtl8OUStringES6_PvS7_;
+ _ZN9salhelper18ORealDynamicLoaderC2EPPS0_RKN3rtl8OUStringES6_PvS7_;
+ _ZN9salhelper18ORealDynamicLoaderD0Ev;
+ _ZN9salhelper18ORealDynamicLoaderD1Ev;
+ _ZN9salhelper18ORealDynamicLoaderD2Ev;
+ _ZN9salhelper21SimpleReferenceObjectD0Ev;
+ _ZN9salhelper21SimpleReferenceObjectD1Ev;
+ _ZN9salhelper21SimpleReferenceObjectD2Ev;
+ _ZN9salhelper21SimpleReferenceObjectdlEPv;
+
+ # Introducing a question mark at the end because of
+ # marginal type discrepancy there is a difference in the
+ # mangled name between Linux and Mac OS X, see #i69351#
+ _ZN9salhelper21SimpleReferenceObjectnwEj; # salhelper::SimpleReferenceObject::operator new (std::size_t)
+
+ _ZNK9salhelper18ORealDynamicLoader6getApiEv;
+ # _ZTIN9salhelper18ORealDynamicLoaderE;
+ # _ZTSN9salhelper18ORealDynamicLoaderE;
+ _ZTVN9salhelper18ORealDynamicLoaderE;
+ # _ZTIN9salhelper21SimpleReferenceObjectE;
+ # _ZTSN9salhelper21SimpleReferenceObjectE;
+ _ZTVN9salhelper21SimpleReferenceObjectE;
+
+ local:
+ *;
+};
+
+UDK_3.1 {
+ global:
+ _ZN9salhelper21SimpleReferenceObjectdlEPvRKSt9nothrow_t;
+
+ # Introducing a wildcard right in the middle because due to
+ # marginal type discrepancy there is a difference in the
+ # mangled name between Linux and Mac OS X see #i69351#
+ _ZN9salhelper21SimpleReferenceObjectnwEjRKSt9nothrow_t; # salhelper::SimpleReferenceObject::operator new (std::size_t, std::nothrow_t const&)
+
+ _ZN9salhelper9ConditionC1ERN3osl5MutexE;
+ _ZN9salhelper9ConditionC2ERN3osl5MutexE;
+ _ZN9salhelper9ConditionD0Ev;
+ _ZN9salhelper9ConditionD1Ev;
+ _ZN9salhelper9ConditionD2Ev;
+ # _ZTIN9salhelper9ConditionE;
+ # _ZTIS9salhelper9ConditionE;
+
+ _ZN9salhelper17ConditionModifierC1ERNS_9ConditionE;
+ _ZN9salhelper17ConditionModifierC2ERNS_9ConditionE;
+ _ZN9salhelper17ConditionModifierD1Ev;
+ _ZN9salhelper17ConditionModifierD2Ev;
+
+ _ZN9salhelper15ConditionWaiterC1ERNS_9ConditionE;
+ _ZN9salhelper15ConditionWaiterC1ERNS_9ConditionEm;
+ _ZN9salhelper15ConditionWaiterC2ERNS_9ConditionE;
+ _ZN9salhelper15ConditionWaiterC2ERNS_9ConditionEm;
+ _ZN9salhelper15ConditionWaiterD1Ev;
+ _ZN9salhelper15ConditionWaiterD2Ev;
+
+ _ZN9salhelper15ConditionWaiter8timedoutaSERKS1_;
+ _ZN9salhelper15ConditionWaiter8timedoutC1ERKS1_;
+ _ZN9salhelper15ConditionWaiter8timedoutC1Ev;
+ _ZN9salhelper15ConditionWaiter8timedoutC2ERKS1_;
+ _ZN9salhelper15ConditionWaiter8timedoutC2Ev;
+ _ZN9salhelper15ConditionWaiter8timedoutD0Ev;
+ _ZN9salhelper15ConditionWaiter8timedoutD1Ev;
+ _ZN9salhelper15ConditionWaiter8timedoutD2Ev;
+ # _ZTIN9salhelper15ConditionWaiter8timedoutE;
+ # _ZTSN9salhelper15ConditionWaiter8timedoutE;
+} UDK_3_0_0;
diff --git a/salhelper/source/makefile.mk b/salhelper/source/makefile.mk
new file mode 100644
index 000000000000..a6b83cb5e090
--- /dev/null
+++ b/salhelper/source/makefile.mk
@@ -0,0 +1,82 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=salhelper
+TARGET=salhelper
+
+ENABLE_EXCEPTIONS=TRUE
+NO_BSYMBOLIC=TRUE
+USE_DEFFILE=TRUE
+
+.IF "$(OS)" != "WNT" && "$(GUI)"!="OS2"
+UNIXVERSIONNAMES=UDK
+.ENDIF # WNT
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/condition.obj \
+ $(SLO)$/dynload.obj \
+ $(SLO)$/simplereferenceobject.obj
+
+.IF "$(GUI)" == "WNT"
+SHL1TARGET= $(TARGET)$(UDK_MAJOR)$(COMID)
+.ELIF "$(GUI)" == "OS2"
+SHL1TARGET= salhelp$(UDK_MAJOR)
+.ELSE
+SHL1TARGET= uno_$(TARGET)$(COMID)
+.ENDIF
+
+SHL1STDLIBS=$(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1RPATH= URELIB
+
+DEF1NAME= $(SHL1TARGET)
+
+.IF "$(COMNAME)"=="msci"
+SHL1VERSIONMAP=msci.map
+.ELIF "$(GUI)"=="OS2"
+SHL1VERSIONMAP=gcc3os2.map
+.ELIF "$(COMNAME)"=="sunpro5"
+SHL1VERSIONMAP=sols.map
+.ELIF "$(COMNAME)"=="gcc3"
+SHL1VERSIONMAP=gcc3.map
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/salhelper/source/msci.map b/salhelper/source/msci.map
new file mode 100644
index 000000000000..737513c93d04
--- /dev/null
+++ b/salhelper/source/msci.map
@@ -0,0 +1,38 @@
+UDK_3_0_0 {
+ global:
+GetVersionInfo
+??0ORealDynamicLoader@salhelper@@IAE@PAPAV01@ABVOUString@rtl@@1PAX2@Z
+??1ORealDynamicLoader@salhelper@@MAE@XZ
+??_7ORealDynamicLoader@salhelper@@6B@
+?acquire@ORealDynamicLoader@salhelper@@QAAKXZ
+?getApi@ORealDynamicLoader@salhelper@@QBAPAXXZ
+?newInstance@ORealDynamicLoader@salhelper@@SAPAV12@PAPAV12@ABVOUString@rtl@@1@Z
+?release@ORealDynamicLoader@salhelper@@QAAKXZ
+??1SimpleReferenceObject@salhelper@@MAE@XZ
+??2SimpleReferenceObject@salhelper@@SAPAXI@Z
+??2SimpleReferenceObject@salhelper@@SAPAXIABUnothrow_t@std@@@Z
+??3SimpleReferenceObject@salhelper@@SAXPAX@Z
+??3SimpleReferenceObject@salhelper@@SAXPAXABUnothrow_t@std@@@Z
+ local:
+ *;
+};
+
+UDK_3.1 {
+ global:
+ ??_7SimpleReferenceObject@salhelper@@6B@;
+
+ ??0Condition@salhelper@@QAE@AAVMutex@osl@@@Z;
+ ??1Condition@salhelper@@UAE@XZ;
+
+ ??0ConditionModifier@salhelper@@QAE@AAVCondition@1@@Z;
+ ??1ConditionModifier@salhelper@@QAE@XZ;
+
+ ??0ConditionWaiter@salhelper@@QAE@AAVCondition@1@@Z;
+ ??0ConditionWaiter@salhelper@@QAE@AAVCondition@1@K@Z;
+ ??1ConditionWaiter@salhelper@@QAE@XZ;
+
+ ??0timedout@ConditionWaiter@salhelper@@QAE@XZ;
+ ??0timedout@ConditionWaiter@salhelper@@QAE@ABU012@@Z;
+ ??1timedout@ConditionWaiter@salhelper@@UAE@XZ;
+ ??4timedout@ConditionWaiter@salhelper@@QAEAAU012@ABU012@@Z;
+} UDK_3_0_0;
diff --git a/salhelper/source/simplereferenceobject.cxx b/salhelper/source/simplereferenceobject.cxx
new file mode 100755
index 000000000000..1e7ac29d3aa9
--- /dev/null
+++ b/salhelper/source/simplereferenceobject.cxx
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "salhelper/simplereferenceobject.hxx"
+#include "osl/diagnose.h"
+
+#ifndef INCLUDED_NEW
+#include <new>
+#define INCLUDED_NEW
+#endif
+
+using salhelper::SimpleReferenceObject;
+
+SimpleReferenceObject::~SimpleReferenceObject() SAL_THROW(())
+{
+ OSL_ASSERT(m_nCount == 0);
+}
+
+void * SimpleReferenceObject::operator new(std::size_t nSize)
+ SAL_THROW((std::bad_alloc))
+{
+ return ::operator new(nSize);
+}
+
+void * SimpleReferenceObject::operator new(std::size_t nSize,
+ std::nothrow_t const &)
+ SAL_THROW(())
+{
+#if defined WNT
+ return ::operator new(nSize);
+ // WNT lacks a global nothrow operator new...
+#else // WNT
+ return ::operator new(nSize, std::nothrow);
+#endif // WNT
+}
+
+void SimpleReferenceObject::operator delete(void * pPtr) SAL_THROW(())
+{
+ ::operator delete(pPtr);
+}
+
+void SimpleReferenceObject::operator delete(void * pPtr, std::nothrow_t const &)
+ SAL_THROW(())
+{
+#if defined WNT
+ ::operator delete(pPtr); // WNT lacks a global nothrow operator delete...
+#else // WNT
+ ::operator delete(pPtr, std::nothrow);
+#endif // WNT
+}
diff --git a/salhelper/source/sols.map b/salhelper/source/sols.map
new file mode 100644
index 000000000000..69454b71089b
--- /dev/null
+++ b/salhelper/source/sols.map
@@ -0,0 +1,76 @@
+UDK_3.1 { # OOo 1.1.2 SDK
+ global:
+ __1cJsalhelperJCondition2t6MrnDoslFMutex__v_;
+ __1cJsalhelperJCondition2t5B6MrnDoslFMutex__v_;
+ __1cJsalhelperJCondition2T6M_v_;
+ __1cJsalhelperJCondition2T5B6M_v_;
+ __1cJsalhelperbF__RTTI__1nJsalhelperJCondition__;
+ __1cJsalhelperbH__RTTI__1CpnJsalhelperJCondition__;
+ __1cJsalhelperbI__RTTI__1CpknJsalhelperJCondition__;
+
+ __1cJsalhelperRConditionModifier2t6Mrn0AJCondition__v_;
+ __1cJsalhelperRConditionModifier2t5B6Mrn0AJCondition__v_;
+ __1cJsalhelperRConditionModifier2T6M_v_;
+ __1cJsalhelperRConditionModifier2T5B6M_v_;
+
+ __1cJsalhelperPConditionWaiter2t6Mrn0AJCondition__v_;
+ __1cJsalhelperPConditionWaiter2t5B6Mrn0AJCondition__v_;
+ __1cJsalhelperPConditionWaiter2t6Mrn0AJCondition_L_v_; #S-ILP32
+ __1cJsalhelperPConditionWaiter2t6Mrn0AJCondition_I_v_; #S-LP64
+ __1cJsalhelperPConditionWaiter2t5B6Mrn0AJCondition_L_v_; #S-ILP32
+ __1cJsalhelperPConditionWaiter2t5B6Mrn0AJCondition_I_v_; #S-LP64
+ __1cJsalhelperPConditionWaiter2T6M_v_;
+ __1cJsalhelperPConditionWaiter2T5B6M_v_;
+
+ __1cJsalhelperPConditionWaiterItimedout2t6M_v_;
+ __1cJsalhelperPConditionWaiterItimedout2t5B6M_v_;
+ __1cJsalhelperPConditionWaiterItimedout2t6Mrk2_v_;
+ __1cJsalhelperPConditionWaiterItimedout2t5B6Mrk2_v_;
+ __1cJsalhelperPConditionWaiterItimedout2T6M_v_;
+ __1cJsalhelperPConditionWaiterItimedout2T5B6M_v_;
+ __1cJsalhelperPConditionWaiterItimedout2G6Mrk2_r2_;
+ __1cJsalhelperbU__RTTI__1nJsalhelperPConditionWaiterItimedout__;
+ __1cJsalhelperbW__RTTI__1CpnJsalhelperPConditionWaiterItimedout__;
+ __1cJsalhelperbX__RTTI__1CpknJsalhelperPConditionWaiterItimedout__;
+} UDK_3.0;
+
+UDK_3.0 {
+ global:
+GetVersionInfo;
+__1cJsalhelperSORealDynamicLoaderLnewInstance6Fpp1rknDrtlIOUString_7_2_;
+__1cJsalhelperSORealDynamicLoader2t5B6Mpp1rknDrtlIOUString_7pv8_v_;
+__1cJsalhelperSORealDynamicLoader2t6Mpp1rknDrtlIOUString_7pv8_v_;
+__1cJsalhelperSORealDynamicLoaderG__vtbl_;
+__1cJsalhelperSORealDynamicLoader2T5B6M_v_;
+__1cJsalhelperSORealDynamicLoader2T6M_v_;
+__1cJsalhelperbR__RTTI__1CpknJsalhelperSORealDynamicLoader__;
+__1cJsalhelperbQ__RTTI__1CpnJsalhelperSORealDynamicLoader__;
+__1cJsalhelperbO__RTTI__1nJsalhelperSORealDynamicLoader__;
+__1cJsalhelperSORealDynamicLoaderHacquire6M_L_; #S-ILP32
+__1cJsalhelperSORealDynamicLoaderHacquire6M_I_; #S-LP64
+__1cJsalhelperSORealDynamicLoaderHrelease6M_L_; #S-ILP32
+__1cJsalhelperSORealDynamicLoaderHrelease6M_I_; #S-LP64
+__1cJsalhelperSORealDynamicLoaderGgetApi6kM_pv_;
+__1cJsalhelperVSimpleReferenceObject2T5B6M_v_;
+__1cJsalhelperVSimpleReferenceObject2T6M_v_;
+__1cJsalhelperVSimpleReferenceObject2k6Fpv_v_;
+__1cJsalhelperVSimpleReferenceObject2k6FpvrknDstdJnothrow_t__v_;
+__1cJsalhelperVSimpleReferenceObject2n6FI_pv_; #S-ILP32
+__1cJsalhelperVSimpleReferenceObject2n6FL_pv_; #S-LP64
+__1cJsalhelperVSimpleReferenceObject2n6FIrknDstdJnothrow_t__pv_; #S-ILP32
+__1cJsalhelperVSimpleReferenceObject2n6FLrknDstdJnothrow_t__pv_; #S-LP64
+__1cJsalhelperVSimpleReferenceObjectG__vtbl_;
+__1cJsalhelperbR__RTTI__1nJsalhelperVSimpleReferenceObject__;
+__1cJsalhelperbT__RTTI__1CpnJsalhelperVSimpleReferenceObject__;
+__1cJsalhelperbU__RTTI__1CpknJsalhelperVSimpleReferenceObject__;
+ local:
+ *;
+} SALHLP_1_0;
+
+SALHLP_1_0 { # WEAK (backward compatibility, should have been UDK_3.0)
+};
+
+{ # BASE
+_init;
+_fini;
+};
diff --git a/salhelper/test/Symbols/loader.cxx b/salhelper/test/Symbols/loader.cxx
new file mode 100644
index 000000000000..82adeecaea9e
--- /dev/null
+++ b/salhelper/test/Symbols/loader.cxx
@@ -0,0 +1,37 @@
+
+#include <salhelper/dynload.hxx>
+#include <rtl/ustring>
+#include <stdio.h>
+#include "samplelib.hxx"
+
+
+using namespace salhelper;
+using namespace rtl;
+
+
+class SampleLibLoader
+ : public ::salhelper::ODynamicLoader<SampleLib_Api>
+{
+public:
+ SampleLibLoader():
+ ::salhelper::ODynamicLoader<SampleLib_Api>
+ (::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SAL_MODULENAME( "samplelib") ) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(SAMPLELIB_INIT_FUNCTION_NAME) ))
+ {}
+
+};
+
+
+int main( int argc, char *argv[ ], char *envp[ ] )
+{
+ SampleLibLoader Loader;
+ SampleLibLoader Loader2;
+ Loader= Loader2;
+ SampleLib_Api *pApi= Loader.getApi();
+
+ sal_Int32 retint= pApi->funcA( 10);
+ double retdouble= pApi->funcB( 3.14);
+
+
+ return 0;
+}
diff --git a/salhelper/test/Symbols/makefile.mk b/salhelper/test/Symbols/makefile.mk
new file mode 100644
index 000000000000..d6026a3c893b
--- /dev/null
+++ b/salhelper/test/Symbols/makefile.mk
@@ -0,0 +1,97 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/
+
+PRJNAME=salhelper
+TARGET=dynloader
+TARGET1=samplelib
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# --- Files ---
+
+#RTTI on
+.IF "$(OS)" == "WNT"
+CFLAGS+= -GR
+.ENDIF
+
+
+#---------------------------------------------------------------------------
+# Build the test library which is loaded by the
+# RealDynamicLoader
+
+SLOFILES= $(SLO)$/samplelib.obj
+
+LIB1TARGET= $(SLB)$/$(TARGET1).lib
+LIB1OBJFILES= $(SLOFILES)
+
+
+SHL1TARGET= $(TARGET1)
+
+SHL1STDLIBS= \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET1)
+SHL1LIBS= $(SLB)$/$(TARGET1).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEFLIB1NAME= $(TARGET1)
+DEF1DEPN= $(MISC)$/$(SHL1TARGET).flt
+
+#DEF1EXPORTFILE= exports.dxp
+
+# ------------------------------------------------------------------------------
+
+OBJFILES= $(OBJ)$/loader.obj
+
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJFILES)
+
+APP1STDLIBS= \
+ $(SALHELPERLIB) \
+ $(SALLIB)
+
+APP1DEF= $(MISC)\$(APP1TARGET).def
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+
+$(MISC)$/$(SHL1TARGET).flt: makefile.mk
+ @echo ------------------------------
+ @echo Making: $@
+ @echo __CT>>$@
diff --git a/salhelper/test/Symbols/samplelib.cxx b/salhelper/test/Symbols/samplelib.cxx
new file mode 100644
index 000000000000..f4809f51fd2e
--- /dev/null
+++ b/salhelper/test/Symbols/samplelib.cxx
@@ -0,0 +1,37 @@
+#include "samplelib.hxx"
+#include <sal/types.h>
+/*
+
+
+*/
+
+extern "C"
+SampleLib_Api* SAL_CALL initSampleLibApi(void)
+{
+ static SampleLib_Api aApi= {0,0};
+ if (!aApi.funcA)
+ {
+ aApi.funcA= &funcA;
+ aApi.funcB= &funcB;
+ return (&aApi);
+ }
+ else
+ {
+ return (&aApi);
+ }
+
+}
+
+
+sal_Int32 SAL_CALL funcA( sal_Int32 a)
+{
+ return a;
+}
+
+
+double SAL_CALL funcB( double a)
+{
+ return a;
+}
+
+
diff --git a/salhelper/test/Symbols/samplelib.hxx b/salhelper/test/Symbols/samplelib.hxx
new file mode 100644
index 000000000000..d5986ad67c5c
--- /dev/null
+++ b/salhelper/test/Symbols/samplelib.hxx
@@ -0,0 +1,22 @@
+#ifndef __SAMPLELIB_HXX_
+#define __SAMPLELIB_HXX_
+
+#include <sal/types.h>
+
+struct SampleLib_Api
+{
+ sal_Int32 (SAL_CALL *funcA)( sal_Int32 );
+ double (SAL_CALL *funcB)( double );
+};
+
+
+typedef SampleLib_Api* (SAL_CALL *InitSampleLib_Api)(void);
+
+#define SAMPLELIB_INIT_FUNCTION_NAME "initSampleLibApi"
+
+
+sal_Int32 SAL_CALL funcA( sal_Int32 a);
+double SAL_CALL funcB( double a);
+
+
+#endif
diff --git a/salhelper/test/dynamicloader/loader.cxx b/salhelper/test/dynamicloader/loader.cxx
new file mode 100644
index 000000000000..82adeecaea9e
--- /dev/null
+++ b/salhelper/test/dynamicloader/loader.cxx
@@ -0,0 +1,37 @@
+
+#include <salhelper/dynload.hxx>
+#include <rtl/ustring>
+#include <stdio.h>
+#include "samplelib.hxx"
+
+
+using namespace salhelper;
+using namespace rtl;
+
+
+class SampleLibLoader
+ : public ::salhelper::ODynamicLoader<SampleLib_Api>
+{
+public:
+ SampleLibLoader():
+ ::salhelper::ODynamicLoader<SampleLib_Api>
+ (::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SAL_MODULENAME( "samplelib") ) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(SAMPLELIB_INIT_FUNCTION_NAME) ))
+ {}
+
+};
+
+
+int main( int argc, char *argv[ ], char *envp[ ] )
+{
+ SampleLibLoader Loader;
+ SampleLibLoader Loader2;
+ Loader= Loader2;
+ SampleLib_Api *pApi= Loader.getApi();
+
+ sal_Int32 retint= pApi->funcA( 10);
+ double retdouble= pApi->funcB( 3.14);
+
+
+ return 0;
+}
diff --git a/salhelper/test/dynamicloader/makefile.mk b/salhelper/test/dynamicloader/makefile.mk
new file mode 100644
index 000000000000..718f9cbe6bbc
--- /dev/null
+++ b/salhelper/test/dynamicloader/makefile.mk
@@ -0,0 +1,117 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/
+
+PRJNAME=salhelper
+TARGET=dynloader
+TARGET1=samplelib
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+NO_BSYMBOLIC= TRUE
+ENABLE_EXCEPTIONS=TRUE
+BOOTSTRAP_SERVICE=FALSE
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# --- Files ---
+
+
+#RTTI on
+.IF "$(OS)" == "WNT"
+CFLAGS+= -GR
+.ENDIF
+
+
+# UNOTYPES= com.sun.star.lang.XInitialization \
+#---------------------------------------------------------------------------
+# Build the test library which is loaded by the
+# RealDynamicLoader
+
+SLOFILES= \
+ $(SLO)$/samplelib.obj
+
+LIB1TARGET=$(SLB)$/$(TARGET1).lib
+LIB1OBJFILES= \
+ $(SLO)$/samplelib.obj
+
+
+SHL1TARGET= $(TARGET1)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET1)
+SHL1LIBS= $(SLB)$/$(TARGET1).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEFLIB1NAME =$(TARGET1)
+DEF1DEPN= $(MISC)$/$(SHL1TARGET).flt
+
+#DEF1EXPORTFILE= exports.dxp
+
+# ------------------------------------------------------------------------------
+
+APP1NOSAL=TRUE
+
+APP1TARGET= $(TARGET)
+
+APP1OBJS= $(OBJ)$/loader.obj
+
+APP1STDLIBS= \
+ $(SALLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB)
+
+#APP1LIBS= $(LB)$/isalhelper.lib
+
+.IF "$(OS)" == "WNT"
+APP1STDLIBS+= $(LB)$/isalhelper.lib
+.ELSE
+APP1STDLIBS+= -lsalhelper$(UDK_MAJOR)$(COM)
+.ENDIF
+
+APP1DEF= $(MISC)\$(APP1TARGET).def
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+
+
+$(MISC)$/$(SHL1TARGET).flt: makefile.mk
+ @echo ------------------------------
+ @echo Making: $@
+ @echo __CT>>$@
+
+
diff --git a/salhelper/test/dynamicloader/samplelib.cxx b/salhelper/test/dynamicloader/samplelib.cxx
new file mode 100644
index 000000000000..f4809f51fd2e
--- /dev/null
+++ b/salhelper/test/dynamicloader/samplelib.cxx
@@ -0,0 +1,37 @@
+#include "samplelib.hxx"
+#include <sal/types.h>
+/*
+
+
+*/
+
+extern "C"
+SampleLib_Api* SAL_CALL initSampleLibApi(void)
+{
+ static SampleLib_Api aApi= {0,0};
+ if (!aApi.funcA)
+ {
+ aApi.funcA= &funcA;
+ aApi.funcB= &funcB;
+ return (&aApi);
+ }
+ else
+ {
+ return (&aApi);
+ }
+
+}
+
+
+sal_Int32 SAL_CALL funcA( sal_Int32 a)
+{
+ return a;
+}
+
+
+double SAL_CALL funcB( double a)
+{
+ return a;
+}
+
+
diff --git a/salhelper/test/dynamicloader/samplelib.hxx b/salhelper/test/dynamicloader/samplelib.hxx
new file mode 100644
index 000000000000..d5986ad67c5c
--- /dev/null
+++ b/salhelper/test/dynamicloader/samplelib.hxx
@@ -0,0 +1,22 @@
+#ifndef __SAMPLELIB_HXX_
+#define __SAMPLELIB_HXX_
+
+#include <sal/types.h>
+
+struct SampleLib_Api
+{
+ sal_Int32 (SAL_CALL *funcA)( sal_Int32 );
+ double (SAL_CALL *funcB)( double );
+};
+
+
+typedef SampleLib_Api* (SAL_CALL *InitSampleLib_Api)(void);
+
+#define SAMPLELIB_INIT_FUNCTION_NAME "initSampleLibApi"
+
+
+sal_Int32 SAL_CALL funcA( sal_Int32 a);
+double SAL_CALL funcB( double a);
+
+
+#endif
diff --git a/salhelper/test/rtti/exports.dxp b/salhelper/test/rtti/exports.dxp
new file mode 100644
index 000000000000..41a9804fdbeb
--- /dev/null
+++ b/salhelper/test/rtti/exports.dxp
@@ -0,0 +1,8 @@
+?funcA@MyClassA@@UAEXXZ
+?funcB@MyClassA@@UAEXXZ
+?funcC@MyClassA@@MAEXXZ
+?funcD@MyClassA@@EAEXXZ
+?funcA@MyClassB@@UAEXXZ
+?funcB@MyClassB@@UAEXXZ
+?funcC@MyClassB@@MAEXXZ
+?funcD@MyClassB@@EAEXXZ \ No newline at end of file
diff --git a/salhelper/test/rtti/makefile.mk b/salhelper/test/rtti/makefile.mk
new file mode 100644
index 000000000000..704454f49851
--- /dev/null
+++ b/salhelper/test/rtti/makefile.mk
@@ -0,0 +1,107 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME= salhelper
+TARGET= rtti
+TARGET1=samplelibrtti
+LIBTARGET=NO
+TARGETTYPE=CUI
+
+
+ENABLE_EXCEPTIONS=TRUE
+
+USE_DEFFILE= TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+#RTTI on
+.IF "$(OS)" == "WNT"
+CFLAGS+= -GR
+.ENDIF
+
+SLOFILES= \
+ $(SLO)$/samplelibrtti.obj
+
+LIB1TARGET=$(SLB)$/$(TARGET1).lib
+LIB1OBJFILES= \
+ $(SLO)$/samplelibrtti.obj
+
+SHL1TARGET= $(TARGET1)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET1)
+SHL1LIBS= $(SLB)$/$(TARGET1).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+DEF1EXPORTFILE= exports.dxp
+
+DEF1NAME= $(SHL1TARGET)
+
+.IF "$(OS)$(CPU)"=="SOLARISS"
+SHL1VERSIONMAP= sols.map
+.ELIF "$(OS)$(CPU)"=="LINUXI"
+SHL1VERSIONMAP= lngi.map
+.ELIF "$(OS)$(CPU)$(COMNAME)" == "GCCFREEBSDIgcc2"
+SHL1VERSIONMAP= gcc2_freebsd_intel.map
+.ELIF "$(OS)$(CPU)$(COMNAME)" == "GCCFREEBSDIgcc3"
+SHL1VERSIONMAP= gcc3_freebsd_intel.map
+.ENDIF
+
+
+# ------------------------------------------------------------------
+
+APP1NOSAL=TRUE
+
+APP1TARGET= $(TARGET)
+
+APP1OBJS= $(OBJ)$/rttitest.obj
+
+APP1STDLIBS= \
+ $(SALLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB)
+
+.IF "$(OS)" == "WNT"
+APP1STDLIBS+= $(LB)$/isamplelibrtti.lib
+.ELSE
+APP1STDLIBS+= -lsamplelibrtti
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/salhelper/test/rtti/rttitest.cxx b/salhelper/test/rtti/rttitest.cxx
new file mode 100644
index 000000000000..ad03f3dc7960
--- /dev/null
+++ b/salhelper/test/rtti/rttitest.cxx
@@ -0,0 +1,29 @@
+#include <rtl/ustring>
+#include <stdio.h>
+#include <typeinfo>
+#include "samplelibrtti.hxx"
+
+
+//using namespace salhelper;
+using namespace rtl;
+
+
+
+int main( int argc, char *argv[ ], char *envp[ ] )
+{
+ MyClassB b;
+ MyClassA* pA= &b;
+ // test the virtual function
+ pA->funcA();
+
+// const type_info& i1= typeid ( b);
+// const type_info& i2= typeid( pA);
+
+ if( typeid( b) == typeid( pA))
+ printf("\nsame types");
+
+
+ MyClassB* pB= dynamic_cast<MyClassB* >( pA);
+ pB->funcA();
+ return 0;
+}
diff --git a/salhelper/test/rtti/samplelibrtti.cxx b/salhelper/test/rtti/samplelibrtti.cxx
new file mode 100644
index 000000000000..151ed9ae3c0a
--- /dev/null
+++ b/salhelper/test/rtti/samplelibrtti.cxx
@@ -0,0 +1,39 @@
+#include "samplelibrtti.hxx"
+#include <stdio.h>
+
+// MyClassA =============================================================
+void MyClassA::funcA()
+{
+ printf("MyClassA::funcA \n");
+}
+
+void MyClassA::funcB()
+{
+}
+
+void MyClassA::funcC()
+{
+}
+
+void MyClassA::funcD()
+{
+}
+
+// MyClassB ===============================================================
+void MyClassB::funcA()
+{
+
+ printf("MyClassA::funcB \n");
+}
+
+void MyClassB::funcB()
+{
+}
+
+void MyClassB::funcC()
+{
+}
+
+void MyClassB::funcD()
+{
+}
diff --git a/salhelper/test/rtti/samplelibrtti.hxx b/salhelper/test/rtti/samplelibrtti.hxx
new file mode 100644
index 000000000000..5f1294dd73af
--- /dev/null
+++ b/salhelper/test/rtti/samplelibrtti.hxx
@@ -0,0 +1,28 @@
+#ifndef __SAMPLELIBRTTI_HXX_
+#define __SAMPLELIBRTTI_HXX_
+
+class MyClassA
+{
+public:
+ virtual void funcA();
+ virtual void funcB();
+protected:
+ virtual void funcC();
+private:
+ virtual void funcD();
+};
+
+
+class MyClassB: public MyClassA
+{
+public:
+ virtual void funcA();
+ virtual void funcB();
+protected:
+ virtual void funcC();
+private:
+ virtual void funcD();
+
+};
+
+#endif
diff --git a/salhelper/test/rtti/sols.map b/salhelper/test/rtti/sols.map
new file mode 100644
index 000000000000..babf2c901585
--- /dev/null
+++ b/salhelper/test/rtti/sols.map
@@ -0,0 +1,34 @@
+UDK_3_0_0 {
+ global:
+GetVersionInfo;
+_fini;
+_init;
+
+__1cIMyClassAFfuncA6M_v_;
+__1cIMyClassAFfuncB6M_v_;
+__1cIMyClassAFfuncC6M_v_;
+__1cIMyClassAFfuncD6M_v_;
+__1cIMyClassAG__vtbl_;
+__1cIMyClassBFfuncA6M_v_;
+__1cIMyClassBFfuncB6M_v_;
+__1cIMyClassBFfuncC6M_v_;
+__1cIMyClassBFfuncD6M_v_;
+__1cIMyClassBG__vtbl_;
+__RTTI__1CpknIMyClassA_;
+__RTTI__1CpknIMyClassB_;
+__RTTI__1CpnIMyClassA_;
+__RTTI__1CpnIMyClassB_;
+__RTTI__1nIMyClassA_;
+__RTTI__1nIMyClassB_;
+
+local:
+ *;
+};
+
+
+
+
+
+
+
+
diff --git a/salhelper/version.mk b/salhelper/version.mk
new file mode 100644
index 000000000000..76f67022677e
--- /dev/null
+++ b/salhelper/version.mk
@@ -0,0 +1,44 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+# target
+SALHELPER_TARGET=salhelper
+
+# the major
+SALHELPER_MAJOR=2
+# the minor
+SALHELPER_MINOR=0
+# the micro
+SALHELPER_MICRO=0
+
+# this is a c++ compatible library
+SALHELPER_CPP=1
+
+SALHELPER=$(SALHELPER_TARGET)_$(CMPEXT)
+
+LIBSALHELPER_UNX=lib$(SALHELPER).a.$(SALHELPER_MAJOR)
+LIBSALHELPER_WIN=$(SALHELPER_TARGET)$(SALHELPER_MAJOR)$(CMPEXT).dll