ruby-oci8 2.1.7 → 2.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  * ocidatetime.c
4
4
  *
5
- * Copyright (C) 2005-2011 KUBO Takehiro <kubo@jiubao.org>
5
+ * Copyright (C) 2005-2014 Kubo Takehiro <kubo@jiubao.org>
6
6
  *
7
7
  */
8
8
  #include "oci8.h"
@@ -27,37 +27,37 @@ OCIDate *oci8_set_ocidate(OCIDate *od, VALUE val)
27
27
  rb_raise(rb_eRuntimeError, "invalid array size %ld", RARRAY_LEN(val));
28
28
  }
29
29
  /* year */
30
- year = NUM2LONG(RARRAY_PTR(val)[0]);
30
+ year = NUM2LONG(RARRAY_AREF(val, 0));
31
31
  if (year < -4712 || 9999 < year) {
32
32
  rb_raise(rb_eRuntimeError, "out of year range: %ld", year);
33
33
  }
34
34
  od->OCIDateYYYY = (sb2)year;
35
35
  /* month */
36
- month = NUM2LONG(RARRAY_PTR(val)[1]);
36
+ month = NUM2LONG(RARRAY_AREF(val, 1));
37
37
  if (month < 0 || 12 < month) {
38
38
  rb_raise(rb_eRuntimeError, "out of month range: %ld", month);
39
39
  }
40
40
  od->OCIDateMM = (ub1)month;
41
41
  /* day */
42
- day = NUM2LONG(RARRAY_PTR(val)[2]);
42
+ day = NUM2LONG(RARRAY_AREF(val, 2));
43
43
  if (day < 0 || 31 < day) {
44
44
  rb_raise(rb_eRuntimeError, "out of day range: %ld", day);
45
45
  }
46
46
  od->OCIDateDD = (ub1)day;
47
47
  /* hour */
48
- hour = NUM2LONG(RARRAY_PTR(val)[3]);
48
+ hour = NUM2LONG(RARRAY_AREF(val, 3));
49
49
  if (hour < 0 || 23 < hour) {
50
50
  rb_raise(rb_eRuntimeError, "out of hour range: %ld", hour);
51
51
  }
52
52
  od->OCIDateTime.OCITimeHH = (ub1)hour;
53
53
  /* minute */
54
- minute = NUM2LONG(RARRAY_PTR(val)[4]);
54
+ minute = NUM2LONG(RARRAY_AREF(val, 4));
55
55
  if (minute < 0 || 59 < minute) {
56
56
  rb_raise(rb_eRuntimeError, "out of minute range: %ld", minute);
57
57
  }
58
58
  od->OCIDateTime.OCITimeMI = (ub1)minute;
59
59
  /* second */
60
- second = NUM2LONG(RARRAY_PTR(val)[5]);
60
+ second = NUM2LONG(RARRAY_AREF(val, 5));
61
61
  if (second < 0 || 59 < second) {
62
62
  rb_raise(rb_eRuntimeError, "out of second range: %ld", second);
63
63
  }
@@ -149,42 +149,42 @@ OCIDateTime *oci8_set_ocitimestamp_tz(OCIDateTime *dttm, VALUE val, VALUE svc)
149
149
  rb_raise(rb_eRuntimeError, "invalid array size %ld", RARRAY_LEN(val));
150
150
  }
151
151
  /* year */
152
- year = NUM2LONG(RARRAY_PTR(val)[0]);
152
+ year = NUM2LONG(RARRAY_AREF(val, 0));
153
153
  if (year < -4712 || 9999 < year) {
154
154
  rb_raise(rb_eRuntimeError, "out of year range: %ld", year);
155
155
  }
156
156
  /* month */
157
- month = NUM2LONG(RARRAY_PTR(val)[1]);
157
+ month = NUM2LONG(RARRAY_AREF(val, 1));
158
158
  if (month < 0 || 12 < month) {
159
159
  rb_raise(rb_eRuntimeError, "out of month range: %ld", month);
160
160
  }
161
161
  /* day */
162
- day = NUM2LONG(RARRAY_PTR(val)[2]);
162
+ day = NUM2LONG(RARRAY_AREF(val, 2));
163
163
  if (day < 0 || 31 < day) {
164
164
  rb_raise(rb_eRuntimeError, "out of day range: %ld", day);
165
165
  }
166
166
  /* hour */
167
- hour = NUM2LONG(RARRAY_PTR(val)[3]);
167
+ hour = NUM2LONG(RARRAY_AREF(val, 3));
168
168
  if (hour < 0 || 23 < hour) {
169
169
  rb_raise(rb_eRuntimeError, "out of hour range: %ld", hour);
170
170
  }
171
171
  /* minute */
172
- minute = NUM2LONG(RARRAY_PTR(val)[4]);
172
+ minute = NUM2LONG(RARRAY_AREF(val, 4));
173
173
  if (minute < 0 || 60 < minute) {
174
174
  rb_raise(rb_eRuntimeError, "out of minute range: %ld", minute);
175
175
  }
176
176
  /* second */
177
- sec = NUM2LONG(RARRAY_PTR(val)[5]);
177
+ sec = NUM2LONG(RARRAY_AREF(val, 5));
178
178
  if (sec < 0 || 60 < sec) {
179
179
  rb_raise(rb_eRuntimeError, "out of second range: %ld", sec);
180
180
  }
181
181
  /* sec_fraction */
182
- fsec = NUM2LONG(RARRAY_PTR(val)[6]);
182
+ fsec = NUM2LONG(RARRAY_AREF(val, 6));
183
183
  if (fsec < 0 || 1000000000 < fsec) {
184
184
  rb_raise(rb_eRuntimeError, "out of sec_fraction range: %ld", fsec);
185
185
  }
186
186
  /* time zone */
187
- if (NIL_P(RARRAY_PTR(val)[7]) && NIL_P(RARRAY_PTR(val)[8])) {
187
+ if (NIL_P(RARRAY_AREF(val, 7)) && NIL_P(RARRAY_AREF(val, 8))) {
188
188
  if (!NIL_P(svc)) {
189
189
  /* use session timezone. */
190
190
  seshp = oci8_get_oci_session(svc);
@@ -193,8 +193,8 @@ OCIDateTime *oci8_set_ocitimestamp_tz(OCIDateTime *dttm, VALUE val, VALUE svc)
193
193
  tzlen = 0;
194
194
  } else {
195
195
  snprintf(tz_str, sizeof(tz_str), "%+02ld:%02ld",
196
- NUM2LONG(RARRAY_PTR(val)[7]),
197
- NUM2LONG(RARRAY_PTR(val)[8]));
196
+ NUM2LONG(RARRAY_AREF(val, 7)),
197
+ NUM2LONG(RARRAY_AREF(val, 8)));
198
198
  tz_str[sizeof(tz_str) - 1] = '\0';
199
199
  tz = (OraText*)tz_str;
200
200
  tzlen = strlen(tz_str);
@@ -232,9 +232,20 @@ static void bind_ocitimestamp_free(oci8_base_t *base)
232
232
  bind_free_common(base, OCI_DTYPE_TIMESTAMP);
233
233
  }
234
234
 
235
- static const oci8_bind_vtable_t bind_ocitimestamp_vtable = {
235
+ static const oci8_bind_data_type_t bind_ocitimestamp_data_type = {
236
236
  {
237
- NULL,
237
+ {
238
+ "OCI8::BindType::OCITimestamp",
239
+ {
240
+ NULL,
241
+ oci8_handle_cleanup,
242
+ oci8_handle_size,
243
+ },
244
+ &oci8_bind_data_type.rb_data_type, NULL,
245
+ #ifdef RUBY_TYPED_WB_PROTECTED
246
+ RUBY_TYPED_WB_PROTECTED,
247
+ #endif
248
+ },
238
249
  bind_ocitimestamp_free,
239
250
  sizeof(oci8_bind_t)
240
251
  },
@@ -246,6 +257,11 @@ static const oci8_bind_vtable_t bind_ocitimestamp_vtable = {
246
257
  SQLT_TIMESTAMP
247
258
  };
248
259
 
260
+ static VALUE bind_ocitimestamp_alloc(VALUE klass)
261
+ {
262
+ return oci8_allocate_typeddata(klass, &bind_ocitimestamp_data_type.base);
263
+ }
264
+
249
265
  static VALUE bind_ocitimestamp_tz_get(oci8_bind_t *obind, void *data, void *null_struct)
250
266
  {
251
267
  return oci8_make_ocitimestamp(*(OCIDateTime **)data, TRUE);
@@ -288,9 +304,20 @@ static void bind_ocitimestamp_tz_free(oci8_base_t *base)
288
304
  bind_free_common(base, OCI_DTYPE_TIMESTAMP_TZ);
289
305
  }
290
306
 
291
- static const oci8_bind_vtable_t bind_ocitimestamp_tz_vtable = {
307
+ static const oci8_bind_data_type_t bind_ocitimestamp_tz_data_type = {
292
308
  {
293
- NULL,
309
+ {
310
+ "OCI8::BindType::OCITimestampTZ",
311
+ {
312
+ NULL,
313
+ oci8_handle_cleanup,
314
+ oci8_handle_size,
315
+ },
316
+ &oci8_bind_data_type.rb_data_type, NULL,
317
+ #ifdef RUBY_TYPED_WB_PROTECTED
318
+ RUBY_TYPED_WB_PROTECTED,
319
+ #endif
320
+ },
294
321
  bind_ocitimestamp_tz_free,
295
322
  sizeof(oci8_bind_t)
296
323
  },
@@ -302,6 +329,11 @@ static const oci8_bind_vtable_t bind_ocitimestamp_tz_vtable = {
302
329
  SQLT_TIMESTAMP_TZ
303
330
  };
304
331
 
332
+ static VALUE bind_ocitimestamp_tz_alloc(VALUE klass)
333
+ {
334
+ return oci8_allocate_typeddata(klass, &bind_ocitimestamp_tz_data_type.base);
335
+ }
336
+
305
337
  VALUE oci8_make_ociinterval_ym(OCIInterval *s)
306
338
  {
307
339
  sb4 year;
@@ -320,8 +352,8 @@ OCIInterval *oci8_set_ociinterval_ym(OCIInterval *intvl, VALUE val)
320
352
  if (RARRAY_LEN(val) != 2) {
321
353
  rb_raise(rb_eRuntimeError, "invalid array size %ld", RARRAY_LEN(val));
322
354
  }
323
- year = NUM2INT(RARRAY_PTR(val)[0]);
324
- month = NUM2INT(RARRAY_PTR(val)[1]);
355
+ year = NUM2INT(RARRAY_AREF(val, 0));
356
+ month = NUM2INT(RARRAY_AREF(val, 1));
325
357
  if (oracle_client_version >= ORAVERNUM(9, 2, 0, 3, 0)) {
326
358
  chkerr(OCIIntervalSetYearMonth(oci8_envhp, oci8_errhp,
327
359
  year, month, intvl));
@@ -372,11 +404,11 @@ OCIInterval *oci8_set_ociinterval_ds(OCIInterval *intvl, VALUE val)
372
404
  if (RARRAY_LEN(val) != 5) {
373
405
  rb_raise(rb_eRuntimeError, "invalid array size %ld", RARRAY_LEN(val));
374
406
  }
375
- day = NUM2INT(RARRAY_PTR(val)[0]);
376
- hour = NUM2INT(RARRAY_PTR(val)[1]);
377
- minute = NUM2INT(RARRAY_PTR(val)[2]);
378
- sec = NUM2INT(RARRAY_PTR(val)[3]);
379
- fsec = NUM2INT(RARRAY_PTR(val)[4]);
407
+ day = NUM2INT(RARRAY_AREF(val, 0));
408
+ hour = NUM2INT(RARRAY_AREF(val, 1));
409
+ minute = NUM2INT(RARRAY_AREF(val, 2));
410
+ sec = NUM2INT(RARRAY_AREF(val, 3));
411
+ fsec = NUM2INT(RARRAY_AREF(val, 4));
380
412
  if (oracle_client_version >= ORAVERNUM(9, 2, 0, 3, 0)) {
381
413
  chkerr(OCIIntervalSetDaySecond(oci8_envhp, oci8_errhp,
382
414
  day, hour, minute, sec, fsec, intvl));
@@ -447,9 +479,20 @@ static void bind_ociinterval_ds_free(oci8_base_t *base)
447
479
  bind_free_common(base, OCI_DTYPE_INTERVAL_DS);
448
480
  }
449
481
 
450
- static const oci8_bind_vtable_t bind_ociinterval_ym_vtable = {
482
+ static const oci8_bind_data_type_t bind_ociinterval_ym_data_type = {
451
483
  {
452
- NULL,
484
+ {
485
+ "OCI8::BindType::OCIIntervalYM",
486
+ {
487
+ NULL,
488
+ oci8_handle_cleanup,
489
+ oci8_handle_size,
490
+ },
491
+ &oci8_bind_data_type.rb_data_type, NULL,
492
+ #ifdef RUBY_TYPED_WB_PROTECTED
493
+ RUBY_TYPED_WB_PROTECTED,
494
+ #endif
495
+ },
453
496
  bind_ociinterval_ym_free,
454
497
  sizeof(oci8_bind_t)
455
498
  },
@@ -461,9 +504,25 @@ static const oci8_bind_vtable_t bind_ociinterval_ym_vtable = {
461
504
  SQLT_INTERVAL_YM
462
505
  };
463
506
 
464
- static const oci8_bind_vtable_t bind_ociinterval_ds_vtable = {
507
+ static VALUE bind_ociinterval_ym_alloc(VALUE klass)
508
+ {
509
+ return oci8_allocate_typeddata(klass, &bind_ociinterval_ym_data_type.base);
510
+ }
511
+
512
+ static const oci8_bind_data_type_t bind_ociinterval_ds_data_type = {
465
513
  {
466
- NULL,
514
+ {
515
+ "OCI8::BindType::OCIIntervalDS",
516
+ {
517
+ NULL,
518
+ oci8_handle_cleanup,
519
+ oci8_handle_size,
520
+ },
521
+ &oci8_bind_data_type.rb_data_type, NULL,
522
+ #ifdef RUBY_TYPED_WB_PROTECTED
523
+ RUBY_TYPED_WB_PROTECTED,
524
+ #endif
525
+ },
467
526
  bind_ociinterval_ds_free,
468
527
  sizeof(oci8_bind_t)
469
528
  },
@@ -475,10 +534,15 @@ static const oci8_bind_vtable_t bind_ociinterval_ds_vtable = {
475
534
  SQLT_INTERVAL_DS
476
535
  };
477
536
 
537
+ static VALUE bind_ociinterval_ds_alloc(VALUE klass)
538
+ {
539
+ return oci8_allocate_typeddata(klass, &bind_ociinterval_ds_data_type.base);
540
+ }
541
+
478
542
  void Init_oci_datetime(void)
479
543
  {
480
- oci8_define_bind_class("OCITimestamp", &bind_ocitimestamp_vtable);
481
- oci8_define_bind_class("OCITimestampTZ", &bind_ocitimestamp_tz_vtable);
482
- oci8_define_bind_class("OCIIntervalYM", &bind_ociinterval_ym_vtable);
483
- oci8_define_bind_class("OCIIntervalDS", &bind_ociinterval_ds_vtable);
544
+ oci8_define_bind_class("OCITimestamp", &bind_ocitimestamp_data_type, bind_ocitimestamp_alloc);
545
+ oci8_define_bind_class("OCITimestampTZ", &bind_ocitimestamp_tz_data_type, bind_ocitimestamp_tz_alloc);
546
+ oci8_define_bind_class("OCIIntervalYM", &bind_ociinterval_ym_data_type, bind_ociinterval_ym_alloc);
547
+ oci8_define_bind_class("OCIIntervalDS", &bind_ociinterval_ds_data_type, bind_ociinterval_ds_alloc);
484
548
  }
@@ -2,13 +2,15 @@
2
2
  /*
3
3
  * ocihandle.c
4
4
  *
5
- * Copyright (C) 2009-2013 Kubo Takehiro <kubo@jiubao.org>
5
+ * Copyright (C) 2009-2015 Kubo Takehiro <kubo@jiubao.org>
6
6
  *
7
7
  * implement OCIHandle
8
8
  *
9
9
  */
10
10
  #include "oci8.h"
11
11
 
12
+ #define TO_HANDLE(obj) ((oci8_base_t*)oci8_check_typeddata((obj), &oci8_handle_data_type, 1))
13
+
12
14
  #ifdef _MSC_VER
13
15
  #define MAGIC_NUMBER 0xDEAFBEAFDEAFBEAFui64;
14
16
  #else
@@ -25,9 +27,19 @@ static long check_data_range(VALUE val, long min, long max, const char *type)
25
27
  return lval;
26
28
  }
27
29
 
28
-
29
- static oci8_base_vtable_t oci8_base_vtable = {
30
- NULL,
30
+ const oci8_handle_data_type_t oci8_handle_data_type = {
31
+ {
32
+ "OCIHandle",
33
+ {
34
+ NULL,
35
+ oci8_handle_cleanup,
36
+ oci8_handle_size,
37
+ },
38
+ NULL, NULL,
39
+ #ifdef RUBY_TYPED_WB_PROTECTED
40
+ RUBY_TYPED_WB_PROTECTED,
41
+ #endif
42
+ },
31
43
  NULL,
32
44
  sizeof(oci8_base_t),
33
45
  };
@@ -38,10 +50,10 @@ static VALUE oci8_handle_initialize(VALUE self)
38
50
  }
39
51
 
40
52
  /*
41
- * Clears the object internal structure and its dependents.
53
+ * Clears the object internal structure and its dependents.
42
54
  *
43
- * @since 2.0.0
44
- * @private
55
+ * @since 2.0.0
56
+ * @private
45
57
  */
46
58
  static VALUE oci8_handle_free(VALUE self)
47
59
  {
@@ -51,14 +63,9 @@ static VALUE oci8_handle_free(VALUE self)
51
63
  return self;
52
64
  }
53
65
 
54
- static void oci8_handle_mark(oci8_base_t *base)
55
- {
56
- if (base->vptr->mark != NULL)
57
- base->vptr->mark(base);
58
- }
59
-
60
- static void oci8_handle_cleanup(oci8_base_t *base)
66
+ void oci8_handle_cleanup(void *ptr)
61
67
  {
68
+ oci8_base_t *base = (oci8_base_t *)ptr;
62
69
  if (oci8_in_finalizer) {
63
70
  /* Do nothing when the program exits.
64
71
  * The first two words of memory addressed by VALUE datatype is
@@ -71,35 +78,43 @@ static void oci8_handle_cleanup(oci8_base_t *base)
71
78
  xfree(base);
72
79
  }
73
80
 
81
+ size_t oci8_handle_size(const void *ptr)
82
+ {
83
+ const oci8_base_t *base = (const oci8_base_t *)ptr;
84
+ const oci8_bind_t *bind = (const oci8_bind_t *)ptr;
85
+ size_t size = base->data_type->size;
86
+
87
+ if (base->hp.ptr != NULL) {
88
+ size += 256; /* I don't know the real size. Use 256 for now. */
89
+ }
90
+ switch (base->type) {
91
+ case OCI_HTYPE_DEFINE:
92
+ case OCI_HTYPE_BIND:
93
+ size += bind->alloc_sz * (bind->maxar_sz ? bind->maxar_sz : 1);
94
+ }
95
+ return size;
96
+ }
97
+
74
98
  static VALUE oci8_s_allocate(VALUE klass)
99
+ {
100
+ return oci8_allocate_typeddata(klass, &oci8_handle_data_type);
101
+ }
102
+
103
+ VALUE oci8_allocate_typeddata(VALUE klass, const oci8_handle_data_type_t *data_type)
75
104
  {
76
105
  oci8_base_t *base;
77
- const oci8_base_vtable_t *vptr;
78
- VALUE superklass;
79
106
  VALUE obj;
80
107
 
81
- superklass = klass;
82
- while (!RTEST(rb_ivar_defined(superklass, oci8_id_oci8_vtable))) {
83
- superklass = rb_class_superclass(superklass);
84
- if (superklass == rb_cObject)
85
- rb_raise(rb_eRuntimeError, "private method `new' called for %s:Class", rb_class2name(klass));
86
- }
87
- obj = rb_ivar_get(superklass, oci8_id_oci8_vtable);
88
- vptr = DATA_PTR(obj);
89
-
90
- base = xmalloc(vptr->size);
91
- memset(base, 0, vptr->size);
108
+ base = xmalloc(data_type->size);
109
+ memset(base, 0, data_type->size);
92
110
 
93
- obj = Data_Wrap_Struct(klass, oci8_handle_mark, oci8_handle_cleanup, base);
111
+ obj = TypedData_Wrap_Struct(klass, &data_type->rb_data_type, base);
94
112
  base->self = obj;
95
- base->vptr = vptr;
113
+ base->data_type = data_type;
96
114
  base->parent = NULL;
97
115
  base->next = base;
98
116
  base->prev = base;
99
117
  base->children = NULL;
100
- if (vptr->init != NULL) {
101
- vptr->init(base);
102
- }
103
118
  return obj;
104
119
  }
105
120
 
@@ -121,7 +136,7 @@ enum datatype {
121
136
 
122
137
  static VALUE attr_get_common(int argc, VALUE *argv, VALUE self, enum datatype datatype)
123
138
  {
124
- oci8_base_t *base = DATA_PTR(self);
139
+ oci8_base_t *base = oci8_check_typeddata(self, &oci8_handle_data_type, 0);
125
140
  VALUE attr_type;
126
141
  VALUE strict;
127
142
  VALUE args[6];
@@ -141,8 +156,24 @@ static VALUE attr_get_common(int argc, VALUE *argv, VALUE self, enum datatype da
141
156
  ub4 size = 0;
142
157
  sword rv;
143
158
 
144
- if (base->type == 0) {
145
- return Qnil;
159
+ if (base->closed) {
160
+ /* Returns nil when the backtrace includes `inspect'.
161
+ * Otherwise, raises an exception.
162
+ * IMO, `inspect' should not raise an exception.
163
+ */
164
+ volatile VALUE backtrace = rb_funcall(rb_cObject, rb_intern("caller"), 0);
165
+ if (TYPE(backtrace) == T_ARRAY) {
166
+ int i;
167
+ for (i = 0; i < RARRAY_LEN(backtrace); i++) {
168
+ volatile VALUE elem = RARRAY_AREF(backtrace, i);
169
+ char *s = StringValueCStr(elem);
170
+ if (strstr(s, "inspect") != NULL) {
171
+ return Qnil;
172
+ }
173
+ }
174
+ }
175
+ /* check again just to raise an exception. */
176
+ oci8_check_typeddata(self, &oci8_handle_data_type, 1);
146
177
  }
147
178
 
148
179
  v.ub8val = MAGIC_NUMBER;
@@ -210,17 +241,16 @@ static VALUE attr_get_common(int argc, VALUE *argv, VALUE self, enum datatype da
210
241
  }
211
242
 
212
243
  /*
213
- * call-seq:
214
- * attr_get_ub1(attr_type, strict = true)
244
+ * @overload attr_get_ub1(attr_type, strict = true)
215
245
  *
216
- * Gets the value of an attribute as `ub1' datatype.
246
+ * Gets the value of an attribute as `ub1' datatype.
217
247
  *
218
- * @param [Fixnum] attr_type
219
- * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
220
- * @return [Fixnum]
248
+ * @param [Fixnum] attr_type
249
+ * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
250
+ * @return [Fixnum]
221
251
  *
222
- * @since 2.0.4
223
- * @private
252
+ * @since 2.0.4
253
+ * @private
224
254
  */
225
255
  static VALUE attr_get_ub1(int argc, VALUE *argv, VALUE self)
226
256
  {
@@ -228,17 +258,16 @@ static VALUE attr_get_ub1(int argc, VALUE *argv, VALUE self)
228
258
  }
229
259
 
230
260
  /*
231
- * call-seq:
232
- * attr_get_ub2(attr_type, strict = true)
261
+ * @overload attr_get_ub2(attr_type, strict = true)
233
262
  *
234
- * Gets the value of an attribute as `ub2' datatype.
263
+ * Gets the value of an attribute as `ub2' datatype.
235
264
  *
236
- * @param [Fixnum] attr_type
237
- * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
238
- * @return [Fixnum]
265
+ * @param [Fixnum] attr_type
266
+ * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
267
+ * @return [Fixnum]
239
268
  *
240
- * @since 2.0.4
241
- * @private
269
+ * @since 2.0.4
270
+ * @private
242
271
  */
243
272
  static VALUE attr_get_ub2(int argc, VALUE *argv, VALUE self)
244
273
  {
@@ -246,17 +275,16 @@ static VALUE attr_get_ub2(int argc, VALUE *argv, VALUE self)
246
275
  }
247
276
 
248
277
  /*
249
- * call-seq:
250
- * attr_get_ub4(attr_type, strict = true)
278
+ * @overload attr_get_ub4(attr_type, strict = true)
251
279
  *
252
- * Gets the value of an attribute as `ub4' datatype.
280
+ * Gets the value of an attribute as `ub4' datatype.
253
281
  *
254
- * @param [Fixnum] attr_type
255
- * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
256
- * @return [Integer]
282
+ * @param [Fixnum] attr_type
283
+ * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
284
+ * @return [Integer]
257
285
  *
258
- * @since 2.0.4
259
- * @private
286
+ * @since 2.0.4
287
+ * @private
260
288
  */
261
289
  static VALUE attr_get_ub4(int argc, VALUE *argv, VALUE self)
262
290
  {
@@ -264,17 +292,16 @@ static VALUE attr_get_ub4(int argc, VALUE *argv, VALUE self)
264
292
  }
265
293
 
266
294
  /*
267
- * call-seq:
268
- * attr_get_ub8(attr_type, strict = true)
295
+ * @overload attr_get_ub8(attr_type, strict = true)
269
296
  *
270
- * Gets the value of an attribute as `ub8' datatype.
297
+ * Gets the value of an attribute as `ub8' datatype.
271
298
  *
272
- * @param [Fixnum] attr_type
273
- * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
274
- * @return [Integer]
299
+ * @param [Fixnum] attr_type
300
+ * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
301
+ * @return [Integer]
275
302
  *
276
- * @since 2.0.4
277
- * @private
303
+ * @since 2.0.4
304
+ * @private
278
305
  */
279
306
  static VALUE attr_get_ub8(int argc, VALUE *argv, VALUE self)
280
307
  {
@@ -282,17 +309,16 @@ static VALUE attr_get_ub8(int argc, VALUE *argv, VALUE self)
282
309
  }
283
310
 
284
311
  /*
285
- * call-seq:
286
- * attr_get_sb1(attr_type, strict = true)
312
+ * @overload attr_get_sb1(attr_type, strict = true)
287
313
  *
288
- * Gets the value of an attribute as `sb1' datatype.
314
+ * Gets the value of an attribute as `sb1' datatype.
289
315
  *
290
- * @param [Fixnum] attr_type
291
- * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
292
- * @return [Fixnum]
316
+ * @param [Fixnum] attr_type
317
+ * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
318
+ * @return [Fixnum]
293
319
  *
294
- * @since 2.0.4
295
- * @private
320
+ * @since 2.0.4
321
+ * @private
296
322
  */
297
323
  static VALUE attr_get_sb1(int argc, VALUE *argv, VALUE self)
298
324
  {
@@ -300,17 +326,16 @@ static VALUE attr_get_sb1(int argc, VALUE *argv, VALUE self)
300
326
  }
301
327
 
302
328
  /*
303
- * call-seq:
304
- * attr_get_sb2(attr_type, strict = true)
329
+ * @overload attr_get_sb2(attr_type, strict = true)
305
330
  *
306
- * Gets the value of an attribute as `sb2' datatype.
331
+ * Gets the value of an attribute as `sb2' datatype.
307
332
  *
308
- * @param [Fixnum] attr_type
309
- * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
310
- * @return [Fixnum]
333
+ * @param [Fixnum] attr_type
334
+ * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
335
+ * @return [Fixnum]
311
336
  *
312
- * @since 2.0.4
313
- * @private
337
+ * @since 2.0.4
338
+ * @private
314
339
  */
315
340
  static VALUE attr_get_sb2(int argc, VALUE *argv, VALUE self)
316
341
  {
@@ -318,17 +343,16 @@ static VALUE attr_get_sb2(int argc, VALUE *argv, VALUE self)
318
343
  }
319
344
 
320
345
  /*
321
- * call-seq:
322
- * attr_get_sb4(attr_type, strict = true)
346
+ * @overload attr_get_sb4(attr_type, strict = true)
323
347
  *
324
- * Gets the value of an attribute as `sb4' datatype.
348
+ * Gets the value of an attribute as `sb4' datatype.
325
349
  *
326
- * @param [Fixnum] attr_type
327
- * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
328
- * @return [Integer]
350
+ * @param [Fixnum] attr_type
351
+ * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
352
+ * @return [Integer]
329
353
  *
330
- * @since 2.0.4
331
- * @private
354
+ * @since 2.0.4
355
+ * @private
332
356
  */
333
357
  static VALUE attr_get_sb4(int argc, VALUE *argv, VALUE self)
334
358
  {
@@ -336,17 +360,16 @@ static VALUE attr_get_sb4(int argc, VALUE *argv, VALUE self)
336
360
  }
337
361
 
338
362
  /*
339
- * call-seq:
340
- * attr_get_sb8(attr_type, strict = true)
363
+ * @overload attr_get_sb8(attr_type, strict = true)
341
364
  *
342
- * Gets the value of an attribute as `sb8' datatype.
365
+ * Gets the value of an attribute as `sb8' datatype.
343
366
  *
344
- * @param [Fixnum] attr_type
345
- * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
346
- * @return [Integer]
367
+ * @param [Fixnum] attr_type
368
+ * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
369
+ * @return [Integer]
347
370
  *
348
- * @since 2.0.4
349
- * @private
371
+ * @since 2.0.4
372
+ * @private
350
373
  */
351
374
  static VALUE attr_get_sb8(int argc, VALUE *argv, VALUE self)
352
375
  {
@@ -354,17 +377,16 @@ static VALUE attr_get_sb8(int argc, VALUE *argv, VALUE self)
354
377
  }
355
378
 
356
379
  /*
357
- * call-seq:
358
- * attr_get_boolean(attr_type, strict = true)
380
+ * @overload attr_get_boolean(attr_type, strict = true)
359
381
  *
360
- * Gets the value of an attribute as `boolean' datatype.
382
+ * Gets the value of an attribute as `boolean' datatype.
361
383
  *
362
- * @param [Fixnum] attr_type
363
- * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
364
- * @return [true of false]
384
+ * @param [Fixnum] attr_type
385
+ * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
386
+ * @return [true of false]
365
387
  *
366
- * @since 2.0.4
367
- * @private
388
+ * @since 2.0.4
389
+ * @private
368
390
  */
369
391
  static VALUE attr_get_boolean(int argc, VALUE *argv, VALUE self)
370
392
  {
@@ -372,22 +394,21 @@ static VALUE attr_get_boolean(int argc, VALUE *argv, VALUE self)
372
394
  }
373
395
 
374
396
  /*
375
- * call-seq:
376
- * attr_get_string(attr_type, strict = true)
397
+ * @overload attr_get_string(attr_type, strict = true)
377
398
  *
378
- * Gets the value of an attribute as `oratext *' datatype.
379
- * The return value is converted to Encoding.default_internal or
380
- * tagged with {OCI8.encoding} when the ruby version is 1.9.
399
+ * Gets the value of an attribute as `oratext *' datatype.
400
+ * The return value is converted to Encoding.default_internal or
401
+ * tagged with {OCI8.encoding} when the ruby version is 1.9.
381
402
  *
382
- * @note If the specified attr_type's datatype is not a
383
- * pointer type, it causes a segmentation fault.
403
+ * @note If the specified attr_type's datatype is not a
404
+ * pointer type, it causes a segmentation fault.
384
405
  *
385
- * @param [Fixnum] attr_type
386
- * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
387
- * @return [String]
406
+ * @param [Fixnum] attr_type
407
+ * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
408
+ * @return [String]
388
409
  *
389
- * @since 2.0.4
390
- * @private
410
+ * @since 2.0.4
411
+ * @private
391
412
  */
392
413
  static VALUE attr_get_string(int argc, VALUE *argv, VALUE self)
393
414
  {
@@ -395,21 +416,20 @@ static VALUE attr_get_string(int argc, VALUE *argv, VALUE self)
395
416
  }
396
417
 
397
418
  /*
398
- * call-seq:
399
- * attr_get_binary(attr_type, strict = true)
419
+ * @overload attr_get_binary(attr_type, strict = true)
400
420
  *
401
- * Gets the value of an attribute as `ub1 *' datatype.
402
- * The return value is tagged with ASCII-8BIT when the ruby version is 1.9.
421
+ * Gets the value of an attribute as `ub1 *' datatype.
422
+ * The return value is tagged with ASCII-8BIT when the ruby version is 1.9.
403
423
  *
404
- * @note If the specified attr_type's datatype is not a
405
- * pointer type, it causes a segmentation fault.
424
+ * @note If the specified attr_type's datatype is not a
425
+ * pointer type, it causes a segmentation fault.
406
426
  *
407
- * @param [Fixnum] attr_type
408
- * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
409
- * @return [String]
427
+ * @param [Fixnum] attr_type
428
+ * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
429
+ * @return [String]
410
430
  *
411
- * @since 2.0.4
412
- * @private
431
+ * @since 2.0.4
432
+ * @private
413
433
  */
414
434
  static VALUE attr_get_binary(int argc, VALUE *argv, VALUE self)
415
435
  {
@@ -417,21 +437,20 @@ static VALUE attr_get_binary(int argc, VALUE *argv, VALUE self)
417
437
  }
418
438
 
419
439
  /*
420
- * call-seq:
421
- * attr_get_integer(attr_type, strict = true)
440
+ * @overload attr_get_integer(attr_type, strict = true)
422
441
  *
423
- * Gets the value of an attribute as `ub1 *' datatype.
424
- * The return value is converted to Integer from internal Oracle NUMBER format.
442
+ * Gets the value of an attribute as `ub1 *' datatype.
443
+ * The return value is converted to Integer from internal Oracle NUMBER format.
425
444
  *
426
- * @note If the specified attr_type's datatype is not a
427
- * pointer type, it causes a segmentation fault.
445
+ * @note If the specified attr_type's datatype is not a
446
+ * pointer type, it causes a segmentation fault.
428
447
  *
429
- * @param [Fixnum] attr_type
430
- * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
431
- * @return [Fixnum]
448
+ * @param [Fixnum] attr_type
449
+ * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
450
+ * @return [Fixnum]
432
451
  *
433
- * @since 2.0.4
434
- * @private
452
+ * @since 2.0.4
453
+ * @private
435
454
  */
436
455
  static VALUE attr_get_integer(int argc, VALUE *argv, VALUE self)
437
456
  {
@@ -439,21 +458,20 @@ static VALUE attr_get_integer(int argc, VALUE *argv, VALUE self)
439
458
  }
440
459
 
441
460
  /*
442
- * call-seq:
443
- * attr_get_oradate(attr_type, strict = true)
461
+ * @overload attr_get_oradate(attr_type, strict = true)
444
462
  *
445
- * Gets the value of an attribute as `ub1 *' datatype.
446
- * The return value is converted to OraDate.
463
+ * Gets the value of an attribute as `ub1 *' datatype.
464
+ * The return value is converted to OraDate.
447
465
  *
448
- * @note If the specified attr_type's datatype is not a
449
- * pointer type, it causes a segmentation fault.
466
+ * @note If the specified attr_type's datatype is not a
467
+ * pointer type, it causes a segmentation fault.
450
468
  *
451
- * @param [Fixnum] attr_type
452
- * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
453
- * @return [OraDate]
469
+ * @param [Fixnum] attr_type
470
+ * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
471
+ * @return [OraDate]
454
472
  *
455
- * @since 2.0.4
456
- * @private
473
+ * @since 2.0.4
474
+ * @private
457
475
  */
458
476
  static VALUE attr_get_oradate(int argc, VALUE *argv, VALUE self)
459
477
  {
@@ -461,24 +479,23 @@ static VALUE attr_get_oradate(int argc, VALUE *argv, VALUE self)
461
479
  }
462
480
 
463
481
  /*
464
- * call-seq:
465
- * attr_set_ub1(attr_type, attr_value)
482
+ * @overload attr_set_ub1(attr_type, attr_value)
466
483
  *
467
- * Sets the value of an attribute as `ub1' datatype.
484
+ * Sets the value of an attribute as `ub1' datatype.
468
485
  *
469
- * @note If the specified attr_type's datatype is a
470
- * pointer type, it causes a segmentation fault.
486
+ * @note If the specified attr_type's datatype is a
487
+ * pointer type, it causes a segmentation fault.
471
488
  *
472
- * @param [Fixnum] attr_type
473
- * @param [Fixnum] attr_value
474
- * @return [self]
489
+ * @param [Fixnum] attr_type
490
+ * @param [Fixnum] attr_value
491
+ * @return [self]
475
492
  *
476
- * @since 2.0.4
477
- * @private
493
+ * @since 2.0.4
494
+ * @private
478
495
  */
479
496
  static VALUE attr_set_ub1(VALUE self, VALUE attr_type, VALUE val)
480
497
  {
481
- oci8_base_t *base = DATA_PTR(self);
498
+ oci8_base_t *base = TO_HANDLE(self);
482
499
  ub1 value;
483
500
 
484
501
  /* validate arguments */
@@ -490,24 +507,23 @@ static VALUE attr_set_ub1(VALUE self, VALUE attr_type, VALUE val)
490
507
  }
491
508
 
492
509
  /*
493
- * call-seq:
494
- * attr_set_ub2(attr_type, attr_value)
510
+ * @overload attr_set_ub2(attr_type, attr_value)
495
511
  *
496
- * Sets the value of an attribute as `ub2' datatype.
512
+ * Sets the value of an attribute as `ub2' datatype.
497
513
  *
498
- * @note If the specified attr_type's datatype is a
499
- * pointer type, it causes a segmentation fault.
514
+ * @note If the specified attr_type's datatype is a
515
+ * pointer type, it causes a segmentation fault.
500
516
  *
501
- * @param [Fixnum] attr_type
502
- * @param [Fixnum] attr_value
503
- * @return [self]
517
+ * @param [Fixnum] attr_type
518
+ * @param [Fixnum] attr_value
519
+ * @return [self]
504
520
  *
505
- * @since 2.0.4
506
- * @private
521
+ * @since 2.0.4
522
+ * @private
507
523
  */
508
524
  static VALUE attr_set_ub2(VALUE self, VALUE attr_type, VALUE val)
509
525
  {
510
- oci8_base_t *base = DATA_PTR(self);
526
+ oci8_base_t *base = TO_HANDLE(self);
511
527
  ub2 value;
512
528
 
513
529
  /* validate arguments */
@@ -519,24 +535,23 @@ static VALUE attr_set_ub2(VALUE self, VALUE attr_type, VALUE val)
519
535
  }
520
536
 
521
537
  /*
522
- * call-seq:
523
- * attr_set_ub4(attr_type, attr_value)
538
+ * @overload attr_set_ub4(attr_type, attr_value)
524
539
  *
525
- * Sets the value of an attribute as `ub4' datatype.
540
+ * Sets the value of an attribute as `ub4' datatype.
526
541
  *
527
- * @note If the specified attr_type's datatype is a
528
- * pointer type, it causes a segmentation fault.
542
+ * @note If the specified attr_type's datatype is a
543
+ * pointer type, it causes a segmentation fault.
529
544
  *
530
- * @param [Fixnum] attr_type
531
- * @param [Integer] attr_value
532
- * @return [self]
545
+ * @param [Fixnum] attr_type
546
+ * @param [Integer] attr_value
547
+ * @return [self]
533
548
  *
534
- * @since 2.0.4
535
- * @private
549
+ * @since 2.0.4
550
+ * @private
536
551
  */
537
552
  static VALUE attr_set_ub4(VALUE self, VALUE attr_type, VALUE val)
538
553
  {
539
- oci8_base_t *base = DATA_PTR(self);
554
+ oci8_base_t *base = TO_HANDLE(self);
540
555
  ub4 value;
541
556
 
542
557
  /* validate arguments */
@@ -548,24 +563,23 @@ static VALUE attr_set_ub4(VALUE self, VALUE attr_type, VALUE val)
548
563
  }
549
564
 
550
565
  /*
551
- * call-seq:
552
- * attr_set_ub8(attr_type, attr_value)
566
+ * @overload attr_set_ub8(attr_type, attr_value)
553
567
  *
554
- * Sets the value of an attribute as `ub8' datatype.
568
+ * Sets the value of an attribute as `ub8' datatype.
555
569
  *
556
- * @note If the specified attr_type's datatype is a
557
- * pointer type, it causes a segmentation fault.
570
+ * @note If the specified attr_type's datatype is a
571
+ * pointer type, it causes a segmentation fault.
558
572
  *
559
- * @param [Fixnum] attr_type
560
- * @param [Integer] attr_value
561
- * @return [self]
573
+ * @param [Fixnum] attr_type
574
+ * @param [Integer] attr_value
575
+ * @return [self]
562
576
  *
563
- * @since 2.0.4
564
- * @private
577
+ * @since 2.0.4
578
+ * @private
565
579
  */
566
580
  static VALUE attr_set_ub8(VALUE self, VALUE attr_type, VALUE val)
567
581
  {
568
- oci8_base_t *base = DATA_PTR(self);
582
+ oci8_base_t *base = TO_HANDLE(self);
569
583
  ub8 value;
570
584
 
571
585
  /* validate arguments */
@@ -577,24 +591,23 @@ static VALUE attr_set_ub8(VALUE self, VALUE attr_type, VALUE val)
577
591
  }
578
592
 
579
593
  /*
580
- * call-seq:
581
- * attr_set_sb1(attr_type, attr_value)
594
+ * @overload attr_set_sb1(attr_type, attr_value)
582
595
  *
583
- * Sets the value of an attribute as `sb1' datatype.
596
+ * Sets the value of an attribute as `sb1' datatype.
584
597
  *
585
- * @note If the specified attr_type's datatype is a
586
- * pointer type, it causes a segmentation fault.
598
+ * @note If the specified attr_type's datatype is a
599
+ * pointer type, it causes a segmentation fault.
587
600
  *
588
- * @param [Fixnum] attr_type
589
- * @param [Fixnum] attr_value
590
- * @return [self]
601
+ * @param [Fixnum] attr_type
602
+ * @param [Fixnum] attr_value
603
+ * @return [self]
591
604
  *
592
- * @since 2.0.4
593
- * @private
605
+ * @since 2.0.4
606
+ * @private
594
607
  */
595
608
  static VALUE attr_set_sb1(VALUE self, VALUE attr_type, VALUE val)
596
609
  {
597
- oci8_base_t *base = DATA_PTR(self);
610
+ oci8_base_t *base = TO_HANDLE(self);
598
611
  sb1 value;
599
612
 
600
613
  /* validate arguments */
@@ -606,24 +619,23 @@ static VALUE attr_set_sb1(VALUE self, VALUE attr_type, VALUE val)
606
619
  }
607
620
 
608
621
  /*
609
- * call-seq:
610
- * attr_set_sb2(attr_type, attr_value)
622
+ * @overload attr_set_sb2(attr_type, attr_value)
611
623
  *
612
- * Sets the value of an attribute as `sb2' datatype.
624
+ * Sets the value of an attribute as `sb2' datatype.
613
625
  *
614
- * @note If the specified attr_type's datatype is a
615
- * pointer type, it causes a segmentation fault.
626
+ * @note If the specified attr_type's datatype is a
627
+ * pointer type, it causes a segmentation fault.
616
628
  *
617
- * @param [Fixnum] attr_type
618
- * @param [Fixnum] attr_value
619
- * @return [self]
629
+ * @param [Fixnum] attr_type
630
+ * @param [Fixnum] attr_value
631
+ * @return [self]
620
632
  *
621
- * @since 2.0.4
622
- * @private
633
+ * @since 2.0.4
634
+ * @private
623
635
  */
624
636
  static VALUE attr_set_sb2(VALUE self, VALUE attr_type, VALUE val)
625
637
  {
626
- oci8_base_t *base = DATA_PTR(self);
638
+ oci8_base_t *base = TO_HANDLE(self);
627
639
  sb2 value;
628
640
 
629
641
  /* validate arguments */
@@ -635,24 +647,23 @@ static VALUE attr_set_sb2(VALUE self, VALUE attr_type, VALUE val)
635
647
  }
636
648
 
637
649
  /*
638
- * call-seq:
639
- * attr_set_sb4(attr_type, attr_value)
650
+ * @overload attr_set_sb4(attr_type, attr_value)
640
651
  *
641
- * Sets the value of an attribute as `sb4' datatype.
652
+ * Sets the value of an attribute as `sb4' datatype.
642
653
  *
643
- * @note If the specified attr_type's datatype is a
644
- * pointer type, it causes a segmentation fault.
654
+ * @note If the specified attr_type's datatype is a
655
+ * pointer type, it causes a segmentation fault.
645
656
  *
646
- * @param [Fixnum] attr_type
647
- * @param [Integer] attr_value
648
- * @return [self]
657
+ * @param [Fixnum] attr_type
658
+ * @param [Integer] attr_value
659
+ * @return [self]
649
660
  *
650
- * @since 2.0.4
651
- * @private
661
+ * @since 2.0.4
662
+ * @private
652
663
  */
653
664
  static VALUE attr_set_sb4(VALUE self, VALUE attr_type, VALUE val)
654
665
  {
655
- oci8_base_t *base = DATA_PTR(self);
666
+ oci8_base_t *base = TO_HANDLE(self);
656
667
  sb4 value;
657
668
 
658
669
  /* validate arguments */
@@ -664,24 +675,23 @@ static VALUE attr_set_sb4(VALUE self, VALUE attr_type, VALUE val)
664
675
  }
665
676
 
666
677
  /*
667
- * call-seq:
668
- * attr_set_sb8(attr_type, attr_value)
678
+ * @overload attr_set_sb8(attr_type, attr_value)
669
679
  *
670
- * Sets the value of an attribute as `sb8' datatype.
680
+ * Sets the value of an attribute as `sb8' datatype.
671
681
  *
672
- * @note If the specified attr_type's datatype is a
673
- * pointer type, it causes a segmentation fault.
682
+ * @note If the specified attr_type's datatype is a
683
+ * pointer type, it causes a segmentation fault.
674
684
  *
675
- * @param [Fixnum] attr_type
676
- * @param [Integer] attr_value
677
- * @return [self]
685
+ * @param [Fixnum] attr_type
686
+ * @param [Integer] attr_value
687
+ * @return [self]
678
688
  *
679
- * @since 2.0.4
680
- * @private
689
+ * @since 2.0.4
690
+ * @private
681
691
  */
682
692
  static VALUE attr_set_sb8(VALUE self, VALUE attr_type, VALUE val)
683
693
  {
684
- oci8_base_t *base = DATA_PTR(self);
694
+ oci8_base_t *base = TO_HANDLE(self);
685
695
  sb8 value;
686
696
 
687
697
  /* validate arguments */
@@ -693,24 +703,23 @@ static VALUE attr_set_sb8(VALUE self, VALUE attr_type, VALUE val)
693
703
  }
694
704
 
695
705
  /*
696
- * call-seq:
697
- * attr_set_boolean(attr_type, attr_value)
706
+ * @overload attr_set_boolean(attr_type, attr_value)
698
707
  *
699
- * Sets the value of an attribute as `boolean' datatype.
708
+ * Sets the value of an attribute as `boolean' datatype.
700
709
  *
701
- * @note If the specified attr_type's datatype is a
702
- * pointer type, it causes a segmentation fault.
710
+ * @note If the specified attr_type's datatype is a
711
+ * pointer type, it causes a segmentation fault.
703
712
  *
704
- * @param [Fixnum] attr_type
705
- * @param [true or false] attr_value
706
- * @return [self]
713
+ * @param [Fixnum] attr_type
714
+ * @param [true or false] attr_value
715
+ * @return [self]
707
716
  *
708
- * @since 2.0.4
709
- * @private
717
+ * @since 2.0.4
718
+ * @private
710
719
  */
711
720
  static VALUE attr_set_boolean(VALUE self, VALUE attr_type, VALUE val)
712
721
  {
713
- oci8_base_t *base = DATA_PTR(self);
722
+ oci8_base_t *base = TO_HANDLE(self);
714
723
  boolean value;
715
724
 
716
725
  /* validate arguments */
@@ -722,23 +731,22 @@ static VALUE attr_set_boolean(VALUE self, VALUE attr_type, VALUE val)
722
731
  }
723
732
 
724
733
  /*
725
- * call-seq:
726
- * attr_set_string(attr_type, attr_value)
734
+ * @overload attr_set_string(attr_type, attr_value)
727
735
  *
728
- * Sets the value of an attribute as `oratext *' datatype.
729
- * +attr_value+ is converted to {OCI8.encoding} before it is set
730
- * when the ruby version is 1.9.
736
+ * Sets the value of an attribute as `oratext *' datatype.
737
+ * +attr_value+ is converted to {OCI8.encoding} before it is set
738
+ * when the ruby version is 1.9.
731
739
  *
732
- * @param [Fixnum] attr_type
733
- * @param [String] attr_value
734
- * @return [self]
740
+ * @param [Fixnum] attr_type
741
+ * @param [String] attr_value
742
+ * @return [self]
735
743
  *
736
- * @since 2.0.4
737
- * @private
744
+ * @since 2.0.4
745
+ * @private
738
746
  */
739
747
  static VALUE attr_set_string(VALUE self, VALUE attr_type, VALUE val)
740
748
  {
741
- oci8_base_t *base = DATA_PTR(self);
749
+ oci8_base_t *base = TO_HANDLE(self);
742
750
 
743
751
  /* validate arguments */
744
752
  Check_Type(attr_type, T_FIXNUM);
@@ -749,21 +757,20 @@ static VALUE attr_set_string(VALUE self, VALUE attr_type, VALUE val)
749
757
  }
750
758
 
751
759
  /*
752
- * call-seq:
753
- * attr_set_binary(attr_type, attr_value)
760
+ * @overload attr_set_binary(attr_type, attr_value)
754
761
  *
755
- * Sets the value of an attribute as `ub1 *' datatype.
762
+ * Sets the value of an attribute as `ub1 *' datatype.
756
763
  *
757
- * @param [Fixnum] attr_type
758
- * @param [String] attr_value
759
- * @return [self]
764
+ * @param [Fixnum] attr_type
765
+ * @param [String] attr_value
766
+ * @return [self]
760
767
  *
761
- * @since 2.0.4
762
- * @private
768
+ * @since 2.0.4
769
+ * @private
763
770
  */
764
771
  static VALUE attr_set_binary(VALUE self, VALUE attr_type, VALUE val)
765
772
  {
766
- oci8_base_t *base = DATA_PTR(self);
773
+ oci8_base_t *base = TO_HANDLE(self);
767
774
 
768
775
  /* validate arguments */
769
776
  Check_Type(attr_type, T_FIXNUM);
@@ -774,23 +781,22 @@ static VALUE attr_set_binary(VALUE self, VALUE attr_type, VALUE val)
774
781
  }
775
782
 
776
783
  /*
777
- * call-seq:
778
- * attr_set_integer(attr_type, number)
784
+ * @overload attr_set_integer(attr_type, number)
779
785
  *
780
- * Sets the value of an attribute as `ub1 *' datatype.
781
- * +number+ is converted to internal Oracle NUMBER format before
782
- * it is set.
786
+ * Sets the value of an attribute as `ub1 *' datatype.
787
+ * +number+ is converted to internal Oracle NUMBER format before
788
+ * it is set.
783
789
  *
784
- * @param [Fixnum] attr_type
785
- * @param [Numeric] number
786
- * @return [self]
790
+ * @param [Fixnum] attr_type
791
+ * @param [Numeric] number
792
+ * @return [self]
787
793
  *
788
- * @since 2.0.4
789
- * @private
794
+ * @since 2.0.4
795
+ * @private
790
796
  */
791
797
  static VALUE attr_set_integer(VALUE self, VALUE attr_type, VALUE val)
792
798
  {
793
- oci8_base_t *base = DATA_PTR(self);
799
+ oci8_base_t *base = TO_HANDLE(self);
794
800
  OCINumber value;
795
801
 
796
802
  /* validate arguments */
@@ -803,8 +809,6 @@ static VALUE attr_set_integer(VALUE self, VALUE attr_type, VALUE val)
803
809
 
804
810
  void Init_oci8_handle(void)
805
811
  {
806
- VALUE obj;
807
-
808
812
  /*
809
813
  * OCIHandle is the abstract base class of OCI handles and
810
814
  * OCI descriptors; opaque data types of Oracle Call Interface.
@@ -816,8 +820,6 @@ void Init_oci8_handle(void)
816
820
  rb_define_alloc_func(oci8_cOCIHandle, oci8_s_allocate);
817
821
  rb_define_method_nodoc(oci8_cOCIHandle, "initialize", oci8_handle_initialize, 0);
818
822
  rb_define_private_method(oci8_cOCIHandle, "free", oci8_handle_free, 0);
819
- obj = Data_Wrap_Struct(rb_cObject, 0, 0, &oci8_base_vtable);
820
- rb_ivar_set(oci8_cOCIHandle, oci8_id_oci8_vtable, obj);
821
823
 
822
824
  /* methods to get attributes */
823
825
  rb_define_private_method(oci8_cOCIHandle, "attr_get_ub1", attr_get_ub1, -1);