mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
cc401c1e5b
* fix string type sso computation * fix rest of sbo/sso calculation * make placement of uintptr_t cast consistent * separate check-inline into function
64 lines
1.6 KiB
TOML
64 lines
1.6 KiB
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(
|
|
isStorageInline(container) ? 0 : (container.capacity() * sizeof(T))
|
|
);
|
|
}
|
|
"""
|
|
|
|
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;
|
|
"""
|