mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-09-19 19:19:05 +01:00
70 lines
2.2 KiB
TOML
70 lines
2.2 KiB
TOML
[info]
|
|
type_name = "std::unordered_set"
|
|
stub_template_params = [1,2,3]
|
|
ctype = "UNORDERED_SET_TYPE"
|
|
header = "unordered_set"
|
|
|
|
# Old:
|
|
typeName = "std::unordered_set<"
|
|
ns = ["namespace std"]
|
|
numTemplateParams = 1
|
|
replaceTemplateParamIndex = [1, 2]
|
|
allocatorIndex = 3
|
|
|
|
[codegen]
|
|
decl = """
|
|
template <typename Key, typename Hasher, typename KeyEqual, typename Alloc>
|
|
void getSizeType(const %1%<Key, Hasher, KeyEqual, Alloc> &container, size_t& returnArg);
|
|
"""
|
|
|
|
func = """
|
|
template <typename Key, typename Hasher, typename KeyEqual, typename Alloc>
|
|
void getSizeType(const %1%<Key, Hasher, KeyEqual, Alloc> &container, size_t& returnArg)
|
|
{
|
|
constexpr size_t nodeSize = sizeof(typename %1%<Key, Hasher, KeyEqual, Alloc>::node_type);
|
|
size_t bucketCount = container.bucket_count();
|
|
size_t numElems = container.size();
|
|
SAVE_SIZE(sizeof(%1%<Key, Hasher, KeyEqual, Alloc>) + (numElems * nodeSize) + (bucketCount * sizeof(uintptr_t)));
|
|
|
|
SAVE_DATA((uintptr_t)nodeSize);
|
|
SAVE_DATA((uintptr_t)bucketCount);
|
|
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, typename T3>
|
|
struct TypeHandler<DB, %1%<T0, T1, T2, T3>> {
|
|
using type = types::st::Pair<
|
|
DB, types::st::VarInt<DB>,
|
|
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, T2, T3>& container,
|
|
typename TypeHandler<DB, %1%<T0, T1, T2, T3>>::type returnArg) {
|
|
constexpr size_t nodeSize = sizeof(typename %1%<T0, T1, T2, T3>::node_type);
|
|
|
|
auto tail = returnArg.write(nodeSize)
|
|
.write(container.bucket_count())
|
|
.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();
|
|
}
|
|
};
|
|
"""
|