object-introspection/types/list_type.toml
2023-06-30 12:54:02 +01:00

61 lines
1.5 KiB
TOML

[info]
type_name = "std::list"
stub_template_params = [1]
ctype = "LIST_TYPE"
header = "list"
# Old:
typeName = "std::list<"
ns = ["namespace std"]
numTemplateParams = 1
replaceTemplateParamIndex = []
allocatorIndex = 1
[codegen]
decl = """
template<typename T, typename Allocator>
void getSizeType(const %1%<T, Allocator> &container, size_t& returnArg);
"""
func = """
template<typename T, typename Allocator>
void getSizeType(const %1%<T, Allocator> &container, size_t& returnArg)
{
SAVE_SIZE(sizeof(%1%<T>));
SAVE_DATA((uintptr_t)&container);
SAVE_DATA((uintptr_t)container.size());
// The double ampersand is needed otherwise this loop doesn't work with vector<bool>
for (auto&& it: container) {
getSizeType(it, returnArg);
}
}
"""
handler = """
template <typename DB, typename T0, typename T1>
struct TypeHandler<DB, %1% <T0, T1>> {
using type = types::st::Pair<DB,
types::st::VarInt<DB>,
types::st::List<DB, typename TypeHandler<DB, T0>::type>>;
static types::st::Unit<DB> getSizeType(
const %1% <T0, T1> & container,
typename TypeHandler<DB, %1% <T0, T1>>::type returnArg) {
auto tail = returnArg.write((uintptr_t)&container)
.write(container.size());
// The double ampersand is needed otherwise this loop doesn't work with
// vector<bool>
for (auto&& it : container) {
tail = tail.delegate([&it](auto ret) {
return OIInternal::getSizeType<DB>(it, ret);
});
}
return tail.finish();
}
};
"""