Skip to content

Instantly share code, notes, and snippets.

@mattn
Created February 26, 2013 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattn/5037786 to your computer and use it in GitHub Desktop.
Save mattn/5037786 to your computer and use it in GitHub Desktop.
diff -r 8b86b69546a9 src/if_ruby.c
--- a/src/if_ruby.c Wed Feb 20 21:26:00 2013 +0100
+++ b/src/if_ruby.c Tue Feb 26 20:20:32 2013 +0900
@@ -189,7 +189,9 @@
#ifndef RUBY19_OR_LATER
#define rb_num2long dll_rb_num2long
#endif
+#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER <= 19
#define rb_num2ulong dll_rb_num2ulong
+#endif
#define rb_obj_alloc dll_rb_obj_alloc
#define rb_obj_as_string dll_rb_obj_as_string
#define rb_obj_id dll_rb_obj_id
@@ -344,6 +346,17 @@
{
return dll_rb_int2big(x);
}
+#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 20
+VALUE
+rb_float_new_in_heap(double d)
+{
+ return dll_rb_float_new(d);
+}
+unsigned long rb_num2ulong(VALUE x)
+{
+ return (long)RSHIFT((SIGNED_VALUE)(x),1);
+}
+#endif
#endif
static HINSTANCE hinstRuby = NULL; /* Instance of ruby.dll */
@@ -434,7 +447,11 @@
#endif
#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18
{"rb_string_value_ptr", (RUBY_PROC*)&dll_rb_string_value_ptr},
+# if DYNAMIC_RUBY_VER <= 19
{"rb_float_new", (RUBY_PROC*)&dll_rb_float_new},
+#else
+ {"rb_float_new_in_heap", (RUBY_PROC*)&dll_rb_float_new},
+# endif
{"rb_ary_new", (RUBY_PROC*)&dll_rb_ary_new},
{"rb_ary_push", (RUBY_PROC*)&dll_rb_ary_push},
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment