From e4bdabc5380ff2d0e164ab0bcda2c3ae7c12010b Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Fri, 23 Feb 2024 09:04:32 -0500 Subject: [PATCH] Compile tolua++ output as C++ --- cmake/ToLua.cmake | 14 +++++++------- lua/libcairo-helper.h | 7 ++++--- lua/libcairo_imlib2_helper.h | 6 +++--- lua/librsvg-helper.h | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/cmake/ToLua.cmake b/cmake/ToLua.cmake index 823f8f58..b5c6d153 100644 --- a/cmake/ToLua.cmake +++ b/cmake/ToLua.cmake @@ -24,20 +24,20 @@ function(wrap_tolua VAR FIL) get_filename_component(ABS_FIL ${FIL} ABSOLUTE) get_filename_component(FIL_WE ${FIL} NAME_WE) - list(APPEND ${VAR} "${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c") + list(APPEND ${VAR} "${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.cc") if(DEFINED ARGV2) get_filename_component(PATCH ${ARGV2} ABSOLUTE) - set(TOLUA_OUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}-orig.c) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c + set(TOLUA_OUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}-orig.cc) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.cc COMMAND ${APP_PATCH} -s ${TOLUA_OUT} ${PATCH} -o - ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c + ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.cc DEPENDS ${TOLUA_OUT} ${PATCH} - COMMENT "Patching lib${FIL_WE}-orig.c" + COMMENT "Patching lib${FIL_WE}-orig.cc" VERBATIM) set_source_files_properties(${TOLUA_OUT} PROPERTIES GENERATED TRUE) else() - set(TOLUA_OUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c) + set(TOLUA_OUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.cc) endif(DEFINED ARGV2) # Call toluapp from 3rdparty/ path directly. The last argument to toluapp is @@ -54,7 +54,7 @@ function(wrap_tolua VAR FIL) ${${VAR}} PROPERTIES COMPILE_FLAGS - "-Wno-bad-function-cast -Wno-unused-parameter -Wno-cast-qual -Wno-error=pedantic" + "-Wno-unused-parameter -Wno-cast-qual -Wno-error=pedantic" ) set(${VAR} ${${VAR}} PARENT_SCOPE) diff --git a/lua/libcairo-helper.h b/lua/libcairo-helper.h index 6c7c1a0e..2e48c0ae 100644 --- a/lua/libcairo-helper.h +++ b/lua/libcairo-helper.h @@ -26,17 +26,18 @@ #define _LIBCAIRO_HELPER_H_ #include +#include cairo_text_extents_t *create_cairo_text_extents_t(void) { - return calloc(1, sizeof(cairo_text_extents_t)); + return (cairo_text_extents_t *)calloc(1, sizeof(cairo_text_extents_t)); } cairo_font_extents_t *create_cairo_font_extents_t(void) { - return calloc(1, sizeof(cairo_font_extents_t)); + return (cairo_font_extents_t *)calloc(1, sizeof(cairo_font_extents_t)); } cairo_matrix_t *create_cairo_matrix_t(void) { - return calloc(1, sizeof(cairo_matrix_t)); + return (cairo_matrix_t *)calloc(1, sizeof(cairo_matrix_t)); } void destroy_cairo_text_extents_t(cairo_text_extents_t *pointer) { diff --git a/lua/libcairo_imlib2_helper.h b/lua/libcairo_imlib2_helper.h index 3b5718a0..a1b39ba2 100644 --- a/lua/libcairo_imlib2_helper.h +++ b/lua/libcairo_imlib2_helper.h @@ -36,7 +36,7 @@ void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y, Imlib_Image premul; cairo_surface_t *result; cairo_t *cr; - Imlib_Image *image = imlib_load_image(file); + auto image = imlib_load_image(file); if (!image) { return; } imlib_context_set_image(image); @@ -64,8 +64,8 @@ void cairo_draw_image(const char *file, cairo_surface_t *cs, int x, int y, /* now pass the result to cairo */ result = cairo_image_surface_create_for_data( - (void *)imlib_image_get_data_for_reading_only(), CAIRO_FORMAT_ARGB32, - scaled_w, scaled_h, sizeof(DATA32) * scaled_w); + (unsigned char *)imlib_image_get_data_for_reading_only(), + CAIRO_FORMAT_ARGB32, scaled_w, scaled_h, sizeof(DATA32) * scaled_w); cr = cairo_create(cs); cairo_set_source_surface(cr, result, x, y); diff --git a/lua/librsvg-helper.h b/lua/librsvg-helper.h index 3c94528c..b09e0410 100644 --- a/lua/librsvg-helper.h +++ b/lua/librsvg-helper.h @@ -93,7 +93,7 @@ int rsvg_destroy_handle(RsvgHandle *handle) { } RsvgRectangle *rsvg_rectangle_create(void) { - return calloc(1, sizeof(RsvgRectangle)); + return (RsvgRectangle *)calloc(1, sizeof(RsvgRectangle)); } void rsvg_rectangle_destroy(RsvgRectangle *rect) { free(rect); }