[ruby-oci8-commit] [411] trunk/ruby-oci8/ext/oci8: * ext/oci8/extconf.rb, ext/oci8/oci8.h, ext /oci8/oci8lib.c,

nobody at rubyforge.org nobody at rubyforge.org
Sun Sep 5 09:07:22 EDT 2010


Revision: 411
Author:   kubo
Date:     2010-09-05 09:07:21 -0400 (Sun, 05 Sep 2010)

Log Message:
-----------
* ext/oci8/extconf.rb, ext/oci8/oci8.h, ext/oci8/oci8lib.c,
  ext/oci8/ocinumber.c: use rb_intern() to retrieve IDs of '+', '-',
    '*' and '/' on rubinus.
* ext/oci8/oradate.c: use rb_call_super() instead of
    rb_obj_init_copy(), which is not declared in rubinus.

Modified Paths:
--------------
    branches/ruby-oci8-2.0/ChangeLog
    branches/ruby-oci8-2.0/ext/oci8/extconf.rb
    branches/ruby-oci8-2.0/ext/oci8/oci8.h
    branches/ruby-oci8-2.0/ext/oci8/oci8lib.c
    branches/ruby-oci8-2.0/ext/oci8/ocinumber.c
    branches/ruby-oci8-2.0/ext/oci8/oradate.c
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/extconf.rb
    trunk/ruby-oci8/ext/oci8/oci8.h
    trunk/ruby-oci8/ext/oci8/oci8lib.c
    trunk/ruby-oci8/ext/oci8/ocinumber.c
    trunk/ruby-oci8/ext/oci8/oradate.c

Modified: branches/ruby-oci8-2.0/ChangeLog
===================================================================
--- branches/ruby-oci8-2.0/ChangeLog	2010-08-28 09:26:45 UTC (rev 410)
+++ branches/ruby-oci8-2.0/ChangeLog	2010-09-05 13:07:21 UTC (rev 411)
@@ -1,3 +1,10 @@
+2010-09-05  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/extconf.rb, ext/oci8/oci8.h, ext/oci8/oci8lib.c,
+	  ext/oci8/ocinumber.c: use rb_intern() to retrieve IDs of '+', '-',
+	    '*' and '/' on rubinus.
+	* ext/oci8/oradate.c: use rb_call_super() instead of
+	    rb_obj_init_copy(), which is not declared in rubinus.
+
 2010-08-28  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/env.c: fix for rubinius.
 

Modified: branches/ruby-oci8-2.0/ext/oci8/extconf.rb
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/extconf.rb	2010-08-28 09:26:45 UTC (rev 410)
+++ branches/ruby-oci8-2.0/ext/oci8/extconf.rb	2010-09-05 13:07:21 UTC (rev 411)
@@ -130,6 +130,9 @@
 
 $defs << "-DInit_oci8lib=Init_#{so_basename}"
 $defs << "-Doci8lib=#{so_basename}"
+if defined? RUBY_ENGINE and RUBY_ENGINE == 'rbx'
+  $defs << "-DCHAR_IS_NOT_A_SHORTCUT_TO_ID"
+end
 
 create_header()
 

Modified: branches/ruby-oci8-2.0/ext/oci8/oci8.h
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/oci8.h	2010-08-28 09:26:45 UTC (rev 410)
+++ branches/ruby-oci8-2.0/ext/oci8/oci8.h	2010-09-05 13:07:21 UTC (rev 411)
@@ -394,6 +394,17 @@
 extern ID oci8_id_set;
 extern ID oci8_id_keys;
 extern ID oci8_id_oci8_class;
+#ifdef CHAR_IS_NOT_A_SHORTCUT_TO_ID
+extern ID oci8_id_add_op; /* ID of the addition operator '+' */
+extern ID oci8_id_sub_op; /* ID of the subtraction operator '-' */
+extern ID oci8_id_mul_op; /* ID of the multiplication operator '*' */
+extern ID oci8_id_div_op; /* ID of the division operator '/' */
+#else
+#define oci8_id_add_op '+'
+#define oci8_id_sub_op '-'
+#define oci8_id_mul_op '*'
+#define oci8_id_div_op '/'
+#endif
 extern int oci8_in_finalizer;
 extern VALUE oci8_cOCIHandle;
 void oci8_base_free(oci8_base_t *base);

Modified: branches/ruby-oci8-2.0/ext/oci8/oci8lib.c
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/oci8lib.c	2010-08-28 09:26:45 UTC (rev 410)
+++ branches/ruby-oci8-2.0/ext/oci8/oci8lib.c	2010-09-05 13:07:21 UTC (rev 411)
@@ -15,6 +15,12 @@
 ID oci8_id_set;
 ID oci8_id_keys;
 ID oci8_id_oci8_class;
+#ifdef CHAR_IS_NOT_A_SHORTCUT_TO_ID
+ID oci8_id_add_op;
+ID oci8_id_sub_op;
+ID oci8_id_mul_op;
+ID oci8_id_div_op;
+#endif
 int oci8_in_finalizer = 0;
 VALUE oci8_cOCIHandle;
 
@@ -65,6 +71,12 @@
     oci8_id_set = rb_intern("set");
     oci8_id_keys = rb_intern("keys");
     oci8_id_oci8_class = rb_intern("__oci8_class__");
+#ifdef CHAR_IS_NOT_A_SHORTCUT_TO_ID
+    oci8_id_add_op = rb_intern("+");
+    oci8_id_sub_op = rb_intern("-");
+    oci8_id_mul_op = rb_intern("*");
+    oci8_id_div_op = rb_intern("/");
+#endif
     rb_set_end_proc(at_exit_func, Qnil);
 
     Init_oci8_error();

Modified: branches/ruby-oci8-2.0/ext/oci8/ocinumber.c
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/ocinumber.c	2010-08-28 09:26:45 UTC (rev 410)
+++ branches/ruby-oci8-2.0/ext/oci8/ocinumber.c	2010-09-05 13:07:21 UTC (rev 411)
@@ -724,13 +724,13 @@
         oci_lc(OCINumberAdd(errhp, _NUMBER(lhs), _NUMBER(rhs), &r));
         return oci8_make_ocinumber(&r, errhp);
     case T_FLOAT:
-        return rb_funcall(onum_to_f(lhs), '+', 1, rhs);
+        return rb_funcall(onum_to_f(lhs), oci8_id_add_op, 1, rhs);
     case RBOCI8_T_RATIONAL:
-        return rb_funcall(onum_to_r(lhs), '+', 1, rhs);
+        return rb_funcall(onum_to_r(lhs), oci8_id_add_op, 1, rhs);
     case RBOCI8_T_BIGDECIMAL:
-        return rb_funcall(onum_to_d(lhs), '+', 1, rhs);
+        return rb_funcall(onum_to_d(lhs), oci8_id_add_op, 1, rhs);
     }
-    return rb_num_coerce_bin(lhs, rhs, '+');
+    return rb_num_coerce_bin(lhs, rhs, oci8_id_add_op);
 }
 
 /*
@@ -758,13 +758,13 @@
         oci_lc(OCINumberSub(errhp, _NUMBER(lhs), _NUMBER(rhs), &r));
         return oci8_make_ocinumber(&r, errhp);
     case T_FLOAT:
-        return rb_funcall(onum_to_f(lhs), '-', 1, rhs);
+        return rb_funcall(onum_to_f(lhs), oci8_id_sub_op, 1, rhs);
     case RBOCI8_T_RATIONAL:
-        return rb_funcall(onum_to_r(lhs), '-', 1, rhs);
+        return rb_funcall(onum_to_r(lhs), oci8_id_sub_op, 1, rhs);
     case RBOCI8_T_BIGDECIMAL:
-        return rb_funcall(onum_to_d(lhs), '-', 1, rhs);
+        return rb_funcall(onum_to_d(lhs), oci8_id_sub_op, 1, rhs);
     }
-    return rb_num_coerce_bin(lhs, rhs, '-');
+    return rb_num_coerce_bin(lhs, rhs, oci8_id_sub_op);
 }
 
 /*
@@ -791,13 +791,13 @@
         oci_lc(OCINumberMul(errhp, _NUMBER(lhs), _NUMBER(rhs), &r));
         return oci8_make_ocinumber(&r, errhp);
     case T_FLOAT:
-        return rb_funcall(onum_to_f(lhs), '*', 1, rhs);
+        return rb_funcall(onum_to_f(lhs), oci8_id_mul_op, 1, rhs);
     case RBOCI8_T_RATIONAL:
-        return rb_funcall(onum_to_r(lhs), '*', 1, rhs);
+        return rb_funcall(onum_to_r(lhs), oci8_id_mul_op, 1, rhs);
     case RBOCI8_T_BIGDECIMAL:
-        return rb_funcall(onum_to_d(lhs), '*', 1, rhs);
+        return rb_funcall(onum_to_d(lhs), oci8_id_mul_op, 1, rhs);
     }
-    return rb_num_coerce_bin(lhs, rhs, '*');
+    return rb_num_coerce_bin(lhs, rhs, oci8_id_mul_op);
 }
 
 /*
@@ -833,13 +833,13 @@
         oci_lc(OCINumberDiv(errhp, _NUMBER(lhs), _NUMBER(rhs), &r));
         return oci8_make_ocinumber(&r, errhp);
     case T_FLOAT:
-        return rb_funcall(onum_to_f(lhs), '/', 1, rhs);
+        return rb_funcall(onum_to_f(lhs), oci8_id_div_op, 1, rhs);
     case RBOCI8_T_RATIONAL:
-        return rb_funcall(onum_to_r(lhs), '/', 1, rhs);
+        return rb_funcall(onum_to_r(lhs), oci8_id_div_op, 1, rhs);
     case RBOCI8_T_BIGDECIMAL:
-        return rb_funcall(onum_to_d(lhs), '/', 1, rhs);
+        return rb_funcall(onum_to_d(lhs), oci8_id_div_op, 1, rhs);
     }
-    return rb_num_coerce_bin(lhs, rhs, '/');
+    return rb_num_coerce_bin(lhs, rhs, oci8_id_div_op);
 }
 
 /*

Modified: branches/ruby-oci8-2.0/ext/oci8/oradate.c
===================================================================
--- branches/ruby-oci8-2.0/ext/oci8/oradate.c	2010-08-28 09:26:45 UTC (rev 410)
+++ branches/ruby-oci8-2.0/ext/oci8/oradate.c	2010-09-05 13:07:21 UTC (rev 411)
@@ -146,7 +146,7 @@
 {
     ora_date_t *l, *r;
 
-    rb_obj_init_copy(lhs, rhs);
+    rb_call_super(1, &rhs);
     Data_Get_Struct(lhs, ora_date_t, l);
     Data_Get_Struct(rhs, ora_date_t, r);
     memcpy(l, r, sizeof(ora_date_t));

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2010-08-28 09:26:45 UTC (rev 410)
+++ trunk/ruby-oci8/ChangeLog	2010-09-05 13:07:21 UTC (rev 411)
@@ -1,3 +1,10 @@
+2010-09-05  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/extconf.rb, ext/oci8/oci8.h, ext/oci8/oci8lib.c,
+	  ext/oci8/ocinumber.c: use rb_intern() to retrieve IDs of '+', '-',
+	    '*' and '/' on rubinus.
+	* ext/oci8/oradate.c: use rb_call_super() instead of
+	    rb_obj_init_copy(), which is not declared in rubinus.
+
 2010-08-28  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/env.c: fix for rubinius.
 

Modified: trunk/ruby-oci8/ext/oci8/extconf.rb
===================================================================
--- trunk/ruby-oci8/ext/oci8/extconf.rb	2010-08-28 09:26:45 UTC (rev 410)
+++ trunk/ruby-oci8/ext/oci8/extconf.rb	2010-09-05 13:07:21 UTC (rev 411)
@@ -133,6 +133,9 @@
 $defs << "-DInit_oci8lib=Init_#{so_basename}"
 $defs << "-Doci8lib=#{so_basename}"
 $defs << "-DOCI8LIB_VERSION=\\\"#{RUBY_OCI8_VERSION}\\\""
+if defined? RUBY_ENGINE and RUBY_ENGINE == 'rbx'
+  $defs << "-DCHAR_IS_NOT_A_SHORTCUT_TO_ID"
+end
 
 create_header()
 

Modified: trunk/ruby-oci8/ext/oci8/oci8.h
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.h	2010-08-28 09:26:45 UTC (rev 410)
+++ trunk/ruby-oci8/ext/oci8/oci8.h	2010-09-05 13:07:21 UTC (rev 411)
@@ -401,6 +401,17 @@
 extern ID oci8_id_set;
 extern ID oci8_id_keys;
 extern ID oci8_id_oci8_class;
+#ifdef CHAR_IS_NOT_A_SHORTCUT_TO_ID
+extern ID oci8_id_add_op; /* ID of the addition operator '+' */
+extern ID oci8_id_sub_op; /* ID of the subtraction operator '-' */
+extern ID oci8_id_mul_op; /* ID of the multiplication operator '*' */
+extern ID oci8_id_div_op; /* ID of the division operator '/' */
+#else
+#define oci8_id_add_op '+'
+#define oci8_id_sub_op '-'
+#define oci8_id_mul_op '*'
+#define oci8_id_div_op '/'
+#endif
 extern int oci8_in_finalizer;
 extern VALUE oci8_cOCIHandle;
 void oci8_base_free(oci8_base_t *base);

Modified: trunk/ruby-oci8/ext/oci8/oci8lib.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8lib.c	2010-08-28 09:26:45 UTC (rev 410)
+++ trunk/ruby-oci8/ext/oci8/oci8lib.c	2010-09-05 13:07:21 UTC (rev 411)
@@ -15,6 +15,12 @@
 ID oci8_id_set;
 ID oci8_id_keys;
 ID oci8_id_oci8_class;
+#ifdef CHAR_IS_NOT_A_SHORTCUT_TO_ID
+ID oci8_id_add_op;
+ID oci8_id_sub_op;
+ID oci8_id_mul_op;
+ID oci8_id_div_op;
+#endif
 int oci8_in_finalizer = 0;
 VALUE oci8_cOCIHandle;
 
@@ -65,6 +71,12 @@
     oci8_id_set = rb_intern("set");
     oci8_id_keys = rb_intern("keys");
     oci8_id_oci8_class = rb_intern("__oci8_class__");
+#ifdef CHAR_IS_NOT_A_SHORTCUT_TO_ID
+    oci8_id_add_op = rb_intern("+");
+    oci8_id_sub_op = rb_intern("-");
+    oci8_id_mul_op = rb_intern("*");
+    oci8_id_div_op = rb_intern("/");
+#endif
     rb_set_end_proc(at_exit_func, Qnil);
 
     Init_oci8_error();

Modified: trunk/ruby-oci8/ext/oci8/ocinumber.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/ocinumber.c	2010-08-28 09:26:45 UTC (rev 410)
+++ trunk/ruby-oci8/ext/oci8/ocinumber.c	2010-09-05 13:07:21 UTC (rev 411)
@@ -724,13 +724,13 @@
         oci_lc(OCINumberAdd(errhp, _NUMBER(lhs), _NUMBER(rhs), &r));
         return oci8_make_ocinumber(&r, errhp);
     case T_FLOAT:
-        return rb_funcall(onum_to_f(lhs), '+', 1, rhs);
+        return rb_funcall(onum_to_f(lhs), oci8_id_add_op, 1, rhs);
     case RBOCI8_T_RATIONAL:
-        return rb_funcall(onum_to_r(lhs), '+', 1, rhs);
+        return rb_funcall(onum_to_r(lhs), oci8_id_add_op, 1, rhs);
     case RBOCI8_T_BIGDECIMAL:
-        return rb_funcall(onum_to_d(lhs), '+', 1, rhs);
+        return rb_funcall(onum_to_d(lhs), oci8_id_add_op, 1, rhs);
     }
-    return rb_num_coerce_bin(lhs, rhs, '+');
+    return rb_num_coerce_bin(lhs, rhs, oci8_id_add_op);
 }
 
 /*
@@ -758,13 +758,13 @@
         oci_lc(OCINumberSub(errhp, _NUMBER(lhs), _NUMBER(rhs), &r));
         return oci8_make_ocinumber(&r, errhp);
     case T_FLOAT:
-        return rb_funcall(onum_to_f(lhs), '-', 1, rhs);
+        return rb_funcall(onum_to_f(lhs), oci8_id_sub_op, 1, rhs);
     case RBOCI8_T_RATIONAL:
-        return rb_funcall(onum_to_r(lhs), '-', 1, rhs);
+        return rb_funcall(onum_to_r(lhs), oci8_id_sub_op, 1, rhs);
     case RBOCI8_T_BIGDECIMAL:
-        return rb_funcall(onum_to_d(lhs), '-', 1, rhs);
+        return rb_funcall(onum_to_d(lhs), oci8_id_sub_op, 1, rhs);
     }
-    return rb_num_coerce_bin(lhs, rhs, '-');
+    return rb_num_coerce_bin(lhs, rhs, oci8_id_sub_op);
 }
 
 /*
@@ -791,13 +791,13 @@
         oci_lc(OCINumberMul(errhp, _NUMBER(lhs), _NUMBER(rhs), &r));
         return oci8_make_ocinumber(&r, errhp);
     case T_FLOAT:
-        return rb_funcall(onum_to_f(lhs), '*', 1, rhs);
+        return rb_funcall(onum_to_f(lhs), oci8_id_mul_op, 1, rhs);
     case RBOCI8_T_RATIONAL:
-        return rb_funcall(onum_to_r(lhs), '*', 1, rhs);
+        return rb_funcall(onum_to_r(lhs), oci8_id_mul_op, 1, rhs);
     case RBOCI8_T_BIGDECIMAL:
-        return rb_funcall(onum_to_d(lhs), '*', 1, rhs);
+        return rb_funcall(onum_to_d(lhs), oci8_id_mul_op, 1, rhs);
     }
-    return rb_num_coerce_bin(lhs, rhs, '*');
+    return rb_num_coerce_bin(lhs, rhs, oci8_id_mul_op);
 }
 
 /*
@@ -833,13 +833,13 @@
         oci_lc(OCINumberDiv(errhp, _NUMBER(lhs), _NUMBER(rhs), &r));
         return oci8_make_ocinumber(&r, errhp);
     case T_FLOAT:
-        return rb_funcall(onum_to_f(lhs), '/', 1, rhs);
+        return rb_funcall(onum_to_f(lhs), oci8_id_div_op, 1, rhs);
     case RBOCI8_T_RATIONAL:
-        return rb_funcall(onum_to_r(lhs), '/', 1, rhs);
+        return rb_funcall(onum_to_r(lhs), oci8_id_div_op, 1, rhs);
     case RBOCI8_T_BIGDECIMAL:
-        return rb_funcall(onum_to_d(lhs), '/', 1, rhs);
+        return rb_funcall(onum_to_d(lhs), oci8_id_div_op, 1, rhs);
     }
-    return rb_num_coerce_bin(lhs, rhs, '/');
+    return rb_num_coerce_bin(lhs, rhs, oci8_id_div_op);
 }
 
 /*

Modified: trunk/ruby-oci8/ext/oci8/oradate.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oradate.c	2010-08-28 09:26:45 UTC (rev 410)
+++ trunk/ruby-oci8/ext/oci8/oradate.c	2010-09-05 13:07:21 UTC (rev 411)
@@ -146,7 +146,7 @@
 {
     ora_date_t *l, *r;
 
-    rb_obj_init_copy(lhs, rhs);
+    rb_call_super(1, &rhs);
     Data_Get_Struct(lhs, ora_date_t, l);
     Data_Get_Struct(rhs, ora_date_t, r);
     memcpy(l, r, sizeof(ora_date_t));




More information about the ruby-oci8-commit mailing list