object-introspection/types/string_type.toml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
1012 B
TOML
Raw Normal View History

2022-12-19 14:37:51 +00:00
[info]
type_name = "std::basic_string"
stub_template_params = [2]
2022-12-19 14:37:51 +00:00
ctype = "STRING_TYPE"
header = "string"
# Old:
typeName = "std::basic_string<"
2022-12-19 14:37:51 +00:00
ns = ["namespace std"]
numTemplateParams = 1
2022-12-19 14:37:51 +00:00
replaceTemplateParamIndex = []
[codegen]
decl = """
template<typename T, typename Traits, typename Allocator>
void getSizeType(const %1%<T, Traits, Allocator> &container, size_t& returnArg);
2022-12-19 14:37:51 +00:00
"""
func = """
template<typename T, typename Traits, typename Allocator>
void getSizeType(const %1%<T, Traits, Allocator> &container, size_t& returnArg)
2022-12-19 14:37:51 +00:00
{
SAVE_SIZE(sizeof(%1%<T>));
SAVE_DATA((uintptr_t)container.capacity());
SAVE_DATA((uintptr_t)container.size());
2022-12-19 14:37:51 +00:00
// 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>)))
2022-12-19 14:37:51 +00:00
&&
((uintptr_t)container.data() >= (uintptr_t)&container)
? 0 : (container.capacity() * sizeof(T))
2022-12-19 14:37:51 +00:00
);
}
"""