VirtualBox

Changeset 6076 in vbox for trunk/include/VBox/com


Ignore:
Timestamp:
Dec 14, 2007 7:23:03 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
26769
Message:

Merged dmik/s2 branch (r25959:26751) to the trunk.

Location:
trunk/include/VBox/com
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/com/Guid.h

    r5999 r6076  
     1/* $Id$ */
     2
    13/** @file
    24 * MS COM / XPCOM Abstraction Layer:
     
    3436#include "VBox/com/string.h"
    3537
     38#include <iprt/cpputils.h>
    3639#include <iprt/uuid.h>
    3740
     
    5154    Guid (const RTUUID &that) { uuid = that; }
    5255    Guid (const GUID &that) { ::memcpy (&uuid, &that, sizeof (GUID)); }
    53     Guid (const char *that) {
     56    Guid (const char *that)
     57    {
    5458        ::RTUuidClear (&uuid);
    5559        ::RTUuidFromStr (&uuid, that);
    5660    }
    5761
    58     Guid &operator= (const Guid &that) {
     62    Guid &operator= (const Guid &that)
     63    {
    5964        ::memcpy (&uuid, &that.uuid, sizeof (RTUUID));
    6065        return *this;
    6166    }
    62     Guid &operator= (const GUID &guid) {
     67    Guid &operator= (const GUID &guid)
     68    {
    6369        ::memcpy (&uuid, &guid, sizeof (GUID));
    6470        return *this;
    6571    }
    66     Guid &operator= (const RTUUID &guid) {
     72    Guid &operator= (const RTUUID &guid)
     73    {
    6774        ::memcpy (&uuid, &guid, sizeof (RTUUID));
    6875        return *this;
    6976    }
    70     Guid &operator= (const char *str) {
     77    Guid &operator= (const char *str)
     78    {
    7179        ::RTUuidFromStr (&uuid, str);
    7280        return *this;
     
    7684    void clear() { ::RTUuidClear (&uuid); }
    7785
    78     Utf8Str toString () const {
     86    Utf8Str toString () const
     87    {
    7988        char buf [RTUUID_STR_LENGTH];
    8089        ::RTUuidToStr (&uuid, buf, RTUUID_STR_LENGTH);
     
    92101    bool operator< (const GUID &guid) const { return ::RTUuidCompare (&uuid, (PRTUUID) &guid) < 0; }
    93102
    94     // to pass instances as GUIDPARAM parameters to interface methods
     103    /* to pass instances as GUIDPARAM parameters to interface methods */
    95104    operator const GUID &() const { return *(GUID *) &uuid; }
    96105
    97     // to directly pass instances to CFGLDRQueryUUID()
     106    /* to directly pass instances to CFGLDRQueryUUID() */
    98107    PRTUUID ptr() { return &uuid; }
    99108
    100     // to pass instances to printf-like functions
     109    /* to pass instances to printf-like functions */
    101110    PCRTUUID raw() const { return &uuid; }
    102111
    103     // to pass instances to RTUuid*() as a constant argument
     112    /* to pass instances to RTUuid*() as a constant argument */
    104113    operator const RTUUID * () const { return &uuid; }
    105114
    106115#if defined(RT_OS_WINDOWS)
    107116
    108     // to assign instances to GUIDPARAMOUT parameters from within the interface method
    109     const Guid &cloneTo (GUID *pguid) const {
     117    /* to assign instances to GUIDPARAMOUT parameters from within the
     118     *  interface method */
     119    const Guid &cloneTo (GUID *pguid) const
     120    {
    110121        if (pguid) { ::memcpy (pguid, &uuid, sizeof (GUID)); }
    111122        return *this;
    112123    }
    113124
    114     // to pass instances as GUIDPARAMOUT parameters to interface methods
     125    /* to pass instances as GUIDPARAMOUT parameters to interface methods */
    115126    GUID *asOutParam() { return (GUID *) &uuid; }
    116127
    117128#else
    118129
    119     // to assign instances to GUIDPARAMOUT parameters from within the interface method
    120     const Guid &cloneTo (nsID **ppguid) const {
     130    /* to assign instances to GUIDPARAMOUT parameters from within the
     131     * interface method */
     132    const Guid &cloneTo (nsID **ppguid) const
     133    {
    121134        if (ppguid) { *ppguid = (nsID *) nsMemory::Clone (&uuid, sizeof (nsID)); }
    122135        return *this;
    123136    }
    124137
    125     // internal helper class for asOutParam()
    126     class GuidOutParam {
     138    /* internal helper class for asOutParam() */
     139    class GuidOutParam
     140    {
    127141        GuidOutParam (Guid &guid) : ptr (0), outer (guid) { outer.clear(); }
    128142        nsID *ptr;
     
    132146    public:
    133147        operator nsID **() { return &ptr; }
    134         ~GuidOutParam() {
     148        ~GuidOutParam()
     149        {
    135150            if (ptr && outer.isEmpty()) { outer = *ptr; nsMemory::Free (ptr); }
    136151        }
     
    138153    };
    139154
    140     // to pass instances as GUIDPARAMOUT parameters to interface methods
     155    /* to pass instances as GUIDPARAMOUT parameters to interface methods */
    141156    GuidOutParam asOutParam() { return GuidOutParam (*this); }
    142157
    143158#endif
    144159
    145     // to directly test GUIDPARAM interface method's parameters
    146     static BOOL isEmpty (const GUID &guid) { return ::RTUuidIsNull ((PRTUUID) &guid); }
     160    /* to directly test GUIDPARAM interface method's parameters */
     161    static bool isEmpty (const GUID &guid)
     162    {
     163        return ::RTUuidIsNull ((PRTUUID) &guid) != 0;
     164    }
     165
     166    /**
     167     *  Static immutable empty object. May be used for comparison purposes.
     168     */
     169    static const Guid Empty;
    147170
    148171private:
     
    151174};
    152175
    153 #if defined (_MSC_VER)
    154 
    155 // work around error C2593 of the stupid MSVC 7.x ambiguity resolver
    156 inline bool operator! (const Guid& guid) { return !bool (guid); }
    157 inline bool operator&& (const Guid& guid, bool b) { return bool (guid) && b; }
    158 inline bool operator|| (const Guid& guid, bool b) { return bool (guid) || b; }
    159 inline bool operator&& (bool b, const Guid& guid) { return b && bool (guid); }
    160 inline bool operator|| (bool b, const Guid& guid) { return b || bool (guid); }
    161 
    162 #endif
     176/* work around error C2593 of the stupid MSVC 7.x ambiguity resolver */
     177WORKAROUND_MSVC7_ERROR_C2593_FOR_BOOL_OP (Guid);
    163178
    164179} /* namespace com */
    165180
    166 #endif
     181#endif /* ___VBox_com_Guid_h */
    167182
  • trunk/include/VBox/com/assert.h

    r5999 r6076  
    7979
    8080/**
     81 *  A special version of AssertComRC that evaluates the given expression and
     82 *  throws it if the result code is failed.
     83 *
     84 *  @param rc   COM result code
     85 *  @param eval the expression to evaluate
     86 */
     87#define AssertComRCThrow(rc, eval)      \
     88    if (1) { AssertComRC (rc); if (!SUCCEEDED (rc)) { throw (eval); } } else do {} while (0)
     89
     90/**
    8191 *  A special version of AssertComRC that just breaks if the result code is
    8292 *  failed.
     
    8898
    8999/**
     100 *  A special version of AssertComRC that just throws @a rc if the result code is
     101 *  failed.
     102 *
     103 *  @param rc   COM result code
     104 */
     105#define AssertComRCThrowRC(rc)          \
     106    if (1) { AssertComRC (rc); if (!SUCCEEDED (rc)) { throw rc; } } else do {} while (0)
     107
     108/**
    90109 *  Checks whether the given COM result code is successful.
    91110 *  If not, executes the return statement with this result code.
     
    104123#define CheckComRCBreakRC(rc)      \
    105124    if (1) { if (!SUCCEEDED (rc)) { break; } } else do {} while (0)
     125
     126/**
     127 *  Checks whether the given COM result code is successful.
     128 *  If not, throws the given COM result.
     129 *
     130 *  @param rc   COM result code
     131 */
     132#define CheckComRCThrowRC(rc)      \
     133    if (1) { if (!SUCCEEDED (rc)) { throw rc; } } else do {} while (0)
    106134
    107135/*
  • trunk/include/VBox/com/defs.h

    r5999 r6076  
    7777#define COM_IIDOF(I) _ATL_IIDOF (I)
    7878
    79 #else // defined (RT_OS_WINDOWS)
     79#else /* defined (RT_OS_WINDOWS) */
    8080
    8181#error "VBOX_WITH_XPCOM is not defined!"
    8282
    83 #endif // defined (RT_OS_WINDOWS)
    84 
    85 #else // !defined (VBOX_WITH_XPCOM)
     83#endif /* defined (RT_OS_WINDOWS) */
     84
     85#else /* !defined (VBOX_WITH_XPCOM) */
    8686
    8787// XPCOM
     
    101101#undef TRUE
    102102
    103 #endif // defined (RT_OS_OS2)
     103#endif /* defined (RT_OS_OS2) */
    104104
    105105#if defined (RT_OS_DARWIN)
     
    289289}
    290290
    291 #endif // !defined (RT_OS_WINDOWS)
     291#endif /* !defined (RT_OS_WINDOWS) */
    292292
    293293/**
     
    304304#endif
    305305
    306 #endif
    307 
     306#endif /* ___VBox_com_defs_h */
     307
  • trunk/include/VBox/com/string.h

    r5999 r6076  
     1/* $Id$ */
     2
    13/** @file
    24 * MS COM / XPCOM Abstraction Layer:
     
    3638
    3739#include <iprt/string.h>
     40#include <iprt/cpputils.h>
    3841#include <iprt/alloc.h>
    3942
     
    208211    BSTR *asOutParam() { setNull(); return &bstr; }
    209212
     213    /**
     214     *  Static immutable null object. May be used for comparison purposes.
     215     */
     216    static const Bstr Null;
     217
    210218private:
    211219
     
    417425    char **asOutParam() { setNull(); return &str; }
    418426
     427    /**
     428     *  Static immutable null object. May be used for comparison purposes.
     429     */
     430    static const Utf8Str Null;
     431
    419432private:
    420433
     
    568581} /* namespace com */
    569582
    570 #endif
     583#endif /* ___VBox_com_string_h */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette