object-introspection/types/seq_type.toml
2022-12-19 06:37:51 -08:00

35 lines
801 B
TOML

[info]
typeName = "std::vector<"
numTemplateParams = 1
ctype = "SEQ_TYPE"
header = "vector"
ns = ["namespace std"]
replaceTemplateParamIndex = []
allocatorIndex = 1
# underlyingContainerIndex = 0
[codegen]
decl = """
template<typename T>
void getSizeType(const %1%<T> &container, size_t& returnArg);
"""
func = """
template<typename T>
void getSizeType(const %1%<T> &container, size_t& returnArg)
{
SAVE_SIZE(sizeof(%1%<T>));
SAVE_DATA((uintptr_t)&container);
SAVE_DATA((uintptr_t)container.capacity());
SAVE_DATA((uintptr_t)container.size());
SAVE_SIZE((container.capacity() - container.size()) * sizeof(T));
// The double ampersand is needed otherwise this loop doesn't work with vector<bool>
for (auto&& it: container) {
getSizeType(it, returnArg);
}
}
"""