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
  * metadata.c
4
4
  *
5
- * Copyright (C) 2006-2009 KUBO Takehiro <kubo@jiubao.org>
5
+ * Copyright (C) 2006-2015 Kubo Takehiro <kubo@jiubao.org>
6
6
  *
7
7
  * implement private methods of classes in OCI8::Metadata module.
8
8
  *
@@ -11,11 +11,13 @@
11
11
  #include "oci8.h"
12
12
 
13
13
  static VALUE mOCI8Metadata;
14
- VALUE cOCI8MetadataBase;
14
+ static VALUE cOCI8MetadataBase;
15
15
  static VALUE ptype_to_class;
16
16
  static VALUE class_to_ptype;
17
17
  static ID id_at_obj_link;
18
18
 
19
+ #define TO_METADATA(obj) ((oci8_metadata_t *)oci8_check_typeddata((obj), &oci8_metadata_base_data_type, 1))
20
+
19
21
  typedef struct {
20
22
  oci8_base_t base;
21
23
  VALUE svc;
@@ -35,17 +37,32 @@ static void oci8_metadata_free(oci8_base_t *base)
35
37
  base->type = 0; /* to prevent OCIDescriptorFree */
36
38
  }
37
39
 
40
+ const oci8_handle_data_type_t oci8_metadata_base_data_type = {
41
+ {
42
+ "OCI8::Metadata::Base",
43
+ {
44
+ (RUBY_DATA_FUNC)oci8_metadata_mark,
45
+ oci8_handle_cleanup,
46
+ oci8_handle_size,
47
+ },
48
+ &oci8_handle_data_type.rb_data_type, NULL,
49
+ #ifdef RUBY_TYPED_WB_PROTECTED
50
+ RUBY_TYPED_WB_PROTECTED,
51
+ #endif
52
+ },
53
+ oci8_metadata_free,
54
+ sizeof(oci8_metadata_t),
55
+ };
56
+
38
57
  VALUE oci8_metadata_create(OCIParam *parmhp, VALUE svc, VALUE parent)
39
58
  {
40
59
  oci8_metadata_t *md;
41
- oci8_base_t *p;
60
+ oci8_base_t *p = oci8_check_typeddata(parent, &oci8_handle_data_type, 1);
42
61
  ub1 ptype;
43
62
  ub4 size;
44
63
  VALUE klass;
45
64
  VALUE obj;
46
65
 
47
- p = oci8_get_handle(parent, oci8_cOCIHandle);
48
-
49
66
  chker2(OCIAttrGet(parmhp, OCI_DTYPE_PARAM, &ptype, &size, OCI_ATTR_PTYPE, oci8_errhp), p);
50
67
  klass = rb_hash_aref(ptype_to_class, INT2FIX(ptype));
51
68
  if (NIL_P(klass))
@@ -54,10 +71,10 @@ VALUE oci8_metadata_create(OCIParam *parmhp, VALUE svc, VALUE parent)
54
71
  if (!RTEST(rb_obj_is_kind_of(obj, cOCI8MetadataBase))) {
55
72
  rb_raise(rb_eRuntimeError, "invalid class in PTYPE_TO_CLASS");
56
73
  }
57
- md = DATA_PTR(obj);
74
+ md = TO_METADATA(obj);
58
75
  md->base.type = OCI_DTYPE_PARAM;
59
76
  md->base.hp.prm = parmhp;
60
- md->svc = svc;
77
+ RB_OBJ_WRITE(obj, &md->svc, svc);
61
78
 
62
79
  if (p->type == OCI_HTYPE_STMT) {
63
80
  md->is_implicit = 1;
@@ -65,6 +82,7 @@ VALUE oci8_metadata_create(OCIParam *parmhp, VALUE svc, VALUE parent)
65
82
  md->is_implicit = 0;
66
83
  }
67
84
  oci8_link_to_parent(&md->base, p);
85
+ RB_OBJ_WRITTEN(obj, Qundef, p->self);
68
86
  return obj;
69
87
  }
70
88
 
@@ -87,7 +105,7 @@ static VALUE metadata_s_register_ptype(VALUE klass, VALUE ptype)
87
105
  */
88
106
  static VALUE metadata_get_param(VALUE self, VALUE idx)
89
107
  {
90
- oci8_metadata_t *md = DATA_PTR(self);
108
+ oci8_metadata_t *md = TO_METADATA(self);
91
109
  oci8_svcctx_t *svcctx = oci8_get_svcctx(md->svc);
92
110
  OCIParam *value;
93
111
  ub4 size = sizeof(value);
@@ -107,7 +125,7 @@ static VALUE metadata_get_param(VALUE self, VALUE idx)
107
125
 
108
126
  static VALUE metadata_get_param_at(VALUE self, VALUE idx)
109
127
  {
110
- oci8_metadata_t *md = DATA_PTR(self);
128
+ oci8_metadata_t *md = TO_METADATA(self);
111
129
  OCIParam *value;
112
130
 
113
131
  chker2(OCIParamGet(md->base.hp.ptr, md->base.type, oci8_errhp, (dvoid *)&value, FIX2INT(idx)),
@@ -117,19 +135,19 @@ static VALUE metadata_get_param_at(VALUE self, VALUE idx)
117
135
 
118
136
  static VALUE metadata_get_con(VALUE self)
119
137
  {
120
- oci8_metadata_t *md = DATA_PTR(self);
138
+ oci8_metadata_t *md = TO_METADATA(self);
121
139
  return md->svc;
122
140
  }
123
141
 
124
142
  static VALUE metadata_is_implicit_p(VALUE self)
125
143
  {
126
- oci8_metadata_t *md = DATA_PTR(self);
144
+ oci8_metadata_t *md = TO_METADATA(self);
127
145
  return md->is_implicit ? Qtrue : Qfalse;
128
146
  }
129
147
 
130
148
  static VALUE oci8_do_describe(VALUE self, void *objptr, ub4 objlen, ub1 objtype, VALUE klass, VALUE check_public)
131
149
  {
132
- oci8_svcctx_t *svcctx = DATA_PTR(self);
150
+ oci8_svcctx_t *svcctx = oci8_get_svcctx(self);
133
151
  OCIParam *parmhp;
134
152
  VALUE type;
135
153
  VALUE obj;
@@ -165,12 +183,12 @@ static VALUE oci8_do_describe(VALUE self, void *objptr, ub4 objlen, ub1 objtype,
165
183
  * call-seq:
166
184
  * __describe(name, klass, check_public)
167
185
  *
168
- * @param [String] name object name
169
- * @param [subclass of OCI8::Metadata::Base] klass
170
- * @param [Boolean] check_public +true+ to look up the object as a public synonym when
171
- * the object does not exist in the current schema and
172
- * the name includes no dots.
173
- * @return [subclass of OCI8::Metadata::Base]
186
+ * @param [String] name object name
187
+ * @param [subclass of OCI8::Metadata::Base] klass
188
+ * @param [Boolean] check_public +true+ to look up the object as a public synonym when
189
+ * the object does not exist in the current schema and
190
+ * the name includes no dots.
191
+ * @return [subclass of OCI8::Metadata::Base]
174
192
  *
175
193
  * @private
176
194
  */
@@ -200,7 +218,7 @@ static VALUE oci8_describe(VALUE self, VALUE name, VALUE klass, VALUE check_publ
200
218
 
201
219
  static VALUE metadata_get_type_metadata(VALUE self, VALUE klass)
202
220
  {
203
- oci8_metadata_t *md = DATA_PTR(self);
221
+ oci8_metadata_t *md = TO_METADATA(self);
204
222
  oci8_svcctx_t *svcctx = oci8_get_svcctx(md->svc);
205
223
  OCIRef *ref = NULL;
206
224
 
@@ -212,7 +230,7 @@ static VALUE metadata_get_type_metadata(VALUE self, VALUE klass)
212
230
 
213
231
  static VALUE metadata_get_tdo_id(VALUE self)
214
232
  {
215
- oci8_metadata_t *md = DATA_PTR(self);
233
+ oci8_metadata_t *md = TO_METADATA(self);
216
234
  oci8_svcctx_t *svcctx = oci8_get_svcctx(md->svc);
217
235
  OCIRef *tdo_ref = NULL;
218
236
  void *tdo;
@@ -232,16 +250,15 @@ static VALUE metadata_get_tdo_id(VALUE self)
232
250
  #endif
233
251
  }
234
252
 
235
- oci8_base_vtable_t oci8_metadata_vtable = {
236
- oci8_metadata_mark,
237
- oci8_metadata_free,
238
- sizeof(oci8_metadata_t),
239
- };
253
+ static VALUE oci8_metadata_alloc(VALUE klass)
254
+ {
255
+ return oci8_allocate_typeddata(klass, &oci8_metadata_base_data_type);
256
+ }
240
257
 
241
258
  void Init_oci8_metadata(VALUE cOCI8)
242
259
  {
243
260
  mOCI8Metadata = rb_define_module_under(cOCI8, "Metadata");
244
- cOCI8MetadataBase = oci8_define_class_under(mOCI8Metadata, "Base", &oci8_metadata_vtable);
261
+ cOCI8MetadataBase = oci8_define_class_under(mOCI8Metadata, "Base", &oci8_metadata_base_data_type, oci8_metadata_alloc);
245
262
  ptype_to_class = rb_hash_new();
246
263
  class_to_ptype = rb_hash_new();
247
264
  rb_global_variable(&ptype_to_class);
@@ -1,6 +1,6 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
2
  /*
3
- * Copyright (C) 2002-2013 Kubo Takehiro <kubo@jiubao.org>
3
+ * Copyright (C) 2002-2014 Kubo Takehiro <kubo@jiubao.org>
4
4
  */
5
5
 
6
6
  /*
@@ -23,6 +23,9 @@ static VALUE cOCI8BindNamedType;
23
23
  static ID id_to_value;
24
24
  static ID id_set_attributes;
25
25
 
26
+ #define TO_TDO(obj) ((oci8_base_t *)oci8_check_typeddata((obj), &oci8_tdo_data_type, 1))
27
+ #define CHECK_TDO(obj) ((void)oci8_check_typeddata((obj), &oci8_tdo_data_type, 1))
28
+
26
29
  typedef struct {
27
30
  oci8_base_t base;
28
31
  VALUE tdo;
@@ -66,16 +69,30 @@ static void oci8_tdo_free(oci8_base_t *base)
66
69
  }
67
70
  }
68
71
 
72
+ static const oci8_handle_data_type_t oci8_tdo_data_type = {
73
+ {
74
+ "OCI8::TDO",
75
+ {
76
+ (RUBY_DATA_FUNC)oci8_tdo_mark,
77
+ oci8_handle_cleanup,
78
+ oci8_handle_size,
79
+ },
80
+ &oci8_handle_data_type.rb_data_type, NULL,
81
+ #ifdef RUBY_TYPED_WB_PROTECTED
82
+ RUBY_TYPED_WB_PROTECTED,
83
+ #endif
84
+ },
85
+ oci8_tdo_free,
86
+ sizeof(oci8_base_t)
87
+ };
88
+
69
89
  static VALUE oci8_tdo_setup(VALUE self, VALUE svc, VALUE md_obj)
70
90
  {
71
- oci8_base_t *tdo = DATA_PTR(self);
91
+ oci8_base_t *tdo = TO_TDO(self);
72
92
  oci8_svcctx_t *svcctx = oci8_get_svcctx(svc);
73
- oci8_base_t *md;
93
+ oci8_base_t *md = oci8_check_typeddata(md_obj, &oci8_metadata_base_data_type, 1);
74
94
  OCIRef *tdo_ref = NULL;
75
95
 
76
- Check_Object(md_obj, cOCI8MetadataBase);
77
- md = DATA_PTR(md_obj);
78
-
79
96
  if (tdo->hp.tdo != NULL) {
80
97
  OCIObjectUnpin(oci8_envhp, oci8_errhp, tdo->hp.tdo);
81
98
  tdo->hp.tdo = NULL;
@@ -87,14 +104,14 @@ static VALUE oci8_tdo_setup(VALUE self, VALUE svc, VALUE md_obj)
87
104
  chker2(OCIObjectPin_nb(svcctx, oci8_envhp, oci8_errhp, tdo_ref, 0, OCI_PIN_ANY, OCI_DURATION_SESSION, OCI_LOCK_NONE, &tdo->hp.ptr),
88
105
  &svcctx->base);
89
106
  oci8_link_to_parent(tdo, &svcctx->base);
107
+ RB_OBJ_WRITTEN(self, Qundef, svc);
90
108
  return self;
91
109
  }
92
110
 
93
- static oci8_base_vtable_t oci8_tdo_vtable = {
94
- oci8_tdo_mark,
95
- oci8_tdo_free,
96
- sizeof(oci8_base_t)
97
- };
111
+ static VALUE oci8_tdo_alloc(VALUE klass)
112
+ {
113
+ return oci8_allocate_typeddata(klass, &oci8_tdo_data_type);
114
+ }
98
115
 
99
116
  static void oci8_named_type_mark(oci8_base_t *base)
100
117
  {
@@ -181,28 +198,32 @@ static VALUE get_attribute(VALUE self, VALUE datatype, VALUE typeinfo, void *dat
181
198
  case ATTR_BINARY_FLOAT:
182
199
  return rb_float_new((double)*(float*)data);
183
200
  case ATTR_NAMED_TYPE:
184
- Check_Object(typeinfo, cOCI8TDO);
201
+ CHECK_TDO(typeinfo);
185
202
  /* Be carefull. Don't use *tmp_obj* out of this function. */
186
203
  tmp_obj = rb_class_new_instance(0, NULL, cOCI8NamedType);
187
204
  obj = DATA_PTR(tmp_obj);
188
- obj->tdo = typeinfo;
205
+ RB_OBJ_WRITE(tmp_obj, &obj->tdo, typeinfo);
189
206
  obj->instancep = (char**)&data;
190
207
  obj->null_structp = (char**)&ind;
191
208
  oci8_link_to_parent(&obj->base, DATA_PTR(self));
209
+ RB_OBJ_WRITTEN(tmp_obj, Qundef, self);
192
210
  rv = rb_funcall(tmp_obj, id_to_value, 0);
193
211
  oci8_unlink_from_parent(&obj->base);
212
+ RB_OBJ_WRITTEN(tmp_obj, self, Qundef);
194
213
  return rv;
195
214
  case ATTR_NAMED_COLLECTION:
196
- Check_Object(typeinfo, cOCI8TDO);
215
+ CHECK_TDO(typeinfo);
197
216
  /* Be carefull. Don't use *tmp_obj* out of this function. */
198
217
  tmp_obj = rb_class_new_instance(0, NULL, cOCI8NamedCollection);
199
218
  obj = DATA_PTR(tmp_obj);
200
- obj->tdo = typeinfo;
219
+ RB_OBJ_WRITE(tmp_obj, &obj->tdo, typeinfo);
201
220
  obj->instancep = (char**)data;
202
221
  obj->null_structp = (char**)&ind;
203
222
  oci8_link_to_parent(&obj->base, DATA_PTR(self));
223
+ RB_OBJ_WRITTEN(tmp_obj, Qundef, self);
204
224
  rv = rb_funcall(tmp_obj, id_to_value, 0);
205
225
  oci8_unlink_from_parent(&obj->base);
226
+ RB_OBJ_WRITTEN(tmp_obj, self, Qundef);
206
227
  return rv;
207
228
  case ATTR_CLOB:
208
229
  return oci8_make_clob(oci8_get_svcctx(typeinfo), *(OCILobLocator**)data);
@@ -359,16 +380,14 @@ static VALUE oci8_named_coll_set_coll_element(VALUE self, VALUE datatype, VALUE
359
380
  cb_data.indp = &cb_data.ind;
360
381
  break;
361
382
  case ATTR_NAMED_TYPE:
362
- Check_Object(typeinfo, cOCI8TDO);
363
- tdo = DATA_PTR(typeinfo);
383
+ tdo = TO_TDO(typeinfo);
364
384
  chker2(OCIObjectNew(oci8_envhp, oci8_errhp, svcctx->hp.svc, OCI_TYPECODE_OBJECT, tdo->hp.tdo, NULL, OCI_DURATION_SESSION, TRUE, &cb_data.data.ptr),
365
385
  svcctx);
366
386
  chker2(OCIObjectGetInd(oci8_envhp, oci8_errhp, cb_data.data.ptr, (dvoid**)&cb_data.indp),
367
387
  svcctx);
368
388
  break;
369
389
  case ATTR_NAMED_COLLECTION:
370
- Check_Object(typeinfo, cOCI8TDO);
371
- tdo = DATA_PTR(typeinfo);
390
+ tdo = TO_TDO(typeinfo);
372
391
  chker2(OCIObjectNew(oci8_envhp, oci8_errhp, svcctx->hp.svc, OCI_TYPECODE_NAMEDCOLLECTION, tdo->hp.tdo, NULL, OCI_DURATION_SESSION, TRUE, &cb_data.data.ptr),
373
392
  svcctx);
374
393
  chker2(OCIObjectGetInd(oci8_envhp, oci8_errhp, cb_data.data.ptr, (dvoid**)&cb_data.indp),
@@ -411,10 +430,10 @@ static VALUE set_coll_element_func(set_coll_element_cb_data_t *cb_data)
411
430
  for (idx = 0; idx < RARRAY_LEN(val); idx++) {
412
431
  switch (FIX2INT(datatype)) {
413
432
  case ATTR_NAMED_TYPE:
414
- set_attribute(self, datatype, typeinfo, cb_data->data.ptr, cb_data->indp, RARRAY_PTR(val)[idx]);
433
+ set_attribute(self, datatype, typeinfo, cb_data->data.ptr, cb_data->indp, RARRAY_AREF(val, idx));
415
434
  break;
416
435
  default:
417
- set_attribute(self, datatype, typeinfo, (void*)&cb_data->data, cb_data->indp, RARRAY_PTR(val)[idx]);
436
+ set_attribute(self, datatype, typeinfo, (void*)&cb_data->data, cb_data->indp, RARRAY_AREF(val, idx));
418
437
  break;
419
438
  }
420
439
  switch (FIX2INT(datatype)) {
@@ -504,28 +523,32 @@ static void set_attribute(VALUE self, VALUE datatype, VALUE typeinfo, void *data
504
523
  *(float*)data = (float)NUM2DBL(val);
505
524
  break;
506
525
  case ATTR_NAMED_TYPE:
507
- Check_Object(typeinfo, cOCI8TDO);
526
+ CHECK_TDO(typeinfo);
508
527
  /* Be carefull. Don't use *tmp_obj* out of this function. */
509
528
  tmp_obj = rb_class_new_instance(0, NULL, cOCI8NamedType);
510
529
  obj = DATA_PTR(tmp_obj);
511
- obj->tdo = typeinfo;
530
+ RB_OBJ_WRITE(tmp_obj, &obj->tdo, typeinfo);
512
531
  obj->instancep = (char**)&data;
513
532
  obj->null_structp = (char**)&ind;
514
533
  oci8_link_to_parent(&obj->base, DATA_PTR(self));
534
+ RB_OBJ_WRITTEN(tmp_obj, Qundef, self);
515
535
  rb_funcall(tmp_obj, id_set_attributes, 1, val);
516
536
  oci8_unlink_from_parent(&obj->base);
537
+ RB_OBJ_WRITTEN(tmp_obj, self, Qundef);
517
538
  break;
518
539
  case ATTR_NAMED_COLLECTION:
519
- Check_Object(typeinfo, cOCI8TDO);
540
+ CHECK_TDO(typeinfo);
520
541
  /* Be carefull. Don't use *tmp_obj* out of this function. */
521
542
  tmp_obj = rb_class_new_instance(0, NULL, cOCI8NamedCollection);
522
543
  obj = DATA_PTR(tmp_obj);
523
- obj->tdo = typeinfo;
544
+ RB_OBJ_WRITE(tmp_obj, &obj->tdo, typeinfo);
524
545
  obj->instancep = (char**)data;
525
546
  obj->null_structp = (char**)&ind;
526
547
  oci8_link_to_parent(&obj->base, DATA_PTR(self));
548
+ RB_OBJ_WRITTEN(tmp_obj, Qundef, self);
527
549
  rb_funcall(tmp_obj, id_set_attributes, 1, val);
528
550
  oci8_unlink_from_parent(&obj->base);
551
+ RB_OBJ_WRITTEN(tmp_obj, self, Qundef);
529
552
  break;
530
553
  case ATTR_CLOB:
531
554
  oci8_assign_clob(oci8_get_svcctx(typeinfo), val, (OCILobLocator **)data);
@@ -545,12 +568,50 @@ static void set_attribute(VALUE self, VALUE datatype, VALUE typeinfo, void *data
545
568
  *ind = 0;
546
569
  }
547
570
 
548
- static oci8_base_vtable_t oci8_named_type_vtable = {
549
- oci8_named_type_mark,
571
+ static const oci8_handle_data_type_t oci8_named_type_data_type = {
572
+ {
573
+ "OCI8::NamedType",
574
+ {
575
+ (RUBY_DATA_FUNC)oci8_named_type_mark,
576
+ oci8_handle_cleanup,
577
+ oci8_handle_size,
578
+ },
579
+ &oci8_handle_data_type.rb_data_type, NULL,
580
+ #ifdef RUBY_TYPED_WB_PROTECTED
581
+ RUBY_TYPED_WB_PROTECTED,
582
+ #endif
583
+ },
584
+ oci8_named_type_free,
585
+ sizeof(oci8_named_type_t)
586
+ };
587
+
588
+ static const oci8_handle_data_type_t oci8_named_collection_data_type = {
589
+ {
590
+ "OCI8::NamedCollection",
591
+ {
592
+ (RUBY_DATA_FUNC)oci8_named_type_mark,
593
+ oci8_handle_cleanup,
594
+ oci8_handle_size,
595
+ },
596
+ &oci8_handle_data_type.rb_data_type, NULL,
597
+ #ifdef RUBY_TYPED_WB_PROTECTED
598
+ RUBY_TYPED_WB_PROTECTED,
599
+ #endif
600
+ },
550
601
  oci8_named_type_free,
551
602
  sizeof(oci8_named_type_t)
552
603
  };
553
604
 
605
+ static VALUE oci8_named_type_alloc(VALUE klass)
606
+ {
607
+ return oci8_allocate_typeddata(klass, &oci8_named_type_data_type);
608
+ }
609
+
610
+ static VALUE oci8_named_collection_alloc(VALUE klass)
611
+ {
612
+ return oci8_allocate_typeddata(klass, &oci8_named_collection_data_type);
613
+ }
614
+
554
615
  static void bind_named_type_mark(oci8_base_t *base)
555
616
  {
556
617
  oci8_bind_t *obind = (oci8_bind_t *)base;
@@ -602,8 +663,8 @@ static void bind_named_type_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE
602
663
  obind->value_sz = sizeof(void*);
603
664
  obind->alloc_sz = sizeof(oci8_hp_obj_t);
604
665
 
605
- Check_Object(tdo_obj, cOCI8TDO);
606
- obind->tdo = tdo_obj;
666
+ CHECK_TDO(tdo_obj);
667
+ RB_OBJ_WRITE(obind->base.self, &obind->tdo, tdo_obj);
607
668
  }
608
669
 
609
670
  static void bind_named_type_init_elem(oci8_bind_t *obind, VALUE svc)
@@ -627,11 +688,13 @@ static void bind_named_type_init_elem(oci8_bind_t *obind, VALUE svc)
627
688
  svcctx = oci8_get_svcctx(svc);
628
689
  do {
629
690
  oho[idx].obj = rb_class_new_instance(0, NULL, klass);
691
+ RB_OBJ_WRITTEN(obind->base.self, Qundef, oho[idx].obj);
630
692
  obj = DATA_PTR(oho[idx].obj);
631
- obj->tdo = obind->tdo;
693
+ RB_OBJ_WRITE(oho[idx].obj, &obj->tdo, obind->tdo);
632
694
  obj->instancep = (char**)&oho[idx].hp;
633
695
  obj->null_structp = (char**)&obind->u.null_structs[idx];
634
696
  oci8_link_to_parent(&obj->base, &obind->base);
697
+ RB_OBJ_WRITTEN(oho[idx].obj, Qundef, obind->base.self);
635
698
 
636
699
  chker2(OCIObjectNew(oci8_envhp, oci8_errhp, svcctx->base.hp.svc, tc, tdo->hp.tdo, NULL, OCI_DURATION_SESSION, TRUE, (dvoid**)obj->instancep),
637
700
  &svcctx->base);
@@ -658,9 +721,20 @@ static void bind_name_type_post_bind_hook(oci8_bind_t *obind)
658
721
  }
659
722
  }
660
723
 
661
- static const oci8_bind_vtable_t bind_named_type_vtable = {
724
+ static const oci8_bind_data_type_t bind_named_type_data_type = {
662
725
  {
663
- bind_named_type_mark,
726
+ {
727
+ "OCI8::BindType::NamedType",
728
+ {
729
+ (RUBY_DATA_FUNC)bind_named_type_mark,
730
+ oci8_handle_cleanup,
731
+ oci8_handle_size,
732
+ },
733
+ &oci8_bind_data_type.rb_data_type, NULL,
734
+ #ifdef RUBY_TYPED_WB_PROTECTED
735
+ RUBY_TYPED_WB_PROTECTED,
736
+ #endif
737
+ },
664
738
  bind_named_type_free,
665
739
  sizeof(oci8_bind_t)
666
740
  },
@@ -673,13 +747,18 @@ static const oci8_bind_vtable_t bind_named_type_vtable = {
673
747
  bind_name_type_post_bind_hook,
674
748
  };
675
749
 
750
+ static VALUE bind_named_type_alloc(VALUE klass)
751
+ {
752
+ return oci8_allocate_typeddata(klass, &bind_named_type_data_type.base);
753
+ }
754
+
676
755
  void Init_oci_object(VALUE cOCI8)
677
756
  {
678
757
  id_to_value = rb_intern("to_value");
679
758
  id_set_attributes = rb_intern("attributes=");
680
759
 
681
760
  /* OCI8::TDO */
682
- cOCI8TDO = oci8_define_class_under(cOCI8, "TDO", &oci8_tdo_vtable);
761
+ cOCI8TDO = oci8_define_class_under(cOCI8, "TDO", &oci8_tdo_data_type, oci8_tdo_alloc);
683
762
  rb_define_private_method(cOCI8TDO, "setup", oci8_tdo_setup, 2);
684
763
  /* @private */
685
764
  rb_define_const(cOCI8TDO, "ATTR_STRING", INT2FIX(ATTR_STRING));
@@ -732,7 +811,7 @@ void Init_oci_object(VALUE cOCI8)
732
811
  rb_define_const(cOCI8TDO, "ALIGNMENT_OF_DOUBLE", INT2FIX(ALIGNMENT_OF(double)));
733
812
 
734
813
  /* OCI8::NamedType */
735
- cOCI8NamedType = oci8_define_class_under(cOCI8, "NamedType", &oci8_named_type_vtable);
814
+ cOCI8NamedType = oci8_define_class_under(cOCI8, "NamedType", &oci8_named_type_data_type, oci8_named_type_alloc);
736
815
  rb_define_method(cOCI8NamedType, "initialize", oci8_named_type_initialize, 0);
737
816
  rb_define_method(cOCI8NamedType, "tdo", oci8_named_type_tdo, 0);
738
817
  rb_define_private_method(cOCI8NamedType, "get_attribute", oci8_named_type_get_attribute, 4);
@@ -741,12 +820,12 @@ void Init_oci_object(VALUE cOCI8)
741
820
  rb_define_method(cOCI8NamedType, "null=", oci8_named_type_set_null, 1);
742
821
 
743
822
  /* OCI8::NamedCollection */
744
- cOCI8NamedCollection = oci8_define_class_under(cOCI8, "NamedCollection", &oci8_named_type_vtable);
823
+ cOCI8NamedCollection = oci8_define_class_under(cOCI8, "NamedCollection", &oci8_named_collection_data_type, oci8_named_collection_alloc);
745
824
  rb_define_method(cOCI8NamedCollection, "initialize", oci8_named_type_initialize, 0);
746
825
  rb_define_method(cOCI8NamedCollection, "tdo", oci8_named_type_tdo, 0);
747
826
  rb_define_private_method(cOCI8NamedCollection, "get_coll_element", oci8_named_coll_get_coll_element, 2);
748
827
  rb_define_private_method(cOCI8NamedCollection, "set_coll_element", oci8_named_coll_set_coll_element, 3);
749
828
 
750
829
  /* OCI8::BindType::NamedType */
751
- cOCI8BindNamedType = oci8_define_bind_class("NamedType", &bind_named_type_vtable);
830
+ cOCI8BindNamedType = oci8_define_bind_class("NamedType", &bind_named_type_data_type, bind_named_type_alloc);
752
831
  }