VirtualBox

Changeset 45058 in vbox for trunk/include/VBox/com/defs.h


Ignore:
Timestamp:
Mar 18, 2013 12:12:38 PM (12 years ago)
Author:
vboxsync
Message:

include/VBox/com/defs.h: add macro to get size of a safearray, plus whitespace cleanup

File:
1 edited

Legend:

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

    r44528 r45058  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6060# endif
    6161
    62 #endif /* defined (RT_OS_OS2) */
     62#endif /* defined(RT_OS_OS2) */
    6363
    6464/* Include iprt/types.h (which also includes iprt/types.h) now to make sure iprt
     
    6767#include <iprt/types.h>
    6868
    69 #if !defined (VBOX_WITH_XPCOM)
    70 
    71 #if defined (RT_OS_WINDOWS)
     69#if !defined(VBOX_WITH_XPCOM)
     70
     71#if defined(RT_OS_WINDOWS)
    7272
    7373// Windows COM
     
    8989
    9090/** Returns @c true if @a rc represents a warning result code */
    91 #define SUCCEEDED_WARNING(rc)   (SUCCEEDED (rc) && (rc) != S_OK)
     91#define SUCCEEDED_WARNING(rc)   (SUCCEEDED(rc) && (rc) != S_OK)
    9292
    9393/** Tests is a COM result code indicates that the process implementing the
     
    148148 * Wraps the given parameter name to generate an expression that is suitable for
    149149 * passing the parameter to functions that take input safearray parameters
    150  * declared using the ComSafeArrayIn marco.
     150 * declared using the ComSafeArrayIn macro.
    151151 *
    152152 * @param aArg  Parameter name to wrap. The given parameter must be declared
     
    200200 * @param aArg Parameter name to wrap.
    201201 */
    202 #define ComSafeGUIDArrayInIsNull(aArg)  ComSafeArrayInIsNull (aArg)
     202#define ComSafeGUIDArrayInIsNull(aArg)  ComSafeArrayInIsNull(aArg)
    203203
    204204/**
     
    206206 * @param aArg Parameter name to wrap.
    207207 */
    208 #define ComSafeGUIDArrayInArg(aArg)     ComSafeArrayInArg (aArg)
     208#define ComSafeGUIDArrayInArg(aArg)     ComSafeArrayInArg(aArg)
    209209
    210210/**
     
    218218 * @param aArg Parameter name to wrap.
    219219 */
    220 #define ComSafeGUIDArrayOutIsNull(aArg) ComSafeArrayOutIsNull (aArg)
     220#define ComSafeGUIDArrayOutIsNull(aArg) ComSafeArrayOutIsNull(aArg)
    221221
    222222/**
     
    224224 * @param aArg Parameter name to wrap.
    225225 */
    226 #define ComSafeGUIDArrayOutArg(aArg)    ComSafeArrayOutArg (aArg)
     226#define ComSafeGUIDArrayOutArg(aArg)    ComSafeArrayOutArg(aArg)
     227
     228/**
     229 * Gets size of safearray parameter.
     230 * @param aArg Parameter name.
     231 */
     232#define ComSafeArraySize(aArg)  ((aArg) == NULL ? 0 : (aArg)->rgsabound[0].cElements)
    227233
    228234/**
     
    243249#define COM_STRUCT_OR_CLASS(I)  struct I
    244250
    245 #else /* defined (RT_OS_WINDOWS) */
     251#else /* defined(RT_OS_WINDOWS) */
    246252
    247253#error "VBOX_WITH_XPCOM must be defined on a platform other than Windows!"
    248254
    249 #endif /* defined (RT_OS_WINDOWS) */
    250 
    251 #else /* !defined (VBOX_WITH_XPCOM) */
     255#endif /* defined(RT_OS_WINDOWS) */
     256
     257#else /* !defined(VBOX_WITH_XPCOM) */
    252258
    253259// XPCOM
    254260/////////////////////////////////////////////////////////////////////////////
    255261
    256 #if defined (RT_OS_DARWIN) || (defined (QT_VERSION) && (QT_VERSION >= 0x040000))
     262#if defined(RT_OS_DARWIN) || (defined(QT_VERSION) && (QT_VERSION >= 0x040000))
    257263  /* CFBase.h defines these &
    258264   * qglobal.h from Qt4 defines these */
     
    279285#define FAILED      NS_FAILED
    280286
    281 #define SUCCEEDED_WARNING(rc)   (NS_SUCCEEDED (rc) && (rc) != NS_OK)
     287#define SUCCEEDED_WARNING(rc)   (NS_SUCCEEDED(rc) && (rc) != NS_OK)
    282288
    283289#define FAILED_DEAD_INTERFACE(rc)  (   (rc) == NS_ERROR_ABORT \
     
    339345/* safearray input parameter macros for GUID */
    340346#define ComSafeGUIDArrayIn(aArg)            PRUint32 aArg##Size, const nsID **aArg
    341 #define ComSafeGUIDArrayInIsNull(aArg)      ComSafeArrayInIsNull (aArg)
    342 #define ComSafeGUIDArrayInArg(aArg)         ComSafeArrayInArg (aArg)
     347#define ComSafeGUIDArrayInIsNull(aArg)      ComSafeArrayInIsNull(aArg)
     348#define ComSafeGUIDArrayInArg(aArg)         ComSafeArrayInArg(aArg)
    343349
    344350/* safearray output parameter macros for GUID */
    345351#define ComSafeGUIDArrayOut(aArg)           PRUint32 *aArg##Size, nsID ***aArg
    346 #define ComSafeGUIDArrayOutIsNull(aArg)     ComSafeArrayOutIsNull (aArg)
    347 #define ComSafeGUIDArrayOutArg(aArg)        ComSafeArrayOutArg (aArg)
     352#define ComSafeGUIDArrayOutIsNull(aArg)     ComSafeArrayOutIsNull(aArg)
     353#define ComSafeGUIDArrayOutArg(aArg)        ComSafeArrayOutArg(aArg)
     354
     355/* safearray size */
     356#define ComSafeArraySize(aArg)  ((aArg) == NULL ? 0 : (aArg##Size))
    348357
    349358/* CLSID and IID for compatibility with Win32 */
     
    352361
    353362/* OLE error codes */
    354 #define S_OK                ((nsresult) NS_OK)
     363#define S_OK                ((nsresult)NS_OK)
    355364#define E_UNEXPECTED        NS_ERROR_UNEXPECTED
    356365#define E_NOTIMPL           NS_ERROR_NOT_IMPLEMENTED
     
    363372/* Note: a better analog for E_ACCESSDENIED would probably be
    364373 * NS_ERROR_NOT_AVAILABLE, but we want binary compatibility for now. */
    365 #define E_ACCESSDENIED      ((nsresult) 0x80070005L)
     374#define E_ACCESSDENIED      ((nsresult)0x80070005L)
    366375
    367376#define STDMETHOD(a) NS_IMETHOD a
     
    395404extern "C"
    396405{
    397 BSTR SysAllocString (const OLECHAR* sz);
    398 BSTR SysAllocStringByteLen (char *psz, unsigned int len);
    399 BSTR SysAllocStringLen (const OLECHAR *pch, unsigned int cch);
    400 void SysFreeString (BSTR bstr);
    401 int SysReAllocString (BSTR *pbstr, const OLECHAR *psz);
    402 int SysReAllocStringLen (BSTR *pbstr, const OLECHAR *psz, unsigned int cch);
    403 unsigned int SysStringByteLen (BSTR bstr);
    404 unsigned int SysStringLen (BSTR bstr);
     406BSTR SysAllocString(const OLECHAR* sz);
     407BSTR SysAllocStringByteLen(char *psz, unsigned int len);
     408BSTR SysAllocStringLen(const OLECHAR *pch, unsigned int cch);
     409void SysFreeString(BSTR bstr);
     410int SysReAllocString(BSTR *pbstr, const OLECHAR *psz);
     411int SysReAllocStringLen(BSTR *pbstr, const OLECHAR *psz, unsigned int cch);
     412unsigned int SysStringByteLen(BSTR bstr);
     413unsigned int SysStringLen(BSTR bstr);
    405414}
    406415
     
    444453 *  'Constructor' that uses an existing getter function that gets a singleton.
    445454 *  The getter function must have the following prototype:
    446  *      nsresult _GetterProc (_InstanceClass **inst)
     455 *      nsresult _GetterProc(_InstanceClass **inst)
    447456 *  This constructor, as opposed to NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR,
    448457 *  lets the getter function return a result code that is passed back to the
     
    482491}
    483492
    484 #endif /* !defined (VBOX_WITH_XPCOM) */
     493#endif /* !defined(VBOX_WITH_XPCOM) */
    485494
    486495/**
     
    489498 *  @param s    expression to stringify
    490499 */
    491 #if defined (_MSC_VER)
     500#if defined(_MSC_VER)
    492501#   define WSTR_LITERAL(s)  L#s
    493 #elif defined (__GNUC__)
     502#elif defined(__GNUC__)
    494503#   define WSTR_LITERAL(s)  L""#s
    495504#else
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