Skip to content

Commit

Permalink
Compile tolua++ output as C++
Browse files Browse the repository at this point in the history
  • Loading branch information
brndnmtthws committed Feb 23, 2024
1 parent 3bb8188 commit e4bdabc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
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

0 comments on commit e4bdabc

Please sign in to comment.