зеркало из https://github.com/mozilla/gecko-dev.git
Changed NS_ENSURE to be NS_ENSURE_TRUE. Also changed NS_ENSURE_NOT to be NS_ENSURE_FALSE. Left NS_ENSURE and NS_ENSURE_NOT, but they will soon be going away.
This commit is contained in:
Родитель
849b3d2a71
Коммит
3d60c7ebb0
|
@ -857,49 +857,53 @@ CallQueryInterface( nsISupports* aSource, DestinationType** aDestination )
|
|||
// interface implementation.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NS_ENSURE(x, ret) \
|
||||
#define NS_ENSURE_TRUE(x, ret) \
|
||||
PR_BEGIN_MACRO \
|
||||
if(NS_WARN_IF_FALSE(x, "NS_ENSURE(" #x ") failed")) \
|
||||
if(NS_WARN_IF_FALSE(x, "NS_ENSURE_TRUE(" #x ") failed")) \
|
||||
return ret; \
|
||||
PR_END_MACRO
|
||||
|
||||
#define NS_ENSURE_NOT(x, ret) \
|
||||
NS_ENSURE(!(x), ret)
|
||||
#define NS_ENSURE_FALSE(x, ret) \
|
||||
NS_ENSURE_TRUE(!(x), ret)
|
||||
|
||||
// Only here until I can get rid of all the callsites.
|
||||
#define NS_ENSURE(x, ret) NS_ENSURE_TRUE(x, ret)
|
||||
#define NS_ENSURE_NOT(x, ret) NS_ENSURE_FALSE(x, ret)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Macros for checking results
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NS_ENSURE_SUCCESS(res, ret) \
|
||||
NS_ENSURE(NS_SUCCEEDED(res), ret)
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(res), ret)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Macros for checking state and arguments upon entering interface boundaries
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NS_ENSURE_ARG(arg) \
|
||||
NS_ENSURE(arg, NS_ERROR_INVALID_ARG)
|
||||
NS_ENSURE_TRUE(arg, NS_ERROR_INVALID_ARG)
|
||||
|
||||
#define NS_ENSURE_ARG_POINTER(arg) \
|
||||
NS_ENSURE(arg, NS_ERROR_INVALID_POINTER)
|
||||
NS_ENSURE_TRUE(arg, NS_ERROR_INVALID_POINTER)
|
||||
|
||||
#define NS_ENSURE_ARG_MIN(arg, min) \
|
||||
NS_ENSURE((arg) >= min, NS_ERROR_INVALID_ARG)
|
||||
NS_ENSURE_TRUE((arg) >= min, NS_ERROR_INVALID_ARG)
|
||||
|
||||
#define NS_ENSURE_ARG_MAX(arg, max) \
|
||||
NS_ENSURE((arg) <= min, NS_ERROR_INVALID_ARG)
|
||||
NS_ENSURE_TRUE((arg) <= min, NS_ERROR_INVALID_ARG)
|
||||
|
||||
#define NS_ENSURE_ARG_RANGE(arg, min, max) \
|
||||
NS_ENSURE(((arg) >= min) && ((arg) <= max), NS_ERROR_INVALID_ARG)
|
||||
NS_ENSURE_TRUE(((arg) >= min) && ((arg) <= max), NS_ERROR_INVALID_ARG)
|
||||
|
||||
#define NS_ENSURE_STATE(state) \
|
||||
NS_ENSURE(state, NS_ERROR_UNEXPECTED)
|
||||
NS_ENSURE_TRUE(state, NS_ERROR_UNEXPECTED)
|
||||
|
||||
#define NS_ENSURE_NO_AGGREGATION(outer) \
|
||||
NS_ENSURE_NOT(outer, NS_ERROR_NO_AGGREGATION)
|
||||
NS_ENSURE_FALSE(outer, NS_ERROR_NO_AGGREGATION)
|
||||
|
||||
#define NS_ENSURE_PROPER_AGGREGATION(outer, iid) \
|
||||
NS_ENSURE_NOT(outer && !iid.Equals(NS_GET_IID(nsISupports)), NS_ERROR_INVALID_ARG)
|
||||
NS_ENSURE_FALSE(outer && !iid.Equals(NS_GET_IID(nsISupports)), NS_ERROR_INVALID_ARG)
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -857,49 +857,53 @@ CallQueryInterface( nsISupports* aSource, DestinationType** aDestination )
|
|||
// interface implementation.
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NS_ENSURE(x, ret) \
|
||||
#define NS_ENSURE_TRUE(x, ret) \
|
||||
PR_BEGIN_MACRO \
|
||||
if(NS_WARN_IF_FALSE(x, "NS_ENSURE(" #x ") failed")) \
|
||||
if(NS_WARN_IF_FALSE(x, "NS_ENSURE_TRUE(" #x ") failed")) \
|
||||
return ret; \
|
||||
PR_END_MACRO
|
||||
|
||||
#define NS_ENSURE_NOT(x, ret) \
|
||||
NS_ENSURE(!(x), ret)
|
||||
#define NS_ENSURE_FALSE(x, ret) \
|
||||
NS_ENSURE_TRUE(!(x), ret)
|
||||
|
||||
// Only here until I can get rid of all the callsites.
|
||||
#define NS_ENSURE(x, ret) NS_ENSURE_TRUE(x, ret)
|
||||
#define NS_ENSURE_NOT(x, ret) NS_ENSURE_FALSE(x, ret)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Macros for checking results
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NS_ENSURE_SUCCESS(res, ret) \
|
||||
NS_ENSURE(NS_SUCCEEDED(res), ret)
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(res), ret)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Macros for checking state and arguments upon entering interface boundaries
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define NS_ENSURE_ARG(arg) \
|
||||
NS_ENSURE(arg, NS_ERROR_INVALID_ARG)
|
||||
NS_ENSURE_TRUE(arg, NS_ERROR_INVALID_ARG)
|
||||
|
||||
#define NS_ENSURE_ARG_POINTER(arg) \
|
||||
NS_ENSURE(arg, NS_ERROR_INVALID_POINTER)
|
||||
NS_ENSURE_TRUE(arg, NS_ERROR_INVALID_POINTER)
|
||||
|
||||
#define NS_ENSURE_ARG_MIN(arg, min) \
|
||||
NS_ENSURE((arg) >= min, NS_ERROR_INVALID_ARG)
|
||||
NS_ENSURE_TRUE((arg) >= min, NS_ERROR_INVALID_ARG)
|
||||
|
||||
#define NS_ENSURE_ARG_MAX(arg, max) \
|
||||
NS_ENSURE((arg) <= min, NS_ERROR_INVALID_ARG)
|
||||
NS_ENSURE_TRUE((arg) <= min, NS_ERROR_INVALID_ARG)
|
||||
|
||||
#define NS_ENSURE_ARG_RANGE(arg, min, max) \
|
||||
NS_ENSURE(((arg) >= min) && ((arg) <= max), NS_ERROR_INVALID_ARG)
|
||||
NS_ENSURE_TRUE(((arg) >= min) && ((arg) <= max), NS_ERROR_INVALID_ARG)
|
||||
|
||||
#define NS_ENSURE_STATE(state) \
|
||||
NS_ENSURE(state, NS_ERROR_UNEXPECTED)
|
||||
NS_ENSURE_TRUE(state, NS_ERROR_UNEXPECTED)
|
||||
|
||||
#define NS_ENSURE_NO_AGGREGATION(outer) \
|
||||
NS_ENSURE_NOT(outer, NS_ERROR_NO_AGGREGATION)
|
||||
NS_ENSURE_FALSE(outer, NS_ERROR_NO_AGGREGATION)
|
||||
|
||||
#define NS_ENSURE_PROPER_AGGREGATION(outer, iid) \
|
||||
NS_ENSURE_NOT(outer && !iid.Equals(NS_GET_IID(nsISupports)), NS_ERROR_INVALID_ARG)
|
||||
NS_ENSURE_FALSE(outer && !iid.Equals(NS_GET_IID(nsISupports)), NS_ERROR_INVALID_ARG)
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Загрузка…
Ссылка в новой задаче