diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2007-09-22 13:32:42 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2007-09-22 13:32:42 +0000 |
commit | f1f80696ebe87520de0c857371e0ca109fce68cb (patch) | |
tree | 66b241e6ef7384e9bed2b57b11c5d8f075601b12 /test/lib/exceptions.h | |
parent | dac9bafa302a42ef8e58fa017739cc29a046413f (diff) | |
download | libdom-f1f80696ebe87520de0c857371e0ca109fce68cb.tar.gz libdom-f1f80696ebe87520de0c857371e0ca109fce68cb.tar.bz2 |
Create a library of utility functions for the testsuite to use
Make test/binding.c include stdio.h itself rather than relying on other things to include it.
svn path=/trunk/dom/; revision=3568
Diffstat (limited to 'test/lib/exceptions.h')
-rw-r--r-- | test/lib/exceptions.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/lib/exceptions.h b/test/lib/exceptions.h new file mode 100644 index 0000000..1c6b8e2 --- /dev/null +++ b/test/lib/exceptions.h @@ -0,0 +1,34 @@ +#ifndef exceptions_h_ +#define exceptions_h_ + +#include <setjmp.h> + +#include <dom/core/exceptions.h> + +/* Usage: + TRY + THROW(DOM_NOT_FOUND_ERR); + THROW_IF_ERR(dom_document_get_doctype(...)); + CATCH(ex) + printf("exception: %d\n", ex); + ENDTRY +*/ +#define TRY __exvalue=setjmp(__exbuf); \ + if (__exvalue==0) { +#define CATCH(x) } else { \ + int x = __exvalue; +#define ENDTRY } +#define THROW(x) longjmp(__exbuf, x) + +#define THROW_IF_ERR(x) \ + do { \ + int err = x; \ + if (err != DOM_NO_ERR) \ + THROW(err); \ + } while (0) + +jmp_buf __exbuf; +int __exvalue; + +#endif + |