object-introspection/types/set_type.toml

66 lines
1.8 KiB
TOML

[info]
type_name = "std::set"
stub_template_params = [1,2]
ctype = "SET_TYPE"
header = "set"
# Old:
typeName = "std::set<"
ns = ["namespace std"]
numTemplateParams = 1
replaceTemplateParamIndex = [1]
allocatorIndex = 2
[codegen]
decl = """
template<typename Key, typename Compare, typename Alloc>
void getSizeType(const %1%<Key, Compare, Alloc> &container, size_t& returnArg);
"""
func = """
template<typename Key, typename Compare, typename Alloc>
void getSizeType(const %1%<Key, Compare, Alloc> &container, size_t& returnArg)
{
constexpr size_t nodeSize = sizeof(typename %1%<Key, Compare, Alloc>::node_type);
size_t numElems = container.size();
SAVE_SIZE(sizeof(%1%<Key, Compare, Alloc>) + (nodeSize * numElems));
SAVE_DATA((uintptr_t)nodeSize);
SAVE_DATA((uintptr_t)numElems);
// 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, typename T2>
struct TypeHandler<DB, %1% <T0, T1, T2>> {
using type = StaticTypes::Pair<DB,
StaticTypes::VarInt<DB>,
StaticTypes::List<DB, typename TypeHandler<DB, T0>::type>>;
static StaticTypes::Unit<DB> getSizeType(
const %1%<T0, T1, T2>& container,
typename TypeHandler<DB, %1%<T0, T1, T2>>::type returnArg) {
constexpr size_t nodeSize = sizeof(typename %1%<T0, T1, T2>::node_type);
auto tail = returnArg.write(nodeSize)
.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();
}
};
"""