Changeset 6851 in vbox
- Timestamp:
- Feb 7, 2008 4:02:11 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/defs.h
r6076 r6851 70 70 71 71 /** 72 * Declares an input safearray parameter in the COM method implementation. Also 73 * used to declare the COM attribute setter parameter. Corresponds to either of 74 * the following XIDL definitions: 75 * <pre> 76 * <param name="arg" ... dir="in" safearray="yes"/> 77 * ... 78 * <attribute name="arg" ... safearray="yes"/> 79 * </pre> 80 * 81 * The method implementation should use the com::SafeArray helper class to work 82 * with parameters declared using this define. 83 * 84 * @param aType Array element type. 85 * @param aArg Parameter/attribute name. 86 */ 87 #define ComSafeArrayIn(aType, aArg) SAFEARRAY **aArg 88 89 /** 90 * Expands to @true if the given input safearray parameter is a "null pointer" 91 * which makes it impossible to use it for reading safearray data. 92 */ 93 #define ComSafeArrayInIsNull(aArg) (aArg == NULL) 94 95 /** 96 * Wraps the given parameter name to generate an expression that is suitable for 97 * passing the parameter to functions that take input safearray parameters 98 * declared using the ComSafeArrayIn marco. 99 * 100 * @param aArg Parameter name to wrap. The given parameter must be declared 101 * within the calling function using the ComSafeArrayIn macro. 102 */ 103 #define ComSafeArrayInArg(aArg) aArg 104 105 /** 106 * Declares an output safearray parameter in the COM method implementation. Also 107 * used to declare the COM attribute getter parameter. Corresponds to either of 108 * the following XIDL definitions: 109 * <pre> 110 * <param name="arg" ... dir="out" safearray="yes"/> 111 * <param name="arg" ... dir="return" safearray="yes"/> 112 * ... 113 * <attribute name="arg" ... safearray="yes"/> 114 * </pre> 115 * 116 * The method implementation should use the com::SafeArray helper class to work 117 * with parameters declared using this define. 118 * 119 * @param aType Array element type. 120 * @param aArg Parameter/attribute name. 121 */ 122 #define ComSafeArrayOut(aType, aArg) SAFEARRAY **aArg 123 124 /** 125 * Expands to @true if the given output safearray parameter is a "null pointer" 126 * which makes it impossible to use it for returning a safearray. 127 */ 128 #define ComSafeArrayOutIsNull(aArg) (aArg == NULL) 129 130 /** 131 * Wraps the given parameter name to generate an expression that is suitable for 132 * passing the parameter to functions that take output safearray parameters 133 * declared using the ComSafeArrayOut marco. 134 * 135 * @param aArg Parameter name to wrap. The given parameter must be declared 136 * within the calling function using the ComSafeArrayOut macro. 137 */ 138 #define ComSafeArrayOutArg(aArg) aArg 139 140 /** 72 141 * Returns the const reference to the IID (i.e., |const GUID &|) of the given 73 142 * interface. … … 79 148 #else /* defined (RT_OS_WINDOWS) */ 80 149 81 #error "VBOX_WITH_XPCOM is not defined!"150 #error "VBOX_WITH_XPCOM must be defined on a platform other than Windows!" 82 151 83 152 #endif /* defined (RT_OS_WINDOWS) */ … … 156 225 /* a type for an output GUID parameter in the interface method declaration */ 157 226 #define GUIDPARAMOUT nsID ** 227 228 /* safearray input parameter macros */ 229 #define ComSafeArrayIn(aType, aArg) PRUint32 aArg##Size, aType *aArg 230 #define ComSafeArrayInIsNull(aArg) (aArg == NULL) 231 #define ComSafeArrayInArg(aArg) aArg##Size, aArg 232 233 /* safearray output parameter macros */ 234 #define ComSafeArrayOut(aType, aArg) PRUint32 *aArg##Size, aType **aArg 235 #define ComSafeArrayOutIsNull(aArg) (aArg == NULL) 236 #define ComSafeArrayOutArg(aArg) aArg##Size, aArg 158 237 159 238 /* CLSID and IID for compatibility with Win32 */ -
trunk/include/VBox/com/string.h
r6076 r6851 184 184 185 185 /** 186 * Intended to assign instances to |BSTR| out parameters from within the187 * interface method. Transfers the ownership of the duplicated string to188 * the caller.186 * Intended to assign copies of instances to |BSTR| out parameters from 187 * within the interface method. Transfers the ownership of the duplicated 188 * string to the caller. 189 189 */ 190 190 const Bstr &cloneTo (BSTR *pstr) const … … 199 199 200 200 /** 201 * Intended to assign instances to |char *| out parameters from within the 202 * interface method. Transfers the ownership of the duplicated string to 203 * the caller. 201 * Intended to assign instances to |BSTR| out parameters from within the 202 * interface method. Transfers the ownership of the original string to the 203 * caller and resets the instance to null. 204 * 205 * As opposed to cloneTo(), this method doesn't create a copy of the 206 * string. 207 */ 208 Bstr &detachTo (BSTR *pstr) 209 { 210 *pstr = bstr; 211 bstr = NULL; 212 return *this; 213 } 214 215 /** 216 * Intended to assign copies of instances to |char *| out parameters from 217 * within the interface method. Transfers the ownership of the duplicated 218 * string to the caller. 204 219 */ 205 220 const Bstr &cloneTo (char **pstr) const; … … 211 226 BSTR *asOutParam() { setNull(); return &bstr; } 212 227 213 /** 228 /** 214 229 * Static immutable null object. May be used for comparison purposes. 215 230 */ … … 405 420 406 421 /** 422 * Intended to assign instances to |char *| out parameters from within the 423 * interface method. Transfers the ownership of the original string to the 424 * caller and resets the instance to null. 425 * 426 * As opposed to cloneTo(), this method doesn't create a copy of the 427 * string. 428 */ 429 Utf8Str &detachTo (char **pstr) 430 { 431 *pstr = str; 432 str = NULL; 433 return *this; 434 } 435 436 /** 407 437 * Intended to assign instances to |BSTR| out parameters from within the 408 438 * interface method. Transfers the ownership of the duplicated string to the … … 425 455 char **asOutParam() { setNull(); return &str; } 426 456 427 /** 457 /** 428 458 * Static immutable null object. May be used for comparison purposes. 429 459 */ -
trunk/src/VBox/Frontends/VirtualBox/include/COMDefs.h
r5999 r6851 24 24 #define __COMDefs_h__ 25 25 26 /** @defgroup grp_QT_COM Qt-COM Support Layer 27 * @{ 28 * 29 * The Qt-COM support layer provides a set of defintions and smart classes for 30 * writing simple, clean and platform-independent code to access COM/XPCOM 31 * components through exposed COM interfaces. This layer is based on the 32 * COM/XPCOM Abstarction Layer library (the VBoxCOM glue library defined in 33 * include/VBox/com and implemented in src/VBox/Main/glue). 34 * 35 * ... 36 * 37 * @defgroup grp_QT_COM_arrays Arrays 38 * @{ 39 * 40 * COM/XPCOM arrays are mapped to QValueVector objects. QValueVector templates 41 * declared with a type that corresponds to the COM type of elements in the 42 * array using normal Qt-COM type mapping rules. Here is a code example that 43 * demonstrates how to call interface methods that take and return arrays (this 44 * example is based on examples given in @ref grp_COM_arrays): 45 * @code 46 47 CSomething component; 48 49 // ... 50 51 QValueVector <LONG> in (3); 52 in [0] = -1; 53 in [1] = -2; 54 in [2] = -3; 55 56 QValueVector <LONG> out; 57 QValueVector <LONG> ret; 58 59 ret = component.TestArrays (in, out); 60 61 for (size_t i = 0; i < ret.size(); ++ i) 62 LogFlow (("*** ret[%u]=%d\n", i, ret [i])); 63 64 * @endcode 65 * @} 66 */ 26 67 27 68 /* Both VBox/com/assert.h and qglobal.h contain a definition of ASSERT. … … 30 71 31 72 #include <VBox/com/com.h> 73 #include <VBox/com/array.h> 32 74 #include <VBox/com/assert.h> 33 75 … … 37 79 #include <qstring.h> 38 80 #include <quuid.h> 81 #include <qvaluevector.h> 39 82 40 83 #include <iprt/memory> // for auto_copy_ptr … … 139 182 public: 140 183 141 static HRESULT initializeCOM(); 142 static HRESULT cleanupCOM(); 143 144 #if !defined (VBOX_WITH_XPCOM) 145 146 /** Converts a GUID value to QUuid */ 147 static QUuid toQUuid (const GUID &id) 148 { 149 return QUuid (id.Data1, id.Data2, id.Data3, 150 id.Data4[0], id.Data4[1], id.Data4[2], id.Data4[3], 151 id.Data4[4], id.Data4[5], id.Data4[6], id.Data4[7]); 152 } 153 154 #else /* !defined (VBOX_WITH_XPCOM) */ 155 156 /** Converts a GUID value to QUuid */ 157 static QUuid toQUuid (const nsID &id) 158 { 159 return QUuid (id.m0, id.m1, id.m2, 160 id.m3[0], id.m3[1], id.m3[2], id.m3[3], 161 id.m3[4], id.m3[5], id.m3[6], id.m3[7]); 162 } 163 164 #endif /* !defined (VBOX_WITH_XPCOM) */ 184 static HRESULT InitializeCOM(); 185 static HRESULT CleanupCOM(); 165 186 166 187 /** … … 178 199 virtual COMErrorInfo errorInfo() const { return COMErrorInfo(); } 179 200 201 #if !defined (VBOX_WITH_XPCOM) 202 203 /** Converts a GUID value to QUuid */ 204 static QUuid ToQUuid (const GUID &id) 205 { 206 return QUuid (id.Data1, id.Data2, id.Data3, 207 id.Data4[0], id.Data4[1], id.Data4[2], id.Data4[3], 208 id.Data4[4], id.Data4[5], id.Data4[6], id.Data4[7]); 209 } 210 211 #else /* !defined (VBOX_WITH_XPCOM) */ 212 213 /** Converts a GUID value to QUuid */ 214 static QUuid ToQUuid (const nsID &id) 215 { 216 return QUuid (id.m0, id.m1, id.m2, 217 id.m3[0], id.m3[1], id.m3[2], id.m3[3], 218 id.m3[4], id.m3[5], id.m3[6], id.m3[7]); 219 } 220 221 #endif /* !defined (VBOX_WITH_XPCOM) */ 222 223 /* Arrays of arbitrary types */ 224 225 template <typename QT, typename CT> 226 static void ToSafeArray (const QValueVector <QT> &aVec, com::SafeArray <CT> &aArr) 227 { 228 AssertMsgFailedReturnVoid (("No conversion!\n")); 229 } 230 231 template <typename CT, typename QT> 232 static void FromSafeArray (const com::SafeArray <CT> &aArr, QValueVector <QT> &aVec) 233 { 234 AssertMsgFailedReturnVoid (("No conversion!\n")); 235 } 236 237 template <typename QT, typename CT> 238 static void ToSafeArray (const QValueVector <QT *> &aVec, com::SafeArray <CT *> &aArr) 239 { 240 AssertMsgFailedReturnVoid (("No conversion!\n")); 241 } 242 243 template <typename CT, typename QT> 244 static void FromSafeArray (const com::SafeArray <CT *> &aArr, QValueVector <QT *> &aVec) 245 { 246 AssertMsgFailedReturnVoid (("No conversion!\n")); 247 } 248 249 /* Arrays of equal types */ 250 251 template <typename T> 252 static void ToSafeArray (const QValueVector <T> &aVec, com::SafeArray <T> &aArr) 253 { 254 aArr.reset (aVec.size()); 255 size_t i = 0; 256 for (typename QValueVector <T>::const_iterator it = aVec.begin(); 257 it != aVec.end(); ++ it, ++ i) 258 aArr [i] = *it; 259 } 260 261 template <typename T> 262 static void FromSafeArray (const com::SafeArray <T> &aArr, QValueVector <T> &aVec) 263 { 264 aVec = QValueVector <T> (aArr.size()); 265 size_t i = 0; 266 for (typename QValueVector <T>::iterator it = aVec.begin(); 267 it != aVec.end(); ++ it, ++ i) 268 *it = aArr [i]; 269 } 270 271 /* Arrays of interface pointers */ 272 273 template <class CI, class I> 274 static void ToSafeArray (const QValueVector <CI> &aVec, 275 com::SafeArray <I *> &aArr) 276 { 277 aArr.reset (aVec.size()); 278 size_t i = 0; 279 for (typename QValueVector <CI>::const_iterator it = aVec.begin(); 280 it != aVec.end(); ++ it, ++ i) 281 { 282 aArr [i] = (*it).iface(); 283 if (aArr [i]) 284 aArr [i]->AddRef(); 285 } 286 } 287 288 template <class I, class CI> 289 void FromSafeArray (const com::SafeArray <I *> &aArr, 290 QValueVector <CI> &aVec) 291 { 292 aVec = QValueVector <CI> (aArr.size()); 293 size_t i = 0; 294 for (typename QValueVector <CI>::iterator it = aVec.begin(); 295 it != aVec.end(); ++ it, ++ i) 296 (*it).attach (aArr [i]); 297 } 298 299 /* Arrays of strings */ 300 301 static void ToSafeArray (const QValueVector <QString> &aVec, 302 com::SafeArray <BSTR> &aArr); 303 static void FromSafeArray (const com::SafeArray <BSTR> &aArr, 304 QValueVector <QString> &aVec); 305 180 306 protected: 181 307 … … 230 356 }; 231 357 232 /** Adapter to pass CEnums enums as output VirtualBox enum params (*_T) */ 233 template <typename CE, typename VE> 358 /** 359 * Adapter to pass CEnums enums as output COM enum params (*_T). 360 * 361 * @param QE CEnums enum. 362 * @param CE COM enum. 363 */ 364 template <typename QE, typename CE> 234 365 class ENUMOut 235 366 { 236 367 public: 237 368 238 ENUMOut ( CE &e) : ce (e), ve ((VE) 0) {}239 ~ENUMOut() { ce = (CE) ve; }240 operator VE *() { return &ve; }369 ENUMOut (QE &e) : qe (e), ce ((CE) 0) {} 370 ~ENUMOut() { qe = (QE) ce; } 371 operator CE *() { return &ce; } 241 372 242 373 private: 243 374 244 CE &ce;245 VE ve;375 QE &qe; 376 CE ce; 246 377 }; 247 378 … … 605 736 #include "COMWrappers.h" 606 737 738 /** @} */ 739 607 740 #endif // __COMDefs_h__ -
trunk/src/VBox/Frontends/VirtualBox/include/COMWrappers.xsl
r5999 r6851 12 12 /* 13 13 Copyright (C) 2006-2007 innotek GmbH 14 14 15 15 This file is part of VirtualBox Open Source Edition (OSE), as 16 16 available from http://www.virtualbox.org. This file is free software; … … 126 126 <xsl:text> enum </xsl:text> 127 127 <xsl:value-of select="@name"/> 128 <xsl:text> {
</xsl:text>128 <xsl:text>
 {
</xsl:text> 129 129 <xsl:for-each select="const"> 130 130 <xsl:text> </xsl:text> … … 360 360 <xsl:text> C</xsl:text> 361 361 <xsl:value-of select="substring(@name,2)"/> 362 <xsl:text> & operator = (const CUnknown & that) {
 return (C</xsl:text>362 <xsl:text> & operator = (const CUnknown & that)
 {
 return (C</xsl:text> 363 363 <xsl:value-of select="substring(@name,2)"/> 364 364 <xsl:text> &) Base::operator = (that);
 }

</xsl:text> … … 431 431 </xsl:template> 432 432 433 <!-- attribute declarations --> 433 434 <xsl:template match="interface//attribute | collection//attribute" mode="declare"> 435 <xsl:if test="@array"> 436 <xsl:message terminate="yes"> 437 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/> 438 <xsl:text>'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text> 439 </xsl:message> 440 </xsl:if> 434 441 <xsl:apply-templates select="parent::node()" mode="begin"/> 435 442 <xsl:apply-templates select="@if" mode="begin"/> … … 446 453 </xsl:template> 447 454 455 <!-- method declarations --> 448 456 <xsl:template match="interface//method | collection//method" mode="declare"> 449 457 <xsl:apply-templates select="parent::node()" mode="begin"/> … … 468 476 <xsl:text>inline ULONG C</xsl:text> 469 477 <xsl:value-of select="substring(@name,2)"/> 470 <xsl:text>::GetCount () const 478 <xsl:text>::GetCount () const
{
</xsl:text> 471 479 <xsl:text> ULONG count = 0;
</xsl:text> 472 480 <xsl:text> Assert (mIface);
</xsl:text> … … 481 489 <xsl:text> C</xsl:text> 482 490 <xsl:value-of select="substring(@name,2)"/> 483 <xsl:text>::GetItemAt (ULONG index) const 491 <xsl:text>::GetItemAt (ULONG index) const
{
</xsl:text> 484 492 <xsl:text> </xsl:text><xsl:apply-templates select="@type"/> 485 493 <xsl:text> item;
</xsl:text> … … 495 503 <xsl:text> C</xsl:text> 496 504 <xsl:value-of select="substring(@name,2)"/> 497 <xsl:text>::Enumerate () const 505 <xsl:text>::Enumerate () const
{
</xsl:text> 498 506 <xsl:text> </xsl:text><xsl:apply-templates select="@enumerator"/> 499 507 <xsl:text> enumerator;
</xsl:text> … … 510 518 <xsl:text>inline BOOL C</xsl:text> 511 519 <xsl:value-of select="substring(@name,2)"/> 512 <xsl:text>::HasMore () const 520 <xsl:text>::HasMore () const
{
</xsl:text> 513 521 <xsl:text> BOOL more = FALSE;
</xsl:text> 514 522 <xsl:text> Assert (mIface);
</xsl:text> … … 523 531 <xsl:text> C</xsl:text> 524 532 <xsl:value-of select="substring(@name,2)"/> 525 <xsl:text>::GetNext () const 533 <xsl:text>::GetNext () const
{
</xsl:text> 526 534 <xsl:text> </xsl:text><xsl:apply-templates select="@type"/> 527 535 <xsl:text> next;
</xsl:text> … … 545 553 </xsl:template> 546 554 555 <!-- attribute definitions --> 547 556 <xsl:template match="interface//attribute | collection//attribute" mode="define"> 548 557 <xsl:apply-templates select="parent::node()" mode="begin"/> … … 563 572 </xsl:template> 564 573 574 <!-- method definitions --> 565 575 <xsl:template match="interface//method | collection//method" mode="define"> 566 576 <xsl:apply-templates select="parent::node()" mode="begin"/> … … 625 635 </xsl:call-template> 626 636 <xsl:if test="$define"> 627 <xsl:text> 637 <xsl:text>
{
</xsl:text> 628 638 <!-- iface assertion --> 629 639 <xsl:text> Assert (mIface);
</xsl:text> … … 658 668 <xsl:call-template name="composeMethodDecl"/> 659 669 <xsl:if test="$define"> 660 <xsl:text> 670 <xsl:text>
{
 </xsl:text> 661 671 <xsl:apply-templates select="$return/@type"/> 662 <xsl:text> a _</xsl:text>663 < !-- ###xsl:call-template name="capitalize">672 <xsl:text> a</xsl:text> 673 <xsl:call-template name="capitalize"> 664 674 <xsl:with-param name="str" select="$return/@name"/> 665 </xsl:call-template--> 666 <!-- 667 using one of the blocks marked with ### causes sabcmd on RedHat 668 to stupidly fail, so we use <value-of> instead. 669 --> 670 <xsl:value-of select="$return/@name"/> 675 </xsl:call-template> 671 676 <xsl:apply-templates select="$return/@type" mode="initializer"/> 672 677 <xsl:text>;
</xsl:text> 673 678 <!-- iface assertion --> 674 679 <xsl:text> Assert (mIface);
</xsl:text> 675 <xsl:text> if (!mIface)
 return a _</xsl:text>676 < !-- ###xsl:call-template name="capitalize">680 <xsl:text> if (!mIface)
 return a</xsl:text> 681 <xsl:call-template name="capitalize"> 677 682 <xsl:with-param name="str" select="$return/@name"/> 678 </xsl:call-template--> 679 <xsl:value-of select="$return/@name"/> 683 </xsl:call-template> 680 684 <xsl:text>;
</xsl:text> 681 685 <!-- method call --> 682 686 <xsl:call-template name="composeMethodCall"/> 683 687 <!-- return statement --> 684 <xsl:text> return a _</xsl:text>685 < !-- ###xsl:call-template name="capitalize">688 <xsl:text> return a</xsl:text> 689 <xsl:call-template name="capitalize"> 686 690 <xsl:with-param name="str" select="$return/@name"/> 687 </xsl:call-template --> 688 <xsl:value-of select="$return/@name"/> 691 </xsl:call-template> 689 692 <xsl:text>;
}
</xsl:text> 690 693 </xsl:if> … … 720 723 <!-- parameter --> 721 724 <xsl:apply-templates select="@type" mode="param"/> 722 <xsl:text> a _</xsl:text>723 < !-- ###xsl:call-template name="capitalize">725 <xsl:text> a</xsl:text> 726 <xsl:call-template name="capitalize"> 724 727 <xsl:with-param name="str" select="@name"/> 725 </xsl:call-template --> 726 <xsl:value-of select="@name"/> 728 </xsl:call-template> 727 729 <xsl:text>)</xsl:text> 728 730 </xsl:when> … … 749 751 <xsl:for-each select="param[@dir!='return']"> 750 752 <xsl:apply-templates select="@type" mode="param"/> 751 <xsl:text> a _</xsl:text>752 < !-- ###xsl:call-template name="capitalize">753 <xsl:text> a</xsl:text> 754 <xsl:call-template name="capitalize"> 753 755 <xsl:with-param name="str" select="@name"/> 754 </xsl:call-template --> 755 <xsl:value-of select="@name"/> 756 </xsl:call-template> 756 757 <xsl:if test="position() != last()"> 757 758 <xsl:text>, </xsl:text> … … 767 768 <xsl:template name="composeMethodCall"> 768 769 <xsl:param name="isSetter" select="''"/> 770 <!-- apply 'pre-call' hooks --> 771 <xsl:choose> 772 <xsl:when test="name()='attribute'"> 773 <xsl:call-template name="hooks"> 774 <xsl:with-param name="when" select="'pre-call'"/> 775 <xsl:with-param name="isSetter" select="$isSetter"/> 776 </xsl:call-template> 777 </xsl:when> 778 <xsl:when test="name()='method'"> 779 <xsl:for-each select="param"> 780 <xsl:call-template name="hooks"> 781 <xsl:with-param name="when" select="'pre-call'"/> 782 </xsl:call-template> 783 </xsl:for-each> 784 </xsl:when> 785 </xsl:choose> 786 <!-- start the call --> 769 787 <xsl:text> mRC = mIface-></xsl:text> 770 788 <xsl:choose> … … 807 825 </xsl:choose> 808 826 <xsl:text>);
</xsl:text> 827 <!-- apply 'post-call' hooks --> 828 <xsl:choose> 829 <xsl:when test="name()='attribute'"> 830 <xsl:call-template name="hooks"> 831 <xsl:with-param name="when" select="'post-call'"/> 832 <xsl:with-param name="isSetter" select="$isSetter"/> 833 </xsl:call-template> 834 </xsl:when> 835 <xsl:when test="name()='method'"> 836 <xsl:for-each select="param"> 837 <xsl:call-template name="hooks"> 838 <xsl:with-param name="when" select="'post-call'"/> 839 </xsl:call-template> 840 </xsl:for-each> 841 </xsl:when> 842 </xsl:choose> 843 <!-- --> 809 844 <xsl:call-template name="tryComposeFetchErrorInfo"/> 810 845 </xsl:template> … … 855 890 <xsl:otherwise> 856 891 <xsl:if test="$supports='strict' or $supports='yes'"> 857 <xsl:text> if (FAILED (mRC)) {
</xsl:text>892 <xsl:text> if (FAILED (mRC))
 {
</xsl:text> 858 893 <xsl:text> fetchErrorInfo (mIface, &COM_IIDOF (Base::Iface));
</xsl:text> 859 894 <xsl:if test="$supports='strict'"> … … 868 903 869 904 <xsl:template name="composeMethodCallParam"> 905 870 906 <xsl:param name="isIn" select="@dir='in'"/> 871 907 <xsl:param name="isOut" select="@dir='out' or @dir='return'"/> … … 874 910 875 911 <xsl:choose> 912 <!-- safearrays --> 913 <xsl:when test="@safearray='yes'"> 914 <xsl:choose> 915 <xsl:when test="$isIn"> 916 <xsl:text>ComSafeArrayAsInParam (</xsl:text> 917 <xsl:value-of select="@name"/> 918 <xsl:text>)</xsl:text> 919 </xsl:when> 920 <xsl:when test="$isOut"> 921 <xsl:text>ComSafeArrayAsOutParam (</xsl:text> 922 <xsl:value-of select="@name"/> 923 <xsl:text>)</xsl:text> 924 </xsl:when> 925 </xsl:choose> 926 </xsl:when> 876 927 <!-- string types --> 877 928 <xsl:when test="@type = 'wstring'"> 878 929 <xsl:choose> 879 930 <xsl:when test="$isIn"> 880 <xsl:text>BSTRIn (a _</xsl:text>881 < !-- ###xsl:call-template name="capitalize">931 <xsl:text>BSTRIn (a</xsl:text> 932 <xsl:call-template name="capitalize"> 882 933 <xsl:with-param name="str" select="@name"/> 883 </xsl:call-template --> 884 <xsl:value-of select="@name"/> 934 </xsl:call-template> 885 935 <xsl:text>)</xsl:text> 886 936 </xsl:when> 887 937 <xsl:when test="$isOut"> 888 <xsl:text>BSTROut (a _</xsl:text>889 < !-- ###xsl:call-template name="capitalize">938 <xsl:text>BSTROut (a</xsl:text> 939 <xsl:call-template name="capitalize"> 890 940 <xsl:with-param name="str" select="@name"/> 891 </xsl:call-template --> 892 <xsl:value-of select="@name"/> 941 </xsl:call-template> 893 942 <xsl:text>)</xsl:text> 894 943 </xsl:when> … … 899 948 <xsl:choose> 900 949 <xsl:when test="$isIn"> 901 <xsl:text>GUIDIn (a _</xsl:text>902 < !-- ###xsl:call-template name="capitalize">950 <xsl:text>GUIDIn (a</xsl:text> 951 <xsl:call-template name="capitalize"> 903 952 <xsl:with-param name="str" select="@name"/> 904 </xsl:call-template --> 905 <xsl:value-of select="@name"/> 953 </xsl:call-template> 906 954 <xsl:text>)</xsl:text> 907 955 </xsl:when> 908 956 <xsl:when test="$isOut"> 909 <xsl:text>GUIDOut (a _</xsl:text>910 < !-- ###xsl:call-template name="capitalize">957 <xsl:text>GUIDOut (a</xsl:text> 958 <xsl:call-template name="capitalize"> 911 959 <xsl:with-param name="str" select="@name"/> 912 </xsl:call-template --> 913 <xsl:value-of select="@name"/> 960 </xsl:call-template> 914 961 <xsl:text>)</xsl:text> 915 962 </xsl:when> … … 925 972 <xsl:text>(</xsl:text> 926 973 <xsl:value-of select="@type"/> 927 <xsl:text>_T) a _</xsl:text>928 < !-- ###xsl:call-template name="capitalize">974 <xsl:text>_T) a</xsl:text> 975 <xsl:call-template name="capitalize"> 929 976 <xsl:with-param name="str" select="@name"/> 930 </xsl:call-template --> 931 <xsl:value-of select="@name"/> 977 </xsl:call-template> 932 978 </xsl:when> 933 979 <xsl:when test="$isOut"> … … 936 982 <xsl:text>, </xsl:text> 937 983 <xsl:value-of select="@type"/> 938 <xsl:text>_T> (a _</xsl:text>939 < !-- ###xsl:call-template name="capitalize">984 <xsl:text>_T> (a</xsl:text> 985 <xsl:call-template name="capitalize"> 940 986 <xsl:with-param name="str" select="@name"/> 941 </xsl:call-template --> 942 <xsl:value-of select="@name"/> 987 </xsl:call-template> 943 988 <xsl:text>)</xsl:text> 944 989 </xsl:when> … … 960 1005 <xsl:choose> 961 1006 <xsl:when test="$isIn"> 962 <xsl:text>a _</xsl:text>963 < !-- ###xsl:call-template name="capitalize">1007 <xsl:text>a</xsl:text> 1008 <xsl:call-template name="capitalize"> 964 1009 <xsl:with-param name="str" select="@name"/> 965 </xsl:call-template --> 966 <xsl:value-of select="@name"/> 1010 </xsl:call-template> 967 1011 <xsl:choose> 968 1012 <xsl:when test="@type='$unknown'"> … … 975 1019 </xsl:when> 976 1020 <xsl:when test="$isOut"> 977 <xsl:text>&a _</xsl:text>978 < !-- ###xsl:call-template name="capitalize">1021 <xsl:text>&a</xsl:text> 1022 <xsl:call-template name="capitalize"> 979 1023 <xsl:with-param name="str" select="@name"/> 980 </xsl:call-template --> 981 <xsl:value-of select="@name"/> 1024 </xsl:call-template> 982 1025 <xsl:choose> 983 1026 <xsl:when test="@type='$unknown'"> … … 1003 1046 <xsl:choose> 1004 1047 <xsl:when test="$isIn"> 1005 <xsl:text>a _</xsl:text>1006 < !-- ###xsl:call-template name="capitalize">1048 <xsl:text>a</xsl:text> 1049 <xsl:call-template name="capitalize"> 1007 1050 <xsl:with-param name="str" select="@name"/> 1008 </xsl:call-template --> 1009 <xsl:value-of select="@name"/> 1051 </xsl:call-template> 1010 1052 </xsl:when> 1011 1053 <xsl:when test="$isOut"> 1012 <xsl:text>&a _</xsl:text>1013 < !-- ###xsl:call-template name="capitalize">1054 <xsl:text>&a</xsl:text> 1055 <xsl:call-template name="capitalize"> 1014 1056 <xsl:with-param name="str" select="@name"/> 1015 </xsl:call-template --> 1016 <xsl:value-of select="@name"/> 1057 </xsl:call-template> 1017 1058 </xsl:when> 1018 1059 </xsl:choose> … … 1023 1064 1024 1065 <!-- 1025 * attribute/parameter type conversion ( plaintype name)1066 * attribute/parameter type conversion (returns plain Qt type name) 1026 1067 --> 1027 1068 <xsl:template match=" … … 1031 1072 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/> 1032 1073 1033 <xsl:if test="name(..)='param' and ../@array and ../@dir='return'"> 1074 <xsl:if test="../@array and ../@safearray='yes'"> 1075 <xsl:message terminate="yes"> 1076 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 1077 <xsl:text>either 'array' or 'safearray="yes"' attribute is allowed, but not both!</xsl:text> 1078 </xsl:message> 1079 </xsl:if> 1080 1081 <xsl:if test="../@array and ((name(..)='param' and ../@dir='return') or (name(..)='attribute'))"> 1034 1082 <xsl:message terminate="yes"> 1035 1083 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 1036 <xsl:text>return array parameters are not currently supported</xsl:text>1084 <xsl:text>return 'array' parameters and 'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text> 1037 1085 </xsl:message> 1038 1086 </xsl:if> … … 1041 1089 <!-- modifiers (ignored for 'enumeration' attributes)--> 1042 1090 <xsl:when test="name(current())='type' and ../@mod"> 1091 <xsl:if test="../@safearray"> 1092 <xsl:message terminate="yes"> 1093 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 1094 <xsl:text>either 'safearray' or 'mod' attribute is allowed, but not both!</xsl:text> 1095 </xsl:message> 1096 </xsl:if> 1043 1097 <xsl:if test="../@array"> 1044 1098 <xsl:message terminate="yes"> 1045 1099 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 1046 1100 <xsl:text>either 'array' or 'mod' attribute is allowed, but not both!</xsl:text> 1047 1101 </xsl:message> … … 1079 1133 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 1080 1134 <xsl:value-of select="concat('value "',../@mod,'" ')"/> 1081 <xsl:text>of att ibute 'mod' is invalid!</xsl:text>1135 <xsl:text>of attribute 'mod' is invalid!</xsl:text> 1082 1136 </xsl:message> 1083 1137 </xsl:otherwise> … … 1086 1140 <!-- no modifiers --> 1087 1141 <xsl:otherwise> 1142 <xsl:if test="../@safearray"> 1143 <xsl:text>QValueVector <</xsl:text> 1144 </xsl:if> 1088 1145 <xsl:choose> 1089 1146 <!-- standard types --> … … 1139 1196 </xsl:otherwise> 1140 1197 </xsl:choose> 1198 <xsl:if test="../@safearray"> 1199 <xsl:text>></xsl:text> 1200 </xsl:if> 1141 1201 </xsl:otherwise> 1142 1202 </xsl:choose> … … 1157 1217 1158 1218 <xsl:choose> 1219 <!-- safearrays don't need initializers --> 1220 <xsl:when test="../@safearray"> 1221 </xsl:when> 1159 1222 <!-- modifiers (ignored for 'enumeration' attributes)--> 1160 1223 <xsl:when test="name(current())='type' and ../@mod"> 1161 <xsl:if test="../@array">1162 <xsl:message terminate="yes">1163 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>1164 <xsl:text>either 'array' or 'mod' attribute is allowed, but not both!</xsl:text>1165 </xsl:message>1166 </xsl:if>1167 1224 <xsl:choose> 1168 1225 <xsl:when test="../@mod='ptr'"> … … 1197 1254 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 1198 1255 <xsl:value-of select="concat('value "',../@mod,'" ')"/> 1199 <xsl:text>of att ibute 'mod' is invalid!</xsl:text>1256 <xsl:text>of attribute 'mod' is invalid!</xsl:text> 1200 1257 </xsl:message> 1201 1258 </xsl:otherwise> … … 1247 1304 .='string' or 1248 1305 .='wstring' or 1306 ../@safearray='yes' or 1249 1307 ((ancestor::library/enum[@name=current()]) or 1250 1308 (ancestor::library/if[@target=$self_target]/enum[@name=current()]) … … 1270 1328 <!-- <param> context --> 1271 1329 <xsl:when test="name(..)='param'"> 1272 <xsl:if test="../@array">1273 <xsl:message terminate="yes">1274 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>1275 <xsl:text>arrays of non-scalar types are not currently supported</xsl:text>1276 </xsl:message>1277 </xsl:if>1278 1330 <xsl:choose> 1279 1331 <xsl:when test="../@dir='in'"> … … 1324 1376 1325 1377 1378 <!-- 1379 * attribute/parameter type conversion (returns plain COM type name) 1380 * (basically, copied from midl.xsl) 1381 --> 1382 <xsl:template match=" 1383 attribute/@type | param/@type | 1384 enumerator/@type | collection/@type | collection/@enumerator 1385 " mode="com"> 1386 1387 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/> 1388 1389 <xsl:choose> 1390 <!-- modifiers (ignored for 'enumeration' attributes)--> 1391 <xsl:when test="name(current())='type' and ../@mod"> 1392 <xsl:choose> 1393 <xsl:when test="../@mod='ptr'"> 1394 <xsl:choose> 1395 <!-- standard types --> 1396 <!--xsl:when test=".='result'">??</xsl:when--> 1397 <xsl:when test=".='boolean'">BOOL *</xsl:when> 1398 <xsl:when test=".='octet'">BYTE *</xsl:when> 1399 <xsl:when test=".='short'">SHORT *</xsl:when> 1400 <xsl:when test=".='unsigned short'">USHORT *</xsl:when> 1401 <xsl:when test=".='long'">LONG *</xsl:when> 1402 <xsl:when test=".='long long'">LONG64 *</xsl:when> 1403 <xsl:when test=".='unsigned long'">ULONG *</xsl:when> 1404 <xsl:when test=".='unsigned long long'">ULONG64 *</xsl:when> 1405 <xsl:when test=".='char'">CHAR *</xsl:when> 1406 <!--xsl:when test=".='string'">??</xsl:when--> 1407 <xsl:when test=".='wchar'">OLECHAR *</xsl:when> 1408 <!--xsl:when test=".='wstring'">??</xsl:when--> 1409 <xsl:otherwise> 1410 <xsl:message terminate="yes"> 1411 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 1412 <xsl:text>attribute 'mod=</xsl:text> 1413 <xsl:value-of select="concat('"',../@mod,'"')"/> 1414 <xsl:text>' cannot be used with type </xsl:text> 1415 <xsl:value-of select="concat('"',current(),'"!')"/> 1416 </xsl:message> 1417 </xsl:otherwise> 1418 </xsl:choose> 1419 </xsl:when> 1420 <xsl:otherwise> 1421 <xsl:message terminate="yes"> 1422 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 1423 <xsl:value-of select="concat('value "',../@mod,'" ')"/> 1424 <xsl:text>of attribute 'mod' is invalid!</xsl:text> 1425 </xsl:message> 1426 </xsl:otherwise> 1427 </xsl:choose> 1428 </xsl:when> 1429 <!-- no modifiers --> 1430 <xsl:otherwise> 1431 <xsl:choose> 1432 <!-- standard types --> 1433 <xsl:when test=".='result'">HRESULT</xsl:when> 1434 <xsl:when test=".='boolean'">BOOL</xsl:when> 1435 <xsl:when test=".='octet'">BYTE</xsl:when> 1436 <xsl:when test=".='short'">SHORT</xsl:when> 1437 <xsl:when test=".='unsigned short'">USHORT</xsl:when> 1438 <xsl:when test=".='long'">LONG</xsl:when> 1439 <xsl:when test=".='long long'">LONG64</xsl:when> 1440 <xsl:when test=".='unsigned long'">ULONG</xsl:when> 1441 <xsl:when test=".='unsigned long long'">ULONG64</xsl:when> 1442 <xsl:when test=".='char'">CHAR</xsl:when> 1443 <xsl:when test=".='string'">CHAR *</xsl:when> 1444 <xsl:when test=".='wchar'">OLECHAR</xsl:when> 1445 <xsl:when test=".='wstring'">BSTR</xsl:when> 1446 <!-- UUID type --> 1447 <xsl:when test=".='uuid'">GUID</xsl:when> 1448 <!-- system interface types --> 1449 <xsl:when test=".='$unknown'">IUnknown *</xsl:when> 1450 <xsl:otherwise> 1451 <xsl:choose> 1452 <!-- enum types --> 1453 <xsl:when test=" 1454 (ancestor::library/enum[@name=current()]) or 1455 (ancestor::library/if[@target=$self_target]/enum[@name=current()]) 1456 "> 1457 <xsl:value-of select="."/> 1458 </xsl:when> 1459 <!-- custom interface types --> 1460 <xsl:when test=" 1461 (name(current())='enumerator' and 1462 ((ancestor::library/enumerator[@name=current()]) or 1463 (ancestor::library/if[@target=$self_target]/enumerator[@name=current()])) 1464 ) or 1465 ((ancestor::library/interface[@name=current()]) or 1466 (ancestor::library/if[@target=$self_target]/interface[@name=current()]) 1467 ) or 1468 ((ancestor::library/collection[@name=current()]) or 1469 (ancestor::library/if[@target=$self_target]/collection[@name=current()]) 1470 ) 1471 "> 1472 <xsl:value-of select="."/><xsl:text> *</xsl:text> 1473 </xsl:when> 1474 <!-- other types --> 1475 <xsl:otherwise> 1476 <xsl:message terminate="yes"> 1477 <xsl:text>Unknown parameter type: </xsl:text> 1478 <xsl:value-of select="."/> 1479 </xsl:message> 1480 </xsl:otherwise> 1481 </xsl:choose> 1482 </xsl:otherwise> 1483 </xsl:choose> 1484 </xsl:otherwise> 1485 </xsl:choose> 1486 </xsl:template> 1487 1488 1489 <!-- 1490 * attribute/parameter type additional hooks. 1491 * 1492 * Called in the context of <attribute> or <param> elements. 1493 * 1494 * @param when When the hook is being called: 1495 * 'pre-call' - right before the method call 1496 * 'post-call' - right after the method call 1497 * @param isSetter Non-empty if called in the cotext of the attribute setter 1498 * call. 1499 --> 1500 <xsl:template name="hooks"> 1501 1502 <xsl:param name="when" select="''"/> 1503 <xsl:param name="isSetter" select="''"/> 1504 1505 <xsl:choose> 1506 <xsl:when test="$when='pre-call'"> 1507 <xsl:choose> 1508 <xsl:when test="@safearray='yes'"> 1509 <!-- declare a SafeArray variable --> 1510 <xsl:text> com::SafeArray <</xsl:text> 1511 <xsl:apply-templates select="@type" mode="com"/> 1512 <xsl:text>> </xsl:text> 1513 <xsl:value-of select="@name"/> 1514 <xsl:text>;
</xsl:text> 1515 <xsl:if test="(name()='attribute' and $isSetter) or 1516 (name()='param' and @dir='in')"> 1517 <!-- convert QValueVector to SafeArray --> 1518 <xsl:text> ToSafeArray (</xsl:text> 1519 <xsl:text>a</xsl:text> 1520 <xsl:call-template name="capitalize"> 1521 <xsl:with-param name="str" select="@name"/> 1522 </xsl:call-template> 1523 <xsl:text>, </xsl:text> 1524 <xsl:value-of select="@name"/> 1525 <xsl:text>);
</xsl:text> 1526 </xsl:if> 1527 </xsl:when> 1528 </xsl:choose> 1529 </xsl:when> 1530 <xsl:when test="$when='post-call'"> 1531 <xsl:choose> 1532 <xsl:when test="@safearray='yes'"> 1533 <xsl:if test="(name()='attribute' and not($isSetter)) or 1534 (name()='param' and (@dir='out' or @dir='return'))"> 1535 <!-- convert SafeArray to QValueVector --> 1536 <xsl:text> FromSafeArray (</xsl:text> 1537 <xsl:value-of select="@name"/> 1538 <xsl:text>, </xsl:text> 1539 <xsl:text>a</xsl:text> 1540 <xsl:call-template name="capitalize"> 1541 <xsl:with-param name="str" select="@name"/> 1542 </xsl:call-template> 1543 <xsl:text>);
</xsl:text> 1544 </xsl:if> 1545 </xsl:when> 1546 </xsl:choose> 1547 </xsl:when> 1548 <xsl:otherwise> 1549 <xsl:message terminate="yes"> 1550 <xsl:text>Invalid when value: </xsl:text> 1551 <xsl:value-of select="$when"/> 1552 </xsl:message> 1553 </xsl:otherwise> 1554 </xsl:choose> 1555 1556 </xsl:template> 1557 1558 1326 1559 </xsl:stylesheet> 1327 1560 -
trunk/src/VBox/Frontends/VirtualBox/src/COMDefs.cpp
r5999 r6851 86 86 * Initializes COM/XPCOM. 87 87 */ 88 HRESULT COMBase:: initializeCOM()88 HRESULT COMBase::InitializeCOM() 89 89 { 90 90 LogFlowFuncEnter(); … … 126 126 127 127 if (FAILED (rc)) 128 cleanupCOM();128 CleanupCOM(); 129 129 130 130 AssertComRC (rc); … … 139 139 * Cleans up COM/XPCOM. 140 140 */ 141 HRESULT COMBase:: cleanupCOM()141 HRESULT COMBase::CleanupCOM() 142 142 { 143 143 LogFlowFuncEnter(); … … 182 182 } 183 183 184 /* static */ 185 void COMBase::ToSafeArray (const QValueVector <QString> &aVec, 186 com::SafeArray <BSTR> &aArr) 187 { 188 aArr.reset (aVec.size()); 189 size_t i = 0; 190 for (QValueVector <QString>::const_iterator it = aVec.begin(); 191 it != aVec.end(); ++ it, ++ i) 192 aArr [i] = SysAllocString ((const OLECHAR *) (*it).ucs2()); 193 } 194 195 /* static */ 196 void COMBase::FromSafeArray (const com::SafeArray <BSTR> &aArr, 197 QValueVector <QString> &aVec) 198 { 199 aVec = QValueVector <QString> (aArr.size()); 200 size_t i = 0; 201 for (QValueVector <QString>::iterator it = aVec.begin(); 202 it != aVec.end(); ++ it, ++ i) 203 *it = QString::fromUcs2 (aArr [i]); 204 } 205 184 206 //////////////////////////////////////////////////////////////////////////////// 185 207 … … 351 373 if (callee && calleeIID && mIsBasicAvailable) 352 374 { 353 mCalleeIID = COMBase:: toQUuid (*calleeIID);375 mCalleeIID = COMBase::ToQUuid (*calleeIID); 354 376 mCalleeName = getInterfaceNameFromIID (mCalleeIID); 355 377 } -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r6807 r6851 190 190 STDMETHOD(OnMachineStateChange) (IN_GUIDPARAM id, MachineState_T state) 191 191 { 192 postEvent (new VBoxMachineStateChangeEvent (COMBase:: toQUuid (id),192 postEvent (new VBoxMachineStateChangeEvent (COMBase::ToQUuid (id), 193 193 (CEnums::MachineState) state)); 194 194 return S_OK; … … 197 197 STDMETHOD(OnMachineDataChange) (IN_GUIDPARAM id) 198 198 { 199 postEvent (new VBoxMachineDataChangeEvent (COMBase:: toQUuid (id)));199 postEvent (new VBoxMachineDataChangeEvent (COMBase::ToQUuid (id))); 200 200 return S_OK; 201 201 } … … 208 208 return E_INVALIDARG; 209 209 210 if (COMBase:: toQUuid (id).isNull())210 if (COMBase::ToQUuid (id).isNull()) 211 211 { 212 212 /* it's a global extra data key someone wants to change */ … … 257 257 IN_BSTRPARAM key, IN_BSTRPARAM value) 258 258 { 259 if (COMBase:: toQUuid (id).isNull())259 if (COMBase::ToQUuid (id).isNull()) 260 260 { 261 261 QString sKey = QString::fromUcs2 (key); … … 300 300 STDMETHOD(OnMachineRegistered) (IN_GUIDPARAM id, BOOL registered) 301 301 { 302 postEvent (new VBoxMachineRegisteredEvent (COMBase:: toQUuid (id),302 postEvent (new VBoxMachineRegisteredEvent (COMBase::ToQUuid (id), 303 303 registered)); 304 304 return S_OK; … … 307 307 STDMETHOD(OnSessionStateChange) (IN_GUIDPARAM id, SessionState_T state) 308 308 { 309 postEvent (new VBoxSessionStateChangeEvent (COMBase:: toQUuid (id),309 postEvent (new VBoxSessionStateChangeEvent (COMBase::ToQUuid (id), 310 310 (CEnums::SessionState) state)); 311 311 return S_OK; … … 314 314 STDMETHOD(OnSnapshotTaken) (IN_GUIDPARAM aMachineId, IN_GUIDPARAM aSnapshotId) 315 315 { 316 postEvent (new VBoxSnapshotEvent (COMBase:: toQUuid (aMachineId),317 COMBase:: toQUuid (aSnapshotId),316 postEvent (new VBoxSnapshotEvent (COMBase::ToQUuid (aMachineId), 317 COMBase::ToQUuid (aSnapshotId), 318 318 VBoxSnapshotEvent::Taken)); 319 319 return S_OK; … … 322 322 STDMETHOD(OnSnapshotDiscarded) (IN_GUIDPARAM aMachineId, IN_GUIDPARAM aSnapshotId) 323 323 { 324 postEvent (new VBoxSnapshotEvent (COMBase:: toQUuid (aMachineId),325 COMBase:: toQUuid (aSnapshotId),324 postEvent (new VBoxSnapshotEvent (COMBase::ToQUuid (aMachineId), 325 COMBase::ToQUuid (aSnapshotId), 326 326 VBoxSnapshotEvent::Discarded)); 327 327 return S_OK; … … 330 330 STDMETHOD(OnSnapshotChange) (IN_GUIDPARAM aMachineId, IN_GUIDPARAM aSnapshotId) 331 331 { 332 postEvent (new VBoxSnapshotEvent (COMBase:: toQUuid (aMachineId),333 COMBase:: toQUuid (aSnapshotId),332 postEvent (new VBoxSnapshotEvent (COMBase::ToQUuid (aMachineId), 333 COMBase::ToQUuid (aSnapshotId), 334 334 VBoxSnapshotEvent::Changed)); 335 335 return S_OK; … … 1934 1934 { 1935 1935 LogFlow (("MediaEnumThread started.\n")); 1936 COMBase:: initializeCOM();1936 COMBase::InitializeCOM(); 1937 1937 1938 1938 CVirtualBox mVBox = vboxGlobal().virtualBox(); … … 2010 2010 QApplication::postEvent (target, new VBoxEnumerateMediaEvent()); 2011 2011 2012 COMBase:: cleanupCOM();2012 COMBase::CleanupCOM(); 2013 2013 LogFlow (("MediaEnumThread finished.\n")); 2014 2014 } … … 3770 3770 /* COM for the main thread is initialized in main() */ 3771 3771 #else 3772 HRESULT rc = COMBase:: initializeCOM();3772 HRESULT rc = COMBase::InitializeCOM(); 3773 3773 if (FAILED (rc)) 3774 3774 { … … 4030 4030 /* COM for the main thread is shutdown in main() */ 4031 4031 #else 4032 COMBase:: cleanupCOM();4032 COMBase::CleanupCOM(); 4033 4033 #endif 4034 4034 -
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r6264 r6851 138 138 * for some unknown reason), see also src/VBox/Main/glue/initterm.cpp. */ 139 139 /// @todo find a proper solution that satisfies both OLE and VBox 140 HRESULT hrc = COMBase:: initializeCOM();140 HRESULT hrc = COMBase::InitializeCOM(); 141 141 #endif 142 142 … … 267 267 /* See COMBase::initializeCOM() above */ 268 268 if (SUCCEEDED (hrc)) 269 COMBase:: cleanupCOM();269 COMBase::CleanupCOM(); 270 270 #endif 271 271 -
trunk/src/VBox/Main/Doxyfile.Main
r6076 r6851 86 86 # "is" "provides" "specifies" "contains" "represents" "a" "an" "the" 87 87 88 ABBREVIATE_BRIEF = "The $name interface" "represents" "a" "an" "the"88 ABBREVIATE_BRIEF = "The $name class" "The $name interface" "is" "provides" "represents" "a" "an" "the" 89 89 90 90 # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -
trunk/src/VBox/Main/Makefile.kmk
r6778 r6851 394 394 ConsoleImpl.cpp_DEFS = VBOX_BUILD_TARGET=\"$(BUILD_TARGET).$(BUILD_TARGET_ARCH)\" 395 395 396 win32/VBoxC.rc_DEPS = $(PATH_TARGET)/VBoxC.rgs 396 win32/VBoxC.rc_DEPS = $(PATH_TARGET)/VBoxC.rgs $(PATH_VBoxCOM)/VirtualBox.tlb 397 397 398 398 -
trunk/src/VBox/Main/VirtualBoxBase.cpp
r6076 r6851 932 932 } 933 933 934 #if defined VBOX_MAIN_SETTINGS_ADDONS 934 // VirtualBoxBaseWithChildrenNEXT methods 935 //////////////////////////////////////////////////////////////////////////////// 936 937 /** 938 * Uninitializes all dependent children registered with #addDependentChild(). 939 * 940 * Typically called from the uninit() method. Note that this method will call 941 * uninit() methods of child objects. If these methods need to call the parent 942 * object during initialization, uninitDependentChildren() must be called before 943 * the relevant part of the parent is uninitialized, usually at the begnning of 944 * the parent uninitialization sequence. 945 */ 946 void VirtualBoxBaseWithChildrenNEXT::uninitDependentChildren() 947 { 948 LogFlowThisFuncEnter(); 949 950 AutoLock mapLock (mMapLock); 951 952 LogFlowThisFunc (("count=%u...\n", mDependentChildren.size())); 953 954 if (mDependentChildren.size()) 955 { 956 /* We keep the lock until we have enumerated all children. 957 * Those ones that will try to call removeDependentChild() from a 958 * different thread will have to wait */ 959 960 Assert (mUninitDoneSem == NIL_RTSEMEVENT); 961 int vrc = RTSemEventCreate (&mUninitDoneSem); 962 AssertRC (vrc); 963 964 Assert (mChildrenLeft == 0); 965 mChildrenLeft = mDependentChildren.size(); 966 967 for (DependentChildren::iterator it = mDependentChildren.begin(); 968 it != mDependentChildren.end(); ++ it) 969 { 970 VirtualBoxBase *child = (*it).second; 971 Assert (child); 972 if (child) 973 child->uninit(); 974 } 975 976 mDependentChildren.clear(); 977 } 978 979 /* Wait until all children that called uninit() on their own on other 980 * threads but stuck waiting for the map lock in removeDependentChild() have 981 * finished uninitialization. */ 982 983 if (mUninitDoneSem != NIL_RTSEMEVENT) 984 { 985 /* let stuck children run */ 986 mapLock.leave(); 987 988 LogFlowThisFunc (("Waiting for uninitialization of all children...\n")); 989 990 RTSemEventWait (mUninitDoneSem, RT_INDEFINITE_WAIT); 991 992 mapLock.enter(); 993 994 RTSemEventDestroy (mUninitDoneSem); 995 mUninitDoneSem = NIL_RTSEMEVENT; 996 Assert (mChildrenLeft == 0); 997 } 998 999 LogFlowThisFuncLeave(); 1000 } 1001 1002 /** 1003 * Returns a pointer to the dependent child corresponding to the given 1004 * interface pointer (used as a key in the map of dependent children) or NULL 1005 * if the interface pointer doesn't correspond to any child registered using 1006 * #addDependentChild(). 1007 * 1008 * Note that ComPtr <IUnknown> is used as an argument instead of IUnknown * in 1009 * order to guarantee IUnknown identity and disambiguation by doing 1010 * QueryInterface (IUnknown) rather than a regular C cast. 1011 * 1012 * @param aUnk Pointer to map to the dependent child object. 1013 * @return Pointer to the dependent child object. 1014 */ 1015 VirtualBoxBaseNEXT * 1016 VirtualBoxBaseWithChildrenNEXT::getDependentChild (const ComPtr <IUnknown> &aUnk) 1017 { 1018 AssertReturn (!!aUnk, NULL); 1019 1020 AutoLock alock (mMapLock); 1021 1022 /* return NULL if uninitDependentChildren() is in action */ 1023 if (mUninitDoneSem != NIL_RTSEMEVENT) 1024 return NULL; 1025 1026 DependentChildren::const_iterator it = mDependentChildren.find (aUnk); 1027 if (it == mDependentChildren.end()) 1028 return NULL; 1029 return (*it).second; 1030 } 1031 1032 void VirtualBoxBaseWithChildrenNEXT::doAddDependentChild ( 1033 IUnknown *aUnk, VirtualBoxBaseNEXT *aChild) 1034 { 1035 AssertReturnVoid (aUnk && aChild); 1036 1037 AutoLock alock (mMapLock); 1038 1039 if (mUninitDoneSem != NIL_RTSEMEVENT) 1040 { 1041 /* uninitDependentChildren() is being run. For this very unlikely case, 1042 * we have to increase the number of children left, for symmetry with 1043 * a later #removeDependentChild() call. */ 1044 ++ mChildrenLeft; 1045 return; 1046 } 1047 1048 std::pair <DependentChildren::iterator, bool> result = 1049 mDependentChildren.insert (DependentChildren::value_type (aUnk, aChild)); 1050 AssertMsg (result.second, ("Failed to insert a child to the map\n")); 1051 } 1052 1053 void VirtualBoxBaseWithChildrenNEXT::doRemoveDependentChild (IUnknown *aUnk) 1054 { 1055 AssertReturnVoid (aUnk); 1056 1057 AutoLock alock (mMapLock); 1058 1059 if (mUninitDoneSem != NIL_RTSEMEVENT) 1060 { 1061 /* uninitDependentChildren() is being run. Just decrease the number of 1062 * children left and signal a semaphore if it reaches zero. */ 1063 Assert (mChildrenLeft != 0); 1064 -- mChildrenLeft; 1065 if (mChildrenLeft == 0) 1066 { 1067 int vrc = RTSemEventSignal (mUninitDoneSem); 1068 AssertRC (vrc); 1069 } 1070 return; 1071 } 1072 1073 DependentChildren::size_type result = mDependentChildren.erase (aUnk); 1074 AssertMsg (result == 1, ("Failed to remove the child %p from the map\n", 1075 aUnk)); 1076 NOREF (result); 1077 } 1078 1079 // VirtualBoxBaseWithTypedChildrenNEXT methods 1080 //////////////////////////////////////////////////////////////////////////////// 1081 1082 /** 1083 * Uninitializes all dependent children registered with 1084 * #addDependentChild(). 1085 * 1086 * @note This method will call uninit() methods of children. If these 1087 * methods access the parent object, uninitDependentChildren() must be 1088 * called either at the beginning of the parent uninitialization 1089 * sequence (when it is still operational) or after setReady(false) is 1090 * called to indicate the parent is out of action. 1091 */ 1092 template <class C> 1093 void VirtualBoxBaseWithTypedChildrenNEXT <C>::uninitDependentChildren() 1094 { 1095 AutoLock mapLock (mMapLock); 1096 1097 if (mDependentChildren.size()) 1098 { 1099 /* set flag to ignore #removeDependentChild() called from 1100 * child->uninit() */ 1101 mInUninit = true; 1102 1103 /* leave the locks to let children waiting for 1104 * #removeDependentChild() run */ 1105 mapLock.leave(); 1106 1107 for (typename DependentChildren::iterator it = mDependentChildren.begin(); 1108 it != mDependentChildren.end(); ++ it) 1109 { 1110 C *child = (*it); 1111 Assert (child); 1112 if (child) 1113 child->uninit(); 1114 } 1115 mDependentChildren.clear(); 1116 1117 mapLock.enter(); 1118 1119 mInUninit = false; 1120 } 1121 } 935 1122 936 1123 // Settings API additions 937 1124 //////////////////////////////////////////////////////////////////////////////// 1125 1126 #if defined VBOX_MAIN_SETTINGS_ADDONS 938 1127 939 1128 namespace settings -
trunk/src/VBox/Main/idl/midl.xsl
r5999 r6851 6 6 7 7 Copyright (C) 2006-2007 innotek GmbH 8 8 9 9 This file is part of VirtualBox Open Source Edition (OSE), as 10 10 available from http://www.virtualbox.org. This file is free software; … … 199 199 <xsl:template match="interface//attribute | collection//attribute"> 200 200 <xsl:apply-templates select="@if" mode="begin"/> 201 <xsl:if test="@array"> 202 <xsl:message terminate="yes"> 203 <xsl:value-of select="concat(../@name,'::',@name,': ')"/> 204 <xsl:text>'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text> 205 </xsl:message> 206 </xsl:if> 207 <!-- getter --> 201 208 <xsl:text> [propget] HRESULT </xsl:text> 202 209 <xsl:call-template name="capitalize"> … … 204 211 </xsl:call-template> 205 212 <xsl:text> ([out, retval] </xsl:text> 213 <xsl:if test="@safearray='yes'"> 214 <xsl:text>SAFEARRAY(</xsl:text> 215 </xsl:if> 206 216 <xsl:apply-templates select="@type"/> 217 <xsl:if test="@safearray='yes'"> 218 <xsl:text>)</xsl:text> 219 </xsl:if> 207 220 <xsl:text> * a</xsl:text> 208 221 <xsl:call-template name="capitalize"> … … 210 223 </xsl:call-template> 211 224 <xsl:text>);
</xsl:text> 225 <!-- setter --> 212 226 <xsl:if test="not(@readonly='yes')"> 213 227 <xsl:text> [propput] HRESULT </xsl:text> … … 215 229 <xsl:with-param name="str" select="@name"/> 216 230 </xsl:call-template> 217 <xsl:text> ([in] </xsl:text> 231 <xsl:text> ([in</xsl:text> 232 <xsl:if test="@safearray='yes'"> 233 <!-- VB supports only [in, out], [out] and [out, retval] arrays --> 234 <xsl:text>, out</xsl:text> 235 </xsl:if> 236 <xsl:text>] </xsl:text> 237 <xsl:if test="@safearray='yes'"> 238 <xsl:text>SAFEARRAY(</xsl:text> 239 </xsl:if> 218 240 <xsl:apply-templates select="@type"/> 241 <xsl:if test="@safearray='yes'"> 242 <xsl:text>) *</xsl:text> 243 </xsl:if> 219 244 <xsl:text> a</xsl:text> 220 245 <xsl:call-template name="capitalize"> … … 392 417 <xsl:otherwise>in</xsl:otherwise> 393 418 </xsl:choose> 419 <xsl:if test="@safearray='yes'"> 420 <!-- VB supports only [in, out], [out] and [out, retval] arrays --> 421 <xsl:if test="@dir='in'">, out</xsl:if> 422 </xsl:if> 394 423 <xsl:if test="@array"> 395 424 <xsl:if test="@dir='return'"> 396 425 <xsl:message terminate="yes"> 397 426 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/> 398 <xsl:text>return array parameters are not currently supported</xsl:text>427 <xsl:text>return 'array' parameters are not supported, use 'safearray="yes"' instead.</xsl:text> 399 428 </xsl:message> 400 429 </xsl:if> … … 410 439 <xsl:text>, size_is(</xsl:text> 411 440 <xsl:if test="@dir='out'"> 412 <xsl:text>, </xsl:text>441 <xsl:text>, *</xsl:text> 413 442 </xsl:if> 414 <xsl:if test="../param[@name=current()/@array]/@dir='out'">415 <xsl:text>*</xsl:text>416 </xsl:if>417 <!--xsl:value-of select="@array"/-->418 443 <xsl:text>a</xsl:text> 419 444 <xsl:call-template name="capitalize"> … … 432 457 </xsl:if> 433 458 <xsl:text>] </xsl:text> 459 <xsl:if test="@safearray='yes'"> 460 <xsl:text>SAFEARRAY(</xsl:text> 461 </xsl:if> 434 462 <xsl:apply-templates select="@type"/> 435 <xsl:text> </xsl:text> 463 <xsl:if test="@safearray='yes'"> 464 <xsl:text>)</xsl:text> 465 </xsl:if> 436 466 <xsl:if test="@array"> 437 <xsl:text>* </xsl:text> 438 </xsl:if> 439 <xsl:if test="@dir='out' or @dir='return'"> 440 <xsl:text>* </xsl:text> 441 </xsl:if> 442 <!--xsl:value-of select="@name"/--> 443 <xsl:text>a</xsl:text> 467 <xsl:text> *</xsl:text> 468 </xsl:if> 469 <xsl:if test="@dir='out' or @dir='return' or @safearray='yes'"> 470 <xsl:text> *</xsl:text> 471 </xsl:if> 472 <xsl:text> a</xsl:text> 444 473 <xsl:call-template name="capitalize"> 445 474 <xsl:with-param name="str" select="@name"/> … … 457 486 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/> 458 487 488 <xsl:if test="../@array and ../@safearray='yes'"> 489 <xsl:message terminate="yes"> 490 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 491 <xsl:text>either 'array' or 'safearray="yes"' attribute is allowed, but not both!</xsl:text> 492 </xsl:message> 493 </xsl:if> 494 459 495 <xsl:choose> 460 496 <!-- modifiers (ignored for 'enumeration' attributes)--> 461 497 <xsl:when test="name(current())='type' and ../@mod"> 462 <xsl:if test="../@array">463 <xsl:message terminate="yes">464 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>465 <xsl:text>either 'array' or 'mod' attribute is allowed, but not both!</xsl:text>466 </xsl:message>467 </xsl:if>468 498 <xsl:choose> 469 499 <xsl:when test="../@mod='ptr'"> … … 498 528 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 499 529 <xsl:value-of select="concat('value "',../@mod,'" ')"/> 500 <xsl:text>of att ibute 'mod' is invalid!</xsl:text>530 <xsl:text>of attribute 'mod' is invalid!</xsl:text> 501 531 </xsl:message> 502 532 </xsl:otherwise> -
trunk/src/VBox/Main/idl/xpidl.xsl
r5999 r6851 26 26 ///////////////////////////////////////////////////////////////////////////// 27 27 --> 28 29 <!-- 30 * capitalizes the first letter 31 --> 32 <xsl:template name="capitalize"> 33 <xsl:param name="str" select="."/> 34 <xsl:value-of select=" 35 concat( 36 translate(substring($str,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 37 substring($str,2) 38 ) 39 "/> 40 </xsl:template> 28 41 29 42 <!-- … … 214 227 --> 215 228 <xsl:template match="interface//attribute | collection//attribute"> 229 <xsl:if test="@array"> 230 <xsl:message terminate="yes"> 231 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/> 232 <xsl:text>'array' attributes are not supported, use 'safearray="yes"' instead.</xsl:text> 233 </xsl:message> 234 </xsl:if> 216 235 <xsl:apply-templates select="@if" mode="begin"/> 217 236 <xsl:if test="@mod='ptr'"> … … 219 238 <xsl:text> [noscript]
</xsl:text> 220 239 </xsl:if> 221 <xsl:text> </xsl:text> 222 <xsl:if test="@readonly='yes'"> 223 <xsl:text>readonly </xsl:text> 224 </xsl:if> 225 <xsl:text>attribute </xsl:text> 226 <xsl:apply-templates select="@type"/> 227 <xsl:text> </xsl:text> 228 <xsl:value-of select="@name"/> 229 <xsl:text>;
</xsl:text> 240 <xsl:choose> 241 <!-- safearray pseudo attribute --> 242 <xsl:when test="@safearray='yes'"> 243 <!-- getter --> 244 <xsl:text> void get</xsl:text> 245 <xsl:call-template name="capitalize"> 246 <xsl:with-param name="str" select="@name"/> 247 </xsl:call-template> 248 <xsl:text> (
</xsl:text> 249 <!-- array size --> 250 <xsl:text> out unsigned long </xsl:text> 251 <xsl:value-of select="@name"/> 252 <xsl:text>Size,
</xsl:text> 253 <!-- array pointer --> 254 <xsl:text> [array, size_is(</xsl:text> 255 <xsl:value-of select="@name"/> 256 <xsl:text>Size), retval] out </xsl:text> 257 <xsl:apply-templates select="@type"/> 258 <xsl:text> </xsl:text> 259 <xsl:value-of select="@name"/> 260 <xsl:text>
 );
</xsl:text> 261 <!-- setter --> 262 <xsl:if test="not(@readonly='yes')"> 263 <xsl:text> void set</xsl:text> 264 <xsl:call-template name="capitalize"> 265 <xsl:with-param name="str" select="@name"/> 266 </xsl:call-template> 267 <xsl:text> (
</xsl:text> 268 <!-- array size --> 269 <xsl:text> in unsigned long </xsl:text> 270 <xsl:value-of select="@name"/> 271 <xsl:text>Size,
</xsl:text> 272 <!-- array pointer --> 273 <xsl:text> [array, size_is(</xsl:text> 274 <xsl:value-of select="@name"/> 275 <xsl:text>Size)] in </xsl:text> 276 <xsl:apply-templates select="@type"/> 277 <xsl:text> </xsl:text> 278 <xsl:value-of select="@name"/> 279 <xsl:text>
 );
</xsl:text> 280 </xsl:if> 281 </xsl:when> 282 <!-- normal attribute --> 283 <xsl:otherwise> 284 <xsl:text> </xsl:text> 285 <xsl:if test="@readonly='yes'"> 286 <xsl:text>readonly </xsl:text> 287 </xsl:if> 288 <xsl:text>attribute </xsl:text> 289 <xsl:apply-templates select="@type"/> 290 <xsl:text> </xsl:text> 291 <xsl:value-of select="@name"/> 292 <xsl:text>;
</xsl:text> 293 </xsl:otherwise> 294 </xsl:choose> 230 295 <xsl:apply-templates select="@if" mode="end"/> 231 296 <xsl:text>
</xsl:text> … … 408 473 --> 409 474 <xsl:template match="method/param"> 410 <xsl:if test="@array"> 411 <xsl:if test="@dir='return'"> 412 <xsl:message terminate="yes"> 413 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/> 414 <xsl:text>return array parameters are not currently supported</xsl:text> 415 </xsl:message> 416 </xsl:if> 417 <xsl:text>[array, </xsl:text> 418 <xsl:choose> 419 <xsl:when test="../param[@name=current()/@array]"> 420 <xsl:if test="../param[@name=current()/@array]/@dir != @dir"> 475 <xsl:choose> 476 <!-- safearray parameters --> 477 <xsl:when test="@safearray='yes'"> 478 <!-- array size --> 479 <xsl:choose> 480 <xsl:when test="@dir='in'">in </xsl:when> 481 <xsl:when test="@dir='out'">out </xsl:when> 482 <xsl:when test="@dir='return'">out </xsl:when> 483 <xsl:otherwise>in </xsl:otherwise> 484 </xsl:choose> 485 <xsl:text>unsigned long </xsl:text> 486 <xsl:value-of select="@name"/> 487 <xsl:text>Size,
</xsl:text> 488 <!-- array pointer --> 489 <xsl:text> [array, size_is(</xsl:text> 490 <xsl:value-of select="@name"/> 491 <xsl:text>Size)</xsl:text> 492 <xsl:choose> 493 <xsl:when test="@dir='in'">] in </xsl:when> 494 <xsl:when test="@dir='out'">] out </xsl:when> 495 <xsl:when test="@dir='return'"> , retval] out </xsl:when> 496 <xsl:otherwise>] in </xsl:otherwise> 497 </xsl:choose> 498 <xsl:apply-templates select="@type"/> 499 <xsl:text> </xsl:text> 500 <xsl:value-of select="@name"/> 501 </xsl:when> 502 <!-- normal and array parameters --> 503 <xsl:otherwise> 504 <xsl:if test="@array"> 505 <xsl:if test="@dir='return'"> 421 506 <xsl:message terminate="yes"> 422 <xsl:value-of select="concat(../../@name,'::',../@name,': ')"/> 423 <xsl:value-of select="concat(@name,' and ',../param[@name=current()/@array]/@name)"/> 424 <xsl:text> must have the same direction</xsl:text> 507 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/> 508 <xsl:text>return 'array' parameters are not supported, use 'safearray="yes"' instead.</xsl:text> 425 509 </xsl:message> 426 510 </xsl:if> 427 <xsl:text>size_is(</xsl:text> 428 <xsl:if test="@dir='out'"> 429 <xsl:text>, </xsl:text> 430 </xsl:if> 431 <xsl:if test="../param[@name=current()/@array]/@dir='out'"> 432 <xsl:text>*</xsl:text> 433 </xsl:if> 434 <xsl:value-of select="@array"/> 435 <xsl:text>)</xsl:text> 436 </xsl:when> 437 <xsl:otherwise> 438 <xsl:message terminate="yes"> 439 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/> 440 <xsl:text>array attribute refers to non-existent param: </xsl:text> 441 <xsl:value-of select="@array"/> 442 </xsl:message> 443 </xsl:otherwise> 444 </xsl:choose> 445 <xsl:text>] </xsl:text> 446 </xsl:if> 447 <xsl:choose> 448 <xsl:when test="@dir='in'">in </xsl:when> 449 <xsl:when test="@dir='out'">out </xsl:when> 450 <xsl:when test="@dir='return'">[retval] out </xsl:when> 451 <xsl:otherwise>in</xsl:otherwise> 511 <xsl:text>[array, </xsl:text> 512 <xsl:choose> 513 <xsl:when test="../param[@name=current()/@array]"> 514 <xsl:if test="../param[@name=current()/@array]/@dir != @dir"> 515 <xsl:message terminate="yes"> 516 <xsl:value-of select="concat(../../@name,'::',../@name,': ')"/> 517 <xsl:value-of select="concat(@name,' and ',../param[@name=current()/@array]/@name)"/> 518 <xsl:text> must have the same direction</xsl:text> 519 </xsl:message> 520 </xsl:if> 521 <xsl:text>size_is(</xsl:text> 522 <xsl:value-of select="@array"/> 523 <xsl:text>)</xsl:text> 524 </xsl:when> 525 <xsl:otherwise> 526 <xsl:message terminate="yes"> 527 <xsl:value-of select="concat(../../@name,'::',../@name,'::',@name,': ')"/> 528 <xsl:text>array attribute refers to non-existent param: </xsl:text> 529 <xsl:value-of select="@array"/> 530 </xsl:message> 531 </xsl:otherwise> 532 </xsl:choose> 533 <xsl:text>] </xsl:text> 534 </xsl:if> 535 <xsl:choose> 536 <xsl:when test="@dir='in'">in </xsl:when> 537 <xsl:when test="@dir='out'">out </xsl:when> 538 <xsl:when test="@dir='return'">[retval] out </xsl:when> 539 <xsl:otherwise>in </xsl:otherwise> 540 </xsl:choose> 541 <xsl:apply-templates select="@type"/> 542 <xsl:text> </xsl:text> 543 <xsl:value-of select="@name"/> 544 </xsl:otherwise> 452 545 </xsl:choose> 453 <xsl:apply-templates select="@type"/>454 <xsl:text> </xsl:text>455 <xsl:value-of select="@name"/>456 546 </xsl:template> 457 547 … … 466 556 <xsl:variable name="self_target" select="current()/ancestor::if/@target"/> 467 557 558 <xsl:if test="../@array and ../@safearray='yes'"> 559 <xsl:message terminate="yes"> 560 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 561 <xsl:text>either 'array' or 'safearray="yes"' attribute is allowed, but not both!</xsl:text> 562 </xsl:message> 563 </xsl:if> 564 468 565 <xsl:choose> 469 566 <!-- modifiers (ignored for 'enumeration' attributes)--> 470 567 <xsl:when test="name(current())='type' and ../@mod"> 471 <xsl:if test="../@array">472 <xsl:message terminate="yes">473 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/>474 <xsl:text>either 'array' or 'mod' attribute is allowed, but not both!</xsl:text>475 </xsl:message>476 </xsl:if>477 568 <xsl:choose> 478 569 <xsl:when test="../@mod='ptr'"> … … 507 598 <xsl:value-of select="concat(../../../@name,'::',../../@name,'::',../@name,': ')"/> 508 599 <xsl:value-of select="concat('value "',../@mod,'" ')"/> 509 <xsl:text>of att ibute 'mod' is invalid!</xsl:text>600 <xsl:text>of attribute 'mod' is invalid!</xsl:text> 510 601 </xsl:message> 511 602 </xsl:otherwise> -
trunk/src/VBox/Main/include/USBControllerImpl.h
r6076 r6851 137 137 ComObjPtr <USBDeviceFilter> getDependentChild (IUSBDeviceFilter *aFilter) 138 138 { 139 VirtualBoxBase *child = VirtualBoxBaseWithChildren ::139 VirtualBoxBase *child = VirtualBoxBaseWithChildrenNEXT:: 140 140 getDependentChild (ComPtr <IUnknown> (aFilter)); 141 141 return child ? static_cast <USBDeviceFilter *> (child) -
trunk/src/VBox/Main/include/VirtualBoxBase.h
r6076 r6851 1446 1446 * VirtualBoxBase::uninit() implementations). This is done simply by 1447 1447 * calling the #uninitDependentChildren() method. 1448 * </li>< ol>1448 * </li></ol> 1449 1449 * 1450 1450 * In order to let the above work, the following must be done: … … 1459 1459 * uninit() implementation must do is to check for readiness after acquiring 1460 1460 * the object's lock and return immediately if not ready. 1461 * </li>< ol>1461 * </li></ol> 1462 1462 * 1463 1463 * Children added by #addDependentChild() are <b>weakly</b> referenced … … 1471 1471 * if #addDependentChild() or #removeDependentChild() are used incorrectly 1472 1472 * (called at inappropriate times). Check the above rules once more. 1473 * 1474 * @deprecated Use VirtualBoxBaseWithChildrenNEXT for new classes. 1473 1475 */ 1474 1476 class VirtualBoxBaseWithChildren : public VirtualBoxBase … … 1544 1546 }; 1545 1547 1546 /** 1547 * Temporary class to disable deprecated methods of VirtualBoxBase. 1548 * Can be used as a base for components that are completely switched to 1549 * the new locking scheme (VirtualBoxBaseNEXT_base). 1550 * 1551 * @todo remove after we switch to VirtualBoxBaseNEXT completely. 1552 */ 1553 class VirtualBoxBaseWithChildrenNEXT : public VirtualBoxBaseWithChildren 1548 //////////////////////////////////////////////////////////////////////////////// 1549 1550 /** 1551 * 1552 * Base class to track VirtualBoxBaseNEXT chlidren of the component. 1553 * 1554 * This class is a preferrable VirtualBoxBase replacement for components that 1555 * operate with collections of child components. It gives two useful 1556 * possibilities: 1557 * 1558 * <ol><li> 1559 * Given an IUnknown instance, it's possible to quickly determine 1560 * whether this instance represents a child object created by the given 1561 * component, and if so, get a valid VirtualBoxBase pointer to the child 1562 * object. The returned pointer can be then safely casted to the 1563 * actual class of the child object (to get access to its "internal" 1564 * non-interface methods) provided that no other child components implement 1565 * the same initial interface IUnknown is queried from. 1566 * </li><li> 1567 * When the parent object uninitializes itself, it can easily unintialize 1568 * all its VirtualBoxBase derived children (using their 1569 * VirtualBoxBase::uninit() implementations). This is done simply by 1570 * calling the #uninitDependentChildren() method. 1571 * </li></ol> 1572 * 1573 * In order to let the above work, the following must be done: 1574 * <ol><li> 1575 * When a child object is initialized, it calls #addDependentChild() of 1576 * its parent to register itself within the list of dependent children. 1577 * </li><li> 1578 * When a child object it is uninitialized, it calls 1579 * #removeDependentChild() to unregister itself. Since the child's 1580 * uninitialization may originate both from this method and from the child 1581 * itself calling its uninit() on another thread at the same time, please 1582 * make sure that #removeDependentChild() is called: 1583 * <ul><li> 1584 * after the child has successfully entered AutoUninitSpan -- to make 1585 * sure this method is called only once for the given child object 1586 * transitioning from Ready to NotReady. A failure to do so will at 1587 * least likely cause an assertion ("Failed to remove the child from 1588 * the map"). 1589 * </li><li> 1590 * outside the child object's lock -- to avoid guaranteed deadlocks 1591 * caused by different lock order: (child_lock, map_lock) in uninit() 1592 * and (map_lock, child_lock) in this method. 1593 * </li></ul> 1594 * </li></ol> 1595 * 1596 * Note that children added by #addDependentChild() are <b>weakly</b> referenced 1597 * (i.e. AddRef() is not called), so when a child object is deleted externally 1598 * (because it's reference count goes to zero), it will automatically remove 1599 * itself from the map of dependent children provided that it follows the rules 1600 * described here. 1601 * 1602 * @note Once again: because of weak referencing, deadlocks and assertions are 1603 * very likely if #addDependentChild() or #removeDependentChild() are used 1604 * incorrectly (called at inappropriate times). Check the above rules once 1605 * more. 1606 * 1607 * @todo This is a VirtualBoxBaseWithChildren equivalent that uses the 1608 * VirtualBoxBaseNEXT implementation. Will completely supercede 1609 * VirtualBoxBaseWithChildren after the old VirtualBoxBase implementation 1610 * has gone. 1611 */ 1612 class VirtualBoxBaseWithChildrenNEXT : public VirtualBoxBaseNEXT 1554 1613 { 1614 public: 1615 1616 VirtualBoxBaseWithChildrenNEXT() 1617 : mUninitDoneSem (NIL_RTSEMEVENT), mChildrenLeft (0) 1618 {} 1619 1620 virtual ~VirtualBoxBaseWithChildrenNEXT() 1621 {} 1622 1623 /** 1624 * Adds the given child to the map of dependent children. 1625 * 1626 * Typically called from the child's init() method, from within the 1627 * AutoInitSpan scope. Otherwise, VirtualBoxBase::AutoCaller must be 1628 * used on @a aChild to make sure it is not uninitialized during this 1629 * method's call. 1630 * 1631 * @param aChild Child object to add (must inherit VirtualBoxBase AND 1632 * implement some interface). 1633 */ 1634 template <class C> 1635 void addDependentChild (C *aChild) 1636 { 1637 AssertReturnVoid (aChild); 1638 doAddDependentChild (ComPtr <IUnknown> (aChild), aChild); 1639 } 1640 1641 /** 1642 * Removes the given child from the map of dependent children. 1643 * 1644 * Make sure this method is called after the child has successfully entered 1645 * AutoUninitSpan and outside the child lock. 1646 * 1647 * If called not from within the AutoUninitSpan scope, 1648 * VirtualBoxBase::AutoCaller must be used on @a aChild to make sure it is 1649 * not uninitialized during this method's call. 1650 * 1651 * @param aChild Child object to remove (must inherit VirtualBoxBase AND 1652 * implement some interface). 1653 */ 1654 template <class C> 1655 void removeDependentChild (C *aChild) 1656 { 1657 AssertReturnVoid (aChild); 1658 Assert (!aChild->isLockedOnCurrentThread()); 1659 doRemoveDependentChild (ComPtr <IUnknown> (aChild)); 1660 } 1661 1662 protected: 1663 1664 void uninitDependentChildren(); 1665 1666 VirtualBoxBaseNEXT *getDependentChild (const ComPtr <IUnknown> &aUnk); 1667 1555 1668 private: 1556 1669 1557 void lock(); 1558 void unlock(); 1559 void setReady (bool isReady); 1560 bool isReady(); 1670 /// @todo temporarily reinterpret VirtualBoxBase * as VirtualBoxBaseNEXT * 1671 // until ported HardDisk and Progress to the new scheme. 1672 void doAddDependentChild (IUnknown *aUnk, VirtualBoxBase *aChild) 1673 { 1674 doAddDependentChild (aUnk, 1675 reinterpret_cast <VirtualBoxBaseNEXT *> (aChild)); 1676 } 1677 1678 void doAddDependentChild (IUnknown *aUnk, VirtualBoxBaseNEXT *aChild); 1679 void doRemoveDependentChild (IUnknown *aUnk); 1680 1681 typedef std::map <IUnknown *, VirtualBoxBaseNEXT *> DependentChildren; 1682 DependentChildren mDependentChildren; 1683 1684 RTSEMEVENT mUninitDoneSem; 1685 size_t mChildrenLeft; 1686 1687 /* Protects all the fields above */ 1688 AutoLock::Handle mMapLock; 1561 1689 }; 1562 1690 … … 1579 1707 * @param C type of child objects (must inherit VirtualBoxBase AND 1580 1708 * implement some interface) 1709 * 1710 * @deprecated Use VirtualBoxBaseWithTypedChildrenNEXT for new classes. 1581 1711 */ 1582 1712 template <class C> … … 1709 1839 }; 1710 1840 1711 /** 1712 * Temporary class to disable deprecated methods of VirtualBoxBase. 1713 * Can be used as a base for components that are completely switched to 1714 * the new locking scheme (VirtualBoxBaseNEXT_base). 1715 * 1716 * @todo remove after we switch to VirtualBoxBaseNEXT completely. 1841 //////////////////////////////////////////////////////////////////////////////// 1842 1843 /** 1844 * Base class to track component's chlidren of the particular type. 1845 * 1846 * This class is similar to VirtualBoxBaseWithChildren, with the exception that 1847 * all children must be of the same type. For this reason, it's not necessary to 1848 * use a map to store children, so a list is used instead. 1849 * 1850 * As opposed to VirtualBoxBaseWithChildren, children added by 1851 * #addDependentChild() are <b>strongly</b> referenced, so that they cannot be 1852 * externally deleted until #removeDependentChild() is called. For this 1853 * reason, strict rules of calling #removeDependentChild() don't apply to 1854 * instances of this class -- it can be called anywhere in the child's uninit() 1855 * implementation. 1856 * 1857 * @param C Type of child objects (must inherit VirtualBoxBase AND implementsome 1858 * interface). 1859 * 1860 * @todo This is a VirtualBoxBaseWithChildren equivalent that uses the 1861 * VirtualBoxBaseNEXT implementation. Will completely supercede 1862 * VirtualBoxBaseWithChildren after the old VirtualBoxBase implementation 1863 * has gone. 1717 1864 */ 1718 1865 template <class C> 1719 class VirtualBoxBaseWithTypedChildrenNEXT : public VirtualBoxBase WithTypedChildren <C>1866 class VirtualBoxBaseWithTypedChildrenNEXT : public VirtualBoxBaseNEXT 1720 1867 { 1721 1868 public: 1722 1869 1723 typedef util::AutoLock AutoLock; 1870 typedef std::list <ComObjPtr <C> > DependentChildren; 1871 1872 VirtualBoxBaseWithTypedChildrenNEXT() : mInUninit (false) {} 1873 1874 virtual ~VirtualBoxBaseWithTypedChildrenNEXT() {} 1875 1876 /** 1877 * Adds the given child to the list of dependent children. 1878 * 1879 * VirtualBoxBase::AutoCaller must be used on @a aChild to make sure it is 1880 * not uninitialized during this method's call. 1881 * 1882 * @param aChild Child object to add (must inherit VirtualBoxBase AND 1883 * implement some interface). 1884 */ 1885 void addDependentChild (C *aChild) 1886 { 1887 AssertReturnVoid (aChild); 1888 1889 AutoLock alock (mMapLock); 1890 if (mInUninit) 1891 return; 1892 1893 mDependentChildren.push_back (aChild); 1894 } 1895 1896 /** 1897 * Removes the given child from the list of dependent children. 1898 * 1899 * VirtualBoxBase::AutoCaller must be used on @a aChild to make sure it is 1900 * not uninitialized during this method's call. 1901 * 1902 * @param aChild the child object to remove (must inherit VirtualBoxBase 1903 * AND implement some interface). 1904 */ 1905 void removeDependentChild (C *aChild) 1906 { 1907 AssertReturnVoid (aChild); 1908 1909 AutoLock alock (mMapLock); 1910 if (mInUninit) 1911 return; 1912 1913 mDependentChildren.remove (aChild); 1914 } 1915 1916 protected: 1917 1918 /** 1919 * Returns an internal lock handle used to lock the list of children 1920 * returned by #dependentChildren(). This lock is to be used by AutoLock as 1921 * follows: 1922 * <code> 1923 * AutoLock alock (dependentChildrenLock()); 1924 * </code> 1925 */ 1926 AutoLock::Handle &dependentChildrenLock() const { return mMapLock; } 1927 1928 /** 1929 * Returns the read-only list of all dependent children. 1930 * 1931 * @note Access the returned list (iterate, get size etc.) only after doing 1932 * AutoLock alock (dependentChildrenLock())! 1933 */ 1934 const DependentChildren &dependentChildren() const { return mDependentChildren; } 1935 1936 void uninitDependentChildren(); 1937 1938 /** 1939 * Removes (detaches) all dependent children registered with 1940 * #addDependentChild(), without uninitializing them. 1941 * 1942 * @note This method must be called from under the main object's lock. 1943 */ 1944 void removeDependentChildren() 1945 { 1946 /// @todo why?.. 1947 AssertReturnVoid (isLockedOnCurrentThread()); 1948 1949 AutoLock alock (mMapLock); 1950 mDependentChildren.clear(); 1951 } 1724 1952 1725 1953 private: 1726 1954 1727 void lock(); 1728 void unlock(); 1729 bool isLockedOnCurrentThread(); 1730 void setReady (bool isReady); 1731 bool isReady(); 1955 DependentChildren mDependentChildren; 1956 1957 bool mInUninit; 1958 1959 /* Protects the two fields above */ 1960 mutable AutoLock::Handle mMapLock; 1732 1961 }; 1733 1962
Note:
See TracChangeset
for help on using the changeset viewer.