Add constants to `{default|ignore}_handler`.

This is better than explicitly casting to the handler you want.
Niklas Hauser 2015-12-21 12:00:14 +00:00 committed by Martin Kojtal
parent aca2e920e3
commit 15f3ccad1b
1 changed files with 39 additions and 17 deletions

View File

@ -31,37 +31,59 @@ namespace v1 {
/** Default handler hint.
*
* Use this handler to indicate the you want the default handler to be called.
* This type automatically casts itself into the appropriate handler type.
* This type automatically casts itself into the appropriate handler type, when possible.
* Use the constants to default a handler unambigously.
*/
const struct
{
operator test_setup_handler_t() const { return test_setup_handler_t(1); }
operator test_teardown_handler_t() const { return test_teardown_handler_t(1); }
operator test_failure_handler_t() const { return test_failure_handler_t(1); }
const test_setup_handler_t test_setup = test_setup_handler_t(1);
const test_teardown_handler_t test_teardown = test_teardown_handler_t(1);
const test_failure_handler_t test_failure = test_failure_handler_t(1);
operator case_setup_handler_t() const { return case_setup_handler_t(1); }
operator case_teardown_handler_t() const { return case_teardown_handler_t(1); }
operator case_failure_handler_t() const { return case_failure_handler_t(1); }
const case_setup_handler_t case_setup = case_setup_handler_t(1);
const case_teardown_handler_t case_teardown = case_teardown_handler_t(1);
const case_failure_handler_t case_failure = case_failure_handler_t(1);
operator test_setup_handler_t() const { return test_setup; }
operator test_teardown_handler_t() const { return test_teardown; }
operator test_failure_handler_t() const { return test_failure; }
operator case_setup_handler_t() const { return case_setup; }
operator case_teardown_handler_t() const { return case_teardown; }
operator case_failure_handler_t() const { return case_failure; }
} default_handler;
/** Ignore handler hint.
*
* Use this handler to indicate the you want to ignore this handler and it will not be called.
* This type automatically casts itself into the appropriate handler type.
* This type automatically casts itself into the appropriate handler type, when possible.
* Use the constants to ignore a handler unambigously.
*/
const struct
{
operator case_handler_t() const { return case_handler_t(NULL); }
operator case_control_handler_t() const { return case_control_handler_t(NULL); }
operator case_repeat_count_handler_t() const { return case_repeat_count_handler_t(NULL); }
const case_handler_t handler = case_handler_t(NULL);
const case_control_handler_t control = case_control_handler_t(NULL);
const case_repeat_count_handler_t repeat_count = case_repeat_count_handler_t(NULL);
operator test_setup_handler_t() const { return test_setup_handler_t(NULL); }
operator test_teardown_handler_t() const { return test_teardown_handler_t(NULL); }
operator test_failure_handler_t() const { return test_failure_handler_t(NULL); }
const test_setup_handler_t test_setup = test_setup_handler_t(1);
const test_teardown_handler_t test_teardown = test_teardown_handler_t(1);
const test_failure_handler_t test_failure = test_failure_handler_t(1);
operator case_setup_handler_t() const { return case_setup_handler_t(NULL); }
operator case_teardown_handler_t() const { return case_teardown_handler_t(NULL); }
operator case_failure_handler_t() const { return case_failure_handler_t(NULL); }
const case_setup_handler_t case_setup = case_setup_handler_t(1);
const case_teardown_handler_t case_teardown = case_teardown_handler_t(1);
const case_failure_handler_t case_failure = case_failure_handler_t(1);
operator case_handler_t() const { return handler; }
operator case_control_handler_t() const { return control; }
operator case_repeat_count_handler_t() const { return repeat_count; }
operator test_setup_handler_t() const { return test_setup; }
operator test_teardown_handler_t() const { return test_teardown; }
operator test_failure_handler_t() const { return test_failure; }
operator case_setup_handler_t() const { return case_setup; }
operator case_teardown_handler_t() const { return case_teardown; }
operator case_failure_handler_t() const { return case_failure; }
} ignore_handler;
/** A table of handlers.