summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-04-01 16:02:09 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-04-01 16:02:09 +0200
commitd2250034a7e629455b9bfbf735473ea39638a701 (patch)
tree5d5cedf0e6447a75162d9ef1b89309e911740227 /fitz
parent6192f4c4fdec838fd5ef86a17517d615d7ff16ca (diff)
downloadmupdf-d2250034a7e629455b9bfbf735473ea39638a701.tar.xz
Use a function pointer for resolveindirect.
This removes a static dependency between fitz and mupdf. Fitz should now be link time independent of mupdf again.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/fitz.h6
-rw-r--r--fitz/obj_simple.c32
2 files changed, 11 insertions, 27 deletions
diff --git a/fitz/fitz.h b/fitz/fitz.h
index f8bef4c3..d4ab8ff4 100644
--- a/fitz/fitz.h
+++ b/fitz/fitz.h
@@ -406,13 +406,15 @@ struct fz_obj_s
} u;
};
+extern fz_obj* (*fz_resolveindirect)(fz_obj*);
+
fz_obj *fz_newnull(void);
fz_obj *fz_newbool(int b);
fz_obj *fz_newint(int i);
fz_obj *fz_newreal(float f);
fz_obj *fz_newname(char *str);
fz_obj *fz_newstring(char *str, int len);
-fz_obj *fz_newindirect(int num, int gen, struct pdf_xref_s *xref);
+fz_obj *fz_newindirect(int num, int gen, void *xref);
fz_obj *fz_newarray(int initialcap);
fz_obj *fz_newdict(int initialcap);
@@ -435,8 +437,6 @@ int fz_isindirect(fz_obj *obj);
int fz_objcmp(fz_obj *a, fz_obj *b);
-fz_obj *fz_resolveindirect(fz_obj *obj);
-
/* silent failure, no error reporting */
int fz_tobool(fz_obj *obj);
int fz_toint(fz_obj *obj);
diff --git a/fitz/obj_simple.c b/fitz/obj_simple.c
index f279bd55..b629974e 100644
--- a/fitz/obj_simple.c
+++ b/fitz/obj_simple.c
@@ -1,9 +1,15 @@
#include "fitz.h"
-#include "mupdf.h" /* for pdf_loadobject */
extern void fz_freearray(fz_obj *array);
extern void fz_freedict(fz_obj *dict);
+static fz_obj *fz_resolve_indirect_null(fz_obj *ref)
+{
+ return ref;
+}
+
+fz_obj* (*fz_resolveindirect)(fz_obj*) = fz_resolve_indirect_null;
+
fz_obj *
fz_newnull(void)
{
@@ -66,7 +72,7 @@ fz_newname(char *str)
}
fz_obj *
-fz_newindirect(int num, int gen, pdf_xref *xref)
+fz_newindirect(int num, int gen, void *xref)
{
fz_obj *o = fz_malloc(sizeof(fz_obj));
o->refs = 1;
@@ -219,28 +225,6 @@ int fz_togen(fz_obj *obj)
return 0;
}
-fz_obj *fz_resolveindirect(fz_obj *ref)
-{
- if (fz_isindirect(ref))
- {
- pdf_xref *xref = ref->u.r.xref;
- int num = fz_tonum(ref);
- int gen = fz_togen(ref);
- if (xref)
- {
- fz_error error = pdf_cacheobject(xref, num, gen);
- if (error)
- {
- fz_catch(error, "cannot load object (%d %d R) into cache", num, gen);
- return ref;
- }
- if (xref->table[num].obj)
- return xref->table[num].obj;
- }
- }
- return ref;
-}
-
int
fz_objcmp(fz_obj *a, fz_obj *b)
{