object-introspection/types/ref_wrapper_type.toml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
1.5 KiB
TOML
Raw Normal View History

2022-12-19 14:37:51 +00:00
[info]
type_name = "std::reference_wrapper"
2022-12-19 14:37:51 +00:00
ctype = "REF_WRAPPER_TYPE"
header = "functional"
# Old:
typeName = "std::reference_wrapper<"
2022-12-19 14:37:51 +00:00
ns = ["namespace std"]
numTemplateParams = 1
2022-12-19 14:37:51 +00:00
replaceTemplateParamIndex = []
[codegen]
decl = """
template<typename T>
void getSizeType(const %1%<T> &ref, size_t& returnArg);
2022-12-19 14:37:51 +00:00
"""
func = """
template<typename T>
void getSizeType(const %1%<T> &ref, size_t& returnArg)
{
SAVE_SIZE(sizeof(%1%<T>));
SAVE_DATA((uintptr_t)&(ref.get()));
if (ctx.pointers.add((uintptr_t)&ref.get())) {
2023-04-05 20:55:40 +01:00
SAVE_DATA(1);
getSizeType(ref.get(), returnArg);
} else {
SAVE_DATA(0);
}
2022-12-19 14:37:51 +00:00
}
"""
traversal_func = """
auto tail = returnArg.write((uintptr_t)&(container.get()));
if (ctx.pointers.add((uintptr_t)&container.get())) {
return tail.template delegate<1>([&ctx, &container](auto ret) {
return OIInternal::getSizeType<Ctx>(ctx, container.get(), ret);
});
} else {
return tail.template delegate<0>(std::identity());
}
"""
[[codegen.processor]]
type = "types::st::VarInt<DB>"
func = """
el.pointer = std::get<ParsedData::VarInt>(d.val).value;
"""
[[codegen.processor]]
type = """
types::st::Sum<DB,
types::st::Unit<DB>,
typename TypeHandler<Ctx, T0>::type>
"""
func = """
auto sum = std::get<ParsedData::Sum>(d.val);
el.container_stats.emplace(result::Element::ContainerStats {
.capacity = 1,
.length = sum.index, // 0 if in a cycle, 1 otherwise
});
if constexpr (oi_is_complete<T0>) {
if (sum.index == 1) {
static constexpr auto element = make_field<Ctx, T0>("ref_val");
stack_ins(element);
}
}
"""