object-introspection/types/pair_type.toml
Jake Hillion b117150f83 tbv2: add dynamic context passed through all functions (#410)
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
2023-11-16 08:03:32 -08:00

48 lines
1.2 KiB
TOML

[info]
type_name = "std::pair"
ctype = "PAIR_TYPE"
header = "utility"
# Old:
typeName = "std::pair<"
ns = ["namespace std"]
numTemplateParams = 2
replaceTemplateParamIndex = []
[codegen]
decl = """
template<typename P, typename Q>
void getSizeType(const %1%<P,Q> &container, size_t& returnArg);
"""
func = """
template<typename P, typename Q>
void getSizeType(const %1%<P,Q> &container, size_t& returnArg)
{
SAVE_SIZE(sizeof(%1%<P,Q>) - sizeof(P) - sizeof(Q));
getSizeType(container.first, returnArg);
getSizeType(container.second, returnArg);
}
"""
traversal_func = """
return OIInternal::getSizeType<Ctx>(ctx,
container.second,
returnArg.delegate([&ctx, &container](auto ret) {
return OIInternal::getSizeType<Ctx>(ctx, container.first, ret);
})
);
"""
[[codegen.processor]]
type = "types::st::Pair<DB, typename TypeHandler<Ctx, T0>::type, typename TypeHandler<Ctx, T1>::type>"
func = """
static constexpr auto firstField = make_field<Ctx, T0>("first");
static constexpr auto secondField = make_field<Ctx, T1>("second");
el.exclusive_size = sizeof(std::pair<T0, T1>) - sizeof(T0) - sizeof(T1);
stack_ins(secondField);
stack_ins(firstField);
"""