object-introspection/types/string_type.toml
Alastair Robertson 784b900218 TypeGraph: Replace allocators with DummyAllocator
When we were previously removing allocators, we were only able to work
with containers whose allocators appeared as their last template
parameter.

Now we can replace allocators in the middle of a parameter list.

This fixes tests for folly::sorted_vector_set.
2023-05-31 15:49:37 +01:00

38 lines
1012 B
TOML

[info]
type_name = "std::basic_string"
stub_template_params = [2]
ctype = "STRING_TYPE"
header = "string"
# Old:
typeName = "std::basic_string<"
ns = ["namespace std"]
numTemplateParams = 1
replaceTemplateParamIndex = []
[codegen]
decl = """
template<typename T, typename Traits, typename Allocator>
void getSizeType(const %1%<T, Traits, Allocator> &container, size_t& returnArg);
"""
func = """
template<typename T, typename Traits, typename Allocator>
void getSizeType(const %1%<T, Traits, Allocator> &container, size_t& returnArg)
{
SAVE_SIZE(sizeof(%1%<T>));
SAVE_DATA((uintptr_t)container.capacity());
SAVE_DATA((uintptr_t)container.size());
// Test for small string optimisation - whether the underlying string is
// contained within the string object.
SAVE_SIZE(
((uintptr_t)container.data() < (uintptr_t)(&container + sizeof(%1%<T>)))
&&
((uintptr_t)container.data() >= (uintptr_t)&container)
? 0 : (container.capacity() * sizeof(T))
);
}
"""