|
|
|
@ -332,7 +332,7 @@ do { \
|
|
|
|
|
} while (0) \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define RETQUIRE_REPORT(targ,file,line) HXAssertFailedLine(targ,file,line)
|
|
|
|
|
#define REQUIRE_REPORT(targ,file,line) HXAssertFailedLine(targ,file,line)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -525,7 +525,7 @@ int safe_int_func_call(LONG32 f);
|
|
|
|
|
#define HX_ASSERT_VALID_READ_PTR(pOb) ((void)0)
|
|
|
|
|
#define HXOutputDebugString(f) ((void)0)
|
|
|
|
|
|
|
|
|
|
#define RETQUIRE_REPORT(targ,file,line) ((int)0)
|
|
|
|
|
#define REQUIRE_REPORT(targ,file,line) ((int)0)
|
|
|
|
|
|
|
|
|
|
#if defined (_MACINTOSH)
|
|
|
|
|
// this is the proper release version of HX_VERIFY that preserves the syntactic
|
|
|
|
@ -574,104 +574,104 @@ class LogInfo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// CHECK/RETQUIRE MACROS
|
|
|
|
|
// CHECK/REQUIRE MACROS
|
|
|
|
|
//
|
|
|
|
|
// These macros are always valid (debug and release builds)
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// RETQUIRE and RETQUIRE_ACTION _always_ emit code for the goto if the statement is false
|
|
|
|
|
// REQUIRE and REQUIRE_ACTION _always_ emit code for the goto if the statement is false
|
|
|
|
|
//
|
|
|
|
|
// RETQUIRE_REPORT only generates code in Debug builds
|
|
|
|
|
// REQUIRE_REPORT only generates code in Debug builds
|
|
|
|
|
//
|
|
|
|
|
// The do {} while (0) construct ensures this is legal wherever a statement is legal
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#define CHECK(stmt) HX_ASSERT(stmt)
|
|
|
|
|
|
|
|
|
|
#define RETQUIRE_VOID_RETURN(stmt) \
|
|
|
|
|
do { if ((stmt) == 0) { if (RETQUIRE_REPORT(#stmt,__FILE__,__LINE__)) HXDebugBreak(); return; } } while (0)
|
|
|
|
|
#define RETQUIRE_RETURN(stmt,returned) \
|
|
|
|
|
do { if ((stmt) == 0) { if (RETQUIRE_REPORT(#stmt,__FILE__,__LINE__)) HXDebugBreak(); return (returned); } } while (0)
|
|
|
|
|
#define RETQUIRE_VOID_RETURN_TQUIET(stmt) \
|
|
|
|
|
#define REQUIRE_VOID_RETURN(stmt) \
|
|
|
|
|
do { if ((stmt) == 0) { if (REQUIRE_REPORT(#stmt,__FILE__,__LINE__)) HXDebugBreak(); return; } } while (0)
|
|
|
|
|
#define REQUIRE_RETURN(stmt,returned) \
|
|
|
|
|
do { if ((stmt) == 0) { if (REQUIRE_REPORT(#stmt,__FILE__,__LINE__)) HXDebugBreak(); return (returned); } } while (0)
|
|
|
|
|
#define REQUIRE_VOID_RETURN_QUIET(stmt) \
|
|
|
|
|
do { if ((stmt) == 0) { return; } } while (0)
|
|
|
|
|
#define RETQUIRE_RETURN_TQUIET(stmt,returned) \
|
|
|
|
|
#define REQUIRE_RETURN_QUIET(stmt,returned) \
|
|
|
|
|
do { if ((stmt) == 0) { return (returned); } } while (0)
|
|
|
|
|
#define RETQUIRE(stmt,target) \
|
|
|
|
|
do { if ((stmt) == 0) { RETQUIRE_REPORT(#target,__FILE__,__LINE__); goto target; } } while (0)
|
|
|
|
|
#define RETQUIRE_ACTION(stmt,target,action) \
|
|
|
|
|
do { if ((stmt) == 0) { RETQUIRE_REPORT(#target,__FILE__,__LINE__); {{action;} goto target;} } } while (0)
|
|
|
|
|
#define RETQUIRE_TQUIET(stmt,target) \
|
|
|
|
|
#define REQUIRE(stmt,target) \
|
|
|
|
|
do { if ((stmt) == 0) { REQUIRE_REPORT(#target,__FILE__,__LINE__); goto target; } } while (0)
|
|
|
|
|
#define REQUIRE_ACTION(stmt,target,action) \
|
|
|
|
|
do { if ((stmt) == 0) { REQUIRE_REPORT(#target,__FILE__,__LINE__); {{action;} goto target;} } } while (0)
|
|
|
|
|
#define REQUIRE_QUIET(stmt,target) \
|
|
|
|
|
do { if ((stmt) == 0) goto target; } while (0)
|
|
|
|
|
#define RETQUIRE_ACTION_TQUIET(stmt,target,action) \
|
|
|
|
|
#define REQUIRE_ACTION_QUIET(stmt,target,action) \
|
|
|
|
|
do { if ((stmt) == 0) {{action;} goto target;} } while (0)
|
|
|
|
|
#define PRE_RETQUIRE_RETURN(stmt,returned) \
|
|
|
|
|
RETQUIRE_RETURN(stmt,returned)
|
|
|
|
|
#define PRE_RETQUIRE_VOID_RETURN(stmt) \
|
|
|
|
|
RETQUIRE_VOID_RETURN(stmt)
|
|
|
|
|
#define POST_RETQUIRE_RETURN(stmt,returned) \
|
|
|
|
|
RETQUIRE_RETURN(stmt,returned)
|
|
|
|
|
#define POST_RETQUIRE_VOID_RETURN(stmt) \
|
|
|
|
|
RETQUIRE_VOID_RETURN(stmt)
|
|
|
|
|
|
|
|
|
|
#define RETQUIRE_SUCCESS_RETURN_TQUIET(expr) \
|
|
|
|
|
#define PRE_REQUIRE_RETURN(stmt,returned) \
|
|
|
|
|
REQUIRE_RETURN(stmt,returned)
|
|
|
|
|
#define PRE_REQUIRE_VOID_RETURN(stmt) \
|
|
|
|
|
REQUIRE_VOID_RETURN(stmt)
|
|
|
|
|
#define POST_REQUIRE_RETURN(stmt,returned) \
|
|
|
|
|
REQUIRE_RETURN(stmt,returned)
|
|
|
|
|
#define POST_REQUIRE_VOID_RETURN(stmt) \
|
|
|
|
|
REQUIRE_VOID_RETURN(stmt)
|
|
|
|
|
|
|
|
|
|
#define REQUIRE_SUCCESS_RETURN_QUIET(expr) \
|
|
|
|
|
do { register HX_RESULT const res = expr; if (FAILED (res)) return res; } while (0)
|
|
|
|
|
#define RETQUIRE_SUCCESS_RETURN(expr) \
|
|
|
|
|
do { register HX_RESULT const res = expr; if (FAILED (res)) { RETQUIRE_REPORT("False condition, Aborting...",__FILE__,__LINE__); return res; } } while (0)
|
|
|
|
|
#define REQUIRE_SUCCESS_RETURN(expr) \
|
|
|
|
|
do { register HX_RESULT const res = expr; if (FAILED (res)) { REQUIRE_REPORT("False condition, Aborting...",__FILE__,__LINE__); return res; } } while (0)
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// RETQUIRE_SUCCESS reports the error if an expected result failed
|
|
|
|
|
// REQUIRE_SUCCESS reports the error if an expected result failed
|
|
|
|
|
// Ideally, this should report the status value as well
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#define CHECK_SUCCESS(stat) HX_ASSERT(((unsigned long)(stat)>>31) == 0)
|
|
|
|
|
|
|
|
|
|
#define RETQUIRE_SUCCESS(stat,target) \
|
|
|
|
|
do { if (((unsigned long)(stat)>>31) != 0) { RETQUIRE_REPORT(#target,__FILE__,__LINE__); goto target; } } while (0)
|
|
|
|
|
#define RETQUIRE_SUCCESS_ACTION(stat,target,action) \
|
|
|
|
|
do { if (((unsigned long)(stat)>>31) != 0) { RETQUIRE_REPORT(#target,__FILE__,__LINE__); {{action;} goto target;} } } while (0)
|
|
|
|
|
#define RETQUIRE_SUCCESS_TQUIET(stat,target) \
|
|
|
|
|
#define REQUIRE_SUCCESS(stat,target) \
|
|
|
|
|
do { if (((unsigned long)(stat)>>31) != 0) { REQUIRE_REPORT(#target,__FILE__,__LINE__); goto target; } } while (0)
|
|
|
|
|
#define REQUIRE_SUCCESS_ACTION(stat,target,action) \
|
|
|
|
|
do { if (((unsigned long)(stat)>>31) != 0) { REQUIRE_REPORT(#target,__FILE__,__LINE__); {{action;} goto target;} } } while (0)
|
|
|
|
|
#define REQUIRE_SUCCESS_QUIET(stat,target) \
|
|
|
|
|
do { if (((unsigned long)(stat)>>31) != 0) goto target; } while (0)
|
|
|
|
|
#define RETQUIRE_SUCCESS_ACTION_TQUIET(stat,target,action) \
|
|
|
|
|
#define REQUIRE_SUCCESS_ACTION_QUIET(stat,target,action) \
|
|
|
|
|
do { if (((unsigned long)(stat)>>31) != 0) {{action;} goto target;} } while (0)
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// RETQUIRE_NOERR reports the error if the error value is non-zero
|
|
|
|
|
// REQUIRE_NOERR reports the error if the error value is non-zero
|
|
|
|
|
// Ideally, this should report the error value as well
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#define CHECK_NOERR(err) HX_ASSERT((err) == 0)
|
|
|
|
|
|
|
|
|
|
#define RETQUIRE_NOERR_RETURN(err,returned) \
|
|
|
|
|
do { if ((err) != 0) { RETQUIRE_REPORT("Toolbox error, Aborting...",__FILE__,__LINE__); return (returned); } } while (0)
|
|
|
|
|
#define RETQUIRE_NOERR(err,target) \
|
|
|
|
|
do { if ((err) != 0) { RETQUIRE_REPORT(#target,__FILE__,__LINE__); goto target; } } while (0)
|
|
|
|
|
#define RETQUIRE_NOERR_ACTION(err,target,action) \
|
|
|
|
|
do { if ((err) != 0) { RETQUIRE_REPORT(#target,__FILE__,__LINE__); {{action;} goto target;} } } while (0)
|
|
|
|
|
#define RETQUIRE_NOERR_TQUIET(err,target) \
|
|
|
|
|
#define REQUIRE_NOERR_RETURN(err,returned) \
|
|
|
|
|
do { if ((err) != 0) { REQUIRE_REPORT("Toolbox error, Aborting...",__FILE__,__LINE__); return (returned); } } while (0)
|
|
|
|
|
#define REQUIRE_NOERR(err,target) \
|
|
|
|
|
do { if ((err) != 0) { REQUIRE_REPORT(#target,__FILE__,__LINE__); goto target; } } while (0)
|
|
|
|
|
#define REQUIRE_NOERR_ACTION(err,target,action) \
|
|
|
|
|
do { if ((err) != 0) { REQUIRE_REPORT(#target,__FILE__,__LINE__); {{action;} goto target;} } } while (0)
|
|
|
|
|
#define REQUIRE_NOERR_QUIET(err,target) \
|
|
|
|
|
do { if ((err) != 0) goto target; } while (0)
|
|
|
|
|
#define RETQUIRE_NOERR_ACTION_TQUIET(err,target,action) \
|
|
|
|
|
#define REQUIRE_NOERR_ACTION_QUIET(err,target,action) \
|
|
|
|
|
do { if ((err) != 0) {{action;} goto target;} } while (0)
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// RETQUIRE_NONNULL reports the error if the ptr value is null
|
|
|
|
|
// REQUIRE_NONNULL reports the error if the ptr value is null
|
|
|
|
|
// Ideally, this should report the error value as well
|
|
|
|
|
//
|
|
|
|
|
#define CHECK_NONNULL(ptr) HX_ASSERT((ptr) != 0L)
|
|
|
|
|
#define CHECK_NULL(ptr) HX_ASSERT((ptr) == 0L)
|
|
|
|
|
|
|
|
|
|
#define RETQUIRE_NONNULL_VOID_RETURN(ptr) \
|
|
|
|
|
do { if ((ptr) == 0L) { RETQUIRE_REPORT(#ptr" is nil, Aborting...",__FILE__,__LINE__); return; } } while (0)
|
|
|
|
|
#define RETQUIRE_NONNULL_RETURN(ptr,returned) \
|
|
|
|
|
do { if ((ptr) == 0L) { RETQUIRE_REPORT(#ptr" is nil, Aborting...",__FILE__,__LINE__); return (returned); } } while (0)
|
|
|
|
|
#define RETQUIRE_NONNULL(ptr,target) \
|
|
|
|
|
do { if ((ptr) == 0L) { RETQUIRE_REPORT(#target,__FILE__,__LINE__); goto target; } } while (0)
|
|
|
|
|
#define RETQUIRE_NONNULL_ACTION(ptr,target,action) \
|
|
|
|
|
do { if ((ptr) == 0L) { RETQUIRE_REPORT(#target,__FILE__,__LINE__); {{action;} goto target;} } } while (0)
|
|
|
|
|
#define RETQUIRE_NONNULL_TQUIET(ptr,target) \
|
|
|
|
|
#define REQUIRE_NONNULL_VOID_RETURN(ptr) \
|
|
|
|
|
do { if ((ptr) == 0L) { REQUIRE_REPORT(#ptr" is nil, Aborting...",__FILE__,__LINE__); return; } } while (0)
|
|
|
|
|
#define REQUIRE_NONNULL_RETURN(ptr,returned) \
|
|
|
|
|
do { if ((ptr) == 0L) { REQUIRE_REPORT(#ptr" is nil, Aborting...",__FILE__,__LINE__); return (returned); } } while (0)
|
|
|
|
|
#define REQUIRE_NONNULL(ptr,target) \
|
|
|
|
|
do { if ((ptr) == 0L) { REQUIRE_REPORT(#target,__FILE__,__LINE__); goto target; } } while (0)
|
|
|
|
|
#define REQUIRE_NONNULL_ACTION(ptr,target,action) \
|
|
|
|
|
do { if ((ptr) == 0L) { REQUIRE_REPORT(#target,__FILE__,__LINE__); {{action;} goto target;} } } while (0)
|
|
|
|
|
#define REQUIRE_NONNULL_QUIET(ptr,target) \
|
|
|
|
|
do { if ((ptr) == 0L) goto target; } while (0)
|
|
|
|
|
#define RETQUIRE_NONNULL_ACTION_TQUIET(ptr,target,action) \
|
|
|
|
|
#define REQUIRE_NONNULL_ACTION_QUIET(ptr,target,action) \
|
|
|
|
|
do { if ((ptr) == 0L) {{action;} goto target;} } while (0)
|
|
|
|
|
// lower case versions make source code more readable
|
|
|
|
|
|
|
|
|
@ -690,38 +690,38 @@ class LogInfo
|
|
|
|
|
|
|
|
|
|
#define check(stmt) CHECK(stmt)
|
|
|
|
|
|
|
|
|
|
#define require_void_return(stmt) RETQUIRE_VOID_RETURN(stmt)
|
|
|
|
|
#define require_return_void(stmt) RETQUIRE_VOID_RETURN(stmt)
|
|
|
|
|
#define require_return(stmt,returned) RETQUIRE_RETURN(stmt,returned)
|
|
|
|
|
#define require(stmt,target) RETQUIRE(stmt,target)
|
|
|
|
|
#define require_action(stmt,target,action) RETQUIRE_ACTION(stmt,target,action)
|
|
|
|
|
#define require_quiet(stmt,target) RETQUIRE_TQUIET(stmt,target)
|
|
|
|
|
#define require_action_quiet(stmt,target,action) RETQUIRE_ACTION_TQUIET(stmt,target,action)
|
|
|
|
|
#define require_void_return(stmt) REQUIRE_VOID_RETURN(stmt)
|
|
|
|
|
#define require_return_void(stmt) REQUIRE_VOID_RETURN(stmt)
|
|
|
|
|
#define require_return(stmt,returned) REQUIRE_RETURN(stmt,returned)
|
|
|
|
|
#define require(stmt,target) REQUIRE(stmt,target)
|
|
|
|
|
#define require_action(stmt,target,action) REQUIRE_ACTION(stmt,target,action)
|
|
|
|
|
#define require_quiet(stmt,target) REQUIRE_QUIET(stmt,target)
|
|
|
|
|
#define require_action_quiet(stmt,target,action) REQUIRE_ACTION_QUIET(stmt,target,action)
|
|
|
|
|
|
|
|
|
|
#define check_success(stat) CHECK_SUCCESS(stat)
|
|
|
|
|
|
|
|
|
|
#define require_success(stat,target) RETQUIRE_SUCCESS(stat,target)
|
|
|
|
|
#define require_success_action(stat,target,action) RETQUIRE_SUCCESS_ACTION(stat,target,action)
|
|
|
|
|
#define require_success_quiet(stat,target) RETQUIRE_SUCCESS_TQUIET(stat,target)
|
|
|
|
|
#define require_success_action_quiet(stat,target,action) RETQUIRE_SUCCESS_ACTION_TQUIET(stat,target,action)
|
|
|
|
|
#define require_success(stat,target) REQUIRE_SUCCESS(stat,target)
|
|
|
|
|
#define require_success_action(stat,target,action) REQUIRE_SUCCESS_ACTION(stat,target,action)
|
|
|
|
|
#define require_success_quiet(stat,target) REQUIRE_SUCCESS_QUIET(stat,target)
|
|
|
|
|
#define require_success_action_quiet(stat,target,action) REQUIRE_SUCCESS_ACTION_QUIET(stat,target,action)
|
|
|
|
|
|
|
|
|
|
#define check_noerr(err) CHECK_NOERR(err)
|
|
|
|
|
|
|
|
|
|
#define require_noerr_return(err,returned) RETQUIRE_NOERR_RETURN(err,returned)
|
|
|
|
|
#define require_noerr(err,target) RETQUIRE_NOERR(err,target)
|
|
|
|
|
#define require_noerr_action(err,target,action) RETQUIRE_NOERR_ACTION(err,target,action)
|
|
|
|
|
#define require_noerr_quiet(err,target) RETQUIRE_NOERR_TQUIET(err,target)
|
|
|
|
|
#define require_noerr_action_quiet(err,target,action) RETQUIRE_NOERR_ACTION_TQUIET(err,target,action)
|
|
|
|
|
#define require_noerr_return(err,returned) REQUIRE_NOERR_RETURN(err,returned)
|
|
|
|
|
#define require_noerr(err,target) REQUIRE_NOERR(err,target)
|
|
|
|
|
#define require_noerr_action(err,target,action) REQUIRE_NOERR_ACTION(err,target,action)
|
|
|
|
|
#define require_noerr_quiet(err,target) REQUIRE_NOERR_QUIET(err,target)
|
|
|
|
|
#define require_noerr_action_quiet(err,target,action) REQUIRE_NOERR_ACTION_QUIET(err,target,action)
|
|
|
|
|
|
|
|
|
|
#define check_nonnull(ptr) CHECK_NONNULL(ptr)
|
|
|
|
|
#define check_null(ptr) CHECK_NULL(ptr)
|
|
|
|
|
|
|
|
|
|
#define require_nonnull_void_return(ptr) RETQUIRE_NONNULL_VOID_RETURN(ptr)
|
|
|
|
|
#define require_nonnull_return(ptr,returned) RETQUIRE_NONNULL_RETURN(ptr,returned)
|
|
|
|
|
#define require_nonnull(ptr,target) RETQUIRE_NONNULL(ptr,target)
|
|
|
|
|
#define require_nonnull_action(ptr,target,action) RETQUIRE_NONNULL_ACTION(ptr,target,action)
|
|
|
|
|
#define require_nonnull_quiet(ptr,target) RETQUIRE_NONNULL_TQUIET(ptr,target)
|
|
|
|
|
#define require_nonnull_action_quiet(ptr,target,action) RETQUIRE_NONNULL_ACTION_TQUIET(ptr,target,action)
|
|
|
|
|
#define require_nonnull_void_return(ptr) REQUIRE_NONNULL_VOID_RETURN(ptr)
|
|
|
|
|
#define require_nonnull_return(ptr,returned) REQUIRE_NONNULL_RETURN(ptr,returned)
|
|
|
|
|
#define require_nonnull(ptr,target) REQUIRE_NONNULL(ptr,target)
|
|
|
|
|
#define require_nonnull_action(ptr,target,action) REQUIRE_NONNULL_ACTION(ptr,target,action)
|
|
|
|
|
#define require_nonnull_quiet(ptr,target) REQUIRE_NONNULL_QUIET(ptr,target)
|
|
|
|
|
#define require_nonnull_action_quiet(ptr,target,action) REQUIRE_NONNULL_ACTION_QUIET(ptr,target,action)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // !_HXASSERT_H_
|
|
|
|
|