Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile tolua++ output as C++ #1740

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions cmake/ToLua.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions lua/libcairo-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@
#define _LIBCAIRO_HELPER_H_

#include <cairo.h>
#include <cstdlib>

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) {
Expand Down
6 changes: 3 additions & 3 deletions lua/libcairo_imlib2_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lua/librsvg-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down