object-introspection/types/string_type.toml

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

64 lines
1.6 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(
isStorageInline(container) ? 0 : (container.capacity() * sizeof(T))
2022-12-19 14:37:51 +00:00
);
}
"""
traversal_func = """
bool sso = isStorageInline(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;
"""