use correct macros in ruby code so code compiles in 32bit and 64bit mode

This commit is contained in:
Edward Rudd 2014-01-01 11:20:42 -05:00
parent 1ce4970d62
commit 5c0295e972
2 changed files with 23 additions and 23 deletions

View File

@ -93,7 +93,7 @@ template<class C>
static inline C * static inline C *
getPrivateDataCheck(VALUE self, const rb_data_type_struct &type) getPrivateDataCheck(VALUE self, const rb_data_type_struct &type)
{ {
void *obj = rb_check_typeddata(self, &type); void *obj = Check_TypedStruct(self, &type);
return static_cast<C*>(obj); return static_cast<C*>(obj);
} }
@ -197,11 +197,11 @@ rb_float_arg(VALUE arg, double *out, int argPos = 0)
switch (rb_type(arg)) switch (rb_type(arg))
{ {
case RUBY_T_FLOAT : case RUBY_T_FLOAT :
*out = rb_float_value(arg); *out = RFLOAT_VALUE(arg);
break; break;
case RUBY_T_FIXNUM : case RUBY_T_FIXNUM :
*out = rb_fix2int(arg); *out = FIX2INT(arg);
break; break;
default: default:
@ -216,11 +216,11 @@ rb_int_arg(VALUE arg, int *out, int argPos = 0)
{ {
case RUBY_T_FLOAT : case RUBY_T_FLOAT :
// FIXME check int range? // FIXME check int range?
*out = rb_num2long(arg); *out = NUM2LONG(arg);
break; break;
case RUBY_T_FIXNUM : case RUBY_T_FIXNUM :
*out = rb_fix2int(arg); *out = FIX2INT(arg);
break; break;
default: default:

View File

@ -47,18 +47,18 @@ RB_METHOD(tableResize)
{ {
default: default:
case 1: case 1:
t->resize(rb_fix2int(argv[0])); t->resize(FIX2INT(argv[0]));
return Qnil; return Qnil;
case 2: case 2:
t->resize(rb_fix2int(argv[0]), t->resize(FIX2INT(argv[0]),
rb_fix2int(argv[1])); FIX2INT(argv[1]));
return Qnil; return Qnil;
case 3: case 3:
t->resize(rb_fix2int(argv[0]), t->resize(FIX2INT(argv[0]),
rb_fix2int(argv[1]), FIX2INT(argv[1]),
rb_fix2int(argv[2])); FIX2INT(argv[2]));
return Qnil; return Qnil;
} }
} }
@ -82,11 +82,11 @@ RB_METHOD(tableGetAt)
int x, y, z; int x, y, z;
x = y = z = 0; x = y = z = 0;
x = rb_num2int(argv[0]); x = NUM2INT(argv[0]);
if (argc > 1) if (argc > 1)
y = rb_num2int(argv[1]); y = NUM2INT(argv[1]);
if (argc > 2) if (argc > 2)
z = rb_num2int(argv[2]); z = NUM2INT(argv[2]);
if (argc > 3) if (argc > 3)
rb_raise(rb_eArgError, "wrong number of arguments"); rb_raise(rb_eArgError, "wrong number of arguments");
@ -117,19 +117,19 @@ RB_METHOD(tableSetAt)
{ {
default: default:
case 2 : case 2 :
x = rb_fix2int(argv[0]); x = FIX2INT(argv[0]);
value = rb_fix2int(argv[1]); value = FIX2INT(argv[1]);
break; break;
case 3 : case 3 :
x = rb_fix2int(argv[0]); x = FIX2INT(argv[0]);
y = rb_fix2int(argv[1]); y = FIX2INT(argv[1]);
value = rb_fix2int(argv[2]); value = FIX2INT(argv[2]);
break; break;
case 4 : case 4 :
x = rb_fix2int(argv[0]); x = FIX2INT(argv[0]);
y = rb_fix2int(argv[1]); y = FIX2INT(argv[1]);
z = rb_fix2int(argv[2]); z = FIX2INT(argv[2]);
value = rb_fix2int(argv[3]); value = FIX2INT(argv[3]);
break; break;
} }