VirtualBox

source: vbox/trunk/include/VBox/com/assert.h@ 58099

最後變更 在這個檔案從58099是 58099,由 vboxsync 提交於 9 年 前

com/assert.h: Cleanup fixes.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 3.8 KB
 
1/** @file
2 * MS COM / XPCOM Abstraction Layer - Assertion macros for COM/XPCOM.
3 */
4
5/*
6 * Copyright (C) 2006-2015 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.alldomusa.eu.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___VBox_com_assert_h
27#define ___VBox_com_assert_h
28
29#include <iprt/assert.h>
30
31/**
32 * Asserts that the COM result code is succeeded in strict builds.
33 * In non-strict builds the result code will be NOREF'ed to kill compiler warnings.
34 *
35 * @param hrc The COM result code
36 */
37#define AssertComRC(hrc) \
38 do { AssertMsg(SUCCEEDED(hrc), ("COM RC = %Rhrc (0x%08X)\n", hrc, hrc)); NOREF(hrc); } while (0)
39
40/**
41 * Same as AssertComRC, except the caller already knows we failed.
42 *
43 * @param hrc The COM result code
44 */
45#define AssertComRCFailed(hrc) \
46 do { AssertMsgFailed(("COM RC = %Rhrc (0x%08X)\n", hrc, hrc)); NOREF(hrc); } while (0)
47
48/**
49 * A special version of AssertComRC that returns the given expression
50 * if the result code is failed.
51 *
52 * @param hrc The COM result code
53 * @param RetExpr The expression to return
54 */
55#define AssertComRCReturn(hrc, RetExpr) \
56 AssertMsgReturn(SUCCEEDED(hrc), ("COM RC = %Rhrc (0x%08X)\n", hrc, hrc), RetExpr)
57
58/**
59 * A special version of AssertComRC that returns the given result code
60 * if it is failed.
61 *
62 * @param hrc The COM result code
63 */
64#define AssertComRCReturnRC(hrc) \
65 AssertMsgReturn(SUCCEEDED(hrc), ("COM RC = %Rhrc (0x%08X)\n", hrc, hrc), hrc)
66
67/**
68 * A special version of AssertComRC that returns if the result code is failed.
69 *
70 * @param hrc The COM result code
71 */
72#define AssertComRCReturnVoid(hrc) \
73 AssertMsgReturnVoid(SUCCEEDED(hrc), ("COM RC = %Rhrc (0x%08X)\n", hrc, hrc))
74
75/**
76 * A special version of AssertComRC that evaluates the given expression and
77 * breaks if the result code is failed.
78 *
79 * @param hrc The COM result code
80 * @param PreBreakExpr The expression to evaluate on failure.
81 */
82#define AssertComRCBreak(hrc, PreBreakExpr) \
83 if (!SUCCEEDED(hrc)) { AssertComRCFailed(hrc); PreBreakExpr; break; } else do {} while (0)
84
85/**
86 * A special version of AssertComRC that evaluates the given expression and
87 * throws it if the result code is failed.
88 *
89 * @param hrc The COM result code
90 * @param ThrowMeExpr The expression which result to be thrown on failure.
91 */
92#define AssertComRCThrow(hrc, ThrowMeExpr) \
93 do { if (SUCCEEDED(hrc)) { /*likely*/} else { AssertComRCFailed(hrc); throw (ThrowMeExpr); } } while (0)
94
95/**
96 * A special version of AssertComRC that just breaks if the result code is
97 * failed.
98 *
99 * @param hrc The COM result code
100 */
101#define AssertComRCBreakRC(hrc) \
102 if (!SUCCEEDED(hrc)) { AssertComRCFailed(hrc); break; } else do {} while (0)
103
104/**
105 * A special version of AssertComRC that just throws @a hrc if the result code
106 * is failed.
107 *
108 * @param hrc The COM result code
109 */
110#define AssertComRCThrowRC(hrc) \
111 do { if (SUCCEEDED(hrc)) { /*likely*/ } else { AssertComRCFailed(hrc); throw hrc; } } while (0)
112
113#endif // !___VBox_com_assert_h
114
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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