Mark functions as const

This commit is contained in:
Sebastian Ramacher 2018-02-08 22:07:34 +01:00
parent 531ee53b1a
commit 324d88100d
4 changed files with 20 additions and 20 deletions

View file

@ -144,7 +144,7 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* uri,
file = NULL;
/* open document */
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
if (functions->document_open == NULL) {
girara_error("plugin has no open function\n");
goto error_free;
@ -221,7 +221,7 @@ zathura_document_free(zathura_document_t* document)
/* free document */
zathura_error_t error = ZATHURA_ERROR_OK;
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
if (functions->document_free == NULL) {
error = ZATHURA_ERROR_NOT_IMPLEMENTED;
} else {
@ -619,7 +619,7 @@ zathura_document_save_as(zathura_document_t* document, const char* path)
return ZATHURA_ERROR_UNKNOWN;
}
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
if (functions->document_save_as == NULL) {
return ZATHURA_ERROR_NOT_IMPLEMENTED;
}
@ -635,7 +635,7 @@ zathura_document_index_generate(zathura_document_t* document, zathura_error_t* e
return NULL;
}
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
if (functions->document_index_generate == NULL) {
check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED);
return NULL;
@ -652,7 +652,7 @@ zathura_document_attachments_get(zathura_document_t* document, zathura_error_t*
return NULL;
}
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
if (functions->document_attachments_get == NULL) {
check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED);
return NULL;
@ -668,7 +668,7 @@ zathura_document_attachment_save(zathura_document_t* document, const char* attac
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
if (functions->document_attachment_save == NULL) {
return ZATHURA_ERROR_NOT_IMPLEMENTED;
}
@ -684,7 +684,7 @@ zathura_document_get_information(zathura_document_t* document, zathura_error_t*
return NULL;
}
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
if (functions->document_get_information == NULL) {
check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED);
return NULL;

View file

@ -45,7 +45,7 @@ zathura_page_new(zathura_document_t* document, unsigned int index, zathura_error
/* init plugin */
zathura_plugin_t* plugin = zathura_document_get_plugin(document);
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
if (functions->page_init == NULL) {
if (error != NULL) {
@ -88,7 +88,7 @@ zathura_page_free(zathura_page_t* page)
}
zathura_plugin_t* plugin = zathura_document_get_plugin(page->document);
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
if (functions->page_clear == NULL) {
return ZATHURA_ERROR_NOT_IMPLEMENTED;
}
@ -211,7 +211,7 @@ zathura_page_search_text(zathura_page_t* page, const char* text, zathura_error_t
}
zathura_plugin_t* plugin = zathura_document_get_plugin(page->document);
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
if (functions->page_search_text == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_NOT_IMPLEMENTED;
@ -233,7 +233,7 @@ zathura_page_links_get(zathura_page_t* page, zathura_error_t* error)
}
zathura_plugin_t* plugin = zathura_document_get_plugin(page->document);
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
if (functions->page_links_get == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_NOT_IMPLEMENTED;
@ -261,7 +261,7 @@ zathura_page_form_fields_get(zathura_page_t* page, zathura_error_t* error)
}
zathura_plugin_t* plugin = zathura_document_get_plugin(page->document);
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
if (functions->page_form_fields_get == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_NOT_IMPLEMENTED;
@ -289,7 +289,7 @@ zathura_page_images_get(zathura_page_t* page, zathura_error_t* error)
}
zathura_plugin_t* plugin = zathura_document_get_plugin(page->document);
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
if (functions->page_images_get == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_NOT_IMPLEMENTED;
@ -311,7 +311,7 @@ zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathu
}
zathura_plugin_t* plugin = zathura_document_get_plugin(page->document);
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
if (functions->page_image_get_cairo == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_NOT_IMPLEMENTED;
@ -333,7 +333,7 @@ zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathu
}
zathura_plugin_t* plugin = zathura_document_get_plugin(page->document);
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
if (functions->page_get_text == NULL) {
if (error) {
*error = ZATHURA_ERROR_NOT_IMPLEMENTED;
@ -352,7 +352,7 @@ zathura_page_render(zathura_page_t* page, cairo_t* cairo, bool printing)
}
zathura_plugin_t* plugin = zathura_document_get_plugin(page->document);
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
if (functions->page_render_cairo == NULL) {
return ZATHURA_ERROR_NOT_IMPLEMENTED;
}
@ -371,7 +371,7 @@ zathura_page_get_label(zathura_page_t* page, zathura_error_t* error)
}
zathura_plugin_t* plugin = zathura_document_get_plugin(page->document);
zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
if (functions->page_get_label == NULL) {
if (error) {
*error = ZATHURA_ERROR_NOT_IMPLEMENTED;

View file

@ -343,11 +343,11 @@ plugin_add_mimetype(zathura_plugin_t* plugin, const char* mime_type)
}
}
zathura_plugin_functions_t*
const zathura_plugin_functions_t*
zathura_plugin_get_functions(zathura_plugin_t* plugin)
{
if (plugin != NULL) {
return &(plugin->functions);
return &plugin->functions;
} else {
return NULL;
}

View file

@ -63,7 +63,7 @@ girara_list_t* zathura_plugin_manager_get_plugins(zathura_plugin_manager_t* plug
* @param plugin The plugin
* @return The plugin functions
*/
zathura_plugin_functions_t* zathura_plugin_get_functions(zathura_plugin_t* plugin);
const zathura_plugin_functions_t* zathura_plugin_get_functions(zathura_plugin_t* plugin);
/**
* Returns the name of the plugin