summaryrefslogtreecommitdiff
path: root/fitz/exceptxxx.h
blob: 185f73f6b42811b57744cf26df5ccd371c7816fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef EXCEPTXXX_H
#define EXCEPTXXX_H

#include <setjmp.h>

#define fz_try(ctx)                                      \
if(fz_except_xxx_push(ctx->except),                      \
   !setjmp(ctx->except.stack[ctx->except.depth].buffer)) \
{

#define fz_catch(ctx)                               \
    ctx->except.stack[ctx->except.depth].failed = 0;\
}\
else\
{\
    ctx->except.stack[ctx->except.depth].failed = 1;\
}\
if(ex->stack[ex->depth--].failed)

typedef struct fz_except_xxx_stack
{
    int failed;
    jmp_buf buffer;
} fz_except_xxx_stack;

#define MAXDEPTH (20)

struct fz_except_context {
    fz_except_xxx_stack stack[MAXDEPTH];
    int depth;
    fz_except except;
};

void fz_except_xxx_push(fz_except_context *);

#endif /* EXCEPTXXX */