Rename fields of m_exception_t:

data->context
n->num
This commit is contained in:
Patrick Pelissier committed 2023-03-18 18:11:23 +01:00
1 parent 030bea9c11
commit 9f8b97ae46
3 files changed
+21 -21

No files matched your search

+2 -2
View File
@@ -7813,8 +7813,8 @@ This is the exception type. It is composed of the following fields:
* error\_code: The error code. It is used to identify the error that are raised the exception.
* line: The line number where the error was detected.
* filename: The filename (CSTR) where the error was detected.
* n: Number of entries in 'data' table
* data: an array of M\_USE\_MAX\_EXCEPTION elements.
* num: Number of entries in 'context' table
* context: an array of M\_USE\_MAX\_CONTEXT elements.
You can access the fields of the type directly.
+6 -6
View File
@@ -81,7 +81,7 @@
M_STATIC_ASSERT(M_RET_ARG1 (__VA_ARGS__) != 0, \
M_LIB_NOT_A_CONSTANT_NON_NULL_INTEGER, \
"The error code shall be a non null constant"); \
M_STATIC_ASSERT(M_NARGS (__VA_ARGS__) <= 1+M_USE_MAX_EXCEPTION, \
M_STATIC_ASSERT(M_NARGS (__VA_ARGS__) <= 1+M_USE_MAX_CONTEXT, \
M_LIB_TOO_MANY_ARGUMENTS, \
"There are too many arguments for an exception."); \
M_IF_NARGS_EQ1(__VA_ARGS__)(M_THROW_1, M_THROW_N)(__VA_ARGS__); \
@@ -89,10 +89,10 @@
/*
* Size of the extra data that are stored in an exception.
* Size of the context data that are stored in an exception.
*/
#ifndef M_USE_MAX_EXCEPTION
#define M_USE_MAX_EXCEPTION 5
#ifndef M_USE_MAX_CONTEXT
#define M_USE_MAX_CONTEXT 10
#endif
/*
@@ -121,9 +121,9 @@ template <unsigned int N>
struct m_exception_s {
unsigned error_code; // Error code
unsigned short line; // Line number where the error was detected
unsigned short n; // Number of entries in 'error' table
unsigned short num; // Number of entries in 'context' table
const char *filename; // filename where the error was detected
intptr_t data[M_USE_MAX_EXCEPTION]; // Specific data of the exception
intptr_t context[M_USE_MAX_CONTEXT]; // Specific context of the exception
#ifdef __cplusplus
m_exception_s<N> *operator->() { return this; }
#endif
+13 -13
View File
@@ -31,8 +31,8 @@ static void test_throw(void)
M_TRY(protect) {
M_THROW(67, 56);
} M_CATCH(protect, 67) {
assert(protect->n == 1);
M_THROW(M_ERROR_MEMORY, protect->data[0], 4, 6, 8);
assert(protect->num == 1);
M_THROW(M_ERROR_MEMORY, protect->context[0], 4, 6, 8);
}
}
@@ -96,8 +96,8 @@ static void test1(void)
assert(0);
} M_CATCH(test2, M_ERROR_ACCESS) {
assert(flow++ == 6);
assert(test2->n == 1);
assert(test2->data[0] == 12);
assert(test2->num == 1);
assert(test2->context[0] == 12);
}
} M_CATCH(test1, M_ERROR_MEMORY) {
assert(0);
@@ -129,9 +129,9 @@ static void test1(void)
assert(0);
} M_CATCH(test1, 42) {
assert(flow++ == 6);
assert(test1->n == 2);
assert(test1->data[0] == 1);
assert(test1->data[1] == 3);
assert(test1->num == 2);
assert(test1->context[0] == 1);
assert(test1->context[1] == 3);
}
assert(flow ++ == 7);
@@ -191,11 +191,11 @@ static void test1(void)
}
} M_CATCH(test1, M_ERROR_MEMORY) {
assert(flow ++ == 4);
assert(test1->n == 4);
assert(test1->data[0] == 56);
assert(test1->data[1] == 4);
assert(test1->data[2] == 6);
assert(test1->data[3] == 8);
assert(test1->num == 4);
assert(test1->context[0] == 56);
assert(test1->context[1] == 4);
assert(test1->context[2] == 6);
assert(test1->context[3] == 8);
} M_CATCH(test1, 42) {
assert(0);
}
@@ -219,7 +219,7 @@ static void test1(void)
assert(flow ++ == 3);
#ifndef __cplusplus
assert(test1->error_code == 23);
assert(test1->n == 0);
assert(test1->num == 0);
#endif
}
assert(flow ++ == 4);