mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +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
65 lines
1.4 KiB
TOML
65 lines
1.4 KiB
TOML
[info]
|
|
type_name = "std::optional"
|
|
ctype = "OPTIONAL_TYPE"
|
|
header = "optional"
|
|
|
|
# Old:
|
|
typeName = "std::optional<"
|
|
ns = ["namespace std"]
|
|
numTemplateParams = 1
|
|
|
|
[codegen]
|
|
decl = """
|
|
template<typename T>
|
|
void getSizeType(const %1%<T> &container, size_t& returnArg);
|
|
"""
|
|
|
|
func = """
|
|
template <typename T>
|
|
void getSizeType(const %1%<T>& container, size_t& returnArg) {
|
|
if (container) {
|
|
SAVE_SIZE(sizeof(%1%<T>) - sizeof(T));
|
|
SAVE_DATA(true);
|
|
getSizeType(*container, returnArg);
|
|
} else {
|
|
SAVE_SIZE(sizeof(%1%<T>));
|
|
SAVE_DATA(false);
|
|
}
|
|
}
|
|
"""
|
|
|
|
traversal_func = """
|
|
if (container.has_value()) {
|
|
return returnArg.template delegate<1>([&ctx, &container](auto ret) {
|
|
return OIInternal::getSizeType<Ctx>(ctx, *container, ret);
|
|
});
|
|
} else {
|
|
return returnArg.template delegate<0>(std::identity());
|
|
}
|
|
"""
|
|
|
|
[[codegen.processor]]
|
|
type = "types::st::Sum<DB, types::st::Unit<DB>, typename TypeHandler<Ctx, T0>::type>"
|
|
func = """
|
|
static constexpr std::array<std::string_view, 1> names{"TODO"};
|
|
static constexpr auto elementField = inst::Field{
|
|
sizeof(T0),
|
|
"el",
|
|
names,
|
|
TypeHandler<Ctx, T0>::fields,
|
|
TypeHandler<Ctx, T0>::processors,
|
|
};
|
|
|
|
auto sum = std::get<ParsedData::Sum>(d.val);
|
|
|
|
el.container_stats = result::Element::ContainerStats {
|
|
.capacity = 1,
|
|
.length = sum.index,
|
|
};
|
|
|
|
if (sum.index == 1) {
|
|
el.exclusive_size -= sizeof(T0);
|
|
stack_ins(elementField);
|
|
}
|
|
"""
|