Prefix status macro implementation with MP_.
This makes it less likely for the implementation to conflict with other ASSIGN_OR_RETURN() and RETURN_IF_ERROR() implementations. PiperOrigin-RevId: 570726994
This commit is contained in:
parent
9bb042cc86
commit
7f1c17065a
|
@ -82,7 +82,7 @@
|
||||||
// return absl::OkStatus();
|
// return absl::OkStatus();
|
||||||
// }
|
// }
|
||||||
#define MP_RETURN_IF_ERROR(expr) \
|
#define MP_RETURN_IF_ERROR(expr) \
|
||||||
STATUS_MACROS_IMPL_ELSE_BLOCKER_ \
|
MP_STATUS_MACROS_IMPL_ELSE_BLOCKER_ \
|
||||||
if (mediapipe::status_macro_internal::StatusAdaptorForMacros \
|
if (mediapipe::status_macro_internal::StatusAdaptorForMacros \
|
||||||
status_macro_internal_adaptor = {(expr), MEDIAPIPE_LOC}) { \
|
status_macro_internal_adaptor = {(expr), MEDIAPIPE_LOC}) { \
|
||||||
} else /* NOLINT */ \
|
} else /* NOLINT */ \
|
||||||
|
@ -135,9 +135,9 @@
|
||||||
// ASSIGN_OR_RETURN(ValueType value, MaybeGetValue(query), _.LogError());
|
// ASSIGN_OR_RETURN(ValueType value, MaybeGetValue(query), _.LogError());
|
||||||
//
|
//
|
||||||
#define ASSIGN_OR_RETURN(...) \
|
#define ASSIGN_OR_RETURN(...) \
|
||||||
STATUS_MACROS_IMPL_GET_VARIADIC_((__VA_ARGS__, \
|
MP_STATUS_MACROS_IMPL_GET_VARIADIC_( \
|
||||||
STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_3_, \
|
(__VA_ARGS__, MP_STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_3_, \
|
||||||
STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_2_)) \
|
MP_STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_2_)) \
|
||||||
(__VA_ARGS__)
|
(__VA_ARGS__)
|
||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
@ -146,27 +146,28 @@
|
||||||
|
|
||||||
// MSVC incorrectly expands variadic macros, splice together a macro call to
|
// MSVC incorrectly expands variadic macros, splice together a macro call to
|
||||||
// work around the bug.
|
// work around the bug.
|
||||||
#define STATUS_MACROS_IMPL_GET_VARIADIC_HELPER_(_1, _2, _3, NAME, ...) NAME
|
#define MP_STATUS_MACROS_IMPL_GET_VARIADIC_HELPER_(_1, _2, _3, NAME, ...) NAME
|
||||||
#define STATUS_MACROS_IMPL_GET_VARIADIC_(args) \
|
#define MP_STATUS_MACROS_IMPL_GET_VARIADIC_(args) \
|
||||||
STATUS_MACROS_IMPL_GET_VARIADIC_HELPER_ args
|
MP_STATUS_MACROS_IMPL_GET_VARIADIC_HELPER_ args
|
||||||
|
|
||||||
#define STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_2_(lhs, rexpr) \
|
#define MP_STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_2_(lhs, rexpr) \
|
||||||
STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_( \
|
MP_STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_( \
|
||||||
STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __LINE__), lhs, rexpr, \
|
MP_STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __LINE__), lhs, rexpr, \
|
||||||
return mediapipe::StatusBuilder( \
|
return mediapipe::StatusBuilder( \
|
||||||
std::move(STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __LINE__)) \
|
std::move(MP_STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __LINE__)) \
|
||||||
.status(), \
|
.status(), \
|
||||||
MEDIAPIPE_LOC))
|
MEDIAPIPE_LOC))
|
||||||
#define STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_3_(lhs, rexpr, error_expression) \
|
#define MP_STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_3_(lhs, rexpr, \
|
||||||
STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_( \
|
error_expression) \
|
||||||
STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __LINE__), lhs, rexpr, \
|
MP_STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_( \
|
||||||
|
MP_STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __LINE__), lhs, rexpr, \
|
||||||
mediapipe::StatusBuilder _( \
|
mediapipe::StatusBuilder _( \
|
||||||
std::move(STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __LINE__)) \
|
std::move(MP_STATUS_MACROS_IMPL_CONCAT_(_status_or_value, __LINE__)) \
|
||||||
.status(), \
|
.status(), \
|
||||||
MEDIAPIPE_LOC); \
|
MEDIAPIPE_LOC); \
|
||||||
(void)_; /* error_expression is allowed to not use this variable */ \
|
(void)_; /* error_expression is allowed to not use this variable */ \
|
||||||
return (error_expression))
|
return (error_expression))
|
||||||
#define STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_(statusor, lhs, rexpr, \
|
#define MP_STATUS_MACROS_IMPL_ASSIGN_OR_RETURN_(statusor, lhs, rexpr, \
|
||||||
error_expression) \
|
error_expression) \
|
||||||
auto statusor = (rexpr); \
|
auto statusor = (rexpr); \
|
||||||
if (ABSL_PREDICT_FALSE(!statusor.ok())) { \
|
if (ABSL_PREDICT_FALSE(!statusor.ok())) { \
|
||||||
|
@ -175,8 +176,9 @@
|
||||||
lhs = std::move(statusor).value()
|
lhs = std::move(statusor).value()
|
||||||
|
|
||||||
// Internal helper for concatenating macro values.
|
// Internal helper for concatenating macro values.
|
||||||
#define STATUS_MACROS_IMPL_CONCAT_INNER_(x, y) x##y
|
#define MP_STATUS_MACROS_IMPL_CONCAT_INNER_(x, y) x##y
|
||||||
#define STATUS_MACROS_IMPL_CONCAT_(x, y) STATUS_MACROS_IMPL_CONCAT_INNER_(x, y)
|
#define MP_STATUS_MACROS_IMPL_CONCAT_(x, y) \
|
||||||
|
MP_STATUS_MACROS_IMPL_CONCAT_INNER_(x, y)
|
||||||
|
|
||||||
// The GNU compiler emits a warning for code like:
|
// The GNU compiler emits a warning for code like:
|
||||||
//
|
//
|
||||||
|
@ -189,7 +191,7 @@
|
||||||
// if (do_expr) MP_RETURN_IF_ERROR(expr) << "Some message";
|
// if (do_expr) MP_RETURN_IF_ERROR(expr) << "Some message";
|
||||||
//
|
//
|
||||||
// The "switch (0) case 0:" idiom is used to suppress this.
|
// The "switch (0) case 0:" idiom is used to suppress this.
|
||||||
#define STATUS_MACROS_IMPL_ELSE_BLOCKER_ \
|
#define MP_STATUS_MACROS_IMPL_ELSE_BLOCKER_ \
|
||||||
switch (0) \
|
switch (0) \
|
||||||
case 0: \
|
case 0: \
|
||||||
default: // NOLINT
|
default: // NOLINT
|
||||||
|
|
Loading…
Reference in New Issue
Block a user