I should probably just switch all this to C++ at this rate.
This commit is contained in:
parent
f517742a3c
commit
5d63b34904
|
@ -15,9 +15,9 @@
|
||||||
// Feel free to redefine checkErrorParams and checkErrorCases as necessary.
|
// Feel free to redefine checkErrorParams and checkErrorCases as necessary.
|
||||||
|
|
||||||
#define checkErrorCat(a, b) a ## b
|
#define checkErrorCat(a, b) a ## b
|
||||||
#define checkErrorCase(call, msgWant) checkErrorCaseFull(__LINE__, call, msgWant)
|
#define checkErrorCase(call, msgWant) checkErrorCaseFull(__LINE__, #call, call, msgWant)
|
||||||
|
|
||||||
#define checkErrorCaseFull(line, call, msgWant) \
|
#define checkErrorCaseFull(line, name, call, msgWant) \
|
||||||
static void checkErrorCat(doCheck, line)(void *data) \
|
static void checkErrorCat(doCheck, line)(void *data) \
|
||||||
{ \
|
{ \
|
||||||
struct checkErrorParams *p = (struct checkErrorParams *) data; \
|
struct checkErrorParams *p = (struct checkErrorParams *) data; \
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
#undef checkErrorCaseFull
|
#undef checkErrorCaseFull
|
||||||
|
|
||||||
static const struct checkErrorCase checkErrorCases[] = {
|
static const struct checkErrorCase checkErrorCases[] = {
|
||||||
#define checkErrorCaseFull(line, callstr, msgWant) { callstr, checkErrorCat(doCheck, line), msgWant },
|
#define checkErrorCaseFull(line, name, call, msgWant) { name, checkErrorCat(doCheck, line), msgWant },
|
||||||
#include checkErrorHeader
|
#include checkErrorHeader
|
||||||
#undef checkErrorCaseFull
|
#undef checkErrorCaseFull
|
||||||
{ NULL, NULL, NULL, },
|
{ NULL, NULL, NULL, },
|
||||||
|
|
|
@ -22,25 +22,39 @@ struct checkErrorParams {
|
||||||
uiEvent *eventWithHandlers;
|
uiEvent *eventWithHandlers;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define checkErrorCaseWhileFiringFull(line, call, msgWant) \
|
#define checkEventErrorCat(a, b) a ## b
|
||||||
static void checkCat(eventHandler, line)(void *sender, void *args, void *data) \
|
|
||||||
|
// First, define the firing-case handlers.
|
||||||
|
#define checkErrorCase(call, msgWant)
|
||||||
|
#define checkEventErrorCaseWhileFiringFull(line, call, msgWant) \
|
||||||
|
static void checkEventErrorCat(eventHandler, line)(void *sender, void *args, void *data) \
|
||||||
{ \
|
{ \
|
||||||
struct checkErrorParams *p = (struct checkErrorParams *) data; \
|
struct checkErrorParams *p = (struct checkErrorParams *) data; \
|
||||||
(void) p; /* in the event call does not use this */ \
|
(void) p; /* in the event call does not use this */ \
|
||||||
call; \
|
call; \
|
||||||
} \
|
} \
|
||||||
static void checkCat(runEventCheck, line)(struct checkErrorParams *p) \
|
static void checkEventErrorCat(runEventCheck, line)(struct checkErrorParams *p) \
|
||||||
{ \
|
{ \
|
||||||
int id; \
|
int id; \
|
||||||
id = uiEventAddHandler(p->firingEvent, checkCat(eventHandler, line), NULL, p); \
|
id = uiEventAddHandler(p->firingEvent, checkEventErrorCat(eventHandler, line), NULL, p); \
|
||||||
uiEventFire(p->firingEvent, NULL, NULL); \
|
uiEventFire(p->firingEvent, NULL, NULL); \
|
||||||
uiEventDeleteHandler(p->firingEvent, id); \
|
uiEventDeleteHandler(p->firingEvent, id); \
|
||||||
} \
|
}
|
||||||
checkErrorCaseFull(line, checkCat(runEventCheck, line)(p), msgWant)
|
#define checkEventErrorCaseWhileFiring(call, msgWant) checkEventErrorCaseWhileFiringFull(__LINE__, call, msgWant)
|
||||||
#define checkErrorCaseWhileFiring(call, msgWant) checkErrorCaseWhileFiringFull(__LINE__, call, msgWant)
|
#include "event_errors.h"
|
||||||
#include "events_errors.h"
|
#undef checkEventErrorCaseWhileFiring
|
||||||
#undef checkErrorCaseWhileFiringFull
|
#undef checkEventErrorCaseWhileFiringFull
|
||||||
#undef checkErrorCaseWhileFiring
|
#undef checkErrorCase
|
||||||
|
|
||||||
|
#define checkEventErrorCaseWhileFiringFull(line, call, msgWant) checkErrorCaseFull(line, #call, checkEventErrorCat(runEventCheck, line), msgWant)
|
||||||
|
#define checkEventErrorCaseWhileFiring(call, msgWant) checkEventErrorCaseWhileFiringFull(__LINE__, call, msgWant)
|
||||||
|
#define checkErrorHeader "events_errors.h"
|
||||||
|
#include "events.h"
|
||||||
|
#undef checkErrorHeader
|
||||||
|
#undef checkEventErrorCaseWhileFiring
|
||||||
|
#undef checkEventErrorCaseWhileFiringFull
|
||||||
|
|
||||||
|
#undef checkEventErrorCat
|
||||||
|
|
||||||
testingTest(EventErrors)
|
testingTest(EventErrors)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,14 +7,14 @@ checkErrorCase(uiNewEvent(&(p->eventOptionsBadSize)),
|
||||||
|
|
||||||
checkErrorCase(uiEventFree(NULL),
|
checkErrorCase(uiEventFree(NULL),
|
||||||
"uiEventFree(): invalid null pointer for uiEvent")
|
"uiEventFree(): invalid null pointer for uiEvent")
|
||||||
checkErrorCaseWhileFiring(uiEventFree(p->firingEvent),
|
checkEventErrorCaseWhileFiring(uiEventFree(p->firingEvent),
|
||||||
"uiEventFree(): can't change a uiEvent while it is firing")
|
"uiEventFree(): can't change a uiEvent while it is firing")
|
||||||
checkErrorCase(uiEventFree(p->eventWithHandlers),
|
checkErrorCase(uiEventFree(p->eventWithHandlers),
|
||||||
"uiEventFree(): can't free event that still has handlers registered")
|
"uiEventFree(): can't free event that still has handlers registered")
|
||||||
|
|
||||||
checkErrorCase(uiEventAddHandler(NULL, p->handlerPlaceholder, p->senderPlaceholder, p->dataPlaceholder),
|
checkErrorCase(uiEventAddHandler(NULL, p->handlerPlaceholder, p->senderPlaceholder, p->dataPlaceholder),
|
||||||
"uiEventAddHandler(): invalid null pointer for uiEvent")
|
"uiEventAddHandler(): invalid null pointer for uiEvent")
|
||||||
checkErrorCaseWhileFiring(uiEventAddHandler(p->firingEvent, p->handlerPlaceholder, p->senderPlaceholder, p->dataPlaceholder),
|
checkEventErrorCaseWhileFiring(uiEventAddHandler(p->firingEvent, p->handlerPlaceholder, p->senderPlaceholder, p->dataPlaceholder),
|
||||||
"uiEventAddHandler(): can't change a uiEvent while it is firing")
|
"uiEventAddHandler(): can't change a uiEvent while it is firing")
|
||||||
checkErrorCase(uiEventAddHandler(p->eventPlaceholder, NULL, p->senderPlaceholder, p->dataPlaceholder),
|
checkErrorCase(uiEventAddHandler(p->eventPlaceholder, NULL, p->senderPlaceholder, p->dataPlaceholder),
|
||||||
"uiEventAddHandler(): invalid null pointer for uiEventHandler")
|
"uiEventAddHandler(): invalid null pointer for uiEventHandler")
|
||||||
|
@ -25,14 +25,14 @@ checkErrorCase(uiEventAddHandler(p->nonglobalEvent, p->handlerPlaceholder, NULL,
|
||||||
|
|
||||||
checkErrorCase(uiEventDeleteHandler(NULL, p->idPlaceholder),
|
checkErrorCase(uiEventDeleteHandler(NULL, p->idPlaceholder),
|
||||||
"uiEventDeleteHandler(): invalid null pointer for uiEvent")
|
"uiEventDeleteHandler(): invalid null pointer for uiEvent")
|
||||||
checkErrorCaseWhileFiring(uiEventDeleteHandler(p->firingEvent, p->idPlaceholder),
|
checkEventErrorCaseWhileFiring(uiEventDeleteHandler(p->firingEvent, p->idPlaceholder),
|
||||||
"uiEventDeleteHandler(): can't change a uiEvent while it is firing")
|
"uiEventDeleteHandler(): can't change a uiEvent while it is firing")
|
||||||
checkErrorCase(uiEventDeleteHandler(p->eventPlaceholder, 5),
|
checkErrorCase(uiEventDeleteHandler(p->eventPlaceholder, 5),
|
||||||
"uiEventDeleteHandler(): event handler 5 not found")
|
"uiEventDeleteHandler(): event handler 5 not found")
|
||||||
|
|
||||||
checkErrorCase(uiEventFire(NULL, p->senderPlaceholder, p->argsPlaceholder),
|
checkErrorCase(uiEventFire(NULL, p->senderPlaceholder, p->argsPlaceholder),
|
||||||
"uiEventFire(): invalid null pointer for uiEvent")
|
"uiEventFire(): invalid null pointer for uiEvent")
|
||||||
checkErrorCaseWhileFiring(uiEventFire(p->firingEvent, p->senderPlaceholder, p->argsPlaceholder),
|
checkEventErrorCaseWhileFiring(uiEventFire(p->firingEvent, p->senderPlaceholder, p->argsPlaceholder),
|
||||||
"uiEventFire(): can't recursively fire a uiEvent")
|
"uiEventFire(): can't recursively fire a uiEvent")
|
||||||
checkErrorCase(uiEventFire(p->globalEvent, p->nonNullSender, p->argsPlaceholder),
|
checkErrorCase(uiEventFire(p->globalEvent, p->nonNullSender, p->argsPlaceholder),
|
||||||
"uiEventFire(): can't use a non-NULL sender with a global event")
|
"uiEventFire(): can't use a non-NULL sender with a global event")
|
||||||
|
@ -46,14 +46,14 @@ checkErrorCase(uiEventHandlerBlocked(p->eventPlaceholder, 5),
|
||||||
|
|
||||||
checkErrorCase(uiEventSetHandlerBlocked(NULL, p->idPlaceholder, p->blockedPlaceholder),
|
checkErrorCase(uiEventSetHandlerBlocked(NULL, p->idPlaceholder, p->blockedPlaceholder),
|
||||||
"uiEventSetHandlerBlocked(): invalid null pointer for uiEvent")
|
"uiEventSetHandlerBlocked(): invalid null pointer for uiEvent")
|
||||||
checkErrorCaseWhileFiring(uiEventSetHandlerBlocked(p->firingEvent, p->idPlaceholder, p->blockedPlaceholder),
|
checkEventErrorCaseWhileFiring(uiEventSetHandlerBlocked(p->firingEvent, p->idPlaceholder, p->blockedPlaceholder),
|
||||||
"uiEventSetHandlerBlocked(): can't change a uiEvent while it is firing")
|
"uiEventSetHandlerBlocked(): can't change a uiEvent while it is firing")
|
||||||
checkErrorCase(uiEventSetHandlerBlocked(p->eventPlaceholder, 5, p->blockedPlaceholder),
|
checkErrorCase(uiEventSetHandlerBlocked(p->eventPlaceholder, 5, p->blockedPlaceholder),
|
||||||
"uiEventSetHandlerBlocked(): event handler 5 not found")
|
"uiEventSetHandlerBlocked(): event handler 5 not found")
|
||||||
|
|
||||||
checkErrorCase(uiEventInvalidateSender(NULL, p->senderPlaceholder),
|
checkErrorCase(uiEventInvalidateSender(NULL, p->senderPlaceholder),
|
||||||
"uiEventInvalidateSender(): invalid null pointer for uiEvent")
|
"uiEventInvalidateSender(): invalid null pointer for uiEvent")
|
||||||
checkErrorCaseWhileFiring(uiEventInvalidateSender(p->firingEvent, p->senderPlaceholder),
|
checkEventErrorCaseWhileFiring(uiEventInvalidateSender(p->firingEvent, p->senderPlaceholder),
|
||||||
"uiEventInvalidateSender(): can't change a uiEvent while it is firing")
|
"uiEventInvalidateSender(): can't change a uiEvent while it is firing")
|
||||||
checkErrorCase(uiEventInvalidateSender(p->globalEvent, NULL),
|
checkErrorCase(uiEventInvalidateSender(p->globalEvent, NULL),
|
||||||
"uiEventInvalidateSender(): can't invalidate a global event")
|
"uiEventInvalidateSender(): can't invalidate a global event")
|
||||||
|
|
Loading…
Reference in New Issue