mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-13 22:06:55 +00:00
b117150f83
Summary: tbv2: add dynamic context passed through all functions Previously for we had some shared state between all requests, noticeably the pointers set. This change adds a by reference value to all requests which can hold additional mutable state. The pointers set is moved into this mutable state for OIL, which means each concurrent request will have its own pointer set. Doing things this way allows more features to be added in the future without such a big code modification. Closes https://github.com/facebookexperimental/object-introspection/issues/404 Pull Request resolved: https://github.com/facebookexperimental/object-introspection/pull/410 Test Plan: - CI Differential Revision: D51394035 Pulled By: JakeHillion fbshipit-source-id: 55d2ba9b5e056148a29dc821020cfc3d94e5175a
55 lines
1.3 KiB
TOML
55 lines
1.3 KiB
TOML
[info]
|
|
type_name = "std::array"
|
|
ctype = "ARRAY_TYPE"
|
|
header = "array"
|
|
|
|
# Old:
|
|
numTemplateParams = 1
|
|
ns = ["namespace std"]
|
|
typeName = "std::array<"
|
|
|
|
[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);
|
|
}
|
|
}
|
|
"""
|
|
|
|
traversal_func = """
|
|
auto tail = returnArg.write(container.size());
|
|
|
|
for (auto & it: container) {
|
|
tail = tail.delegate([&ctx, &it](auto ret) {
|
|
return TypeHandler<Ctx, T0>::getSizeType(ctx, it, ret);
|
|
});
|
|
}
|
|
|
|
return tail.finish();
|
|
"""
|
|
|
|
[[codegen.processor]]
|
|
type = "types::st::List<DB, typename TypeHandler<Ctx, T0>::type>"
|
|
func = """
|
|
static constexpr auto childField = make_field<Ctx, T0>("[]");
|
|
|
|
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++)
|
|
stack_ins(childField);
|
|
"""
|