📄 ehm.h
字号:
// The above macros with Asserts when the condition fails
#ifdef DEBUG
#ifdef FAILPOINTS_ENABLED
#define _CHRA_DONTINJECTFAILURE(hResult, hrFail) _CHR_DONTINJECTFAILURE(hResult, hrFail)
#define _CHRAEx0_DONTINJECTFAILURE(hResult, hrFail) _CHREx0_DONTINJECTFAILURE(hResult, hrFail)
#define _CPRA_DONTINJECTFAILURE(hResult, hrFail) _CPR_DONTINJECTFAILURE(hResult, hrFail)
#define _CBRA_DONTINJECTFAILURE(hResult, hrFail) _CBR_DONTINJECTFAILURE(hResult, hrFail)
#define _CWRA_DONTINJECTFAILURE(hResult, hrFail) _CWR_DONTINJECTFAILURE(hResult, hrFail)
#define _CHRAEx0(hResult) _CHREx0(hResult)
#define _CHRA(hResult, hrFail) _CHR(hResult, hrFail)
#define _CPRA(fResult, hrFail) _CPR(fResult, hrFail)
#define _CBRA(fResult, hrFail) _CBR(fResult, hrFail)
#define _CWRA(fResult, hrFail) _CWR(fResult, hrFail)
#else // #ifdef FAILPOINTS_ENABLED
#define _CHRAEx0(hResult) \
do { \
hr = (hResult); \
if(FAILED(hr)) \
{ \
if(_ehmOnAssertionFail(eHRESULT, hr, TEXT(__FILE__), __LINE__, TEXT("CHRA(") TEXT( # hResult ) TEXT(")"))) \
{ \
DebugBreak(); \
} \
goto _ehmErrorLab; \
} \
} \
while (0,0)
#define _CHRA(hResult, hrFail) \
do { \
hr = (hResult); \
if(FAILED(hr)) \
{ \
hr = (hrFail); \
if(_ehmOnAssertionFail(eHRESULT, hr, TEXT(__FILE__), __LINE__, TEXT("CHRA(") TEXT( # hResult ) TEXT(")"))) \
{ \
DebugBreak(); \
} \
goto _ehmErrorLab; \
} \
} \
while (0,0)
#define _CPRA(p, hrFail) \
do { \
if (PF_EXPR(!(p))) \
{ \
hr = (hrFail); \
if(_ehmOnAssertionFail(ePOINTER, 0, TEXT(__FILE__), __LINE__, TEXT("CPRA(") TEXT( # p ) TEXT(")"))) \
{ \
DebugBreak(); \
} \
goto _ehmErrorLab; \
} \
} \
while (0,0)
#define _CBRA(fResult, hrFail) \
do { \
if (PF_EXPR(!(fResult))) \
{ \
hr = (hrFail); \
if(_ehmOnAssertionFail(eBOOL, 0, TEXT(__FILE__), __LINE__, TEXT("CBRA(") TEXT( # fResult ) TEXT(")"))) \
{ \
DebugBreak(); \
} \
goto _ehmErrorLab; \
} \
} \
while (0,0)
#define _CWRA(fResult, hrFail) \
do { \
if (PF_EXPR(!(fResult))) \
{ \
hr = (hrFail); \
if(_ehmOnAssertionFail(eWINDOWS, 0, TEXT(__FILE__), __LINE__, TEXT("CWRA(") TEXT( # fResult ) TEXT(")"))) \
{ \
DebugBreak(); \
} \
goto _ehmErrorLab; \
} \
} \
while (0,0)
#define _CHRA_DONTINJECTFAILURE(hResult, hrFail) _CHRA(Result, hrFail)
#define _CHRAEx0_DONTINJECTFAILURE(hResult, hrFail) _CHRAEx0(hResult, hrFail)
#define _CPRA_DONTINJECTFAILURE(hResult, hrFail) _CPRA(hResult, hrFail)
#define _CBRA_DONTINJECTFAILURE(hResult, hrFail) _CBRA(hResult, hrFail)
#define _CWRA_DONTINJECTFAILURE(hResult, hrFail) _CWRA(hResult, hrFail)
#endif // #ifdef FAILPOINTS_ENABLED
#define VBR(fResult) \
do { \
if (PF_EXPR(!(fResult))) \
{ \
if(_ehmOnAssertionFail(eBOOL, 0, TEXT(__FILE__), __LINE__, TEXT("VBR(") TEXT( # fResult ) TEXT(")"))) \
{ \
DebugBreak(); \
} \
} \
} \
while (0,0)
#define VPR(fResult) \
do { \
if (PF_EXPR(!(fResult))) \
{ \
if(_ehmOnAssertionFail(ePOINTER, 0, TEXT(__FILE__), __LINE__, TEXT("VPR(") TEXT( # fResult ) TEXT(")"))) \
{ \
DebugBreak(); \
} \
} \
} \
while (0,0)
// Verify Windows Result
#define VWR(fResult) \
do { \
if (!(PF_EXPR(NULL != (fResult)))) \
{ \
if(_ehmOnAssertionFail(eWINDOWS, 0, TEXT(__FILE__), __LINE__, TEXT("VWR(") TEXT( # fResult ) TEXT(")"))) \
{ \
DebugBreak(); \
} \
} \
} \
while (0,0)
// Verify HRESULT (careful not to modify hr)
#define VHR(hResult) \
do { \
HRESULT _EHM_hrTmp = (hResult); \
if(FAILED(_EHM_hrTmp)) \
{ \
if(_ehmOnAssertionFail(eHRESULT, _EHM_hrTmp, TEXT(__FILE__), __LINE__, TEXT("VHR(") TEXT( # hResult ) TEXT(")"))) \
{ \
DebugBreak(); \
} \
} \
} \
while (0,0)
// NOTE: because the Dxx macros are intended for DEBUG spew - there is no logging extensibility
// make sure you keep the xTmp, can only eval arg 1x
// todo: dump GetLastError in DWR
#define DWR(fResult) \
do { if (PF_EXPR(!(fResult))) {DEBUGMSG(1, (TEXT("DWR(") TEXT( # fResult ) TEXT(")\r\n") ));}} while (0,0)
#define DHR(hResult) \
do { HRESULT hrTmp = hResult; if(FAILED(hrTmp)) {DEBUGMSG(1, (TEXT("DHR(") TEXT( # hResult ) TEXT(")=0x%x\r\n"), hrTmp));}} while (0,0)
#define DPR DWR // tmp
#define DBR DWR // tmp
#define CHRA(e) _CHRAEx0(e)
#define CPRA(e) _CPRA(e, E_OUTOFMEMORY)
#define CBRA(e) _CBRA(e, E_FAIL)
#define CWRA(e) _CWRA(e, E_FAIL)
#define CHRAEx(e, hrFail) _CHRA(e, hrFail)
#define CPRAEx(e, hrFail) _CPRA(e, hrFail)
#define CBRAEx(e, hrFail) _CBRA(e, hrFail)
#define CWRAEx(e, hrFail) _CWRA(e, hrFail)
#else
#define CHRA CHR
#define CPRA CPR
#define CBRA CBR
#define CWRA CWR
#define CHRAEx CHREx
#define CPRAEx CPREx
#define CBRAEx CBREx
#define CWRAEx CWREx
// Cast to void to eliminate prefast warnings.
#define VHR(x) ((void)(x))
#define VPR(x) ((void)(x))
#define VBR(x) ((void)(x))
#define VWR(x) ((void)(x))
#define DHR(x) (x)
#define DPR(x) (x)
#define DBR(x) (x)
#define DWR(x) (x)
#endif
#define CHR(e) _CHREx0(e)
#define CHR_DONTINJECTFAILURE(e) _CHREx0_DONTINJECTFAILURE(e)
#define CHRA_DONTINJECTFAILURE(e) _CHRAEx0_DONTINJECTFAILURE(e)
#define CPR(e) _CPR(e, E_OUTOFMEMORY)
#define CPR_DONTINJECTFAILURE(e) _CPR_DONTINJECTFAILURE(e, E_OUTOFMEMORY)
#define CPRA_DONTINJECTFAILURE(e) _CPRA_DONTINJECTFAILURE(e, E_OUTOFMEMORY)
#define CBR(e) _CBR(e, E_FAIL)
#define CBR_DONTINJECTFAILURE(e) _CBR_DONTINJECTFAILURE(e, E_FAIL)
#define CBRA_DONTINJECTFAILURE(e) _CBRA_DONTINJECTFAILURE(e, E_FAIL)
#define CWR(e) _CWR(e, E_FAIL)
#define CWR_DONTINJECTFAILURE(e) _CWR_DONTINJECTFAILURE(e, E_FAIL)
#define CWRA_DONTINJECTFAILURE(e) _CWRA_DONTINJECTFAILURE(e, E_FAIL)
#define CHREx(e, hrFail) _CHR(e, hrFail)
#define CPREx(e, hrFail) _CPR(e, hrFail)
#define CBREx(e, hrFail) _CBR(e, hrFail)
#define CWREx(e, hrFail) _CWR(e, hrFail)
#ifdef FAILPOINTS_ENABLED
#define ASSERT_DONTINJECTFAILURE(e)
#else
#define ASSERT_DONTINJECTFAILURE(e) ASSERT(e)
#endif // FAILPOINTS_ENABLED
// obsolete (but still in use)
// - work around various pseudo-pblms:
// partial images, CEPC no-radio, etc.
// - also things that we want to know about in dev, but not in QA/stress:
// an e.g. is our DoVerb stuff, there are 'good' failures (END when no call,
// or TALK w/ 0 entries) and 'bad' failures (e.g. TAPI returns an error), we
// don't want to int3 during stress but we do want to on our dev machines
//
// eventually we'll make these do "if (g_Assert) int3;", then we
// can run w/ g_Assert on for dev and off for stress.
#define xCHRA CHR // should be CHRA but...
#define xCPRA CPR // should be CPRA but...
#define xCBRA CBR // should be CBRA but...
#define xCWRA CWR // should be CWRA but...
#define xVHR DHR // should be VHR but...
#define xVPR DPR // should be VPR but...
#define xVBR DBR // should be VBR but...
#define xVWR DWR // should be VWR but...
#ifdef __cplusplus
}
#endif
#endif // _EHM_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -