summaryrefslogtreecommitdiff
path: root/include/cppu
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2013-04-19 18:54:16 +0200
committerDavid Tardon <dtardon@redhat.com>2013-04-24 05:17:10 +0000
commit6c7659b584ea7ed3652ca4eb9a2297f36310c365 (patch)
treeadf631e2d3db309b0696babd9d026bce0996c215 /include/cppu
parent24500d6798007d84521eb24a81c121ebe69d3bfd (diff)
move URE headers to include/
Change-Id: Ib48a12e902f2311c295b2007f08f44dee28f431d Reviewed-on: https://gerrit.libreoffice.org/3499 Reviewed-by: David Tardon <dtardon@redhat.com> Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'include/cppu')
-rw-r--r--include/cppu/Enterable.hxx108
-rw-r--r--include/cppu/EnvDcp.hxx69
-rw-r--r--include/cppu/EnvGuards.hxx107
-rw-r--r--include/cppu/Map.hxx107
-rw-r--r--include/cppu/cppudllapi.h21
-rw-r--r--include/cppu/helper/purpenv/Environment.hxx42
-rw-r--r--include/cppu/helper/purpenv/Mapping.hxx63
-rw-r--r--include/cppu/macros.hxx58
-rw-r--r--include/cppu/unotype.hxx375
9 files changed, 950 insertions, 0 deletions
diff --git a/include/cppu/Enterable.hxx b/include/cppu/Enterable.hxx
new file mode 100644
index 000000000000..6bb4a9c274d4
--- /dev/null
+++ b/include/cppu/Enterable.hxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_cppu_Enterable_hxx
+#define INCLUDED_cppu_Enterable_hxx
+
+#include "uno/Enterable.h"
+#include "rtl/ustring.hxx"
+
+namespace cppu
+{
+/** C++ wrapper for binary C Enterable
+ (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Environment_Stack)
+
+ @see uno_Enterable
+ @since UDK 3.2.7
+*/
+class Enterable : public uno_Enterable
+{
+public:
+ /* These methods need to be implemented in a derived class.
+ */
+ virtual void v_enter (void) = 0;
+ virtual void v_leave (void) = 0;
+ virtual void v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam) = 0;
+ virtual void v_callOut_v (uno_EnvCallee * pCallee, va_list * pParam) = 0;
+ virtual int v_isValid (rtl::OUString * pReason) = 0;
+
+ virtual ~Enterable() {}
+
+public:
+ inline explicit Enterable(void);
+
+ inline void enter(void) {m_enter(this);}
+ inline void leave(void) {m_leave(this);}
+
+ inline void callInto_v(uno_EnvCallee * pCallee, va_list * pParam) {m_callInto_v(this, pCallee, pParam);}
+ inline void callOut_v (uno_EnvCallee * pCallee, va_list * pParam) {m_callOut_v (this, pCallee, pParam);}
+
+ inline void callInto(uno_EnvCallee * pCallee, ...);
+ inline void callOut (uno_EnvCallee * pCallee, ...);
+
+ inline int isValid (rtl::OUString * pReason) {return m_isValid(this, (rtl_uString **)pReason);}
+
+private:
+ Enterable(Enterable const &);
+ Enterable & operator = (Enterable const &);
+};
+
+extern "C" inline void Enterable_call_enter (void * context) { ((Enterable *)context)->v_enter(); }
+extern "C" inline void Enterable_call_leave (void * context) { ((Enterable *)context)->v_leave(); }
+extern "C" inline void Enterable_call_callInto_v(void * context, uno_EnvCallee * pCallee, va_list * pParam)
+ { ((Enterable *)context)->v_callInto_v(pCallee, pParam); }
+extern "C" inline void Enterable_call_callOut_v (void * context, uno_EnvCallee * pCallee, va_list * pParam)
+ { ((Enterable *)context)->v_callOut_v(pCallee, pParam); }
+extern "C" inline int Enterable_call_isValid (void * context, rtl_uString ** pReason)
+ {return ((Enterable *)context)->v_isValid((rtl::OUString *)pReason);}
+
+
+Enterable::Enterable(void)
+{
+ m_enter = Enterable_call_enter;
+ m_leave = Enterable_call_leave;
+ m_callInto_v = Enterable_call_callInto_v;
+ m_callOut_v = Enterable_call_callOut_v;
+ m_isValid = Enterable_call_isValid;
+}
+
+void Enterable::callInto(uno_EnvCallee * pCallee, ...)
+{
+ va_list param;
+
+ va_start(param, pCallee);
+ callInto_v(pCallee, &param);
+ va_end(param);
+}
+
+void Enterable::callOut(uno_EnvCallee * pCallee, ...)
+{
+ va_list param;
+
+ va_start(param, pCallee);
+ callOut_v(pCallee, &param);
+ va_end(param);
+}
+
+}
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/EnvDcp.hxx b/include/cppu/EnvDcp.hxx
new file mode 100644
index 000000000000..340ebcb3d5e1
--- /dev/null
+++ b/include/cppu/EnvDcp.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_cppu_EnvDcp_hxx
+#define INCLUDED_cppu_EnvDcp_hxx
+
+#include "rtl/ustring.hxx"
+#include "uno/EnvDcp.h"
+
+
+namespace cppu
+{
+namespace EnvDcp
+{
+/** Get the OBI type part of an environment descriptor.
+ (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Environment_Descriptor)
+
+ @param rEnvDcp the Environment Descriptor
+ @return the OBI type
+ @since UDK 3.2.7
+*/
+inline rtl::OUString getTypeName(rtl::OUString const & rEnvDcp)
+{
+ rtl::OUString typeName;
+
+ uno_EnvDcp_getTypeName(rEnvDcp.pData, &typeName.pData);
+
+ return typeName;
+}
+
+/** Get the purpose part of an environment descriptor.
+ (http://wiki.services.openoffice.org/wiki/Uno/Binary/Spec/Environment_Descriptor)
+
+ @param rEnvDcp the Environment Descriptor
+ @return the purpose
+ @since UDK 3.2.7
+*/
+inline rtl::OUString getPurpose(rtl::OUString const & rEnvDcp)
+{
+ rtl::OUString purpose;
+
+ uno_EnvDcp_getPurpose(rEnvDcp.pData, &purpose.pData);
+
+ return purpose;
+}
+
+}
+}
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/EnvGuards.hxx b/include/cppu/EnvGuards.hxx
new file mode 100644
index 000000000000..e1334ac7909a
--- /dev/null
+++ b/include/cppu/EnvGuards.hxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_cppu_EnvGuards_hxx
+#define INCLUDED_cppu_EnvGuards_hxx
+
+#include "uno/environment.hxx"
+#include "uno/mapping.hxx"
+
+
+namespace cssuno = com::sun::star::uno;
+
+
+namespace cppu
+{
+ /** Environment Guard
+ The provided Environment becomes entered in the constructor and left
+ in the destructor.
+ (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Environment_Guard)
+
+ @since UDK 3.2.7
+ */
+ class EnvGuard
+ {
+ cssuno::Environment m_env;
+
+ public:
+ explicit EnvGuard(cssuno::Environment const & env)
+ {
+ if (env.is())
+ {
+ m_env = cssuno::Environment::getCurrent();
+ env.enter();
+ }
+ }
+
+ ~EnvGuard()
+ {
+ m_env.enter();
+ }
+
+ /** Checks if the associated environment is non empty.
+
+ @return 0 == empty, 1 == non empty
+ */
+ sal_Bool SAL_CALL is() const SAL_THROW(())
+ {
+ return m_env.is();
+ }
+
+ /** Leaves the associated environment and clears
+ the reference.
+ */
+ void clear()
+ {
+ if (m_env.is())
+ {
+ m_env.enter();
+ m_env.clear();
+ }
+ }
+ };
+
+ /** Environment Anti-Guard
+ Any entered Environment becomes left in the constructor and re-entered
+ in the destructor.
+ (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Environment_AntiGuard)
+
+ @since UDK 3.2.7
+ */
+ class AntiEnvGuard
+ {
+ cssuno::Environment m_env;
+
+ public:
+ explicit AntiEnvGuard()
+ : m_env(cssuno::Environment::getCurrent())
+ {
+ uno_Environment_enter(NULL);
+ }
+
+ ~AntiEnvGuard()
+ {
+ m_env.enter();
+ }
+ };
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/Map.hxx b/include/cppu/Map.hxx
new file mode 100644
index 000000000000..576d2e9133ae
--- /dev/null
+++ b/include/cppu/Map.hxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_cppu_Map_hxx
+#define INCLUDED_cppu_Map_hxx
+
+#include <uno/mapping.hxx>
+
+
+namespace cssu = com::sun::star::uno;
+
+namespace cppu
+{
+ /** Helpers for mapping objects relative to the current environment.
+ (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Map_Helpers)
+ */
+
+ /** Maps an object from the current to an outer Environment, returns mapped object.
+
+ @param pT the object to be mapped
+ @param outerEnv the target environment
+ @return the mapped object
+ @since UDK 3.2.7
+ */
+ template<class T> inline T * mapOut(T * pT, cssu::Environment const & outerEnv)
+ {
+ cssu::Mapping curr2outer(cssu::Environment::getCurrent(), outerEnv);
+
+ return reinterpret_cast<T *>(curr2outer.mapInterface(pT, getCppuType((cssu::Reference<T> *)NULL)));
+ }
+
+
+ /** Maps an object from an outer Environment to the current, returns mapped object.
+
+ @param pT the object to be mapped
+ @param outerEnv the source environment
+ @return the mapped object
+ @since UDK 3.2.7
+ */
+ template<class T> inline T * mapIn(T * pT, cssu::Environment const & outerEnv)
+ {
+ cssu::Mapping outer2curr(outerEnv, cssu::Environment::getCurrent());
+
+ return reinterpret_cast<T *>(outer2curr.mapInterface(pT, getCppuType((cssu::Reference<T> *)NULL)));
+ }
+
+
+ /** Maps an any from the current to an outer Environment, fills passed any.
+
+ @param any the any to be mapped
+ @param res the target any
+ @param outerEnv the target environment
+ @since UDK 3.2.7
+ */
+ // Problem: any gets assigned to something, acquire/releases may be called in wrong env.
+ inline void mapOutAny(cssu::Any const & any, cssu::Any * res, cssu::Environment const & outerEnv)
+ {
+ cssu::Mapping curr2outer(cssu::Environment::getCurrent(), outerEnv);
+
+ uno_any_destruct(res, (uno_ReleaseFunc)cssu::cpp_release);
+ uno_type_any_constructAndConvert(
+ res,
+ const_cast<void *>(any.getValue()),
+ any.getValueTypeRef(),
+ curr2outer.get());
+ }
+
+
+ /** Maps an any from an outer Environment to the current, fills passed any.
+
+ @param any the any to be mapped
+ @param res the target any
+ @param outerEnv the source environment
+ @since UDK 3.2.7
+ */
+ inline void mapInAny(cssu::Any const & any, cssu::Any * res, cssu::Environment const & outerEnv)
+ {
+ cssu::Mapping outer2curr(outerEnv, cssu::Environment::getCurrent());
+
+ uno_any_destruct(res, (uno_ReleaseFunc)cssu::cpp_release);
+ uno_type_any_constructAndConvert(
+ res,
+ const_cast<void *>(any.getValue()),
+ any.getValueTypeRef(),
+ outer2curr.get());
+ }
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/cppudllapi.h b/include/cppu/cppudllapi.h
new file mode 100644
index 000000000000..ee37e1b1c399
--- /dev/null
+++ b/include/cppu/cppudllapi.h
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#ifndef INCLUDED_CPPUDLLAPI_H
+#define INCLUDED_CPPUDLLAPI_H
+
+#include "sal/types.h"
+
+#if defined(CPPU_DLLIMPLEMENTATION)
+#define CPPU_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define CPPU_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+
+#if defined(PURPENV_DLLIMPLEMENTATION)
+#define PURPENV_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define PURPENV_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif /* INCLUDED_CPPUDLLAPI_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/helper/purpenv/Environment.hxx b/include/cppu/helper/purpenv/Environment.hxx
new file mode 100644
index 000000000000..04985d7643b0
--- /dev/null
+++ b/include/cppu/helper/purpenv/Environment.hxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_cppu_helper_purpenv_Environment_hxx
+#define INCLUDED_cppu_helper_purpenv_Environment_hxx
+
+#include <cppu/cppudllapi.h>
+#include "uno/environment.h"
+#include "cppu/Enterable.hxx"
+
+
+namespace cppu { namespace helper { namespace purpenv {
+
+/** C++ helper for implementing Purpose Environments.
+ (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Purpose_Bridge_Implementation_Helper)
+
+ @since UDK 3.2.7
+*/
+PURPENV_DLLPUBLIC void Environment_initWithEnterable(
+ uno_Environment * pEnvironment, cppu::Enterable * pEnterable);
+
+}}}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/helper/purpenv/Mapping.hxx b/include/cppu/helper/purpenv/Mapping.hxx
new file mode 100644
index 000000000000..83518cf75d21
--- /dev/null
+++ b/include/cppu/helper/purpenv/Mapping.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_cppu_helper_purpenv_Mapping_hxx
+#define INCLUDED_cppu_helper_purpenv_Mapping_hxx
+
+#include "com/sun/star/uno/Any.h"
+
+#include <cppu/cppudllapi.h>
+#include "uno/environment.h"
+#include "uno/mapping.h"
+
+
+namespace cppu { namespace helper { namespace purpenv {
+
+/** C++ helper for implementing Purpose Environments.
+ (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Purpose_Bridge_Implementation_Helper)
+
+ @since UDK 3.2.7
+*/
+
+typedef void ProbeFun(
+ bool pre,
+ void * pThis,
+ void * pContext,
+ typelib_TypeDescriptionReference * pReturnTypeRef,
+ typelib_MethodParameter * pParams,
+ sal_Int32 nParams,
+ typelib_TypeDescription const * pMemberType,
+ void * pReturn,
+ void * pArgs[],
+ uno_Any ** ppException );
+
+
+
+PURPENV_DLLPUBLIC void createMapping(uno_Mapping ** ppMapping,
+ uno_Environment * pFrom,
+ uno_Environment * pTo,
+ ProbeFun * probeFun = NULL,
+ void * pContext = NULL
+ );
+
+}}}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/macros.hxx b/include/cppu/macros.hxx
new file mode 100644
index 000000000000..ecaa1470893b
--- /dev/null
+++ b/include/cppu/macros.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _CPPU_MACROS_HXX_
+#define _CPPU_MACROS_HXX_
+
+#include <sal/types.h>
+#include <uno/lbnames.h>
+
+/** Namespace name for compiler/ platform, e.g. gcc3, msci */
+#define CPPU_CURRENT_NAMESPACE CPPU_ENV
+
+/// @cond INTERNAL
+
+/** Patching the GCC 3 incomatible alignment change for Linux.
+
+ This macro is appended by cppumaker to every first member of a struct, if
+ the struct inherits from a base struct and the first member is neither
+ double nor sal_[u]Int64. (The double/sal_[u]Int64 restriction is due to a
+ bug in GCC prior to version 3.3, which would cause __alignof__ of such a
+ struct to become 8 instead of 4 if CPPU_GCC3_ALIGN were added to its first
+ member.)
+*/
+#if defined(__GNUC__)
+#define CPPU_GCC3_ALIGN( base_struct ) __attribute__ ((aligned (__alignof__ (base_struct))))
+#else
+#define CPPU_GCC3_ALIGN( base_struct )
+#endif
+
+/**
+ Exporting the symbols necessary for exception handling on GCC.
+
+ These macros are used in the headers generated by cppumaker for UNO exception
+ types, to ensure that exception handling does not fail on GCC.
+*/
+#define CPPU_GCC_DLLPUBLIC_EXPORT SAL_EXCEPTION_DLLPUBLIC_EXPORT
+#define CPPU_GCC_DLLPRIVATE SAL_EXCEPTION_DLLPRIVATE
+
+/// @endcond
+
+#endif // _CPPU_MACROS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/cppu/unotype.hxx b/include/cppu/unotype.hxx
new file mode 100644
index 000000000000..2861bdb2c922
--- /dev/null
+++ b/include/cppu/unotype.hxx
@@ -0,0 +1,375 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_CPPU_UNOTYPE_HXX
+#define INCLUDED_CPPU_UNOTYPE_HXX
+
+#include "sal/config.h"
+#include "com/sun/star/uno/Type.h"
+#include "sal/types.h"
+#include "typelib/typeclass.h"
+#include "typelib/typedescription.h"
+
+namespace com { namespace sun { namespace star { namespace uno {
+ class Any;
+ class Exception;
+ template< typename > class Reference;
+ template< typename > class Sequence;
+ class XInterface;
+} } } }
+namespace rtl { class OUString; }
+
+namespace cppu {
+
+template< typename > class UnoType;
+
+/**
+ A unique C++ type representing the UNO type VOID in cppu::UnoType.
+
+ This type is declared but not defined. Its only use is as a template
+ argument to cppu::UnoType.
+
+ @since UDK 3.2.2
+*/
+struct UnoVoidType;
+
+/**
+ A unique C++ type representing the UNO type UNSIGNED SHORT in cppu::UnoType.
+
+ The UNO types UNSIGNED SHORT and CHAR map to the same C++ type, so this C++
+ type is needed to unambiguously specify UNO types in cppu::UnoType.
+
+ This type is declared but not defined. Its only use is as a template
+ argument to cppu::UnoType.
+
+ @since UDK 3.2.2
+*/
+struct UnoUnsignedShortType;
+
+/**
+ A unique C++ type representing the UNO type UNSIGNED SHORT in cppu::UnoType.
+
+ The UNO types UNSIGNED SHORT and CHAR map to the same C++ type, so this C++
+ type is needed to unambiguously specify UNO types in cppu::UnoType.
+
+ This type is declared but not defined. Its only use is as a template
+ argument to cppu::UnoType.
+
+ @since UDK 3.2.2
+*/
+struct UnoCharType;
+
+/**
+ A unique C++ type template representing the UNO sequence types in
+ cppu::UnoType.
+
+ The UNO types UNSIGNED SHORT and CHAR map to the same C++ type, so this C++
+ type is needed to unambiguously specify UNO types in cppu::UnoType.
+
+ This type is declared but not defined. Its only use is as a template
+ argument to cppu::UnoType.
+
+ @since UDK 3.2.2
+*/
+template< typename > struct UnoSequenceType;
+
+namespace detail {
+
+inline ::com::sun::star::uno::Type const & getTypeFromTypeDescriptionReference(
+ ::typelib_TypeDescriptionReference * const * tdr)
+{
+ return *reinterpret_cast< ::com::sun::star::uno::Type const * >(tdr);
+}
+
+inline ::com::sun::star::uno::Type const &
+getTypeFromTypeClass(::typelib_TypeClass tc) {
+ return getTypeFromTypeDescriptionReference(
+ ::typelib_static_type_getByTypeClass(tc));
+}
+
+}
+
+}
+
+namespace cppu { namespace detail {
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoVoidType const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_VOID);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER bool const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BOOLEAN);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Bool const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BOOLEAN);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int8 const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BYTE);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int16 const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_SHORT);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(
+ SAL_UNUSED_PARAMETER ::cppu::UnoUnsignedShortType const *)
+{
+ return ::cppu::detail::getTypeFromTypeClass(
+ ::typelib_TypeClass_UNSIGNED_SHORT);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int32 const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_LONG);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt32 const *) {
+ return ::cppu::detail::getTypeFromTypeClass(
+ ::typelib_TypeClass_UNSIGNED_LONG);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int64 const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_HYPER);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt64 const *) {
+ return ::cppu::detail::getTypeFromTypeClass(
+ ::typelib_TypeClass_UNSIGNED_HYPER);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER float const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_FLOAT);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER double const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_DOUBLE);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoCharType const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_CHAR);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::rtl::OUString const *) {
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_STRING);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Type const *)
+{
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_TYPE);
+}
+
+inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Any const *)
+{
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_ANY);
+}
+
+template< typename T > inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(
+ SAL_UNUSED_PARAMETER ::cppu::UnoSequenceType< T > const *)
+{
+ //TODO: depending on memory model, the following might not work reliably
+ static typelib_TypeDescriptionReference * p = 0;
+ if (p == 0) {
+ ::typelib_static_sequence_type_init(
+ &p, ::cppu::UnoType< T >::get().getTypeLibType());
+ }
+ return ::cppu::detail::getTypeFromTypeDescriptionReference(&p);
+}
+
+template< typename T > inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(
+ SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
+{
+ return cppu_detail_getUnoType(
+ static_cast< ::cppu::UnoSequenceType< T > * >(0));
+}
+
+inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
+ SAL_UNUSED_PARAMETER ::com::sun::star::uno::Exception const *)
+{
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_EXCEPTION);
+}
+
+inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
+ SAL_UNUSED_PARAMETER ::com::sun::star::uno::XInterface const *)
+{
+ return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_INTERFACE);
+}
+
+template< typename T > inline ::com::sun::star::uno::Type const &
+cppu_detail_getUnoType(
+ SAL_UNUSED_PARAMETER ::com::sun::star::uno::Reference< T > const *)
+{
+ return ::cppu::UnoType< T >::get();
+}
+
+} }
+
+namespace cppu {
+
+/**
+ Get the com::sun::star::uno::Type instance representing a certain UNO type.
+
+ For each C++ type representing a UNO type, the corresponding instantiation of
+ this template has a public static member function get(). (The template is
+ specialized for C++ templates representing polymorphic struct type templates
+ of UNO. In those cases, it does not work to instantiate UnoType with a C++
+ type that is derived from a C++ type that represents a UNO type, but does not
+ itself represent a UNO type. In all other cases, UnoType even works for such
+ C++ types that are unambiguously derived from one C++ type that represents a
+ UNO type.) In addition to those C++ types that are mappings of UNO types
+ (except for sal_uInt16 and sal_Unicode, see below), the following C++ types
+ are appropriate as template arguments: cppu::UnoVoidType, bool,
+ cppu::UnoUnsignedShortType, cppu::UnoCharType, cppu::UnoSequenceType with any
+ appropriate template argument (the latter three to unambiguously specify UNO
+ types, as the UNO types UNSIGNED SHORT and CHAR map to the same C++ type),
+ and com::sun::star::uno::Reference with any appropriate template argument.
+
+ @since UDK 3.2.2
+*/
+template< typename T > class UnoType {
+public:
+ static inline ::com::sun::star::uno::Type const & get() {
+ using namespace ::cppu::detail;
+ return cppu_detail_getUnoType(static_cast< T * >(0));
+ }
+
+private:
+ UnoType(UnoType &); // not defined
+ ~UnoType(); // not defined
+ void operator =(UnoType &); // not defined
+};
+
+/**
+ A working replacement for getCppuType (see there).
+
+ There are three overloads of this function that together form the replacement
+ of getCppuType. The replacement has exactly the same semantics as
+ getCppuType, in that it returns correct results for the UNO type UNSIGNED
+ SHORT but not for the UNO type CHAR.
+
+ @since UDK 3.2.2
+*/
+template< typename T > inline ::com::sun::star::uno::Type const &
+getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *) {
+ return ::cppu::UnoType< T >::get();
+}
+
+/**
+ A working replacement for getCppuType (see there).
+
+ There are three overloads of this function that together form the replacement
+ of getCppuType. The replacement has exactly the same semantics as
+ getCppuType, in that it returns correct results for the UNO type UNSIGNED
+ SHORT but not for the UNO type CHAR.
+
+ @since UDK 3.2.2
+*/
+inline ::com::sun::star::uno::Type const &
+getTypeFavourUnsigned(SAL_UNUSED_PARAMETER ::sal_uInt16 const *) {
+ return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
+}
+
+/**
+ A working replacement for getCppuType (see there).
+
+ There are three overloads of this function that together form the replacement
+ of getCppuType. The replacement has exactly the same semantics as
+ getCppuType, in that it returns correct results for the UNO type UNSIGNED
+ SHORT but not for the UNO type CHAR.
+
+ @since UDK 3.2.2
+*/
+template< typename T > inline ::com::sun::star::uno::Type const &
+getTypeFavourUnsigned(::com::sun::star::uno::Sequence< T > const *);
+ // defined in com/sun/star/uno/Sequence.hxx
+
+/// @cond INTERNAL
+
+/**
+ A working replacement for getCppuType (see there).
+
+ There are three overloads of this function that together form the replacement
+ of the getCppuType template. The replacement has exactly the same semantics
+ as the getCppuType template, in that it returns correct results for the UNO
+ type CHAR but not for the UNO type UNSIGNED SHORT. Additionally, it also
+ returns the intended results for sequence types.
+
+ @since UDK 3.2.3
+*/
+template< typename T > inline ::com::sun::star::uno::Type const &
+getTypeFavourChar(SAL_UNUSED_PARAMETER T const *) {
+ return ::cppu::UnoType< T >::get();
+}
+
+/**
+ A working replacement for getCppuType (see there).
+
+ There are three overloads of this function that together form the replacement
+ of the getCppuType template. The replacement has exactly the same semantics
+ as the getCppuType template, in that it returns correct results for the UNO
+ type CHAR but not for the UNO type UNSIGNED SHORT. Additionally, it also
+ returns the intended results for sequence types.
+
+ @since UDK 3.2.3
+*/
+inline ::com::sun::star::uno::Type const &
+getTypeFavourChar(SAL_UNUSED_PARAMETER ::sal_Unicode const *) {
+ return ::cppu::UnoType< ::cppu::UnoCharType >::get();
+}
+
+/**
+ A working replacement for getCppuType (see there).
+
+ There are three overloads of this function that together form the replacement
+ of the getCppuType template. The replacement has exactly the same semantics
+ as the getCppuType template, in that it returns correct results for the UNO
+ type CHAR but not for the UNO type UNSIGNED SHORT. Additionally, it also
+ returns the intended results for sequence types.
+
+ @since UDK 3.2.3
+*/
+template< typename T > inline ::com::sun::star::uno::Type const &
+getTypeFavourChar(::com::sun::star::uno::Sequence< T > const *);
+ // defined in com/sun/star/uno/Sequence.hxx
+
+/// @endcond
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */