-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMuPDFWrapper.xsi
73 lines (58 loc) · 1.28 KB
/
MuPDFWrapper.xsi
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
STATIC MGVTBL mupdf_mg_vtbl = { 0, 0, 0, 0, 0, 0, 0, 0 };
typedef enum InternalKind {
Context,
Document,
Pixmap,
ColorSpace
} Graphics__MuPDF__InternalKind;
typedef struct {
fz_context* ctx;
SV* ctx_sv;
} Graphics__MuPDF__Context;
typedef struct {
fz_context* ctx;
fz_document* doc;
SV* ctx_sv;
} Graphics__MuPDF__Document;
typedef struct {
fz_context* ctx;
fz_pixmap* pix;
SV* ctx_sv;
} Graphics__MuPDF__Pixmap;
typedef struct {
fz_context* ctx;
fz_colorspace* cs;
SV* ctx_sv;
} Graphics__MuPDF__ColorSpace;
typedef struct {
Graphics__MuPDF__InternalKind kind;
union {
Graphics__MuPDF__Context* context;
Graphics__MuPDF__Document* document;
Graphics__MuPDF__Pixmap* pixmap;
Graphics__MuPDF__ColorSpace* colorspace;
};
} Graphics__MuPDF__Internal;
void _mupdf_attach_mg( SV* sv, void* ptr ) {
sv_magicext (SvRV(sv), NULL, PERL_MAGIC_ext, &mupdf_mg_vtbl,
(const char *)ptr, 0);
}
MAGIC *
_mupdf_find_mg (SV * sv) {
MAGIC *mg;
if (SvTYPE (sv) < SVt_PVMG)
return NULL;
if ((mg = mg_findext(sv, PERL_MAGIC_ext, &mupdf_mg_vtbl))) {
assert (mg->mg_ptr);
return mg;
}
return NULL;
}
Graphics__MuPDF__Internal*
mupdf_get_object (SV * sv)
{
MAGIC *mg;
if (!(mg = _mupdf_find_mg(SvRV (sv))))
return NULL;
return (Graphics__MuPDF__Internal*) mg->mg_ptr;
}