-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContext.xsi
More file actions
38 lines (31 loc) · 1.04 KB
/
Context.xsi
File metadata and controls
38 lines (31 loc) · 1.04 KB
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
37
38
MODULE = Graphics::MuPDF PACKAGE = Graphics::MuPDF::Context PREFIX = Context_
PROTOTYPES: DISABLE
void Context__build(SV* self)
CODE:
fz_context* ctx = fz_new_context(NULL, NULL, FZ_STORE_UNLIMITED);
if( ! ctx ) {
croak("Context not created");
}
/* Register the default file types to handle. */
fz_try(ctx) {
fz_register_document_handlers(ctx);
}
fz_catch(ctx) {
warn("cannot register document handlers: %s\n", fz_caught_message(ctx));
fz_drop_context(ctx);
croak("Context not created");
}
Graphics__MuPDF__Internal* internal;
Newx(internal, 1, Graphics__MuPDF__Internal);
internal->kind = Context;
Newx(internal->context, 1, Graphics__MuPDF__Context);
internal->context->ctx = ctx;
_mupdf_attach_mg(self, internal);
internal->context->ctx_sv = self;
void Context_DESTROY(SV* self)
CODE:
Graphics__MuPDF__Internal* internal = mupdf_get_object(self);
if( Context != internal->kind ) croak("Wrong magic: expected Context");
fz_drop_context(internal->context->ctx);
Safefree(internal->context);
Safefree(internal);