summaryrefslogtreecommitdiff
path: root/include/mupdf/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2017-09-06 17:03:04 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-10-26 15:29:11 +0200
commitb3ceba9fa1d19c1004aec38b0a8870154a865ea4 (patch)
treebc94d586b4fc6af72ba347ebf1d8ef5c4fd74c61 /include/mupdf/fitz
parent4f8796cafcd5c15247fb85e7febd1bb591d0a853 (diff)
downloadmupdf-b3ceba9fa1d19c1004aec38b0a8870154a865ea4.tar.xz
Rewrite try/always/catch macros to allow fz_context to be opaque.
Hide fz_stack_slot and exception handling details too. Also make sure we have an initialized jmp_buf so we can safely throw from the always block even in the exception stack overflow case.
Diffstat (limited to 'include/mupdf/fitz')
-rw-r--r--include/mupdf/fitz/context.h28
1 files changed, 9 insertions, 19 deletions
diff --git a/include/mupdf/fitz/context.h b/include/mupdf/fitz/context.h
index 8f72ad99..de83d0e6 100644
--- a/include/mupdf/fitz/context.h
+++ b/include/mupdf/fitz/context.h
@@ -57,25 +57,15 @@ void fz_var_imp(void *);
attention to the man behind the curtain.
*/
-#define fz_try(ctx) \
- { \
- if (fz_push_try(ctx)) { \
- if (fz_setjmp((ctx)->error->top->buffer) == 0) do \
-
-#define fz_always(ctx) \
- while (0); \
- } \
- if (ctx->error->top->code < 3) { \
- ctx->error->top->code++; \
- do \
-
-#define fz_catch(ctx) \
- while (0); \
- } \
- } \
- if ((ctx->error->top--)->code > 1)
-
-int fz_push_try(fz_context *ctx);
+void *fz_push_try(fz_context *ctx);
+int fz_do_try(fz_context *ctx);
+int fz_do_always(fz_context *ctx);
+int fz_do_catch(fz_context *ctx);
+
+#define fz_try(ctx) if (!fz_setjmp(fz_push_try(ctx))) if (fz_do_try(ctx)) do
+#define fz_always(ctx) while (0); if (fz_do_always(ctx)) do
+#define fz_catch(ctx) while (0); if (fz_do_catch(ctx))
+
FZ_NORETURN void fz_vthrow(fz_context *ctx, int errcode, const char *, va_list ap);
FZ_NORETURN void fz_throw(fz_context *ctx, int errcode, const char *, ...) FZ_PRINTFLIKE(3,4);
FZ_NORETURN void fz_rethrow(fz_context *ctx);