Simplify M_ON_EXCEPTION / M_IF_EXCEPTION

This commit is contained in:
Patrick Pelissier committed 2024-04-06 19:13:08 +02:00
1 parent 6cba7ad8ba
commit 12ee3213b0
2 files changed
+16 -8

No files matched your search

+5 -8
View File
@@ -4542,16 +4542,13 @@ m_core_parse2_enum (const char str[], const char **endptr)
// Rest of initialization code
}
}
Do nothing if exceptions are not enabled.
*/
#define M_ON_EXCEPTION(fix) \
for(bool cont = true; cont; cont = false) \
M_DEFER_TRY_INJECT_PRE(cont, fix) \
for( ; cont ; cont = false) \
M_DEFER_TRY_INJECT_POST(cont, fix) \
for( ; cont; cont = false)
#define M_ON_EXCEPTION(...) for(bool cont = true; cont; cont = false) \
/* If exceptions are activated, M_IF_EXCEPTION will expand the code */
#define M_IF_EXCEPTION(fix) (void) 0
/* If exceptions are activated, M_IF_EXCEPTION will expand the code.
Do nothing if exceptions are not enabled. */
#define M_IF_EXCEPTION(...) (void) 0
/* Declare a variable, initialize it, continue if the initialization succeeds,
and clears the variable afterwards.
+11
View File
@@ -156,6 +156,17 @@ struct m_exception_s {
/********************************** INTERNAL *********************************/
/*****************************************************************************/
#undef M_IF_EXCEPTION
#define M_IF_EXCEPTION(...) __VA_ARGS__
#undef M_ON_EXCEPTION
#define M_ON_EXCEPTION(...) \
for(bool cont = true; cont; cont = false) \
M_DEFER_TRY_INJECT_PRE(cont, __VA_ARGS__) \
for( ; cont ; cont = false) \
M_DEFER_TRY_INJECT_POST(cont, __VA_ARGS__) \
for( ; cont; cont = false)
/*
* Define the C++ back-end.
* It is fully different from C back-end as it reuses the classic try of the C++.