diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-02-26 11:15:16 -0800 |
---|---|---|
committer | Robin Watts <robin@ghostscript.com> | 2012-02-26 19:36:30 +0000 |
commit | bbfe635555dce16858403706e2031dd3bfa1a9f1 (patch) | |
tree | 6e414005f04f233a83dbeec5607c0665a6d498bc /pdf/pdf_store.c | |
parent | ca578b08dc1243dc6cbb3235272d52d9e2336925 (diff) | |
download | mupdf-bbfe635555dce16858403706e2031dd3bfa1a9f1.tar.xz |
Move fz_obj to be pdf_obj.
Currently, we are in the slightly strange position of having
the PDF specific object types as part of fitz. Here we pull
them out into the pdf layer instead. This has been made possible
by the recent changes to make the store no longer be tied to
having fz_obj's as keys.
Most of this work is a simple huge rename; to help customers who
may have code that use such functions we have provided a sed
script to do the renaming; scripts/rename2.sed.
Various other small tweaks are required; the store used to have
some debugging code that still required knowledge of fz_obj
types - we extract that into a nicer 'type' based function
pointer. Also, the type 3 font handling used to have an fz_obj
pointer for type 3 resources, and therefore needed to know how
to free this; this has become a void * with a function to free
it.
Diffstat (limited to 'pdf/pdf_store.c')
-rw-r--r-- | pdf/pdf_store.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/pdf/pdf_store.c b/pdf/pdf_store.c index 4f51526d..faa81b80 100644 --- a/pdf/pdf_store.c +++ b/pdf/pdf_store.c @@ -4,31 +4,43 @@ static int pdf_make_hash_key(fz_store_hash *hash, void *key_) { - fz_obj *key = (fz_obj *)key_; + pdf_obj *key = (pdf_obj *)key_; - if (!fz_is_indirect(key)) + if (!pdf_is_indirect(key)) return 0; - hash->u.i.i0 = fz_to_num(key); - hash->u.i.i1 = fz_to_gen(key); + hash->u.i.i0 = pdf_to_num(key); + hash->u.i.i1 = pdf_to_gen(key); return 1; } static void * pdf_keep_key(fz_context *ctx, void *key) { - return (void *)fz_keep_obj((fz_obj *)key); + return (void *)pdf_keep_obj((pdf_obj *)key); } static void pdf_drop_key(fz_context *ctx, void *key) { - fz_drop_obj((fz_obj *)key); + pdf_drop_obj((pdf_obj *)key); } static int pdf_cmp_key(void *k0, void *k1) { - return fz_objcmp((fz_obj *)k0, (fz_obj *)k1); + return pdf_objcmp((pdf_obj *)k0, (pdf_obj *)k1); +} + +static void +pdf_debug_key(void *key_) +{ + pdf_obj *key = (pdf_obj *)key_; + + if (pdf_is_indirect(key)) + { + printf("(%d %d R) ", pdf_to_num(key), pdf_to_gen(key)); + } else + pdf_debug_obj(key); } static fz_store_type pdf_obj_store_type = @@ -36,23 +48,24 @@ static fz_store_type pdf_obj_store_type = pdf_make_hash_key, pdf_keep_key, pdf_drop_key, - pdf_cmp_key + pdf_cmp_key, + pdf_debug_key }; void -pdf_store_item(fz_context *ctx, fz_obj *key, void *val, unsigned int itemsize) +pdf_store_item(fz_context *ctx, pdf_obj *key, void *val, unsigned int itemsize) { fz_store_item(ctx, key, val, itemsize, &pdf_obj_store_type); } void * -pdf_find_item(fz_context *ctx, fz_store_free_fn *free, fz_obj *key) +pdf_find_item(fz_context *ctx, fz_store_free_fn *free, pdf_obj *key) { return fz_find_item(ctx, free, key, &pdf_obj_store_type); } void -pdf_remove_item(fz_context *ctx, fz_store_free_fn *free, fz_obj *key) +pdf_remove_item(fz_context *ctx, fz_store_free_fn *free, pdf_obj *key) { fz_remove_item(ctx, free, key, &pdf_obj_store_type); } |