object-introspection/types/std_variant.toml
Jake Hillion f9cb0115e1 types: remove now unused handlers
Summary:

Handlers were added in an intermediate form of tbv2 but those intermediate
forms have now been removed. Remove all the handlers to make grepping/find and
replaces easier across the types.

Test Plan:

- CI
2023-11-15 14:27:07 +00:00

41 lines
1.1 KiB
TOML

[info]
type_name = "std::variant"
ctype = "STD_VARIANT_TYPE"
header = "variant"
# Old:
typeName = "std::variant"
ns = ["namespace std"]
[codegen]
decl = """
template<class... Types>
void getSizeType(const %1%<Types...> &container, size_t& returnArg);
"""
func = """
template<class... Types>
void getSizeType(const %1%<Types...> &container, size_t& returnArg)
{
SAVE_SIZE(sizeof(%1%<Types...>));
SAVE_DATA(container.index());
// This check should be `container.valueless_by_exception()` but it doesn't
// work with the variable sized integers used in `std::variant`. For fewer
// than 256 options it uses a `uint8_t` index but checks against -1 of
// `uintptr_t`. Manually check for any out of bounds indices as a workaround.
if (container.index() >= sizeof...(Types)) {
return;
}
std::visit([&returnArg](auto &&arg) {
// Account for inline contents
SAVE_SIZE(-sizeof(arg));
getSizeType(arg, returnArg);
}, container);
}
"""
# TODO: Add tbv2 definitions. The removed intermediate handler is a good
# template for this, find it in the git logs.