2022-12-19 14:37:51 +00:00
|
|
|
[info]
|
2023-05-23 22:26:38 +01:00
|
|
|
type_name = "std::unique_ptr"
|
2022-12-19 14:37:51 +00:00
|
|
|
ctype = "UNIQ_PTR_TYPE"
|
|
|
|
header = "memory"
|
2023-05-23 22:26:38 +01:00
|
|
|
stub_template_params = [1]
|
|
|
|
|
|
|
|
# Old:
|
|
|
|
typeName = "std::unique_ptr"
|
2022-12-19 14:37:51 +00:00
|
|
|
ns = ["namespace std"]
|
2023-05-23 22:26:38 +01:00
|
|
|
numTemplateParams = 1
|
2022-12-19 14:37:51 +00:00
|
|
|
replaceTemplateParamIndex = []
|
|
|
|
|
|
|
|
[codegen]
|
|
|
|
decl = """
|
|
|
|
template<typename T, class Deleter>
|
2023-05-23 22:26:38 +01:00
|
|
|
void getSizeType(const %1%<T,Deleter> &container, size_t& returnArg);
|
2022-12-19 14:37:51 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
func = """
|
|
|
|
template<typename T, class Deleter>
|
2023-05-23 22:26:38 +01:00
|
|
|
void getSizeType(const %1%<T,Deleter> &u_ptr, size_t& returnArg)
|
2022-12-19 14:37:51 +00:00
|
|
|
{
|
|
|
|
SAVE_SIZE(sizeof(%1%<T,Deleter>));
|
|
|
|
|
2024-01-04 17:01:52 +00:00
|
|
|
if constexpr (oi_is_complete<T>) {
|
2023-05-23 22:26:38 +01:00
|
|
|
SAVE_DATA((uintptr_t)(u_ptr.get()));
|
2022-12-19 14:37:51 +00:00
|
|
|
|
2023-11-16 15:34:03 +00:00
|
|
|
if (u_ptr && ctx.pointers.add((uintptr_t)(u_ptr.get()))) {
|
2023-04-05 20:55:40 +01:00
|
|
|
SAVE_DATA(1);
|
2023-05-23 22:26:38 +01:00
|
|
|
getSizeType(*(u_ptr.get()), returnArg);
|
2023-04-05 20:55:40 +01:00
|
|
|
} else {
|
|
|
|
SAVE_DATA(0);
|
|
|
|
}
|
2022-12-19 14:37:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
2023-04-20 17:52:58 +01:00
|
|
|
|
2023-08-30 20:33:49 +01:00
|
|
|
traversal_func = """
|
|
|
|
auto tail = returnArg.write((uintptr_t)container.get());
|
|
|
|
|
2024-01-04 17:01:52 +00:00
|
|
|
if constexpr (!oi_is_complete<T0>) {
|
2023-08-30 20:33:49 +01:00
|
|
|
return tail.template delegate<0>(std::identity());
|
|
|
|
} else {
|
2023-11-16 15:34:03 +00:00
|
|
|
bool do_visit = container && ctx.pointers.add((uintptr_t)container.get());
|
2023-08-30 20:33:49 +01:00
|
|
|
if (!do_visit)
|
|
|
|
return tail.template delegate<0>(std::identity());
|
|
|
|
|
2023-11-16 15:34:03 +00:00
|
|
|
return tail.template delegate<1>([&ctx, &container](auto ret) {
|
|
|
|
return OIInternal::getSizeType<Ctx>(ctx, *container, ret);
|
2023-08-30 20:33:49 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
|
|
|
[[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>,
|
2023-11-15 19:28:21 +00:00
|
|
|
typename TypeHandler<Ctx, T0>::type>
|
2023-08-30 20:33:49 +01:00
|
|
|
"""
|
|
|
|
func = """
|
|
|
|
auto sum = std::get<ParsedData::Sum>(d.val);
|
|
|
|
el.container_stats.emplace(result::Element::ContainerStats {
|
|
|
|
.capacity = 1,
|
|
|
|
.length = sum.index, // 0 for empty containers/void, 1 otherwise
|
|
|
|
});
|
|
|
|
|
2023-11-15 19:28:21 +00:00
|
|
|
// Must be in a `if constexpr` or the compiler will complain about make_field<Ctx, void>
|
2024-01-04 17:01:52 +00:00
|
|
|
if constexpr (oi_is_complete<T0>) {
|
2023-08-30 20:33:49 +01:00
|
|
|
if (sum.index == 1) {
|
2023-11-15 19:28:21 +00:00
|
|
|
static constexpr auto element = make_field<Ctx, T0>("ptr_val");
|
2023-09-14 16:09:23 +01:00
|
|
|
stack_ins(element);
|
2023-08-30 20:33:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|