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
|
|
|
|
|
|
|
handler = """
|
|
|
|
template<typename DB, typename T0, long unsigned int N>
|
|
|
|
struct TypeHandler<DB, %1%<T0, N>> {
|
2023-06-29 13:07:46 +01:00
|
|
|
using type = types::st::List<DB, typename TypeHandler<DB, T0>::type>;
|
2023-04-20 17:52:58 +01:00
|
|
|
|
2023-06-29 13:07:46 +01:00
|
|
|
static types::st::Unit<DB> getSizeType(
|
2023-04-20 17:52:58 +01:00
|
|
|
const %1%<T0, N> &container,
|
|
|
|
typename TypeHandler<DB, %1%<T0,N>>::type returnArg) {
|
|
|
|
auto tail = returnArg.write(container.size());
|
|
|
|
|
|
|
|
for (auto & it: container) {
|
|
|
|
tail = tail.delegate([&it](auto ret) {
|
|
|
|
return TypeHandler<DB, T0>::getSizeType(it, ret);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return tail.finish();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
"""
|
2023-08-16 20:40:36 +01:00
|
|
|
|
|
|
|
traversal_func = """
|
|
|
|
auto tail = returnArg.write(container.size());
|
|
|
|
|
|
|
|
for (auto & it: container) {
|
|
|
|
tail = tail.delegate([&it](auto ret) {
|
|
|
|
return TypeHandler<DB, T0>::getSizeType(it, ret);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return tail.finish();
|
|
|
|
"""
|
|
|
|
|
|
|
|
[[codegen.processor]]
|
|
|
|
type = "types::st::List<DB, typename TypeHandler<DB, T0>::type>"
|
|
|
|
func = """
|
2023-08-25 18:36:42 +01:00
|
|
|
static constexpr auto childField = make_field<DB, 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++)
|
|
|
|
ins.emplace(childField);
|
|
|
|
"""
|