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
|
|
|
|
|
|
|
handler = """
|
2023-07-04 16:55:17 +01:00
|
|
|
template <typename DB, typename T0, typename T1>
|
|
|
|
struct TypeHandler<DB, %1%<T0, T1>> {
|
2023-06-29 13:07:46 +01:00
|
|
|
using type = types::st::Pair<
|
|
|
|
DB, types::st::VarInt<DB>,
|
|
|
|
types::st::Pair<
|
|
|
|
DB, types::st::VarInt<DB>,
|
|
|
|
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-07-04 16:55:17 +01:00
|
|
|
const %1%<T0, T1> & container,
|
|
|
|
typename TypeHandler<DB, %1%<T0, T1>>::type returnArg) {
|
2023-04-20 17:52:58 +01:00
|
|
|
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) {
|
|
|
|
return OIInternal::getSizeType<DB>(it, ret);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return tail.finish();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
"""
|
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) {
|
|
|
|
return OIInternal::getSizeType<DB>(it, ret);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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]]
|
|
|
|
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
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < list.length; i++)
|
2023-09-14 16:09:23 +01:00
|
|
|
stack_ins(childField);
|
2023-08-16 20:40:36 +01:00
|
|
|
"""
|