Index: /trunk/include/VBox/com/array.h
===================================================================
--- /trunk/include/VBox/com/array.h	(revision 36185)
+++ /trunk/include/VBox/com/array.h	(revision 36186)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -56,7 +56,7 @@
  * @code
 
-    STDMETHOD(TestArrays) (ComSafeArrayIn (LONG, aIn),
-                           ComSafeArrayOut (LONG, aOut),
-                           ComSafeArrayOut (LONG, aRet));
+    STDMETHOD(TestArrays)(ComSafeArrayIn(LONG, aIn),
+                          ComSafeArrayOut(LONG, aOut),
+                          ComSafeArrayOut(LONG, aRet));
 
  * @endcode
@@ -65,33 +65,33 @@
  * @code
 
-    STDMETHODIMP Component::TestArrays (ComSafeArrayIn (LONG, aIn),
-                                        ComSafeArrayOut (LONG, aOut),
-                                        ComSafeArrayOut (LONG, aRet))
-    {
-        if (ComSafeArrayInIsNull (aIn))
+    STDMETHODIMP Component::TestArrays(ComSafeArrayIn(LONG, aIn),
+                                       ComSafeArrayOut(LONG, aOut),
+                                       ComSafeArrayOut(LONG, aRet))
+    {
+        if (ComSafeArrayInIsNull(aIn))
             return E_INVALIDARG;
-        if (ComSafeArrayOutIsNull (aOut))
+        if (ComSafeArrayOutIsNull(aOut))
             return E_POINTER;
-        if (ComSafeArrayOutIsNull (aRet))
+        if (ComSafeArrayOutIsNull(aRet))
             return E_POINTER;
 
         // Use SafeArray to access the input array parameter
 
-        com::SafeArray <LONG> in (ComSafeArrayInArg (aIn));
+        com::SafeArray<LONG> in(ComSafeArrayInArg(aIn));
 
         for (size_t i = 0; i < in.size(); ++ i)
-            LogFlow (("*** in[%u]=%d\n", i, in [i]));
+            LogFlow(("*** in[%u]=%d\n", i, in[i]));
 
         // Use SafeArray to create the return array (the same technique is used
         // for output array parameters)
 
-        SafeArray <LONG> ret (in.size() * 2);
+        SafeArray<LONG> ret(in.size() * 2);
         for (size_t i = 0; i < in.size(); ++ i)
         {
-            ret [i] = in [i];
-            ret [i + in.size()] = in [i] * 10;
-        }
-
-        ret.detachTo (ComSafeArrayOutArg (aRet));
+            ret[i] = in[i];
+            ret[i + in.size()] = in[i] * 10;
+        }
+
+        ret.detachTo(ComSafeArrayOutArg(aRet));
 
         return S_OK;
@@ -103,23 +103,23 @@
  * @code
 
-    ComPtr <ISomething> component;
+    ComPtr<ISomething> component;
 
     // ...
 
-    com::SafeArray <LONG> in (3);
-    in [0] = -1;
-    in [1] = -2;
-    in [2] = -3;
-
-    com::SafeArray <LONG> out;
-    com::SafeArray <LONG> ret;
-
-    HRESULT rc = component->TestArrays (ComSafeArrayAsInParam (in),
-                                        ComSafeArrayAsOutParam (out),
-                                        ComSafeArrayAsOutParam (ret));
-
-    if (SUCCEEDED (rc))
+    com::SafeArray<LONG> in(3);
+    in[0] = -1;
+    in[1] = -2;
+    in[2] = -3;
+
+    com::SafeArray<LONG> out;
+    com::SafeArray<LONG> ret;
+
+    HRESULT rc = component->TestArrays(ComSafeArrayAsInParam(in),
+                                       ComSafeArrayAsOutParam(out),
+                                       ComSafeArrayAsOutParam(ret));
+
+    if (SUCCEEDED(rc))
         for (size_t i = 0; i < ret.size(); ++ i)
-            printf ("*** ret[%u]=%d\n", i, ret [i]);
+            printf("*** ret[%u]=%d\n", i, ret[i]);
 
  * @endcode
@@ -130,10 +130,10 @@
  * @code
 
-    STDMETHODIMP Component::COMGETTER(Values) (ComSafeArrayOut (int, aValues))
-    {
-        // ... assume there is a |std::list <int> mValues| data member
-
-        com::SafeArray <int> values (mValues);
-        values.detachTo (ComSafeArrayOutArg (aValues));
+    STDMETHODIMP Component::COMGETTER(Values)(ComSafeArrayOut(int, aValues))
+    {
+        // ... assume there is a |std::list<int> mValues| data member
+
+        com::SafeArray<int> values(mValues);
+        values.detachTo(ComSafeArrayOutArg(aValues));
 
         return S_OK;
@@ -151,5 +151,5 @@
  *
  * Also note that in order to pass input BSTR array parameters declared
- * using the ComSafeArrayIn (IN_BSTR, aParam) macro to the SafeArray<>
+ * using the ComSafeArrayIn(IN_BSTR, aParam) macro to the SafeArray<>
  * constructor using the ComSafeArrayInArg() macro, you should use IN_BSTR
  * as the SafeArray<> template argument, not just BSTR.
@@ -161,5 +161,5 @@
  */
 
-#if defined (VBOX_WITH_XPCOM)
+#ifdef VBOX_WITH_XPCOM
 # include <nsMemory.h>
 #endif
@@ -169,5 +169,5 @@
 #include "VBox/com/assert.h"
 
-#if defined (VBOX_WITH_XPCOM)
+#ifdef VBOX_WITH_XPCOM
 
 /**
@@ -179,5 +179,5 @@
  */
 #define ComSafeArrayAsInParam(aArray)   \
-    (aArray).size(), (aArray).__asInParam_Arr ((aArray).raw())
+    (aArray).size(), (aArray).__asInParam_Arr((aArray).raw())
 
 /**
@@ -191,5 +191,5 @@
     (aArray).__asOutParam_Size(), (aArray).__asOutParam_Arr()
 
-#else /* defined (VBOX_WITH_XPCOM) */
+#else /* !VBOX_WITH_XPCOM */
 
 #define ComSafeArrayAsInParam(aArray)   (aArray).__asInParam()
@@ -197,5 +197,5 @@
 #define ComSafeArrayAsOutParam(aArray)  (aArray).__asOutParam()
 
-#endif /* defined (VBOX_WITH_XPCOM) */
+#endif /* !VBOX_WITH_XPCOM */
 
 /**
@@ -205,5 +205,5 @@
 {
 
-#if defined (VBOX_WITH_XPCOM)
+#ifdef VBOX_WITH_XPCOM
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -214,5 +214,5 @@
  * @param T Type of array elements.
  */
-template <typename T>
+template<typename T>
 struct SafeArrayTraits
 {
@@ -220,11 +220,11 @@
 
     /** Initializes memory for aElem. */
-    static void Init (T &aElem) { aElem = 0; }
+    static void Init(T &aElem) { aElem = 0; }
 
     /** Initializes memory occupied by aElem. */
-    static void Uninit (T &aElem) { aElem = 0; }
+    static void Uninit(T &aElem) { aElem = 0; }
 
     /** Creates a deep copy of aFrom and stores it in aTo. */
-    static void Copy (const T &aFrom, T &aTo) { aTo = aFrom; }
+    static void Copy(const T &aFrom, T &aTo) { aTo = aFrom; }
 
 public:
@@ -235,10 +235,10 @@
      * (char/PRUnichar pointers) as const but doesn't do so for pointers to
      * arrays. */
-    static T *__asInParam_Arr (T *aArr) { return aArr; }
-    static T *__asInParam_Arr (const T *aArr) { return const_cast <T *> (aArr); }
-};
-
-template <typename T>
-struct SafeArrayTraits <T *>
+    static T *__asInParam_Arr(T *aArr) { return aArr; }
+    static T *__asInParam_Arr(const T *aArr) { return const_cast<T *>(aArr); }
+};
+
+template<typename T>
+struct SafeArrayTraits<T *>
 {
     // Arbitrary pointers are not supported
@@ -246,23 +246,23 @@
 
 template<>
-struct SafeArrayTraits <PRUnichar *>
+struct SafeArrayTraits<PRUnichar *>
 {
 protected:
 
-    static void Init (PRUnichar * &aElem) { aElem = NULL; }
-
-    static void Uninit (PRUnichar * &aElem)
+    static void Init(PRUnichar * &aElem) { aElem = NULL; }
+
+    static void Uninit(PRUnichar * &aElem)
     {
         if (aElem)
         {
-            ::SysFreeString (aElem);
+            ::SysFreeString(aElem);
             aElem = NULL;
         }
     }
 
-    static void Copy (const PRUnichar * aFrom, PRUnichar * &aTo)
-    {
-        AssertCompile (sizeof (PRUnichar) == sizeof (OLECHAR));
-        aTo = aFrom ? ::SysAllocString ((const OLECHAR *) aFrom) : NULL;
+    static void Copy(const PRUnichar * aFrom, PRUnichar * &aTo)
+    {
+        AssertCompile(sizeof(PRUnichar) == sizeof(OLECHAR));
+        aTo = aFrom ? ::SysAllocString((const OLECHAR *)aFrom) : NULL;
     }
 
@@ -270,30 +270,30 @@
 
     /* Magic to workaround strict rules of par. 4.4.4 of the C++ standard */
-    static const PRUnichar **__asInParam_Arr (PRUnichar **aArr)
-    {
-        return const_cast <const PRUnichar **> (aArr);
-    }
-    static const PRUnichar **__asInParam_Arr (const PRUnichar **aArr) { return aArr; }
+    static const PRUnichar **__asInParam_Arr(PRUnichar **aArr)
+    {
+        return const_cast<const PRUnichar **>(aArr);
+    }
+    static const PRUnichar **__asInParam_Arr(const PRUnichar **aArr) { return aArr; }
 };
 
 template<>
-struct SafeArrayTraits <const PRUnichar *>
+struct SafeArrayTraits<const PRUnichar *>
 {
 protected:
 
-    static void Init (const PRUnichar * &aElem) { aElem = NULL; }
-    static void Uninit (const PRUnichar * &aElem)
+    static void Init(const PRUnichar * &aElem) { aElem = NULL; }
+    static void Uninit(const PRUnichar * &aElem)
     {
         if (aElem)
         {
-            ::SysFreeString (const_cast <PRUnichar *> (aElem));
+            ::SysFreeString(const_cast<PRUnichar *>(aElem));
             aElem = NULL;
         }
     }
 
-    static void Copy (const PRUnichar * aFrom, const PRUnichar * &aTo)
-    {
-        AssertCompile (sizeof (PRUnichar) == sizeof (OLECHAR));
-        aTo = aFrom ? ::SysAllocString ((const OLECHAR *) aFrom) : NULL;
+    static void Copy(const PRUnichar * aFrom, const PRUnichar * &aTo)
+    {
+        AssertCompile(sizeof(PRUnichar) == sizeof(OLECHAR));
+        aTo = aFrom ? ::SysAllocString((const OLECHAR *)aFrom) : NULL;
     }
 
@@ -301,28 +301,28 @@
 
     /* Magic to workaround strict rules of par. 4.4.4 of the C++ standard */
-    static const PRUnichar **__asInParam_Arr (const PRUnichar **aArr) { return aArr; }
+    static const PRUnichar **__asInParam_Arr(const PRUnichar **aArr) { return aArr; }
 };
 
 template<>
-struct SafeArrayTraits <nsID *>
+struct SafeArrayTraits<nsID *>
 {
 protected:
 
-    static void Init (nsID * &aElem) { aElem = NULL; }
-
-    static void Uninit (nsID * &aElem)
+    static void Init(nsID * &aElem) { aElem = NULL; }
+
+    static void Uninit(nsID * &aElem)
     {
         if (aElem)
         {
-            ::nsMemory::Free (aElem);
+            ::nsMemory::Free(aElem);
             aElem = NULL;
         }
     }
 
-    static void Copy (const nsID * aFrom, nsID * &aTo)
+    static void Copy(const nsID * aFrom, nsID * &aTo)
     {
         if (aFrom)
         {
-            aTo = (nsID *) ::nsMemory::Alloc (sizeof (nsID));
+            aTo = (nsID *) ::nsMemory::Alloc(sizeof(nsID));
             if (aTo)
                 *aTo = *aFrom;
@@ -336,18 +336,18 @@
      * be never called in context of SafeConstGUIDArray. */
 
-    static void Init (const nsID * &aElem) { NOREF (aElem); AssertFailed(); }
-    static void Uninit (const nsID * &aElem) { NOREF (aElem); AssertFailed(); }
+    static void Init(const nsID * &aElem) { NOREF(aElem); AssertFailed(); }
+    static void Uninit(const nsID * &aElem) { NOREF(aElem); AssertFailed(); }
 
 public:
 
     /** Magic to workaround strict rules of par. 4.4.4 of the C++ standard. */
-    static const nsID **__asInParam_Arr (nsID **aArr)
-    {
-        return const_cast <const nsID **> (aArr);
-    }
-    static const nsID **__asInParam_Arr (const nsID **aArr) { return aArr; }
-};
-
-#else /* defined (VBOX_WITH_XPCOM) */
+    static const nsID **__asInParam_Arr(nsID **aArr)
+    {
+        return const_cast<const nsID **>(aArr);
+    }
+    static const nsID **__asInParam_Arr(const nsID **aArr) { return aArr; }
+};
+
+#else /* !VBOX_WITH_XPCOM */
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -357,6 +357,6 @@
 protected:
 
-    static SAFEARRAY *CreateSafeArray (VARTYPE aVarType, SAFEARRAYBOUND *aBound)
-    { return SafeArrayCreate (aVarType, 1, aBound); }
+    static SAFEARRAY *CreateSafeArray(VARTYPE aVarType, SAFEARRAYBOUND *aBound)
+    { return SafeArrayCreate(aVarType, 1, aBound); }
 };
 
@@ -373,14 +373,14 @@
     // Returns the number of VarType() elements necessary for aSize
     // elements of T
-    static ULONG VarCount (size_t aSize);
+    static ULONG VarCount(size_t aSize);
 
     // Returns the number of elements of T that fit into the given number of
-    // VarType() elements (opposite to VarCount (size_t aSize)).
-    static size_t Size (ULONG aVarCount);
+    // VarType() elements (opposite to VarCount(size_t aSize)).
+    static size_t Size(ULONG aVarCount);
 
     // Creates a deep copy of aFrom and stores it in aTo
-    static void Copy (ULONG aFrom, ULONG &aTo);
+    static void Copy(ULONG aFrom, ULONG &aTo);
  */
-template <typename T>
+template<typename T>
 struct SafeArrayTraits : public SafeArrayTraitsBase
 {
@@ -394,31 +394,31 @@
     static VARTYPE VarType()
     {
-        if (sizeof (T) % 8 == 0) return VT_I8;
-        if (sizeof (T) % 4 == 0) return VT_I4;
-        if (sizeof (T) % 2 == 0) return VT_I2;
+        if (sizeof(T) % 8 == 0) return VT_I8;
+        if (sizeof(T) % 4 == 0) return VT_I4;
+        if (sizeof(T) % 2 == 0) return VT_I2;
         return VT_I1;
     }
 
-    static ULONG VarCount (size_t aSize)
-    {
-        if (sizeof (T) % 8 == 0) return (ULONG) ((sizeof (T) / 8) * aSize);
-        if (sizeof (T) % 4 == 0) return (ULONG) ((sizeof (T) / 4) * aSize);
-        if (sizeof (T) % 2 == 0) return (ULONG) ((sizeof (T) / 2) * aSize);
-        return (ULONG) (sizeof (T) * aSize);
-    }
-
-    static size_t Size (ULONG aVarCount)
-    {
-        if (sizeof (T) % 8 == 0) return (size_t) (aVarCount * 8) / sizeof (T);
-        if (sizeof (T) % 4 == 0) return (size_t) (aVarCount * 4) / sizeof (T);
-        if (sizeof (T) % 2 == 0) return (size_t) (aVarCount * 2) / sizeof (T);
-        return (size_t) aVarCount / sizeof (T);
-    }
-
-    static void Copy (T aFrom, T &aTo) { aTo = aFrom; }
-};
-
-template <typename T>
-struct SafeArrayTraits <T *>
+    static ULONG VarCount(size_t aSize)
+    {
+        if (sizeof(T) % 8 == 0) return (ULONG)((sizeof(T) / 8) * aSize);
+        if (sizeof(T) % 4 == 0) return (ULONG)((sizeof(T) / 4) * aSize);
+        if (sizeof(T) % 2 == 0) return (ULONG)((sizeof(T) / 2) * aSize);
+        return (ULONG)(sizeof(T) * aSize);
+    }
+
+    static size_t Size(ULONG aVarCount)
+    {
+        if (sizeof(T) % 8 == 0) return (size_t)(aVarCount * 8) / sizeof(T);
+        if (sizeof(T) % 4 == 0) return (size_t)(aVarCount * 4) / sizeof(T);
+        if (sizeof(T) % 2 == 0) return (size_t)(aVarCount * 2) / sizeof(T);
+        return (size_t) aVarCount / sizeof(T);
+    }
+
+    static void Copy(T aFrom, T &aTo) { aTo = aFrom; }
+};
+
+template<typename T>
+struct SafeArrayTraits<T *>
 {
     // Arbitrary pointer types are not supported
@@ -429,68 +429,68 @@
 
 template<>
-struct SafeArrayTraits <LONG> : public SafeArrayTraitsBase
+struct SafeArrayTraits<LONG> : public SafeArrayTraitsBase
 {
 protected:
 
     static VARTYPE VarType() { return VT_I4; }
-    static ULONG VarCount (size_t aSize) { return (ULONG) aSize; }
-    static size_t Size (ULONG aVarCount) { return (size_t) aVarCount; }
-
-    static void Copy (LONG aFrom, LONG &aTo) { aTo = aFrom; }
+    static ULONG VarCount(size_t aSize) { return (ULONG)aSize; }
+    static size_t Size(ULONG aVarCount) { return (size_t)aVarCount; }
+
+    static void Copy(LONG aFrom, LONG &aTo) { aTo = aFrom; }
 };
 
 template<>
-struct SafeArrayTraits <ULONG> : public SafeArrayTraitsBase
+struct SafeArrayTraits<ULONG> : public SafeArrayTraitsBase
 {
 protected:
 
     static VARTYPE VarType() { return VT_UI4; }
-    static ULONG VarCount (size_t aSize) { return (ULONG) aSize; }
-    static size_t Size (ULONG aVarCount) { return (size_t) aVarCount; }
-
-    static void Copy (ULONG aFrom, ULONG &aTo) { aTo = aFrom; }
+    static ULONG VarCount(size_t aSize) { return (ULONG)aSize; }
+    static size_t Size(ULONG aVarCount) { return (size_t)aVarCount; }
+
+    static void Copy(ULONG aFrom, ULONG &aTo) { aTo = aFrom; }
 };
 
 template<>
-struct SafeArrayTraits <LONG64> : public SafeArrayTraitsBase
+struct SafeArrayTraits<LONG64> : public SafeArrayTraitsBase
 {
 protected:
 
     static VARTYPE VarType() { return VT_I8; }
-    static ULONG VarCount (size_t aSize) { return (ULONG) aSize; }
-    static size_t Size (ULONG aVarCount) { return (size_t) aVarCount; }
-
-    static void Copy (LONG64 aFrom, LONG64 &aTo) { aTo = aFrom; }
+    static ULONG VarCount(size_t aSize) { return (ULONG)aSize; }
+    static size_t Size(ULONG aVarCount) { return (size_t)aVarCount; }
+
+    static void Copy(LONG64 aFrom, LONG64 &aTo) { aTo = aFrom; }
 };
 
 template<>
-struct SafeArrayTraits <ULONG64> : public SafeArrayTraitsBase
+struct SafeArrayTraits<ULONG64> : public SafeArrayTraitsBase
 {
 protected:
 
     static VARTYPE VarType() { return VT_UI8; }
-    static ULONG VarCount (size_t aSize) { return (ULONG) aSize; }
-    static size_t Size (ULONG aVarCount) { return (size_t) aVarCount; }
-
-    static void Copy (ULONG64 aFrom, ULONG64 &aTo) { aTo = aFrom; }
+    static ULONG VarCount(size_t aSize) { return (ULONG)aSize; }
+    static size_t Size(ULONG aVarCount) { return (size_t)aVarCount; }
+
+    static void Copy(ULONG64 aFrom, ULONG64 &aTo) { aTo = aFrom; }
 };
 
 template<>
-struct SafeArrayTraits <BSTR> : public SafeArrayTraitsBase
+struct SafeArrayTraits<BSTR> : public SafeArrayTraitsBase
 {
 protected:
 
     static VARTYPE VarType() { return VT_BSTR; }
-    static ULONG VarCount (size_t aSize) { return (ULONG) aSize; }
-    static size_t Size (ULONG aVarCount) { return (size_t) aVarCount; }
-
-    static void Copy (BSTR aFrom, BSTR &aTo)
-    {
-        aTo = aFrom ? ::SysAllocString ((const OLECHAR *) aFrom) : NULL;
+    static ULONG VarCount(size_t aSize) { return (ULONG)aSize; }
+    static size_t Size(ULONG aVarCount) { return (size_t)aVarCount; }
+
+    static void Copy(BSTR aFrom, BSTR &aTo)
+    {
+        aTo = aFrom ? ::SysAllocString((const OLECHAR *)aFrom) : NULL;
     }
 };
 
 template<>
-struct SafeArrayTraits <GUID> : public SafeArrayTraitsBase
+struct SafeArrayTraits<GUID> : public SafeArrayTraitsBase
 {
 protected:
@@ -500,13 +500,13 @@
 
     /* GUID is 128 bit, so we need two VT_UI8 */
-    static ULONG VarCount (size_t aSize)
-    {
-        AssertCompileSize (GUID, 16);
-        return (ULONG) (aSize * 2);
-    }
-
-    static size_t Size (ULONG aVarCount) { return (size_t) aVarCount / 2; }
-
-    static void Copy (GUID aFrom, GUID &aTo) { aTo = aFrom; }
+    static ULONG VarCount(size_t aSize)
+    {
+        AssertCompileSize(GUID, 16);
+        return (ULONG)(aSize * 2);
+    }
+
+    static size_t Size(ULONG aVarCount) { return (size_t)aVarCount / 2; }
+
+    static void Copy(GUID aFrom, GUID &aTo) { aTo = aFrom; }
 };
 
@@ -517,11 +517,11 @@
 class OutSafeArrayDipper
 {
-    OutSafeArrayDipper (SAFEARRAY **aArr, void **aRaw)
-        : arr (aArr), raw (aRaw) { Assert (*aArr == NULL && *aRaw == NULL); }
+    OutSafeArrayDipper(SAFEARRAY **aArr, void **aRaw)
+        : arr(aArr), raw(aRaw) { Assert(*aArr == NULL && *aRaw == NULL); }
 
     SAFEARRAY **arr;
     void **raw;
 
-    template <class, class> friend class SafeArray;
+    template<class, class> friend class SafeArray;
 
 public:
@@ -531,6 +531,6 @@
         if (*arr != NULL)
         {
-            HRESULT rc = SafeArrayAccessData (*arr, raw);
-            AssertComRC (rc);
+            HRESULT rc = SafeArrayAccessData(*arr, raw);
+            AssertComRC(rc);
         }
     }
@@ -539,5 +539,5 @@
 };
 
-#endif /* defined (VBOX_WITH_XPCOM) */
+#endif /* !VBOX_WITH_XPCOM */
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -569,5 +569,5 @@
  * @note This class is not thread-safe.
  */
-template  <typename T, class Traits = SafeArrayTraits <T> >
+template<typename T, class Traits = SafeArrayTraits<T> >
 class SafeArray : public Traits
 {
@@ -589,5 +589,5 @@
      *       The constructor will also assert in this case.
      */
-    SafeArray (size_t aSize) { resize (aSize); }
+    SafeArray(size_t aSize) { resize(aSize); }
 
     /**
@@ -597,5 +597,5 @@
      * this:
      * <pre>
-     *  SafeArray safeArray (ComSafeArrayInArg (aArg));
+     *  SafeArray safeArray(ComSafeArrayInArg(aArg));
      * </pre>
      *
@@ -606,9 +606,9 @@
      * @param aArg  Input method parameter to attach to.
      */
-    SafeArray (ComSafeArrayIn (T, aArg))
-    {
-#if defined (VBOX_WITH_XPCOM)
-
-        AssertReturnVoid (aArg != NULL);
+    SafeArray(ComSafeArrayIn(T, aArg))
+    {
+#ifdef VBOX_WITH_XPCOM
+
+        AssertReturnVoid(aArg != NULL);
 
         m.size = aArgSize;
@@ -616,22 +616,22 @@
         m.isWeak = true;
 
-#else /* defined (VBOX_WITH_XPCOM) */
-
-        AssertReturnVoid (aArg != NULL);
+#else /* !VBOX_WITH_XPCOM */
+
+        AssertReturnVoid(aArg != NULL);
         SAFEARRAY *arg = aArg;
 
         if (arg)
         {
-            AssertReturnVoid (arg->cDims == 1);
+            AssertReturnVoid(arg->cDims == 1);
 
             VARTYPE vt;
-            HRESULT rc = SafeArrayGetVartype (arg, &vt);
-            AssertComRCReturnVoid (rc);
-            AssertMsgReturnVoid (vt == VarType(),
-                                 ("Expected vartype %d, got %d.\n",
-                                  VarType(), vt));
-
-            rc = SafeArrayAccessData (arg, (void HUGEP **) &m.raw);
-            AssertComRCReturnVoid (rc);
+            HRESULT rc = SafeArrayGetVartype(arg, &vt);
+            AssertComRCReturnVoid(rc);
+            AssertMsgReturnVoid(vt == VarType(),
+                                ("Expected vartype %d, got %d.\n",
+                                 VarType(), vt));
+
+            rc = SafeArrayAccessData(arg, (void HUGEP **)&m.raw);
+            AssertComRCReturnVoid(rc);
         }
 
@@ -639,5 +639,5 @@
         m.isWeak = true;
 
-#endif /* defined (VBOX_WITH_XPCOM) */
+#endif /* !VBOX_WITH_XPCOM */
     }
 
@@ -651,17 +651,17 @@
      *              @c aCntr).
      */
-    template <template <typename, typename> class C, class A>
-    SafeArray (const C <T, A> & aCntr)
-    {
-        resize (aCntr.size());
-        AssertReturnVoid (!isNull());
+    template<template<typename, typename> class C, class A>
+    SafeArray(const C<T, A> & aCntr)
+    {
+        resize(aCntr.size());
+        AssertReturnVoid(!isNull());
 
         size_t i = 0;
-        for (typename C <T, A>::const_iterator it = aCntr.begin();
+        for (typename C<T, A>::const_iterator it = aCntr.begin();
              it != aCntr.end(); ++ it, ++ i)
-#if defined (VBOX_WITH_XPCOM)
-            Copy (*it, m.arr [i]);
-#else
-            Copy (*it, m.raw [i]);
+#ifdef VBOX_WITH_XPCOM
+            Copy(*it, m.arr[i]);
+#else
+            Copy(*it, m.raw[i]);
 #endif
     }
@@ -679,20 +679,20 @@
      * @param K     Map key class (deduced from @c aCntr).
      */
-    template <template <typename, typename, typename, typename>
+    template<template<typename, typename, typename, typename>
               class C, class L, class A, class K>
-    SafeArray (const C <K, T, L, A> & aMap)
-    {
-        typedef C <K, T, L, A> Map;
-
-        resize (aMap.size());
-        AssertReturnVoid (!isNull());
+    SafeArray(const C<K, T, L, A> & aMap)
+    {
+        typedef C<K, T, L, A> Map;
+
+        resize(aMap.size());
+        AssertReturnVoid(!isNull());
 
         int i = 0;
         for (typename Map::const_iterator it = aMap.begin();
              it != aMap.end(); ++ it, ++ i)
-#if defined (VBOX_WITH_XPCOM)
-            Copy (it->second, m.arr [i]);
-#else
-            Copy (it->second, m.raw [i]);
+#ifdef VBOX_WITH_XPCOM
+            Copy(it->second, m.arr[i]);
+#else
+            Copy(it->second, m.raw[i]);
 #endif
     }
@@ -734,5 +734,5 @@
     size_t size() const
     {
-#if defined (VBOX_WITH_XPCOM)
+#ifdef VBOX_WITH_XPCOM
         if (m.arr)
             return m.size;
@@ -740,5 +740,5 @@
 #else
         if (m.arr)
-            return Size (m.arr->rgsabound [0].cElements);
+            return Size(m.arr->rgsabound[0].cElements);
         return 0;
 #endif
@@ -753,5 +753,5 @@
      * This method is handy in cases where you want to assign a copy of the
      * existing value to the array element, for example:
-     * <tt>Bstr string; array.push_back (string);</tt>. If you create a string
+     * <tt>Bstr string; array.push_back(string);</tt>. If you create a string
      * just to put it in the array, you may find #appendedRaw() more useful.
      *
@@ -761,14 +761,14 @@
      *                  memory for resizing.
      */
-    bool push_back (const T &aElement)
-    {
-        if (!ensureCapacity (size() + 1))
+    bool push_back(const T &aElement)
+    {
+        if (!ensureCapacity(size() + 1))
             return false;
 
-#if defined (VBOX_WITH_XPCOM)
-        Copy (aElement, m.arr [m.size]);
+#ifdef VBOX_WITH_XPCOM
+        Copy(aElement, m.arr[m.size]);
         ++ m.size;
 #else
-        Copy (aElement, m.raw [size() - 1]);
+        Copy(aElement, m.raw[size() - 1]);
 #endif
         return true;
@@ -788,6 +788,6 @@
      *
      * This method is handy for operations like
-     * <tt>Bstr ("foo").detachTo (array.appendedRaw());</tt>. Don't use it as
-     * an l-value (<tt>array.appendedRaw() = SysAllocString (L"tralala");</tt>)
+     * <tt>Bstr("foo").detachTo(array.appendedRaw());</tt>. Don't use it as
+     * an l-value (<tt>array.appendedRaw() = SysAllocString(L"tralala");</tt>)
      * since this doesn't check for a NULL condition; use #resize() and
      * #setRawAt() instead. If you need to assign a copy of the existing value
@@ -798,15 +798,15 @@
     T *appendedRaw()
     {
-        if (!ensureCapacity (size() + 1))
+        if (!ensureCapacity(size() + 1))
             return NULL;
 
-#if defined (VBOX_WITH_XPCOM)
-        Init (m.arr [m.size]);
+#ifdef VBOX_WITH_XPCOM
+        Init(m.arr[m.size]);
         ++ m.size;
-        return &m.arr [m.size - 1];
+        return &m.arr[m.size - 1];
 #else
         /* nothing to do here, SafeArrayCreate() has performed element
          * initialization */
-        return &m.raw [size() - 1];
+        return &m.raw[size() - 1];
 #endif
     }
@@ -822,10 +822,10 @@
      *                  memory for resizing.
      */
-    bool resize (size_t aNewSize)
-    {
-        if (!ensureCapacity (aNewSize))
+    bool resize(size_t aNewSize)
+    {
+        if (!ensureCapacity(aNewSize))
             return false;
 
-#if defined (VBOX_WITH_XPCOM)
+#ifdef VBOX_WITH_XPCOM
 
         if (m.size < aNewSize)
@@ -833,5 +833,5 @@
             /* initialize the new elements */
             for (size_t i = m.size; i < aNewSize; ++ i)
-                Init (m.arr [i]);
+                Init(m.arr[i]);
         }
 
@@ -852,8 +852,8 @@
      *                  memory for resizing.
      */
-    bool reset (size_t aNewSize)
+    bool reset(size_t aNewSize)
     {
         m.uninit();
-        return resize (aNewSize);
+        return resize(aNewSize);
     }
 
@@ -867,5 +867,5 @@
     T *raw()
     {
-#if defined (VBOX_WITH_XPCOM)
+#ifdef VBOX_WITH_XPCOM
         return m.arr;
 #else
@@ -879,5 +879,5 @@
     const T *raw() const
     {
-#if defined (VBOX_WITH_XPCOM)
+#ifdef VBOX_WITH_XPCOM
         return m.arr;
 #else
@@ -897,11 +897,11 @@
     T &operator[] (size_t aIdx)
     {
-        AssertReturn (m.arr != NULL,  *((T *) NULL));
-        AssertReturn (aIdx < size(), *((T *) NULL));
-#if defined (VBOX_WITH_XPCOM)
-        return m.arr [aIdx];
-#else
-        AssertReturn (m.raw != NULL,  *((T *) NULL));
-        return m.raw [aIdx];
+        AssertReturn(m.arr != NULL,  *((T *)NULL));
+        AssertReturn(aIdx < size(), *((T *)NULL));
+#ifdef VBOX_WITH_XPCOM
+        return m.arr[aIdx];
+#else
+        AssertReturn(m.raw != NULL,  *((T *)NULL));
+        return m.raw[aIdx];
 #endif
     }
@@ -912,11 +912,11 @@
     const T operator[] (size_t aIdx) const
     {
-        AssertReturn (m.arr != NULL,  *((T *) NULL));
-        AssertReturn (aIdx < size(), *((T *) NULL));
-#if defined (VBOX_WITH_XPCOM)
-        return m.arr [aIdx];
-#else
-        AssertReturn (m.raw != NULL,  *((T *) NULL));
-        return m.raw [aIdx];
+        AssertReturn(m.arr != NULL,  *((T *)NULL));
+        AssertReturn(aIdx < size(), *((T *)NULL));
+#ifdef VBOX_WITH_XPCOM
+        return m.arr[aIdx];
+#else
+        AssertReturn(m.raw != NULL,  *((T *)NULL));
+        return m.raw[aIdx];
 #endif
     }
@@ -927,5 +927,5 @@
      * parameter name in the ComSafeArrayOutArg macro call like this:
      * <pre>
-     *  safeArray.cloneTo (ComSafeArrayOutArg (aArg));
+     *  safeArray.cloneTo(ComSafeArrayOutArg(aArg));
      * </pre>
      *
@@ -936,17 +936,17 @@
      * @param aArg  Output method parameter to clone to.
      */
-    virtual const SafeArray &cloneTo (ComSafeArrayOut (T, aArg)) const
+    virtual const SafeArray &cloneTo(ComSafeArrayOut(T, aArg)) const
     {
         /// @todo Implement me!
-#if defined (VBOX_WITH_XPCOM)
-        NOREF (aArgSize);
-        NOREF (aArg);
-#else
-        NOREF (aArg);
-#endif
-        AssertFailedReturn (*this);
-    }
-
-    void cloneTo (SafeArray<T>& aOther) const
+#ifdef VBOX_WITH_XPCOM
+        NOREF(aArgSize);
+        NOREF(aArg);
+#else
+        NOREF(aArg);
+#endif
+        AssertFailedReturn(*this);
+    }
+
+    void cloneTo(SafeArray<T>& aOther) const
     {
         aOther.reset(size());
@@ -961,5 +961,5 @@
      * ComSafeArrayOutArg macro call like this:
      * <pre>
-     *  safeArray.detachTo (ComSafeArrayOutArg (aArg));
+     *  safeArray.detachTo(ComSafeArrayOutArg(aArg));
      * </pre>
      *
@@ -973,12 +973,12 @@
      * @param aArg  Location to detach to.
      */
-    virtual SafeArray &detachTo (ComSafeArrayOut (T, aArg))
-    {
-        AssertReturn (m.isWeak == false, *this);
-
-#if defined (VBOX_WITH_XPCOM)
-
-        AssertReturn (aArgSize != NULL, *this);
-        AssertReturn (aArg != NULL, *this);
+    virtual SafeArray &detachTo(ComSafeArrayOut(T, aArg))
+    {
+        AssertReturn(m.isWeak == false, *this);
+
+#ifdef VBOX_WITH_XPCOM
+
+        AssertReturn(aArgSize != NULL, *this);
+        AssertReturn(aArg != NULL, *this);
 
         *aArgSize = m.size;
@@ -989,13 +989,13 @@
         m.arr = NULL;
 
-#else /* defined (VBOX_WITH_XPCOM) */
-
-        AssertReturn (aArg != NULL, *this);
+#else /* !VBOX_WITH_XPCOM */
+
+        AssertReturn(aArg != NULL, *this);
         *aArg = m.arr;
 
         if (m.raw)
         {
-            HRESULT rc = SafeArrayUnaccessData (m.arr);
-            AssertComRCReturn (rc, *this);
+            HRESULT rc = SafeArrayUnaccessData(m.arr);
+            AssertComRCReturn(rc, *this);
             m.raw = NULL;
         }
@@ -1004,5 +1004,5 @@
         m.arr = NULL;
 
-#endif /* defined (VBOX_WITH_XPCOM) */
+#endif /* !VBOX_WITH_XPCOM */
 
         return *this;
@@ -1014,5 +1014,5 @@
     // Public methods for internal purposes only.
 
-#if defined (VBOX_WITH_XPCOM)
+#ifdef VBOX_WITH_XPCOM
 
     /** Internal function. Never call it directly. */
@@ -1020,7 +1020,7 @@
 
     /** Internal function Never call it directly. */
-    T **__asOutParam_Arr() { Assert (isNull()); return &m.arr; }
-
-#else /* defined (VBOX_WITH_XPCOM) */
+    T **__asOutParam_Arr() { Assert(isNull()); return &m.arr; }
+
+#else /* !VBOX_WITH_XPCOM */
 
     /** Internal function Never call it directly. */
@@ -1029,7 +1029,7 @@
     /** Internal function Never call it directly. */
     OutSafeArrayDipper __asOutParam()
-    { setNull(); return OutSafeArrayDipper (&m.arr, (void **) &m.raw); }
-
-#endif /* defined (VBOX_WITH_XPCOM) */
+    { setNull(); return OutSafeArrayDipper(&m.arr, (void **)&m.raw); }
+
+#endif /* !VBOX_WITH_XPCOM */
 
     static const SafeArray Null;
@@ -1058,9 +1058,9 @@
      * @return @c true on success and @c false if not enough memory.
      */
-    bool ensureCapacity (size_t aNewSize)
-    {
-        AssertReturn (!m.isWeak, false);
-
-#if defined (VBOX_WITH_XPCOM)
+    bool ensureCapacity(size_t aNewSize)
+    {
+        AssertReturn(!m.isWeak, false);
+
+#ifdef VBOX_WITH_XPCOM
 
         /* Note: we distinguish between a null array and an empty (zero
@@ -1072,10 +1072,10 @@
 
         /* Allocate in 16-byte pieces. */
-        size_t newCapacity = RT_MAX ((aNewSize + 15) / 16 * 16, 16);
+        size_t newCapacity = RT_MAX((aNewSize + 15) / 16 * 16, 16);
 
         if (m.capacity != newCapacity)
         {
-            T *newArr = (T *) nsMemory::Alloc (RT_MAX (newCapacity, 1) * sizeof (T));
-            AssertReturn (newArr != NULL, false);
+            T *newArr = (T *)nsMemory::Alloc(RT_MAX(newCapacity, 1) * sizeof(T));
+            AssertReturn(newArr != NULL, false);
 
             if (m.arr != NULL)
@@ -1086,5 +1086,5 @@
                      * shrink the size. */
                     for (size_t i = aNewSize; i < m.size; ++ i)
-                        Uninit (m.arr [i]);
+                        Uninit(m.arr[i]);
 
                     m.size = aNewSize;
@@ -1092,6 +1092,6 @@
 
                 /* Copy the old contents. */
-                memcpy (newArr, m.arr, m.size * sizeof (T));
-                nsMemory::Free ((void *) m.arr);
+                memcpy(newArr, m.arr, m.size * sizeof(T));
+                nsMemory::Free((void *)m.arr);
             }
 
@@ -1105,5 +1105,5 @@
                  * shrink the size. */
                 for (size_t i = aNewSize; i < m.size; ++ i)
-                    Uninit (m.arr [i]);
+                    Uninit(m.arr[i]);
 
                 m.size = aNewSize;
@@ -1115,22 +1115,22 @@
 #else
 
-        SAFEARRAYBOUND bound = { VarCount (aNewSize), 0 };
+        SAFEARRAYBOUND bound = { VarCount(aNewSize), 0 };
         HRESULT rc;
 
         if (m.arr == NULL)
         {
-            m.arr = CreateSafeArray (VarType(), &bound);
-            AssertReturn (m.arr != NULL, false);
+            m.arr = CreateSafeArray(VarType(), &bound);
+            AssertReturn(m.arr != NULL, false);
         }
         else
         {
-            SafeArrayUnaccessData (m.arr);
-
-            rc = SafeArrayRedim (m.arr, &bound);
-            AssertComRCReturn (rc == S_OK, false);
-        }
-
-        rc = SafeArrayAccessData (m.arr, (void HUGEP **) &m.raw);
-        AssertComRCReturn (rc, false);
+            SafeArrayUnaccessData(m.arr);
+
+            rc = SafeArrayRedim(m.arr, &bound);
+            AssertComRCReturn(rc == S_OK, false);
+        }
+
+        rc = SafeArrayAccessData(m.arr, (void HUGEP **)&m.raw);
+        AssertComRCReturn(rc, false);
 
 #endif
@@ -1141,9 +1141,9 @@
     {
         Data()
-            : isWeak (false)
-#if defined (VBOX_WITH_XPCOM)
-            , capacity (0), size (0), arr (NULL)
-#else
-            , arr (NULL), raw (NULL)
+            : isWeak(false)
+#ifdef VBOX_WITH_XPCOM
+            , capacity(0), size(0), arr(NULL)
+#else
+            , arr(NULL), raw(NULL)
 #endif
         {}
@@ -1153,5 +1153,5 @@
         void uninit()
         {
-#if defined (VBOX_WITH_XPCOM)
+#ifdef VBOX_WITH_XPCOM
 
             if (arr)
@@ -1160,7 +1160,7 @@
                 {
                     for (size_t i = 0; i < size; ++ i)
-                        Uninit (arr [i]);
-
-                    nsMemory::Free ((void *) arr);
+                        Uninit(arr[i]);
+
+                    nsMemory::Free((void *)arr);
                 }
                 else
@@ -1172,5 +1172,5 @@
             size = capacity = 0;
 
-#else /* defined (VBOX_WITH_XPCOM) */
+#else /* !VBOX_WITH_XPCOM */
 
             if (arr)
@@ -1178,5 +1178,5 @@
                 if (raw)
                 {
-                    SafeArrayUnaccessData (arr);
+                    SafeArrayUnaccessData(arr);
                     raw = NULL;
                 }
@@ -1184,6 +1184,6 @@
                 if (!isWeak)
                 {
-                    HRESULT rc = SafeArrayDestroy (arr);
-                    AssertComRCReturnVoid (rc);
+                    HRESULT rc = SafeArrayDestroy(arr);
+                    AssertComRCReturnVoid(rc);
                 }
                 else
@@ -1193,10 +1193,10 @@
             }
 
-#endif /* defined (VBOX_WITH_XPCOM) */
+#endif /* !VBOX_WITH_XPCOM */
         }
 
         bool isWeak : 1;
 
-#if defined (VBOX_WITH_XPCOM)
+#ifdef VBOX_WITH_XPCOM
         PRUint32 capacity;
         PRUint32 size;
@@ -1244,5 +1244,5 @@
 ////////////////////////////////////////////////////////////////////////////////
 
-#if defined (VBOX_WITH_XPCOM)
+#ifdef VBOX_WITH_XPCOM
 
 /**
@@ -1274,9 +1274,9 @@
  * this class cannot handle them because of const modifiers.
  */
-class SafeGUIDArray : public SafeArray <nsID *>
+class SafeGUIDArray : public SafeArray<nsID *>
 {
 public:
 
-    typedef SafeArray <nsID *> Base;
+    typedef SafeArray<nsID *> Base;
 
     class nsIDRef
@@ -1284,5 +1284,5 @@
     public:
 
-        nsIDRef (nsID * &aVal) : mVal (aVal) {}
+        nsIDRef(nsID * &aVal) : mVal(aVal) {}
 
         operator const nsID &() const { return mVal ? *mVal : *Empty; }
@@ -1294,5 +1294,5 @@
         {
             if (mVal == NULL)
-                Copy (&aThat, mVal);
+                Copy(&aThat, mVal);
             else
                 *mVal = aThat;
@@ -1312,6 +1312,6 @@
     SafeGUIDArray() {}
 
-    /** See SafeArray<>::SafeArray (size_t). */
-    SafeGUIDArray (size_t aSize) : Base (aSize) {}
+    /** See SafeArray<>::SafeArray(size_t). */
+    SafeGUIDArray(size_t aSize) : Base(aSize) {}
 
     /**
@@ -1325,7 +1325,7 @@
     nsIDRef operator[] (size_t aIdx)
     {
-        Assert (m.arr != NULL);
-        Assert (aIdx < size());
-        return nsIDRef (m.arr [aIdx]);
+        Assert(m.arr != NULL);
+        Assert(aIdx < size());
+        return nsIDRef(m.arr[aIdx]);
     }
 
@@ -1335,7 +1335,7 @@
     const nsID &operator[] (size_t aIdx) const
     {
-        Assert (m.arr != NULL);
-        Assert (aIdx < size());
-        return m.arr [aIdx] ? *m.arr [aIdx] : *nsIDRef::Empty;
+        Assert(m.arr != NULL);
+        Assert(aIdx < size());
+        return m.arr[aIdx] ? *m.arr[aIdx] : *nsIDRef::Empty;
     }
 };
@@ -1347,17 +1347,17 @@
  * implementations. See SafeGUIDArray for more details.
  */
-class SafeConstGUIDArray : public SafeArray <const nsID *,
-                                            SafeArrayTraits <nsID *> >
+class SafeConstGUIDArray : public SafeArray<const nsID *,
+                                            SafeArrayTraits<nsID *> >
 {
 public:
 
-    typedef SafeArray <const nsID *, SafeArrayTraits <nsID *> > Base;
+    typedef SafeArray<const nsID *, SafeArrayTraits<nsID *> > Base;
 
     /** See SafeArray<>::SafeArray(). */
     SafeConstGUIDArray() {}
 
-    /* See SafeArray<>::SafeArray (ComSafeArrayIn (T, aArg)). */
-    SafeConstGUIDArray (ComSafeGUIDArrayIn (aArg))
-        : Base (ComSafeGUIDArrayInArg (aArg)) {}
+    /* See SafeArray<>::SafeArray(ComSafeArrayIn(T, aArg)). */
+    SafeConstGUIDArray(ComSafeGUIDArrayIn(aArg))
+        : Base(ComSafeGUIDArrayInArg(aArg)) {}
 
     /**
@@ -1370,7 +1370,7 @@
     const nsID &operator[] (size_t aIdx) const
     {
-        AssertReturn (m.arr != NULL,  **((const nsID * *) NULL));
-        AssertReturn (aIdx < size(), **((const nsID * *) NULL));
-        return *m.arr [aIdx];
+        AssertReturn(m.arr != NULL,  **((const nsID * *)NULL));
+        AssertReturn(aIdx < size(), **((const nsID * *)NULL));
+        return *m.arr[aIdx];
     }
 
@@ -1378,25 +1378,25 @@
 
     /* These are disabled because of const. */
-    bool reset (size_t aNewSize) { NOREF (aNewSize); return false; }
-};
-
-#else /* defined (VBOX_WITH_XPCOM) */
-
-typedef SafeArray <GUID> SafeGUIDArray;
-typedef SafeArray <const GUID, SafeArrayTraits <GUID> > SafeConstGUIDArray;
-
-#endif /* defined (VBOX_WITH_XPCOM) */
+    bool reset(size_t aNewSize) { NOREF(aNewSize); return false; }
+};
+
+#else /* !VBOX_WITH_XPCOM */
+
+typedef SafeArray<GUID> SafeGUIDArray;
+typedef SafeArray<const GUID, SafeArrayTraits<GUID> > SafeConstGUIDArray;
+
+#endif /* !VBOX_WITH_XPCOM */
 
 ////////////////////////////////////////////////////////////////////////////////
 
-#if defined (VBOX_WITH_XPCOM)
-
-template <class I>
+#ifdef VBOX_WITH_XPCOM
+
+template<class I>
 struct SafeIfaceArrayTraits
 {
 protected:
 
-    static void Init (I * &aElem) { aElem = NULL; }
-    static void Uninit (I * &aElem)
+    static void Init(I * &aElem) { aElem = NULL; }
+    static void Uninit(I * &aElem)
     {
         if (aElem)
@@ -1407,5 +1407,5 @@
     }
 
-    static void Copy (I * aFrom, I * &aTo)
+    static void Copy(I * aFrom, I * &aTo)
     {
         if (aFrom != NULL)
@@ -1421,11 +1421,11 @@
 
     /* Magic to workaround strict rules of par. 4.4.4 of the C++ standard. */
-    static I **__asInParam_Arr (I **aArr) { return aArr; }
-    static I **__asInParam_Arr (const I **aArr) { return const_cast <I **> (aArr); }
-};
-
-#else /* defined (VBOX_WITH_XPCOM) */
-
-template <class I>
+    static I **__asInParam_Arr(I **aArr) { return aArr; }
+    static I **__asInParam_Arr(const I **aArr) { return const_cast<I **>(aArr); }
+};
+
+#else /* !VBOX_WITH_XPCOM */
+
+template<class I>
 struct SafeIfaceArrayTraits
 {
@@ -1433,8 +1433,8 @@
 
     static VARTYPE VarType() { return VT_DISPATCH; }
-    static ULONG VarCount (size_t aSize) { return (ULONG) aSize; }
-    static size_t Size (ULONG aVarCount) { return (size_t) aVarCount; }
-
-    static void Copy (I * aFrom, I * &aTo)
+    static ULONG VarCount(size_t aSize) { return (ULONG)aSize; }
+    static size_t Size(ULONG aVarCount) { return (size_t)aVarCount; }
+
+    static void Copy(I * aFrom, I * &aTo)
     {
         if (aFrom != NULL)
@@ -1447,12 +1447,12 @@
     }
 
-    static SAFEARRAY *CreateSafeArray (VARTYPE aVarType, SAFEARRAYBOUND *aBound)
-    {
-        NOREF (aVarType);
-        return SafeArrayCreateEx (VT_DISPATCH, 1, aBound, (PVOID) &_ATL_IIDOF (I));
-    }
-};
-
-#endif /* defined (VBOX_WITH_XPCOM) */
+    static SAFEARRAY *CreateSafeArray(VARTYPE aVarType, SAFEARRAYBOUND *aBound)
+    {
+        NOREF(aVarType);
+        return SafeArrayCreateEx(VT_DISPATCH, 1, aBound, (PVOID)&_ATL_IIDOF(I));
+    }
+};
+
+#endif /* !VBOX_WITH_XPCOM */
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1466,10 +1466,10 @@
  * @param I     Interface class (no asterisk).
  */
-template <class I>
-class SafeIfaceArray : public SafeArray <I *, SafeIfaceArrayTraits <I> >
+template<class I>
+class SafeIfaceArray : public SafeArray<I *, SafeIfaceArrayTraits<I> >
 {
 public:
 
-    typedef SafeArray <I *, SafeIfaceArrayTraits <I> > Base;
+    typedef SafeArray<I *, SafeIfaceArrayTraits<I> > Base;
 
     /**
@@ -1489,5 +1489,5 @@
      *       The constructor will also assert in this case.
      */
-    SafeIfaceArray (size_t aSize) { Base::resize (aSize); }
+    SafeIfaceArray(size_t aSize) { Base::resize(aSize); }
 
     /**
@@ -1497,5 +1497,5 @@
      * this:
      * <pre>
-     *  SafeArray safeArray (ComSafeArrayInArg (aArg));
+     *  SafeArray safeArray(ComSafeArrayInArg(aArg));
      * </pre>
      *
@@ -1506,9 +1506,9 @@
      * @param aArg  Input method parameter to attach to.
      */
-    SafeIfaceArray (ComSafeArrayIn (I *, aArg))
-    {
-#if defined (VBOX_WITH_XPCOM)
-
-        AssertReturnVoid (aArg != NULL);
+    SafeIfaceArray(ComSafeArrayIn(I *, aArg))
+    {
+#ifdef VBOX_WITH_XPCOM
+
+        AssertReturnVoid(aArg != NULL);
 
         Base::m.size = aArgSize;
@@ -1516,28 +1516,28 @@
         Base::m.isWeak = true;
 
-#else /* defined (VBOX_WITH_XPCOM) */
-
-        AssertReturnVoid (aArg != NULL);
+#else /* !VBOX_WITH_XPCOM */
+
+        AssertReturnVoid(aArg != NULL);
         SAFEARRAY *arg = aArg;
 
         if (arg)
         {
-            AssertReturnVoid (arg->cDims == 1);
+            AssertReturnVoid(arg->cDims == 1);
 
             VARTYPE vt;
-            HRESULT rc = SafeArrayGetVartype (arg, &vt);
-            AssertComRCReturnVoid (rc);
-            AssertMsgReturnVoid (vt == VT_UNKNOWN || vt == VT_DISPATCH,
-                                 ("Expected vartype VT_UNKNOWN, got %d.\n",
-                                  VarType(), vt));
+            HRESULT rc = SafeArrayGetVartype(arg, &vt);
+            AssertComRCReturnVoid(rc);
+            AssertMsgReturnVoid(vt == VT_UNKNOWN || vt == VT_DISPATCH,
+                                ("Expected vartype VT_UNKNOWN, got %d.\n",
+                                 VarType(), vt));
             GUID guid;
-            rc = SafeArrayGetIID (arg, &guid);
-            AssertComRCReturnVoid (rc);
-            AssertMsgReturnVoid (InlineIsEqualGUID (_ATL_IIDOF (I), guid),
-                                 ("Expected IID {%RTuuid}, got {%RTuuid}.\n",
-                                  &_ATL_IIDOF (I), &guid));
-
-            rc = SafeArrayAccessData (arg, (void HUGEP **) &m.raw);
-            AssertComRCReturnVoid (rc);
+            rc = SafeArrayGetIID(arg, &guid);
+            AssertComRCReturnVoid(rc);
+            AssertMsgReturnVoid(InlineIsEqualGUID(_ATL_IIDOF(I), guid),
+                                ("Expected IID {%RTuuid}, got {%RTuuid}.\n",
+                                 &_ATL_IIDOF(I), &guid));
+
+            rc = SafeArrayAccessData(arg, (void HUGEP **)&m.raw);
+            AssertComRCReturnVoid(rc);
         }
 
@@ -1545,10 +1545,10 @@
         m.isWeak = true;
 
-#endif /* defined (VBOX_WITH_XPCOM) */
+#endif /* !VBOX_WITH_XPCOM */
     }
 
     /**
      * Creates a deep copy of the given standard C++ container that stores
-     * interface pointers as objects of the ComPtr <I> class.
+     * interface pointers as objects of the ComPtr<I> class.
      *
      * @param aCntr Container object to copy.
@@ -1559,19 +1559,19 @@
      * @param OI    Argument to the ComPtr template (deduced from @c aCntr).
      */
-    template <template <typename, typename> class C, class A, class OI>
-    SafeIfaceArray (const C <ComPtr <OI>, A> & aCntr)
-    {
-        typedef C <ComPtr <OI>, A> List;
-
-        Base::resize (aCntr.size());
-        AssertReturnVoid (!Base::isNull());
+    template<template<typename, typename> class C, class A, class OI>
+    SafeIfaceArray(const C<ComPtr<OI>, A> & aCntr)
+    {
+        typedef C<ComPtr<OI>, A> List;
+
+        Base::resize(aCntr.size());
+        AssertReturnVoid(!Base::isNull());
 
         int i = 0;
         for (typename List::const_iterator it = aCntr.begin();
              it != aCntr.end(); ++ it, ++ i)
-#if defined (VBOX_WITH_XPCOM)
-            Copy (*it, Base::m.arr [i]);
-#else
-            Copy (*it, Base::m.raw [i]);
+#ifdef VBOX_WITH_XPCOM
+            Copy(*it, Base::m.arr[i]);
+#else
+            Copy(*it, Base::m.raw[i]);
 #endif
     }
@@ -1579,5 +1579,5 @@
     /**
      * Creates a deep copy of the given standard C++ container that stores
-     * interface pointers as objects of the ComObjPtr <I> class.
+     * interface pointers as objects of the ComObjPtr<I> class.
      *
      * @param aCntr Container object to copy.
@@ -1588,19 +1588,19 @@
      * @param OI    Argument to the ComObjPtr template (deduced from @c aCntr).
      */
-    template <template <typename, typename> class C, class A, class OI>
-    SafeIfaceArray (const C <ComObjPtr <OI>, A> & aCntr)
-    {
-        typedef C <ComObjPtr <OI>, A> List;
-
-        Base::resize (aCntr.size());
-        AssertReturnVoid (!Base::isNull());
+    template<template<typename, typename> class C, class A, class OI>
+    SafeIfaceArray(const C<ComObjPtr<OI>, A> & aCntr)
+    {
+        typedef C<ComObjPtr<OI>, A> List;
+
+        Base::resize(aCntr.size());
+        AssertReturnVoid(!Base::isNull());
 
         int i = 0;
         for (typename List::const_iterator it = aCntr.begin();
              it != aCntr.end(); ++ it, ++ i)
-#if defined (VBOX_WITH_XPCOM)
-            Copy (*it, Base::m.arr [i]);
-#else
-            Copy (*it, Base::m.raw [i]);
+#ifdef VBOX_WITH_XPCOM
+            Copy(*it, Base::m.arr[i]);
+#else
+            Copy(*it, Base::m.raw[i]);
 #endif
     }
@@ -1608,5 +1608,5 @@
     /**
      * Creates a deep copy of the given standard C++ map whose values are
-     * interface pointers stored as objects of the ComPtr <I> class.
+     * interface pointers stored as objects of the ComPtr<I> class.
      *
      * @param aMap  Map object to copy.
@@ -1619,20 +1619,20 @@
      * @param OI    Argument to the ComPtr template (deduced from @c aCntr).
      */
-    template <template <typename, typename, typename, typename>
+    template<template<typename, typename, typename, typename>
               class C, class L, class A, class K, class OI>
-    SafeIfaceArray (const C <K, ComPtr <OI>, L, A> & aMap)
-    {
-        typedef C <K, ComPtr <OI>, L, A> Map;
-
-        Base::resize (aMap.size());
-        AssertReturnVoid (!Base::isNull());
+    SafeIfaceArray(const C<K, ComPtr<OI>, L, A> & aMap)
+    {
+        typedef C<K, ComPtr<OI>, L, A> Map;
+
+        Base::resize(aMap.size());
+        AssertReturnVoid(!Base::isNull());
 
         int i = 0;
         for (typename Map::const_iterator it = aMap.begin();
              it != aMap.end(); ++ it, ++ i)
-#if defined (VBOX_WITH_XPCOM)
-            Copy (it->second, Base::m.arr [i]);
-#else
-            Copy (it->second, Base::m.raw [i]);
+#ifdef VBOX_WITH_XPCOM
+            Copy(it->second, Base::m.arr[i]);
+#else
+            Copy(it->second, Base::m.raw[i]);
 #endif
     }
@@ -1640,5 +1640,5 @@
     /**
      * Creates a deep copy of the given standard C++ map whose values are
-     * interface pointers stored as objects of the ComObjPtr <I> class.
+     * interface pointers stored as objects of the ComObjPtr<I> class.
      *
      * @param aMap  Map object to copy.
@@ -1651,20 +1651,20 @@
      * @param OI    Argument to the ComObjPtr template (deduced from @c aCntr).
      */
-    template <template <typename, typename, typename, typename>
+    template<template<typename, typename, typename, typename>
               class C, class L, class A, class K, class OI>
-    SafeIfaceArray (const C <K, ComObjPtr <OI>, L, A> & aMap)
-    {
-        typedef C <K, ComObjPtr <OI>, L, A> Map;
-
-        Base::resize (aMap.size());
-        AssertReturnVoid (!Base::isNull());
+    SafeIfaceArray(const C<K, ComObjPtr<OI>, L, A> & aMap)
+    {
+        typedef C<K, ComObjPtr<OI>, L, A> Map;
+
+        Base::resize(aMap.size());
+        AssertReturnVoid(!Base::isNull());
 
         int i = 0;
         for (typename Map::const_iterator it = aMap.begin();
              it != aMap.end(); ++ it, ++ i)
-#if defined (VBOX_WITH_XPCOM)
-            Copy (it->second, Base::m.arr [i]);
-#else
-            Copy (it->second, Base::m.raw [i]);
+#ifdef VBOX_WITH_XPCOM
+            Copy(it->second, Base::m.arr[i]);
+#else
+            Copy(it->second, Base::m.raw[i]);
 #endif
     }
@@ -1672,8 +1672,8 @@
     void setElement(size_t iIdx, I* obj)
     {
-#if defined (VBOX_WITH_XPCOM)
-        Copy (obj, Base::m.arr [iIdx]);
-#else
-        Copy (obj, Base::m.raw [iIdx]);
+#ifdef VBOX_WITH_XPCOM
+        Copy(obj, Base::m.arr[iIdx]);
+#else
+        Copy(obj, Base::m.raw[iIdx]);
 #endif
     }
