VirtualBox

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


Ignore:
Timestamp:
Nov 20, 2013 10:51:56 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
90773
Message:

com/array.h: Implemented simple fallback in case type traits for signed/unsigned types or not available.

File:
1 edited

Legend:

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

    r49573 r49576  
    422422    }
    423423
     424    /*
     425     * Fallback method in case type traits (VBOX_WITH_TYPE_TRAITS)
     426     * are not available. Always returns unsigned types.
     427     */
     428    static VARTYPE VarTypeUnsigned()
     429    {
     430        if (sizeof(T) % 8 == 0) return VT_UI8;
     431        if (sizeof(T) % 4 == 0) return VT_UI4;
     432        if (sizeof(T) % 2 == 0) return VT_UI2;
     433        return VT_UI1;
     434    }
     435
    424436    static ULONG VarCount(size_t aSize)
    425437    {
     
    650662            HRESULT rc = SafeArrayGetVartype(arg, &vt);
    651663            AssertComRCReturnVoid(rc);
    652             AssertMsgReturnVoid(vt == VarType(),
     664# ifndef VBOX_WITH_TYPE_TRAITS
     665            AssertMsgReturnVoid(
     666                                   vt == VarType()
     667                                || vt == VarTypeUnsigned(),
     668                                ("Expected vartype %d or %d, got %d.\n",
     669                                 VarType(), VarTypeUnsigned(), vt));
     670# else /* !VBOX_WITH_TYPE_TRAITS */
     671            AssertMsgReturnVoid(
     672                                   vt == VarType(),
    653673                                ("Expected vartype %d, got %d.\n",
    654674                                 VarType(), vt));
    655 
     675# endif
    656676            rc = SafeArrayAccessData(arg, (void HUGEP **)&m.raw);
    657677            AssertComRCReturnVoid(rc);
     
    15941614            AssertComRCReturnVoid(rc);
    15951615            AssertMsgReturnVoid(vt == VT_UNKNOWN || vt == VT_DISPATCH,
    1596                                 ("Expected vartype VT_UNKNOWN, got %d.\n",
    1597                                  VarType(), vt));
     1616                                ("Expected vartype VT_UNKNOWN or VT_DISPATCH, got %d.\n",
     1617                                 vt));
    15981618            GUID guid;
    15991619            rc = SafeArrayGetIID(arg, &guid);
Note: See TracChangeset for help on using the changeset viewer.

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