2022-12-19 14:37:51 +00:00
|
|
|
[info]
|
2023-05-23 22:26:38 +01:00
|
|
|
type_name = "std::vector"
|
|
|
|
stub_template_params = [1]
|
2022-12-19 14:37:51 +00:00
|
|
|
header = "vector"
|
2023-05-23 22:26:38 +01:00
|
|
|
|
|
|
|
# Old:
|
2023-08-16 20:40:36 +01:00
|
|
|
ctype = "SEQ_TYPE"
|
2023-05-23 22:26:38 +01:00
|
|
|
typeName = "std::vector<"
|
2022-12-19 14:37:51 +00:00
|
|
|
ns = ["namespace std"]
|
2023-05-23 22:26:38 +01:00
|
|
|
numTemplateParams = 1
|
2022-12-19 14:37:51 +00:00
|
|
|
allocatorIndex = 1
|
|
|
|
|
|
|
|
[codegen]
|
|
|
|
decl = """
|
2023-05-31 14:49:47 +01:00
|
|
|
template<typename T, typename Allocator>
|
|
|
|
void getSizeType(const %1%<T, Allocator> &container, size_t& returnArg);
|
2022-12-19 14:37:51 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
func = """
|
2023-05-31 14:49:47 +01:00
|
|
|
template<typename T, typename Allocator>
|
|
|
|
void getSizeType(const %1%<T, Allocator> &container, size_t& returnArg)
|
2022-12-19 14:37:51 +00:00
|
|
|
{
|
|
|
|
SAVE_SIZE(sizeof(%1%<T>));
|
|
|
|
|
|
|
|
SAVE_DATA((uintptr_t)&container);
|
|
|
|
SAVE_DATA((uintptr_t)container.capacity());
|
|
|
|
SAVE_DATA((uintptr_t)container.size());
|
|
|
|
|
|
|
|
SAVE_SIZE((container.capacity() - container.size()) * sizeof(T));
|
|
|
|
|
|
|
|
// The double ampersand is needed otherwise this loop doesn't work with vector<bool>
|
|
|
|
for (auto&& it: container) {
|
|
|
|
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((uintptr_t)&container)
|
|
|
|
.write(container.capacity())
|
|
|
|
.write(container.size());
|
|
|
|
|
|
|
|
// The double ampersand is needed otherwise this loop doesn't work with
|
|
|
|
// vector<bool>
|
|
|
|
for (auto&& it : container) {
|
|
|
|
tail = tail.delegate([&it](auto ret) {
|
2023-11-15 19:28:21 +00:00
|
|
|
return OIInternal::getSizeType<Ctx>(it, ret);
|
2023-08-16 20:40:36 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return tail.finish();
|
|
|
|
"""
|
|
|
|
|
|
|
|
[[codegen.processor]]
|
|
|
|
type = "types::st::VarInt<DB>"
|
|
|
|
func = """
|
|
|
|
el.pointer = std::get<ParsedData::VarInt>(d.val).value;
|
|
|
|
"""
|
|
|
|
|
|
|
|
[[codegen.processor]]
|
|
|
|
type = "types::st::VarInt<DB>"
|
|
|
|
func = """
|
|
|
|
el.container_stats.emplace(result::Element::ContainerStats{ .capacity = std::get<ParsedData::VarInt>(d.val).value });
|
|
|
|
"""
|
|
|
|
|
|
|
|
[[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
|
|
|
|
|
|
|
auto list = std::get<ParsedData::List>(d.val);
|
|
|
|
el.container_stats->length = list.length;
|
|
|
|
el.exclusive_size += (el.container_stats->capacity - el.container_stats->length) * sizeof(T0);
|
|
|
|
|
2023-10-13 01:29:38 +01:00
|
|
|
stack_ins(inst::Repeat{ list.length, childField });
|
2023-08-16 20:40:36 +01:00
|
|
|
"""
|