summaryrefslogtreecommitdiff
path: root/include/VBox/com
diff options
context:
space:
mode:
Diffstat (limited to 'include/VBox/com')
-rw-r--r--include/VBox/com/AutoLock.h7
-rw-r--r--include/VBox/com/ErrorInfo.h35
-rw-r--r--include/VBox/com/EventQueue.h114
-rw-r--r--include/VBox/com/Guid.h143
-rw-r--r--include/VBox/com/MultiResult.h6
-rw-r--r--include/VBox/com/NativeEventQueue.h140
-rw-r--r--include/VBox/com/VirtualBox.h26
-rw-r--r--include/VBox/com/array.h80
-rw-r--r--include/VBox/com/assert.h6
-rw-r--r--include/VBox/com/com.h3
-rw-r--r--include/VBox/com/defs.h90
-rw-r--r--include/VBox/com/errorprint.h9
-rw-r--r--include/VBox/com/list.h46
-rw-r--r--include/VBox/com/listeners.h3
-rw-r--r--include/VBox/com/mtlist.h32
-rw-r--r--include/VBox/com/ptr.h6
-rw-r--r--include/VBox/com/string.h24
17 files changed, 540 insertions, 230 deletions
diff --git a/include/VBox/com/AutoLock.h b/include/VBox/com/AutoLock.h
index 9c700dd9..12eeccae 100644
--- a/include/VBox/com/AutoLock.h
+++ b/include/VBox/com/AutoLock.h
@@ -1,5 +1,4 @@
/** @file
- *
* Automatic locks, implementation
*/
@@ -24,8 +23,8 @@
* terms and conditions of either the GPL or the CDDL or both.
*/
-#ifndef ____H_AUTOLOCK
-#define ____H_AUTOLOCK
+#ifndef ___VBox_com_AutoLock_h
+#define ___VBox_com_AutoLock_h
#include <iprt/types.h>
@@ -633,6 +632,6 @@ public:
} /* namespace util */
-#endif // ____H_AUTOLOCK
+#endif
/* vi: set tabstop=4 shiftwidth=4 expandtab: */
diff --git a/include/VBox/com/ErrorInfo.h b/include/VBox/com/ErrorInfo.h
index 1037b253..869b9983 100644
--- a/include/VBox/com/ErrorInfo.h
+++ b/include/VBox/com/ErrorInfo.h
@@ -1,10 +1,9 @@
/** @file
- * MS COM / XPCOM Abstraction Layer:
- * ErrorInfo class declaration
+ * MS COM / XPCOM Abstraction Layer - ErrorInfo class declaration.
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -174,6 +173,7 @@ public:
: mIsBasicAvailable(false),
mIsFullAvailable(false),
mResultCode(S_OK),
+ mResultDetail(0),
m_pNext(NULL)
{
init();
@@ -183,6 +183,7 @@ public:
: mIsBasicAvailable(false),
mIsFullAvailable(false),
mResultCode(S_OK),
+ mResultDetail(0),
m_pNext(NULL)
{
init(pObj, aIID);
@@ -191,7 +192,7 @@ public:
/** Specialization for the IVirtualBoxErrorInfo smart pointer */
ErrorInfo (const ComPtr <IVirtualBoxErrorInfo> &aPtr)
: mIsBasicAvailable (false), mIsFullAvailable (false)
- , mResultCode (S_OK)
+ , mResultCode (S_OK), mResultDetail(0)
{ init (aPtr); }
/**
@@ -204,7 +205,7 @@ public:
*/
ErrorInfo (IVirtualBoxErrorInfo *aInfo)
: mIsBasicAvailable (false), mIsFullAvailable (false)
- , mResultCode (S_OK)
+ , mResultCode (S_OK), mResultDetail(0)
{ init (aInfo); }
ErrorInfo(const ErrorInfo &x)
@@ -267,6 +268,14 @@ public:
}
/**
+ * Returns the (optional) result detail code of the failed operation.
+ */
+ LONG getResultDetail() const
+ {
+ return mResultDetail;
+ }
+
+ /**
* Returns the IID of the interface that defined the error.
*/
const Guid& getInterfaceID() const
@@ -330,6 +339,8 @@ public:
return mCalleeName;
}
+ HRESULT getVirtualBoxErrorInfo(ComPtr<IVirtualBoxErrorInfo> &pVirtualBoxErrorInfo);
+
/**
* Resets all collected error information. #isBasicAvailable() and
* #isFullAvailable will return @c true after this method is called.
@@ -359,6 +370,7 @@ protected:
bool mIsFullAvailable : 1;
HRESULT mResultCode;
+ LONG mResultDetail;
Guid mInterfaceID;
Bstr mComponent;
Bstr mText;
@@ -444,6 +456,19 @@ public:
}
/**
+ * Constructs a new instance from an ErrorInfo object, to inject a full
+ * error info created elsewhere.
+ *
+ * @param aInfo @c true to prevent fetching error info and leave
+ * the instance uninitialized.
+ */
+ ErrorInfoKeeper(const ErrorInfo &aInfo)
+ : ErrorInfo(false), mForgot(false)
+ {
+ copyFrom(aInfo);
+ }
+
+ /**
* Destroys this instance and automatically calls #restore() which will
* either restore error info fetched by the constructor or do nothing
* if #forget() was called before destruction.
diff --git a/include/VBox/com/EventQueue.h b/include/VBox/com/EventQueue.h
index 14f4fc84..2f6587ce 100644
--- a/include/VBox/com/EventQueue.h
+++ b/include/VBox/com/EventQueue.h
@@ -1,10 +1,10 @@
+/* $Id: EventQueue.h $ */
/** @file
- * MS COM / XPCOM Abstraction Layer:
- * Event and EventQueue class declaration
+ * Event queue class declaration.
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -27,11 +27,10 @@
#ifndef ___VBox_com_EventQueue_h
#define ___VBox_com_EventQueue_h
-#ifndef VBOX_WITH_XPCOM
-# include <Windows.h>
-#else // VBOX_WITH_XPCOM
-# include <nsEventQueueUtils.h>
-#endif // VBOX_WITH_XPCOM
+#include <list>
+
+#include <iprt/asm.h>
+#include <iprt/critsect.h>
#include <VBox/com/defs.h>
#include <VBox/com/assert.h>
@@ -52,8 +51,21 @@ class Event
{
public:
- Event() {}
- virtual ~Event() {};
+ Event(void) :
+ mRefCount(0) { }
+ virtual ~Event(void) { AssertMsg(!mRefCount,
+ ("Reference count of event=%p not 0 on destruction (is %RU32)\n",
+ this, mRefCount)); }
+public:
+
+ uint32_t AddRef(void) { return ASMAtomicIncU32(&mRefCount); }
+ void Release(void)
+ {
+ Assert(mRefCount);
+ uint32_t cRefs = ASMAtomicDecU32(&mRefCount);
+ if (!cRefs)
+ delete this;
+ }
protected:
@@ -63,78 +75,56 @@ protected:
*
* @return reserved, should be NULL.
*/
- virtual void *handler() { return NULL; }
+ virtual void *handler(void) { return NULL; }
friend class EventQueue;
+
+protected:
+
+ /** The event's reference count. */
+ uint32_t mRefCount;
};
+typedef std::list< Event* > EventQueueList;
+typedef std::list< Event* >::iterator EventQueueListIterator;
+typedef std::list< Event* >::const_iterator EventQueueListIteratorConst;
+
/**
* Simple event queue.
- *
- * When using XPCOM, this will map onto the default XPCOM queue for the thread.
- * So, if a queue is created on the main thread, it automatically processes
- * XPCOM/IPC events while waiting.
- *
- * When using Windows, Darwin and OS/2, this will map onto the native thread
- * queue/runloop. So, windows messages and what not will be processed while
- * waiting for events.
- *
- * @note It is intentional that there is no way to retrieve arbitrary
- * events and controlling their processing. There is no use case which
- * warrants introducing the complexity of platform independent events.
*/
class EventQueue
{
public:
- EventQueue();
- ~EventQueue();
+ EventQueue(void);
+ virtual ~EventQueue(void);
+
+public:
BOOL postEvent(Event *event);
int processEventQueue(RTMSINTERVAL cMsTimeout);
+ int processPendingEvents(size_t cNumEvents);
int interruptEventQueueProcessing();
- int getSelectFD();
- static int init();
- static int uninit();
- static EventQueue *getMainEventQueue();
-
-#ifdef VBOX_WITH_XPCOM
- already_AddRefed<nsIEventQueue> getIEventQueue()
- {
- return mEventQ.get();
- }
-#else
- static int dispatchMessageOnWindows(MSG const *pMsg, int rc);
-#endif
private:
- static EventQueue *sMainQueue;
-
-#ifndef VBOX_WITH_XPCOM
-
- /** The thread which the queue belongs to. */
- DWORD mThreadId;
- /** Duplicated thread handle for MsgWaitForMultipleObjects. */
- HANDLE mhThread;
-#else // VBOX_WITH_XPCOM
-
- /** Whether it was created (and thus needs destroying) or if a queue already
- * associated with the thread was used. */
- bool mEQCreated;
-
- /** Whether event processing should be interrupted. */
- bool mInterrupted;
-
- nsCOMPtr <nsIEventQueue> mEventQ;
- nsCOMPtr <nsIEventQueueService> mEventQService;
-
- static void *PR_CALLBACK plEventHandler(PLEvent *self);
- static void PR_CALLBACK plEventDestructor(PLEvent *self);
-
-#endif // VBOX_WITH_XPCOM
+ /** Critical section for serializing access to this
+ * event queue. */
+ RTCRITSECT mCritSect;
+ /** Number of concurrent users. At the moment we
+ * only support one concurrent user at a time when
+ calling processEventQueue(). */
+ uint32_t mUserCnt;
+ /** Event semaphore for getting notified on new
+ * events being handled. */
+ RTSEMEVENT mSemEvent;
+ /** The actual event queue, implemented as a list. */
+ EventQueueList mEvents;
+ /** Shutdown indicator. */
+ bool mShutdown;
};
} /* namespace com */
#endif
+
diff --git a/include/VBox/com/Guid.h b/include/VBox/com/Guid.h
index c55d69dc..969780b5 100644
--- a/include/VBox/com/Guid.h
+++ b/include/VBox/com/Guid.h
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -47,6 +47,13 @@
namespace com
{
+typedef enum
+ {
+ ZERO_GUID,
+ NORMAL_GUID,
+ INVALID_GUID
+ }GuidState_t;
+
/**
* Helper class that represents the UUID type and hides platform-specific
* implementation details.
@@ -59,18 +66,27 @@ public:
{
::RTUuidClear(&mUuid);
refresh();
+ mGuidState = ZERO_GUID;
}
Guid(const Guid &that)
{
mUuid = that.mUuid;
refresh();
+ if (isEmpty())
+ mGuidState = ZERO_GUID;
+ else
+ mGuidState = NORMAL_GUID;
}
Guid(const RTUUID &that)
{
mUuid = that;
refresh();
+ if (isEmpty())
+ mGuidState = ZERO_GUID;
+ else
+ mGuidState = NORMAL_GUID;
}
Guid(const GUID &that)
@@ -78,6 +94,10 @@ public:
AssertCompileSize(GUID, sizeof(RTUUID));
::memcpy(&mUuid, &that, sizeof(GUID));
refresh();
+ if (isEmpty())
+ mGuidState = ZERO_GUID;
+ else
+ mGuidState = NORMAL_GUID;
}
/**
@@ -91,9 +111,17 @@ public:
*/
Guid(const char *that)
{
+ mGuidState = NORMAL_GUID;
+
int rc = ::RTUuidFromStr(&mUuid, that);
+
if (RT_FAILURE(rc))
+ {
::RTUuidClear(&mUuid);
+ mGuidState = INVALID_GUID;
+ }
+ else if(isEmpty())
+ mGuidState = ZERO_GUID;
refresh();
}
@@ -108,49 +136,84 @@ public:
*/
Guid(const Bstr &that)
{
- int rc = !that.isEmpty()
- ? ::RTUuidFromUtf16(&mUuid, that.raw())
- : VERR_INVALID_UUID_FORMAT;
- if (RT_FAILURE(rc))
+ mGuidState = NORMAL_GUID;
+
+ if (that.isEmpty())
+ {
::RTUuidClear(&mUuid);
+ mGuidState = ZERO_GUID;
+ }
+ else
+ {
+ int rc = ::RTUuidFromUtf16(&mUuid, that.raw());
+ if (RT_FAILURE(rc))
+ {
+ ::RTUuidClear(&mUuid);
+ mGuidState = INVALID_GUID;
+ }
+ }
+
refresh();
}
Guid& operator=(const Guid &that)
{
+ mGuidState = NORMAL_GUID;
::memcpy(&mUuid, &that.mUuid, sizeof (RTUUID));
+ if (isEmpty())
+ mGuidState = ZERO_GUID;
refresh();
return *this;
}
Guid& operator=(const GUID &guid)
{
+ mGuidState = NORMAL_GUID;
::memcpy(&mUuid, &guid, sizeof (GUID));
+ if (isEmpty())
+ mGuidState = ZERO_GUID;
refresh();
return *this;
}
Guid& operator=(const RTUUID &guid)
{
+ mGuidState = NORMAL_GUID;
::memcpy(&mUuid, &guid, sizeof (RTUUID));
+ if (isEmpty())
+ mGuidState = ZERO_GUID;
refresh();
return *this;
}
Guid& operator=(const char *str)
{
+ mGuidState = NORMAL_GUID;
int rc = ::RTUuidFromStr(&mUuid, str);
+
if (RT_FAILURE(rc))
+ {
::RTUuidClear(&mUuid);
+ mGuidState = INVALID_GUID;
+ }
+ else
+ {
+ if (isEmpty())
+ mGuidState = ZERO_GUID;
+ }
+
refresh();
+
return *this;
}
void create()
{
::RTUuidCreate(&mUuid);
+ mGuidState = NORMAL_GUID;
refresh();
}
void clear()
{
::RTUuidClear(&mUuid);
+ mGuidState = ZERO_GUID;
refresh();
}
@@ -163,7 +226,18 @@ public:
Utf8Str toString() const
{
char buf[RTUUID_STR_LENGTH];
+
+ ::memset(buf,0,RTUUID_STR_LENGTH);
+
+ if (mGuidState == INVALID_GUID)
+ {
+ /* What to return in case of wrong Guid */
+ return Utf8Str("00000000-0000-0000-0000-00000000000");
+ }
+
::RTUuidToStr(&mUuid, buf, RTUUID_STR_LENGTH);
+
+
return Utf8Str(buf);
}
@@ -175,10 +249,19 @@ public:
*/
Utf8Str toStringCurly() const
{
+
+ if (mGuidState == INVALID_GUID)
+ {
+ /* What to return in case of wrong Guid */
+ return Utf8Str("{00000000-0000-0000-0000-00000000000}");
+ }
+
char buf[RTUUID_STR_LENGTH + 2] = "{";
+
::RTUuidToStr(&mUuid, buf + 1, RTUUID_STR_LENGTH);
buf[sizeof(buf) - 2] = '}';
buf[sizeof(buf) - 1] = '\0';
+
return Utf8Str(buf);
}
@@ -190,22 +273,26 @@ public:
*/
Bstr toUtf16() const
{
- if (isEmpty())
- return Bstr();
+ if (mGuidState == INVALID_GUID)
+ return Bstr("00000000-0000-0000-0000-00000000000");
RTUTF16 buf[RTUUID_STR_LENGTH];
::RTUuidToUtf16(&mUuid, buf, RTUUID_STR_LENGTH);
return Bstr(buf);
}
- bool isEmpty() const
+ bool isValid() const
{
- return ::RTUuidIsNull(&mUuid);
+ bool res = true;
+ if (mGuidState == INVALID_GUID)
+ res = false;
+
+ return res;
}
- bool isNotEmpty() const
+ bool isZero() const
{
- return !::RTUuidIsNull(&mUuid);
+ return (::RTUuidIsNull(&mUuid) && mGuidState == ZERO_GUID);
}
bool operator==(const Guid &that) const { return ::RTUuidCompare(&mUuid, &that.mUuid) == 0; }
@@ -256,6 +343,7 @@ public:
{
if (ppGuid)
*ppGuid = (nsID *)nsMemory::Clone(&mUuid, sizeof(nsID));
+
return *this;
}
@@ -308,6 +396,18 @@ public:
*/
static const Guid Empty;
+protected:
+
+ bool isEmpty() const
+ {
+ return ::RTUuidIsNull(&mUuid);
+ }
+
+ bool isNotEmpty() const
+ {
+ return !::RTUuidIsNull(&mUuid);
+ }
+
private:
/**
* Refresh the debug-only UUID string.
@@ -319,14 +419,16 @@ private:
inline void refresh()
{
#ifdef DEBUG
- ::RTUuidToStr(&mUuid, mszUuid, RTUUID_STR_LENGTH);
- m_pcszUUID = mszUuid;
+// ::RTUuidToStr(&mUuid, mszUuid, RTUUID_STR_LENGTH);
+// m_pcszUUID = mszUuid;
#endif
}
/** The UUID. */
RTUUID mUuid;
+ GuidState_t mGuidState;
+
#ifdef DEBUG
/** String representation of mUuid for printing in the debugger. */
char mszUuid[RTUUID_STR_LENGTH];
@@ -334,18 +436,19 @@ private:
const char *m_pcszUUID;
#endif
};
-
+/*
inline Bstr asGuidStr(const Bstr& str)
{
Guid guid(str);
return guid.isEmpty() ? Bstr() : guid.toUtf16();
}
-
-inline bool isValidGuid(const Bstr& str)
-{
- Guid guid(str);
- return !guid.isEmpty();
-}
+*/
+//inline bool isValidGuid(const Bstr& str)
+//{
+// Guid guid(str);
+// return guid.isValid();
+//// return !guid.isEmpty();
+//}
} /* namespace com */
diff --git a/include/VBox/com/MultiResult.h b/include/VBox/com/MultiResult.h
index 705e1dbe..e8946468 100644
--- a/include/VBox/com/MultiResult.h
+++ b/include/VBox/com/MultiResult.h
@@ -1,8 +1,6 @@
/* $Id: MultiResult.h $ */
-
/** @file
- * MS COM / XPCOM Abstraction Layer:
- * MultiResult class declarations
+ * MS COM / XPCOM Abstraction Layer - MultiResult class declarations.
*/
/*
@@ -258,5 +256,5 @@ private:
} /* namespace com */
-#endif /* ___VBox_com_MultiResult_h */
+#endif /* !___VBox_com_MultiResult_h */
diff --git a/include/VBox/com/NativeEventQueue.h b/include/VBox/com/NativeEventQueue.h
new file mode 100644
index 00000000..96a872f1
--- /dev/null
+++ b/include/VBox/com/NativeEventQueue.h
@@ -0,0 +1,140 @@
+/** @file
+ * MS COM / XPCOM Abstraction Layer:
+ * Event and EventQueue class declaration
+ */
+
+/*
+ * Copyright (C) 2006-2013 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+#ifndef ___VBox_com_EventQueue_h
+#define ___VBox_com_EventQueue_h
+
+#ifndef VBOX_WITH_XPCOM
+# include <Windows.h>
+#else // VBOX_WITH_XPCOM
+# include <nsEventQueueUtils.h>
+#endif // VBOX_WITH_XPCOM
+
+#include <VBox/com/defs.h>
+#include <VBox/com/assert.h>
+
+namespace com
+{
+
+class MainEventQueue;
+
+/**
+ * Base class for all events. Intended to be subclassed to introduce new
+ * events and handlers for them.
+ *
+ * Subclasses usually reimplement virtual #handler() (that does nothing by
+ * default) and add new data members describing the event.
+ */
+class NativeEvent
+{
+public:
+
+ NativeEvent() {}
+ virtual ~NativeEvent() {};
+
+protected:
+
+ /**
+ * Event handler. Called in the context of the event queue's thread.
+ * Always reimplemented by subclasses
+ *
+ * @return reserved, should be NULL.
+ */
+ virtual void *handler() { return NULL; }
+
+ friend class NativeEventQueue;
+};
+
+/**
+ * Simple event queue.
+ *
+ * When using XPCOM, this will map onto the default XPCOM queue for the thread.
+ * So, if a queue is created on the main thread, it automatically processes
+ * XPCOM/IPC events while waiting.
+ *
+ * When using Windows, Darwin and OS/2, this will map onto the native thread
+ * queue/runloop. So, windows messages and what not will be processed while
+ * waiting for events.
+ *
+ * @note It is intentional that there is no way to retrieve arbitrary
+ * events and controlling their processing. There is no use case which
+ * warrants introducing the complexity of platform independent events.
+ */
+class NativeEventQueue
+{
+public:
+
+ NativeEventQueue();
+ virtual ~NativeEventQueue();
+
+ BOOL postEvent(NativeEvent *event);
+ int processEventQueue(RTMSINTERVAL cMsTimeout);
+ int interruptEventQueueProcessing();
+ int getSelectFD();
+ static int init();
+ static int uninit();
+ static NativeEventQueue *getMainEventQueue();
+
+#ifdef VBOX_WITH_XPCOM
+ already_AddRefed<nsIEventQueue> getIEventQueue()
+ {
+ return mEventQ.get();
+ }
+#else
+ static int dispatchMessageOnWindows(MSG const *pMsg, int rc);
+#endif
+
+private:
+ static NativeEventQueue *sMainQueue;
+
+#ifndef VBOX_WITH_XPCOM
+
+ /** The thread which the queue belongs to. */
+ DWORD mThreadId;
+ /** Duplicated thread handle for MsgWaitForMultipleObjects. */
+ HANDLE mhThread;
+
+#else // VBOX_WITH_XPCOM
+
+ /** Whether it was created (and thus needs destroying) or if a queue already
+ * associated with the thread was used. */
+ bool mEQCreated;
+
+ /** Whether event processing should be interrupted. */
+ bool mInterrupted;
+
+ nsCOMPtr <nsIEventQueue> mEventQ;
+ nsCOMPtr <nsIEventQueueService> mEventQService;
+
+ static void *PR_CALLBACK plEventHandler(PLEvent *self);
+ static void PR_CALLBACK plEventDestructor(PLEvent *self);
+
+#endif // VBOX_WITH_XPCOM
+};
+
+} /* namespace com */
+
+#endif
diff --git a/include/VBox/com/VirtualBox.h b/include/VBox/com/VirtualBox.h
index 92fe1e84..288ed8ff 100644
--- a/include/VBox/com/VirtualBox.h
+++ b/include/VBox/com/VirtualBox.h
@@ -1,22 +1,19 @@
/** @file
- * MS COM / XPCOM Abstraction Layer:
- * VirtualBox COM Library definitions.
+ * MS COM / XPCOM Abstraction Layer - VirtualBox COM Library definitions.
*
- * Note: This is the main header file that COM/XPCOM clients
- * include; however, it is only a wrapper around another
- * platform-dependent include file that contains the real
- * COM/XPCOM interface declarations. That other include file
- * is generated automatically at build time from
- * /src/VBox/Main/idl/VirtualBox.xidl, which contains all
- * the VirtualBox interfaces; the include file is called
- * VirtualBox.h on Windows hosts and VirtualBox_XPCOM.h
- * on Linux hosts. The build process places it in
- * out/<platform>/bin/sdk/include, from where it gets
- * included by the rest of the VirtualBox code.
+ * @note This is the main header file that COM/XPCOM clients include; however,
+ * it is only a wrapper around another platform-dependent include file
+ * that contains the real COM/XPCOM interface declarations. That other
+ * include file is generated automatically at build time from
+ * /src/VBox/Main/idl/VirtualBox.xidl, which contains all the VirtualBox
+ * interfaces; the include file is called VirtualBox.h on Windows hosts
+ * and VirtualBox_XPCOM.h on Linux hosts. The build process places it in
+ * out/<platform>/bin/sdk/include, from where it gets
+ * included by the rest of the VirtualBox code.
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -53,3 +50,4 @@
#include "VBox/com/ptr.h"
#endif
+
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 */
+
diff --git a/include/VBox/com/assert.h b/include/VBox/com/assert.h
index 0a9b1afd..900ce131 100644
--- a/include/VBox/com/assert.h
+++ b/include/VBox/com/assert.h
@@ -1,10 +1,9 @@
/** @file
- * MS COM / XPCOM Abstraction Layer:
- * Assertion macros for COM/XPCOM
+ * MS COM / XPCOM Abstraction Layer - Assertion macros for COM/XPCOM.
*/
/*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -106,3 +105,4 @@
if (!SUCCEEDED (rc)) { AssertComRC (rc); throw rc; } else do {} while (0)
#endif // !___VBox_com_assert_h
+
diff --git a/include/VBox/com/com.h b/include/VBox/com/com.h
index 524c89c6..92502689 100644
--- a/include/VBox/com/com.h
+++ b/include/VBox/com/com.h
@@ -1,6 +1,5 @@
/** @file
- * MS COM / XPCOM Abstraction Layer:
- * COM initialization / shutdown
+ * MS COM / XPCOM Abstraction Layer - COM initialization / shutdown.
*/
/*
diff --git a/include/VBox/com/defs.h b/include/VBox/com/defs.h
index aa9800dd..65db7938 100644
--- a/include/VBox/com/defs.h
+++ b/include/VBox/com/defs.h
@@ -1,10 +1,9 @@
/** @file
- * MS COM / XPCOM Abstraction Layer:
- * Common definitions
+ * MS COM / XPCOM Abstraction Layer - Common definitions.
*/
/*
- * Copyright (C) 2006-2010 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;
@@ -59,16 +58,16 @@
# define RT_MAX(Value1, Value2) ( (Value1) >= (Value2) ? (Value1) : (Value2) )
# endif
-#endif /* defined (RT_OS_OS2) */
+#endif /* defined(RT_OS_OS2) */
/* Include iprt/types.h (which also includes iprt/types.h) now to make sure iprt
* gets to stdint.h first, otherwise a system/xpcom header might beat us and
* we'll be without the macros that are optional in C++. */
#include <iprt/types.h>
-#if !defined (VBOX_WITH_XPCOM)
+#if !defined(VBOX_WITH_XPCOM)
-#if defined (RT_OS_WINDOWS)
+#if defined(RT_OS_WINDOWS)
// Windows COM
/////////////////////////////////////////////////////////////////////////////
@@ -88,7 +87,7 @@
#define NS_DECL_ISUPPORTS
/** Returns @c true if @a rc represents a warning result code */
-#define SUCCEEDED_WARNING(rc) (SUCCEEDED (rc) && (rc) != S_OK)
+#define SUCCEEDED_WARNING(rc) (SUCCEEDED(rc) && (rc) != S_OK)
/** Tests is a COM result code indicates that the process implementing the
* interface is dead.
@@ -96,12 +95,18 @@
* COM status codes:
* 0x800706ba - RPC_S_SERVER_UNAVAILABLE. Killed before call was made.
* 0x800706be - RPC_S_CALL_FAILED. Killed after call was made.
- * 0x800706bf - RPC_S_CALL_FAILED_DNE. Not observed, but should be matter of timing.
+ * 0x800706bf - RPC_S_CALL_FAILED_DNE. Not observed, but should be
+ * matter of timing.
+ * 0x80010108 - RPC_E_DISCONNECTED. Observed deregistering
+ * python event listener.
+ * 0x800706b5 - RPC_S_UNKNOWN_IF. Observed deregistering python
+ * event listener
*/
#define FAILED_DEAD_INTERFACE(rc) \
( (rc) == HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE) \
|| (rc) == HRESULT_FROM_WIN32(RPC_S_CALL_FAILED) \
|| (rc) == HRESULT_FROM_WIN32(RPC_S_CALL_FAILED_DNE) \
+ || (rc) == RPC_E_DISCONNECTED \
)
/** Immutable BSTR string */
@@ -147,7 +152,7 @@ typedef const OLECHAR *CBSTR;
/**
* Wraps the given parameter name to generate an expression that is suitable for
* passing the parameter to functions that take input safearray parameters
- * declared using the ComSafeArrayIn marco.
+ * declared using the ComSafeArrayIn macro.
*
* @param aArg Parameter name to wrap. The given parameter must be declared
* within the calling function using the ComSafeArrayIn macro.
@@ -199,13 +204,13 @@ typedef const OLECHAR *CBSTR;
* Version of ComSafeArrayInIsNull for GUID.
* @param aArg Parameter name to wrap.
*/
-#define ComSafeGUIDArrayInIsNull(aArg) ComSafeArrayInIsNull (aArg)
+#define ComSafeGUIDArrayInIsNull(aArg) ComSafeArrayInIsNull(aArg)
/**
* Version of ComSafeArrayInArg for GUID.
* @param aArg Parameter name to wrap.
*/
-#define ComSafeGUIDArrayInArg(aArg) ComSafeArrayInArg (aArg)
+#define ComSafeGUIDArrayInArg(aArg) ComSafeArrayInArg(aArg)
/**
* Version of ComSafeArrayOut for GUID.
@@ -217,13 +222,19 @@ typedef const OLECHAR *CBSTR;
* Version of ComSafeArrayOutIsNull for GUID.
* @param aArg Parameter name to wrap.
*/
-#define ComSafeGUIDArrayOutIsNull(aArg) ComSafeArrayOutIsNull (aArg)
+#define ComSafeGUIDArrayOutIsNull(aArg) ComSafeArrayOutIsNull(aArg)
/**
* Version of ComSafeArrayOutArg for GUID.
* @param aArg Parameter name to wrap.
*/
-#define ComSafeGUIDArrayOutArg(aArg) ComSafeArrayOutArg (aArg)
+#define ComSafeGUIDArrayOutArg(aArg) ComSafeArrayOutArg(aArg)
+
+/**
+ * Gets size of safearray parameter.
+ * @param aArg Parameter name.
+ */
+#define ComSafeArraySize(aArg) ((aArg) == NULL ? 0 : (aArg)->rgsabound[0].cElements)
/**
* Returns the const reference to the IID (i.e., |const GUID &|) of the given
@@ -242,18 +253,18 @@ typedef const OLECHAR *CBSTR;
*/
#define COM_STRUCT_OR_CLASS(I) struct I
-#else /* defined (RT_OS_WINDOWS) */
+#else /* defined(RT_OS_WINDOWS) */
#error "VBOX_WITH_XPCOM must be defined on a platform other than Windows!"
-#endif /* defined (RT_OS_WINDOWS) */
+#endif /* defined(RT_OS_WINDOWS) */
-#else /* !defined (VBOX_WITH_XPCOM) */
+#else /* !defined(VBOX_WITH_XPCOM) */
// XPCOM
/////////////////////////////////////////////////////////////////////////////
-#if defined (RT_OS_DARWIN) || (defined (QT_VERSION) && (QT_VERSION >= 0x040000))
+#if defined(RT_OS_DARWIN) || (defined(QT_VERSION) && (QT_VERSION >= 0x040000))
/* CFBase.h defines these &
* qglobal.h from Qt4 defines these */
# undef FALSE
@@ -278,7 +289,7 @@ typedef const OLECHAR *CBSTR;
#define SUCCEEDED NS_SUCCEEDED
#define FAILED NS_FAILED
-#define SUCCEEDED_WARNING(rc) (NS_SUCCEEDED (rc) && (rc) != NS_OK)
+#define SUCCEEDED_WARNING(rc) (NS_SUCCEEDED(rc) && (rc) != NS_OK)
#define FAILED_DEAD_INTERFACE(rc) ( (rc) == NS_ERROR_ABORT \
|| (rc) == NS_ERROR_CALL_FAILED \
@@ -338,20 +349,23 @@ typedef BSTR *LPBSTR;
/* safearray input parameter macros for GUID */
#define ComSafeGUIDArrayIn(aArg) PRUint32 aArg##Size, const nsID **aArg
-#define ComSafeGUIDArrayInIsNull(aArg) ComSafeArrayInIsNull (aArg)
-#define ComSafeGUIDArrayInArg(aArg) ComSafeArrayInArg (aArg)
+#define ComSafeGUIDArrayInIsNull(aArg) ComSafeArrayInIsNull(aArg)
+#define ComSafeGUIDArrayInArg(aArg) ComSafeArrayInArg(aArg)
/* safearray output parameter macros for GUID */
#define ComSafeGUIDArrayOut(aArg) PRUint32 *aArg##Size, nsID ***aArg
-#define ComSafeGUIDArrayOutIsNull(aArg) ComSafeArrayOutIsNull (aArg)
-#define ComSafeGUIDArrayOutArg(aArg) ComSafeArrayOutArg (aArg)
+#define ComSafeGUIDArrayOutIsNull(aArg) ComSafeArrayOutIsNull(aArg)
+#define ComSafeGUIDArrayOutArg(aArg) ComSafeArrayOutArg(aArg)
+
+/* safearray size */
+#define ComSafeArraySize(aArg) ((aArg) == NULL ? 0 : (aArg##Size))
/* CLSID and IID for compatibility with Win32 */
typedef nsCID CLSID;
typedef nsIID IID;
/* OLE error codes */
-#define S_OK ((nsresult) NS_OK)
+#define S_OK ((nsresult)NS_OK)
#define E_UNEXPECTED NS_ERROR_UNEXPECTED
#define E_NOTIMPL NS_ERROR_NOT_IMPLEMENTED
#define E_OUTOFMEMORY NS_ERROR_OUT_OF_MEMORY
@@ -362,10 +376,11 @@ typedef nsIID IID;
#define E_FAIL NS_ERROR_FAILURE
/* Note: a better analog for E_ACCESSDENIED would probably be
* NS_ERROR_NOT_AVAILABLE, but we want binary compatibility for now. */
-#define E_ACCESSDENIED ((nsresult) 0x80070005L)
+#define E_ACCESSDENIED ((nsresult)0x80070005L)
#define STDMETHOD(a) NS_IMETHOD a
#define STDMETHODIMP NS_IMETHODIMP
+#define STDMETHOD_(ret, meth) NS_IMETHOD_(ret) meth
#define COM_IIDOF(I) NS_GET_IID(I)
@@ -394,14 +409,14 @@ public:
/* helper functions */
extern "C"
{
-BSTR SysAllocString (const OLECHAR* sz);
-BSTR SysAllocStringByteLen (char *psz, unsigned int len);
-BSTR SysAllocStringLen (const OLECHAR *pch, unsigned int cch);
-void SysFreeString (BSTR bstr);
-int SysReAllocString (BSTR *pbstr, const OLECHAR *psz);
-int SysReAllocStringLen (BSTR *pbstr, const OLECHAR *psz, unsigned int cch);
-unsigned int SysStringByteLen (BSTR bstr);
-unsigned int SysStringLen (BSTR bstr);
+BSTR SysAllocString(const OLECHAR* sz);
+BSTR SysAllocStringByteLen(char *psz, unsigned int len);
+BSTR SysAllocStringLen(const OLECHAR *pch, unsigned int cch);
+void SysFreeString(BSTR bstr);
+int SysReAllocString(BSTR *pbstr, const OLECHAR *psz);
+int SysReAllocStringLen(BSTR *pbstr, const OLECHAR *psz, unsigned int cch);
+unsigned int SysStringByteLen(BSTR bstr);
+unsigned int SysStringLen(BSTR bstr);
}
/**
@@ -443,7 +458,7 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \
/**
* 'Constructor' that uses an existing getter function that gets a singleton.
* The getter function must have the following prototype:
- * nsresult _GetterProc (_InstanceClass **inst)
+ * nsresult _GetterProc(_InstanceClass **inst)
* This constructor, as opposed to NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR,
* lets the getter function return a result code that is passed back to the
* caller that tries to instantiate the object.
@@ -481,16 +496,16 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \
return rv; \
}
-#endif /* !defined (VBOX_WITH_XPCOM) */
+#endif /* !defined(VBOX_WITH_XPCOM) */
/**
* Declares a wchar_t string literal from the argument.
* Necessary to overcome MSC / GCC differences.
* @param s expression to stringify
*/
-#if defined (_MSC_VER)
+#if defined(_MSC_VER)
# define WSTR_LITERAL(s) L#s
-#elif defined (__GNUC__)
+#elif defined(__GNUC__)
# define WSTR_LITERAL(s) L""#s
#else
# error "Unsupported compiler!"
@@ -546,4 +561,5 @@ namespace com
} /* namespace com */
-#endif /* ___VBox_com_defs_h */
+#endif /* !___VBox_com_defs_h */
+
diff --git a/include/VBox/com/errorprint.h b/include/VBox/com/errorprint.h
index 2ee11676..f6b49ec0 100644
--- a/include/VBox/com/errorprint.h
+++ b/include/VBox/com/errorprint.h
@@ -1,11 +1,13 @@
/** @file
- * MS COM / XPCOM Abstraction Layer:
+ * MS COM / XPCOM Abstraction Layer - Error Reporting.
+ *
* Error printing macros using shared functions defined in shared glue code.
- * Use these CHECK_* macros for efficient error checking around calling COM methods.
+ * Use these CHECK_* macros for efficient error checking around calling COM
+ * methods.
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -259,3 +261,4 @@ void GlueHandleComErrorProgress(ComPtr<IProgress> progress,
if (1) { ASSERT(expr); if (!(expr)) break; } else do {} while (0)
} /* namespace com */
+
diff --git a/include/VBox/com/list.h b/include/VBox/com/list.h
index 11a137b5..5ecf4f16 100644
--- a/include/VBox/com/list.h
+++ b/include/VBox/com/list.h
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2011 Oracle Corporation
+ * Copyright (C) 2011-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -29,8 +29,10 @@
#include <VBox/com/ptr.h>
#include <VBox/com/string.h>
+#include <VBox/com/array.h>
#include <iprt/cpp/list.h>
+
/**
* Specialized list class for using with com::ComPtr<C>
*
@@ -54,8 +56,8 @@ public:
* @param cCapacitiy The initial capacity the list has.
* @throws std::bad_alloc
*/
- RTCList(size_t cCapacity = BASE::DefaultCapacity)
- : BASE(cCapacity) {}
+ RTCList(size_t cCapacity = BASE::kDefaultCapacity)
+ : BASE(cCapacity) {}
/* Define our own new and delete. */
RTMEMEF_NEW_AND_DELETE_OPERATORS();
@@ -84,8 +86,8 @@ public:
* @param cCapacitiy The initial capacity the list has.
* @throws std::bad_alloc
*/
- RTCList(size_t cCapacity = BASE::DefaultCapacity)
- : BASE(cCapacity) {}
+ RTCList(size_t cCapacity = BASE::kDefaultCapacity)
+ : BASE(cCapacity) {}
/* Define our own new and delete. */
RTMEMEF_NEW_AND_DELETE_OPERATORS();
@@ -97,10 +99,10 @@ public:
* The class offers methods for importing com::SafeArray's of com::Bstr's.
*/
template <>
-class RTCList<Utf8Str>: public RTCListBase<Utf8Str, Utf8Str*, false>
+class RTCList<com::Utf8Str>: public RTCListBase<com::Utf8Str, com::Utf8Str*, false>
{
/* Traits */
- typedef Utf8Str T;
+ typedef com::Utf8Str T;
typedef T *ITYPE;
static const bool MT = false;
typedef RTCListBase<T, ITYPE, MT> BASE;
@@ -114,8 +116,8 @@ public:
* @param cCapacitiy The initial capacity the list has.
* @throws std::bad_alloc
*/
- RTCList(size_t cCapacity = BASE::DefaultCapacity)
- : BASE(cCapacity) {}
+ RTCList(size_t cCapacity = BASE::kDefaultCapacity)
+ : BASE(cCapacity) {}
/**
* Creates a copy of another list.
@@ -130,9 +132,10 @@ public:
RTCList(ComSafeArrayIn(IN_BSTR, other))
{
com::SafeArray<IN_BSTR> sfaOther(ComSafeArrayInArg(other));
- realloc(sfaOther.size());
- m_cSize = sfaOther.size();
- for (size_t i = 0; i < m_cSize; ++i)
+ size_t const cElementsOther = sfaOther.size();
+ resizeArray(cElementsOther);
+ m_cElements = cElementsOther;
+ for (size_t i = 0; i < cElementsOther; ++i)
RTCListHelper<T, ITYPE>::set(m_pArray, i, T(sfaOther[i]));
}
@@ -147,9 +150,9 @@ public:
* @throws std::bad_alloc
*/
RTCList(const com::SafeArray<IN_BSTR> &other)
- : BASE(other.size())
+ : BASE(other.size())
{
- for (size_t i = 0; i < m_cSize; ++i)
+ for (size_t i = 0; i < m_cElements; ++i)
RTCListHelper<T, ITYPE>::set(m_pArray, i, T(other[i]));
}
@@ -164,16 +167,19 @@ public:
RTCListBase<T, ITYPE, MT> &operator=(const com::SafeArray<IN_BSTR> &other)
{
m_guard.enterWrite();
+
/* Values cleanup */
- RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cSize);
+ RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cElements);
+
/* Copy */
- if (other.size() != m_cCapacity)
- realloc_no_elements_clean(other.size());
- m_cSize = other.size();
- for (size_t i = 0; i < other.size(); ++i)
+ size_t cElementsOther = other.size();
+ if (cElementsOther != m_cCapacity)
+ resizeArrayNoErase(cElementsOther);
+ m_cElements = cElementsOther;
+ for (size_t i = 0; i < cElementsOther; ++i)
RTCListHelper<T, ITYPE>::set(m_pArray, i, T(other[i]));
- m_guard.leaveWrite();
+ m_guard.leaveWrite();
return *this;
}
diff --git a/include/VBox/com/listeners.h b/include/VBox/com/listeners.h
index 419b18fa..6a55e4ce 100644
--- a/include/VBox/com/listeners.h
+++ b/include/VBox/com/listeners.h
@@ -1,6 +1,6 @@
/* $Id: listeners.h $ */
/** @file
- * Listeners helpers.
+ * MS COM / XPCOM Abstraction Layer - Listeners helpers.
*/
/*
@@ -169,3 +169,4 @@ public:
#endif
#endif
+
diff --git a/include/VBox/com/mtlist.h b/include/VBox/com/mtlist.h
index c4142c5f..16b8e8ce 100644
--- a/include/VBox/com/mtlist.h
+++ b/include/VBox/com/mtlist.h
@@ -4,7 +4,7 @@
*/
/*
- * Copyright (C) 2011 Oracle Corporation
+ * Copyright (C) 2011-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -29,6 +29,7 @@
#include <VBox/com/ptr.h>
#include <VBox/com/string.h>
+#include <VBox/com/array.h>
#include <iprt/cpp/mtlist.h>
/**
@@ -54,8 +55,8 @@ public:
* @param cCapacitiy The initial capacity the list has.
* @throws std::bad_alloc
*/
- RTCList(size_t cCapacity = BASE::DefaultCapacity)
- : BASE(cCapacity) {}
+ RTCMTList(size_t cCapacity = BASE::kDefaultCapacity)
+ : BASE(cCapacity) {}
/* Define our own new and delete. */
RTMEMEF_NEW_AND_DELETE_OPERATORS();
@@ -84,7 +85,7 @@ public:
* @param cCapacitiy The initial capacity the list has.
* @throws std::bad_alloc
*/
- RTCList(size_t cCapacity = BASE::DefaultCapacity)
+ RTCMTList(size_t cCapacity = BASE::kDefaultCapacity)
: BASE(cCapacity) {}
/* Define our own new and delete. */
@@ -97,10 +98,10 @@ public:
* The class offers methods for importing com::SafeArray's of com::Bstr's.
*/
template <>
-class RTCMTList<Utf8Str>: public RTCListBase<Utf8Str, Utf8Str*, true>
+class RTCMTList<com::Utf8Str>: public RTCListBase<com::Utf8Str, com::Utf8Str *, true>
{
/* Traits */
- typedef Utf8Str T;
+ typedef com::Utf8Str T;
typedef T *ITYPE;
static const bool MT = true;
typedef RTCListBase<T, ITYPE, MT> BASE;
@@ -114,8 +115,8 @@ public:
* @param cCapacitiy The initial capacity the list has.
* @throws std::bad_alloc
*/
- RTCMTList(size_t cCapacity = BASE::DefaultCapacity)
- : BASE(cCapacity) {}
+ RTCMTList(size_t cCapacity = BASE::kDefaultCapacity)
+ : BASE(cCapacity) {}
/**
* Creates a copy of another list.
@@ -130,9 +131,10 @@ public:
RTCMTList(ComSafeArrayIn(IN_BSTR, other))
{
com::SafeArray<IN_BSTR> sfaOther(ComSafeArrayInArg(other));
- realloc(sfaOther.size());
- m_cSize = sfaOther.size();
- for (size_t i = 0; i < m_cSize; ++i)
+ size_t const cElementsOther = sfaOther.size();
+ resizeArray(cElementsOther);
+ m_cElements = cElementsOther;
+ for (size_t i = 0; i < cElementsOther; ++i)
RTCListHelper<T, ITYPE>::set(m_pArray, i, T(sfaOther[i]));
}
@@ -149,7 +151,7 @@ public:
RTCMTList(const com::SafeArray<IN_BSTR> &other)
: BASE(other.size())
{
- for (size_t i = 0; i < m_cSize; ++i)
+ for (size_t i = 0; i < m_cElements; ++i)
RTCListHelper<T, ITYPE>::set(m_pArray, i, T(other[i]));
}
@@ -165,11 +167,11 @@ public:
{
m_guard.enterWrite();
/* Values cleanup */
- RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cSize);
+ RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cElements);
/* Copy */
if (other.size() != m_cCapacity)
- realloc_no_elements_clean(other.size());
- m_cSize = other.size();
+ resizeArrayNoErase(other.size());
+ m_cElements = other.size();
for (size_t i = 0; i < other.size(); ++i)
RTCListHelper<T, ITYPE>::set(m_pArray, i, T(other[i]));
m_guard.leaveWrite();
diff --git a/include/VBox/com/ptr.h b/include/VBox/com/ptr.h
index 1942274b..bb6e5715 100644
--- a/include/VBox/com/ptr.h
+++ b/include/VBox/com/ptr.h
@@ -1,10 +1,9 @@
/** @file
- * MS COM / XPCOM Abstraction Layer:
- * Smart COM pointer classes declaration
+ * MS COM / XPCOM Abstraction Layer - Smart COM pointer classes declaration.
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -491,3 +490,4 @@ public:
}
};
#endif
+
diff --git a/include/VBox/com/string.h b/include/VBox/com/string.h
index 3462818e..63e08ae9 100644
--- a/include/VBox/com/string.h
+++ b/include/VBox/com/string.h
@@ -204,15 +204,23 @@ public:
}
bool operator==(const Bstr &that) const { return !compare(that.m_bstr); }
+ bool operator==(CBSTR that) const { return !compare(that); }
+ bool operator==(BSTR that) const { return !compare(that); }
bool operator!=(const Bstr &that) const { return !!compare(that.m_bstr); }
- bool operator==(CBSTR that) const { return !compare(that); }
- bool operator==(BSTR that) const { return !compare(that); }
-
- bool operator!=(CBSTR that) const { return !!compare(that); }
- bool operator!=(BSTR that) const { return !!compare(that); }
- bool operator<(const Bstr &that) const { return compare(that.m_bstr) < 0; }
- bool operator<(CBSTR that) const { return compare(that) < 0; }
- bool operator<(BSTR that) const { return compare(that) < 0; }
+ bool operator!=(CBSTR that) const { return !!compare(that); }
+ bool operator!=(BSTR that) const { return !!compare(that); }
+ bool operator<(const Bstr &that) const { return compare(that.m_bstr) < 0; }
+ bool operator<(CBSTR that) const { return compare(that) < 0; }
+ bool operator<(BSTR that) const { return compare(that) < 0; }
+ bool operator<=(const Bstr &that) const { return compare(that.m_bstr) <= 0; }
+ bool operator<=(CBSTR that) const { return compare(that) <= 0; }
+ bool operator<=(BSTR that) const { return compare(that) <= 0; }
+ bool operator>(const Bstr &that) const { return compare(that.m_bstr) > 0; }
+ bool operator>(CBSTR that) const { return compare(that) > 0; }
+ bool operator>(BSTR that) const { return compare(that) > 0; }
+ bool operator>=(const Bstr &that) const { return compare(that.m_bstr) >= 0; }
+ bool operator>=(CBSTR that) const { return compare(that) >= 0; }
+ bool operator>=(BSTR that) const { return compare(that) >= 0; }
/**
* Returns true if the member string has no length.