object-introspection/types/string_type.toml

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

69 lines
1.9 KiB
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
);
}
"""
traversal_func = """
bool sso = ((uintptr_t)container.data() <
(uintptr_t)(&container + sizeof(std::__cxx11::basic_string<T0>))) &&
((uintptr_t)container.data() >= (uintptr_t)&container);
return returnArg.write(container.capacity())
.write(sso)
.write(container.size());
"""
[[codegen.processor]]
type = "types::st::VarInt<DB>"
func = """
uint64_t capacity = std::get<ParsedData::VarInt>(d.val).value;
el.container_stats.emplace(result::Element::ContainerStats { .capacity = capacity });
"""
[[codegen.processor]]
type = "types::st::VarInt<DB>"
func = """
bool sso = std::get<ParsedData::VarInt>(d.val).value;
if (!sso)
el.exclusive_size += el.container_stats->capacity * sizeof(T0);
"""
[[codegen.processor]]
type = "types::st::VarInt<DB>"
func = """
el.container_stats->length = std::get<ParsedData::VarInt>(d.val).value;
"""