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
This commit is contained in:
Jake Hillion 2023-11-15 06:14:52 -08:00 committed by Jake Hillion
parent e9d8df0ca4
commit f9cb0115e1
35 changed files with 2 additions and 934 deletions

View File

@ -29,27 +29,6 @@ void getSizeType(const %1%<T,N> &container, size_t& returnArg)
}
"""
handler = """
template<typename DB, typename T0, long unsigned int N>
struct TypeHandler<DB, %1%<T0, N>> {
using type = types::st::List<DB, typename TypeHandler<DB, T0>::type>;
static types::st::Unit<DB> getSizeType(
const %1%<T0, N> &container,
typename TypeHandler<DB, %1%<T0,N>>::type returnArg) {
auto tail = returnArg.write(container.size());
for (auto & it: container) {
tail = tail.delegate([&it](auto ret) {
return TypeHandler<DB, T0>::getSizeType(it, ret);
});
}
return tail.finish();
}
};
"""
traversal_func = """
auto tail = returnArg.write(container.size());

View File

@ -36,24 +36,6 @@ void getSizeType(const %1%<T, Traits, Allocator> &container, size_t& returnArg)
}
"""
handler = """
template <typename DB, typename T0>
struct TypeHandler<DB, %1% <T0>> {
using type =
types::st::Pair<DB, types::st::VarInt<DB>, types::st::VarInt<DB>>;
static types::st::Unit<DB> getSizeType(
const %1% <T0> & container,
typename TypeHandler<DB, %1% <T0>>::type returnArg) {
bool sso = ((uintptr_t)container.data() <
(uintptr_t)(&container + sizeof(%1% <T0>))) &&
((uintptr_t)container.data() >= (uintptr_t)&container);
return returnArg.write(container.capacity()).write(container.size());
}
};
"""
extra = """
template <typename DB, typename CharT, typename Traits, typename Allocator>
class CaptureKeyHandler<DB, std::__cxx11::basic_string<CharT, Traits, Allocator>> {

View File

@ -33,28 +33,3 @@ void getSizeType(const %1%<T, Allocator> &container, size_t& 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 TypeHandler<DB, T0>::getSizeType(it, ret);
});
}
return tail.finish();
}
};
"""

View File

@ -36,40 +36,6 @@ void getSizeType(const %1%<Key, Mapped, Hasher, KeyEqual, Alloc> &container, siz
}
"""
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) {
size_t memorySize = container.getAllocatedMemorySize();
auto tail = returnArg
.write(memorySize)
.write(container.bucket_count())
.write(container.size());
for (auto &&entry: container) {
tail = tail.delegate([&key = entry.first, &value = entry.second](auto ret) {
auto next = ret.delegate([&key](typename TypeHandler<DB, T0>::type ret) {
return OIInternal::getSizeType<DB>(key, ret);
});
return OIInternal::getSizeType<DB>(value, next);
});
}
return tail.finish();
}
};
"""
traversal_func = """
auto tail = returnArg
.write((uintptr_t)container.getAllocatedMemorySize())

View File

@ -35,36 +35,6 @@ void getSizeType(const %1%<Key, Hasher, KeyEqual, Alloc> &container, size_t& ret
}
"""
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) {
size_t memorySize = container.getAllocatedMemorySize();
auto tail = returnArg
.write(memorySize)
.write(container.bucket_count())
.write(container.size());
for (auto &&entry: container) {
tail = tail.delegate([&entry](auto ret) {
return OIInternal::getSizeType<DB>(entry, ret);
});
}
return tail.finish();
}
};
"""
traversal_func = """
auto tail = returnArg
.write((uintptr_t)container.getAllocatedMemorySize())

View File

@ -36,40 +36,6 @@ void getSizeType(const %1%<Key, Mapped, Hasher, KeyEqual, Alloc> &container, siz
}
"""
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) {
size_t memorySize = container.getAllocatedMemorySize();
auto tail = returnArg
.write(memorySize)
.write(container.bucket_count())
.write(container.size());
for (auto &&entry: container) {
tail = tail.delegate([&key = entry.first, &value = entry.second](auto ret) {
auto next = ret.delegate([&key](typename TypeHandler<DB, T0>::type ret) {
return OIInternal::getSizeType<DB>(key, ret);
});
return OIInternal::getSizeType<DB>(value, next);
});
}
return tail.finish();
}
};
"""
traversal_func = """
auto tail = returnArg
.write((uintptr_t)container.getAllocatedMemorySize())

View File

@ -35,36 +35,6 @@ void getSizeType(const %1%<Key, Hasher, KeyEqual, Alloc> &container, size_t& ret
}
"""
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) {
size_t memorySize = container.getAllocatedMemorySize();
auto tail = returnArg
.write(memorySize)
.write(container.bucket_count())
.write(container.size());
for (auto &&entry: container) {
tail = tail.delegate([&entry](auto ret) {
return OIInternal::getSizeType<DB>(entry, ret);
});
}
return tail.finish();
}
};
"""
traversal_func = """
auto tail = returnArg
.write((uintptr_t)container.getAllocatedMemorySize())

View File

@ -36,40 +36,6 @@ void getSizeType(const %1%<Key, Mapped, Hasher, KeyEqual, Alloc> &container, siz
}
"""
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) {
size_t memorySize = container.getAllocatedMemorySize();
auto tail = returnArg
.write(memorySize)
.write(container.bucket_count())
.write(container.size());
for (auto &&entry: container) {
tail = tail.delegate([&key = entry.first, &value = entry.second](auto ret) {
auto next = ret.delegate([&key](typename TypeHandler<DB, T0>::type ret) {
return OIInternal::getSizeType<DB>(key, ret);
});
return OIInternal::getSizeType<DB>(value, next);
});
}
return tail.finish();
}
};
"""
traversal_func = """
auto tail = returnArg
.write((uintptr_t)container.getAllocatedMemorySize())

View File

@ -35,36 +35,6 @@ void getSizeType(const %1%<Key, Hasher, KeyEqual, Alloc> &container, size_t& ret
}
"""
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) {
size_t memorySize = container.getAllocatedMemorySize();
auto tail = returnArg
.write(memorySize)
.write(container.bucket_count())
.write(container.size());
for (auto &&entry: container) {
tail = tail.delegate([&entry](auto ret) {
return OIInternal::getSizeType<DB>(entry, ret);
});
}
return tail.finish();
}
};
"""
traversal_func = """
auto tail = returnArg
.write((uintptr_t)container.getAllocatedMemorySize())

View File

@ -36,40 +36,6 @@ void getSizeType(const %1%<Key, Mapped, Hasher, KeyEqual, Alloc> &container, siz
}
"""
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) {
size_t memorySize = container.getAllocatedMemorySize();
auto tail = returnArg
.write(memorySize)
.write(container.bucket_count())
.write(container.size());
for (auto &&entry: container) {
tail = tail.delegate([&key = entry.first, &value = entry.second](auto ret) {
auto next = ret.delegate([&key](typename TypeHandler<DB, T0>::type ret) {
return OIInternal::getSizeType<DB>(key, ret);
});
return OIInternal::getSizeType<DB>(value, next);
});
}
return tail.finish();
}
};
"""
traversal_func = """
auto tail = returnArg
.write((uintptr_t)container.getAllocatedMemorySize())

View File

@ -35,36 +35,6 @@ void getSizeType(const %1%<Key, Hasher, KeyEqual, Alloc> &container, size_t& ret
}
"""
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) {
size_t memorySize = container.getAllocatedMemorySize();
auto tail = returnArg
.write(memorySize)
.write(container.bucket_count())
.write(container.size());
for (auto &&entry: container) {
tail = tail.delegate([&entry](auto ret) {
return OIInternal::getSizeType<DB>(entry, ret);
});
}
return tail.finish();
}
};
"""
traversal_func = """
auto tail = returnArg
.write((uintptr_t)container.getAllocatedMemorySize())

View File

@ -38,38 +38,6 @@ void getSizeType(const %1%<E, T, A, Storage> &container, size_t& 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::Pair<DB,
types::st::VarInt<DB>,
types::st::VarInt<DB>
>>>;
static types::st::Unit<DB> getSizeType(
const %1%<T0, T1, T2, T3>& container,
typename TypeHandler<DB, %1%<T0, T1, T2, T3>>::type returnArg) {
auto last = returnArg.write((uintptr_t)container.data())
.write(container.capacity())
.write(container.size());
bool inlined = ((uintptr_t)container.data() < (uintptr_t)(&container + sizeof(%1%<T0, T1, T2, T3>)))
&&
((uintptr_t)container.data() >= (uintptr_t)&container);
if (!inlined && pointers.add((uintptr_t)container.data())) {
return last.write(1);
} else {
return last.write(0);
}
}
};
"""
traversal_func = """
// fbstring has inlining (SSO) and allocates large strings as
// reference counted strings. Reference counted strings have an

View File

@ -35,37 +35,6 @@ void getSizeType(const %1%<Key, Value, Compare, Allocator, GrowthPolicy, Contain
}
}
"""
handler = """
template <typename DB, typename T0, typename T1, typename T2, typename T3, typename T4, typename T5>
struct TypeHandler<DB, %1%<T0, T1, T2, T3, T4, T5>> {
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, T5>& container,
typename TypeHandler<DB, %1%<T0, T1, T2, T3, T4, T5>>::type returnArg) {
auto tail = returnArg.write((uintptr_t)&container)
.write(container.capacity())
.write(container.size());
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();
}
};
"""
traversal_func = '''
auto tail = returnArg.write((uintptr_t)&container)

View File

@ -33,34 +33,6 @@ void getSizeType(const %1%<Key,T,Compare,Allocator> &container, size_t& returnAr
}
"""
handler = """
template <typename DB, typename T0, typename T1, typename T2, typename T3>
struct TypeHandler<DB, %1%<T0, T1, T2, T3>> {
using type = 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>& container,
typename TypeHandler<DB, %1%<T0, T1, T2, T3>>::type returnArg) {
auto tail = returnArg.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.second, ret.delegate([&it](auto ret) {
return OIInternal::getSizeType<DB>(it.first, ret);
}));
});
}
return tail.finish();
}
};
"""
traversal_func = """
auto tail = returnArg
.write((uintptr_t)&container)

View File

@ -35,31 +35,6 @@ void getSizeType(const %1%<Key, Compare, Alloc> &container, size_t& returnArg)
}
"""
handler = """
template <typename DB, typename T0, typename T1, typename T2>
struct TypeHandler<DB, %1% <T0, T1, T2>> {
using type = types::st::List<DB, typename TypeHandler<DB, T0>::type>;
static types::st::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(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();
}
};
"""
traversal_func = """
auto tail = returnArg.write((uintptr_t)&container)
.write(container.size());

View File

@ -28,28 +28,6 @@ void getSizeType(const %1%<T>& container, size_t& returnArg) {
}
"""
handler = """
template <typename DB, typename T0>
struct TypeHandler<DB, %1%<T0>> {
using type = types::st::Sum<DB,
types::st::Unit<DB>,
typename TypeHandler<DB, T0>::type
>;
static types::st::Unit<DB> getSizeType(
const %1%<T0>& container,
typename TypeHandler<DB, %1%<T0>>::type returnArg) {
if (container) {
return returnArg.template delegate<1>([&container](auto ret) {
return OIInternal::getSizeType<DB>(*container, ret);
});
} else {
return returnArg.template delegate<0>(std::identity());
}
}
};
"""
traversal_func = """
if (container.has_value()) {
return returnArg.template delegate<1>([&container](auto ret) {

View File

@ -26,26 +26,6 @@ void getSizeType(const %1%<P,Q> &container, size_t& returnArg)
}
"""
handler = """
template <typename DB, typename T0, typename T1>
struct TypeHandler<DB, %1%<T0, T1>> {
using type = types::st::Pair<DB,
typename TypeHandler<DB, T0>::type,
typename TypeHandler<DB, T1>::type>;
static types::st::Unit<DB> getSizeType(
const %1%<T0, T1> & container,
typename TypeHandler<DB, %1%<T0, T1>>::type returnArg) {
return OIInternal::getSizeType<DB>(
container.second,
returnArg.delegate([&container](auto ret) {
return OIInternal::getSizeType<DB>(container.first, ret);
})
);
}
};
"""
traversal_func = """
return OIInternal::getSizeType<DB>(
container.second,

View File

@ -32,21 +32,3 @@ void getSizeType(const %1%<T, Container, Cmp> &containerAdapter, size_t& returnA
getSizeType(container, returnArg);
}
"""
handler = """
template <typename DB, typename T0, typename T1, typename T2>
struct TypeHandler<DB, %1%<T0, T1, T2>> {
using type = types::st::Pair<DB,
types::st::VarInt<DB>,
typename TypeHandler<DB, T1>::type>;
static types::st::Unit<DB> getSizeType(
const %1%<T0, T1, T2>& container,
typename TypeHandler<DB, %1%<T0, T1, T2>>::type returnArg) {
auto tail = returnArg.write((uintptr_t)&container);
const T1 &underlyingContainer = get_container(container);
return OIInternal::getSizeType<DB>(underlyingContainer, tail);
}
};
"""

View File

@ -32,20 +32,3 @@ void getSizeType(const %1%<T, Container> &containerAdapter, size_t& 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>,
typename TypeHandler<DB, T1>::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);
const T1 &underlyingContainer = get_container(container);
return OIInternal::getSizeType<DB>(underlyingContainer, tail);
}
};
"""

View File

@ -29,29 +29,3 @@ void getSizeType(const %1%<T> &ref, size_t& returnArg)
}
}
"""
handler = """
template <typename DB, typename T0>
struct TypeHandler<DB, %1%<T0>> {
using type = types::st::Pair<DB,
types::st::VarInt<DB>,
types::st::Sum<DB,
types::st::Unit<DB>,
typename TypeHandler<DB, T0>::type
>>;
static types::st::Unit<DB> getSizeType(
const %1%<T0>& container,
typename TypeHandler<DB, %1%<T0>>::type returnArg) {
auto r0 = returnArg.write((uintptr_t)&(container.get()));
if (pointers.add((uintptr_t)&container.get())) {
return r0.template delegate<1>([&container](auto ret) {
return OIInternal::getSizeType<DB>(container.get(), ret);
});
} else {
return r0.template delegate<0>(std::identity());
}
}
};
"""

View File

@ -35,35 +35,6 @@ void getSizeType(const %1%<T, Allocator> &container, size_t& 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::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.capacity())
.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();
}
};
"""
traversal_func = """
auto tail = returnArg.write((uintptr_t)&container)
.write(container.capacity())

View File

@ -36,34 +36,6 @@ void getSizeType(const %1%<Key, Compare, Alloc> &container, size_t& returnArg)
}
"""
handler = """
template <typename DB, typename T0, typename T1, typename T2>
struct TypeHandler<DB, %1% <T0, T1, T2>> {
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, 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();
}
};
"""
traversal_func = """
auto tail = returnArg.write((uintptr_t)&container)
.write(container.size());

View File

@ -34,38 +34,6 @@ void getSizeType(const %1%<T> &s_ptr, size_t& returnArg)
}
"""
handler = """
template <typename DB, typename T0>
struct TypeHandler<DB, %1%<T0>> {
using type = typename std::conditional<
std::is_void<T0>::value,
types::st::Unit<DB>,
types::st::Pair<DB,
types::st::VarInt<DB>,
types::st::Sum<DB,
types::st::Unit<DB>,
typename TypeHandler<DB, T0>::type
>>>::type;
static types::st::Unit<DB> getSizeType(
const %1%<T0>& container,
typename TypeHandler<DB, %1%<T0>>::type returnArg) {
if constexpr (!std::is_void<T0>::value) {
auto r0 = returnArg.write((uintptr_t)(container.get()));
if (container && pointers.add((uintptr_t)(container.get()))) {
return r0.template delegate<1>([&container](auto ret) {
return OIInternal::getSizeType<DB>(*(container.get()), ret);
});
} else {
return r0.template delegate<0>(std::identity());
}
} else {
return returnArg;
}
}
};
"""
traversal_func = """
auto tail = returnArg.write((uintptr_t)container.get());

View File

@ -42,33 +42,6 @@ void getSizeType(const %1%<V, N, P> &container, size_t& returnArg)
}
"""
handler = """
template <typename DB, typename T0, std::size_t N0, typename T1>
struct TypeHandler<DB, %1%<T0, N0, T1>> {
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, N0, T1> & container,
typename TypeHandler<DB, %1%<T0, N0, T1>>::type returnArg) {
auto tail = returnArg.write(N0)
.write(container.capacity())
.write(container.size());
for (auto& it : container) {
tail = tail.delegate([&it](auto ret) {
return OIInternal::getSizeType<DB>(it, ret);
});
}
return tail.finish();
}
};
"""
traversal_func = """
// If `container.data()` pointer is within the container struct,
// then the container's storage is inlined and doesn't uses the heap.

View File

@ -31,23 +31,6 @@ void getSizeType(const %1%<T,Compare, Allocator, GrowthPolicy, Container> &conta
}
"""
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>,
typename TypeHandler<DB, T4>::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) {
auto tail = returnArg.write((uintptr_t)&container);
const T4 &underlyingContainer = container.get_container();
return OIInternal::getSizeType<DB>(underlyingContainer, tail);
}
};
"""
traversal_func = '''
auto tail = returnArg.write((uintptr_t)&container)
.write(container.capacity())

View File

@ -31,21 +31,3 @@ void getSizeType(const %1%<T, Container> &containerAdapter, size_t& returnArg)
getSizeType(container, 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>,
typename TypeHandler<DB, T1>::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);
const T1 &underlyingContainer = get_container(container);
return OIInternal::getSizeType<DB>(underlyingContainer, tail);
}
};
"""

View File

@ -37,38 +37,6 @@ void getSizeType(const %1%<K, T, C, A> &container, size_t& 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::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>& 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.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();
}
};
"""
traversal_func = """
auto tail = returnArg
.write((uintptr_t)&container)

View File

@ -39,42 +39,6 @@ void getSizeType(const %1%<K, T, H, KE, A> &container, size_t& 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();
}
};
"""
traversal_func = """
auto tail = returnArg
.write((uintptr_t)&container)

View File

@ -39,42 +39,6 @@ void getSizeType(const %1%<K, T, H, KE, A> &container, size_t& 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();
}
};
"""
traversal_func = """
auto tail = returnArg
.write((uintptr_t)&container)

View File

@ -36,33 +36,5 @@ void getSizeType(const %1%<Types...> &container, size_t& returnArg)
}
"""
handler = """
template <typename DB, typename... Types>
struct TypeHandler<DB, %1%<Types...>> {
using type = types::st::Sum<DB, typename TypeHandler<DB, Types>::type..., types::st::Unit<DB>>;
static types::st::Unit<DB> getSizeType(
const %1%<Types...>& container,
typename TypeHandler<DB, %1%<Types...>>::type returnArg) {
return getSizeTypeRecursive(container, returnArg);
}
private:
template <size_t I = 0>
static types::st::Unit<DB> getSizeTypeRecursive(
const %1%<Types...>& container,
typename TypeHandler<DB, %1%<Types...>>::type returnArg) {
if constexpr (I < sizeof...(Types)) {
if (I == container.index()) {
return returnArg.template delegate<I>([&container](auto ret) {
return OIInternal::getSizeType<DB>(std::get<I>(container), ret);
});
} else {
return getSizeTypeRecursive<I+1>(container, returnArg);
}
} else {
return returnArg.template delegate<sizeof...(Types)>(std::identity());
}
}
};
"""
# TODO: Add tbv2 definitions. The removed intermediate handler is a good
# template for this, find it in the git logs.

View File

@ -17,9 +17,6 @@ decl = """
func = """
// DummyFunc %1%
"""
handler = """
// DummyHandler %1%
"""
traversal_func = """
return returnArg;

View File

@ -35,38 +35,6 @@ void getSizeType(const %1%<T,Deleter> &u_ptr, size_t& returnArg)
}
"""
handler = """
template <typename DB, typename T0, typename T1>
struct TypeHandler<DB, %1%<T0,T1>> {
using type = typename std::conditional<
std::is_void<T0>::value,
types::st::Unit<DB>,
types::st::Pair<DB,
types::st::VarInt<DB>,
types::st::Sum<DB,
types::st::Unit<DB>,
typename TypeHandler<DB, T0>::type
>>>::type;
static types::st::Unit<DB> getSizeType(
const %1%<T0,T1>& container,
typename TypeHandler<DB, %1%<T0,T1>>::type returnArg) {
if constexpr (!std::is_void<T0>::value) {
auto r0 = returnArg.write((uintptr_t)(container.get()));
if (container && pointers.add((uintptr_t)(container.get()))) {
return r0.template delegate<1>([&container](auto ret) {
return OIInternal::getSizeType<DB>(*(container.get()), ret);
});
} else {
return r0.template delegate<0>(std::identity());
}
} else {
return returnArg;
}
}
};
"""
traversal_func = """
auto tail = returnArg.write((uintptr_t)container.get());

View File

@ -37,37 +37,6 @@ void getSizeType(const %1%<Key, Hasher, KeyEqual, Alloc> &container, size_t& ret
}
"""
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();
}
};
"""
traversal_func = """
auto tail = returnArg
.write((uintptr_t)&container)

View File

@ -37,37 +37,6 @@ void getSizeType(const %1%<Key, Hasher, KeyEqual, Alloc> &container, size_t& ret
}
"""
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();
}
};
"""
traversal_func = """
auto tail = returnArg
.write((uintptr_t)&container)

View File

@ -24,18 +24,5 @@ void getSizeType(const %1%<T> &s_ptr, size_t& returnArg)
}
"""
handler = """
template <typename DB, typename T0>
struct TypeHandler<DB, %1%<T0>> {
using type = types::st::Unit<DB>;
static types::st::Unit<DB> getSizeType(
const %1%<T0>& container,
typename TypeHandler<DB, %1%<T0>>::type returnArg) {
return returnArg;
}
};
"""
traversal_func = "return returnArg;"