object-introspection/types/map_seq_type.toml
Jake Hillion f9cb0115e1 types: remove now unused handlers
Summary:

Handlers were added in an intermediate form of tbv2 but those intermediate
forms have now been removed. Remove all the handlers to make grepping/find and
replaces easier across the types.

Test Plan:

- CI
2023-11-15 14:27:07 +00:00

103 lines
3.1 KiB
TOML

[info]
type_name = "folly::sorted_vector_map"
ctype = "MAP_SEQ_TYPE"
header = "folly/sorted_vector_types.h"
stub_template_params = [2,3]
# Old:
typeName = "folly::sorted_vector_map<"
ns = ["namespace std", "folly::sorted_vector_map"]
numTemplateParams = 2
replaceTemplateParamIndex = []
[codegen]
decl = """
template <class Key, class Value, class Compare, class Allocator, class GrowthPolicy, class Container>
void getSizeType(const %1%<Key, Value, Compare, Allocator, GrowthPolicy, Container> &container, size_t& returnArg);
"""
func = """
template <class Key, class Value, class Compare, class Allocator, class GrowthPolicy, class Container>
void getSizeType(const %1%<Key, Value, Compare, Allocator, GrowthPolicy, Container> &container, size_t& returnArg)
{
SAVE_SIZE(sizeof(%1%<Key,Value,Compare,Allocator,GrowthPolicy,Container>));
SAVE_DATA((uintptr_t)&container);
SAVE_DATA((uintptr_t)container.capacity());
SAVE_DATA((uintptr_t)container.size());
SAVE_SIZE((container.capacity() - container.size()) * (sizeof(Key) + sizeof(Value)));
for (auto const& it : container)
{
getSizeType(it.first, returnArg);
getSizeType(it.second, returnArg);
}
}
"""
traversal_func = '''
auto tail = returnArg.write((uintptr_t)&container)
.write(container.capacity())
.write(container.size());
for (const auto& kv : container) {
tail = tail.delegate([&kv](auto ret) {
auto start = maybeCaptureKey<captureKeys, DB, T0>(kv.first, ret);
auto next = start.delegate([&kv](typename TypeHandler<DB, T0>::type ret) {
return OIInternal::getSizeType<DB>(kv.first, ret);
});
return OIInternal::getSizeType<DB>(kv.second, next);
});
}
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 = '''
std::conditional_t<captureKeys,
types::st::List<DB, types::st::Pair<DB,
typename CaptureKeyHandler<DB, T0>::type,
types::st::Pair<DB,
typename TypeHandler<DB, T0>::type,
typename TypeHandler<DB, T1>::type>>>,
types::st::List<DB, types::st::Pair<DB,
typename TypeHandler<DB, T0>::type,
typename TypeHandler<DB, T1>::type>>>
'''
func = '''
using element_type = std::pair<T0, T1>;
static constexpr std::array<inst::Field, 2> entryFields{
make_field<DB, T0>("key"),
make_field<DB, T1>("value"),
};
static constexpr auto processors = maybeCaptureKeysProcessor<captureKeys, DB, T0>();
static constexpr auto entry = inst::Field {
sizeof(element_type),
sizeof(element_type) - sizeof(T0) - sizeof(T1),
"[]",
std::array<std::string_view, 0>{},
entryFields,
processors,
};
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(element_type);
for (size_t i = 0; i < list.length; i++)
stack_ins(entry);
'''