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.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/CHANGELOG.md +7 -1940
- data/README.md +38 -32
- data/carray.gemspec +16 -4
- data/docs/changelogs/CHANGELOG-3.0.md +2464 -0
- data/ext/ca_array_pool.c +4 -5
- data/ext/ca_axis_descriptor.h +45 -30
- data/ext/ca_axis_dispatch.c +7 -4
- data/ext/ca_axis_group.c +6 -9
- data/ext/ca_bincmp_dispatch.h +16 -38
- data/ext/ca_binop_dispatch.c +27 -0
- data/ext/ca_binop_dispatch.h +22 -47
- data/ext/ca_categorical_iterator.c +36 -34
- data/ext/ca_compare.c +0 -1
- data/ext/ca_compare.h +8 -1
- data/ext/ca_composite_dispatch.h +6 -0
- data/ext/ca_for_buffer.h +6 -1
- data/ext/ca_group_iter.c +17 -18
- data/ext/ca_iter_state_fields.h +196 -0
- data/ext/ca_iter_substrate.h +84 -103
- data/ext/ca_kernel_iterator.c +125 -89
- data/ext/ca_kernel_iterator.h +229 -1506
- data/ext/ca_kernel_iterator_internal.h +1167 -0
- data/ext/ca_moncmp_dispatch.h +17 -24
- data/ext/ca_monop_dispatch.h +25 -74
- data/ext/ca_obj_array.c +90 -163
- data/ext/ca_obj_bincmp.c +47 -46
- data/ext/ca_obj_binop.c +38 -38
- data/ext/ca_obj_bitarray.c +5 -17
- data/ext/ca_obj_bitfield.c +15 -30
- data/ext/ca_obj_block.c +11 -12
- data/ext/ca_obj_byte_swap.c +32 -30
- data/ext/ca_obj_const_string.c +57 -62
- data/ext/ca_obj_face.c +99 -91
- data/ext/ca_obj_face.h +32 -170
- data/ext/ca_obj_fake.c +15 -21
- data/ext/ca_obj_farray.c +7 -9
- data/ext/ca_obj_field.c +17 -13
- data/ext/ca_obj_fixlen_string.c +8 -19
- data/ext/ca_obj_grid.c +137 -106
- data/ext/ca_obj_meld.c +23 -21
- data/ext/ca_obj_moncmp.c +10 -21
- data/ext/ca_obj_monop.c +24 -35
- data/ext/ca_obj_object.c +51 -37
- data/ext/ca_obj_record.c +74 -22
- data/ext/ca_obj_reduce.c +8 -10
- data/ext/ca_obj_refer.c +42 -29
- data/ext/ca_obj_remap.c +11 -29
- data/ext/ca_obj_repeat.c +41 -23
- data/ext/ca_obj_roll.c +18 -24
- data/ext/ca_obj_select.c +10 -22
- data/ext/ca_obj_select_axis.c +27 -36
- data/ext/ca_obj_shift.c +22 -42
- data/ext/ca_obj_source.c +1 -5
- data/ext/ca_obj_stack.c +28 -24
- data/ext/ca_obj_stride.c +53 -54
- data/ext/ca_obj_string.c +6 -18
- data/ext/ca_obj_tile.c +12 -12
- data/ext/ca_obj_time.c +12 -23
- data/ext/ca_obj_timedelta.c +12 -23
- data/ext/ca_obj_transpose.c +8 -10
- data/ext/ca_obj_triop.c +35 -39
- data/ext/ca_obj_window.c +67 -86
- data/ext/ca_op_cmplx64.h +4 -0
- data/ext/ca_op_ipower.c +34 -12
- data/ext/ca_op_powi.h +4 -0
- data/ext/ca_pow5_table.h +2 -1
- data/ext/ca_rng_normal.h +4 -0
- data/ext/ca_rng_xoshiro256pp.h +3 -0
- data/ext/ca_sort_kernels.h +20 -26
- data/ext/ca_sweep_engine.c +2 -3
- data/ext/ca_sweep_engine.h +17 -9
- data/ext/ca_transform_common.c +3 -8
- data/ext/ca_triop_dispatch.h +20 -32
- data/ext/caframe_csv_reader.c +11 -11
- data/ext/carray.h +300 -1011
- data/ext/carray_access.c +234 -180
- data/ext/carray_address_basis.c +33 -38
- data/ext/carray_attribute.c +81 -104
- data/ext/carray_bincount.c +12 -14
- data/ext/carray_broadcast.c +30 -26
- data/ext/carray_call_cfunc.c +169 -277
- data/ext/carray_call_cfunc.h +36 -28
- data/ext/carray_cast.c +912 -346
- data/ext/carray_cast_func.rb +31 -3
- data/ext/carray_class.c +6 -11
- data/ext/carray_conversion.c +43 -38
- data/ext/carray_copy.c +28 -26
- data/ext/carray_core.c +217 -126
- data/ext/carray_count.c +27 -15
- data/ext/carray_element.c +40 -25
- data/ext/carray_factorize.c +53 -52
- data/ext/carray_generate.c +26 -19
- data/ext/carray_histogram.c +8 -10
- data/ext/carray_hold.c +7 -9
- data/ext/carray_index_classifier.c +123 -228
- data/ext/carray_index_classifier.h +11 -10
- data/ext/carray_integer_total.c +523 -0
- data/ext/carray_internal.h +1274 -160
- data/ext/carray_key_windows.c +3 -3
- data/ext/carray_lazy.c +21 -36
- data/ext/carray_loop.c +19 -22
- data/ext/carray_mask.c +123 -145
- data/ext/carray_math_kernel.h +23 -47
- data/ext/carray_mathfunc.c +10 -3
- data/ext/carray_median_percentile.c +95 -94
- data/ext/carray_memory_view.c +42 -47
- data/ext/carray_operator.c +423 -122
- data/ext/carray_order.c +121 -85
- data/ext/carray_partition.c +13 -15
- data/ext/carray_random.c +47 -41
- data/ext/carray_round.c +9 -4
- data/ext/carray_scatter.c +54 -40
- data/ext/carray_segment.c +41 -45
- data/ext/carray_slab.c +64 -47
- data/ext/carray_slab.h +44 -33
- data/ext/carray_sort.c +32 -29
- data/ext/carray_sort_kernel.c +12 -10
- data/ext/carray_struct.c +38 -43
- data/ext/carray_test.c +47 -43
- data/ext/carray_time_text.c +24 -31
- data/ext/carray_undef.c +50 -7
- data/ext/carray_utils.c +258 -94
- data/ext/extconf.rb +24 -17
- data/ext/mk_call_cfunc.rb +19 -20
- data/ext/mk_pow5_table.rb +2 -1
- data/ext/mkkernel.rb +782 -461
- data/ext/ruby_carray.c +47 -42
- data/ext/version.h +7 -5
- data/lib/carray/attribute.rb +19 -18
- data/lib/carray/autoload_carray.rb +20 -15
- data/lib/carray/autoload_method_extension.rb +64 -57
- data/lib/carray/axis_group.rb +264 -180
- data/lib/carray/basics.rb +272 -48
- data/lib/carray/bincount_nd.rb +33 -16
- data/lib/carray/block_iterator.rb +123 -102
- data/lib/carray/boolean_reduce.rb +7 -4
- data/lib/carray/categorical.rb +63 -51
- data/lib/carray/categorical_iterator.rb +89 -67
- data/lib/carray/complex.rb +61 -41
- data/lib/carray/conditional.rb +49 -22
- data/lib/carray/const_string.rb +54 -62
- data/lib/carray/core_extensions.rb +1 -1
- data/lib/carray/distance_limit.rb +7 -5
- data/lib/carray/factories.rb +269 -0
- data/lib/carray/fixlen_string.rb +25 -24
- data/lib/carray/frame/column_verbs.rb +20 -8
- data/lib/carray/frame/concat.rb +3 -3
- data/lib/carray/frame/convert.rb +2 -1
- data/lib/carray/frame/csv_parser.rb +7 -1
- data/lib/carray/frame/frame.rb +35 -25
- data/lib/carray/frame/group.rb +183 -150
- data/lib/carray/frame/io.rb +26 -7
- data/lib/carray/frame/join.rb +37 -12
- data/lib/carray/frame/records.rb +1 -1
- data/lib/carray/frame/reshape.rb +3 -3
- data/lib/carray/frame/sort.rb +10 -8
- data/lib/carray/frame/verbs.rb +148 -118
- data/lib/carray/frame/windows.rb +232 -21
- data/lib/carray/frame.rb +1 -2
- data/lib/carray/fuse_source.rb +24 -21
- data/lib/carray/fusion.rb +30 -30
- data/lib/carray/histogram.rb +35 -16
- data/lib/carray/inspect.rb +7 -7
- data/lib/carray/iterator.rb +97 -24
- data/lib/carray/key_windows.rb +83 -57
- data/lib/carray/lazy.rb +196 -94
- data/lib/carray/limits.rb +80 -0
- data/lib/carray/mask_gap_fill.rb +21 -16
- data/lib/carray/math.rb +87 -50
- data/lib/carray/meld_reduce.rb +30 -8
- data/lib/carray/methods/align_addr.rb +29 -17
- data/lib/carray/methods/bin.rb +5 -1
- data/lib/carray/methods/bincount.rb +4 -2
- data/lib/carray/methods/bit_string.rb +19 -31
- data/lib/carray/methods/broadcast.rb +8 -3
- data/lib/carray/methods/choose.rb +5 -5
- data/lib/carray/methods/composition.rb +72 -71
- data/lib/carray/methods/{index.rb → coordinate.rb} +13 -13
- data/lib/carray/methods/discovery_along.rb +3 -3
- data/lib/carray/methods/gather_nd.rb +106 -106
- data/lib/carray/methods/insert_block.rb +2 -2
- data/lib/carray/methods/is_between.rb +6 -4
- data/lib/carray/methods/is_in.rb +165 -145
- data/lib/carray/methods/join.rb +2 -1
- data/lib/carray/methods/lag.rb +6 -2
- data/lib/carray/methods/locate_addr.rb +150 -138
- data/lib/carray/methods/mask_duplicates.rb +1 -1
- data/lib/carray/methods/meshgrid.rb +28 -16
- data/lib/carray/methods/mode.rb +67 -67
- data/lib/carray/methods/nunique.rb +9 -7
- data/lib/carray/methods/repeat.rb +12 -12
- data/lib/carray/methods/resize.rb +1 -1
- data/lib/carray/methods/snap.rb +24 -20
- data/lib/carray/methods/string_format.rb +2 -2
- data/lib/carray/methods/unique.rb +4 -2
- data/lib/carray/methods/value_counts.rb +1 -1
- data/lib/carray/mkmf.rb +25 -28
- data/lib/carray/percentile_arguments.rb +82 -0
- data/lib/carray/record_order.rb +18 -17
- data/lib/carray/rng.rb +1 -0
- data/lib/carray/runtime.rb +190 -22
- data/lib/carray/segment_iterator.rb +251 -129
- data/lib/carray/serialize.rb +618 -571
- data/lib/carray/slab_iterator.rb +114 -114
- data/lib/carray/stack.rb +11 -12
- data/lib/carray/string.rb +16 -22
- data/lib/carray/string_operation_extension.rb +76 -52
- data/lib/carray/struct.rb +122 -164
- data/lib/carray/struct_builder.rb +243 -72
- data/lib/carray/time.rb +496 -342
- data/lib/carray/window_iterator.rb +191 -150
- data/lib/carray.rb +6 -11
- data/yard-stubs/ca_obj_array.rb +20 -135
- data/yard-stubs/ca_obj_bitarray.rb +1 -8
- data/yard-stubs/ca_obj_bitfield.rb +4 -3
- data/yard-stubs/ca_obj_byte_swap.rb +21 -7
- data/yard-stubs/ca_obj_fake.rb +3 -1
- data/yard-stubs/ca_obj_farray.rb +1 -1
- data/yard-stubs/ca_obj_field.rb +8 -6
- data/yard-stubs/ca_obj_refer.rb +7 -5
- data/yard-stubs/ca_obj_roll.rb +7 -6
- data/yard-stubs/ca_obj_shift.rb +2 -3
- data/yard-stubs/ca_obj_stride.rb +5 -7
- data/yard-stubs/ca_obj_tile.rb +1 -1
- data/yard-stubs/ca_obj_time.rb +43 -0
- data/yard-stubs/ca_obj_transpose.rb +1 -1
- data/yard-stubs/ca_obj_window.rb +26 -15
- data/yard-stubs/carray_access.rb +51 -4
- data/yard-stubs/carray_attribute.rb +26 -38
- data/yard-stubs/carray_cast.rb +118 -165
- data/yard-stubs/carray_class.rb +3 -4
- data/yard-stubs/carray_conversion.rb +6 -7
- data/yard-stubs/carray_copy.rb +2 -1
- data/yard-stubs/carray_count.rb +5 -3
- data/yard-stubs/carray_element.rb +4 -3
- data/yard-stubs/carray_limits.rb +100 -0
- data/yard-stubs/carray_loop.rb +0 -20
- data/yard-stubs/carray_mask.rb +59 -41
- data/yard-stubs/carray_math.rb +157 -100
- data/yard-stubs/carray_mathfunc.rb +415 -3
- data/yard-stubs/carray_median_percentile.rb +29 -11
- data/yard-stubs/carray_memory_view.rb +2 -2
- data/yard-stubs/carray_order.rb +67 -34
- data/yard-stubs/carray_random.rb +6 -6
- data/yard-stubs/carray_reduce.rb +353 -0
- data/yard-stubs/carray_rng.rb +92 -0
- data/yard-stubs/carray_scatter.rb +10 -2
- data/yard-stubs/carray_slab.rb +7 -4
- data/yard-stubs/carray_sort.rb +7 -6
- data/yard-stubs/carray_undef.rb +44 -5
- data/yard-stubs/ruby_carray.rb +75 -40
- metadata +62 -24
- data/CHANGELOG.v1.md +0 -126
- data/ext/carray_build_flags.h +0 -3
- data/ext/carray_config.h +0 -28
- data/ext/carray_data_type.c +0 -90
- data/ext/carray_kernels_bincmp.c +0 -6457
- data/ext/carray_kernels_binop.c +0 -31534
- data/ext/carray_kernels_init.c +0 -1734
- data/ext/carray_kernels_moncmp.c +0 -2104
- data/ext/carray_kernels_monop.c +0 -25337
- data/ext/carray_kernels_reduce_aggregate.c +0 -27545
- data/ext/carray_kernels_reduce_boolean.c +0 -1924
- data/ext/carray_kernels_reduce_cumulative.c +0 -11646
- data/ext/carray_kernels_reduce_extreme.c +0 -21631
- data/ext/carray_kernels_reduce_variance.c +0 -5981
- data/ext/carray_kernels_scan.c +0 -4302
- data/ext/carray_kernels_search.c +0 -37776
- data/ext/carray_kernels_sort.c +0 -10814
- data/ext/carray_kernels_triop.c +0 -1864
- data/lib/carray/construct.rb +0 -360
- data/lib/carray/data_type_extension.rb +0 -262
- data/lib/carray/data_type_limits.rb +0 -91
data/ext/ca_obj_face.c
CHANGED
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
#include "ruby.h"
|
|
31
31
|
#include "carray.h"
|
|
32
32
|
#include "ca_obj_face.h"
|
|
33
|
-
#include "carray_internal.h"
|
|
34
33
|
|
|
35
34
|
/* ---- shared op helpers (thin-forward) ---- */
|
|
36
35
|
|
|
@@ -39,7 +38,7 @@ ca_face_attach (void *ap)
|
|
|
39
38
|
{
|
|
40
39
|
CAView *cav = (CAView *) ap;
|
|
41
40
|
CArray *ca = (CArray *) ap;
|
|
42
|
-
ca_attach(cav->parent); /*
|
|
41
|
+
ca_attach(cav->parent); /* attach: a Face's attach slot; its detach slot releases */
|
|
43
42
|
/* alias parent->ptr (Face has identical data layout, so copy is unneeded) */
|
|
44
43
|
ca->ptr = cav->parent->ptr;
|
|
45
44
|
}
|
|
@@ -122,7 +121,7 @@ ca_face_xfer_all (void *ap, void *data, int dir)
|
|
|
122
121
|
*
|
|
123
122
|
* Called from ca_face_lift and from subclass lift / clone / dup paths. */
|
|
124
123
|
VALUE
|
|
125
|
-
rb_ca_face_template (VALUE original_face, CArray *new_parent,
|
|
124
|
+
rb_ca_face_template (volatile VALUE original_face, CArray *new_parent,
|
|
126
125
|
ca_size_t *new_dim)
|
|
127
126
|
{
|
|
128
127
|
CArray *src;
|
|
@@ -131,7 +130,7 @@ rb_ca_face_template (VALUE original_face, CArray *new_parent,
|
|
|
131
130
|
size_t size;
|
|
132
131
|
const rb_data_type_t *tdata;
|
|
133
132
|
|
|
134
|
-
|
|
133
|
+
GetCArray(original_face, src);
|
|
135
134
|
tdata = ca_typeddata[src->obj_type];
|
|
136
135
|
|
|
137
136
|
/* The struct with its subclass tail. struct_size is the struct alone;
|
|
@@ -194,7 +193,7 @@ static void
|
|
|
194
193
|
ca_face_fresh_entity_is_writable (volatile VALUE lifted, VALUE face)
|
|
195
194
|
{
|
|
196
195
|
CArray *lc;
|
|
197
|
-
|
|
196
|
+
GetCArray(lifted, lc);
|
|
198
197
|
if ( ca_test_flag(lc, CA_FLAG_READ_ONLY)
|
|
199
198
|
&& RTEST(rb_funcall(face, rb_intern("holds_new_values?"), 0)) ) {
|
|
200
199
|
ca_unset_flag(lc, CA_FLAG_READ_ONLY);
|
|
@@ -206,18 +205,18 @@ ca_face_relift_entity (VALUE face, volatile VALUE result)
|
|
|
206
205
|
{
|
|
207
206
|
static ID id_copy_state = 0;
|
|
208
207
|
CArray *rc, *lc;
|
|
209
|
-
VALUE lifted;
|
|
208
|
+
volatile VALUE lifted;
|
|
210
209
|
if ( id_copy_state == 0 ) id_copy_state = rb_intern("copy_state");
|
|
211
|
-
|
|
210
|
+
GetCArray(result, rc);
|
|
212
211
|
lifted = rb_ca_face_template(face, rc, rc->dim);
|
|
213
212
|
rb_ca_set_parent(lifted, result);
|
|
214
213
|
ca_face_fresh_entity_is_writable(lifted, face);
|
|
215
214
|
if ( ca_has_mask(rc) ) {
|
|
216
215
|
/* The template starts without a mask. */
|
|
217
|
-
|
|
216
|
+
GetCArray(lifted, lc);
|
|
218
217
|
ca_copy_mask(lc, rc);
|
|
219
218
|
}
|
|
220
|
-
if (
|
|
219
|
+
if ( rb_obj_respond_to(face, id_copy_state, Qtrue) ) {
|
|
221
220
|
rb_funcall(lifted, id_copy_state, 1, face);
|
|
222
221
|
}
|
|
223
222
|
return lifted;
|
|
@@ -248,14 +247,14 @@ ca_lift_move_mask_down (CArray *view_ca, CArray *wp)
|
|
|
248
247
|
* Caller (rb_ca_aref / rb_ca_store) must have already checked that
|
|
249
248
|
* face_parent carries the CA_FLAG_IS_FACE flag. */
|
|
250
249
|
VALUE
|
|
251
|
-
ca_face_lift (VALUE view, VALUE face_parent)
|
|
250
|
+
ca_face_lift (volatile VALUE view, volatile VALUE face_parent)
|
|
252
251
|
{
|
|
253
252
|
CArray *view_ca;
|
|
254
|
-
VALUE
|
|
253
|
+
volatile VALUE lifted;
|
|
255
254
|
static ID id_copy_state = 0;
|
|
256
255
|
if ( id_copy_state == 0 ) id_copy_state = rb_intern("copy_state");
|
|
257
256
|
|
|
258
|
-
|
|
257
|
+
GetCArray(view, view_ca);
|
|
259
258
|
|
|
260
259
|
/* Idempotent lift: if the view is already a Face of the same class as
|
|
261
260
|
face_parent, it has already been lifted — a builder that lifts internally
|
|
@@ -277,7 +276,7 @@ ca_face_lift (VALUE view, VALUE face_parent)
|
|
|
277
276
|
presents the surface. */
|
|
278
277
|
{
|
|
279
278
|
CArray *fp, *p;
|
|
280
|
-
|
|
279
|
+
GetCArray(face_parent, fp);
|
|
281
280
|
p = fp;
|
|
282
281
|
while (p && ca_is_face(p)) {
|
|
283
282
|
p = ((CAView *) p)->parent;
|
|
@@ -328,12 +327,12 @@ ca_face_lift (VALUE view, VALUE face_parent)
|
|
|
328
327
|
etc.) auto-carry via the template memcpy; Faces holding state in
|
|
329
328
|
Ruby ivars (Ruby-implemented CAObject-derived Faces etc.) should
|
|
330
329
|
override copy_state to copy them. */
|
|
331
|
-
if (
|
|
330
|
+
if ( rb_obj_respond_to(face_parent, id_copy_state, Qtrue) ) {
|
|
332
331
|
rb_funcall(lifted, id_copy_state, 1, face_parent);
|
|
333
332
|
}
|
|
334
333
|
|
|
335
334
|
#ifdef CARRAY_DEV_BUILD
|
|
336
|
-
/* Soundness
|
|
335
|
+
/* Soundness check (docs/internal/FaceLiftSoundness.md §0/§7): after a lift the view
|
|
337
336
|
node under the new Face must not point back at the Face we lifted from —
|
|
338
337
|
the §8.3 one-level swap must have moved it exactly one level, so a
|
|
339
338
|
redundant middle Face is structurally caught here, wherever it enters.
|
|
@@ -343,9 +342,9 @@ ca_face_lift (VALUE view, VALUE face_parent)
|
|
|
343
342
|
->parent (slot 0) is storage; this checks that slot. */
|
|
344
343
|
{
|
|
345
344
|
CArray *lifted_ca, *lp, *fps;
|
|
346
|
-
|
|
345
|
+
GetCArray(lifted, lifted_ca);
|
|
347
346
|
lp = CAVIEW(lifted_ca)->parent;
|
|
348
|
-
|
|
347
|
+
GetCArray(face_parent, fps);
|
|
349
348
|
if ( lp && ca_is_view(lp) ) {
|
|
350
349
|
if ( CAVIEW(lp)->parent == fps ) {
|
|
351
350
|
rb_bug("ca_face_lift: §8.3 one-level swap did not fire — redundant "
|
|
@@ -376,12 +375,12 @@ ca_face_lift (VALUE view, VALUE face_parent)
|
|
|
376
375
|
* builder handed us a view whose parent is the marker, and leaving it
|
|
377
376
|
* there would stack a redundant marker in the middle. */
|
|
378
377
|
static VALUE
|
|
379
|
-
ca_lazy_marker_lift (VALUE view, volatile VALUE marker)
|
|
378
|
+
ca_lazy_marker_lift (volatile VALUE view, volatile VALUE marker)
|
|
380
379
|
{
|
|
381
380
|
CArray *view_ca, *mp;
|
|
382
381
|
extern VALUE rb_ca_lazy_marker_new (VALUE cary);
|
|
383
382
|
|
|
384
|
-
|
|
383
|
+
GetCArray(view, view_ca);
|
|
385
384
|
|
|
386
385
|
/* Idempotent: a builder that wrapped internally already returned a
|
|
387
386
|
marker (mirrors the same guard in ca_face_lift). */
|
|
@@ -389,7 +388,7 @@ ca_lazy_marker_lift (VALUE view, volatile VALUE marker)
|
|
|
389
388
|
return view;
|
|
390
389
|
}
|
|
391
390
|
|
|
392
|
-
|
|
391
|
+
GetCArray(marker, mp);
|
|
393
392
|
|
|
394
393
|
/* One-level swap (CAFace.md section 8.3, same reasoning): move the view
|
|
395
394
|
off the marker and onto what the marker wraps. Guarded on pointer
|
|
@@ -409,13 +408,13 @@ ca_lazy_marker_lift (VALUE view, volatile VALUE marker)
|
|
|
409
408
|
* CA_WRAPPER_LIFT. The macro has already established that wrapper_ca
|
|
410
409
|
* carries one of the two flags and that view is a CArray. */
|
|
411
410
|
VALUE
|
|
412
|
-
ca_wrapper_lift (VALUE view, VALUE wrapper, void *wrapper_ca)
|
|
411
|
+
ca_wrapper_lift (volatile VALUE view, VALUE wrapper, void *wrapper_ca)
|
|
413
412
|
{
|
|
414
413
|
CArray *ca = (CArray *) wrapper_ca;
|
|
415
414
|
|
|
416
415
|
if ( ca_is_face(ca) ) {
|
|
417
416
|
CArray *view_ca;
|
|
418
|
-
|
|
417
|
+
GetCArray(view, view_ca);
|
|
419
418
|
/* Some builders (select / repeat / ...) lift their own result; a
|
|
420
419
|
second lift here would double-wrap. Mirrors the guard the `[]`
|
|
421
420
|
call site used to carry inline. */
|
|
@@ -451,14 +450,14 @@ ca_strip_face (CArray *src)
|
|
|
451
450
|
* result into a Face wrapper (index / addr / linear outputs are not
|
|
452
451
|
* Face-semantic). Complements ca_strip_face on the C-struct axis. */
|
|
453
452
|
VALUE
|
|
454
|
-
rb_ca_strip_face_value (VALUE v)
|
|
453
|
+
rb_ca_strip_face_value (volatile VALUE v)
|
|
455
454
|
{
|
|
456
455
|
CArray *ca;
|
|
457
456
|
if ( ! rb_obj_is_kind_of(v, rb_cCArray) ) return v;
|
|
458
|
-
|
|
457
|
+
GetCArray(v, ca);
|
|
459
458
|
while ( ca_is_face(ca) ) {
|
|
460
459
|
v = rb_ca_parent(v);
|
|
461
|
-
|
|
460
|
+
GetCArray(v, ca);
|
|
462
461
|
}
|
|
463
462
|
return v;
|
|
464
463
|
}
|
|
@@ -498,7 +497,7 @@ rb_ca_face_s_allocate_forbidden (VALUE klass)
|
|
|
498
497
|
}
|
|
499
498
|
|
|
500
499
|
VALUE
|
|
501
|
-
ca_face_storage_value (CArray *ca, VALUE raw)
|
|
500
|
+
ca_face_storage_value (CArray *ca, volatile VALUE raw)
|
|
502
501
|
{
|
|
503
502
|
CArray *storage;
|
|
504
503
|
CArray as_storage;
|
|
@@ -528,7 +527,7 @@ ca_face_storage_value (CArray *ca, VALUE raw)
|
|
|
528
527
|
ca_face_storage_to_element_fn ca_face_storage_to_element_table[CA_OBJ_TYPE_MAX];
|
|
529
528
|
|
|
530
529
|
void
|
|
531
|
-
ca_face_register_storage_to_element (
|
|
530
|
+
ca_face_register_storage_to_element (int16_t obj_type, ca_face_storage_to_element_fn fn)
|
|
532
531
|
{
|
|
533
532
|
if ( obj_type < 0 || obj_type >= CA_OBJ_TYPE_MAX ) {
|
|
534
533
|
rb_raise(rb_eArgError,
|
|
@@ -545,7 +544,7 @@ ca_face_register_storage_to_element (int obj_type, ca_face_storage_to_element_fn
|
|
|
545
544
|
ca_face_element_to_storage_fn ca_face_element_to_storage_table[CA_OBJ_TYPE_MAX];
|
|
546
545
|
|
|
547
546
|
void
|
|
548
|
-
ca_face_register_element_to_storage (
|
|
547
|
+
ca_face_register_element_to_storage (int16_t obj_type, ca_face_element_to_storage_fn fn)
|
|
549
548
|
{
|
|
550
549
|
if ( obj_type < 0 || obj_type >= CA_OBJ_TYPE_MAX ) {
|
|
551
550
|
rb_raise(rb_eArgError,
|
|
@@ -560,7 +559,7 @@ ca_face_register_element_to_storage (int obj_type, ca_face_element_to_storage_fn
|
|
|
560
559
|
ca_face_state_compatible_fn ca_face_state_compatible_table[CA_OBJ_TYPE_MAX];
|
|
561
560
|
|
|
562
561
|
void
|
|
563
|
-
ca_face_register_state_compatible (
|
|
562
|
+
ca_face_register_state_compatible (int16_t obj_type, ca_face_state_compatible_fn fn)
|
|
564
563
|
{
|
|
565
564
|
if ( obj_type < 0 || obj_type >= CA_OBJ_TYPE_MAX ) {
|
|
566
565
|
rb_raise(rb_eArgError,
|
|
@@ -601,7 +600,7 @@ ca_face_state_compatible (VALUE va, CArray *a, VALUE vb, CArray *b)
|
|
|
601
600
|
|
|
602
601
|
/* Ruby-side: CArray#face_state_compatible?(other) */
|
|
603
602
|
static VALUE
|
|
604
|
-
rb_ca_face_state_compatible_p (VALUE self, VALUE other)
|
|
603
|
+
rb_ca_face_state_compatible_p (volatile VALUE self, volatile VALUE other)
|
|
605
604
|
{
|
|
606
605
|
CArray *a, *b;
|
|
607
606
|
|
|
@@ -609,8 +608,8 @@ rb_ca_face_state_compatible_p (VALUE self, VALUE other)
|
|
|
609
608
|
rb_raise(rb_eArgError,
|
|
610
609
|
"face_state_compatible?: argument must be a CArray");
|
|
611
610
|
}
|
|
612
|
-
|
|
613
|
-
|
|
611
|
+
GetCArray(self, a);
|
|
612
|
+
GetCArray(other, b);
|
|
614
613
|
if ( ! ca_is_face(a) || ! ca_is_face(b) ) {
|
|
615
614
|
rb_raise(rb_eArgError,
|
|
616
615
|
"face_state_compatible?: both receiver and argument must be Face");
|
|
@@ -631,7 +630,7 @@ rb_ca_face_state_compatible_p (VALUE self, VALUE other)
|
|
|
631
630
|
static int8_t ca_face_memory_view_table[CA_OBJ_TYPE_MAX];
|
|
632
631
|
|
|
633
632
|
void
|
|
634
|
-
ca_face_register_memory_view (
|
|
633
|
+
ca_face_register_memory_view (int16_t obj_type, int exportable)
|
|
635
634
|
{
|
|
636
635
|
if ( obj_type < 0 || obj_type >= CA_OBJ_TYPE_MAX ) {
|
|
637
636
|
rb_raise(rb_eArgError,
|
|
@@ -671,7 +670,7 @@ rb_ca_s_face_state_portable_false (VALUE klass)
|
|
|
671
670
|
}
|
|
672
671
|
|
|
673
672
|
void
|
|
674
|
-
ca_face_register_state_portable (
|
|
673
|
+
ca_face_register_state_portable (int16_t obj_type, int portable)
|
|
675
674
|
{
|
|
676
675
|
if ( obj_type < 0 || obj_type >= CA_OBJ_TYPE_MAX ) {
|
|
677
676
|
rb_raise(rb_eArgError,
|
|
@@ -685,7 +684,7 @@ ca_face_register_state_portable (int obj_type, int portable)
|
|
|
685
684
|
ca_install_obj_type before this call — Faces register from
|
|
686
685
|
within their Init_*, which runs after ca_install_obj_type. */
|
|
687
686
|
if ( !NIL_P(ca_class[obj_type]) ) {
|
|
688
|
-
|
|
687
|
+
rb_define_private_method(rb_singleton_class(ca_class[obj_type]), "face_state_portable?",
|
|
689
688
|
portable ? rb_ca_s_face_state_portable_true
|
|
690
689
|
: rb_ca_s_face_state_portable_false,
|
|
691
690
|
0);
|
|
@@ -704,7 +703,7 @@ ca_face_class_has_portable_method (VALUE klass)
|
|
|
704
703
|
ID id_owner = rb_intern("owner");
|
|
705
704
|
VALUE m, owner;
|
|
706
705
|
if ( NIL_P(klass) ) return 0;
|
|
707
|
-
if ( !
|
|
706
|
+
if ( !rb_obj_respond_to(klass, id_face_state_portable_p, Qtrue) ) return 0;
|
|
708
707
|
m = rb_funcall(klass, id_method, 1, ID2SYM(id_face_state_portable_p));
|
|
709
708
|
owner = rb_funcall(m, id_owner, 0);
|
|
710
709
|
/* owner is a (singleton) class — if it isn't rb_singleton_class(rb_cCArray)
|
|
@@ -779,28 +778,29 @@ ca_face_refuse_order (const char *name, VALUE face, const char *verb)
|
|
|
779
778
|
when the Face is ORDERABLE; refuses otherwise (ca_face_refuse_order). A
|
|
780
779
|
family that can order by a key asks ca_face_orders_by_itself first. */
|
|
781
780
|
void
|
|
782
|
-
ca_face_require_orderable (VALUE face, const char *name, const char *verb)
|
|
781
|
+
ca_face_require_orderable (volatile VALUE face, const char *name, const char *verb)
|
|
783
782
|
{
|
|
784
783
|
CArray *ca;
|
|
785
|
-
|
|
784
|
+
GetCArray(face, ca);
|
|
786
785
|
if ( ! ca_test_flag(ca, CA_FLAG_FACE_ORDERABLE_STORAGE) ) {
|
|
787
786
|
ca_face_refuse_order(name, face, verb);
|
|
788
787
|
}
|
|
789
788
|
}
|
|
790
789
|
|
|
791
|
-
/* Whether a Face is ordered by its own #
|
|
792
|
-
it is not ORDERABLE and answers #
|
|
793
|
-
so a family that orders by a key can take that
|
|
794
|
-
not one: it sorts the storage and comes back
|
|
790
|
+
/* Whether a Face is ordered by its own #rank_index rather than by its
|
|
791
|
+
storage: it is not ORDERABLE and answers #rank_index itself
|
|
792
|
+
(CAConstString, CARecord), so a family that orders by a key can take that
|
|
793
|
+
order. CArray#rank_index is not one: it sorts the storage and comes back
|
|
794
|
+
to the gate. */
|
|
795
795
|
int
|
|
796
|
-
ca_face_orders_by_itself (VALUE face)
|
|
796
|
+
ca_face_orders_by_itself (volatile VALUE face)
|
|
797
797
|
{
|
|
798
|
-
ID id_order = rb_intern("
|
|
798
|
+
ID id_order = rb_intern("rank_index");
|
|
799
799
|
ID id_method = rb_intern("method");
|
|
800
800
|
ID id_owner = rb_intern("owner");
|
|
801
801
|
CArray *ca;
|
|
802
802
|
VALUE m;
|
|
803
|
-
|
|
803
|
+
GetCArray(face, ca);
|
|
804
804
|
if ( ca_test_flag(ca, CA_FLAG_FACE_ORDERABLE_STORAGE) ) {
|
|
805
805
|
return 0;
|
|
806
806
|
}
|
|
@@ -812,7 +812,7 @@ ca_face_orders_by_itself (VALUE face)
|
|
|
812
812
|
whose cells encode its values rather than being numbers, pointing at what
|
|
813
813
|
gives numbers. Returns when `self` is not a Face. */
|
|
814
814
|
void
|
|
815
|
-
ca_face_refuse_numeric (VALUE self, const char *name, VALUE eclass)
|
|
815
|
+
ca_face_refuse_numeric (volatile VALUE self, const char *name, VALUE eclass)
|
|
816
816
|
{
|
|
817
817
|
CArray *ca;
|
|
818
818
|
if ( ! rb_obj_is_carray(self) ) {
|
|
@@ -840,13 +840,13 @@ ca_face_refuse_numeric (VALUE self, const char *name, VALUE eclass)
|
|
|
840
840
|
}
|
|
841
841
|
|
|
842
842
|
VALUE
|
|
843
|
-
ca_face_operand_descend (VALUE operand, const char *name)
|
|
843
|
+
ca_face_operand_descend (volatile VALUE operand, const char *name)
|
|
844
844
|
{
|
|
845
845
|
CArray *op;
|
|
846
846
|
if ( ! RTEST(rb_obj_is_carray(operand)) ) {
|
|
847
847
|
return operand;
|
|
848
848
|
}
|
|
849
|
-
|
|
849
|
+
GetCArray(operand, op);
|
|
850
850
|
if ( ! ca_is_face(op) ) {
|
|
851
851
|
return operand;
|
|
852
852
|
}
|
|
@@ -887,12 +887,12 @@ ca_face_operand_descend (VALUE operand, const char *name)
|
|
|
887
887
|
strings of different widths), and `eql?`, which has to agree with #hash,
|
|
888
888
|
answers false. */
|
|
889
889
|
int
|
|
890
|
-
ca_face_equal (VALUE va, VALUE vb, int strict)
|
|
890
|
+
ca_face_equal (volatile VALUE va, volatile VALUE vb, int strict)
|
|
891
891
|
{
|
|
892
892
|
CArray *a, *b;
|
|
893
893
|
int8_t i;
|
|
894
|
-
|
|
895
|
-
|
|
894
|
+
GetCArray(va, a);
|
|
895
|
+
GetCArray(vb, b);
|
|
896
896
|
if ( ! ca_is_face(a) || ! ca_is_face(b) ) {
|
|
897
897
|
return 0;
|
|
898
898
|
}
|
|
@@ -925,13 +925,13 @@ ca_face_equal (VALUE va, VALUE vb, int strict)
|
|
|
925
925
|
(#to_string) or, for any other, its values (to_type(:object)). Any
|
|
926
926
|
other operand is returned as it is. */
|
|
927
927
|
static VALUE
|
|
928
|
-
ca_face_operand_values (VALUE operand)
|
|
928
|
+
ca_face_operand_values (volatile VALUE operand)
|
|
929
929
|
{
|
|
930
930
|
CArray *op;
|
|
931
931
|
if ( ! RTEST(rb_obj_is_carray(operand)) ) {
|
|
932
932
|
return operand;
|
|
933
933
|
}
|
|
934
|
-
|
|
934
|
+
GetCArray(operand, op);
|
|
935
935
|
if ( ! ca_is_face(op) || op->obj_type == CA_OBJ_RECORD
|
|
936
936
|
|| ca_test_flag(op, CA_FLAG_FACE_ORDERABLE_STORAGE) ) {
|
|
937
937
|
return operand;
|
|
@@ -939,7 +939,8 @@ ca_face_operand_values (VALUE operand)
|
|
|
939
939
|
if ( rb_respond_to(operand, rb_intern("to_string")) ) {
|
|
940
940
|
return rb_funcall(operand, rb_intern("to_string"), 0);
|
|
941
941
|
}
|
|
942
|
-
|
|
942
|
+
/* coerce: a fixed type, the operand's values as objects */
|
|
943
|
+
return rb_ca_to_type(operand, ID2SYM(ca_data_type_sym[CA_OBJECT]), Qnil);
|
|
943
944
|
}
|
|
944
945
|
|
|
945
946
|
/* Bring `operand` into the storage space of `reference`, a Face, so the
|
|
@@ -965,17 +966,17 @@ ca_face_operand_values (VALUE operand)
|
|
|
965
966
|
UNDEF is undefined in every space, so it passes as it is and the entry
|
|
966
967
|
answers it as it does for a plain array. */
|
|
967
968
|
VALUE
|
|
968
|
-
ca_face_reconcile_operand (VALUE reference, VALUE operand, const char *name)
|
|
969
|
+
ca_face_reconcile_operand (volatile VALUE reference, volatile VALUE operand, const char *name)
|
|
969
970
|
{
|
|
970
971
|
CArray *ca;
|
|
971
972
|
if ( operand == CA_UNDEF ) {
|
|
972
973
|
return operand;
|
|
973
974
|
}
|
|
974
|
-
|
|
975
|
+
GetCArray(reference, ca);
|
|
975
976
|
if ( ca->obj_type == CA_OBJ_RECORD ) {
|
|
976
977
|
if ( RTEST(rb_obj_is_carray(operand)) ) {
|
|
977
978
|
CArray *op;
|
|
978
|
-
|
|
979
|
+
GetCArray(operand, op);
|
|
979
980
|
if ( ca_is_face(op) ) {
|
|
980
981
|
if ( op->obj_type != CA_OBJ_RECORD ) {
|
|
981
982
|
rb_raise(rb_eTypeError,
|
|
@@ -998,7 +999,7 @@ ca_face_reconcile_operand (VALUE reference, VALUE operand, const char *name)
|
|
|
998
999
|
return ca_face_operand_descend(ca_face_operand_values(operand), name);
|
|
999
1000
|
}
|
|
1000
1001
|
ca_face_require_orderable(reference, name, "compare");
|
|
1001
|
-
if (
|
|
1002
|
+
if ( rb_obj_respond_to(reference, rb_intern("to_comparable"), Qtrue) ) {
|
|
1002
1003
|
return rb_ca_strip_face_value(rb_funcall(reference,
|
|
1003
1004
|
rb_intern("to_comparable"),
|
|
1004
1005
|
1, operand));
|
|
@@ -1033,17 +1034,18 @@ ca_face_reconcile_pair (volatile VALUE *pref, volatile VALUE *poperand,
|
|
|
1033
1034
|
const char *name)
|
|
1034
1035
|
{
|
|
1035
1036
|
static ID id_comparable_pair = 0;
|
|
1036
|
-
VALUE ref = *pref
|
|
1037
|
+
volatile VALUE ref = *pref;
|
|
1038
|
+
VALUE operand = *poperand;
|
|
1037
1039
|
CArray *ca;
|
|
1038
1040
|
if ( id_comparable_pair == 0 ) {
|
|
1039
1041
|
id_comparable_pair = rb_intern("comparable_pair");
|
|
1040
1042
|
}
|
|
1041
|
-
|
|
1043
|
+
GetCArray(ref, ca);
|
|
1042
1044
|
if ( operand != CA_UNDEF
|
|
1043
1045
|
&& ca->obj_type != CA_OBJ_RECORD
|
|
1044
1046
|
&& ! ca_test_flag(ca, CA_FLAG_FACE_COMPARABLE_STORAGE)
|
|
1045
1047
|
&& ca_test_flag(ca, CA_FLAG_FACE_ORDERABLE_STORAGE)
|
|
1046
|
-
&&
|
|
1048
|
+
&& rb_obj_respond_to(ref, id_comparable_pair, Qtrue) ) {
|
|
1047
1049
|
VALUE pair = rb_funcall(ref, id_comparable_pair, 1, operand);
|
|
1048
1050
|
*pref = rb_ary_entry(pair, 0);
|
|
1049
1051
|
*poperand = rb_ca_strip_face_value(rb_ary_entry(pair, 1));
|
|
@@ -1053,7 +1055,7 @@ ca_face_reconcile_pair (volatile VALUE *pref, volatile VALUE *poperand,
|
|
|
1053
1055
|
}
|
|
1054
1056
|
|
|
1055
1057
|
int
|
|
1056
|
-
ca_face_state_portable (
|
|
1058
|
+
ca_face_state_portable (int16_t obj_type, VALUE klass)
|
|
1057
1059
|
{
|
|
1058
1060
|
int8_t entry;
|
|
1059
1061
|
if ( obj_type < 0 || obj_type >= CA_OBJ_TYPE_MAX ) return 1;
|
|
@@ -1077,10 +1079,10 @@ ca_face_list_class (VALUE list, const char *who)
|
|
|
1077
1079
|
CArray *ref = NULL;
|
|
1078
1080
|
|
|
1079
1081
|
for ( i = 0; i < n; i++ ) {
|
|
1080
|
-
VALUE p = rb_ary_entry(list, i);
|
|
1082
|
+
volatile VALUE p = rb_ary_entry(list, i);
|
|
1081
1083
|
CArray *ca;
|
|
1082
1084
|
rb_check_carray_object(p);
|
|
1083
|
-
|
|
1085
|
+
GetCArray(p, ca);
|
|
1084
1086
|
if ( ! ca_is_face(ca) ) { all_face = 0; continue; }
|
|
1085
1087
|
any_face = 1;
|
|
1086
1088
|
if ( NIL_P(face_class) ) {
|
|
@@ -1126,9 +1128,9 @@ ca_face_list_class (VALUE list, const char *who)
|
|
|
1126
1128
|
ca_face_conversion_hint(face));
|
|
1127
1129
|
}
|
|
1128
1130
|
for ( i = 1; i < n; i++ ) {
|
|
1129
|
-
VALUE p = rb_ary_entry(list, i);
|
|
1131
|
+
volatile VALUE p = rb_ary_entry(list, i);
|
|
1130
1132
|
CArray *ca;
|
|
1131
|
-
|
|
1133
|
+
GetCArray(p, ca);
|
|
1132
1134
|
if ( ! ca_face_state_compatible(rb_ary_entry(list, 0), ref, p, ca) ) {
|
|
1133
1135
|
rb_raise(rb_eArgError,
|
|
1134
1136
|
"%s: Face state mismatch (the %"PRIsVALUE" at index %ld differs from "
|
|
@@ -1139,10 +1141,10 @@ ca_face_list_class (VALUE list, const char *who)
|
|
|
1139
1141
|
}
|
|
1140
1142
|
|
|
1141
1143
|
VALUE
|
|
1142
|
-
ca_face_strip_one (VALUE v)
|
|
1144
|
+
ca_face_strip_one (volatile VALUE v)
|
|
1143
1145
|
{
|
|
1144
1146
|
CArray *c;
|
|
1145
|
-
|
|
1147
|
+
GetCArray(v, c);
|
|
1146
1148
|
return ca_is_face(c) ? rb_ca_parent(v) : v;
|
|
1147
1149
|
}
|
|
1148
1150
|
|
|
@@ -1162,7 +1164,7 @@ rb_ca_s_face_state_portable_p (VALUE klass)
|
|
|
1162
1164
|
CA_FLAG_FACE_ORDERABLE_STORAGE, false for a Face whose cells encode the
|
|
1163
1165
|
value (a const string's ranges, a categorical's codes). */
|
|
1164
1166
|
static VALUE
|
|
1165
|
-
rb_ca_orderable_storage_p (VALUE self)
|
|
1167
|
+
rb_ca_orderable_storage_p (volatile VALUE self)
|
|
1166
1168
|
{
|
|
1167
1169
|
CArray *ca;
|
|
1168
1170
|
GetCArray(self, ca);
|
|
@@ -1175,7 +1177,7 @@ rb_ca_orderable_storage_p (VALUE self)
|
|
|
1175
1177
|
for an array that is not a Face and for a Face that declares
|
|
1176
1178
|
CA_FLAG_FACE_COMPARABLE_STORAGE. */
|
|
1177
1179
|
static VALUE
|
|
1178
|
-
rb_ca_comparable_storage_p (VALUE self)
|
|
1180
|
+
rb_ca_comparable_storage_p (volatile VALUE self)
|
|
1179
1181
|
{
|
|
1180
1182
|
CArray *ca;
|
|
1181
1183
|
GetCArray(self, ca);
|
|
@@ -1196,7 +1198,7 @@ rb_ca_face_storage (VALUE self)
|
|
|
1196
1198
|
(ca_face_reconcile_operand for a Face, ca_face_operand_descend for an
|
|
1197
1199
|
array that is not one). For the families written in Ruby. */
|
|
1198
1200
|
static VALUE
|
|
1199
|
-
rb_ca_reconcile_operand (VALUE self, VALUE operand, VALUE rname)
|
|
1201
|
+
rb_ca_reconcile_operand (volatile VALUE self, VALUE operand, volatile VALUE rname)
|
|
1200
1202
|
{
|
|
1201
1203
|
CArray *ca;
|
|
1202
1204
|
const char *name = StringValueCStr(rname);
|
|
@@ -1213,18 +1215,18 @@ rb_ca_reconcile_operand (VALUE self, VALUE operand, VALUE rname)
|
|
|
1213
1215
|
promote_list pass). Delegates the data_type rewrite and optional
|
|
1214
1216
|
copy_state callback to ca_face_lift. */
|
|
1215
1217
|
static VALUE
|
|
1216
|
-
rb_ca_face_lift_method (VALUE self, VALUE face_parent)
|
|
1218
|
+
rb_ca_face_lift_method (volatile VALUE self, volatile VALUE face_parent)
|
|
1217
1219
|
{
|
|
1218
1220
|
CArray *fp, *vc, *storage;
|
|
1219
1221
|
if ( ! rb_obj_is_kind_of(face_parent, rb_cCArray) ) {
|
|
1220
1222
|
rb_raise(rb_eArgError, "face_lift: face_parent must be a CArray");
|
|
1221
1223
|
}
|
|
1222
|
-
|
|
1224
|
+
GetCArray(face_parent, fp);
|
|
1223
1225
|
if ( ! ca_is_face(fp) ) {
|
|
1224
1226
|
rb_raise(rb_eArgError, "face_lift: face_parent must be a Face instance");
|
|
1225
1227
|
}
|
|
1226
1228
|
rb_check_carray_object(self);
|
|
1227
|
-
|
|
1229
|
+
GetCArray(self, vc);
|
|
1228
1230
|
/* A Face of the same class is already lifted (see ca_face_lift). */
|
|
1229
1231
|
if ( ca_is_face(vc) && rb_obj_class(self) == rb_obj_class(face_parent) ) {
|
|
1230
1232
|
return self;
|
|
@@ -1263,13 +1265,13 @@ rb_ca_face_lift_method (VALUE self, VALUE face_parent)
|
|
|
1263
1265
|
void
|
|
1264
1266
|
ca_face_reconcile_comparison (volatile VALUE *pself, volatile VALUE *pother)
|
|
1265
1267
|
{
|
|
1266
|
-
VALUE self = *pself, other = *pother;
|
|
1268
|
+
volatile VALUE self = *pself, other = *pother;
|
|
1267
1269
|
CArray *sc, *storage;
|
|
1268
1270
|
|
|
1269
1271
|
if ( ! rb_obj_is_kind_of(self, rb_cCArray) ) {
|
|
1270
1272
|
return;
|
|
1271
1273
|
}
|
|
1272
|
-
|
|
1274
|
+
GetCArray(self, sc);
|
|
1273
1275
|
if ( ! ca_is_face(sc) ) {
|
|
1274
1276
|
return;
|
|
1275
1277
|
}
|
|
@@ -1282,7 +1284,7 @@ ca_face_reconcile_comparison (volatile VALUE *pself, volatile VALUE *pother)
|
|
|
1282
1284
|
static ID id_to_string = 0;
|
|
1283
1285
|
CArray *oc;
|
|
1284
1286
|
if ( id_to_string == 0 ) id_to_string = rb_intern("to_string");
|
|
1285
|
-
|
|
1287
|
+
GetCArray(other, oc);
|
|
1286
1288
|
if ( ca_is_face(oc) && rb_respond_to(self, id_to_string)
|
|
1287
1289
|
&& rb_respond_to(other, id_to_string)
|
|
1288
1290
|
&& ( rb_obj_class(self) != rb_obj_class(other)
|
|
@@ -1322,22 +1324,29 @@ ca_face_reconcile_comparison (volatile VALUE *pself, volatile VALUE *pother)
|
|
|
1322
1324
|
}
|
|
1323
1325
|
}
|
|
1324
1326
|
|
|
1325
|
-
/* A Face's parent, the array its values are stored in, is
|
|
1326
|
-
read-only view: a write through it would change the
|
|
1327
|
-
without the Face's conversion (a tick count stored into a
|
|
1328
|
-
into a record). The storage is written through the Face's
|
|
1329
|
-
methods (CATime#ticks), which take it with face_storage.
|
|
1330
|
-
|
|
1331
|
-
|
|
1327
|
+
/* CArray#parent. A Face's parent, the array its values are stored in, is
|
|
1328
|
+
handed out as a read-only view: a write through it would change the
|
|
1329
|
+
Face's values without the Face's conversion (a tick count stored into a
|
|
1330
|
+
time, bytes into a record). The storage is written through the Face's
|
|
1331
|
+
own named methods (CATime#ticks), which take it with face_storage. A
|
|
1332
|
+
Face is told by its flag, so a Face written in Ruby (a CAObject with
|
|
1333
|
+
face: true) is handed the same view as a subclass of CAFace. Any other
|
|
1334
|
+
array gets its parent itself. */
|
|
1335
|
+
VALUE
|
|
1336
|
+
rb_ca_parent_method (volatile VALUE self)
|
|
1332
1337
|
{
|
|
1333
1338
|
volatile VALUE st = rb_ca_parent(self), view;
|
|
1334
|
-
CArray *cs, *cv;
|
|
1339
|
+
CArray *ca, *cs, *cv;
|
|
1335
1340
|
if ( NIL_P(st) ) {
|
|
1336
1341
|
return st;
|
|
1337
1342
|
}
|
|
1338
|
-
|
|
1343
|
+
GetCArray(self, ca);
|
|
1344
|
+
if ( ! ca_is_face(ca) ) {
|
|
1345
|
+
return st;
|
|
1346
|
+
}
|
|
1347
|
+
GetCArray(st, cs);
|
|
1339
1348
|
view = rb_ca_refer_new(st, cs->data_type, cs->ndim, cs->dim, cs->bytes, 0);
|
|
1340
|
-
|
|
1349
|
+
GetCArray(view, cv);
|
|
1341
1350
|
ca_set_flag(cv, CA_FLAG_READ_ONLY);
|
|
1342
1351
|
return view;
|
|
1343
1352
|
}
|
|
@@ -1351,7 +1360,6 @@ Init_ca_face (void)
|
|
|
1351
1360
|
ahead of this Init) — CAFace inherits from it. */
|
|
1352
1361
|
rb_cCAFace = rb_define_class("CAFace", rb_cCAView);
|
|
1353
1362
|
rb_define_alloc_func(rb_cCAFace, rb_ca_face_s_allocate_forbidden);
|
|
1354
|
-
rb_define_method(rb_cCAFace, "parent", rb_ca_face_parent, 0);
|
|
1355
1363
|
|
|
1356
1364
|
/* Initialise the portable table to -1 for every slot so dispatch
|
|
1357
1365
|
can distinguish "explicitly registered 0" (CAConstString) from
|
|
@@ -1360,11 +1368,11 @@ Init_ca_face (void)
|
|
|
1360
1368
|
ca_face_state_portable_table[i] = -1;
|
|
1361
1369
|
}
|
|
1362
1370
|
|
|
1363
|
-
|
|
1371
|
+
rb_define_private_method(rb_cCArray, "face_state_compatible?",
|
|
1364
1372
|
rb_ca_face_state_compatible_p, 1);
|
|
1365
|
-
|
|
1373
|
+
rb_define_private_method(rb_singleton_class(rb_cCArray), "face_state_portable?",
|
|
1366
1374
|
rb_ca_s_face_state_portable_p, 0);
|
|
1367
|
-
|
|
1375
|
+
rb_define_private_method(rb_cCArray, "face_lift", rb_ca_face_lift_method, 1);
|
|
1368
1376
|
rb_define_private_method(rb_cCArray, "orderable_storage?",
|
|
1369
1377
|
rb_ca_orderable_storage_p, 0);
|
|
1370
1378
|
rb_define_private_method(rb_cCArray, "comparable_storage?",
|