diff options
Diffstat (limited to 'cppu/inc/cppu')
-rw-r--r-- | cppu/inc/cppu/Enterable.hxx | 114 | ||||
-rw-r--r-- | cppu/inc/cppu/EnvDcp.hxx | 75 | ||||
-rw-r--r-- | cppu/inc/cppu/EnvGuards.hxx | 113 | ||||
-rw-r--r-- | cppu/inc/cppu/FreeReference.hxx | 166 | ||||
-rw-r--r-- | cppu/inc/cppu/Map.hxx | 113 | ||||
-rw-r--r-- | cppu/inc/cppu/Shield.hxx | 90 | ||||
-rw-r--r-- | cppu/inc/cppu/helper/purpenv/Environment.hxx | 46 | ||||
-rw-r--r-- | cppu/inc/cppu/helper/purpenv/Mapping.hxx | 68 | ||||
-rw-r--r-- | cppu/inc/cppu/macros.hxx | 65 | ||||
-rw-r--r-- | cppu/inc/cppu/unotype.hxx | 377 |
10 files changed, 1227 insertions, 0 deletions
diff --git a/cppu/inc/cppu/Enterable.hxx b/cppu/inc/cppu/Enterable.hxx new file mode 100644 index 000000000000..c8bbfb49d382 --- /dev/null +++ b/cppu/inc/cppu/Enterable.hxx @@ -0,0 +1,114 @@ +/************************************************************************* + * + * 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 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, ¶m); + va_end(param); +} + +void Enterable::callOut(uno_EnvCallee * pCallee, ...) +{ + va_list param; + + va_start(param, pCallee); + callOut_v(pCallee, ¶m); + va_end(param); +} + +} + + +#endif diff --git a/cppu/inc/cppu/EnvDcp.hxx b/cppu/inc/cppu/EnvDcp.hxx new file mode 100644 index 000000000000..c4e394b98460 --- /dev/null +++ b/cppu/inc/cppu/EnvDcp.hxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * 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 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 diff --git a/cppu/inc/cppu/EnvGuards.hxx b/cppu/inc/cppu/EnvGuards.hxx new file mode 100644 index 000000000000..c7408f01cfd1 --- /dev/null +++ b/cppu/inc/cppu/EnvGuards.hxx @@ -0,0 +1,113 @@ +/************************************************************************* + * + * 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 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 diff --git a/cppu/inc/cppu/FreeReference.hxx b/cppu/inc/cppu/FreeReference.hxx new file mode 100644 index 000000000000..e2d60775c0b3 --- /dev/null +++ b/cppu/inc/cppu/FreeReference.hxx @@ -0,0 +1,166 @@ +/************************************************************************* + * + * 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 INCLUDED_cppu_FreeReference_hxx +#define INCLUDED_cppu_FreeReference_hxx + +#include "uno/environment.hxx" +#include "cppu/Map.hxx" +#include "com/sun/star/uno/Reference.h" + + +namespace cssuno = com::sun::star::uno; + + +namespace cppu +{ + /** Freely (environment independent) usable Reference. + (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/FreeReference) + + @since UDK 3.2.7 + */ + template< class T > + class FreeReference + { + cssuno::Environment m_env; + T * m_pObject; + + public: + FreeReference() : m_pObject(NULL) {} + + FreeReference(T * pObject, __sal_NoAcquire) + : m_env(cssuno::Environment::getCurrent()), + m_pObject(pObject) + { + } + + FreeReference(T * pObject) + : m_env(cssuno::Environment::getCurrent()), + m_pObject(pObject) + { + if (m_pObject) + m_env.get()->pExtEnv->acquireInterface(m_env.get()->pExtEnv, m_pObject); + } + + explicit FreeReference(cssuno::Reference<T> const & xRef) + : m_env(cssuno::Environment::getCurrent()), + m_pObject(xRef.get()) + { + if (m_pObject) + m_env.get()->pExtEnv->acquireInterface(m_env.get()->pExtEnv, m_pObject); + } + + FreeReference(FreeReference<T> const & rOther) + : m_env (rOther.m_env), + m_pObject(rOther.m_pObject) + { + if (m_pObject) + m_env.get()->pExtEnv->acquireInterface(m_env.get()->pExtEnv, m_pObject); + } + + + ~FreeReference() + { + clear(); + } + + cssuno::Environment getEnv() const throw (cssuno::RuntimeException) + { + return m_env; + } + + cssuno::Reference<T> get() const throw (cssuno::RuntimeException) + { + return cssuno::Reference<T>(cppu::mapIn(m_pObject, m_env), SAL_NO_ACQUIRE); + } + + operator cssuno::Reference<T> () const throw (cssuno::RuntimeException) + { + return get(); + } + + cssuno::Reference<T> operator -> () const throw (cssuno::RuntimeException) + { + return get(); + } + + bool is() const throw (cssuno::RuntimeException) + { + return m_pObject != NULL; + } + + void clear() + { + if (m_pObject) + { + + m_env.get()->pExtEnv->releaseInterface(m_env.get()->pExtEnv, m_pObject); + m_pObject = NULL; + m_env.clear(); + } + } + + FreeReference<T> & operator = (FreeReference<T> const & rOther) + { + clear(); + + m_pObject = rOther.m_pObject; + if (m_pObject) + { + m_env = rOther.m_env; + m_env.get()->pExtEnv->acquireInterface(m_env.get()->pExtEnv, m_pObject); + } + + return *this; + } + + void set(cssuno::Reference<T> const & xRef) + { + clear(); + + m_pObject = xRef.get(); + if (m_pObject) + { + m_env = cssuno::Environment::getCurrent(); + + m_env.get()->pExtEnv->acquireInterface(m_env.get()->pExtEnv, m_pObject); + } + } + + bool operator == (FreeReference const & rOther) const + { + return get() == rOther.get(); + } + + bool operator != (FreeReference const & rOther) const + { + return !operator==(rOther); + } + }; +} + +#endif diff --git a/cppu/inc/cppu/Map.hxx b/cppu/inc/cppu/Map.hxx new file mode 100644 index 000000000000..455bee6e5fbd --- /dev/null +++ b/cppu/inc/cppu/Map.hxx @@ -0,0 +1,113 @@ +/************************************************************************* + * + * 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 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 diff --git a/cppu/inc/cppu/Shield.hxx b/cppu/inc/cppu/Shield.hxx new file mode 100644 index 000000000000..46cdaeacea06 --- /dev/null +++ b/cppu/inc/cppu/Shield.hxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * 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 INCLUDED_cppu_Shield_hxx +#define INCLUDED_cppu_Shield_hxx + +#include <cppu/Map.hxx> + + +namespace cssu = com::sun::star::uno; + +namespace cppu +{ + /** Helpers for mapping objects relative to the thread-safe and current environments. + (http://wiki.services.openoffice.org/wiki/Uno/Cpp/Spec/Shield_Helpers) + */ + + + /** Maps an object from the current to the thread-safe Environment, returns mapped object. + + @param pT the object to be mapped + @return the mapped object + @since UDK 3.2.7 + */ + template<class T> inline T * shield(T * pT) + { + return mapOut(pT, cssu::Environment(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CPPU_STRINGIFY(CPPU_ENV))))); + } + + /** Maps an object from the thread-safe Environment to the current one, returns mapped object. + + @param pT the object to be mapped + @return the mapped object + @since UDK 3.2.7 + */ + template<class T> inline T * unshield(T * pT) + { + return mapIn(pT, cssu::Environment(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CPPU_STRINGIFY(CPPU_ENV))))); + } + + + /** Maps an any from the current to the thread-safe Environment, fills the passed any. + + @param any the any to be mapped + @param the target any + @since UDK 3.2.7 + */ + inline void shieldAny(cssu::Any const & any, cssu::Any * res) + { + mapOutAny(any, res, cssu::Environment(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CPPU_STRINGIFY(CPPU_ENV))))); + } + + + /** Maps an any from the thread-safe Environment to the current one, fills the passed any. + + @param any the any to be mapped + @param the target any + @since UDK 3.2.7 + */ + inline void unshieldAny(cssu::Any const & any, cssu::Any * res) + { + mapInAny(any, res, cssu::Environment(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CPPU_STRINGIFY(CPPU_ENV))))); + } +} + +#endif diff --git a/cppu/inc/cppu/helper/purpenv/Environment.hxx b/cppu/inc/cppu/helper/purpenv/Environment.hxx new file mode 100644 index 000000000000..ba56c22e53cf --- /dev/null +++ b/cppu/inc/cppu/helper/purpenv/Environment.hxx @@ -0,0 +1,46 @@ +/************************************************************************* + * + * 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 INCLUDED_cppu_helper_purpenv_Environment_hxx +#define INCLUDED_cppu_helper_purpenv_Environment_hxx + +#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 +*/ +void Environment_initWithEnterable(uno_Environment * pEnvironment, cppu::Enterable * pEnterable); + +}}} + +#endif diff --git a/cppu/inc/cppu/helper/purpenv/Mapping.hxx b/cppu/inc/cppu/helper/purpenv/Mapping.hxx new file mode 100644 index 000000000000..c20309e7a180 --- /dev/null +++ b/cppu/inc/cppu/helper/purpenv/Mapping.hxx @@ -0,0 +1,68 @@ +/************************************************************************* + * + * 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 INCLUDED_cppu_helper_purpenv_Mapping_hxx +#define INCLUDED_cppu_helper_purpenv_Mapping_hxx + +#include "com/sun/star/uno/Any.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 ); + + + +void createMapping(uno_Mapping ** ppMapping, + uno_Environment * pFrom, + uno_Environment * pTo, + ProbeFun * probeFun = NULL, + void * pContext = NULL + ); + +}}} + +#endif diff --git a/cppu/inc/cppu/macros.hxx b/cppu/inc/cppu/macros.hxx new file mode 100644 index 000000000000..fd64d1c767df --- /dev/null +++ b/cppu/inc/cppu/macros.hxx @@ -0,0 +1,65 @@ +/************************************************************************* + * + * 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 _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 + +/** 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.) + + @internal +*/ +#if defined(__GNUC__) && (__GNUC__ >= 3) +#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. + + @internal +*/ +#define CPPU_GCC_DLLPUBLIC_EXPORT SAL_EXCEPTION_DLLPUBLIC_EXPORT +#define CPPU_GCC_DLLPRIVATE SAL_EXCEPTION_DLLPRIVATE + +#endif // _CPPU_MACROS_HXX_ + diff --git a/cppu/inc/cppu/unotype.hxx b/cppu/inc/cppu/unotype.hxx new file mode 100644 index 000000000000..bef23d3cf38d --- /dev/null +++ b/cppu/inc/cppu/unotype.hxx @@ -0,0 +1,377 @@ +/************************************************************************* + * + * 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 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)); +} + +} + +} + +// For _MSC_VER 1310, define cppu_detail_getUnoType in the global namespace, to +// avoid spurious compiler errors in code that calls cppu_detail_getUnoType: +#if !defined _MSC_VER || _MSC_VER > 1310 +namespace cppu { namespace detail { +#endif + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(::cppu::UnoVoidType const *) { + return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_VOID); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(bool const *) { + return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BOOLEAN); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(::sal_Bool const *) { + return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BOOLEAN); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(::sal_Int8 const *) { + return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BYTE); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(::sal_Int16 const *) { + return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_SHORT); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(::cppu::UnoUnsignedShortType const *) { + return ::cppu::detail::getTypeFromTypeClass( + ::typelib_TypeClass_UNSIGNED_SHORT); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(::sal_Int32 const *) { + return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_LONG); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(::sal_uInt32 const *) { + return ::cppu::detail::getTypeFromTypeClass( + ::typelib_TypeClass_UNSIGNED_LONG); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(::sal_Int64 const *) { + return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_HYPER); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(::sal_uInt64 const *) { + return ::cppu::detail::getTypeFromTypeClass( + ::typelib_TypeClass_UNSIGNED_HYPER); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(float const *) { + return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_FLOAT); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(double const *) { + return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_DOUBLE); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(::cppu::UnoCharType const *) { + return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_CHAR); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(::rtl::OUString const *) { + return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_STRING); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(::com::sun::star::uno::Type const *) { + return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_TYPE); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(::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(::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(::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(::com::sun::star::uno::Exception const *) { + return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_EXCEPTION); +} + +inline ::com::sun::star::uno::Type const & +cppu_detail_getUnoType(::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(::com::sun::star::uno::Reference< T > const *) { + return ::cppu::UnoType< T >::get(); +} + +#if !defined _MSC_VER || _MSC_VER > 1310 +} } +#endif + +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(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_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 + +/** + 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. + + @internal + + @since UDK 3.2.3 +*/ +template< typename T > inline ::com::sun::star::uno::Type const & +getTypeFavourChar(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. + + @internal + + @since UDK 3.2.3 +*/ +inline ::com::sun::star::uno::Type const & +getTypeFavourChar(::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. + + @internal + + @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 + +} + +#endif |