carray 3.0.7 → 3.1.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.
Files changed (275) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -1
  3. data/CHANGELOG.md +7 -1940
  4. data/README.md +38 -32
  5. data/carray.gemspec +16 -4
  6. data/docs/changelogs/CHANGELOG-3.0.md +2464 -0
  7. data/ext/ca_array_pool.c +4 -5
  8. data/ext/ca_axis_descriptor.h +45 -30
  9. data/ext/ca_axis_dispatch.c +7 -4
  10. data/ext/ca_axis_group.c +6 -9
  11. data/ext/ca_bincmp_dispatch.h +16 -38
  12. data/ext/ca_binop_dispatch.c +27 -0
  13. data/ext/ca_binop_dispatch.h +22 -47
  14. data/ext/ca_categorical_iterator.c +36 -34
  15. data/ext/ca_compare.c +0 -1
  16. data/ext/ca_compare.h +8 -1
  17. data/ext/ca_composite_dispatch.h +6 -0
  18. data/ext/ca_for_buffer.h +6 -1
  19. data/ext/ca_group_iter.c +17 -18
  20. data/ext/ca_iter_state_fields.h +196 -0
  21. data/ext/ca_iter_substrate.h +84 -103
  22. data/ext/ca_kernel_iterator.c +125 -89
  23. data/ext/ca_kernel_iterator.h +229 -1506
  24. data/ext/ca_kernel_iterator_internal.h +1167 -0
  25. data/ext/ca_moncmp_dispatch.h +17 -24
  26. data/ext/ca_monop_dispatch.h +25 -74
  27. data/ext/ca_obj_array.c +90 -163
  28. data/ext/ca_obj_bincmp.c +47 -46
  29. data/ext/ca_obj_binop.c +38 -38
  30. data/ext/ca_obj_bitarray.c +5 -17
  31. data/ext/ca_obj_bitfield.c +15 -30
  32. data/ext/ca_obj_block.c +11 -12
  33. data/ext/ca_obj_byte_swap.c +32 -30
  34. data/ext/ca_obj_const_string.c +57 -62
  35. data/ext/ca_obj_face.c +99 -91
  36. data/ext/ca_obj_face.h +32 -170
  37. data/ext/ca_obj_fake.c +15 -21
  38. data/ext/ca_obj_farray.c +7 -9
  39. data/ext/ca_obj_field.c +17 -13
  40. data/ext/ca_obj_fixlen_string.c +8 -19
  41. data/ext/ca_obj_grid.c +137 -106
  42. data/ext/ca_obj_meld.c +23 -21
  43. data/ext/ca_obj_moncmp.c +10 -21
  44. data/ext/ca_obj_monop.c +24 -35
  45. data/ext/ca_obj_object.c +51 -37
  46. data/ext/ca_obj_record.c +74 -22
  47. data/ext/ca_obj_reduce.c +8 -10
  48. data/ext/ca_obj_refer.c +42 -29
  49. data/ext/ca_obj_remap.c +11 -29
  50. data/ext/ca_obj_repeat.c +41 -23
  51. data/ext/ca_obj_roll.c +18 -24
  52. data/ext/ca_obj_select.c +10 -22
  53. data/ext/ca_obj_select_axis.c +27 -36
  54. data/ext/ca_obj_shift.c +22 -42
  55. data/ext/ca_obj_source.c +1 -5
  56. data/ext/ca_obj_stack.c +28 -24
  57. data/ext/ca_obj_stride.c +53 -54
  58. data/ext/ca_obj_string.c +6 -18
  59. data/ext/ca_obj_tile.c +12 -12
  60. data/ext/ca_obj_time.c +12 -23
  61. data/ext/ca_obj_timedelta.c +12 -23
  62. data/ext/ca_obj_transpose.c +8 -10
  63. data/ext/ca_obj_triop.c +35 -39
  64. data/ext/ca_obj_window.c +67 -86
  65. data/ext/ca_op_cmplx64.h +4 -0
  66. data/ext/ca_op_ipower.c +34 -12
  67. data/ext/ca_op_powi.h +4 -0
  68. data/ext/ca_pow5_table.h +2 -1
  69. data/ext/ca_rng_normal.h +4 -0
  70. data/ext/ca_rng_xoshiro256pp.h +3 -0
  71. data/ext/ca_sort_kernels.h +20 -26
  72. data/ext/ca_sweep_engine.c +2 -3
  73. data/ext/ca_sweep_engine.h +17 -9
  74. data/ext/ca_transform_common.c +3 -8
  75. data/ext/ca_triop_dispatch.h +20 -32
  76. data/ext/caframe_csv_reader.c +11 -11
  77. data/ext/carray.h +300 -1011
  78. data/ext/carray_access.c +234 -180
  79. data/ext/carray_address_basis.c +33 -38
  80. data/ext/carray_attribute.c +81 -104
  81. data/ext/carray_bincount.c +12 -14
  82. data/ext/carray_broadcast.c +30 -26
  83. data/ext/carray_call_cfunc.c +169 -277
  84. data/ext/carray_call_cfunc.h +36 -28
  85. data/ext/carray_cast.c +912 -346
  86. data/ext/carray_cast_func.rb +31 -3
  87. data/ext/carray_class.c +6 -11
  88. data/ext/carray_conversion.c +43 -38
  89. data/ext/carray_copy.c +28 -26
  90. data/ext/carray_core.c +217 -126
  91. data/ext/carray_count.c +27 -15
  92. data/ext/carray_element.c +40 -25
  93. data/ext/carray_factorize.c +53 -52
  94. data/ext/carray_generate.c +26 -19
  95. data/ext/carray_histogram.c +8 -10
  96. data/ext/carray_hold.c +7 -9
  97. data/ext/carray_index_classifier.c +123 -228
  98. data/ext/carray_index_classifier.h +11 -10
  99. data/ext/carray_integer_total.c +523 -0
  100. data/ext/carray_internal.h +1274 -160
  101. data/ext/carray_key_windows.c +3 -3
  102. data/ext/carray_lazy.c +21 -36
  103. data/ext/carray_loop.c +19 -22
  104. data/ext/carray_mask.c +123 -145
  105. data/ext/carray_math_kernel.h +23 -47
  106. data/ext/carray_mathfunc.c +10 -3
  107. data/ext/carray_median_percentile.c +95 -94
  108. data/ext/carray_memory_view.c +42 -47
  109. data/ext/carray_operator.c +423 -122
  110. data/ext/carray_order.c +121 -85
  111. data/ext/carray_partition.c +13 -15
  112. data/ext/carray_random.c +47 -41
  113. data/ext/carray_round.c +9 -4
  114. data/ext/carray_scatter.c +54 -40
  115. data/ext/carray_segment.c +41 -45
  116. data/ext/carray_slab.c +64 -47
  117. data/ext/carray_slab.h +44 -33
  118. data/ext/carray_sort.c +32 -29
  119. data/ext/carray_sort_kernel.c +12 -10
  120. data/ext/carray_struct.c +38 -43
  121. data/ext/carray_test.c +47 -43
  122. data/ext/carray_time_text.c +24 -31
  123. data/ext/carray_undef.c +50 -7
  124. data/ext/carray_utils.c +258 -94
  125. data/ext/extconf.rb +24 -17
  126. data/ext/mk_call_cfunc.rb +19 -20
  127. data/ext/mk_pow5_table.rb +2 -1
  128. data/ext/mkkernel.rb +782 -461
  129. data/ext/ruby_carray.c +47 -42
  130. data/ext/version.h +7 -5
  131. data/lib/carray/attribute.rb +19 -18
  132. data/lib/carray/autoload_carray.rb +20 -15
  133. data/lib/carray/autoload_method_extension.rb +64 -57
  134. data/lib/carray/axis_group.rb +264 -180
  135. data/lib/carray/basics.rb +272 -48
  136. data/lib/carray/bincount_nd.rb +33 -16
  137. data/lib/carray/block_iterator.rb +123 -102
  138. data/lib/carray/boolean_reduce.rb +7 -4
  139. data/lib/carray/categorical.rb +63 -51
  140. data/lib/carray/categorical_iterator.rb +89 -67
  141. data/lib/carray/complex.rb +61 -41
  142. data/lib/carray/conditional.rb +49 -22
  143. data/lib/carray/const_string.rb +54 -62
  144. data/lib/carray/core_extensions.rb +1 -1
  145. data/lib/carray/distance_limit.rb +7 -5
  146. data/lib/carray/factories.rb +269 -0
  147. data/lib/carray/fixlen_string.rb +25 -24
  148. data/lib/carray/frame/column_verbs.rb +20 -8
  149. data/lib/carray/frame/concat.rb +3 -3
  150. data/lib/carray/frame/convert.rb +2 -1
  151. data/lib/carray/frame/csv_parser.rb +7 -1
  152. data/lib/carray/frame/frame.rb +35 -25
  153. data/lib/carray/frame/group.rb +183 -150
  154. data/lib/carray/frame/io.rb +26 -7
  155. data/lib/carray/frame/join.rb +37 -12
  156. data/lib/carray/frame/records.rb +1 -1
  157. data/lib/carray/frame/reshape.rb +3 -3
  158. data/lib/carray/frame/sort.rb +10 -8
  159. data/lib/carray/frame/verbs.rb +148 -118
  160. data/lib/carray/frame/windows.rb +232 -21
  161. data/lib/carray/frame.rb +1 -2
  162. data/lib/carray/fuse_source.rb +24 -21
  163. data/lib/carray/fusion.rb +30 -30
  164. data/lib/carray/histogram.rb +35 -16
  165. data/lib/carray/inspect.rb +7 -7
  166. data/lib/carray/iterator.rb +97 -24
  167. data/lib/carray/key_windows.rb +83 -57
  168. data/lib/carray/lazy.rb +196 -94
  169. data/lib/carray/limits.rb +80 -0
  170. data/lib/carray/mask_gap_fill.rb +21 -16
  171. data/lib/carray/math.rb +87 -50
  172. data/lib/carray/meld_reduce.rb +30 -8
  173. data/lib/carray/methods/align_addr.rb +29 -17
  174. data/lib/carray/methods/bin.rb +5 -1
  175. data/lib/carray/methods/bincount.rb +4 -2
  176. data/lib/carray/methods/bit_string.rb +19 -31
  177. data/lib/carray/methods/broadcast.rb +8 -3
  178. data/lib/carray/methods/choose.rb +5 -5
  179. data/lib/carray/methods/composition.rb +72 -71
  180. data/lib/carray/methods/{index.rb → coordinate.rb} +13 -13
  181. data/lib/carray/methods/discovery_along.rb +3 -3
  182. data/lib/carray/methods/gather_nd.rb +106 -106
  183. data/lib/carray/methods/insert_block.rb +2 -2
  184. data/lib/carray/methods/is_between.rb +6 -4
  185. data/lib/carray/methods/is_in.rb +165 -145
  186. data/lib/carray/methods/join.rb +2 -1
  187. data/lib/carray/methods/lag.rb +6 -2
  188. data/lib/carray/methods/locate_addr.rb +150 -138
  189. data/lib/carray/methods/mask_duplicates.rb +1 -1
  190. data/lib/carray/methods/meshgrid.rb +28 -16
  191. data/lib/carray/methods/mode.rb +67 -67
  192. data/lib/carray/methods/nunique.rb +9 -7
  193. data/lib/carray/methods/repeat.rb +12 -12
  194. data/lib/carray/methods/resize.rb +1 -1
  195. data/lib/carray/methods/snap.rb +24 -20
  196. data/lib/carray/methods/string_format.rb +2 -2
  197. data/lib/carray/methods/unique.rb +4 -2
  198. data/lib/carray/methods/value_counts.rb +1 -1
  199. data/lib/carray/mkmf.rb +25 -28
  200. data/lib/carray/percentile_arguments.rb +82 -0
  201. data/lib/carray/record_order.rb +18 -17
  202. data/lib/carray/rng.rb +1 -0
  203. data/lib/carray/runtime.rb +190 -22
  204. data/lib/carray/segment_iterator.rb +251 -129
  205. data/lib/carray/serialize.rb +618 -571
  206. data/lib/carray/slab_iterator.rb +114 -114
  207. data/lib/carray/stack.rb +11 -12
  208. data/lib/carray/string.rb +16 -22
  209. data/lib/carray/string_operation_extension.rb +76 -52
  210. data/lib/carray/struct.rb +122 -164
  211. data/lib/carray/struct_builder.rb +243 -72
  212. data/lib/carray/time.rb +496 -342
  213. data/lib/carray/window_iterator.rb +191 -150
  214. data/lib/carray.rb +6 -11
  215. data/yard-stubs/ca_obj_array.rb +20 -135
  216. data/yard-stubs/ca_obj_bitarray.rb +1 -8
  217. data/yard-stubs/ca_obj_bitfield.rb +4 -3
  218. data/yard-stubs/ca_obj_byte_swap.rb +21 -7
  219. data/yard-stubs/ca_obj_fake.rb +3 -1
  220. data/yard-stubs/ca_obj_farray.rb +1 -1
  221. data/yard-stubs/ca_obj_field.rb +8 -6
  222. data/yard-stubs/ca_obj_refer.rb +7 -5
  223. data/yard-stubs/ca_obj_roll.rb +7 -6
  224. data/yard-stubs/ca_obj_shift.rb +2 -3
  225. data/yard-stubs/ca_obj_stride.rb +5 -7
  226. data/yard-stubs/ca_obj_tile.rb +1 -1
  227. data/yard-stubs/ca_obj_time.rb +43 -0
  228. data/yard-stubs/ca_obj_transpose.rb +1 -1
  229. data/yard-stubs/ca_obj_window.rb +26 -15
  230. data/yard-stubs/carray_access.rb +51 -4
  231. data/yard-stubs/carray_attribute.rb +26 -38
  232. data/yard-stubs/carray_cast.rb +118 -165
  233. data/yard-stubs/carray_class.rb +3 -4
  234. data/yard-stubs/carray_conversion.rb +6 -7
  235. data/yard-stubs/carray_copy.rb +2 -1
  236. data/yard-stubs/carray_count.rb +5 -3
  237. data/yard-stubs/carray_element.rb +4 -3
  238. data/yard-stubs/carray_limits.rb +100 -0
  239. data/yard-stubs/carray_loop.rb +0 -20
  240. data/yard-stubs/carray_mask.rb +59 -41
  241. data/yard-stubs/carray_math.rb +157 -100
  242. data/yard-stubs/carray_mathfunc.rb +415 -3
  243. data/yard-stubs/carray_median_percentile.rb +29 -11
  244. data/yard-stubs/carray_memory_view.rb +2 -2
  245. data/yard-stubs/carray_order.rb +67 -34
  246. data/yard-stubs/carray_random.rb +6 -6
  247. data/yard-stubs/carray_reduce.rb +353 -0
  248. data/yard-stubs/carray_rng.rb +92 -0
  249. data/yard-stubs/carray_scatter.rb +10 -2
  250. data/yard-stubs/carray_slab.rb +7 -4
  251. data/yard-stubs/carray_sort.rb +7 -6
  252. data/yard-stubs/carray_undef.rb +44 -5
  253. data/yard-stubs/ruby_carray.rb +75 -40
  254. metadata +62 -24
  255. data/CHANGELOG.v1.md +0 -126
  256. data/ext/carray_build_flags.h +0 -3
  257. data/ext/carray_config.h +0 -28
  258. data/ext/carray_data_type.c +0 -90
  259. data/ext/carray_kernels_bincmp.c +0 -6457
  260. data/ext/carray_kernels_binop.c +0 -31534
  261. data/ext/carray_kernels_init.c +0 -1734
  262. data/ext/carray_kernels_moncmp.c +0 -2104
  263. data/ext/carray_kernels_monop.c +0 -25337
  264. data/ext/carray_kernels_reduce_aggregate.c +0 -27545
  265. data/ext/carray_kernels_reduce_boolean.c +0 -1924
  266. data/ext/carray_kernels_reduce_cumulative.c +0 -11646
  267. data/ext/carray_kernels_reduce_extreme.c +0 -21631
  268. data/ext/carray_kernels_reduce_variance.c +0 -5981
  269. data/ext/carray_kernels_scan.c +0 -4302
  270. data/ext/carray_kernels_search.c +0 -37776
  271. data/ext/carray_kernels_sort.c +0 -10814
  272. data/ext/carray_kernels_triop.c +0 -1864
  273. data/lib/carray/construct.rb +0 -360
  274. data/lib/carray/data_type_extension.rb +0 -262
  275. data/lib/carray/data_type_limits.rb +0 -91
data/ext/ca_obj_face.h CHANGED
@@ -1,19 +1,26 @@
1
1
  /* ---------------------------------------------------------------------------
2
2
 
3
- ca_obj_face.h
4
-
5
- Face mechanism — shared op helper signatures + lift/strip entry points.
6
-
7
- This header provides signatures for (1) shared op helpers (= thin-forward
8
- for storage ops, alias-based since Face is data-layout identical to
9
- parent), (2) `rb_ca_face_template` (struct duplicate + parent swap),
10
- (3) `ca_face_lift` (= wrap hook at the tail of user-facing access
11
- methods), (4) `ca_strip_face` (= Face-stripping helper for code that
12
- must see the storage).
13
-
14
- A Face is a "mask of a semantic type" (= identity layered on a storage
15
- type such as int64, with no value conversion), sibling to CAFake which
16
- was a "mask of data_type conversion".
3
+ ca_obj_face.h -- the Face authoring surface
4
+
5
+ A Face is a "mask of a semantic type": an identity layered on a storage
6
+ type such as int64, with no value conversion. An extension that defines
7
+ its own Face includes this header itself, after carray.h; carray.h does
8
+ not include it.
9
+
10
+ For extensions, and fixed for the rest of 3.x:
11
+ - the operation-table slots ca_face_attach / sync / detach / fill_* /
12
+ xfer_*, which forward to the parent
13
+ - the lift and strip parts: CA_FACE_LIFT_IF_FACE, ca_face_lift,
14
+ ca_strip_face, rb_ca_strip_face_value
15
+ - the hooks a Face registers (ca_face_register_storage_to_element /
16
+ _element_to_storage / _state_compatible / _state_portable, with their
17
+ *_fn types), and CA_FACE_STORAGE_TO_ELEMENT_IF_FACE with what it
18
+ expands to
19
+ - the ordering and search gate parts ca_face_require_orderable,
20
+ ca_face_orders_by_itself, ca_face_refuse_order and
21
+ ca_face_reconcile_operand
22
+ The Face parts that are carray's own are declared in carray_internal.h,
23
+ which is not installed.
17
24
 
18
25
  --------------------------------------------------------------------------- */
19
26
 
@@ -53,23 +60,11 @@ void ca_face_xfer_all (void *ap, void *data, int dir);
53
60
 
54
61
  /* -- lift / strip helpers -- */
55
62
 
56
- /* Struct duplicate + parent + shape swap. The primitive under
57
- ca_face_lift; also called directly where a result is re-wrapped under
58
- a Face without going through a view (partition, generated reduce). */
59
- VALUE rb_ca_face_template (VALUE original_face, CArray *new_parent,
60
- ca_size_t *new_dim);
61
-
62
63
  /* At the tail of view-creating methods, `if the receiver is a Face, wrap
63
64
  the result as a Face`. Reached through CA_FACE_LIFT_IF_FACE, which
64
65
  each view-creating method deploys at its return path. */
65
66
  VALUE ca_face_lift (VALUE view, VALUE face_parent);
66
67
 
67
- /* Lift a fresh array `result` (one a reduction, a scan or a partition built
68
- from the Face's storage) into the Face `face`: the same Face class over
69
- `result`, carrying the subclass tail, `result`'s mask and the state
70
- copy_state carries. `result` stays reachable through the new Face. */
71
- VALUE ca_face_relift_entity (VALUE face, VALUE result);
72
-
73
68
  /* Follow the Face flag down to the first non-Face parent, for code that
74
69
  must talk to the storage (store, mask, MemoryView export). The kernel
75
70
  iterator strips Faces at entry with its own loop, which also strips
@@ -82,32 +77,6 @@ CArray *ca_strip_face (CArray *src);
82
77
  root storage, not the Face surface. */
83
78
  VALUE rb_ca_strip_face_value (VALUE v);
84
79
 
85
- /* Face gate for the element-wise comparison operators (< <= > >=, eq, ne).
86
- When self is a Face over numeric storage, descends both operands to
87
- storage (ORDERABLE required) and reconciles a Face RHS via to_comparable;
88
- a fixlen-storage Face or a non-Face self is left untouched. Called from
89
- rb_ca_call_bincmp. See ca_obj_face.c for the full contract. */
90
- void ca_face_reconcile_comparison (volatile VALUE *pself,
91
- volatile VALUE *pother);
92
-
93
- /* CAFace abstract base class init (rev11 2026-06-10).
94
- Called from ruby_carray.c's Init after rb_cCAView is defined, before
95
- CATime / CATimedelta Init. */
96
- void Init_ca_face (void);
97
-
98
- /* -- R.5: composite Face data_class universal dispatch --
99
- Extern for direct C access from `rb_ca_data_class` (carray_attribute.c)
100
- into the CARecord tail. CA_OBJ_RECORD identifies the obj_type (assigned
101
- at runtime by ca_install_obj_type). To add a future composite Face,
102
- follow the same pattern: add an extern here and one line of case in the
103
- switch in carray_attribute.c. */
104
- extern int8_t CA_OBJ_RECORD;
105
- VALUE rb_ca_record_get_data_class (CArray *ca);
106
-
107
- /* CA_OBJ_STRING identifies CAString, read by the store path
108
- (carray_access.c) to send an array source through the write hook. */
109
- extern int8_t CA_OBJ_STRING;
110
-
111
80
  /* -- Convenience macro for view-creating method deployment --
112
81
  Insert at the tail of each view-creating Ruby method (= rb_ca_transpose
113
82
  / rb_ca_reshape / etc.) just before return. `ca` is self's CArray *,
@@ -119,39 +88,12 @@ extern int8_t CA_OBJ_STRING;
119
88
  } \
120
89
  } while (0)
121
90
 
122
- /* -- wrapper lift (Face or CALazyMarker) --
123
-
124
- A Face and a CALazyMarker are both storage-identical wrappers: they add
125
- an interpretation over their parent's bytes without changing them. Both
126
- want the same invariant at a view-creating method -- the wrapper stays on
127
- top, and the view is built against what the wrapper wraps. For a Face
128
- that keeps `dt.shift(1)` a CATime; for a marker it keeps a fuse block's
129
- expression lazy instead of dropping out of the chain.
130
-
131
- The flag test comes first and covers both bits in one mask, so an
132
- ordinary array leaves through a single AND. That matters: `[]` is the
133
- hottest method this is deployed on.
134
-
135
- NOT interchangeable with CA_FACE_LIFT_IF_FACE. Face is lifted at ~24
136
- sites, including ones a marker must not follow it through -- `copy` owns
137
- its data, `sort` reorders values, `value` and `strip_mask` change what
138
- the mask means. Deploy this only where the result is a view whose shape
139
- was fixed at construction and which only moves positions. */
140
- #define CA_WRAPPER_LIFT(obj, self, ca) do { \
141
- if ( ca_test_flag((ca), CA_FLAG_IS_FACE | CA_FLAG_IS_LAZY_MARKER) \
142
- && rb_obj_is_kind_of((obj), rb_cCArray) ) { \
143
- (obj) = ca_wrapper_lift((obj), (self), (ca)); \
144
- } \
145
- } while (0)
146
-
147
- VALUE ca_wrapper_lift (VALUE view, VALUE wrapper, void *wrapper_ca);
148
-
149
91
  /* -- Scalar fetch decode hook (storage -> surface) --
150
92
  On the scalar-return path (= tail of rb_ca_fetch_index /
151
93
  rb_ca_fetch_addr), if a Face-derived subclass defines a
152
94
  `storage_to_element(raw_value)` Ruby callback, invoke it. This is a
153
95
  decode (copy the storage value out and construct a new value object),
154
- not a wrap (a zero-copy lens over live memory). Its write-direction
96
+ not a wrap (a zero-copy view of live memory). Its write-direction
155
97
  counterpart is `element_to_storage` (below).
156
98
 
157
99
  Use cases:
@@ -180,7 +122,7 @@ typedef VALUE (*ca_face_storage_to_element_fn)(VALUE self, VALUE raw);
180
122
 
181
123
  extern ca_face_storage_to_element_fn ca_face_storage_to_element_table[];
182
124
 
183
- void ca_face_register_storage_to_element (int obj_type,
125
+ void ca_face_register_storage_to_element (int16_t obj_type,
184
126
  ca_face_storage_to_element_fn fn);
185
127
 
186
128
  /* -- Scalar store encode hook (surface -> storage), mirror of the decode --
@@ -194,44 +136,20 @@ void ca_face_register_storage_to_element (int obj_type,
194
136
  first, then the Ruby fallback. */
195
137
  typedef VALUE (*ca_face_element_to_storage_fn)(VALUE self, VALUE surface);
196
138
 
197
- extern ca_face_element_to_storage_fn ca_face_element_to_storage_table[];
198
-
199
- void ca_face_register_element_to_storage (int obj_type,
139
+ void ca_face_register_element_to_storage (int16_t obj_type,
200
140
  ca_face_element_to_storage_fn fn);
201
141
 
202
- /* Single source of truth for the surface -> storage-domain conversion.
203
- Returns `obj` unchanged when `ca` is not a Face or when no hook is
204
- registered / defined (so a bare Integer / String passes through to the
205
- existing storage cast). Otherwise returns the storage-domain value the
206
- Face produced. Called from rb_ca_obj2ptr (single-cell / fill / masked /
207
- range stores) and from the Array-of-scalars bulk store branch. */
208
- VALUE ca_face_element_to_storage (VALUE self, CArray *ca, VALUE obj);
209
-
210
- /* -- F.S0: Face state homogeneity check (= prerequisite for multi-Face APIs
211
- such as CAStack lift) --
142
+ /* -- Face state homogeneity check (what multi-Face operations such as
143
+ CAStack lift ask) --
212
144
  Per-obj_type C hook returning 1 if `a` and `b` (= both Face instances of
213
145
  the same obj_type) have compatible state (= same struct tail fields).
214
- Caller of `ca_face_state_compatible` guarantees both args are Face and
215
- have identical obj_type. */
146
+ carray calls it only with two Faces of the same obj_type. */
216
147
  typedef int (*ca_face_state_compatible_fn)(CArray *a, CArray *b);
217
148
 
218
- extern ca_face_state_compatible_fn ca_face_state_compatible_table[];
219
-
220
- void ca_face_register_state_compatible (int obj_type,
149
+ void ca_face_register_state_compatible (int16_t obj_type,
221
150
  ca_face_state_compatible_fn fn);
222
151
 
223
- /* Dispatch order:
224
- 1. C hook registered for a->obj_type → call hook, return its result
225
- 2. Else if the Ruby class of `va` defines `face_state_compatible?`
226
- on a Face subclass (= overrides CArray's default) → invoke with
227
- `vb`, return RTEST of result
228
- 3. Else → 1 (= default compatible, class identity only)
229
- Caller must pre-check a->obj_type == b->obj_type. `va` / `vb` are
230
- the Ruby VALUEs of the same instances (used only for the Ruby fallback
231
- path). */
232
- int ca_face_state_compatible (VALUE va, CArray *a, VALUE vb, CArray *b);
233
-
234
- /* -- F.S1: Face state portability (= class-level predicate) --
152
+ /* -- Face state portability (= class-level predicate) --
235
153
  Whether a Face class's state can be "moved" from one parent to
236
154
  another -- i.e., whether list[0]'s state can stand in for the result
237
155
  when a multi-parent operation (CAStack lift, compose family Face
@@ -247,46 +165,8 @@ int ca_face_state_compatible (VALUE va, CArray *a, VALUE vb, CArray *b);
247
165
  metadata-only Faces, including Ruby-implemented Faces that don't reach
248
166
  a C Init). Faces whose state holds per-parent storage MUST explicitly
249
167
  register 0 (= CAConstString). */
250
- extern int8_t ca_face_state_portable_table[];
251
-
252
- void ca_face_register_state_portable (int obj_type, int portable);
253
-
254
- /* Dispatch:
255
- 1. C table entry registered for obj_type → return that value
256
- 2. Else if the Ruby class `klass` defines a singleton method
257
- `face_state_portable?` (= subclass owns it) → invoke and RTEST
258
- 3. Else → 1 (= default portable)
259
- `klass` is the Ruby class of the Face instance (used for the Ruby
260
- fallback path). Pass Qnil when the class is unknown / unavailable
261
- (= falls through to default). */
262
- int ca_face_state_portable (int obj_type, VALUE klass);
263
-
264
- /* Check a list of arrays about to be combined into one (CAStack, CAMeld,
265
- promote_list). Returns the Face class every element shares, or Qnil
266
- when none of them is a Face; the combined array is then lifted into
267
- that class. Raises ArgumentError for a mix of Face and non-Face arrays
268
- or of two Face classes, for two or more of a Face whose state is not
269
- portable, and for elements whose state differs from the first one's.
270
- `who` names the caller at the head of the message. */
271
- VALUE ca_face_list_class (VALUE list, const char *who);
272
-
273
- /* A Face array's storage-side parent, one level down; any other array
274
- as it is. */
275
- VALUE ca_face_strip_one (VALUE v);
276
-
277
- /* Bring a Face *operand* into the reference's storage space, or refuse.
278
-
279
- The gate asks `fz_face_descend`'s question -- "is your storage your
280
- surface?" -- of the receiver, and for a long time asked nothing at all of
281
- the operand: a COMPARABLE receiver stripped any Face handed to it, and got
282
- back that Face's encoding rather than its values. Where the two encodings
283
- happened to be the same width the comparison then answered, wrongly and
284
- silently. Call this instead of stripping an operand by hand.
285
-
286
- A Face passes only if it declares COMPARABLE_STORAGE, i.e. its storage
287
- cells *are* the values it shows. Anything else -- a byte range, a code, a
288
- tick -- is refused rather than compared as bytes. Non-Face operands are
289
- returned untouched. `name` opens the message. */
168
+ void ca_face_register_state_portable (int16_t obj_type, int portable);
169
+
290
170
  /* Refuse to order (verb "order") or count by value (verb "count") a Face
291
171
  whose storage does not hold its values in order, naming the conversion. */
292
172
  NORETURN(void ca_face_refuse_order (const char *name, VALUE face,
@@ -303,20 +183,6 @@ void ca_face_require_orderable (VALUE face, const char *name,
303
183
  the storage. */
304
184
  int ca_face_orders_by_itself (VALUE face);
305
185
 
306
- /* The conversion a refusal of a Face whose cells encode its values points
307
- at (#to_string for a string Face, to_type(:object) for any other). */
308
- const char *ca_face_conversion_hint (VALUE face);
309
-
310
- /* The method that gives the storage under a Face (#ticks, #codes), or NULL
311
- when the Face has none of those. */
312
- const char *ca_face_storage_method (VALUE face);
313
-
314
- /* Raise eclass naming a Face that does not define the numeric operation
315
- `name`; returns when self is not a Face. See ca_obj_face.c. */
316
- void ca_face_refuse_numeric (VALUE self, const char *name, VALUE eclass);
317
-
318
- VALUE ca_face_operand_descend (VALUE operand, const char *name);
319
-
320
186
  /* Bring an operand into the storage space of a Face reference (a record's
321
187
  own data_class, a COMPARABLE Face's plain values, or the reference's
322
188
  to_comparable), refusing what the reference cannot read. See
@@ -324,10 +190,6 @@ VALUE ca_face_operand_descend (VALUE operand, const char *name);
324
190
  VALUE ca_face_reconcile_operand (VALUE reference, VALUE operand,
325
191
  const char *name);
326
192
 
327
- /* `==` (strict = 0) / `eql?` (strict = 1) when an operand is a Face other
328
- than a record array. See ca_obj_face.c. */
329
- int ca_face_equal (VALUE va, VALUE vb, int strict);
330
-
331
193
  /* The storage value of a cell read through a Face. A gated (CA_FIXLEN)
332
194
  surface over a numeric storage delivers the cell as its bytes; they are
333
195
  read back as the storage data_type (a boolean as true / false). A
@@ -348,7 +210,7 @@ VALUE ca_face_storage_value (CArray *ca, VALUE raw);
348
210
  static ID _id_storage_to_element = 0; \
349
211
  (obj) = ca_face_storage_value((ca), (obj)); \
350
212
  if ( _id_storage_to_element == 0 ) _id_storage_to_element = rb_intern("storage_to_element"); \
351
- if ( rb_respond_to((self), _id_storage_to_element) ) { \
213
+ if ( rb_obj_respond_to((self), _id_storage_to_element, Qtrue) ) { \
352
214
  (obj) = rb_funcall((self), _id_storage_to_element, 1, (obj)); \
353
215
  } \
354
216
  } \
data/ext/ca_obj_fake.c CHANGED
@@ -8,22 +8,12 @@
8
8
  ---------------------------------------------------------------------------- */
9
9
 
10
10
  #include "carray.h"
11
- #include "carray_internal.h" /* per-obj_type view constructors */
12
11
  #include "ca_iter_substrate.h" /* ca_xfer_stride_transform_fused */
13
12
 
14
13
  extern ca_operation_function_t ca_stride_func;
15
14
 
16
15
  typedef struct {
17
- int16_t obj_type;
18
- int8_t data_type;
19
- int8_t ndim;
20
- int32_t flags;
21
- ca_size_t bytes;
22
- ca_size_t elements;
23
- ca_size_t *dim;
24
- char *ptr;
25
- CArray *mask;
26
- char *_pool; /* framework-managed pool buffer (NULL = legacy ALLOC_N path). */
16
+ CA_ARRAY_HEADER
27
17
  CArray *parent;
28
18
  uint32_t attach;
29
19
  uint8_t nosync;
@@ -64,7 +54,7 @@ const rb_data_type_t cafake_data_type = {
64
54
  .flags = RUBY_TYPED_FREE_IMMEDIATELY
65
55
  };
66
56
 
67
- static int8_t CA_OBJ_FAKE;
57
+ static int16_t CA_OBJ_FAKE;
68
58
 
69
59
  static VALUE rb_cCAFake;
70
60
 
@@ -78,8 +68,8 @@ ca_fake_setup (CAFake *ca, CArray *parent, int8_t data_type, ca_size_t bytes)
78
68
 
79
69
  /* check arguments */
80
70
 
81
- CA_CHECK_DATA_TYPE_GIVEN(data_type);
82
- CA_CHECK_BYTES_GIVEN(data_type, bytes);
71
+ CA_CHECK_DATA_TYPE(data_type);
72
+ CA_CHECK_BYTES(data_type, bytes);
83
73
 
84
74
  /* ca == NULL asks for the checks above only, so that a constructor can
85
75
  run them before it allocates. */
@@ -429,7 +419,7 @@ ca_fake_func_detach (void *ap)
429
419
  }
430
420
 
431
421
  /* Thin wrapper around xfer_stride that walks native row-major
432
- strides. xfer_stride itself picks the right rung via
422
+ strides. xfer_stride itself picks the right fast path via
433
423
  ca_xfer_stride_transform_fused:
434
424
  CAStride family parent fused walk + cast in one pass
435
425
  Non-CAStride parent with live ptr fused via linear stride math
@@ -511,13 +501,13 @@ ca_operation_function_t ca_fake_func = {
511
501
  /* ------------------------------------------------------------------- */
512
502
 
513
503
  VALUE
514
- rb_ca_fake_new (VALUE cary, int8_t data_type, ca_size_t bytes)
504
+ rb_ca_fake_new (volatile VALUE cary, int8_t data_type, ca_size_t bytes)
515
505
  {
516
506
  volatile VALUE obj;
517
507
  CArray *parent;
518
508
  CAFake *ca;
519
509
  rb_check_carray_object(cary);
520
- TypedData_Get_Struct(cary, CArray, &carray_data_type, parent);
510
+ GetCArray(cary, parent);
521
511
  if ( ca_is_face(parent) && ( data_type == CA_OBJECT
522
512
  || parent->data_type == CA_FIXLEN ) ) {
523
513
  /* A Face's cells do not mean their storage bytes, so reading them
@@ -541,12 +531,17 @@ rb_ca_fake_new (VALUE cary, int8_t data_type, ca_size_t bytes)
541
531
  VALUE
542
532
  rb_ca_fake (int argc, VALUE *argv, VALUE self)
543
533
  {
544
- volatile VALUE obj, rtype, ropt, rbytes = Qnil;
534
+ volatile VALUE obj;
535
+ VALUE rtype, ropt, rbytes = Qnil;
545
536
  int8_t data_type;
546
537
  ca_size_t bytes;
547
538
 
548
- rb_scan_args(argc, argv, "11", (VALUE *) &rtype, (VALUE *) &ropt);
539
+ rb_scan_args(argc, argv, "11", &rtype, &ropt);
549
540
  rb_scan_options(ropt, "bytes", &rbytes);
541
+ ca_refuse_type_number(rtype);
542
+ if ( RTEST(rb_obj_is_data_class(rtype)) ) {
543
+ return ca_record_view_of(self, rtype, "fake");
544
+ }
550
545
 
551
546
  rb_ca_guess_type_and_bytes(rtype, rbytes, &data_type, &bytes);
552
547
  obj = rb_ca_fake_new(self, data_type, bytes);
@@ -573,7 +568,7 @@ rb_ca_fake_s_allocate (VALUE klass)
573
568
  }
574
569
 
575
570
  static VALUE
576
- rb_ca_fake_initialize_copy (VALUE self, VALUE other)
571
+ rb_ca_fake_initialize_copy (volatile VALUE self, volatile VALUE other)
577
572
  {
578
573
  CAFake *ca, *cs;
579
574
 
@@ -603,7 +598,6 @@ Init_ca_obj_fake (void)
603
598
  &cafake_data_type,
604
599
  rb_cCArrayMask,
605
600
  &carray_mask_data_type, &ca_fake_func, sizeof(ca_fake_func));
606
- rb_define_const(rb_cObject, "CA_OBJ_FAKE", INT2NUM(CA_OBJ_FAKE));
607
601
 
608
602
  rb_define_method(rb_cCArray, "fake", rb_ca_fake, -1);
609
603
 
data/ext/ca_obj_farray.c CHANGED
@@ -7,12 +7,11 @@
7
7
  ---------------------------------------------------------------------------- */
8
8
 
9
9
  #include "carray.h"
10
- #include "carray_internal.h" /* ca_view_inherit_mask */
11
10
  #include "ca_obj_face.h" /* CA_WRAPPER_LIFT */
12
11
 
13
12
  extern ca_operation_function_t ca_stride_func;
14
13
 
15
- static int8_t CA_OBJ_FARRAY;
14
+ static int16_t CA_OBJ_FARRAY;
16
15
 
17
16
  VALUE rb_cCAFarray;
18
17
  VALUE rb_cCAFarrayMask;
@@ -71,13 +70,13 @@ ca_farray_new (CArray *parent)
71
70
  /* ------------------------------------------------------------------- */
72
71
 
73
72
  VALUE
74
- rb_ca_farray_new (VALUE cary)
73
+ rb_ca_farray_new (volatile VALUE cary)
75
74
  {
76
75
  volatile VALUE obj;
77
76
  CArray *parent;
78
77
  CAStride *ca;
79
78
  rb_check_carray_object(cary);
80
- TypedData_Get_Struct(cary, CArray, &carray_data_type, parent);
79
+ GetCArray(cary, parent);
81
80
  ca = ca_farray_new(parent);
82
81
  obj = ca_wrap_struct(ca);
83
82
  rb_ca_set_parent(obj, cary);
@@ -86,18 +85,18 @@ rb_ca_farray_new (VALUE cary)
86
85
 
87
86
  /* CArray#farray -- column-major view (dimension order reversed). */
88
87
  VALUE
89
- rb_ca_farray (VALUE self)
88
+ rb_ca_farray (volatile VALUE self)
90
89
  {
91
90
  volatile VALUE obj = rb_ca_farray_new(self);
92
91
  CArray *ca;
93
92
 
94
- TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
93
+ GetCArray(self, ca);
95
94
  CA_WRAPPER_LIFT(obj, self, ca);
96
95
  return obj;
97
96
  }
98
97
 
99
98
  static VALUE
100
- rb_ca_farray_initialize_copy (VALUE self, VALUE other)
99
+ rb_ca_farray_initialize_copy (volatile VALUE self, volatile VALUE other)
101
100
  {
102
101
  CAStride *ca, *cs;
103
102
  TypedData_Get_Struct(self, CAStride, &castride_data_type, ca);
@@ -116,14 +115,13 @@ void
116
115
  Init_ca_obj_farray (void)
117
116
  {
118
117
  rb_cCAFarray = rb_define_class("CAFarray", rb_cCAStride);
119
- rb_cCAFarrayMask = rb_define_class("CAFarrayMask", rb_cCAFarray);
118
+ rb_cCAFarrayMask = rb_define_class_under(rb_cCAFarray, "Mask", rb_cCAFarray);
120
119
 
121
120
  CA_OBJ_FARRAY = ca_install_obj_type(rb_cCAFarray,
122
121
  &castride_data_type,
123
122
  rb_cCAFarrayMask,
124
123
  &castride_mask_data_type,
125
124
  &ca_stride_func, sizeof(ca_stride_func));
126
- rb_define_const(rb_cObject, "CA_OBJ_FARRAY", INT2NUM(CA_OBJ_FARRAY));
127
125
 
128
126
  rb_define_method(rb_cCArray, "farray", rb_ca_farray, 0);
129
127
 
data/ext/ca_obj_field.c CHANGED
@@ -12,11 +12,10 @@
12
12
  ---------------------------------------------------------------------------- */
13
13
 
14
14
  #include "carray.h"
15
- #include "carray_internal.h" /* per-obj_type view constructors */
16
15
 
17
16
  extern ca_operation_function_t ca_stride_func;
18
17
 
19
- int8_t CA_OBJ_FIELD;
18
+ int16_t CA_OBJ_FIELD;
20
19
  VALUE rb_cCAField;
21
20
  VALUE rb_cCAFieldMask;
22
21
 
@@ -32,8 +31,8 @@ ca_field_setup (CAStride *ca, CArray *parent,
32
31
  ca_size_t strides[CA_RANK_MAX];
33
32
  int8_t i;
34
33
 
35
- CA_CHECK_DATA_TYPE_GIVEN(data_type);
36
- CA_CHECK_BYTES_GIVEN(data_type, bytes);
34
+ CA_CHECK_DATA_TYPE(data_type);
35
+ CA_CHECK_BYTES(data_type, bytes);
37
36
 
38
37
  if ( offset < 0 ) {
39
38
  rb_raise(rb_eArgError, "negative offset");
@@ -98,14 +97,15 @@ ca_field_new (CArray *parent, ca_size_t offset, int8_t data_type, ca_size_t byte
98
97
 
99
98
  /* ------------------------------------------------------------------- */
100
99
 
100
+ /* recursion: re-enters once, for a byte field */
101
101
  VALUE
102
- rb_ca_field_new (VALUE cary, ca_size_t offset, int8_t data_type, ca_size_t bytes)
102
+ rb_ca_field_new (volatile VALUE cary, ca_size_t offset, int8_t data_type, ca_size_t bytes)
103
103
  {
104
104
  volatile VALUE obj;
105
105
  CArray *parent;
106
106
  CAStride *ca;
107
107
  rb_check_carray_object(cary);
108
- TypedData_Get_Struct(cary, CArray, &carray_data_type, parent);
108
+ GetCArray(cary, parent);
109
109
  /* A record's boolean member is a byte of a fixlen array that other
110
110
  fields (a uint8 one, a String store of the record) can write as any
111
111
  byte. It is read through a cast to boolean, which refuses a byte
@@ -128,9 +128,12 @@ rb_ca_field_new (VALUE cary, ca_size_t offset, int8_t data_type, ca_size_t bytes
128
128
  CAField is wrapped in a CARecord so encode/decode dispatch is
129
129
  carried. One-arg form delegates to rb_ca_face_field. */
130
130
  VALUE
131
- rb_ca_field (int argc, VALUE *argv, VALUE self)
131
+ rb_ca_field (int argc, VALUE *argv, volatile VALUE self)
132
132
  {
133
- volatile VALUE obj, voffset, rtype, ropt, rbytes = Qnil;
133
+ volatile VALUE obj;
134
+ VALUE voffset;
135
+ VALUE rtype_arg, ropt, rbytes = Qnil;
136
+ volatile VALUE rtype;
134
137
  CArray *ca;
135
138
  int8_t data_type;
136
139
  ca_size_t offset, bytes;
@@ -139,14 +142,15 @@ rb_ca_field (int argc, VALUE *argv, VALUE self)
139
142
  return rb_ca_face_field(self, argv[0]);
140
143
  }
141
144
 
142
- TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
145
+ GetCArray(self, ca);
143
146
 
144
147
  /* CArray#field(offset, data_type[, :bytes=>bytes]) */
145
148
  /* CArray#field(offset, data_class) */
146
149
  /* CArray#field(offset, template) */
147
150
 
148
- rb_scan_args(argc, argv, "21", (VALUE *) &voffset, (VALUE *) &rtype, (VALUE *) &ropt);
151
+ rb_scan_args(argc, argv, "21", &voffset, &rtype_arg, &ropt);
149
152
  rb_scan_options(ropt, "bytes", &rbytes);
153
+ rtype = rtype_arg;
150
154
 
151
155
  offset = ca_integer_arg(voffset, "offset", NULL);
152
156
 
@@ -155,7 +159,7 @@ rb_ca_field (int argc, VALUE *argv, VALUE self)
155
159
  ca_size_t dim[CA_RANK_MAX];
156
160
  int8_t ndim;
157
161
  int8_t i, j;
158
- TypedData_Get_Struct(rtype, CArray, &carray_data_type, ct);
162
+ GetCArray(rtype, ct);
159
163
  data_type = CA_FIXLEN;
160
164
  bytes = ct->bytes * ct->elements;
161
165
  ca_check_rank_fits((long) ca->ndim + ct->ndim, "field");
@@ -170,6 +174,7 @@ rb_ca_field (int argc, VALUE *argv, VALUE self)
170
174
  obj = rb_ca_refer_new(obj, ct->data_type, ndim, dim, ct->bytes, 0);
171
175
  }
172
176
  else {
177
+ ca_refuse_type_number(rtype);
173
178
  rb_ca_guess_type_and_bytes(rtype, rbytes, &data_type, &bytes);
174
179
  obj = rb_ca_field_new(self, offset, data_type, bytes);
175
180
  /* When rtype is a data_class, wrap the CAField in a CARecord so the
@@ -188,7 +193,7 @@ rb_ca_field (int argc, VALUE *argv, VALUE self)
188
193
  already correct for CAField too. */
189
194
 
190
195
  static VALUE
191
- rb_ca_field_initialize_copy (VALUE self, VALUE other)
196
+ rb_ca_field_initialize_copy (volatile VALUE self, volatile VALUE other)
192
197
  {
193
198
  CAStride *ca, *cs;
194
199
 
@@ -219,7 +224,6 @@ Init_ca_obj_field (void)
219
224
  rb_cCAFieldMask,
220
225
  &castride_mask_data_type,
221
226
  &ca_stride_func, sizeof(ca_stride_func));
222
- rb_define_const(rb_cObject, "CA_OBJ_FIELD", INT2NUM(CA_OBJ_FIELD));
223
227
 
224
228
  rb_define_method(rb_cCArray, "field", rb_ca_field, -1);
225
229
 
@@ -23,21 +23,11 @@
23
23
 
24
24
  #include "carray.h"
25
25
  #include "ca_obj_face.h"
26
- #include "carray_internal.h"
27
26
  #include <ruby/encoding.h>
28
27
 
29
28
  typedef struct {
30
29
  /* === CAView prefix === */
31
- int16_t obj_type;
32
- int8_t data_type; /* CA_FIXLEN (== storage) */
33
- int8_t ndim;
34
- int32_t flags; /* CA_FLAG_IS_FACE set */
35
- ca_size_t bytes; /* K = parent->bytes */
36
- ca_size_t elements;
37
- ca_size_t *dim;
38
- char *ptr;
39
- CArray *mask;
40
- char *_pool; /* framework-managed pool buffer */
30
+ CA_ARRAY_HEADER
41
31
  CArray *parent;
42
32
  uint32_t attach;
43
33
  uint8_t nosync;
@@ -80,7 +70,7 @@ const rb_data_type_t cafixlen_string_data_type = {
80
70
  .flags = RUBY_TYPED_FREE_IMMEDIATELY
81
71
  };
82
72
 
83
- static int8_t CA_OBJ_FIXLEN_STRING;
73
+ static int16_t CA_OBJ_FIXLEN_STRING;
84
74
  static VALUE rb_cCAFixlenString;
85
75
 
86
76
  /* ------------------------------------------------------------------- */
@@ -223,14 +213,14 @@ ca_operation_function_t ca_fixlen_string_func = {
223
213
  /* CAFixlenString.wrap(fixlen_array, encoding: nil) — zero-copy Face wrap.
224
214
  Without an encoding the cells are bytes that claim no text encoding. */
225
215
  VALUE
226
- rb_ca_fixlen_string_wrap (VALUE parent_val, int encoding_id)
216
+ rb_ca_fixlen_string_wrap (volatile VALUE parent_val, int encoding_id)
227
217
  {
228
218
  volatile VALUE obj;
229
219
  CArray *parent;
230
220
  CAFixlenString *ca;
231
221
 
232
222
  rb_check_carray_object(parent_val);
233
- TypedData_Get_Struct(parent_val, CArray, &carray_data_type, parent);
223
+ GetCArray(parent_val, parent);
234
224
 
235
225
  ca = ca_fixlen_string_new(parent, encoding_id);
236
226
  obj = ca_wrap_struct(ca);
@@ -251,7 +241,7 @@ rb_ca_fixlen_string_wrap_method (int argc, VALUE *argv, VALUE klass)
251
241
 
252
242
  /* The encoding of the text in the cells; BINARY when the cells claim none. */
253
243
  static VALUE
254
- rb_ca_fixlen_string_encoding (VALUE self)
244
+ rb_ca_fixlen_string_encoding (volatile VALUE self)
255
245
  {
256
246
  CAFixlenString *ca;
257
247
  TypedData_Get_Struct(self, CAFixlenString, &cafixlen_string_data_type, ca);
@@ -276,7 +266,7 @@ ca_fixlen_string_state_compatible (CArray *a, CArray *b)
276
266
  search / MemoryView still see the raw padded bytes. Genuine trailing NULs
277
267
  cannot survive here; use a raw CA_FIXLEN array for binary blobs. */
278
268
  static VALUE
279
- rb_ca_fixlen_string_storage_to_element (VALUE self, VALUE raw)
269
+ rb_ca_fixlen_string_storage_to_element (volatile VALUE self, volatile VALUE raw)
280
270
  {
281
271
  if ( TYPE(raw) == T_STRING ) {
282
272
  CAFixlenString *ca;
@@ -300,7 +290,7 @@ rb_ca_fixlen_string_s_allocate (VALUE klass)
300
290
  }
301
291
 
302
292
  static VALUE
303
- rb_ca_fixlen_string_initialize_copy (VALUE self, VALUE other)
293
+ rb_ca_fixlen_string_initialize_copy (volatile VALUE self, volatile VALUE other)
304
294
  {
305
295
  CAFixlenString *ca, *cs;
306
296
  TypedData_Get_Struct(self, CAFixlenString, &cafixlen_string_data_type, ca);
@@ -328,7 +318,6 @@ Init_ca_obj_fixlen_string (void)
328
318
  rb_cCArrayMask,
329
319
  &carray_mask_data_type,
330
320
  &ca_fixlen_string_func, sizeof(ca_fixlen_string_func));
331
- rb_define_const(rb_cObject, "CA_OBJ_FIXLEN_STRING", INT2NUM(CA_OBJ_FIXLEN_STRING));
332
321
 
333
322
  rb_define_alloc_func(rb_cCAFixlenString, rb_ca_fixlen_string_s_allocate);
334
323
  rb_define_method(rb_cCAFixlenString, "initialize_copy",
@@ -337,7 +326,7 @@ Init_ca_obj_fixlen_string (void)
337
326
  rb_ca_fixlen_string_wrap_method, -1);
338
327
  rb_define_method(rb_cCAFixlenString, "encoding",
339
328
  rb_ca_fixlen_string_encoding, 0);
340
- rb_define_method(rb_cCAFixlenString, "storage_to_element",
329
+ rb_define_private_method(rb_cCAFixlenString, "storage_to_element",
341
330
  rb_ca_fixlen_string_storage_to_element, 1);
342
331
  ca_face_register_storage_to_element(CA_OBJ_FIXLEN_STRING,
343
332
  rb_ca_fixlen_string_storage_to_element);