diff --git a/ext/fox16_c/FXRbApp.cpp b/ext/fox16_c/FXRbApp.cpp index 7ade711ad506993003c4b2ec68f7088d0b5ecae0..6a61bc4cc32b7ee57769039def468361a5636ea4 100644 --- a/ext/fox16_c/FXRbApp.cpp +++ b/ext/fox16_c/FXRbApp.cpp @@ -26,7 +26,7 @@ #include "FXRbCommon.h" -#ifndef RUBY_1_9 +#if defined(RUBY_1_8) extern "C" { #include "rubysig.h" /* For CHECK_INTS */ } @@ -97,14 +97,14 @@ long FXRbApp::onChoreThreads(FXObject*,FXSelector,void*){ wait.tv_usec=100*sleepTime; // Confirm that this thread can be interrupted, then go to sleep -#ifndef RUBY_1_9 +#if defined(RUBY_1_8) CHECK_INTS; if(!rb_thread_critical) rb_thread_wait_for(wait); #else // if(!rb_thread_critical) rb_thread_wait_for(wait); rb_thread_wait_for(wait); -#endif /* RUBY_1_9 */ +#endif /* RUBY_1_8 */ // Re-register this chore for next time addChore(this,ID_CHORE_THREADS); diff --git a/ext/fox16_c/FXRuby.cpp b/ext/fox16_c/FXRuby.cpp index f933db34f37e1d4dccfc57028fbf512c678010fa..4f2cb144ed48f8f3e9dee390e52eebf72afb1d98 100644 --- a/ext/fox16_c/FXRuby.cpp +++ b/ext/fox16_c/FXRuby.cpp @@ -39,19 +39,19 @@ #include <signal.h> // for definitions of SIGINT, etc. #endif -#ifdef RUBY_1_9 - -#include "ruby/io.h" -#include "ruby/st.h" - -#else +#if defined(RUBY_1_8) extern "C" { #include "st.h" #include "rubyio.h" // for GetOpenFile(), etc. } -#endif /* RUBY_1_9 */ +#else + +#include "ruby/io.h" +#include "ruby/st.h" + +#endif /* RUBY_1_8 */ // Opaque type declaration from SWIG runtime @@ -204,17 +204,17 @@ FXInputHandle FXRbGetWriteFileHandle(VALUE obj) { VALUE vwrite = rb_intern("@write"); if(rb_ivar_defined(obj, vwrite)) obj = rb_ivar_get(obj, vwrite); fd = FIX2INT(rb_funcall(obj, rb_intern("fileno"), 0)); -#elif defined(RUBY_1_9) +#elif defined(RUBY_1_8) + OpenFile *fptr; + GetOpenFile(obj, fptr); + FILE *fpw=GetWriteFile(fptr); + fd = fileno(fpw); +#else rb_io_t *fptr; GetOpenFile(obj, fptr); VALUE wrio = fptr->tied_io_for_writing; if(wrio) obj = wrio; fd = FIX2INT(rb_funcall(obj, rb_intern("fileno"), 0)); -#else - OpenFile *fptr; - GetOpenFile(obj, fptr); - FILE *fpw=GetWriteFile(fptr); - fd = fileno(fpw); #endif #ifdef WIN32 #ifdef __CYGWIN__ diff --git a/ext/fox16_c/extconf.rb b/ext/fox16_c/extconf.rb index ba24adff0a2a13afda8767cf2edf380f675f6914..9e9b75ac1a2be03998c5b2f11a4b42d0efe4899b 100755 --- a/ext/fox16_c/extconf.rb +++ b/ext/fox16_c/extconf.rb @@ -145,8 +145,9 @@ end # Platform-specific modifications do_rake_compiler_setup -# Check for Ruby 1.9 +$CFLAGS += " -DRUBY_1_8" if RUBY_VERSION =~ /1\.8\./ $CFLAGS += " -DRUBY_1_9" if RUBY_VERSION =~ /1\.9\./ +$CFLAGS += " -DRUBY_2_0" if RUBY_VERSION =~ /2\.0\./ # Last step: build the makefile create_makefile("fox16_c")