mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-09-19 19:19:05 +01:00
77 lines
2.2 KiB
TOML
77 lines
2.2 KiB
TOML
[info]
|
|
type_name = "std::unordered_map"
|
|
stub_template_params = [2,3,4]
|
|
ctype = "STD_UNORDERED_MAP_TYPE"
|
|
header = "unordered_map"
|
|
|
|
# Old:
|
|
typeName = "std::unordered_map<"
|
|
ns = ["namespace std"]
|
|
numTemplateParams = 2
|
|
replaceTemplateParamIndex = [2, 3]
|
|
allocatorIndex = 4
|
|
|
|
[codegen]
|
|
decl = """
|
|
template<class K, class T, class H, class KE, class A>
|
|
void getSizeType(const %1%<K, T, H, KE, A> &container, size_t& returnArg);
|
|
"""
|
|
|
|
func = """
|
|
template<class K, class T, class H, class KE, class A>
|
|
void getSizeType(const %1%<K, T, H, KE, A> &container, size_t& returnArg)
|
|
{
|
|
constexpr size_t nodeSize = sizeof(typename %1%<K, T, H, KE, A>::node_type);
|
|
size_t bucketCount = container.bucket_count();
|
|
size_t numElems = container.size();
|
|
|
|
SAVE_SIZE(sizeof(%1%<K, T, H, KE, A>) + (nodeSize * numElems) + (bucketCount * sizeof(uintptr_t)));
|
|
|
|
SAVE_DATA((uintptr_t)nodeSize);
|
|
SAVE_DATA((uintptr_t)bucketCount);
|
|
SAVE_DATA((uintptr_t)numElems);
|
|
|
|
for (auto const& it : container)
|
|
{
|
|
getSizeType(it.first, returnArg);
|
|
getSizeType(it.second, returnArg);
|
|
}
|
|
}
|
|
"""
|
|
|
|
handler = """
|
|
template <typename DB, typename T0, typename T1, typename T2, typename T3, typename T4>
|
|
struct TypeHandler<DB, %1%<T0, T1, T2, T3, T4>> {
|
|
using type = types::st::Pair<DB,
|
|
types::st::VarInt<DB>,
|
|
types::st::Pair<DB,
|
|
types::st::VarInt<DB>,
|
|
types::st::List<DB, types::st::Pair<DB,
|
|
typename TypeHandler<DB, T0>::type,
|
|
typename TypeHandler<DB, T1>::type
|
|
>>>>;
|
|
|
|
static types::st::Unit<DB> getSizeType(
|
|
const %1%<T0, T1, T2, T3, T4>& container,
|
|
typename TypeHandler<DB, %1%<T0, T1, T2, T3, T4>>::type returnArg) {
|
|
constexpr size_t nodeSize = sizeof(typename %1%<T0, T1, T2, T3, T4>::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 (const auto& it : container) {
|
|
tail = tail.delegate([&it](auto ret) {
|
|
return OIInternal::getSizeType<DB>(it.second, ret.delegate([&it](auto ret) {
|
|
return OIInternal::getSizeType<DB>(it.first, ret);
|
|
}));
|
|
});
|
|
}
|
|
|
|
return tail.finish();
|
|
}
|
|
};
|
|
"""
|