2022-12-19 14:37:51 +00:00
|
|
|
[info]
|
2023-05-23 22:26:38 +01:00
|
|
|
type_name = "std::array"
|
2022-12-19 14:37:51 +00:00
|
|
|
ctype = "ARRAY_TYPE"
|
|
|
|
header = "array"
|
2023-05-23 22:26:38 +01:00
|
|
|
|
|
|
|
# Old:
|
|
|
|
numTemplateParams = 1
|
2022-12-19 14:37:51 +00:00
|
|
|
ns = ["namespace std"]
|
2023-05-23 22:26:38 +01:00
|
|
|
typeName = "std::array<"
|
2022-12-19 14:37:51 +00:00
|
|
|
|
|
|
|
[codegen]
|
|
|
|
decl = """
|
|
|
|
template<typename T, long unsigned int N>
|
|
|
|
void getSizeType(const %1%<T, N> &container, size_t& returnArg);
|
|
|
|
"""
|
|
|
|
|
|
|
|
func = """
|
|
|
|
template<typename T, long unsigned int N>
|
|
|
|
void getSizeType(const %1%<T,N> &container, size_t& returnArg)
|
|
|
|
{
|
|
|
|
SAVE_DATA((uintptr_t)container.size());
|
|
|
|
SAVE_SIZE(sizeof(container));
|
|
|
|
|
|
|
|
for (auto & it: container) {
|
|
|
|
// undo the static size that has already been added per-element
|
|
|
|
SAVE_SIZE(-sizeof(it));
|
|
|
|
getSizeType(it, returnArg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
2023-04-20 17:52:58 +01:00
|
|
|
|
2023-08-16 20:40:36 +01:00
|
|
|
traversal_func = """
|
|
|
|
auto tail = returnArg.write(container.size());
|
|
|
|
|
|
|
|
for (auto & it: container) {
|
2023-11-16 15:34:03 +00:00
|
|
|
tail = tail.delegate([&ctx, &it](auto ret) {
|
|
|
|
return TypeHandler<Ctx, T0>::getSizeType(ctx, it, ret);
|
2023-08-16 20:40:36 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return tail.finish();
|
|
|
|
"""
|
|
|
|
|
|
|
|
[[codegen.processor]]
|
2023-11-15 19:28:21 +00:00
|
|
|
type = "types::st::List<DB, typename TypeHandler<Ctx, T0>::type>"
|
2023-08-16 20:40:36 +01:00
|
|
|
func = """
|
2023-11-15 19:28:21 +00:00
|
|
|
static constexpr auto childField = make_field<Ctx, T0>("[]");
|
2023-08-16 20:40:36 +01:00
|
|
|
|
|
|
|
size_t size = std::get<ParsedData::List>(d.val).length;
|
|
|
|
el.exclusive_size = N0 == 0 ? 1 : 0;
|
|
|
|
el.container_stats.emplace(result::Element::ContainerStats{ .capacity = size, .length = size });
|
|
|
|
for (size_t i = 0; i < size; i++)
|
2023-09-14 16:09:23 +01:00
|
|
|
stack_ins(childField);
|
2023-08-16 20:40:36 +01:00
|
|
|
"""
|