mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
52 lines
1.2 KiB
TOML
52 lines
1.2 KiB
TOML
[info]
|
|
type_name = "std::array"
|
|
ctype = "ARRAY_TYPE"
|
|
header = "array"
|
|
|
|
# Old:
|
|
numTemplateParams = 1
|
|
ns = ["namespace std"]
|
|
typeName = "std::array<"
|
|
|
|
[codegen]
|
|
decl = """
|
|
template<typename T, long unsigned int N>
|
|
void getSizeType(const %1%<T, N> &container, size_t& returnArg);
|
|
"""
|
|
|
|
func = """
|
|
template<typename T, long unsigned int N>
|
|
void getSizeType(const %1%<T,N> &container, size_t& returnArg)
|
|
{
|
|
SAVE_DATA((uintptr_t)container.size());
|
|
SAVE_SIZE(sizeof(container));
|
|
|
|
for (auto & it: container) {
|
|
// undo the static size that has already been added per-element
|
|
SAVE_SIZE(-sizeof(it));
|
|
getSizeType(it, 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();
|
|
}
|
|
};
|
|
"""
|