[ruby-oci8-commit] [255] trunk/ruby-oci8: * ext/oci8/bind.c, ext/oci8/lob.c, ext/oci8/object.c , ext/oci8/oci8.h,

nobody at rubyforge.org nobody at rubyforge.org
Sat Mar 22 10:11:32 EDT 2008


Revision: 255
Author:   kubo
Date:     2008-03-22 10:11:32 -0400 (Sat, 22 Mar 2008)

Log Message:
-----------
* ext/oci8/bind.c, ext/oci8/lob.c, ext/oci8/object.c, ext/oci8/oci8.h,
  ext/oci8/oci8lib.c, ext/oci8/ocidatetime.c, ext/oci8/ocinumber.c,
  ext/oci8/oradate.c, ext/oci8/stmt.c: add qualifier 'const' to
    oci8_bind_*class_t values. These are read only.

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/bind.c
    trunk/ruby-oci8/ext/oci8/lob.c
    trunk/ruby-oci8/ext/oci8/object.c
    trunk/ruby-oci8/ext/oci8/oci8.h
    trunk/ruby-oci8/ext/oci8/oci8lib.c
    trunk/ruby-oci8/ext/oci8/ocidatetime.c
    trunk/ruby-oci8/ext/oci8/ocinumber.c
    trunk/ruby-oci8/ext/oci8/oradate.c
    trunk/ruby-oci8/ext/oci8/stmt.c

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2008-03-22 03:18:42 UTC (rev 254)
+++ trunk/ruby-oci8/ChangeLog	2008-03-22 14:11:32 UTC (rev 255)
@@ -1,4 +1,10 @@
 2008-03-22  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/bind.c, ext/oci8/lob.c, ext/oci8/object.c, ext/oci8/oci8.h,
+	  ext/oci8/oci8lib.c, ext/oci8/ocidatetime.c, ext/oci8/ocinumber.c,
+	  ext/oci8/oradate.c, ext/oci8/stmt.c: add qualifier 'const' to
+	    oci8_bind_*class_t values. These are read only.
+
+2008-03-22  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/.: add apiwrap.[ch] to svn:ignore property.
 	* ext/oci8/apiwrap.c.tmpl, ext/oci8/apiwrap.rb, ext/oci8/apiwrap.yml:
 	    add alternative code if OCINumberSetPi(), OCINumberIsInt() is

Modified: trunk/ruby-oci8/ext/oci8/bind.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/bind.c	2008-03-22 03:18:42 UTC (rev 254)
+++ trunk/ruby-oci8/ext/oci8/bind.c	2008-03-22 14:11:32 UTC (rev 255)
@@ -55,7 +55,7 @@
     obind->alloc_sz = (sz + (sizeof(sb4) - 1)) & ~(sizeof(sb4) - 1);
 }
 
-static oci8_bind_class_t bind_string_class = {
+static const oci8_bind_class_t bind_string_class = {
     {
         NULL,
         oci8_bind_free,
@@ -74,7 +74,7 @@
 /*
  * bind_raw
  */
-static oci8_bind_class_t bind_raw_class = {
+static const oci8_bind_class_t bind_raw_class = {
     {
         NULL,
         oci8_bind_free,
@@ -188,7 +188,7 @@
     obind->u.inds[idx] = 0;
 }
 
-static oci8_bind_class_t bind_long_class = {
+static const oci8_bind_class_t bind_long_class = {
     {
         bind_long_mark,
         oci8_bind_free,
@@ -207,7 +207,7 @@
 /*
  * bind_long_raw
  */
-static oci8_bind_class_t bind_long_raw_class = {
+static const oci8_bind_class_t bind_long_raw_class = {
     {
         bind_long_mark,
         oci8_bind_free,
@@ -243,7 +243,7 @@
     obind->alloc_sz = sizeof(long);
 }
 
-static oci8_bind_class_t bind_fixnum_class = {
+static const oci8_bind_class_t bind_fixnum_class = {
     {
         NULL,
         oci8_bind_free,
@@ -279,7 +279,7 @@
     obind->alloc_sz = sizeof(double);
 }
 
-static oci8_bind_class_t bind_float_class = {
+static const oci8_bind_class_t bind_float_class = {
     {
         NULL,
         oci8_bind_free,
@@ -296,7 +296,7 @@
 };
 
 #ifdef SQLT_BDOUBLE
-static oci8_bind_class_t bind_binary_double_class = {
+static const oci8_bind_class_t bind_binary_double_class = {
     {
         NULL,
         oci8_bind_free,
@@ -313,7 +313,7 @@
 };
 #endif
 
-static inline VALUE oci8_get_data_at(oci8_bind_class_t *obc, oci8_bind_t *obind, ub4 idx)
+static inline VALUE oci8_get_data_at(const oci8_bind_class_t *obc, oci8_bind_t *obind, ub4 idx)
 {
     void **null_structp = NULL;
 
@@ -331,7 +331,7 @@
 static VALUE oci8_get_data(VALUE self)
 {
     oci8_bind_t *obind = DATA_PTR(self);
-    oci8_bind_class_t *obc = (oci8_bind_class_t *)obind->base.klass;
+    const oci8_bind_class_t *obc = (const oci8_bind_class_t *)obind->base.klass;
 
     if (obind->maxar_sz == 0) {
         return oci8_get_data_at(obc, obind, 0);
@@ -346,7 +346,7 @@
     }
 }
 
-static inline void oci8_set_data_at(oci8_bind_class_t *obc, oci8_bind_t *obind, ub4 idx, VALUE val)
+static inline void oci8_set_data_at(const oci8_bind_class_t *obc, oci8_bind_t *obind, ub4 idx, VALUE val)
 {
 
     if (NIL_P(val)) {
@@ -371,7 +371,7 @@
 static VALUE oci8_set_data(VALUE self, VALUE val)
 {
     oci8_bind_t *obind = DATA_PTR(self);
-    oci8_bind_class_t *obc = (oci8_bind_class_t *)obind->base.klass;
+    const oci8_bind_class_t *obc = (const oci8_bind_class_t *)obind->base.klass;
 
     if (obind->maxar_sz == 0) {
         oci8_set_data_at(obc, obind, 0, val);
@@ -395,7 +395,7 @@
 static VALUE oci8_bind_initialize(VALUE self, VALUE svc, VALUE val, VALUE length, VALUE max_array_size)
 {
     oci8_bind_t *obind = DATA_PTR(self);
-    oci8_bind_class_t *bind_class = (oci8_bind_class_t *)obind->base.klass;
+    const oci8_bind_class_t *bind_class = (const oci8_bind_class_t *)obind->base.klass;
     ub4 cnt = 1;
 
     obind->tdo = Qnil;

Modified: trunk/ruby-oci8/ext/oci8/lob.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/lob.c	2008-03-22 03:18:42 UTC (rev 254)
+++ trunk/ruby-oci8/ext/oci8/lob.c	2008-03-22 14:11:32 UTC (rev 255)
@@ -567,7 +567,7 @@
 static void bind_lob_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val)
 {
     oci8_hp_obj_t *oho = (oci8_hp_obj_t *)data;
-    oci8_bind_lob_class_t *klass = (oci8_bind_lob_class_t *)obind->base.klass;
+    const oci8_bind_lob_class_t *klass = (const oci8_bind_lob_class_t *)obind->base.klass;
     oci8_base_t *h;
     if (!rb_obj_is_kind_of(val, *klass->klass))
         rb_raise(rb_eArgError, "Invalid argument: %s (expect %s)", rb_class2name(CLASS_OF(val)), rb_class2name(*klass->klass));
@@ -584,7 +584,7 @@
 
 static void bind_lob_init_elem(oci8_bind_t *obind, VALUE svc)
 {
-    oci8_bind_lob_class_t *klass = (oci8_bind_lob_class_t *)obind->base.klass;
+    const oci8_bind_lob_class_t *klass = (const oci8_bind_lob_class_t *)obind->base.klass;
     oci8_hp_obj_t *oho = (oci8_hp_obj_t *)obind->valuep;
     oci8_base_t *h;
     ub4 idx = 0;
@@ -596,7 +596,7 @@
     } while (++idx < obind->maxar_sz);
 }
 
-static oci8_bind_lob_class_t bind_clob_class = {
+static const oci8_bind_lob_class_t bind_clob_class = {
     {
         {
             oci8_bind_hp_obj_mark,
@@ -615,7 +615,7 @@
     &cOCI8CLOB
 };
 
-static oci8_bind_lob_class_t bind_nclob_class = {
+static const oci8_bind_lob_class_t bind_nclob_class = {
     {
         {
             oci8_bind_hp_obj_mark,
@@ -635,7 +635,7 @@
     &cOCI8NCLOB
 };
 
-static oci8_bind_lob_class_t bind_blob_class = {
+static const oci8_bind_lob_class_t bind_blob_class = {
     {
         {
             oci8_bind_hp_obj_mark,
@@ -654,7 +654,7 @@
     &cOCI8BLOB
 };
 
-static oci8_bind_lob_class_t bind_bfile_class = {
+static const oci8_bind_lob_class_t bind_bfile_class = {
     {
         {
             oci8_bind_hp_obj_mark,

Modified: trunk/ruby-oci8/ext/oci8/object.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/object.c	2008-03-22 03:18:42 UTC (rev 254)
+++ trunk/ruby-oci8/ext/oci8/object.c	2008-03-22 14:11:32 UTC (rev 255)
@@ -552,7 +552,7 @@
     } while (++idx < obind->maxar_sz);
 }
 
-static oci8_bind_class_t bind_named_type_class = {
+static const oci8_bind_class_t bind_named_type_class = {
     {
         bind_named_type_mark,
         bind_named_type_free,

Modified: trunk/ruby-oci8/ext/oci8/oci8.h
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.h	2008-03-22 03:18:42 UTC (rev 254)
+++ trunk/ruby-oci8/ext/oci8/oci8.h	2008-03-22 14:11:32 UTC (rev 255)
@@ -159,7 +159,7 @@
         OCIDescribe *dschp;
     } hp;
     VALUE self;
-    oci8_base_class_t *klass;
+    const oci8_base_class_t *klass;
     oci8_base_t *parent;
     oci8_base_t *next;
     oci8_base_t *prev;
@@ -275,7 +275,7 @@
 void oci8_base_free(oci8_base_t *base);
 VALUE oci8_define_class(const char *name, oci8_base_class_t *klass);
 VALUE oci8_define_class_under(VALUE outer, const char *name, oci8_base_class_t *klass);
-VALUE oci8_define_bind_class(const char *name, oci8_bind_class_t *oci8_bind_class);
+VALUE oci8_define_bind_class(const char *name, const oci8_bind_class_t *oci8_bind_class);
 void oci8_link_to_parent(oci8_base_t *base, oci8_base_t *parent);
 void oci8_unlink_from_parent(oci8_base_t *base);
 #ifndef RUBY_VM

Modified: trunk/ruby-oci8/ext/oci8/oci8lib.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8lib.c	2008-03-22 03:18:42 UTC (rev 254)
+++ trunk/ruby-oci8/ext/oci8/oci8lib.c	2008-03-22 14:11:32 UTC (rev 255)
@@ -77,7 +77,7 @@
 static VALUE oci8_s_allocate(VALUE klass)
 {
     oci8_base_t *base;
-    oci8_base_class_t *base_class;
+    const oci8_base_class_t *base_class;
     VALUE superklass;
     VALUE obj;
 
@@ -178,10 +178,10 @@
     return klass;
 }
 
-VALUE oci8_define_bind_class(const char *name, oci8_bind_class_t *bind_class)
+VALUE oci8_define_bind_class(const char *name, const oci8_bind_class_t *bind_class)
 {
     VALUE klass = rb_define_class_under(mOCI8BindType, name, cOCI8BindTypeBase);
-    VALUE obj = Data_Wrap_Struct(rb_cObject, 0, 0, bind_class);
+    VALUE obj = Data_Wrap_Struct(rb_cObject, 0, 0, (void*)bind_class);
     rb_ivar_set(klass, id_oci8_class, obj);
     return klass;
 }

Modified: trunk/ruby-oci8/ext/oci8/ocidatetime.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/ocidatetime.c	2008-03-22 03:18:42 UTC (rev 254)
+++ trunk/ruby-oci8/ext/oci8/ocidatetime.c	2008-03-22 14:11:32 UTC (rev 255)
@@ -646,7 +646,7 @@
     } while (++idx < obind->maxar_sz);
 }
 
-static oci8_bind_class_t bind_datetime_class = {
+static const oci8_bind_class_t bind_datetime_class = {
     {
         NULL,
         oci8_bind_dsc_free,
@@ -662,7 +662,7 @@
     SQLT_TIMESTAMP_TZ
 };
 
-static oci8_bind_class_t bind_interval_ym_class = {
+static const oci8_bind_class_t bind_interval_ym_class = {
     {
         NULL,
         oci8_bind_dsc_free,
@@ -678,7 +678,7 @@
     SQLT_INTERVAL_YM
 };
 
-static oci8_bind_class_t bind_interval_ds_class = {
+static const oci8_bind_class_t bind_interval_ds_class = {
     {
         NULL,
         oci8_bind_dsc_free,

Modified: trunk/ruby-oci8/ext/oci8/ocinumber.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/ocinumber.c	2008-03-22 03:18:42 UTC (rev 254)
+++ trunk/ruby-oci8/ext/oci8/ocinumber.c	2008-03-22 14:11:32 UTC (rev 255)
@@ -1069,7 +1069,7 @@
     } while (++idx < obind->maxar_sz);
 }
 
-static oci8_bind_class_t bind_ocinumber_class = {
+static const oci8_bind_class_t bind_ocinumber_class = {
     {
         NULL,
         oci8_bind_free,
@@ -1085,7 +1085,7 @@
     SQLT_VNU,
 };
 
-static oci8_bind_class_t bind_integer_class = {
+static const oci8_bind_class_t bind_integer_class = {
     {
         NULL,
         oci8_bind_free,

Modified: trunk/ruby-oci8/ext/oci8/oradate.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oradate.c	2008-03-22 03:18:42 UTC (rev 254)
+++ trunk/ruby-oci8/ext/oci8/oradate.c	2008-03-22 14:11:32 UTC (rev 255)
@@ -399,7 +399,7 @@
     } while (++idx < obind->maxar_sz);
 }
 
-static oci8_bind_class_t bind_oradate_class = {
+static const oci8_bind_class_t bind_oradate_class = {
     {
         NULL,
         oci8_bind_free,

Modified: trunk/ruby-oci8/ext/oci8/stmt.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/stmt.c	2008-03-22 03:18:42 UTC (rev 254)
+++ trunk/ruby-oci8/ext/oci8/stmt.c	2008-03-22 14:11:32 UTC (rev 255)
@@ -125,7 +125,7 @@
     oci8_stmt_t *stmt = DATA_PTR(self);
     ub4 position;
     oci8_bind_t *obind;
-    oci8_bind_class_t *bind_class;
+    const oci8_bind_class_t *bind_class;
     sword status;
     ub4 mode;
 
@@ -134,7 +134,7 @@
     if (obind->base.hp.dfn != NULL) {
         oci8_base_free(&obind->base); /* TODO: OK? */
     }
-    bind_class = (oci8_bind_class_t *)obind->base.klass;
+    bind_class = (const oci8_bind_class_t *)obind->base.klass;
     if (bind_class->out == NULL) {
         mode = OCI_DEFAULT;
     } else {
@@ -175,7 +175,7 @@
     ub4 placeholder_len = 0;
     ub4 position = 0;
     oci8_bind_t *obind;
-    oci8_bind_class_t *bind_class;
+    const oci8_bind_class_t *bind_class;
     sword status;
     VALUE old_value;
     void *indp;
@@ -203,7 +203,7 @@
     if (obind->base.hp.bnd != NULL) {
         oci8_base_free(&obind->base); /* TODO: OK? */
     }
-    bind_class = (oci8_bind_class_t *)obind->base.klass;
+    bind_class = (const oci8_bind_class_t *)obind->base.klass;
     if (bind_class->in != NULL || bind_class->out != NULL) {
         mode = OCI_DATA_AT_EXEC;
     } else {
@@ -284,7 +284,7 @@
     rv = oci8_call_stmt_execute(svcctx, stmt, iters, mode);
     while (rv == OCI_NEED_DATA) {
         oci8_bind_t *obind;
-        oci8_bind_class_t *bind_class;
+        const oci8_bind_class_t *bind_class;
         /* get piece info. */
         dvoid *hp;
         ub4 type;
@@ -303,7 +303,7 @@
             if (obind->base.hp.ptr == hp) {
                 if (type != OCI_HTYPE_BIND)
                     rb_bug("ruby-oci8: expect OCI_HTYPE_BIND but %d", type);
-                bind_class = (oci8_bind_class_t *)obind->base.klass;
+                bind_class = (const oci8_bind_class_t *)obind->base.klass;
                 switch (in_out) {
                 case OCI_PARAM_IN:
                     if (bind_class->in == NULL)
@@ -366,12 +366,12 @@
     sword rv;
     long idx;
     oci8_bind_t *obind;
-    oci8_bind_class_t *bind_class;
+    const oci8_bind_class_t *bind_class;
 
     obind = (oci8_bind_t *)stmt->base.children;
     do {
         if (obind->base.type == OCI_HTYPE_DEFINE) {
-            bind_class = (oci8_bind_class_t *)obind->base.klass;
+            bind_class = (const oci8_bind_class_t *)obind->base.klass;
             if (bind_class->pre_fetch_hook != NULL) {
                 bind_class->pre_fetch_hook(obind, stmt->svc);
             }
@@ -398,7 +398,7 @@
             if (obind->base.hp.ptr == hp) {
                 if (type != OCI_HTYPE_DEFINE)
                     rb_bug("ruby-oci8: expect OCI_HTYPE_DEFINE but %d", type);
-                bind_class = (oci8_bind_class_t *)obind->base.klass;
+                bind_class = (const oci8_bind_class_t *)obind->base.klass;
                 switch (in_out) {
                 case OCI_PARAM_OUT:
                     if (bind_class->out == NULL)
@@ -432,7 +432,7 @@
         void *indp;
 
         if (obind->base.type == OCI_HTYPE_DEFINE) {
-            bind_class = (oci8_bind_class_t *)obind->base.klass;
+            bind_class = (const oci8_bind_class_t *)obind->base.klass;
             if (bind_class->out != NULL) {
                 if (obind->maxar_sz == 0) {
                     bind_class->out(obind, 0, 0, &valuep, &alenp, &indp);
@@ -737,7 +737,7 @@
     } while (++idx < obind->maxar_sz);
 }
 
-static oci8_bind_class_t bind_stmt_class = {
+static const oci8_bind_class_t bind_stmt_class = {
     {
         oci8_bind_hp_obj_mark,
         oci8_bind_free,




More information about the ruby-oci8-commit mailing list