Skip to content

Commit

Permalink
Fix "wrong type of arguments for cairo_set_dash", sf.net #3014648
Browse files Browse the repository at this point in the history
I am not particularly proud of this solution. If you have a better one, feel free to implement
it.
  • Loading branch information
labath committed Jun 13, 2010
1 parent 2232641 commit c80deb2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 20 deletions.
44 changes: 26 additions & 18 deletions cmake/ToLua.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,34 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

function(wrap_tolua VAR)
if(NOT ARGN)
message(SEND_ERROR "Error: wrap_tolua called without any files")
return()
endif(NOT ARGN)

function(wrap_tolua VAR FIL)
SET(INCL)
SET(${VAR})
FOREACH(FIL ${ARGN})
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")

ADD_CUSTOM_COMMAND( OUTPUT ${${VAR}} ${INCL} COMMAND ${APP_TOLUA} -n
${FIL_WE} -o ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c ${ABS_FIL} DEPENDS
${ABS_FIL} COMMENT "Running tolua++ on ${FIL}"
VERBATIM )

SET_SOURCE_FILES_PROPERTIES(${${VAR}} ${INCL} PROPERTIES GENERATED TRUE)
ENDFOREACH(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")

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
COMMAND patch -s ${TOLUA_OUT} ${PATCH} -o ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c
DEPENDS ${TOLUA_OUT} ${PATCH}
COMMENT "Patching lib${FIL_WE}-orig.c"
VERBATIM)
SET_SOURCE_FILES_PROPERTIES(${TOLUA_OUT} PROPERTIES GENERATED TRUE)
else()
SET(TOLUA_OUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c)
endif(DEFINED ARGV2)

ADD_CUSTOM_COMMAND( OUTPUT ${TOLUA_OUT} ${INCL} COMMAND ${APP_TOLUA} -n
${FIL_WE} -o ${TOLUA_OUT} ${ABS_FIL} DEPENDS
${ABS_FIL} COMMENT "Running tolua++ on ${FIL}"
VERBATIM )

SET_SOURCE_FILES_PROPERTIES(${${VAR}} ${INCL} PROPERTIES GENERATED TRUE)


SET(${VAR} ${${VAR}} PARENT_SCOPE)

Expand Down
4 changes: 3 additions & 1 deletion lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ set(CMAKE_CXX_FLAGS_DEBUG "-ggdb")

if(BUILD_LUA_CAIRO)
include_directories(${luacairo_includes} ${CMAKE_CURRENT_SOURCE_DIR})
wrap_tolua(luacairo_src cairo.pkg)
# cairo_set_dash() needs this special hack to work properly
# if you have a better solution, please let me know
wrap_tolua(luacairo_src cairo.pkg libcairo.patch)

add_library(cairo SHARED ${luacairo_src})

Expand Down
2 changes: 1 addition & 1 deletion lua/cairo.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ typedef enum _cairo_line_join {

void cairo_set_line_join(cairo_t * cr, cairo_line_join_t line_join);

void cairo_set_dash(cairo_t * cr, const double *dashes, int num_dashes, double offset);
void cairo_set_dash(cairo_t * cr, const double dashes[num_dashes], int num_dashes, double offset);

void cairo_set_miter_limit(cairo_t * cr, double limit);

Expand Down
16 changes: 16 additions & 0 deletions lua/libcairo.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- lua/libcairo.c~ 2010-06-11 23:14:43.000000000 +0200
+++ lua/libcairo.c 2010-06-12 10:47:51.000000000 +0200
@@ -1452,12 +1452,12 @@
#endif
{
struct _cairo* cr = (( struct _cairo*) tolua_tousertype(tolua_S,1,0));
+ int num_dashes = ((int) tolua_tonumber(tolua_S,3,0));
#ifdef __cplusplus
double* dashes = Mtolua_new_dim(double, num_dashes);
#else
double* dashes = (double*) malloc((num_dashes)*sizeof(double));
#endif
- int num_dashes = ((int) tolua_tonumber(tolua_S,3,0));
double offset = ((double) tolua_tonumber(tolua_S,4,0));
{
#ifndef TOLUA_RELEASE

0 comments on commit c80deb2

Please sign in to comment.