carray 1.5.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/NEWS.md +10 -0
- data/TODO.md +1 -0
- data/carray.gemspec +1 -1
- data/ext/ca_iter_block.c +20 -5
- data/ext/ca_iter_dimension.c +21 -10
- data/ext/ca_iter_window.c +17 -5
- data/ext/ca_obj_array.c +73 -10
- data/ext/ca_obj_bitarray.c +21 -6
- data/ext/ca_obj_bitfield.c +21 -11
- data/ext/ca_obj_block.c +34 -10
- data/ext/ca_obj_fake.c +21 -6
- data/ext/ca_obj_farray.c +34 -5
- data/ext/ca_obj_field.c +23 -7
- data/ext/ca_obj_grid.c +36 -7
- data/ext/ca_obj_mapping.c +36 -7
- data/ext/ca_obj_object.c +35 -9
- data/ext/ca_obj_reduce.c +34 -5
- data/ext/ca_obj_refer.c +31 -10
- data/ext/ca_obj_repeat.c +35 -12
- data/ext/ca_obj_select.c +35 -9
- data/ext/ca_obj_shift.c +41 -12
- data/ext/ca_obj_transpose.c +36 -7
- data/ext/ca_obj_unbound_repeat.c +39 -14
- data/ext/ca_obj_window.c +46 -15
- data/ext/carray.h +97 -31
- data/ext/carray_access.c +25 -42
- data/ext/carray_attribute.c +35 -35
- data/ext/carray_call_cfunc.c +28 -28
- data/ext/carray_cast.c +25 -26
- data/ext/carray_cast_func.rb +1 -2
- data/ext/carray_conversion.c +7 -10
- data/ext/carray_copy.c +5 -5
- data/ext/carray_core.c +44 -7
- data/ext/carray_element.c +9 -9
- data/ext/carray_generate.c +7 -7
- data/ext/carray_iterator.c +33 -23
- data/ext/carray_loop.c +9 -9
- data/ext/carray_mask.c +38 -36
- data/ext/carray_math.rb +6 -6
- data/ext/carray_numeric.c +1 -1
- data/ext/carray_operator.c +31 -21
- data/ext/carray_order.c +216 -12
- data/ext/carray_sort_addr.c +2 -2
- data/ext/carray_stat.c +22 -22
- data/ext/carray_stat_proc.rb +13 -13
- data/ext/carray_test.c +8 -8
- data/ext/ruby_carray.c +7 -0
- data/ext/ruby_ccomplex.c +25 -11
- data/ext/version.h +6 -6
- data/lib/carray/inspect.rb +0 -3
- data/lib/carray/io/imagemagick.rb +8 -9
- data/lib/carray/mkmf.rb +1 -0
- data/lib/carray/time.rb +1 -1
- data/spec/Classes/ex1.rb +46 -0
- metadata +4 -6
data/ext/carray_attribute.c
CHANGED
@@ -24,7 +24,7 @@ VALUE
|
|
24
24
|
rb_ca_obj_type (VALUE self)
|
25
25
|
{
|
26
26
|
CArray *ca;
|
27
|
-
|
27
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
28
28
|
return INT2NUM(ca->obj_type);
|
29
29
|
}
|
30
30
|
|
@@ -38,7 +38,7 @@ VALUE
|
|
38
38
|
rb_ca_data_type (VALUE self)
|
39
39
|
{
|
40
40
|
CArray *ca;
|
41
|
-
|
41
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
42
42
|
return INT2NUM(ca->data_type);
|
43
43
|
}
|
44
44
|
|
@@ -52,7 +52,7 @@ VALUE
|
|
52
52
|
rb_ca_ndim (VALUE self)
|
53
53
|
{
|
54
54
|
CArray *ca;
|
55
|
-
|
55
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
56
56
|
return INT2NUM(ca->ndim);
|
57
57
|
}
|
58
58
|
|
@@ -70,7 +70,7 @@ VALUE
|
|
70
70
|
rb_ca_bytes (VALUE self)
|
71
71
|
{
|
72
72
|
CArray *ca;
|
73
|
-
|
73
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
74
74
|
return SIZE2NUM(ca->bytes);
|
75
75
|
}
|
76
76
|
|
@@ -84,7 +84,7 @@ VALUE
|
|
84
84
|
rb_ca_elements (VALUE self)
|
85
85
|
{
|
86
86
|
CArray *ca;
|
87
|
-
|
87
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
88
88
|
return SIZE2NUM(ca->elements);
|
89
89
|
}
|
90
90
|
|
@@ -101,7 +101,7 @@ rb_ca_dim (VALUE self)
|
|
101
101
|
volatile VALUE dim;
|
102
102
|
CArray *ca;
|
103
103
|
int i;
|
104
|
-
|
104
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
105
105
|
dim = rb_ary_new2(ca->ndim);
|
106
106
|
for (i=0; i<ca->ndim; i++) {
|
107
107
|
rb_ary_store(dim, i, SIZE2NUM(ca->dim[i]));
|
@@ -120,7 +120,7 @@ VALUE
|
|
120
120
|
rb_ca_dim0 (VALUE self)
|
121
121
|
{
|
122
122
|
CArray *ca;
|
123
|
-
|
123
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
124
124
|
return SIZE2NUM(ca->dim[0]);
|
125
125
|
}
|
126
126
|
|
@@ -135,7 +135,7 @@ VALUE
|
|
135
135
|
rb_ca_dim1 (VALUE self)
|
136
136
|
{
|
137
137
|
CArray *ca;
|
138
|
-
|
138
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
139
139
|
return ( ca->ndim >= 2 ) ? SIZE2NUM(ca->dim[1]) : Qnil;
|
140
140
|
}
|
141
141
|
|
@@ -150,7 +150,7 @@ VALUE
|
|
150
150
|
rb_ca_dim2 (VALUE self)
|
151
151
|
{
|
152
152
|
CArray *ca;
|
153
|
-
|
153
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
154
154
|
return ( ca->ndim >= 3 ) ? SIZE2NUM(ca->dim[2]) : Qnil;
|
155
155
|
}
|
156
156
|
|
@@ -165,7 +165,7 @@ VALUE
|
|
165
165
|
rb_ca_dim3 (VALUE self)
|
166
166
|
{
|
167
167
|
CArray *ca;
|
168
|
-
|
168
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
169
169
|
return ( ca->ndim >= 4 ) ? SIZE2NUM(ca->dim[3]) : Qnil;
|
170
170
|
}
|
171
171
|
|
@@ -179,7 +179,7 @@ VALUE
|
|
179
179
|
rb_ca_data_type_name (VALUE self)
|
180
180
|
{
|
181
181
|
CArray *ca;
|
182
|
-
|
182
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
183
183
|
return rb_str_new2(ca_type_name[ca->data_type]);
|
184
184
|
}
|
185
185
|
|
@@ -201,7 +201,7 @@ VALUE
|
|
201
201
|
rb_ca_is_scalar (VALUE self)
|
202
202
|
{
|
203
203
|
CArray *ca;
|
204
|
-
|
204
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
205
205
|
return ( ca_is_scalar(ca) ) ? Qtrue : Qfalse;
|
206
206
|
}
|
207
207
|
|
@@ -212,7 +212,7 @@ rb_obj_is_cscalar (VALUE obj)
|
|
212
212
|
{
|
213
213
|
CArray *ca;
|
214
214
|
if ( rb_obj_is_carray(obj) ) {
|
215
|
-
|
215
|
+
TypedData_Get_Struct(obj, CArray, &carray_data_type, ca);
|
216
216
|
return ( ca_is_scalar(ca) ) ? Qtrue : Qfalse;
|
217
217
|
}
|
218
218
|
return Qfalse;
|
@@ -236,7 +236,7 @@ VALUE
|
|
236
236
|
rb_ca_is_entity (VALUE self)
|
237
237
|
{
|
238
238
|
CArray *ca;
|
239
|
-
|
239
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
240
240
|
return ( ca_is_virtual(ca) ) ? Qfalse : Qtrue;
|
241
241
|
}
|
242
242
|
|
@@ -250,7 +250,7 @@ VALUE
|
|
250
250
|
rb_ca_is_virtual (VALUE self)
|
251
251
|
{
|
252
252
|
CArray *ca;
|
253
|
-
|
253
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
254
254
|
return ( ca_is_virtual(ca) ) ? Qtrue : Qfalse;
|
255
255
|
}
|
256
256
|
|
@@ -265,7 +265,7 @@ VALUE
|
|
265
265
|
rb_ca_is_attached (VALUE self)
|
266
266
|
{
|
267
267
|
CArray *ca;
|
268
|
-
|
268
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
269
269
|
return ( ca_is_attached(ca) ) ? Qtrue : Qfalse;
|
270
270
|
}
|
271
271
|
|
@@ -280,7 +280,7 @@ VALUE
|
|
280
280
|
rb_ca_is_empty (VALUE self)
|
281
281
|
{
|
282
282
|
CArray *ca;
|
283
|
-
|
283
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
284
284
|
return ( ca->elements == 0 ) ? Qtrue : Qfalse;
|
285
285
|
}
|
286
286
|
|
@@ -313,7 +313,7 @@ VALUE
|
|
313
313
|
rb_ca_is_read_only (VALUE self)
|
314
314
|
{
|
315
315
|
CArray *ca;
|
316
|
-
|
316
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
317
317
|
return ( ca_is_readonly(ca) ) ? Qtrue : Qfalse;
|
318
318
|
}
|
319
319
|
|
@@ -346,7 +346,7 @@ VALUE
|
|
346
346
|
rb_ca_is_mask_array (VALUE self)
|
347
347
|
{
|
348
348
|
CArray *ca;
|
349
|
-
|
349
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
350
350
|
return ( ca_is_mask_array(ca) ) ? Qtrue : Qfalse;
|
351
351
|
}
|
352
352
|
|
@@ -379,7 +379,7 @@ VALUE
|
|
379
379
|
rb_ca_is_value_array (VALUE self)
|
380
380
|
{
|
381
381
|
CArray *ca;
|
382
|
-
|
382
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
383
383
|
return ( ca_is_value_array(ca) ) ? Qtrue : Qfalse;
|
384
384
|
}
|
385
385
|
|
@@ -401,7 +401,8 @@ VALUE
|
|
401
401
|
rb_ca_is_fixlen_type (VALUE self)
|
402
402
|
{
|
403
403
|
CArray *ca;
|
404
|
-
|
404
|
+
|
405
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
405
406
|
return ca_is_fixlen_type(ca) ? Qtrue : Qfalse;
|
406
407
|
}
|
407
408
|
|
@@ -423,7 +424,7 @@ VALUE
|
|
423
424
|
rb_ca_is_boolean_type (VALUE self)
|
424
425
|
{
|
425
426
|
CArray *ca;
|
426
|
-
|
427
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
427
428
|
return ca_is_boolean_type(ca) ? Qtrue : Qfalse;
|
428
429
|
}
|
429
430
|
|
@@ -446,7 +447,7 @@ VALUE
|
|
446
447
|
rb_ca_is_numeric_type (VALUE self)
|
447
448
|
{
|
448
449
|
CArray *ca;
|
449
|
-
|
450
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
450
451
|
return ca_is_numeric_type(ca) ? Qtrue : Qfalse;
|
451
452
|
}
|
452
453
|
|
@@ -469,7 +470,7 @@ VALUE
|
|
469
470
|
rb_ca_is_integer_type (VALUE self)
|
470
471
|
{
|
471
472
|
CArray *ca;
|
472
|
-
|
473
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
473
474
|
return ca_is_integer_type(ca) ? Qtrue : Qfalse;
|
474
475
|
}
|
475
476
|
|
@@ -499,7 +500,7 @@ VALUE
|
|
499
500
|
rb_ca_is_unsigned_type (VALUE self)
|
500
501
|
{
|
501
502
|
CArray *ca;
|
502
|
-
|
503
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
503
504
|
return ca_is_unsigned_type(ca) ? Qtrue : Qfalse;
|
504
505
|
}
|
505
506
|
|
@@ -522,7 +523,7 @@ VALUE
|
|
522
523
|
rb_ca_is_float_type (VALUE self)
|
523
524
|
{
|
524
525
|
CArray *ca;
|
525
|
-
|
526
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
526
527
|
return ca_is_float_type(ca) ? Qtrue : Qfalse;
|
527
528
|
}
|
528
529
|
|
@@ -545,7 +546,7 @@ VALUE
|
|
545
546
|
rb_ca_is_complex_type (VALUE self)
|
546
547
|
{
|
547
548
|
CArray *ca;
|
548
|
-
|
549
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
549
550
|
return ca_is_complex_type(ca) ? Qtrue : Qfalse;
|
550
551
|
}
|
551
552
|
|
@@ -567,7 +568,7 @@ VALUE
|
|
567
568
|
rb_ca_is_object_type (VALUE self)
|
568
569
|
{
|
569
570
|
CArray *ca;
|
570
|
-
|
571
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
571
572
|
return ca_is_object_type(ca) ? Qtrue : Qfalse;
|
572
573
|
}
|
573
574
|
|
@@ -591,7 +592,6 @@ rb_ca_parent (VALUE self)
|
|
591
592
|
VALUE
|
592
593
|
rb_ca_set_parent (VALUE self, VALUE obj)
|
593
594
|
{
|
594
|
-
OBJ_INFECT(self, obj);
|
595
595
|
rb_ivar_set(self, id_parent, obj);
|
596
596
|
if ( OBJ_FROZEN(obj) ) {
|
597
597
|
rb_ca_freeze(self);
|
@@ -615,7 +615,7 @@ rb_ca_data_class (VALUE self)
|
|
615
615
|
{
|
616
616
|
volatile VALUE parent, data_class;
|
617
617
|
CArray *ca;
|
618
|
-
|
618
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
619
619
|
if ( ca_test_flag(ca, CA_FLAG_NOT_DATA_CLASS) ) {
|
620
620
|
return Qnil;
|
621
621
|
}
|
@@ -641,7 +641,7 @@ rb_ca_data_class (VALUE self)
|
|
641
641
|
}
|
642
642
|
else {
|
643
643
|
CArray *cr;
|
644
|
-
|
644
|
+
TypedData_Get_Struct(parent, CArray, &carray_data_type, cr);
|
645
645
|
if ( cr->bytes != ca->bytes ) { /* byte size mismatch */
|
646
646
|
ca_set_flag(ca, CA_FLAG_NOT_DATA_CLASS);
|
647
647
|
return Qnil;
|
@@ -670,7 +670,7 @@ VALUE
|
|
670
670
|
rb_ca_has_data_class (VALUE self)
|
671
671
|
{
|
672
672
|
CArray *ca;
|
673
|
-
|
673
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
674
674
|
if ( ca_test_flag(ca, CA_FLAG_NOT_DATA_CLASS) ) {
|
675
675
|
return Qfalse;
|
676
676
|
}
|
@@ -756,7 +756,7 @@ rb_ca_root_array (VALUE self)
|
|
756
756
|
{
|
757
757
|
volatile VALUE refary;
|
758
758
|
CArray *ca;
|
759
|
-
|
759
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
760
760
|
if ( ca_is_entity(ca) ) {
|
761
761
|
return self;
|
762
762
|
}
|
@@ -778,7 +778,7 @@ rb_ca_ancestors_loop (VALUE self, VALUE list)
|
|
778
778
|
{
|
779
779
|
volatile VALUE refary;
|
780
780
|
CArray *ca;
|
781
|
-
|
781
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
782
782
|
rb_ary_unshift(list, self);
|
783
783
|
if ( ca_is_entity(ca) ) {
|
784
784
|
return list;
|
@@ -805,7 +805,7 @@ rb_ca_ancestors (VALUE self)
|
|
805
805
|
{
|
806
806
|
volatile VALUE list;
|
807
807
|
CArray *ca;
|
808
|
-
|
808
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
809
809
|
list = rb_ary_new();
|
810
810
|
return rb_ca_ancestors_loop(self, list);
|
811
811
|
}
|
data/ext/carray_call_cfunc.c
CHANGED
@@ -22,7 +22,7 @@ ca_call_cfunc_1 (void (*func)(void *p0), const char *fsync,
|
|
22
22
|
"[BUG] invalid length of fsync arg in rb_ca_call_mathfunc");
|
23
23
|
}
|
24
24
|
|
25
|
-
|
25
|
+
TypedData_Get_Struct(rcx0, CArray, &carray_data_type, cx0);
|
26
26
|
|
27
27
|
ca_attach(cx0);
|
28
28
|
|
@@ -62,8 +62,8 @@ ca_call_cfunc_2 (void (*func)(void *p0, void *p1), const char *fsync,
|
|
62
62
|
"[BUG] invalid length of fsync arg in rb_ca_call_mathfunc");
|
63
63
|
}
|
64
64
|
|
65
|
-
|
66
|
-
|
65
|
+
TypedData_Get_Struct(rcx0, CArray, &carray_data_type, cx0);
|
66
|
+
TypedData_Get_Struct(rcx1, CArray, &carray_data_type, cx1);
|
67
67
|
|
68
68
|
ca_attach_n(2, cx0, cx1);
|
69
69
|
|
@@ -134,9 +134,9 @@ ca_call_cfunc_3 (void (*func)(void *p0, void *p1, void *p2), const char *fsync,
|
|
134
134
|
"[BUG] invalid length of fsync arg in rb_ca_call_mathfunc");
|
135
135
|
}
|
136
136
|
|
137
|
-
|
138
|
-
|
139
|
-
|
137
|
+
TypedData_Get_Struct(rcx0, CArray, &carray_data_type, cx0);
|
138
|
+
TypedData_Get_Struct(rcx1, CArray, &carray_data_type, cx1);
|
139
|
+
TypedData_Get_Struct(rcx2, CArray, &carray_data_type, cx2);
|
140
140
|
|
141
141
|
ca_attach_n(3, cx0, cx1, cx2);
|
142
142
|
|
@@ -214,10 +214,10 @@ ca_call_cfunc_4 (void (*func)(void *p0, void *p1, void *p2, void *p3), const cha
|
|
214
214
|
"[BUG] invalid length of fsync arg in rb_ca_call_mathfunc");
|
215
215
|
}
|
216
216
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
217
|
+
TypedData_Get_Struct(rcx0, CArray, &carray_data_type, cx0);
|
218
|
+
TypedData_Get_Struct(rcx1, CArray, &carray_data_type, cx1);
|
219
|
+
TypedData_Get_Struct(rcx2, CArray, &carray_data_type, cx2);
|
220
|
+
TypedData_Get_Struct(rcx3, CArray, &carray_data_type, cx3);
|
221
221
|
|
222
222
|
ca_attach_n(4, cx0, cx1, cx2, cx3);
|
223
223
|
|
@@ -303,11 +303,11 @@ ca_call_cfunc_5 (void (*func)(void*,void*,void*,void*,void*), const char *fsync,
|
|
303
303
|
"[BUG] invalid length of fsync arg in rb_ca_call_mathfunc");
|
304
304
|
}
|
305
305
|
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
306
|
+
TypedData_Get_Struct(rcx0, CArray, &carray_data_type, cx0);
|
307
|
+
TypedData_Get_Struct(rcx1, CArray, &carray_data_type, cx1);
|
308
|
+
TypedData_Get_Struct(rcx2, CArray, &carray_data_type, cx2);
|
309
|
+
TypedData_Get_Struct(rcx3, CArray, &carray_data_type, cx3);
|
310
|
+
TypedData_Get_Struct(rcx4, CArray, &carray_data_type, cx4);
|
311
311
|
|
312
312
|
ca_attach_n(5, cx0, cx1, cx2, cx3, cx4);
|
313
313
|
|
@@ -400,12 +400,12 @@ ca_call_cfunc_6 (void (*func)(void*,void*,void*,void*,void*,void*), const char *
|
|
400
400
|
"[BUG] invalid length of fsync arg in rb_ca_call_mathfunc");
|
401
401
|
}
|
402
402
|
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
403
|
+
TypedData_Get_Struct(rcx0, CArray, &carray_data_type, cx0);
|
404
|
+
TypedData_Get_Struct(rcx1, CArray, &carray_data_type, cx1);
|
405
|
+
TypedData_Get_Struct(rcx2, CArray, &carray_data_type, cx2);
|
406
|
+
TypedData_Get_Struct(rcx3, CArray, &carray_data_type, cx3);
|
407
|
+
TypedData_Get_Struct(rcx4, CArray, &carray_data_type, cx4);
|
408
|
+
TypedData_Get_Struct(rcx5, CArray, &carray_data_type, cx5);
|
409
409
|
|
410
410
|
ca_attach_n(6, cx0, cx1, cx2, cx3, cx4, cx5);
|
411
411
|
|
@@ -505,13 +505,13 @@ ca_call_cfunc_7 (void (*func)(void*,void*,void*,void*,void*,void*,void*), const
|
|
505
505
|
"[BUG] invalid length of fsync arg in rb_ca_call_mathfunc");
|
506
506
|
}
|
507
507
|
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
508
|
+
TypedData_Get_Struct(rcx0, CArray, &carray_data_type, cx0);
|
509
|
+
TypedData_Get_Struct(rcx1, CArray, &carray_data_type, cx1);
|
510
|
+
TypedData_Get_Struct(rcx2, CArray, &carray_data_type, cx2);
|
511
|
+
TypedData_Get_Struct(rcx3, CArray, &carray_data_type, cx3);
|
512
|
+
TypedData_Get_Struct(rcx4, CArray, &carray_data_type, cx4);
|
513
|
+
TypedData_Get_Struct(rcx5, CArray, &carray_data_type, cx5);
|
514
|
+
TypedData_Get_Struct(rcx6, CArray, &carray_data_type, cx6);
|
515
515
|
|
516
516
|
ca_attach_n(7, cx0, cx1, cx2, cx3, cx4, cx5, cx6);
|
517
517
|
|
data/ext/carray_cast.c
CHANGED
@@ -232,7 +232,7 @@ rb_ca_data_class_to_object (VALUE self)
|
|
232
232
|
CArray *ca;
|
233
233
|
int i;
|
234
234
|
|
235
|
-
|
235
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
236
236
|
|
237
237
|
if ( ca_is_scalar(ca) ) {
|
238
238
|
obj = rb_cscalar_new(CA_OBJECT, 0, ca->mask);
|
@@ -256,7 +256,7 @@ rb_ca_object_to_data_class (VALUE self, VALUE rtype, ca_size_t bytes)
|
|
256
256
|
int i;
|
257
257
|
ID id_encode = rb_intern("encode");
|
258
258
|
|
259
|
-
|
259
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
260
260
|
|
261
261
|
if ( ca_is_scalar(ca) ) {
|
262
262
|
obj = rb_cscalar_new(CA_FIXLEN, bytes, ca->mask);
|
@@ -293,7 +293,7 @@ rb_ca_to_type_internal (int argc, VALUE *argv, VALUE self)
|
|
293
293
|
int8_t data_type;
|
294
294
|
ca_size_t bytes;
|
295
295
|
|
296
|
-
|
296
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
297
297
|
|
298
298
|
rb_scan_args(argc, argv, "11", (VALUE *) &rtype, (VALUE *) &ropt);
|
299
299
|
rb_scan_options(ropt, "bytes", &rbytes);
|
@@ -319,7 +319,7 @@ rb_ca_to_type_internal (int argc, VALUE *argv, VALUE self)
|
|
319
319
|
|
320
320
|
rb_ca_data_type_import(obj, rtype);
|
321
321
|
|
322
|
-
|
322
|
+
TypedData_Get_Struct(obj, CArray, &carray_data_type, cb);
|
323
323
|
|
324
324
|
ca_attach(ca);
|
325
325
|
if ( ca_has_mask(ca) ) {
|
@@ -526,7 +526,7 @@ rb_ca_as_type_internal (int argc, VALUE *argv, VALUE self)
|
|
526
526
|
|
527
527
|
rb_ca_guess_type_and_bytes(rtype, rbytes, &data_type, &bytes);
|
528
528
|
|
529
|
-
|
529
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
530
530
|
if ( ca->data_type == data_type ) {
|
531
531
|
if ( ! ca_is_fixlen_type(ca) ) {
|
532
532
|
return self;
|
@@ -725,8 +725,8 @@ rb_ca_cast_block (ca_size_t n, VALUE ra1, void *ptr1,
|
|
725
725
|
VALUE ra2, void *ptr2)
|
726
726
|
{
|
727
727
|
CArray *ca1, *ca2;
|
728
|
-
|
729
|
-
|
728
|
+
TypedData_Get_Struct(ra1, CArray, &carray_data_type, ca1);
|
729
|
+
TypedData_Get_Struct(ra2, CArray, &carray_data_type, ca2);
|
730
730
|
if ( n < 0 ) {
|
731
731
|
rb_raise(rb_eRuntimeError, "[BUG] in rb_ca_cast_block: negative count");
|
732
732
|
}
|
@@ -738,8 +738,8 @@ VALUE
|
|
738
738
|
rb_ca_ptr2ptr (VALUE ra1, void *ptr1, VALUE ra2, void *ptr2)
|
739
739
|
{
|
740
740
|
CArray *ca1, *ca2;
|
741
|
-
|
742
|
-
|
741
|
+
TypedData_Get_Struct(ra1, CArray, &carray_data_type, ca1);
|
742
|
+
TypedData_Get_Struct(ra2, CArray, &carray_data_type, ca2);
|
743
743
|
ca_cast_func_table[ca1->data_type][ca2->data_type](1, ca1, ptr1, ca2, ptr2, NULL);
|
744
744
|
return Qnil;
|
745
745
|
}
|
@@ -751,11 +751,10 @@ rb_ca_ptr2obj (VALUE self, void *ptr)
|
|
751
751
|
volatile VALUE obj;
|
752
752
|
static CArray dummy;
|
753
753
|
CArray *ca;
|
754
|
-
|
754
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
755
755
|
dummy.data_type = CA_OBJECT;
|
756
756
|
ca_cast_func_table[ca->data_type][CA_OBJECT](1, ca, ptr, &dummy, (void*)&obj, NULL);
|
757
757
|
if ( ca_is_fixlen_type(ca) ) {
|
758
|
-
OBJ_TAINT(obj);
|
759
758
|
return rb_ca_data_class_decode(self, obj);
|
760
759
|
}
|
761
760
|
else {
|
@@ -768,7 +767,7 @@ rb_ca_obj2ptr (VALUE self, VALUE obj, void *ptr)
|
|
768
767
|
{
|
769
768
|
static CArray dummy;
|
770
769
|
CArray *ca;
|
771
|
-
|
770
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
772
771
|
if ( obj == CA_UNDEF ) {
|
773
772
|
memset(ptr, 0, ca->bytes);
|
774
773
|
}
|
@@ -788,7 +787,7 @@ rb_ca_wrap_writable (VALUE arg, VALUE rtype)
|
|
788
787
|
int8_t data_type;
|
789
788
|
|
790
789
|
if ( rb_obj_is_carray(obj) ) { /* obj == carray */
|
791
|
-
|
790
|
+
TypedData_Get_Struct(obj, CArray, &carray_data_type, ca);
|
792
791
|
if ( ca_is_readonly(ca) ) {
|
793
792
|
rb_raise(rb_eRuntimeError, "can't modify read-only carray");
|
794
793
|
}
|
@@ -813,7 +812,7 @@ rb_ca_wrap_writable (VALUE arg, VALUE rtype)
|
|
813
812
|
}
|
814
813
|
else if ( rb_respond_to(obj, rb_intern("ca")) ) { /* respond_to obj.ca */
|
815
814
|
obj = rb_funcall(obj, rb_intern("ca"), 0);
|
816
|
-
|
815
|
+
TypedData_Get_Struct(obj, CArray, &carray_data_type, ca);
|
817
816
|
if ( NIL_P(rtype) ) {
|
818
817
|
data_type = ca->data_type;
|
819
818
|
}
|
@@ -855,7 +854,7 @@ rb_ca_wrap_readonly (VALUE arg, VALUE rtype)
|
|
855
854
|
int8_t data_type;
|
856
855
|
|
857
856
|
if ( rb_obj_is_carray(obj) ) { /* carray */
|
858
|
-
|
857
|
+
TypedData_Get_Struct(obj, CArray, &carray_data_type, ca);
|
859
858
|
if ( NIL_P(rtype) ) {
|
860
859
|
data_type = ca->data_type;
|
861
860
|
}
|
@@ -877,7 +876,7 @@ rb_ca_wrap_readonly (VALUE arg, VALUE rtype)
|
|
877
876
|
}
|
878
877
|
else if ( TYPE(obj) == T_ARRAY ) { /* array */
|
879
878
|
obj = rb_funcall(obj, rb_intern("to_ca"), 0);
|
880
|
-
|
879
|
+
TypedData_Get_Struct(obj, CArray, &carray_data_type, ca);
|
881
880
|
if ( NIL_P(rtype) ) {
|
882
881
|
data_type = CA_OBJECT;
|
883
882
|
}
|
@@ -920,7 +919,7 @@ rb_ca_wrap_readonly (VALUE arg, VALUE rtype)
|
|
920
919
|
}
|
921
920
|
else if ( rb_respond_to(obj, rb_intern("ca")) ) {
|
922
921
|
obj = rb_funcall(obj, rb_intern("ca"), 0);
|
923
|
-
|
922
|
+
TypedData_Get_Struct(obj, CArray, &carray_data_type, ca);
|
924
923
|
if ( NIL_P(rtype) ) {
|
925
924
|
data_type = ca->data_type;
|
926
925
|
}
|
@@ -933,7 +932,7 @@ rb_ca_wrap_readonly (VALUE arg, VALUE rtype)
|
|
933
932
|
}
|
934
933
|
else if ( rb_respond_to(obj, rb_intern("to_ca")) ) {
|
935
934
|
obj = rb_funcall(obj, rb_intern("to_ca"), 0);
|
936
|
-
|
935
|
+
TypedData_Get_Struct(obj, CArray, &carray_data_type, ca);
|
937
936
|
if ( NIL_P(rtype) ) {
|
938
937
|
data_type = ca->data_type;
|
939
938
|
}
|
@@ -1105,17 +1104,17 @@ rb_ca_cast_self_or_other (volatile VALUE *self, volatile VALUE *other)
|
|
1105
1104
|
}
|
1106
1105
|
}
|
1107
1106
|
|
1108
|
-
|
1109
|
-
|
1107
|
+
TypedData_Get_Struct(*self, CArray, &carray_data_type, ca);
|
1108
|
+
TypedData_Get_Struct(*other, CArray, &carray_data_type, cb);
|
1110
1109
|
|
1111
1110
|
if ( ca->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
|
1112
1111
|
*self = ca_ubrep_bind_with(*self, *other);
|
1113
|
-
|
1112
|
+
TypedData_Get_Struct(*self, CArray, &carray_data_type, ca);
|
1114
1113
|
}
|
1115
1114
|
|
1116
1115
|
if ( cb->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
|
1117
1116
|
*other = ca_ubrep_bind_with(*other, *self);
|
1118
|
-
|
1117
|
+
TypedData_Get_Struct(*other, CArray, &carray_data_type, cb);
|
1119
1118
|
}
|
1120
1119
|
|
1121
1120
|
if ( ca_is_scalar(ca) ^ ca_is_scalar(cb) ||
|
@@ -1187,7 +1186,7 @@ rb_ca_cast_other (VALUE *self, volatile VALUE *other)
|
|
1187
1186
|
CScalar *cs;
|
1188
1187
|
int test0, test1;
|
1189
1188
|
|
1190
|
-
|
1189
|
+
TypedData_Get_Struct(*self, CArray, &carray_data_type, ca);
|
1191
1190
|
|
1192
1191
|
if ( ! rb_obj_is_carray(*other) ) {
|
1193
1192
|
if ( rb_ca_is_object_type(*self) ) {
|
@@ -1227,7 +1226,7 @@ rb_ca_cast_other (VALUE *self, volatile VALUE *other)
|
|
1227
1226
|
}
|
1228
1227
|
}
|
1229
1228
|
|
1230
|
-
|
1229
|
+
TypedData_Get_Struct(*other, CScalar, &cscalar_data_type, cs);
|
1231
1230
|
|
1232
1231
|
test0 = ca_cast_table2[cs->data_type][ca->data_type];
|
1233
1232
|
|
@@ -1237,11 +1236,11 @@ rb_ca_cast_other (VALUE *self, volatile VALUE *other)
|
|
1237
1236
|
|
1238
1237
|
}
|
1239
1238
|
|
1240
|
-
|
1239
|
+
TypedData_Get_Struct(*other, CArray, &carray_data_type, cb);
|
1241
1240
|
|
1242
1241
|
if ( cb->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
|
1243
1242
|
*other = ca_ubrep_bind_with(*other, *self);
|
1244
|
-
|
1243
|
+
TypedData_Get_Struct(*other, CArray, &carray_data_type, cb);
|
1245
1244
|
}
|
1246
1245
|
|
1247
1246
|
test1 = ca_cast_table[cb->data_type][ca->data_type];
|
data/ext/carray_cast_func.rb
CHANGED
@@ -250,14 +250,13 @@ FIXLEN.each do |type1|
|
|
250
250
|
bytes = a1->bytes;
|
251
251
|
if ( m ) {
|
252
252
|
while ( n-- ) {
|
253
|
-
if ( !*m ) { *p2 = rb_str_new(p1, bytes);
|
253
|
+
if ( !*m ) { *p2 = rb_str_new(p1, bytes); }
|
254
254
|
p1+=bytes; p2++; m++;
|
255
255
|
}
|
256
256
|
}
|
257
257
|
else {
|
258
258
|
while ( n-- ) {
|
259
259
|
*p2 = rb_str_new(p1, bytes);
|
260
|
-
OBJ_TAINT(*p2);
|
261
260
|
p1+=bytes; p2++;
|
262
261
|
}
|
263
262
|
}
|