diff options
Diffstat (limited to 'include/VBox/com/array.h')
-rw-r--r-- | include/VBox/com/array.h | 80 |
1 files changed, 51 insertions, 29 deletions
diff --git a/include/VBox/com/array.h b/include/VBox/com/array.h index 7f1796d9..77f9d60b 100644 --- a/include/VBox/com/array.h +++ b/include/VBox/com/array.h @@ -1,10 +1,9 @@ /** @file - * MS COM / XPCOM Abstraction Layer: - * Safe array helper class declaration + * MS COM / XPCOM Abstraction Layer - Safe array helper class declaration. */ /* - * Copyright (C) 2006-2011 Oracle Corporation + * Copyright (C) 2006-2014 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -608,21 +607,18 @@ public: */ SafeArray(ComSafeArrayIn(T, aArg)) { + if (aArg) + { #ifdef VBOX_WITH_XPCOM - AssertReturnVoid(aArg != NULL); - - m.size = aArgSize; - m.arr = aArg; - m.isWeak = true; + m.size = aArgSize; + m.arr = aArg; + m.isWeak = true; #else /* !VBOX_WITH_XPCOM */ - AssertReturnVoid(aArg != NULL); - SAFEARRAY *arg = aArg; + SAFEARRAY *arg = aArg; - if (arg) - { AssertReturnVoid(arg->cDims == 1); VARTYPE vt; @@ -634,12 +630,12 @@ public: rc = SafeArrayAccessData(arg, (void HUGEP **)&m.raw); AssertComRCReturnVoid(rc); - } - m.arr = arg; - m.isWeak = true; + m.arr = arg; + m.isWeak = true; #endif /* !VBOX_WITH_XPCOM */ + } } /** @@ -975,7 +971,7 @@ public: */ virtual SafeArray &detachTo(ComSafeArrayOut(T, aArg)) { - AssertReturn(m.isWeak == false, *this); + AssertReturn(!m.isWeak, *this); #ifdef VBOX_WITH_XPCOM @@ -1243,6 +1239,34 @@ inline void com::SafeArray<BYTE>::initFrom(const BYTE* aPtr, size_t aSize) template<> +inline void com::SafeArray<SHORT>::initFrom(const com::SafeArray<SHORT> & aRef) +{ + size_t sSize = aRef.size(); + resize(sSize); + ::memcpy(raw(), aRef.raw(), sSize * sizeof(SHORT)); +} +template<> +inline void com::SafeArray<SHORT>::initFrom(const SHORT* aPtr, size_t aSize) +{ + resize(aSize); + ::memcpy(raw(), aPtr, aSize * sizeof(SHORT)); +} + +template<> +inline void com::SafeArray<USHORT>::initFrom(const com::SafeArray<USHORT> & aRef) +{ + size_t sSize = aRef.size(); + resize(sSize); + ::memcpy(raw(), aRef.raw(), sSize * sizeof(USHORT)); +} +template<> +inline void com::SafeArray<USHORT>::initFrom(const USHORT* aPtr, size_t aSize) +{ + resize(aSize); + ::memcpy(raw(), aPtr, aSize * sizeof(USHORT)); +} + +template<> inline void com::SafeArray<LONG>::initFrom(const com::SafeArray<LONG> & aRef) { size_t sSize = aRef.size(); @@ -1523,21 +1547,18 @@ public: */ SafeIfaceArray(ComSafeArrayIn(I *, aArg)) { + if (aArg) + { #ifdef VBOX_WITH_XPCOM - AssertReturnVoid(aArg != NULL); - - Base::m.size = aArgSize; - Base::m.arr = aArg; - Base::m.isWeak = true; + Base::m.size = aArgSize; + Base::m.arr = aArg; + Base::m.isWeak = true; #else /* !VBOX_WITH_XPCOM */ - AssertReturnVoid(aArg != NULL); - SAFEARRAY *arg = aArg; + SAFEARRAY *arg = aArg; - if (arg) - { AssertReturnVoid(arg->cDims == 1); VARTYPE vt; @@ -1555,12 +1576,12 @@ public: rc = SafeArrayAccessData(arg, (void HUGEP **)&m.raw); AssertComRCReturnVoid(rc); - } - m.arr = arg; - m.isWeak = true; + m.arr = arg; + m.isWeak = true; #endif /* !VBOX_WITH_XPCOM */ + } } /** @@ -1699,4 +1720,5 @@ public: /** @} */ -#endif /* ___VBox_com_array_h */ +#endif /* !___VBox_com_array_h */ + |