From fc0432b9121d528d9b775cd9ed103732c6440973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20B=C3=BCnzli?= Date: Thu, 2 Jan 2014 22:13:52 +0100 Subject: fix MSVC warnings C4054 and C4152 These warnings are caused by casting function pointers to void* instead of proper function types. --- include/mupdf/fitz/document.h | 55 +++++++++++++++++++++++++++++-------------- source/cbz/mucbz.c | 16 ++++++------- source/img/muimage.c | 16 ++++++------- source/pdf/pdf-xref-aux.c | 18 ++++---------- source/pdf/pdf-xref.c | 34 +++++++++++++------------- source/xps/xps-zip.c | 20 ++++++++-------- 6 files changed, 84 insertions(+), 75 deletions(-) diff --git a/include/mupdf/fitz/document.h b/include/mupdf/fitz/document.h index d185a31d..887ca151 100644 --- a/include/mupdf/fitz/document.h +++ b/include/mupdf/fitz/document.h @@ -19,26 +19,45 @@ typedef struct fz_annot_s fz_annot; // TODO: move out of this interface (it's pdf specific) typedef struct fz_write_options_s fz_write_options; +typedef void (fz_document_close_fn)(fz_document *doc); +typedef int (fz_document_needs_password_fn)(fz_document *doc); +typedef int (fz_document_authenticate_password_fn)(fz_document *doc, const char *password); +typedef fz_outline *(fz_document_load_outline_fn)(fz_document *doc); +typedef int (fz_document_count_pages_fn)(fz_document *doc); +typedef fz_page *(fz_document_load_page_fn)(fz_document *doc, int number); +typedef fz_link *(fz_document_load_links_fn)(fz_document *doc, fz_page *page); +typedef fz_rect *(fz_document_bound_page_fn)(fz_document *doc, fz_page *page, fz_rect *); +typedef void (fz_document_run_page_contents_fn)(fz_document *doc, fz_page *page, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie); +typedef void (fz_document_run_annot_fn)(fz_document *doc, fz_page *page, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie); +typedef void (fz_document_free_page_fn)(fz_document *doc, fz_page *page); +typedef int (fz_document_meta_fn)(fz_document *doc, int key, void *ptr, int size); +typedef fz_transition *(fz_document_page_presentation_fn)(fz_document *doc, fz_page *page, float *duration); +typedef fz_annot *(fz_document_first_annot_fn)(fz_document *doc, fz_page *page); +typedef fz_annot *(fz_document_next_annot_fn)(fz_document *doc, fz_annot *annot); +typedef fz_rect *(fz_document_bound_annot_fn)(fz_document *doc, fz_annot *annot, fz_rect *rect); +typedef void (fz_document_write_fn)(fz_document *doc, char *filename, fz_write_options *opts); +typedef void (fz_document_rebind_fn)(fz_document *doc, fz_context *ctx); + struct fz_document_s { - void (*close)(fz_document *); - int (*needs_password)(fz_document *doc); - int (*authenticate_password)(fz_document *doc, const char *password); - fz_outline *(*load_outline)(fz_document *doc); - int (*count_pages)(fz_document *doc); - fz_page *(*load_page)(fz_document *doc, int number); - fz_link *(*load_links)(fz_document *doc, fz_page *page); - fz_rect *(*bound_page)(fz_document *doc, fz_page *page, fz_rect *); - void (*run_page_contents)(fz_document *doc, fz_page *page, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie); - void (*run_annot)(fz_document *doc, fz_page *page, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie); - void (*free_page)(fz_document *doc, fz_page *page); - int (*meta)(fz_document *doc, int key, void *ptr, int size); - fz_transition *(*page_presentation)(fz_document *doc, fz_page *page, float *duration); - fz_annot *(*first_annot)(fz_document *doc, fz_page *page); - fz_annot *(*next_annot)(fz_document *doc, fz_annot *annot); - fz_rect *(*bound_annot)(fz_document *doc, fz_annot *annot, fz_rect *rect); - void (*write)(fz_document *doc, char *filename, fz_write_options *opts); - void (*rebind)(fz_document *doc, fz_context *ctx); + fz_document_close_fn *close; + fz_document_needs_password_fn *needs_password; + fz_document_authenticate_password_fn *authenticate_password; + fz_document_load_outline_fn *load_outline; + fz_document_count_pages_fn *count_pages; + fz_document_load_page_fn *load_page; + fz_document_load_links_fn *load_links; + fz_document_bound_page_fn *bound_page; + fz_document_run_page_contents_fn *run_page_contents; + fz_document_run_annot_fn *run_annot; + fz_document_free_page_fn *free_page; + fz_document_meta_fn *meta; + fz_document_page_presentation_fn *page_presentation; + fz_document_first_annot_fn *first_annot; + fz_document_next_annot_fn *next_annot; + fz_document_bound_annot_fn *bound_annot; + fz_document_write_fn *write; + fz_document_rebind_fn *rebind; }; /* diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c index d9be58f3..fa654a54 100644 --- a/source/cbz/mucbz.c +++ b/source/cbz/mucbz.c @@ -421,12 +421,12 @@ cbz_rebind(cbz_document *doc, fz_context *ctx) static void cbz_init_document(cbz_document *doc) { - doc->super.close = (void*)cbz_close_document; - doc->super.count_pages = (void*)cbz_count_pages; - doc->super.load_page = (void*)cbz_load_page; - doc->super.bound_page = (void*)cbz_bound_page; - doc->super.run_page_contents = (void*)cbz_run_page; - doc->super.free_page = (void*)cbz_free_page; - doc->super.meta = (void*)cbz_meta; - doc->super.rebind = (void *)cbz_rebind; + doc->super.close = (fz_document_close_fn *)cbz_close_document; + doc->super.count_pages = (fz_document_count_pages_fn *)cbz_count_pages; + doc->super.load_page = (fz_document_load_page_fn *)cbz_load_page; + doc->super.bound_page = (fz_document_bound_page_fn *)cbz_bound_page; + doc->super.run_page_contents = (fz_document_run_page_contents_fn *)cbz_run_page; + doc->super.free_page = (fz_document_free_page_fn *)cbz_free_page; + doc->super.meta = (fz_document_meta_fn *)cbz_meta; + doc->super.rebind = (fz_document_rebind_fn *)cbz_rebind; } diff --git a/source/img/muimage.c b/source/img/muimage.c index 7a6dfc3a..26f4a0f3 100644 --- a/source/img/muimage.c +++ b/source/img/muimage.c @@ -145,12 +145,12 @@ image_rebind(image_document *doc, fz_context *ctx) static void image_init_document(image_document *doc) { - doc->super.close = (void*)image_close_document; - doc->super.count_pages = (void*)image_count_pages; - doc->super.load_page = (void*)image_load_page; - doc->super.bound_page = (void*)image_bound_page; - doc->super.run_page_contents = (void*)image_run_page; - doc->super.free_page = (void*)image_free_page; - doc->super.meta = (void*)image_meta; - doc->super.rebind = (void*)image_rebind; + doc->super.close = (fz_document_close_fn *)image_close_document; + doc->super.count_pages = (fz_document_count_pages_fn *)image_count_pages; + doc->super.load_page = (fz_document_load_page_fn *)image_load_page; + doc->super.bound_page = (fz_document_bound_page_fn *)image_bound_page; + doc->super.run_page_contents = (fz_document_run_page_contents_fn *)image_run_page; + doc->super.free_page = (fz_document_free_page_fn *)image_free_page; + doc->super.meta = (fz_document_meta_fn *)image_meta; + doc->super.rebind = (fz_document_rebind_fn *)image_rebind; } diff --git a/source/pdf/pdf-xref-aux.c b/source/pdf/pdf-xref-aux.c index 48634374..968a8f9f 100644 --- a/source/pdf/pdf-xref-aux.c +++ b/source/pdf/pdf-xref-aux.c @@ -8,22 +8,12 @@ resulting executables. */ -static void pdf_run_page_contents_shim(fz_document *doc, fz_page *page, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie) -{ - pdf_run_page_contents((pdf_document*)doc, (pdf_page*)page, dev, transform, cookie); -} - -static void pdf_run_annot_shim(fz_document *doc, fz_page *page, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie) -{ - pdf_run_annot((pdf_document*)doc, (pdf_page*)page, (pdf_annot *)annot, dev, transform, cookie); -} - pdf_document * pdf_open_document_with_stream(fz_context *ctx, fz_stream *file) { pdf_document *doc = pdf_open_document_no_run_with_stream(ctx, file); - doc->super.run_page_contents = pdf_run_page_contents_shim; - doc->super.run_annot = pdf_run_annot_shim; + doc->super.run_page_contents = (fz_document_run_page_contents_fn *)pdf_run_page_contents; + doc->super.run_annot = (fz_document_run_annot_fn *)pdf_run_annot; doc->update_appearance = pdf_update_appearance; return doc; } @@ -32,8 +22,8 @@ pdf_document * pdf_open_document(fz_context *ctx, const char *filename) { pdf_document *doc = pdf_open_document_no_run(ctx, filename); - doc->super.run_page_contents = pdf_run_page_contents_shim; - doc->super.run_annot = pdf_run_annot_shim; + doc->super.run_page_contents = (fz_document_run_page_contents_fn *)pdf_run_page_contents; + doc->super.run_annot = (fz_document_run_annot_fn *)pdf_run_annot; doc->update_appearance = pdf_update_appearance; return doc; } diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index 523dd1f3..d7c5cd1b 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -1963,24 +1963,24 @@ pdf_new_document(fz_context *ctx, fz_stream *file) { pdf_document *doc = fz_malloc_struct(ctx, pdf_document); - doc->super.close = (void*)pdf_close_document; - doc->super.needs_password = (void*)pdf_needs_password; - doc->super.authenticate_password = (void*)pdf_authenticate_password; - doc->super.load_outline = (void*)pdf_load_outline; - doc->super.count_pages = (void*)pdf_count_pages; - doc->super.load_page = (void*)pdf_load_page; - doc->super.load_links = (void*)pdf_load_links; - doc->super.bound_page = (void*)pdf_bound_page; - doc->super.first_annot = (void*)pdf_first_annot; - doc->super.next_annot = (void*)pdf_next_annot; - doc->super.bound_annot = (void*)pdf_bound_annot; + doc->super.close = (fz_document_close_fn *)pdf_close_document; + doc->super.needs_password = (fz_document_needs_password_fn *)pdf_needs_password; + doc->super.authenticate_password = (fz_document_authenticate_password_fn *)pdf_authenticate_password; + doc->super.load_outline = (fz_document_load_outline_fn *)pdf_load_outline; + doc->super.count_pages = (fz_document_count_pages_fn *)pdf_count_pages; + doc->super.load_page = (fz_document_load_page_fn *)pdf_load_page; + doc->super.load_links = (fz_document_load_links_fn *)pdf_load_links; + doc->super.bound_page = (fz_document_bound_page_fn *)pdf_bound_page; + doc->super.first_annot = (fz_document_first_annot_fn *)pdf_first_annot; + doc->super.next_annot = (fz_document_next_annot_fn *)pdf_next_annot; + doc->super.bound_annot = (fz_document_bound_annot_fn *)pdf_bound_annot; doc->super.run_page_contents = NULL; /* see pdf_xref_aux.c */ doc->super.run_annot = NULL; /* see pdf_xref_aux.c */ - doc->super.free_page = (void*)pdf_free_page; - doc->super.meta = (void*)pdf_meta; - doc->super.page_presentation = (void*)pdf_page_presentation; - doc->super.write = (void*)pdf_write_document; - doc->super.rebind = (void*)pdf_rebind; + doc->super.free_page = (fz_document_free_page_fn *)pdf_free_page; + doc->super.meta = (fz_document_meta_fn *)pdf_meta; + doc->super.page_presentation = (fz_document_page_presentation_fn *)pdf_page_presentation; + doc->super.write = (fz_document_write_fn *)pdf_write_document; + doc->super.rebind = (fz_document_rebind_fn *)pdf_rebind; pdf_lexbuf_init(ctx, &doc->lexbuf.base, PDF_LEXBUF_LARGE); doc->file = fz_keep_stream(file); @@ -2370,7 +2370,7 @@ pdf_obj *pdf_progressive_advance(pdf_document *doc, int pagenum) pdf_document *pdf_specifics(fz_document *doc) { - return (pdf_document *)((doc && doc->close == (void *)pdf_close_document) ? doc : NULL); + return (pdf_document *)((doc && doc->close == (fz_document_close_fn *)pdf_close_document) ? doc : NULL); } pdf_document *pdf_create_document(fz_context *ctx) diff --git a/source/xps/xps-zip.c b/source/xps/xps-zip.c index 3aca8cdb..f70a28bf 100644 --- a/source/xps/xps-zip.c +++ b/source/xps/xps-zip.c @@ -691,14 +691,14 @@ xps_rebind(xps_document *doc, fz_context *ctx) static void xps_init_document(xps_document *doc) { - doc->super.close = (void*)xps_close_document; - doc->super.load_outline = (void*)xps_load_outline; - doc->super.count_pages = (void*)xps_count_pages; - doc->super.load_page = (void*)xps_load_page; - doc->super.load_links = (void*)xps_load_links; - doc->super.bound_page = (void*)xps_bound_page; - doc->super.run_page_contents = (void*)xps_run_page; - doc->super.free_page = (void*)xps_free_page; - doc->super.meta = (void*)xps_meta; - doc->super.rebind = (void*)xps_rebind; + doc->super.close = (fz_document_close_fn *)xps_close_document; + doc->super.load_outline = (fz_document_load_outline_fn *)xps_load_outline; + doc->super.count_pages = (fz_document_count_pages_fn *)xps_count_pages; + doc->super.load_page = (fz_document_load_page_fn *)xps_load_page; + doc->super.load_links = (fz_document_load_links_fn *)xps_load_links; + doc->super.bound_page = (fz_document_bound_page_fn *)xps_bound_page; + doc->super.run_page_contents = (fz_document_run_page_contents_fn *)xps_run_page; + doc->super.free_page = (fz_document_free_page_fn *)xps_free_page; + doc->super.meta = (fz_document_meta_fn *)xps_meta; + doc->super.rebind = (fz_document_rebind_fn *)xps_rebind; } -- cgit v1.2.3