mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-12 21:56:54 +00:00
Implement Container V2 for folly::sorted_vector_set
This commit is contained in:
parent
8bad704d9c
commit
edb7bf5f3f
@ -5,7 +5,6 @@ definitions = '''
|
||||
|
||||
[cases]
|
||||
[cases.no_ints]
|
||||
oil_skip = 'not implemented for treebuilder v2' # https://github.com/facebookexperimental/object-introspection/issues/320
|
||||
param_types = ["const sorted_vector_set<int>&"]
|
||||
setup = "return {};"
|
||||
expect_json = '''[{
|
||||
@ -21,9 +20,14 @@ definitions = '''
|
||||
"capacity": 0,
|
||||
"elementStaticSize": 4
|
||||
}]}]'''
|
||||
expect_json_v2 = '''[{
|
||||
"staticSize": 24,
|
||||
"exclusiveSize": 24,
|
||||
"length": 0,
|
||||
"capacity": 0
|
||||
}]'''
|
||||
|
||||
[cases.some_ints]
|
||||
oil_skip = 'not implemented for treebuilder v2' # https://github.com/facebookexperimental/object-introspection/issues/320
|
||||
param_types = ["const sorted_vector_set<int>&"]
|
||||
setup = '''
|
||||
sorted_vector_set<int> is;
|
||||
@ -49,3 +53,9 @@ definitions = '''
|
||||
"elementStaticSize": 4
|
||||
}]}]
|
||||
'''
|
||||
expect_json_v2 = '''[{
|
||||
"staticSize": 24,
|
||||
"exclusiveSize": 28,
|
||||
"length": 3,
|
||||
"capacity": 4
|
||||
}]'''
|
||||
|
@ -47,3 +47,41 @@ struct TypeHandler<DB, %1%<T0, T1, T2, T3, T4>> {
|
||||
}
|
||||
};
|
||||
"""
|
||||
|
||||
traversal_func = '''
|
||||
auto tail = returnArg.write((uintptr_t)&container)
|
||||
.write(container.capacity())
|
||||
.write(container.size());
|
||||
|
||||
for (const auto& el : container) {
|
||||
tail = tail.delegate([&el](auto ret) {
|
||||
return OIInternal::getSizeType<DB>(el, 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 = """
|
||||
static constexpr auto childField = make_field<DB, T0>("[]");
|
||||
|
||||
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++)
|
||||
stack_ins(childField);
|
||||
"""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user