object-introspection/types/folly_iobuf_type.toml

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

73 lines
2.1 KiB
TOML
Raw Permalink Normal View History

2022-12-19 14:37:51 +00:00
[info]
type_name = "folly::IOBuf"
2022-12-19 14:37:51 +00:00
ctype = "FOLLY_IOBUF_TYPE"
header = "folly/io/IOBuf.h"
# Old:
typeName = "folly::IOBuf"
matcher = "^folly::IOBuf$"
2022-12-19 14:37:51 +00:00
ns = ["folly::IOBuf"]
numTemplateParams = 0
2022-12-19 14:37:51 +00:00
replaceTemplateParamIndex = []
[codegen]
decl = """
void getSizeType(const %1% &container, size_t& returnArg);
2022-12-19 14:37:51 +00:00
"""
func = """
void getSizeType(const %1% &container, size_t& returnArg)
2022-12-19 14:37:51 +00:00
{
SAVE_SIZE(sizeof(%1%));
// We calculate the length of all IOBufs in the chain manually.
// IOBuf has built-in computeChainCapacity()/computeChainLength()
// functions which do this for us. But dead code optimization in TAO
// caused these functions to be removed which causes relocation
// errors.
std::size_t fullLength = container.length();
std::size_t fullCapacity = container.capacity();
for (const folly::IOBuf* current = container.next(); current != &container;
2022-12-19 14:37:51 +00:00
current = current->next()) {
fullLength += current->length();
fullCapacity += current->capacity();
}
SAVE_DATA(fullCapacity);
SAVE_DATA(fullLength);
SAVE_SIZE(fullCapacity);
}
"""
traversal_func = """
// We calculate the length of all IOBufs in the chain manually.
// IOBuf has built-in computeChainCapacity()/computeChainLength()
// functions which do this for us. But dead code optimization in TAO
// caused these functions to be removed which causes relocation
// errors.
std::size_t fullLength = container.length();
std::size_t fullCapacity = container.capacity();
for (const folly::IOBuf* current = container.next(); current != &container;
current = current->next()) {
fullLength += current->length();
fullCapacity += current->capacity();
}
return returnArg.write(fullCapacity).write(fullLength);
"""
[[codegen.processor]]
type = "types::st::VarInt<DB>"
func = """
el.container_stats.emplace(result::Element::ContainerStats{ .capacity = std::get<ParsedData::VarInt>(d.val).value });
el.exclusive_size += el.container_stats->capacity;
"""
[[codegen.processor]]
type = "types::st::VarInt<DB>"
func = """
el.container_stats->length = std::get<ParsedData::VarInt>(d.val).value;
"""