[ruby-oci8-commit] [247] trunk/ruby-oci8: * ext/oci8/ocinumber.c: fix for ruby-1.9.0-1.
nobody at rubyforge.org
nobody at rubyforge.org
Tue Mar 4 01:21:04 EST 2008
Revision: 247
Author: kubo
Date: 2008-03-04 01:21:04 -0500 (Tue, 04 Mar 2008)
Log Message:
-----------
* ext/oci8/ocinumber.c: fix for ruby-1.9.0-1.
The arguments of rb_num_coerce_cmp() and rb_num_coerce_bin()
are changed in ruby-1.9.0-1.
Modified Paths:
--------------
trunk/ruby-oci8/ChangeLog
trunk/ruby-oci8/ext/oci8/ocinumber.c
Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog 2008-02-27 08:23:39 UTC (rev 246)
+++ trunk/ruby-oci8/ChangeLog 2008-03-04 06:21:04 UTC (rev 247)
@@ -1,3 +1,8 @@
+2008-03-04 KUBO Takehiro <kubo at jiubao.org>
+ * ext/oci8/ocinumber.c: fix for ruby-1.9.0-1.
+ The arguments of rb_num_coerce_cmp() and rb_num_coerce_bin()
+ are changed in ruby-1.9.0-1.
+
2008-2-27 Liming Lian <liming.lian at oracle.com>
Add new feature: Array DML
* lib/oci8/oci8.rb: add three new methods for Array DML to OCI8::Cursor:
Modified: trunk/ruby-oci8/ext/oci8/ocinumber.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/ocinumber.c 2008-02-27 08:23:39 UTC (rev 246)
+++ trunk/ruby-oci8/ext/oci8/ocinumber.c 2008-03-04 06:21:04 UTC (rev 247)
@@ -11,6 +11,15 @@
#include "oci8.h"
#include <orl.h>
+#ifndef RUBY_VM
+/* ruby 1.8 */
+#define rb_num_coerce_cmp(x, y, id) rb_num_coerce_cmp((x), (y))
+#define rb_num_coerce_bin(x, y, id) rb_num_coerce_bin((x), (y))
+#endif
+
+static ID id_power; /* rb_intern("**") */
+static ID id_cmp; /* rb_intern("<=>") */
+
static VALUE cOCINumber;
static OCINumber const_p1; /* +1 */
static OCINumber const_p10; /* +10 */
@@ -541,7 +550,7 @@
/* change to OCINumber */
if (!set_oci_number_from_num(&n, rhs, 0))
- return rb_num_coerce_bin(lhs, rhs);
+ return rb_num_coerce_bin(lhs, rhs, '+');
/* add */
oci_lc(OCINumberAdd(oci8_errhp, _NUMBER(lhs), &n, &r));
return oci8_make_ocinumber(&r);
@@ -561,7 +570,7 @@
/* change to OCINumber */
if (!set_oci_number_from_num(&n, rhs, 0))
- return rb_num_coerce_bin(lhs, rhs);
+ return rb_num_coerce_bin(lhs, rhs, '-');
/* subtracting */
oci_lc(OCINumberSub(oci8_errhp, _NUMBER(lhs), &n, &r));
return oci8_make_ocinumber(&r);
@@ -581,7 +590,7 @@
/* change to OCINumber */
if (!set_oci_number_from_num(&n, rhs, 0))
- return rb_num_coerce_bin(lhs, rhs);
+ return rb_num_coerce_bin(lhs, rhs, '*');
/* multiply */
oci_lc(OCINumberMul(oci8_errhp, _NUMBER(lhs), &n, &r));
return oci8_make_ocinumber(&r);
@@ -602,7 +611,7 @@
/* change to OCINumber */
if (!set_oci_number_from_num(&n, rhs, 0))
- return rb_num_coerce_bin(lhs, rhs);
+ return rb_num_coerce_bin(lhs, rhs, '/');
/* check whether argument is not zero. */
oci_lc(OCINumberIsZero(oci8_errhp, &n, &is_zero));
if (is_zero)
@@ -626,7 +635,7 @@
/* change to OCINumber */
if (!set_oci_number_from_num(&n, rhs, 0))
- return rb_num_coerce_bin(lhs, rhs);
+ return rb_num_coerce_bin(lhs, rhs, '%');
/* check whether argument is not zero. */
oci_lc(OCINumberIsZero(oci8_errhp, &n, &is_zero));
if (is_zero)
@@ -654,7 +663,7 @@
} else {
/* change to OCINumber */
if (!set_oci_number_from_num(&n, rhs, 0))
- return rb_num_coerce_bin(lhs, rhs);
+ return rb_num_coerce_bin(lhs, rhs, id_power);
/* check whether num1 is negative. */
oci_lc(OCINumberSign(oci8_errhp, _NUMBER(lhs), &sign));
/* check whether num2 is an integral value. */
@@ -681,7 +690,7 @@
/* change to OCINumber */
if (!set_oci_number_from_num(&n, rhs, 0))
- return rb_num_coerce_bin(lhs, rhs);
+ return rb_num_coerce_cmp(lhs, rhs, id_cmp);
/* compare */
oci_lc(OCINumberCmp(oci8_errhp, _NUMBER(lhs), &n, &r));
return INT2NUM(r);
@@ -1088,6 +1097,9 @@
VALUE obj_PI;
signed long sl;
+ id_power = rb_intern("**");
+ id_cmp = rb_intern("<=>");
+
#if 0 /* for rdoc */
cOCI8 = rb_define_class("OCI8", rb_cObject);
#endif
More information about the ruby-oci8-commit
mailing list