From ae29b502405ee60e29b7a7d7a1cb269ff2f5a7e9 Mon Sep 17 00:00:00 2001 From: Lyle Johnson Date: Wed, 1 Sep 2004 02:37:54 +0000 Subject: [PATCH] Corrections for Ruby 1.6 compatibility. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6190 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/ruby/rubyhead.swg | 5 ++++- Source/Modules/ruby.cxx | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg index 90becd694..3dd369d9d 100644 --- a/Lib/ruby/rubyhead.swg +++ b/Lib/ruby/rubyhead.swg @@ -58,13 +58,16 @@ #ifdef __cplusplus # ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ +# define PROTECTFUNC(f) ((VALUE (*)()) f) # define VALUEFUNC(f) ((VALUE (*)()) f) # define VOIDFUNC(f) ((void (*)()) f) # else # ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ +# define PROTECTFUNC(f) ((VALUE (*)()) f) # define VALUEFUNC(f) ((VALUE (*)()) f) # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# else /* These definitions should work for Ruby 1.7 */ +# else /* These definitions should work for Ruby 1.7+ */ +# define PROTECTFUNC(f) ((VALUE (*)()) f) # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) # endif diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 85f49e359..c407471d6 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2016,7 +2016,7 @@ public: Printv(w->code, "args.argv = 0;\n", NIL); } Printf(w->code, - "result = rb_protect((VALUE(*)(VALUE)) %s, reinterpret_cast(&args), &status);\n", bodyName, rescueName); + "result = rb_protect(PROTECTFUNC(%s), reinterpret_cast(&args), &status);\n", bodyName, rescueName); Printf(w->code, "if (status) {\n"); Printf(w->code,