numo-narray 0.9.1.2 → 0.9.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -1
  3. data/ext/numo/narray/array.c +6 -6
  4. data/ext/numo/narray/data.c +8 -8
  5. data/ext/numo/narray/depend.erb +4 -4
  6. data/ext/numo/narray/extconf.rb +2 -2
  7. data/ext/numo/narray/gen/cogen.rb +13 -0
  8. data/ext/numo/narray/gen/def/dfloat.rb +1 -0
  9. data/ext/numo/narray/gen/def/sfloat.rb +1 -0
  10. data/ext/numo/narray/gen/narray_def.rb +14 -2
  11. data/ext/numo/narray/gen/spec.rb +26 -10
  12. data/ext/numo/narray/gen/tmpl/accum_binary.c +1 -1
  13. data/ext/numo/narray/gen/tmpl/accum_index.c +11 -1
  14. data/ext/numo/narray/gen/tmpl/alloc_func.c +3 -3
  15. data/ext/numo/narray/gen/tmpl/binary.c +149 -10
  16. data/ext/numo/narray/gen/tmpl/binary2.c +1 -1
  17. data/ext/numo/narray/gen/tmpl/bincount.c +1 -1
  18. data/ext/numo/narray/gen/tmpl/cast.c +1 -1
  19. data/ext/numo/narray/gen/tmpl/cond_binary.c +1 -1
  20. data/ext/numo/narray/gen/tmpl/each.c +1 -1
  21. data/ext/numo/narray/gen/tmpl/each_with_index.c +1 -1
  22. data/ext/numo/narray/gen/tmpl/extract_data.c +3 -3
  23. data/ext/numo/narray/gen/tmpl/inspect.c +1 -1
  24. data/ext/numo/narray/gen/tmpl/lib.c +5 -0
  25. data/ext/numo/narray/gen/tmpl/map_with_index.c +1 -1
  26. data/ext/numo/narray/gen/tmpl/median.c +3 -2
  27. data/ext/numo/narray/gen/tmpl/pow.c +1 -1
  28. data/ext/numo/narray/gen/tmpl/qsort.c +118 -56
  29. data/ext/numo/narray/gen/tmpl/store.c +4 -4
  30. data/ext/numo/narray/gen/tmpl/store_bit.c +4 -4
  31. data/ext/numo/narray/gen/tmpl/to_a.c +1 -1
  32. data/ext/numo/narray/gen/tmpl/unary_s.c +55 -9
  33. data/ext/numo/narray/gen/tmpl_bit/each.c +1 -1
  34. data/ext/numo/narray/gen/tmpl_bit/each_with_index.c +1 -1
  35. data/ext/numo/narray/gen/tmpl_bit/inspect.c +1 -1
  36. data/ext/numo/narray/gen/tmpl_bit/mask.c +1 -1
  37. data/ext/numo/narray/gen/tmpl_bit/to_a.c +1 -1
  38. data/ext/numo/narray/index.c +64 -37
  39. data/ext/numo/narray/math.c +4 -4
  40. data/ext/numo/narray/narray.c +54 -29
  41. data/ext/numo/narray/ndloop.c +7 -7
  42. data/ext/numo/narray/numo/narray.h +9 -2
  43. data/ext/numo/narray/numo/template.h +18 -0
  44. data/ext/numo/narray/numo/types/bit.h +5 -0
  45. data/ext/numo/narray/numo/types/complex_macro.h +5 -0
  46. data/ext/numo/narray/numo/types/float_macro.h +5 -0
  47. data/ext/numo/narray/numo/types/int_macro.h +24 -0
  48. data/ext/numo/narray/numo/types/robj_macro.h +5 -0
  49. data/ext/numo/narray/numo/types/uint_macro.h +24 -0
  50. data/ext/numo/narray/numo/types/xint_macro.h +5 -25
  51. data/ext/numo/narray/rand.c +2 -29
  52. data/ext/numo/narray/step.c +1 -28
  53. data/ext/numo/narray/struct.c +26 -22
  54. data/lib/numo/narray/extra.rb +50 -1
  55. metadata +2 -2
@@ -214,7 +214,7 @@ ndloop_func_loop_spec(ndfunc_t *nf, int user_ndim)
214
214
  static int
215
215
  ndloop_cast_required(VALUE type, VALUE value)
216
216
  {
217
- return CASTABLE(type) && type != CLASS_OF(value);
217
+ return CASTABLE(type) && type != rb_obj_class(value);
218
218
  }
219
219
 
220
220
  static int
@@ -657,7 +657,7 @@ ndloop_check_inplace(VALUE type, int na_ndim, size_t *na_shape, VALUE v)
657
657
  narray_t *na;
658
658
 
659
659
  // type check
660
- if (type != CLASS_OF(v)) {
660
+ if (type != rb_obj_class(v)) {
661
661
  return 0;
662
662
  }
663
663
  GetNArray(v,na);
@@ -724,7 +724,7 @@ ndloop_get_arg_type(ndfunc_t *nf, VALUE args, VALUE t)
724
724
  t = nf->ain[i].type;
725
725
  // if i-th type is Qnil, get the type of i-th input value
726
726
  if (!CASTABLE(t)) {
727
- t = CLASS_OF(RARRAY_AREF(args,i));
727
+ t = rb_obj_class(RARRAY_AREF(args,i));
728
728
  }
729
729
  }
730
730
  return t;
@@ -1392,7 +1392,7 @@ loop_narray(ndfunc_t *nf, na_md_loop_t *lp)
1392
1392
  }
1393
1393
 
1394
1394
 
1395
- VALUE
1395
+ static VALUE
1396
1396
  na_ndloop_main(ndfunc_t *nf, VALUE args, void *opt_ptr)
1397
1397
  {
1398
1398
  unsigned int copy_flag;
@@ -1495,7 +1495,7 @@ na_info_str(VALUE ary)
1495
1495
  GetNArray(ary,na);
1496
1496
  nd = na->ndim;
1497
1497
 
1498
- buf = rb_str_new2(rb_class2name(CLASS_OF(ary)));
1498
+ buf = rb_str_new2(rb_class2name(rb_obj_class(ary)));
1499
1499
  if (NA_TYPE(na) == NARRAY_VIEW_T) {
1500
1500
  rb_str_cat(buf,"(view)",6);
1501
1501
  }
@@ -1644,8 +1644,8 @@ loop_store_subnarray(ndfunc_t *nf, na_md_loop_t *lp, int i0, size_t *c, VALUE a)
1644
1644
  int *dim_map;
1645
1645
  VALUE a_type;
1646
1646
 
1647
- a_type = CLASS_OF(LARG(lp,0).value);
1648
- if (CLASS_OF(a) != a_type) {
1647
+ a_type = rb_obj_class(LARG(lp,0).value);
1648
+ if (rb_obj_class(a) != a_type) {
1649
1649
  a = rb_funcall(a_type, id_cast, 1, a);
1650
1650
  }
1651
1651
  GetNArray(a,na);
@@ -13,8 +13,8 @@ extern "C" {
13
13
  #endif
14
14
  #endif
15
15
 
16
- #define NARRAY_VERSION "0.9.1.2"
17
- #define NARRAY_VERSION_CODE 912
16
+ #define NARRAY_VERSION "0.9.1.3"
17
+ #define NARRAY_VERSION_CODE 913
18
18
 
19
19
  #include <math.h>
20
20
  #include "numo/compat.h"
@@ -107,6 +107,13 @@ extern "C" {
107
107
  # endif
108
108
  #endif
109
109
 
110
+ #if SIZEOF_VALUE > 4
111
+ # undef INT322NUM
112
+ # undef UINT322NUM
113
+ # define INT322NUM(x) INT2FIX(x)
114
+ # define UINT322NUM(x) INT2FIX(x)
115
+ #endif
116
+
110
117
  #ifndef HAVE_TYPE_BOOL
111
118
  typedef int bool;
112
119
  #endif
@@ -145,5 +145,23 @@ is_aligned_step(const ssize_t step, const size_t alignment)
145
145
  return ((step) & ((alignment)-1)) == 0;
146
146
  }
147
147
 
148
+ static inline int
149
+ get_count_of_elements_not_aligned_to_simd_size(const void *ptr, const size_t alignment, const size_t element_size)
150
+ {
151
+ int cnt = (size_t)(ptr) & ((alignment)-1);
152
+ return cnt == 0 ? 0 : (alignment - cnt) / element_size;
153
+ }
154
+
155
+ static inline int is_same_aligned2(const void *ptr1, const void *ptr2, const size_t alignment)
156
+ {
157
+ return ((size_t)(ptr1) & ((alignment)-1)) == ((size_t)(ptr2) & ((alignment)-1));
158
+ }
159
+
160
+ static inline int is_same_aligned3(const void *ptr1, const void *ptr2, const void *ptr3, const size_t alignment)
161
+ {
162
+ return (((size_t)(ptr1) & ((alignment)-1)) == ((size_t)(ptr2) & ((alignment)-1))) &&
163
+ (((size_t)(ptr1) & ((alignment)-1)) == ((size_t)(ptr3) & ((alignment)-1)));
164
+ }
165
+
148
166
 
149
167
  #endif /* ifndef TEMPLATE_H */
@@ -11,6 +11,11 @@ typedef BIT_DIGIT rtype;
11
11
 
12
12
  #define m_from_double(x) (((x)==0) ? 0 : 1)
13
13
  #define m_from_real(x) (((x)==0) ? 0 : 1)
14
+ #define m_from_sint(x) (((x)==0) ? 0 : 1)
15
+ #define m_from_int32(x) (((x)==0) ? 0 : 1)
16
+ #define m_from_int64(x) (((x)==0) ? 0 : 1)
17
+ #define m_from_uint32(x) (((x)==0) ? 0 : 1)
18
+ #define m_from_uint64(x) (((x)==0) ? 0 : 1)
14
19
  #define m_data_to_num(x) INT2FIX(x)
15
20
  #define m_sprintf(s,x) sprintf(s,"%1d",(int)(x))
16
21
 
@@ -43,6 +43,11 @@ static inline dtype c_from_dcomplex(dcomplex x) {
43
43
 
44
44
  #define m_from_double(x) c_new(x,0)
45
45
  #define m_from_real(x) c_new(x,0)
46
+ #define m_from_sint(x) c_new(x,0)
47
+ #define m_from_int32(x) c_new(x,0)
48
+ #define m_from_int64(x) c_new(x,0)
49
+ #define m_from_uint32(x) c_new(x,0)
50
+ #define m_from_uint64(x) c_new(x,0)
46
51
  #define m_from_scomplex(x) c_from_scomplex(x)
47
52
  #define m_from_dcomplex(x) c_from_dcomplex(x)
48
53
 
@@ -17,6 +17,11 @@ extern double pow(double, double);
17
17
 
18
18
  #define m_from_double(x) (x)
19
19
  #define m_from_real(x) (x)
20
+ #define m_from_sint(x) (x)
21
+ #define m_from_int32(x) (x)
22
+ #define m_from_int64(x) (x)
23
+ #define m_from_uint32(x) (x)
24
+ #define m_from_uint64(x) (x)
20
25
 
21
26
  #define m_add(x,y) ((x)+(y))
22
27
  #define m_sub(x,y) ((x)-(y))
@@ -39,3 +39,27 @@ static dtype pow_int(dtype x, int p)
39
39
  }
40
40
  return r;
41
41
  }
42
+
43
+ static inline int64_t f_sum(size_t n, char *p, ssize_t stride)
44
+ {
45
+ int64_t x,y=0;
46
+ size_t i=n;
47
+ for (; i--;) {
48
+ x = *(dtype*)p;
49
+ y += x;
50
+ p += stride;
51
+ }
52
+ return y;
53
+ }
54
+
55
+ static inline int64_t f_prod(size_t n, char *p, ssize_t stride)
56
+ {
57
+ int64_t x,y=1;
58
+ size_t i=n;
59
+ for (; i--;) {
60
+ x = *(dtype*)p;
61
+ y *= x;
62
+ p += stride;
63
+ }
64
+ return y;
65
+ }
@@ -6,6 +6,11 @@
6
6
 
7
7
  #define m_from_double(x) rb_float_new(x)
8
8
  #define m_from_real(x) rb_float_new(x)
9
+ #define m_from_sint(x) INT2FIX(x)
10
+ #define m_from_int32(x) INT322NUM(x)
11
+ #define m_from_int64(x) INT642NUM(x)
12
+ #define m_from_uint32(x) UINT322NUM(x)
13
+ #define m_from_uint64(x) UINT642NUM(x)
9
14
 
10
15
  #define m_add(x,y) rb_funcall(x,'+',1,y)
11
16
  #define m_sub(x,y) rb_funcall(x,'-',1,y)
@@ -30,3 +30,27 @@ static dtype pow_int(dtype x, int p)
30
30
  }
31
31
  return r;
32
32
  }
33
+
34
+ static inline u_int64_t f_sum(size_t n, char *p, ssize_t stride)
35
+ {
36
+ u_int64_t x,y=0;
37
+ size_t i=n;
38
+ for (; i--;) {
39
+ x = *(dtype*)p;
40
+ y += x;
41
+ p += stride;
42
+ }
43
+ return y;
44
+ }
45
+
46
+ static inline u_int64_t f_prod(size_t n, char *p, ssize_t stride)
47
+ {
48
+ u_int64_t x,y=1;
49
+ size_t i=n;
50
+ for (; i--;) {
51
+ x = *(dtype*)p;
52
+ y *= x;
53
+ p += stride;
54
+ }
55
+ return y;
56
+ }
@@ -3,6 +3,11 @@
3
3
 
4
4
  #define m_from_double(x) (x)
5
5
  #define m_from_real(x) (x)
6
+ #define m_from_sint(x) (x)
7
+ #define m_from_int32(x) (x)
8
+ #define m_from_int64(x) (x)
9
+ #define m_from_uint32(x) (x)
10
+ #define m_from_uint64(x) (x)
6
11
 
7
12
  #define m_add(x,y) ((x)+(y))
8
13
  #define m_sub(x,y) ((x)-(y))
@@ -44,31 +49,6 @@
44
49
  #define cmpgt(a,b) \
45
50
  (qsort_cast(a) > qsort_cast(b))
46
51
 
47
-
48
- static inline dtype f_sum(size_t n, char *p, ssize_t stride)
49
- {
50
- dtype x,y=0;
51
- size_t i=n;
52
- for (; i--;) {
53
- x = *(dtype*)p;
54
- y += x;
55
- p += stride;
56
- }
57
- return y;
58
- }
59
-
60
- static inline dtype f_prod(size_t n, char *p, ssize_t stride)
61
- {
62
- dtype x,y=1;
63
- size_t i=n;
64
- for (; i--;) {
65
- x = *(dtype*)p;
66
- y *= x;
67
- p += stride;
68
- }
69
- return y;
70
- }
71
-
72
52
  static inline dtype f_min(size_t n, char *p, ssize_t stride)
73
53
  {
74
54
  dtype x,y;
@@ -10,35 +10,8 @@
10
10
  #include <sys/time.h>
11
11
  #endif
12
12
 
13
- int n_bits(u_int64_t a)
14
- {
15
- int i, x, /*xu,*/ xl, n=5;
16
- u_int64_t m;
17
-
18
- if (a==0) return 0;
19
- //if (a<0) a=-a;
20
-
21
- x = 1<<n;
22
- //xu = 1<<(n+1);
23
- xl = 0;
24
- //printf("%3i, [%3i, %3i], %i\n", i, xu, xl, x);
25
-
26
- for (i=n; i>=0; i--) {
27
- m = ~((1<<(x-1))-1);
28
- if (m & a) {
29
- xl = x;
30
- x += 1<<(i-1);
31
- } else {
32
- //xu = x;
33
- x -= 1<<(i-1);
34
- }
35
- //printf("%3i, [%3i, %3i], %i, 0x%lx, 0x%lx\n", i, xu, xl, x, m, m&a);
36
- }
37
- return xl;
38
- }
39
-
40
13
  static u_int64_t
41
- random_seed()
14
+ random_seed()
42
15
  {
43
16
  static int n = 0;
44
17
  struct timeval tv;
@@ -48,7 +21,7 @@ static u_int64_t
48
21
  }
49
22
 
50
23
  static VALUE
51
- nary_s_srand(int argc, VALUE *argv, VALUE obj)
24
+ nary_s_srand(int argc, VALUE *argv, VALUE obj)
52
25
  {
53
26
  VALUE vseed;
54
27
  u_int64_t seed;
@@ -56,22 +56,7 @@ step_init(
56
56
  SET_EXCL(self, excl);
57
57
  }
58
58
 
59
- VALUE
60
- nary_step_new(
61
- VALUE beg,
62
- VALUE end,
63
- VALUE step,
64
- VALUE len,
65
- VALUE excl
66
- )
67
- {
68
- VALUE self = rb_obj_alloc(na_cStep);
69
-
70
- step_init(self, beg, end, step, len, excl);
71
- return self;
72
- }
73
-
74
- VALUE
59
+ static VALUE
75
60
  nary_step_new2(
76
61
  VALUE range,
77
62
  VALUE step,
@@ -455,18 +440,6 @@ nary_s_step( int argc, VALUE *argv, VALUE mod )
455
440
  }
456
441
 
457
442
 
458
- VALUE
459
- nary_is_sequence( VALUE arg )
460
- {
461
- if ( rb_obj_is_kind_of(arg, rb_cRange) )
462
- return Qtrue;
463
- if ( rb_obj_is_kind_of(arg, na_cStep) )
464
- return Qtrue;
465
- return Qfalse;
466
- }
467
-
468
-
469
-
470
443
  void
471
444
  Init_nary_step()
472
445
  {
@@ -23,7 +23,7 @@ nst_allocate(VALUE self)
23
23
  case NARRAY_DATA_T:
24
24
  ptr = NA_DATA_PTR(na);
25
25
  if (na->size > 0 && ptr == NULL) {
26
- velmsz = rb_const_get(CLASS_OF(self), rb_intern("element_byte_size"));
26
+ velmsz = rb_const_get(rb_obj_class(self), rb_intern("element_byte_size"));
27
27
  ptr = xmalloc(NUM2SIZET(velmsz) * na->size);
28
28
  NA_DATA_PTR(na) = ptr;
29
29
  }
@@ -51,7 +51,7 @@ static VALUE
51
51
  nst_definition(VALUE nst, VALUE idx)
52
52
  {
53
53
  long i;
54
- VALUE def = nst_definitions(CLASS_OF(nst));
54
+ VALUE def = nst_definitions(rb_obj_class(nst));
55
55
  long len = RARRAY_LEN(def);
56
56
 
57
57
  if (TYPE(idx) == T_STRING || TYPE(idx) == T_SYMBOL) {
@@ -76,7 +76,7 @@ nst_definition(VALUE nst, VALUE idx)
76
76
 
77
77
  void na_copy_array_structure(VALUE self, VALUE view);
78
78
 
79
- VALUE
79
+ static VALUE
80
80
  na_make_view_struct(VALUE self, VALUE dtype, VALUE offset)
81
81
  {
82
82
  size_t i, n;
@@ -105,7 +105,7 @@ na_make_view_struct(VALUE self, VALUE dtype, VALUE offset)
105
105
  for (j=na->ndim,k=0; j<ndim; j++,k++) {
106
106
  shape[j] = nt->shape[k];
107
107
  }
108
- klass = CLASS_OF(dtype);
108
+ klass = rb_obj_class(dtype);
109
109
  stridx = ALLOC_N(stridx_t, ndim);
110
110
  stride = na_dtype_elmsz(klass);
111
111
  for (j=ndim,k=nt->ndim; k; ) {
@@ -118,7 +118,7 @@ na_make_view_struct(VALUE self, VALUE dtype, VALUE offset)
118
118
  for (j=0; j<ndim; j++) {
119
119
  shape[j] = na->shape[j];
120
120
  }
121
- klass = CLASS_OF(self);
121
+ klass = rb_obj_class(self);
122
122
  if (TYPE(dtype)==T_CLASS) {
123
123
  if (RTEST(rb_class_inherited_p(dtype,cNArray))) {
124
124
  klass = dtype;
@@ -172,7 +172,7 @@ na_make_view_struct(VALUE self, VALUE dtype, VALUE offset)
172
172
  }
173
173
 
174
174
 
175
- VALUE
175
+ static VALUE
176
176
  nst_field_view(VALUE self, VALUE idx)
177
177
  {
178
178
  VALUE def, type, ofs;
@@ -181,14 +181,14 @@ nst_field_view(VALUE self, VALUE idx)
181
181
  if (!RTEST(def)) {
182
182
  idx = rb_funcall(idx, rb_intern("to_s"), 0);
183
183
  rb_raise(rb_eTypeError, "Invalid field: '%s' for struct %s",
184
- StringValuePtr(idx), rb_class2name(CLASS_OF(self)));
184
+ StringValuePtr(idx), rb_class2name(rb_obj_class(self)));
185
185
  }
186
186
  type = RARRAY_AREF(def,1);
187
187
  ofs = RARRAY_AREF(def,2);
188
188
  return na_make_view_struct(self, type, ofs);
189
189
  }
190
190
 
191
- VALUE
191
+ static VALUE
192
192
  nst_field(VALUE self, VALUE idx)
193
193
  {
194
194
  VALUE obj;
@@ -202,7 +202,7 @@ nst_field(VALUE self, VALUE idx)
202
202
  return obj;
203
203
  }
204
204
 
205
- VALUE
205
+ static VALUE
206
206
  nst_field_set(VALUE self, VALUE idx, VALUE other)
207
207
  {
208
208
  VALUE obj;
@@ -353,7 +353,7 @@ nstruct_add_type(VALUE type, int argc, VALUE *argv, VALUE nst)
353
353
  if (rb_obj_is_kind_of(type,cNArray)) {
354
354
  narray_t *na;
355
355
  GetNArray(type,na);
356
- type = CLASS_OF(type);
356
+ type = rb_obj_class(type);
357
357
  ndim = na->ndim;
358
358
  shape = na->shape;
359
359
  }
@@ -361,7 +361,7 @@ nstruct_add_type(VALUE type, int argc, VALUE *argv, VALUE nst)
361
361
  GetNArrayView(type,nt);
362
362
 
363
363
  nt->stridx = ALLOC_N(stridx_t,ndim);
364
- stride = na_dtype_elmsz(CLASS_OF(type));
364
+ stride = na_dtype_elmsz(rb_obj_class(type));
365
365
  for (j=ndim; j--; ) {
366
366
  SDX_SET_STRIDE(nt->stridx[j], stride);
367
367
  stride *= shape[j];
@@ -441,7 +441,7 @@ nst_create_member_views(VALUE self)
441
441
  long i, len;
442
442
  narray_view_t *ne;
443
443
 
444
- defs = nst_definitions(CLASS_OF(self));
444
+ defs = nst_definitions(rb_obj_class(self));
445
445
  len = RARRAY_LEN(defs);
446
446
  types = rb_ary_new2(len);
447
447
  //ofsts = rb_ary_new2(len);
@@ -472,7 +472,7 @@ nary_struct_to_a(VALUE self)
472
472
 
473
473
 
474
474
 
475
- // ---
475
+ /*
476
476
  static size_t
477
477
  check_array(VALUE item) {
478
478
  narray_t *na;
@@ -490,7 +490,9 @@ check_array(VALUE item) {
490
490
  }
491
491
  return 0;
492
492
  }
493
+ */
493
494
 
495
+ /*
494
496
  static size_t
495
497
  check_array_1d(VALUE item, size_t size) {
496
498
  narray_t *na;
@@ -518,7 +520,9 @@ check_array_1d(VALUE item, size_t size) {
518
520
  }
519
521
  return 0;
520
522
  }
523
+ */
521
524
 
525
+ /*
522
526
  VALUE
523
527
  nst_check_compatibility(VALUE nst, VALUE ary)
524
528
  {
@@ -527,7 +531,7 @@ nst_check_compatibility(VALUE nst, VALUE ary)
527
531
  narray_t *nt;
528
532
 
529
533
  if (TYPE(ary) != T_ARRAY) {
530
- if (nst==CLASS_OF(ary)) { // same Struct
534
+ if (nst==rb_obj_class(ary)) { // same Struct
531
535
  return Qtrue;
532
536
  }
533
537
  return Qfalse;
@@ -579,7 +583,7 @@ nst_check_compatibility(VALUE nst, VALUE ary)
579
583
  }
580
584
  return Qtrue;
581
585
  }
582
-
586
+ */
583
587
 
584
588
 
585
589
  VALUE na_ary_composition_for_struct(VALUE nstruct, VALUE ary);
@@ -600,7 +604,7 @@ iter_nstruct_from_a(na_loop_t *const lp)
600
604
 
601
605
  len = RARRAY_LEN(types);
602
606
  ary = lp->args[1].value;
603
- //rb_p(CLASS_OF(ary));rb_p(ary);
607
+ //rb_p(rb_obj_class(ary));rb_p(ary);
604
608
 
605
609
  for (i=0; i<len; i++) {
606
610
  def = RARRAY_AREF(defs,i);
@@ -629,7 +633,7 @@ nary_struct_cast_array(VALUE klass, VALUE rary)
629
633
  ndfunc_t ndf = {iter_nstruct_from_a, NO_LOOP, 3, 0, ain, 0};
630
634
 
631
635
  //fprintf(stderr,"rary:");rb_p(rary);
632
- //fprintf(stderr,"class_of(rary):");rb_p(CLASS_OF(rary));
636
+ //fprintf(stderr,"class_of(rary):");rb_p(rb_obj_class(rary));
633
637
 
634
638
  //vnc = na_ary_composition_for_struct(klass, rary);
635
639
  //Data_Get_Struct(vnc, na_compose_t, nc);
@@ -715,7 +719,7 @@ nary_struct_store_struct(VALUE self, VALUE obj)
715
719
  static inline VALUE
716
720
  nary_struct_store_array(VALUE self, VALUE obj)
717
721
  {
718
- return nary_struct_store_struct(self, nary_struct_cast_array(CLASS_OF(self),obj));
722
+ return nary_struct_store_struct(self, nary_struct_cast_array(rb_obj_class(self),obj));
719
723
  }
720
724
 
721
725
  /*
@@ -731,13 +735,13 @@ nary_struct_store(VALUE self, VALUE obj)
731
735
  nary_struct_store_array(self,obj);
732
736
  return self;
733
737
  }
734
- if (CLASS_OF(self) == CLASS_OF(obj)) {
738
+ if (rb_obj_class(self) == rb_obj_class(obj)) {
735
739
  nary_struct_store_struct(self,obj);
736
740
  return self;
737
741
  }
738
742
  rb_raise(nary_eCastError, "unknown conversion from %s to %s",
739
- rb_class2name(CLASS_OF(obj)),
740
- rb_class2name(CLASS_OF(self)));
743
+ rb_class2name(rb_obj_class(obj)),
744
+ rb_class2name(rb_obj_class(self)));
741
745
  return self;
742
746
  }
743
747
 
@@ -785,7 +789,7 @@ iter_struct_inspect(char *ptr, size_t pos, VALUE opt)
785
789
  @overload inspect
786
790
  @return [String]
787
791
  */
788
- VALUE
792
+ static VALUE
789
793
  nary_struct_inspect(VALUE ary)
790
794
  {
791
795
  VALUE opt;