Commit bf25490f authored by Sebastian Ramacher's avatar Sebastian Ramacher

Remove function pointer casts

parent 3e7a8f19
......@@ -83,8 +83,10 @@ error_ret:
}
zathura_error_t
pdf_document_free(zathura_document_t* document, mupdf_document_t* mupdf_document)
pdf_document_free(zathura_document_t* document, void* data)
{
mupdf_document_t* mupdf_document = data;
if (document == NULL || mupdf_document == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
......@@ -98,9 +100,10 @@ pdf_document_free(zathura_document_t* document, mupdf_document_t* mupdf_document
}
zathura_error_t
pdf_document_save_as(zathura_document_t* document, mupdf_document_t*
mupdf_document, const char* path)
pdf_document_save_as(zathura_document_t* document, void* data, const char* path)
{
mupdf_document_t* mupdf_document = data;
if (document == NULL || mupdf_document == NULL || path == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
......@@ -115,9 +118,10 @@ pdf_document_save_as(zathura_document_t* document, mupdf_document_t*
}
girara_list_t*
pdf_document_get_information(zathura_document_t* document, mupdf_document_t*
mupdf_document, zathura_error_t* error)
pdf_document_get_information(zathura_document_t* document, void* data, zathura_error_t* error)
{
mupdf_document_t* mupdf_document = data;
if (document == NULL || mupdf_document == NULL || error == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
......
......@@ -10,8 +10,10 @@
static void pdf_zathura_image_free(zathura_image_t* image);
girara_list_t*
pdf_page_images_get(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t* error)
pdf_page_images_get(zathura_page_t* page, void* data, zathura_error_t* error)
{
mupdf_page_t* mupdf_page = data;
if (page == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
......@@ -74,9 +76,11 @@ error_ret:
}
cairo_surface_t*
pdf_page_image_get_cairo(zathura_page_t* page, mupdf_page_t* mupdf_page,
pdf_page_image_get_cairo(zathura_page_t* page, void* data,
zathura_image_t* image, zathura_error_t* error)
{
mupdf_page_t* mupdf_page = data;
if (page == NULL || mupdf_page == NULL || image == NULL || image->data == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
......
......@@ -8,8 +8,10 @@ static void build_index(fz_context* ctx, fz_document* document, fz_outline*
outline, girara_tree_node_t* root);
girara_tree_node_t*
pdf_document_index_generate(zathura_document_t* document, mupdf_document_t* mupdf_document, zathura_error_t* error)
pdf_document_index_generate(zathura_document_t* document, void* data, zathura_error_t* error)
{
mupdf_document_t* mupdf_document = data;
if (document == NULL || mupdf_document == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
......
......@@ -5,7 +5,7 @@
#include "plugin.h"
girara_list_t*
pdf_page_links_get(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t* error)
pdf_page_links_get(zathura_page_t* page, void* data, zathura_error_t* error)
{
if (page == NULL) {
if (error != NULL) {
......@@ -14,6 +14,7 @@ pdf_page_links_get(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error
goto error_ret;
}
mupdf_page_t* mupdf_page = data;
zathura_document_t* document = zathura_page_get_document(page);
if (document == NULL || mupdf_page == NULL || mupdf_page->page == NULL) {
goto error_ret;
......
......@@ -58,12 +58,13 @@ error_free:
}
zathura_error_t
pdf_page_clear(zathura_page_t* page, mupdf_page_t* mupdf_page)
pdf_page_clear(zathura_page_t* page, void* data)
{
if (page == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
mupdf_page_t* mupdf_page = data;
zathura_document_t* document = zathura_page_get_document(page);
mupdf_document_t* mupdf_document = zathura_document_get_data(document);
......
......@@ -6,20 +6,20 @@ ZATHURA_PLUGIN_REGISTER_WITH_FUNCTIONS(
"pdf-mupdf",
VERSION_MAJOR, VERSION_MINOR, VERSION_REV,
ZATHURA_PLUGIN_FUNCTIONS({
.document_open = (zathura_plugin_document_open_t) pdf_document_open,
.document_free = (zathura_plugin_document_free_t) pdf_document_free,
.document_save_as = (zathura_plugin_document_save_as_t) pdf_document_save_as,
.document_index_generate = (zathura_plugin_document_index_generate_t) pdf_document_index_generate,
.document_get_information = (zathura_plugin_document_get_information_t) pdf_document_get_information,
.page_init = (zathura_plugin_page_init_t) pdf_page_init,
.page_clear = (zathura_plugin_page_clear_t) pdf_page_clear,
.page_search_text = (zathura_plugin_page_search_text_t) pdf_page_search_text,
.page_links_get = (zathura_plugin_page_links_get_t) pdf_page_links_get,
.page_images_get = (zathura_plugin_page_images_get_t) pdf_page_images_get,
.page_get_text = (zathura_plugin_page_get_text_t) pdf_page_get_text,
.page_render = (zathura_plugin_page_render_t) pdf_page_render,
.page_render_cairo = (zathura_plugin_page_render_cairo_t) pdf_page_render_cairo,
.page_image_get_cairo = (zathura_plugin_page_image_get_cairo_t) pdf_page_image_get_cairo
.document_open = pdf_document_open,
.document_free = pdf_document_free,
.document_save_as = pdf_document_save_as,
.document_index_generate = pdf_document_index_generate,
.document_get_information = pdf_document_get_information,
.page_init = pdf_page_init,
.page_clear = pdf_page_clear,
.page_search_text = pdf_page_search_text,
.page_links_get = pdf_page_links_get,
.page_images_get = pdf_page_images_get,
.page_get_text = pdf_page_get_text,
.page_render = pdf_page_render,
.page_render_cairo = pdf_page_render_cairo,
.page_image_get_cairo = pdf_page_image_get_cairo
}),
ZATHURA_PLUGIN_MIMETYPES({
"application/pdf",
......
......@@ -39,7 +39,7 @@ zathura_error_t pdf_document_open(zathura_document_t* document);
* @param document Zathura document
* @return true if no error occurred, otherwise false
*/
zathura_error_t pdf_document_free(zathura_document_t* document, mupdf_document_t* mupdf_document);
zathura_error_t pdf_document_free(zathura_document_t* document, void* mupdf_document);
/**
* Saves the document to the given path
......@@ -50,7 +50,7 @@ zathura_error_t pdf_document_free(zathura_document_t* document, mupdf_document_t
* zathura_error_t
*/
zathura_error_t pdf_document_save_as(zathura_document_t* document,
mupdf_document_t* mupdf_document, const char* path);
void* mupdf_document, const char* path);
/**
* Generates the index of the document
......@@ -62,7 +62,7 @@ zathura_error_t pdf_document_save_as(zathura_document_t* document,
* no index)
*/
girara_tree_node_t* pdf_document_index_generate(zathura_document_t* document,
mupdf_document_t* mupdf_document, zathura_error_t* error);
void* mupdf_document, zathura_error_t* error);
/**
* Returns a reference to a page
......@@ -78,7 +78,7 @@ zathura_error_t pdf_page_init(zathura_page_t* page);
* @param page Page
* @return true if no error occurred, otherwise false
*/
zathura_error_t pdf_page_clear(zathura_page_t* page, mupdf_page_t* mupdf_page);
zathura_error_t pdf_page_clear(zathura_page_t* page, void* mupdf_page);
/**
* Searches for a specific text on a page and returns a list of results
......@@ -89,7 +89,7 @@ zathura_error_t pdf_page_clear(zathura_page_t* page, mupdf_page_t* mupdf_page);
* error occurred
* @return List of search results or NULL if an error occurred
*/
girara_list_t* pdf_page_search_text(zathura_page_t* page, mupdf_page_t* mupdf_page, const char* text, zathura_error_t* error);
girara_list_t* pdf_page_search_text(zathura_page_t* page, void* mupdf_page, const char* text, zathura_error_t* error);
/**
* Returns a list of internal/external links that are shown on the given page
......@@ -99,7 +99,7 @@ girara_list_t* pdf_page_search_text(zathura_page_t* page, mupdf_page_t* mupdf_pa
* error occurred
* @return List of links or NULL if an error occurred
*/
girara_list_t* pdf_page_links_get(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t* error);
girara_list_t* pdf_page_links_get(zathura_page_t* page, void* mupdf_page, zathura_error_t* error);
/**
* Returns a list of images included on the zathura page
......@@ -109,7 +109,7 @@ girara_list_t* pdf_page_links_get(zathura_page_t* page, mupdf_page_t* mupdf_page
* error occurred
* @return List of images
*/
girara_list_t* pdf_page_images_get(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t* error);
girara_list_t* pdf_page_images_get(zathura_page_t* page, void* mupdf_page, zathura_error_t* error);
/**
* Gets the content of the image in a cairo surface
......@@ -120,7 +120,7 @@ girara_list_t* pdf_page_images_get(zathura_page_t* page, mupdf_page_t* mupdf_pag
* error occurred
* @return The cairo image surface or NULL if an error occurred
*/
cairo_surface_t* pdf_page_image_get_cairo(zathura_page_t* page, mupdf_page_t*
cairo_surface_t* pdf_page_image_get_cairo(zathura_page_t* page, void*
mupdf_page, zathura_image_t* image, zathura_error_t* error);
/**
......@@ -131,7 +131,7 @@ cairo_surface_t* pdf_page_image_get_cairo(zathura_page_t* page, mupdf_page_t*
* occurred
* @return The selected text (needs to be deallocated with g_free)
*/
char* pdf_page_get_text(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_rectangle_t rectangle, zathura_error_t* error);
char* pdf_page_get_text(zathura_page_t* page, void* mupdf_page, zathura_rectangle_t rectangle, zathura_error_t* error);
/**
* Returns a list of document information entries of the document
......@@ -142,7 +142,7 @@ char* pdf_page_get_text(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_
* @return List of information entries or NULL if an error occurred
*/
girara_list_t* pdf_document_get_information(zathura_document_t* document,
mupdf_document_t* mupdf_document, zathura_error_t* error);
void* mupdf_document, zathura_error_t* error);
/**
* Renders a page and returns a allocated image buffer which has to be freed
......@@ -153,7 +153,7 @@ girara_list_t* pdf_document_get_information(zathura_document_t* document,
* error occurred
* @return Image buffer or NULL if an error occurred
*/
zathura_image_buffer_t* pdf_page_render(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t* error);
zathura_image_buffer_t* pdf_page_render(zathura_page_t* page, void* mupdf_page, zathura_error_t* error);
/**
* Renders a page onto a cairo object
......@@ -162,6 +162,6 @@ zathura_image_buffer_t* pdf_page_render(zathura_page_t* page, mupdf_page_t* mupd
* @param cairo Cairo object
* @return true if no error occurred, otherwise false
*/
zathura_error_t pdf_page_render_cairo(zathura_page_t* page, mupdf_page_t* mupdf_page, cairo_t* cairo, bool printing);
zathura_error_t pdf_page_render_cairo(zathura_page_t* page, void* mupdf_page, cairo_t* cairo, bool printing);
#endif // PDF_H
......@@ -53,8 +53,10 @@ pdf_page_render_to_buffer(mupdf_document_t* mupdf_document, mupdf_page_t* mupdf_
}
zathura_image_buffer_t*
pdf_page_render(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t* error)
pdf_page_render(zathura_page_t* page, void* data, zathura_error_t* error)
{
mupdf_page_t* mupdf_page = data;
if (page == NULL || mupdf_page == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
......@@ -103,8 +105,10 @@ pdf_page_render(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t*
}
zathura_error_t
pdf_page_render_cairo(zathura_page_t* page, mupdf_page_t* mupdf_page, cairo_t* cairo, bool GIRARA_UNUSED(printing))
pdf_page_render_cairo(zathura_page_t* page, void* data, cairo_t* cairo, bool GIRARA_UNUSED(printing))
{
mupdf_page_t* mupdf_page = data;
if (page == NULL || mupdf_page == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
......
......@@ -8,8 +8,10 @@
#include "utils.h"
girara_list_t*
pdf_page_search_text(zathura_page_t* page, mupdf_page_t* mupdf_page, const char* text, zathura_error_t* error)
pdf_page_search_text(zathura_page_t* page, void* data, const char* text, zathura_error_t* error)
{
mupdf_page_t* mupdf_page = data;
if (page == NULL || text == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
......
......@@ -6,8 +6,10 @@
#include "utils.h"
char*
pdf_page_get_text(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_rectangle_t rectangle, zathura_error_t* error)
pdf_page_get_text(zathura_page_t* page, void* data, zathura_rectangle_t rectangle, zathura_error_t* error)
{
mupdf_page_t* mupdf_page = data;
if (page == NULL || mupdf_page == NULL || mupdf_page->text == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment