@@ -25,6 +25,52 @@ struct ArrayConstructorVector;
25
25
constexpr std::size_t MaxArrayConstructorVectorSizeInBytes = 2 * 40 ;
26
26
constexpr std::size_t MaxArrayConstructorVectorAlignInBytes = 8 ;
27
27
28
+ // This file defines an API to "push" an evaluated array constructor value
29
+ // "from" into some storage "to" of an array constructor. It can be seen as a
30
+ // form of std::vector::push_back() implementation for Fortran array
31
+ // constructors. In the APIs and ArrayConstructorVector struct above:
32
+ //
33
+ // - "to" is a ranked-1 descriptor whose declared type is already set to the
34
+ // array constructor derived type. It may be already allocated, even before the
35
+ // first call to this API, or it may be unallocated. "to" extent is increased
36
+ // every time a "from" is pushed past its current extent. At this end of the
37
+ // API calls, its extent is the extent of the array constructor. If "to" is
38
+ // unallocated and its extent is not null, it is assumed this is the final array
39
+ // constructor extent value, and the first allocation already "reserves" storage
40
+ // space accordingly to avoid reallocations.
41
+ // - "from" is a scalar or array descriptor for the evaluated array
42
+ // constructor value that must be copied into the storage of "to" at
43
+ // "nextValuePosition".
44
+ // - "useValueLengthParameters" must be set to true if the array constructor
45
+ // has length parameters and no type spec. If it is true and "to" is
46
+ // unallocated, "to" will take the length parameters of "from". If it is true
47
+ // and "to" is an allocated character array constructor, it will be checked
48
+ // that "from" length matches the one from "to". When it is false, the
49
+ // character length must already be set in "to" before the first call to this
50
+ // API and "from" character lengths are allowed to mismatch from "to".
51
+ // - "nextValuePosition" is the zero based sequence position of "from" in the
52
+ // array constructor. It is updated after this call by the number of "from"
53
+ // elements. It should be set to zero by the caller of this API before the first
54
+ // call.
55
+ // - "actualAllocationSize" is the current allocation size of "to" storage. It
56
+ // may be bigger than "to" extent for reallocation optimization purposes, but
57
+ // should never be smaller, unless this is the first call and "to" is
58
+ // unallocated. It is updated by the runtime after each successful allocation or
59
+ // reallocation. It should be set to "to" extent if "to" is allocated before the
60
+ // first call of this API, and can be left undefined otherwise.
61
+ //
62
+ // Note that this API can be used with "to" being a variable (that can be
63
+ // discontiguous). This can be done when the variable is the left hand side of
64
+ // an assignment from an array constructor as long as:
65
+ // - none of the ac-value overlaps with the variable,
66
+ // - this is an intrinsic assignment that is not a whole allocatable
67
+ // assignment, *and* for a type that has no components requiring user defined
68
+ // assignments,
69
+ // - the variable is properly finalized before using this API if its need to,
70
+ // - "useValueLengthParameters" should be set to false in this case, even if
71
+ // the array constructor has no type-spec, since the variable may have a
72
+ // different character length than the array constructor values.
73
+
28
74
extern " C" {
29
75
// API to initialize an ArrayConstructorVector before any values are pushed to
30
76
// it. Inlined code is only expected to allocate the "ArrayConstructorVector"
0 commit comments