carray 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +5 -25
- data/CHANGELOG.md +16 -0
- data/LICENSE +1 -1
- data/NEWS.md +3 -0
- data/README.md +128 -44
- data/carray.gemspec +22 -24
- data/ext/ca_array_pool.c +91 -0
- data/ext/ca_axis_descriptor.h +186 -0
- data/ext/ca_axis_dispatch.c +924 -0
- data/ext/ca_axis_group.c +1208 -0
- data/ext/ca_bincmp_dispatch.c +76 -0
- data/ext/ca_bincmp_dispatch.h +85 -0
- data/ext/ca_binop_dispatch.c +125 -0
- data/ext/ca_binop_dispatch.h +159 -0
- data/ext/ca_categorical_iterator.c +1375 -0
- data/ext/ca_compare.c +94 -0
- data/ext/ca_compare.h +26 -0
- data/ext/ca_composite_dispatch.c +414 -0
- data/ext/ca_composite_dispatch.h +116 -0
- data/ext/ca_for_buffer.h +96 -0
- data/ext/ca_for_each_element.h +241 -0
- data/ext/ca_group_iter.c +304 -0
- data/ext/ca_iter_substrate.h +325 -0
- data/ext/ca_kernel_iterator.c +4321 -0
- data/ext/ca_kernel_iterator.h +2603 -0
- data/ext/ca_moncmp_dispatch.c +37 -0
- data/ext/ca_moncmp_dispatch.h +62 -0
- data/ext/ca_monop_dispatch.c +200 -0
- data/ext/ca_monop_dispatch.h +235 -0
- data/ext/ca_obj_array.c +355 -359
- data/ext/ca_obj_bincmp.c +809 -0
- data/ext/ca_obj_binop.c +892 -0
- data/ext/ca_obj_bitarray.c +369 -164
- data/ext/ca_obj_bitfield.c +294 -234
- data/ext/ca_obj_block.c +189 -711
- data/ext/ca_obj_byte_swap.c +766 -0
- data/ext/ca_obj_const_string.c +965 -0
- data/ext/ca_obj_face.c +670 -0
- data/ext/ca_obj_face.h +247 -0
- data/ext/ca_obj_fake.c +228 -100
- data/ext/ca_obj_farray.c +54 -441
- data/ext/ca_obj_field.c +82 -529
- data/ext/ca_obj_fixlen_string.c +306 -0
- data/ext/ca_obj_grid.c +858 -440
- data/ext/ca_obj_meld.c +1034 -0
- data/ext/ca_obj_moncmp.c +569 -0
- data/ext/ca_obj_monop.c +1111 -0
- data/ext/ca_obj_object.c +774 -298
- data/ext/ca_obj_record.c +468 -0
- data/ext/ca_obj_reduce.c +97 -82
- data/ext/ca_obj_refer.c +569 -459
- data/ext/ca_obj_remap.c +475 -0
- data/ext/ca_obj_repeat.c +92 -477
- data/ext/ca_obj_roll.c +616 -0
- data/ext/ca_obj_select.c +344 -296
- data/ext/ca_obj_select_axis.c +1296 -0
- data/ext/ca_obj_shift.c +230 -792
- data/ext/ca_obj_source.c +78 -0
- data/ext/ca_obj_stack.c +1173 -0
- data/ext/ca_obj_stride.c +2501 -0
- data/ext/ca_obj_string.c +268 -0
- data/ext/ca_obj_tile.c +614 -0
- data/ext/ca_obj_time.c +546 -0
- data/ext/ca_obj_timedelta.c +435 -0
- data/ext/ca_obj_transpose.c +62 -516
- data/ext/ca_obj_triop.c +746 -0
- data/ext/ca_obj_unbound_repeat.c +208 -241
- data/ext/ca_obj_window.c +1131 -563
- data/ext/ca_op_byte_swap.c +175 -0
- data/ext/ca_op_ipower.c +319 -0
- data/ext/ca_op_powi.h +88 -0
- data/ext/ca_sort_kernels.h +132 -0
- data/ext/ca_sweep_engine.c +430 -0
- data/ext/ca_sweep_engine.h +157 -0
- data/ext/ca_transform_common.c +228 -0
- data/ext/ca_triop_dispatch.c +55 -0
- data/ext/ca_triop_dispatch.h +62 -0
- data/ext/carray.h +795 -402
- data/ext/carray_access.c +831 -711
- data/ext/carray_attribute.c +98 -330
- data/ext/carray_bincount.c +255 -0
- data/ext/carray_broadcast.c +283 -0
- data/ext/carray_call_cfunc.c +1360 -828
- data/ext/carray_call_cfunc.h +160 -0
- data/ext/carray_cast.c +1212 -301
- data/ext/carray_cast_func.rb +81 -40
- data/ext/carray_class.c +53 -63
- data/ext/carray_config.h +28 -0
- data/ext/carray_conversion.c +350 -346
- data/ext/carray_copy.c +156 -268
- data/ext/carray_core.c +1342 -199
- data/ext/carray_count.c +312 -0
- data/ext/carray_data_type.c +43 -19
- data/ext/carray_element.c +585 -213
- data/ext/carray_factorize.c +2542 -0
- data/ext/carray_generate.c +230 -559
- data/ext/carray_histogram.c +490 -0
- data/ext/carray_hold.c +228 -0
- data/ext/carray_index_classifier.c +1035 -0
- data/ext/carray_index_classifier.h +27 -0
- data/ext/carray_internal.h +120 -0
- data/ext/carray_kernels_bincmp.c +4445 -0
- data/ext/carray_kernels_binop.c +10979 -0
- data/ext/carray_kernels_init.c +36 -0
- data/ext/carray_kernels_map.c +3466 -0
- data/ext/carray_kernels_moncmp.c +2096 -0
- data/ext/carray_kernels_monop.c +18312 -0
- data/ext/carray_kernels_reduce_aggregate.c +25836 -0
- data/ext/carray_kernels_reduce_boolean.c +329 -0
- data/ext/carray_kernels_reduce_cumulative.c +14592 -0
- data/ext/carray_kernels_reduce_extreme.c +16947 -0
- data/ext/carray_kernels_reduce_variance.c +3909 -0
- data/ext/carray_kernels_scan.c +3692 -0
- data/ext/carray_kernels_search.c +32137 -0
- data/ext/carray_kernels_sort.c +10625 -0
- data/ext/carray_kernels_triop.c +1391 -0
- data/ext/carray_lazy.c +567 -0
- data/ext/carray_loop.c +88 -200
- data/ext/carray_mask.c +848 -154
- data/ext/carray_math_kernel.h +120 -0
- data/ext/carray_mathfunc.c +10 -241
- data/ext/carray_median_percentile.c +1257 -0
- data/ext/carray_memory_view.c +1625 -0
- data/ext/carray_operator.c +1526 -318
- data/ext/carray_order.c +664 -1394
- data/ext/carray_partition.c +416 -0
- data/ext/carray_random.c +518 -0
- data/ext/carray_scatter.c +357 -0
- data/ext/carray_slab.c +1219 -0
- data/ext/carray_slab.h +84 -0
- data/ext/carray_sort.c +829 -0
- data/ext/carray_sort_kernel.c +620 -0
- data/ext/carray_struct.c +695 -0
- data/ext/carray_test.c +343 -229
- data/ext/carray_undef.c +34 -17
- data/ext/carray_utils.c +175 -74
- data/ext/extconf.rb +216 -55
- data/ext/mk_call_cfunc.rb +480 -0
- data/ext/mkkernel.rb +8842 -0
- data/ext/ruby_carray.c +202 -101
- data/ext/version.h +4 -14
- data/ext/version.rb +5 -13
- data/lib/carray/arrow_tensor.rb +401 -0
- data/lib/carray/attribute.rb +166 -0
- data/lib/carray/autoload_carray.rb +220 -0
- data/lib/carray/autoload_method_extension.rb +44 -0
- data/lib/carray/axis_group.rb +711 -0
- data/lib/carray/basics.rb +481 -0
- data/lib/carray/bincount_nd.rb +358 -0
- data/lib/carray/block_iterator.rb +604 -0
- data/lib/carray/boolean_reduce.rb +109 -0
- data/lib/carray/categorical.rb +561 -0
- data/lib/carray/categorical_iterator.rb +1062 -0
- data/lib/carray/complex.rb +150 -0
- data/lib/carray/conditional.rb +216 -0
- data/lib/carray/const_string.rb +228 -0
- data/lib/carray/construct.rb +139 -328
- data/lib/carray/core_extensions.rb +240 -0
- data/lib/carray/data_type_extension.rb +233 -0
- data/lib/carray/fixlen_string.rb +95 -0
- data/lib/carray/frame/concat.rb +132 -0
- data/lib/carray/frame/convert.rb +95 -0
- data/lib/carray/frame/csv_parser.rb +211 -0
- data/lib/carray/frame/frame.rb +649 -0
- data/lib/carray/frame/group.rb +186 -0
- data/lib/carray/frame/io.rb +164 -0
- data/lib/carray/frame/join.rb +248 -0
- data/lib/carray/frame/records.rb +99 -0
- data/lib/carray/frame/sort.rb +113 -0
- data/lib/carray/frame/verbs.rb +299 -0
- data/lib/carray/frame.rb +16 -0
- data/lib/carray/histogram.rb +512 -0
- data/lib/carray/inspect.rb +37 -20
- data/lib/carray/iterator.rb +57 -349
- data/lib/carray/lazy.rb +889 -0
- data/lib/carray/mask_gap_fill.rb +200 -0
- data/lib/carray/math.rb +78 -342
- data/lib/carray/meld_reduce.rb +289 -0
- data/lib/carray/methods/align_addr.rb +116 -0
- data/lib/carray/methods/bin.rb +128 -0
- data/lib/carray/methods/bincount.rb +87 -0
- data/lib/carray/methods/bit_string.rb +92 -0
- data/lib/carray/methods/broadcast.rb +63 -0
- data/lib/carray/methods/choose.rb +39 -0
- data/lib/carray/methods/composition.rb +280 -0
- data/lib/carray/methods/gather_nd.rb +206 -0
- data/lib/carray/methods/index.rb +39 -0
- data/lib/carray/methods/insert_block.rb +99 -0
- data/lib/carray/methods/is_in.rb +141 -0
- data/lib/carray/methods/join.rb +90 -0
- data/lib/carray/methods/locate_addr.rb +47 -0
- data/lib/carray/methods/mask_duplicates.rb +41 -0
- data/lib/carray/methods/meshgrid.rb +91 -0
- data/lib/carray/methods/mode.rb +126 -0
- data/lib/carray/methods/nunique.rb +46 -0
- data/lib/carray/methods/resize.rb +56 -0
- data/lib/carray/methods/snap.rb +156 -0
- data/lib/carray/methods/string_format.rb +57 -0
- data/lib/carray/methods/unique.rb +47 -0
- data/lib/carray/methods/value_counts.rb +71 -0
- data/lib/carray/mkmf.rb +124 -101
- data/lib/carray/runtime.rb +108 -0
- data/lib/carray/serialize.rb +478 -167
- data/lib/carray/slab_iterator.rb +292 -0
- data/lib/carray/stack.rb +291 -0
- data/lib/carray/string.rb +56 -180
- data/lib/carray/string_operation_extension.rb +289 -0
- data/lib/carray/struct.rb +335 -323
- data/lib/carray/struct_builder.rb +697 -0
- data/lib/carray/table.rb +41 -2
- data/lib/carray/time.rb +2255 -38
- data/lib/carray/window_iterator.rb +655 -0
- data/lib/carray.rb +55 -57
- metadata +163 -130
- data/Rakefile +0 -51
- data/TODO.md +0 -18
- data/ext/ca_iter_block.c +0 -257
- data/ext/ca_iter_dimension.c +0 -299
- data/ext/ca_iter_window.c +0 -214
- data/ext/ca_obj_mapping.c +0 -644
- data/ext/carray_iterator.c +0 -641
- data/ext/carray_math.rb +0 -850
- data/ext/carray_numeric.c +0 -259
- data/ext/carray_sort_addr.c +0 -254
- data/ext/carray_stat.c +0 -2100
- data/ext/carray_stat_proc.rb +0 -1999
- data/ext/mkmath.rb +0 -741
- data/ext/ruby_ccomplex.c +0 -509
- data/ext/ruby_float_func.c +0 -86
- data/lib/carray/array.rb +0 -8
- data/lib/carray/autoload/autoload_base.rb +0 -19
- data/lib/carray/autoload/autoload_gem_cairo.rb +0 -9
- data/lib/carray/autoload/autoload_gem_ffi.rb +0 -9
- data/lib/carray/autoload/autoload_gem_gnuplot.rb +0 -2
- data/lib/carray/autoload/autoload_gem_io_csv.rb +0 -14
- data/lib/carray/autoload/autoload_gem_io_pg.rb +0 -6
- data/lib/carray/autoload/autoload_gem_io_sqlite3.rb +0 -12
- data/lib/carray/autoload/autoload_gem_narray.rb +0 -10
- data/lib/carray/autoload/autoload_gem_numo_narray.rb +0 -15
- data/lib/carray/autoload/autoload_gem_opencv.rb +0 -16
- data/lib/carray/autoload/autoload_gem_random.rb +0 -8
- data/lib/carray/autoload/autoload_gem_rmagick.rb +0 -23
- data/lib/carray/autoload/autoload_gem_zimg.rb +0 -3
- data/lib/carray/autoload/autoload_io_imagemagick.rb +0 -6
- data/lib/carray/autoload/autoload_math_histogram.rb +0 -5
- data/lib/carray/autoload/autoload_math_recurrence.rb +0 -6
- data/lib/carray/autoload/autoload_object_iterator.rb +0 -1
- data/lib/carray/autoload/autoload_object_link.rb +0 -1
- data/lib/carray/autoload/autoload_object_pack.rb +0 -2
- data/lib/carray/autoload.rb +0 -141
- data/lib/carray/basic.rb +0 -191
- data/lib/carray/broadcast.rb +0 -101
- data/lib/carray/compose.rb +0 -315
- data/lib/carray/convert.rb +0 -115
- data/lib/carray/info.rb +0 -110
- data/lib/carray/io/imagemagick.rb +0 -235
- data/lib/carray/mask.rb +0 -102
- data/lib/carray/math/histogram.rb +0 -177
- data/lib/carray/math/recurrence.rb +0 -93
- data/lib/carray/object/ca_obj_iterator.rb +0 -50
- data/lib/carray/object/ca_obj_link.rb +0 -50
- data/lib/carray/object/ca_obj_pack.rb +0 -99
- data/lib/carray/obsolete.rb +0 -256
- data/lib/carray/ordering.rb +0 -181
- data/lib/carray/testing.rb +0 -51
- data/lib/carray/transform.rb +0 -109
- data/misc/Methods.ja.md +0 -182
- data/misc/NOTE +0 -51
- data/spec/Classes/CABitfield_spec.rb +0 -58
- data/spec/Classes/CABlockIterator_spec.rb +0 -114
- data/spec/Classes/CABlock_spec.rb +0 -205
- data/spec/Classes/CAField_spec.rb +0 -39
- data/spec/Classes/CAGrid_spec.rb +0 -75
- data/spec/Classes/CAMap_spec.rb +0 -0
- data/spec/Classes/CAMapping_spec.rb +0 -105
- data/spec/Classes/CAObject_attribute_spec.rb +0 -33
- data/spec/Classes/CAObject_spec.rb +0 -33
- data/spec/Classes/CARefer_spec.rb +0 -93
- data/spec/Classes/CARepeat_spec.rb +0 -65
- data/spec/Classes/CASelect_spec.rb +0 -22
- data/spec/Classes/CAShift_spec.rb +0 -16
- data/spec/Classes/CAStruct_spec.rb +0 -71
- data/spec/Classes/CATranspose_spec.rb +0 -60
- data/spec/Classes/CAUnboudRepeat_spec.rb +0 -102
- data/spec/Classes/CAWindow_spec.rb +0 -54
- data/spec/Classes/CAWrap_spec.rb +0 -8
- data/spec/Classes/CArray_spec.rb +0 -184
- data/spec/Classes/CScalar_spec.rb +0 -55
- data/spec/Classes/ex1.rb +0 -46
- data/spec/Features/feature_130_spec.rb +0 -19
- data/spec/Features/feature_attributes_spec.rb +0 -280
- data/spec/Features/feature_boolean_spec.rb +0 -98
- data/spec/Features/feature_broadcast.rb +0 -116
- data/spec/Features/feature_cast_function.rb +0 -19
- data/spec/Features/feature_cast_spec.rb +0 -33
- data/spec/Features/feature_class_spec.rb +0 -84
- data/spec/Features/feature_complex_spec.rb +0 -42
- data/spec/Features/feature_composite_spec.rb +0 -124
- data/spec/Features/feature_convert_spec.rb +0 -46
- data/spec/Features/feature_copy_spec.rb +0 -123
- data/spec/Features/feature_creation_spec.rb +0 -84
- data/spec/Features/feature_element_spec.rb +0 -144
- data/spec/Features/feature_extream_spec.rb +0 -54
- data/spec/Features/feature_generate_spec.rb +0 -74
- data/spec/Features/feature_index_spec.rb +0 -69
- data/spec/Features/feature_mask_spec.rb +0 -580
- data/spec/Features/feature_math_spec.rb +0 -97
- data/spec/Features/feature_order_spec.rb +0 -146
- data/spec/Features/feature_ref_store_spec.rb +0 -209
- data/spec/Features/feature_serialization_spec.rb +0 -125
- data/spec/Features/feature_stat_spec.rb +0 -397
- data/spec/Features/feature_virtual_spec.rb +0 -48
- data/spec/Features/method_eq_spec.rb +0 -81
- data/spec/Features/method_is_nan_spec.rb +0 -12
- data/spec/Features/method_map_spec.rb +0 -54
- data/spec/Features/method_max_with.rb +0 -20
- data/spec/Features/method_min_with.rb +0 -19
- data/spec/Features/method_ne_spec.rb +0 -18
- data/spec/Features/method_project_spec.rb +0 -188
- data/spec/Features/method_ref_spec.rb +0 -27
- data/spec/Features/method_round_spec.rb +0 -11
- data/spec/Features/method_s_linspace_spec.rb +0 -48
- data/spec/Features/method_s_span_spec.rb +0 -14
- data/spec/Features/method_seq_spec.rb +0 -47
- data/spec/Features/method_sort_with.rb +0 -43
- data/spec/Features/method_sorted_with.rb +0 -29
- data/spec/Features/method_span_spec.rb +0 -42
- data/spec/Features/method_wrap_readonly_spec.rb +0 -43
- data/spec/UnitTest/test_CAVirtual.rb +0 -214
- data/spec/spec_all.rb +0 -10
- data/utils/ca_ase.rb +0 -21
- data/utils/ca_methods.rb +0 -15
- data/utils/cast_checker.rb +0 -30
- data/utils/convert_test.rb +0 -73
- data/utils/extract_yard.rb +0 -22
- data/utils/guess_shape.rb +0 -76
- data/utils/monkey_patch_methods.rb +0 -62
- data/utils/remove_resource_fork.sh +0 -5
data/ext/carray_attribute.c
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
/* ---------------------------------------------------------------------------
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Attribute and predicate accessors for CArray (obj_type / data_type
|
|
4
|
+
/ ndim / shape / dim / bytes / elements + entity? / virtual? /
|
|
5
|
+
fixlen? / boolean? / read_only? / mask_array? / etc.) plus the
|
|
6
|
+
view-chain navigators parent / root_array / ancestors.
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
The corresponding YARD documentation lives in
|
|
9
|
+
yard-stubs/carray_attribute.rb; this file carries only the
|
|
10
|
+
implementation.
|
|
8
11
|
|
|
9
12
|
---------------------------------------------------------------------------- */
|
|
10
13
|
|
|
11
14
|
#include "carray.h"
|
|
15
|
+
#include "ca_obj_face.h" /* CA_OBJ_RECORD + rb_ca_record_get_data_class */
|
|
12
16
|
|
|
13
17
|
/* ------------------------------------------------------------------- */
|
|
14
18
|
|
|
15
|
-
/* @overload obj_type
|
|
16
|
-
|
|
17
|
-
(Attribute)
|
|
18
|
-
Returns the object type (e.g. CA_OBJ_ARRAY, CA_OBJ_BLOCK, ...).
|
|
19
|
-
Since the object type can be known from the class of the object,
|
|
20
|
-
this attribute methods is rarely used.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
19
|
VALUE
|
|
24
20
|
rb_ca_obj_type (VALUE self)
|
|
25
21
|
{
|
|
@@ -28,26 +24,16 @@ rb_ca_obj_type (VALUE self)
|
|
|
28
24
|
return INT2NUM(ca->obj_type);
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
/* @overload data_type
|
|
32
|
-
|
|
33
|
-
(Attribute)
|
|
34
|
-
Returns the data type of each element (e.g. CA_INT32, CA_FLOAT64, ...).
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
27
|
VALUE
|
|
38
28
|
rb_ca_data_type (VALUE self)
|
|
39
29
|
{
|
|
40
30
|
CArray *ca;
|
|
41
31
|
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
42
|
-
|
|
32
|
+
/* Return a Symbol via the pre-computed ID cache; the C internal
|
|
33
|
+
int8_t representation is unchanged. */
|
|
34
|
+
return ID2SYM(ca_data_type_sym[ca->data_type]);
|
|
43
35
|
}
|
|
44
36
|
|
|
45
|
-
/* @overload ndim
|
|
46
|
-
|
|
47
|
-
(Attribute)
|
|
48
|
-
Returns the number of dimensions (e.g. 1 for 1D array, 3 for 3D array, ...).
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
37
|
VALUE
|
|
52
38
|
rb_ca_ndim (VALUE self)
|
|
53
39
|
{
|
|
@@ -56,16 +42,6 @@ rb_ca_ndim (VALUE self)
|
|
|
56
42
|
return INT2NUM(ca->ndim);
|
|
57
43
|
}
|
|
58
44
|
|
|
59
|
-
/* @overload bytes
|
|
60
|
-
|
|
61
|
-
(Attribute)
|
|
62
|
-
Returns the byte size of each element (e.g. 4 for CA_INT32, 8 for CA_FLOAT64).
|
|
63
|
-
The byte size can be obtained using CArray.sizeof(data_type)
|
|
64
|
-
for the numerical data types, but
|
|
65
|
-
the byte size of fixed-length data type can be known
|
|
66
|
-
only by this method.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
45
|
VALUE
|
|
70
46
|
rb_ca_bytes (VALUE self)
|
|
71
47
|
{
|
|
@@ -74,11 +50,13 @@ rb_ca_bytes (VALUE self)
|
|
|
74
50
|
return SIZE2NUM(ca->bytes);
|
|
75
51
|
}
|
|
76
52
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
53
|
+
VALUE
|
|
54
|
+
rb_ca_flags (VALUE self)
|
|
55
|
+
{
|
|
56
|
+
CArray *ca;
|
|
57
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
58
|
+
return INT2NUM(ca->flags);
|
|
59
|
+
}
|
|
82
60
|
|
|
83
61
|
VALUE
|
|
84
62
|
rb_ca_elements (VALUE self)
|
|
@@ -88,13 +66,6 @@ rb_ca_elements (VALUE self)
|
|
|
88
66
|
return SIZE2NUM(ca->elements);
|
|
89
67
|
}
|
|
90
68
|
|
|
91
|
-
/* @overload dim
|
|
92
|
-
|
|
93
|
-
(Attribute)
|
|
94
|
-
Returns the Array object contains the dimensional shape of array
|
|
95
|
-
(e.g. [2,3] for 2D 2x3 array, ...).
|
|
96
|
-
*/
|
|
97
|
-
|
|
98
69
|
VALUE
|
|
99
70
|
rb_ca_dim (VALUE self)
|
|
100
71
|
{
|
|
@@ -109,13 +80,6 @@ rb_ca_dim (VALUE self)
|
|
|
109
80
|
return dim;
|
|
110
81
|
}
|
|
111
82
|
|
|
112
|
-
/*
|
|
113
|
-
@overload dim0
|
|
114
|
-
|
|
115
|
-
(Attribute)
|
|
116
|
-
Short-hand for "dim[0]"
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
83
|
VALUE
|
|
120
84
|
rb_ca_dim0 (VALUE self)
|
|
121
85
|
{
|
|
@@ -124,13 +88,6 @@ rb_ca_dim0 (VALUE self)
|
|
|
124
88
|
return SIZE2NUM(ca->dim[0]);
|
|
125
89
|
}
|
|
126
90
|
|
|
127
|
-
/*
|
|
128
|
-
@overload dim1
|
|
129
|
-
|
|
130
|
-
(Attribute)
|
|
131
|
-
Short-hand for "dim[1]"
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
91
|
VALUE
|
|
135
92
|
rb_ca_dim1 (VALUE self)
|
|
136
93
|
{
|
|
@@ -139,13 +96,6 @@ rb_ca_dim1 (VALUE self)
|
|
|
139
96
|
return ( ca->ndim >= 2 ) ? SIZE2NUM(ca->dim[1]) : Qnil;
|
|
140
97
|
}
|
|
141
98
|
|
|
142
|
-
/*
|
|
143
|
-
@overload dim2
|
|
144
|
-
|
|
145
|
-
(Attribute)
|
|
146
|
-
Short-hand for 'dim[2]'
|
|
147
|
-
*/
|
|
148
|
-
|
|
149
99
|
VALUE
|
|
150
100
|
rb_ca_dim2 (VALUE self)
|
|
151
101
|
{
|
|
@@ -154,13 +104,6 @@ rb_ca_dim2 (VALUE self)
|
|
|
154
104
|
return ( ca->ndim >= 3 ) ? SIZE2NUM(ca->dim[2]) : Qnil;
|
|
155
105
|
}
|
|
156
106
|
|
|
157
|
-
/*
|
|
158
|
-
@overload dim3
|
|
159
|
-
|
|
160
|
-
(Attribute)
|
|
161
|
-
Short-hand for "dim[3]"
|
|
162
|
-
*/
|
|
163
|
-
|
|
164
107
|
VALUE
|
|
165
108
|
rb_ca_dim3 (VALUE self)
|
|
166
109
|
{
|
|
@@ -169,12 +112,6 @@ rb_ca_dim3 (VALUE self)
|
|
|
169
112
|
return ( ca->ndim >= 4 ) ? SIZE2NUM(ca->dim[3]) : Qnil;
|
|
170
113
|
}
|
|
171
114
|
|
|
172
|
-
/* @overload data_type_name
|
|
173
|
-
|
|
174
|
-
(Attribute)
|
|
175
|
-
Returns the string representaion of the data_type (e.g. "int32", "fixlen")
|
|
176
|
-
*/
|
|
177
|
-
|
|
178
115
|
VALUE
|
|
179
116
|
rb_ca_data_type_name (VALUE self)
|
|
180
117
|
{
|
|
@@ -192,11 +129,6 @@ ca_is_scalar (void *ap)
|
|
|
192
129
|
return ca_test_flag(ca, CA_FLAG_SCALAR);
|
|
193
130
|
}
|
|
194
131
|
|
|
195
|
-
/* @overload scalar?
|
|
196
|
-
|
|
197
|
-
(Inquiry) Returns true if the object is a CScalar
|
|
198
|
-
*/
|
|
199
|
-
|
|
200
132
|
VALUE
|
|
201
133
|
rb_ca_is_scalar (VALUE self)
|
|
202
134
|
{
|
|
@@ -205,8 +137,6 @@ rb_ca_is_scalar (VALUE self)
|
|
|
205
137
|
return ( ca_is_scalar(ca) ) ? Qtrue : Qfalse;
|
|
206
138
|
}
|
|
207
139
|
|
|
208
|
-
/* api: rb_obj_is_cscalar */
|
|
209
|
-
|
|
210
140
|
VALUE
|
|
211
141
|
rb_obj_is_cscalar (VALUE obj)
|
|
212
142
|
{
|
|
@@ -221,46 +151,30 @@ rb_obj_is_cscalar (VALUE obj)
|
|
|
221
151
|
/* ------------------------------------------------------------------- */
|
|
222
152
|
|
|
223
153
|
int
|
|
224
|
-
|
|
154
|
+
ca_is_view (void *ap)
|
|
225
155
|
{
|
|
226
156
|
CArray *ca = (CArray *) ap;
|
|
227
|
-
return ( ca_func[ca->obj_type].entity_type ==
|
|
157
|
+
return ( ca_func[ca->obj_type].entity_type == CA_VIEW_ARRAY ) ? 1 : 0;
|
|
228
158
|
}
|
|
229
159
|
|
|
230
|
-
/* @overload entity?
|
|
231
|
-
|
|
232
|
-
(Inquiry) Returns true if `self` is an entity array (not a virtual array).
|
|
233
|
-
*/
|
|
234
|
-
|
|
235
160
|
VALUE
|
|
236
161
|
rb_ca_is_entity (VALUE self)
|
|
237
162
|
{
|
|
238
163
|
CArray *ca;
|
|
239
164
|
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
240
|
-
return (
|
|
165
|
+
return ( ca_is_view(ca) ) ? Qfalse : Qtrue;
|
|
241
166
|
}
|
|
242
167
|
|
|
243
|
-
/*
|
|
244
|
-
@overload virtual?
|
|
245
|
-
|
|
246
|
-
(Inquiry) Returns true if `self` is a virtural array (not an entity array).
|
|
247
|
-
*/
|
|
248
|
-
|
|
249
168
|
VALUE
|
|
250
169
|
rb_ca_is_virtual (VALUE self)
|
|
251
170
|
{
|
|
252
171
|
CArray *ca;
|
|
253
172
|
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
254
|
-
return (
|
|
173
|
+
return ( ca_is_view(ca) ) ? Qtrue : Qfalse;
|
|
255
174
|
}
|
|
256
175
|
|
|
257
176
|
/* ------------------------------------------------------------------- */
|
|
258
177
|
|
|
259
|
-
/* @overload attached?
|
|
260
|
-
|
|
261
|
-
(Inquiry) Returns true if the object is attached.
|
|
262
|
-
*/
|
|
263
|
-
|
|
264
178
|
VALUE
|
|
265
179
|
rb_ca_is_attached (VALUE self)
|
|
266
180
|
{
|
|
@@ -271,11 +185,6 @@ rb_ca_is_attached (VALUE self)
|
|
|
271
185
|
|
|
272
186
|
/* ------------------------------------------------------------------- */
|
|
273
187
|
|
|
274
|
-
/* @overload empty?
|
|
275
|
-
|
|
276
|
-
(Inquiry) Returns true if the object is empty.
|
|
277
|
-
*/
|
|
278
|
-
|
|
279
188
|
VALUE
|
|
280
189
|
rb_ca_is_empty (VALUE self)
|
|
281
190
|
{
|
|
@@ -293,9 +202,22 @@ ca_is_readonly (void *ap)
|
|
|
293
202
|
if ( ca_test_flag(ca, CA_FLAG_READ_ONLY) ) { /* test -> true */
|
|
294
203
|
return 1;
|
|
295
204
|
}
|
|
205
|
+
else if ( ca_test_flag(ca, CA_FLAG_MULTI_PARENTS) ) {
|
|
206
|
+
/* multi-parent view: read-only iff ANY parent is (a whole-view write
|
|
207
|
+
cannot be honoured if any backing parent rejects writes). */
|
|
208
|
+
CAMultiParent *mp = (CAMultiParent *) ca;
|
|
209
|
+
int32_t k;
|
|
210
|
+
for ( k = 0; k < mp->n_parents; k++ ) {
|
|
211
|
+
if ( ca_is_readonly(mp->parents[k]) ) {
|
|
212
|
+
ca_set_flag(ca, CA_FLAG_READ_ONLY);
|
|
213
|
+
return 1;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return 0;
|
|
217
|
+
}
|
|
296
218
|
else { /* test -> false */
|
|
297
|
-
if (
|
|
298
|
-
if ( ca_is_readonly(
|
|
219
|
+
if ( ca_is_view(ca) && CAVIEW(ca)->parent ) {
|
|
220
|
+
if ( ca_is_readonly(CAVIEW(ca)->parent) ) { /* test -> true */
|
|
299
221
|
ca_set_flag(ca, CA_FLAG_READ_ONLY);
|
|
300
222
|
return 1;
|
|
301
223
|
}
|
|
@@ -304,11 +226,6 @@ ca_is_readonly (void *ap)
|
|
|
304
226
|
}
|
|
305
227
|
}
|
|
306
228
|
|
|
307
|
-
/* @overload read_only?
|
|
308
|
-
|
|
309
|
-
(Inquiry) Returns true if the object is read-only
|
|
310
|
-
*/
|
|
311
|
-
|
|
312
229
|
VALUE
|
|
313
230
|
rb_ca_is_read_only (VALUE self)
|
|
314
231
|
{
|
|
@@ -327,8 +244,13 @@ ca_is_mask_array (void *ap)
|
|
|
327
244
|
return 1;
|
|
328
245
|
}
|
|
329
246
|
else { /* test -> false */
|
|
330
|
-
|
|
331
|
-
|
|
247
|
+
/* Identity property: a CAStack is not a mask array unless
|
|
248
|
+
flagged directly (the internal CAStackMask is). Do not
|
|
249
|
+
inherit the property across a multi-parent fan-out — stop at
|
|
250
|
+
the boundary. */
|
|
251
|
+
if ( ca_is_view(ca) && CAVIEW(ca)->parent
|
|
252
|
+
&& ! ca_test_flag(ca, CA_FLAG_MULTI_PARENTS) ) {
|
|
253
|
+
if ( ca_is_mask_array(CAVIEW(ca)->parent) ) { /* test -> true */
|
|
332
254
|
ca_set_flag(ca, CA_FLAG_MASK_ARRAY);
|
|
333
255
|
return 1;
|
|
334
256
|
}
|
|
@@ -337,11 +259,6 @@ ca_is_mask_array (void *ap)
|
|
|
337
259
|
}
|
|
338
260
|
}
|
|
339
261
|
|
|
340
|
-
/* @overload mask_array?
|
|
341
|
-
|
|
342
|
-
(Inquiry) Returns true if `self` is mask array (don't confuse with "masked array")
|
|
343
|
-
*/
|
|
344
|
-
|
|
345
262
|
VALUE
|
|
346
263
|
rb_ca_is_mask_array (VALUE self)
|
|
347
264
|
{
|
|
@@ -360,8 +277,13 @@ ca_is_value_array (void *ap)
|
|
|
360
277
|
return 1;
|
|
361
278
|
}
|
|
362
279
|
else { /* test -> false */
|
|
363
|
-
|
|
364
|
-
|
|
280
|
+
/* Identity property: a CAStack is never "the .value of" a
|
|
281
|
+
single array (s.value wraps it in a flagged CARefer). Do
|
|
282
|
+
not inherit across a multi-parent fan-out — stop at the
|
|
283
|
+
boundary. */
|
|
284
|
+
if ( ca_is_view(ca) && CAVIEW(ca)->parent
|
|
285
|
+
&& ! ca_test_flag(ca, CA_FLAG_MULTI_PARENTS) ) {
|
|
286
|
+
if ( ca_is_value_array(CAVIEW(ca)->parent) ) { /* test -> true */
|
|
365
287
|
ca_set_flag(ca, CA_FLAG_VALUE_ARRAY);
|
|
366
288
|
return 1;
|
|
367
289
|
}
|
|
@@ -370,11 +292,6 @@ ca_is_value_array (void *ap)
|
|
|
370
292
|
}
|
|
371
293
|
}
|
|
372
294
|
|
|
373
|
-
/* @overload value_array?
|
|
374
|
-
|
|
375
|
-
(Inquiry) Returns true if `self` is a value array
|
|
376
|
-
*/
|
|
377
|
-
|
|
378
295
|
VALUE
|
|
379
296
|
rb_ca_is_value_array (VALUE self)
|
|
380
297
|
{
|
|
@@ -385,6 +302,16 @@ rb_ca_is_value_array (VALUE self)
|
|
|
385
302
|
|
|
386
303
|
/* ------------------------------------------------------------------- */
|
|
387
304
|
|
|
305
|
+
VALUE
|
|
306
|
+
rb_ca_is_face (VALUE self)
|
|
307
|
+
{
|
|
308
|
+
CArray *ca;
|
|
309
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
310
|
+
return ( ca_is_face(ca) ) ? Qtrue : Qfalse;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/* ------------------------------------------------------------------- */
|
|
314
|
+
|
|
388
315
|
int
|
|
389
316
|
ca_is_fixlen_type (void *ap)
|
|
390
317
|
{
|
|
@@ -392,16 +319,10 @@ ca_is_fixlen_type (void *ap)
|
|
|
392
319
|
return ( ca->data_type == CA_FIXLEN );
|
|
393
320
|
}
|
|
394
321
|
|
|
395
|
-
/* @overload fixlen?
|
|
396
|
-
|
|
397
|
-
(Inquiry) Returns true if `self` is fixed-length type array
|
|
398
|
-
*/
|
|
399
|
-
|
|
400
322
|
VALUE
|
|
401
323
|
rb_ca_is_fixlen_type (VALUE self)
|
|
402
324
|
{
|
|
403
325
|
CArray *ca;
|
|
404
|
-
|
|
405
326
|
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
406
327
|
return ca_is_fixlen_type(ca) ? Qtrue : Qfalse;
|
|
407
328
|
}
|
|
@@ -415,11 +336,6 @@ ca_is_boolean_type (void *ap)
|
|
|
415
336
|
return ( ca->data_type == CA_BOOLEAN );
|
|
416
337
|
}
|
|
417
338
|
|
|
418
|
-
/* @overload boolean?
|
|
419
|
-
|
|
420
|
-
(Inquiry) Return true if `self` is boolean type array
|
|
421
|
-
*/
|
|
422
|
-
|
|
423
339
|
VALUE
|
|
424
340
|
rb_ca_is_boolean_type (VALUE self)
|
|
425
341
|
{
|
|
@@ -438,11 +354,6 @@ ca_is_numeric_type (void *ap)
|
|
|
438
354
|
( ca->data_type <= CA_CMPLX256 ) );
|
|
439
355
|
}
|
|
440
356
|
|
|
441
|
-
/* @overload numeric?
|
|
442
|
-
|
|
443
|
-
(Inquiry) Returns true if `self` is numeric type array
|
|
444
|
-
*/
|
|
445
|
-
|
|
446
357
|
VALUE
|
|
447
358
|
rb_ca_is_numeric_type (VALUE self)
|
|
448
359
|
{
|
|
@@ -461,11 +372,6 @@ ca_is_integer_type (void *ap)
|
|
|
461
372
|
( ca->data_type <= CA_UINT64 ) );
|
|
462
373
|
}
|
|
463
374
|
|
|
464
|
-
/* @overload integer?
|
|
465
|
-
|
|
466
|
-
(Inquiry) Returns true if `self` is integer type array
|
|
467
|
-
*/
|
|
468
|
-
|
|
469
375
|
VALUE
|
|
470
376
|
rb_ca_is_integer_type (VALUE self)
|
|
471
377
|
{
|
|
@@ -476,36 +382,6 @@ rb_ca_is_integer_type (VALUE self)
|
|
|
476
382
|
|
|
477
383
|
/* ------------------------------------------------------------------- */
|
|
478
384
|
|
|
479
|
-
int
|
|
480
|
-
ca_is_unsigned_type (void *ap)
|
|
481
|
-
{
|
|
482
|
-
CArray *ca = (CArray *) ap;
|
|
483
|
-
switch ( ca->data_type ) {
|
|
484
|
-
case CA_UINT8:
|
|
485
|
-
case CA_UINT16:
|
|
486
|
-
case CA_UINT32:
|
|
487
|
-
case CA_UINT64:
|
|
488
|
-
return 1;
|
|
489
|
-
default:
|
|
490
|
-
return 0;
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
/* @overload unsigned?
|
|
495
|
-
|
|
496
|
-
(Inquiry) Return true if `self` is unsigned integer type array
|
|
497
|
-
*/
|
|
498
|
-
|
|
499
|
-
VALUE
|
|
500
|
-
rb_ca_is_unsigned_type (VALUE self)
|
|
501
|
-
{
|
|
502
|
-
CArray *ca;
|
|
503
|
-
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
504
|
-
return ca_is_unsigned_type(ca) ? Qtrue : Qfalse;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
/* ------------------------------------------------------------------- */
|
|
508
|
-
|
|
509
385
|
int
|
|
510
386
|
ca_is_float_type (void *ap)
|
|
511
387
|
{
|
|
@@ -514,11 +390,6 @@ ca_is_float_type (void *ap)
|
|
|
514
390
|
( ca->data_type <= CA_FLOAT128 ) );
|
|
515
391
|
}
|
|
516
392
|
|
|
517
|
-
/* @overload float?
|
|
518
|
-
|
|
519
|
-
(Inquiry) Returns true if `self` is float type array
|
|
520
|
-
*/
|
|
521
|
-
|
|
522
393
|
VALUE
|
|
523
394
|
rb_ca_is_float_type (VALUE self)
|
|
524
395
|
{
|
|
@@ -537,11 +408,6 @@ ca_is_complex_type (void *ap)
|
|
|
537
408
|
( ca->data_type <= CA_CMPLX256 ) );
|
|
538
409
|
}
|
|
539
410
|
|
|
540
|
-
/* @overload complex?
|
|
541
|
-
|
|
542
|
-
(Inquiry) Returns true if `self` is complex type array
|
|
543
|
-
*/
|
|
544
|
-
|
|
545
411
|
VALUE
|
|
546
412
|
rb_ca_is_complex_type (VALUE self)
|
|
547
413
|
{
|
|
@@ -559,11 +425,6 @@ ca_is_object_type (void *ap)
|
|
|
559
425
|
return ( ca->data_type == CA_OBJECT );
|
|
560
426
|
}
|
|
561
427
|
|
|
562
|
-
/* @overload object?
|
|
563
|
-
|
|
564
|
-
(Inquiry) Returns true if `self` is object type array
|
|
565
|
-
*/
|
|
566
|
-
|
|
567
428
|
VALUE
|
|
568
429
|
rb_ca_is_object_type (VALUE self)
|
|
569
430
|
{
|
|
@@ -576,13 +437,6 @@ rb_ca_is_object_type (VALUE self)
|
|
|
576
437
|
|
|
577
438
|
static ID id_parent;
|
|
578
439
|
|
|
579
|
-
/* @overload parent
|
|
580
|
-
|
|
581
|
-
(Attribute)
|
|
582
|
-
Returns the parent carray if `self` has parent,
|
|
583
|
-
or returns nil if `self` has no parent.
|
|
584
|
-
*/
|
|
585
|
-
|
|
586
440
|
VALUE
|
|
587
441
|
rb_ca_parent (VALUE self)
|
|
588
442
|
{
|
|
@@ -601,128 +455,44 @@ rb_ca_set_parent (VALUE self, VALUE obj)
|
|
|
601
455
|
|
|
602
456
|
/* ------------------------------------------------------------------- */
|
|
603
457
|
|
|
604
|
-
static ID id_data_class;
|
|
605
|
-
|
|
606
|
-
/* @overload data_class
|
|
607
|
-
|
|
608
|
-
(Attribute)
|
|
609
|
-
Returns data_class if `self` is fixed-length type and it
|
|
610
|
-
has the data class.
|
|
611
|
-
*/
|
|
612
|
-
|
|
613
458
|
VALUE
|
|
614
459
|
rb_ca_data_class (VALUE self)
|
|
615
460
|
{
|
|
616
|
-
volatile VALUE parent, data_class;
|
|
617
461
|
CArray *ca;
|
|
618
462
|
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
463
|
+
/* Only a Face carries data_class; a non-Face CArray is always
|
|
464
|
+
Qnil. CARecord stores it in its tail (reached directly via
|
|
465
|
+
obj_type, no Ruby roundtrip); numeric Faces such as
|
|
466
|
+
CATime / CATimedelta have no data_class. */
|
|
467
|
+
if ( ! ca_test_flag(ca, CA_FLAG_IS_FACE) ) {
|
|
624
468
|
return Qnil;
|
|
625
469
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
return data_class;
|
|
629
|
-
}
|
|
630
|
-
else {
|
|
631
|
-
return Qnil;
|
|
632
|
-
if ( ca_is_entity(ca) ) { /* no further parent */
|
|
633
|
-
ca_set_flag(ca, CA_FLAG_NOT_DATA_CLASS);
|
|
634
|
-
return Qnil;
|
|
635
|
-
}
|
|
636
|
-
else {
|
|
637
|
-
parent = rb_ca_parent(self);
|
|
638
|
-
if ( NIL_P(parent) ) { /* no parent */
|
|
639
|
-
ca_set_flag(ca, CA_FLAG_NOT_DATA_CLASS);
|
|
640
|
-
return Qnil;
|
|
641
|
-
}
|
|
642
|
-
else {
|
|
643
|
-
CArray *cr;
|
|
644
|
-
TypedData_Get_Struct(parent, CArray, &carray_data_type, cr);
|
|
645
|
-
if ( cr->bytes != ca->bytes ) { /* byte size mismatch */
|
|
646
|
-
ca_set_flag(ca, CA_FLAG_NOT_DATA_CLASS);
|
|
647
|
-
return Qnil;
|
|
648
|
-
}
|
|
649
|
-
else {
|
|
650
|
-
data_class = rb_ca_data_class(parent); /* parent's data class */
|
|
651
|
-
if ( ! NIL_P(data_class) ) {
|
|
652
|
-
return data_class;
|
|
653
|
-
}
|
|
654
|
-
else {
|
|
655
|
-
ca_set_flag(ca, CA_FLAG_NOT_DATA_CLASS);
|
|
656
|
-
return Qnil;
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
}
|
|
470
|
+
if ( ca->obj_type == CA_OBJ_RECORD ) {
|
|
471
|
+
return rb_ca_record_get_data_class(ca);
|
|
661
472
|
}
|
|
473
|
+
return Qnil;
|
|
662
474
|
}
|
|
663
475
|
|
|
664
|
-
/* @overload has_data_class?
|
|
665
|
-
|
|
666
|
-
(Inquiry) Returns true if `self` is fixed-length type and has the data class.
|
|
667
|
-
*/
|
|
668
|
-
|
|
669
476
|
VALUE
|
|
670
477
|
rb_ca_has_data_class (VALUE self)
|
|
671
478
|
{
|
|
672
|
-
|
|
673
|
-
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
674
|
-
if ( ca_test_flag(ca, CA_FLAG_NOT_DATA_CLASS) ) {
|
|
675
|
-
return Qfalse;
|
|
676
|
-
}
|
|
677
|
-
else {
|
|
678
|
-
if ( ca_is_fixlen_type(ca) ) {
|
|
679
|
-
if ( RTEST(rb_ca_data_class(self)) ) {
|
|
680
|
-
return Qtrue;
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
ca_set_flag(ca, CA_FLAG_NOT_DATA_CLASS);
|
|
684
|
-
return Qfalse;
|
|
685
|
-
}
|
|
479
|
+
return RTEST(rb_ca_data_class(self)) ? Qtrue : Qfalse;
|
|
686
480
|
}
|
|
687
481
|
|
|
688
482
|
/* ------------------------------------------------------------------- */
|
|
689
483
|
|
|
484
|
+
/* data_class= is defined but always raises. data_class now lives
|
|
485
|
+
on the Face (CARecord) tail; there is no way to attach one to a
|
|
486
|
+
non-Face CArray in-place. The setter is kept only so a call
|
|
487
|
+
surfaces the migration message rather than NoMethodError.
|
|
488
|
+
NORETURN: rb_raise never returns, so neither does this function. */
|
|
489
|
+
NORETURN(VALUE rb_ca_set_data_class(VALUE self, VALUE klass));
|
|
690
490
|
VALUE
|
|
691
|
-
rb_ca_data_type_inherit (VALUE self, VALUE other)
|
|
692
|
-
{
|
|
693
|
-
if ( RTEST(rb_ca_is_fixlen_type(self)) ) {
|
|
694
|
-
VALUE data_class = rb_ca_data_class(other);
|
|
695
|
-
if ( RTEST(data_class) ) {
|
|
696
|
-
rb_ivar_set(self, rb_intern("member"), rb_hash_new());
|
|
697
|
-
return rb_ivar_set(self, id_data_class, data_class);
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
return Qnil;
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
VALUE
|
|
704
|
-
rb_ca_data_type_import (VALUE self, VALUE data_type)
|
|
705
|
-
{
|
|
706
|
-
if ( RTEST(rb_ca_is_fixlen_type(self)) &&
|
|
707
|
-
rb_obj_is_data_class(data_type) ) {
|
|
708
|
-
rb_ivar_set(self, rb_intern("member"), rb_hash_new());
|
|
709
|
-
return rb_ivar_set(self, id_data_class, data_type);
|
|
710
|
-
}
|
|
711
|
-
return Qnil;
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
static VALUE
|
|
715
491
|
rb_ca_set_data_class (VALUE self, VALUE klass)
|
|
716
492
|
{
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
return rb_ivar_set(self, id_data_class, klass);
|
|
721
|
-
}
|
|
722
|
-
else {
|
|
723
|
-
rb_raise(rb_eTypeError, "invalid data_class or self is not fixlen array.");
|
|
724
|
-
}
|
|
725
|
-
return Qnil;
|
|
493
|
+
rb_raise(rb_eArgError,
|
|
494
|
+
"CArray#data_class= was removed in 3.0. "
|
|
495
|
+
"Use `CARecord.new(klass, *shape)` or `CARecord.wrap(entity, klass)`.");
|
|
726
496
|
}
|
|
727
497
|
|
|
728
498
|
/* ------------------------------------------------------------------- */
|
|
@@ -734,8 +504,14 @@ ca_root_array (void *ap)
|
|
|
734
504
|
if ( ca_is_entity(ca) ) {
|
|
735
505
|
return ca;
|
|
736
506
|
}
|
|
507
|
+
else if ( ca_test_flag(ca, CA_FLAG_MULTI_PARENTS) ) {
|
|
508
|
+
/* Multi-parent view fans out to K roots, so the single-
|
|
509
|
+
reference chain terminates here — the view itself is the
|
|
510
|
+
root boundary. */
|
|
511
|
+
return ca;
|
|
512
|
+
}
|
|
737
513
|
else {
|
|
738
|
-
|
|
514
|
+
CAView *cr = (CAView *)ca;
|
|
739
515
|
if ( ! cr->parent ) {
|
|
740
516
|
return ca;
|
|
741
517
|
}
|
|
@@ -745,12 +521,6 @@ ca_root_array (void *ap)
|
|
|
745
521
|
}
|
|
746
522
|
}
|
|
747
523
|
|
|
748
|
-
/* @overload root_array
|
|
749
|
-
|
|
750
|
-
(Attribute)
|
|
751
|
-
Returns the object at the root of chain of reference.
|
|
752
|
-
*/
|
|
753
|
-
|
|
754
524
|
static VALUE
|
|
755
525
|
rb_ca_root_array (VALUE self)
|
|
756
526
|
{
|
|
@@ -760,6 +530,9 @@ rb_ca_root_array (VALUE self)
|
|
|
760
530
|
if ( ca_is_entity(ca) ) {
|
|
761
531
|
return self;
|
|
762
532
|
}
|
|
533
|
+
else if ( ca_test_flag(ca, CA_FLAG_MULTI_PARENTS) ) {
|
|
534
|
+
return self; /* Multi-parent: root boundary (fans out to K roots). */
|
|
535
|
+
}
|
|
763
536
|
else {
|
|
764
537
|
refary = rb_ca_parent(self);
|
|
765
538
|
if ( NIL_P(refary) ) {
|
|
@@ -783,6 +556,9 @@ rb_ca_ancestors_loop (VALUE self, VALUE list)
|
|
|
783
556
|
if ( ca_is_entity(ca) ) {
|
|
784
557
|
return list;
|
|
785
558
|
}
|
|
559
|
+
else if ( ca_test_flag(ca, CA_FLAG_MULTI_PARENTS) ) {
|
|
560
|
+
return list; /* Multi-parent: chain terminates here (fans out to K). */
|
|
561
|
+
}
|
|
786
562
|
else {
|
|
787
563
|
refary = rb_ca_parent(self);
|
|
788
564
|
if ( rb_obj_is_carray(refary) ) {
|
|
@@ -794,18 +570,10 @@ rb_ca_ancestors_loop (VALUE self, VALUE list)
|
|
|
794
570
|
}
|
|
795
571
|
}
|
|
796
572
|
|
|
797
|
-
/* @overload ancestors
|
|
798
|
-
|
|
799
|
-
(Attribute)
|
|
800
|
-
Returns the list of objects in the chain of reference.
|
|
801
|
-
*/
|
|
802
|
-
|
|
803
573
|
static VALUE
|
|
804
574
|
rb_ca_ancestors (VALUE self)
|
|
805
575
|
{
|
|
806
576
|
volatile VALUE list;
|
|
807
|
-
CArray *ca;
|
|
808
|
-
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
|
809
577
|
list = rb_ary_new();
|
|
810
578
|
return rb_ca_ancestors_loop(self, list);
|
|
811
579
|
}
|
|
@@ -813,17 +581,17 @@ rb_ca_ancestors (VALUE self)
|
|
|
813
581
|
/* ------------------------------------------------------------------- */
|
|
814
582
|
|
|
815
583
|
void
|
|
816
|
-
Init_carray_attribute ()
|
|
584
|
+
Init_carray_attribute (void)
|
|
817
585
|
{
|
|
818
586
|
id_parent = rb_intern("parent");
|
|
819
|
-
id_data_class = rb_intern("data_class");
|
|
820
587
|
|
|
821
588
|
rb_define_method(rb_cCArray, "obj_type", rb_ca_obj_type, 0);
|
|
822
589
|
rb_define_method(rb_cCArray, "data_type", rb_ca_data_type, 0);
|
|
823
590
|
rb_define_method(rb_cCArray, "bytes", rb_ca_bytes, 0);
|
|
824
|
-
rb_define_method(rb_cCArray, "
|
|
825
|
-
rb_define_method(rb_cCArray, "
|
|
826
|
-
rb_define_method(rb_cCArray, "
|
|
591
|
+
rb_define_method(rb_cCArray, "flags", rb_ca_flags, 0);
|
|
592
|
+
rb_define_method(rb_cCArray, "ndim", rb_ca_ndim, 0);
|
|
593
|
+
rb_define_method(rb_cCArray, "rank", rb_ca_ndim, 0);
|
|
594
|
+
rb_define_method(rb_cCArray, "shape", rb_ca_dim, 0);
|
|
827
595
|
rb_define_method(rb_cCArray, "dim", rb_ca_dim, 0);
|
|
828
596
|
rb_define_method(rb_cCArray, "dim0", rb_ca_dim0, 0);
|
|
829
597
|
rb_define_method(rb_cCArray, "dim1", rb_ca_dim1, 0);
|
|
@@ -846,6 +614,7 @@ Init_carray_attribute ()
|
|
|
846
614
|
rb_define_method(rb_cCArray, "virtual?", rb_ca_is_virtual, 0);
|
|
847
615
|
rb_define_method(rb_cCArray, "value_array?", rb_ca_is_value_array, 0);
|
|
848
616
|
rb_define_method(rb_cCArray, "mask_array?", rb_ca_is_mask_array, 0);
|
|
617
|
+
rb_define_method(rb_cCArray, "face?", rb_ca_is_face, 0);
|
|
849
618
|
|
|
850
619
|
rb_define_method(rb_cCArray, "empty?", rb_ca_is_empty, 0);
|
|
851
620
|
rb_define_method(rb_cCArray, "read_only?", rb_ca_is_read_only, 0);
|
|
@@ -857,7 +626,6 @@ Init_carray_attribute ()
|
|
|
857
626
|
rb_define_method(rb_cCArray, "boolean?", rb_ca_is_boolean_type, 0);
|
|
858
627
|
rb_define_method(rb_cCArray, "numeric?", rb_ca_is_numeric_type, 0);
|
|
859
628
|
rb_define_method(rb_cCArray, "integer?", rb_ca_is_integer_type, 0);
|
|
860
|
-
rb_define_method(rb_cCArray, "unsigned?", rb_ca_is_unsigned_type, 0);
|
|
861
629
|
rb_define_method(rb_cCArray, "float?", rb_ca_is_float_type, 0);
|
|
862
630
|
rb_define_method(rb_cCArray, "complex?", rb_ca_is_complex_type, 0);
|
|
863
631
|
rb_define_method(rb_cCArray, "object?", rb_ca_is_object_type, 0);
|