include/com/sun/star/uno/Any.h | 5 +++++ include/com/sun/star/uno/Any.hxx | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
New commits: commit 0fbe22a77289a624e1346ab457734c2f64f8e6fb Author: Stephan Bergmann <sberg...@redhat.com> Date: Mon Jun 6 15:05:16 2016 +0200 css::uno::Any move semantics (for LIBO_INTERNAL_ONLY) Change-Id: Ib582a744321e0f209395651ac2edffe30152ffba diff --git a/include/com/sun/star/uno/Any.h b/include/com/sun/star/uno/Any.h index 26127f4..d6c7477 100644 --- a/include/com/sun/star/uno/Any.h +++ b/include/com/sun/star/uno/Any.h @@ -135,6 +135,11 @@ public: */ inline Any & SAL_CALL operator = ( const Any & rAny ); +#if defined LIBO_INTERNAL_ONLY + inline Any(Any && other); + inline Any & operator =(Any && other); +#endif + /** Gets the type of the set value. @return a Type object of the set value diff --git a/include/com/sun/star/uno/Any.hxx b/include/com/sun/star/uno/Any.hxx index 8859fa7..1e1f24e 100644 --- a/include/com/sun/star/uno/Any.hxx +++ b/include/com/sun/star/uno/Any.hxx @@ -21,6 +21,7 @@ #include <sal/config.h> +#include <algorithm> #include <cassert> #include <cstddef> #include <iomanip> @@ -120,6 +121,38 @@ inline Any & Any::operator = ( const Any & rAny ) return *this; } +#if defined LIBO_INTERNAL_ONLY + +namespace detail { + +inline void moveAnyInternals(Any & from, Any & to) { + uno_any_construct(&to, nullptr, nullptr, &cpp_acquire); + std::swap(from.pType, to.pType); + std::swap(from.pData, to.pData); + std::swap(from.pReserved, to.pReserved); + if (to.pData == &from.pReserved) { + to.pData = &to.pReserved; + } + // This leaves to.pData (where "to" is now VOID) dangling to somewhere (cf. + // CONSTRUCT_EMPTY_ANY, cppu/source/uno/prim.hxx), but what's relevant is + // only that it isn't a nullptr (as e.g. >>= -> uno_type_assignData -> + // _assignData takes a null pSource to mean "construct a default value"). +} + +} + +Any::Any(Any && other) { + detail::moveAnyInternals(other, *this); +} + +Any & Any::operator =(Any && other) { + uno_any_destruct(this, &cpp_release); + detail::moveAnyInternals(other, *this); + return *this; +} + +#endif + inline ::rtl::OUString Any::getValueTypeName() const { return ::rtl::OUString( pType->pTypeName ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits