object-introspection/types/sorted_vec_set_type.toml

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

71 lines
2.1 KiB
TOML
Raw Permalink Normal View History

2022-12-19 14:37:51 +00:00
[info]
type_name = "folly::sorted_vector_set"
2022-12-19 14:37:51 +00:00
header = "folly/sorted_vector_types.h"
2023-08-16 20:40:36 +01:00
ctype = "SORTED_VEC_SET_TYPE"
stub_template_params = [1,2]
underlying_container_index = 4
# Old
typeName = "folly::sorted_vector_set<"
2022-12-19 14:37:51 +00:00
ns = ["namespace std", "folly::sorted_vector_set"]
replaceTemplateParamIndex = [1,2]
underlyingContainerIndex = 4
2022-12-19 14:37:51 +00:00
[codegen]
decl = """
template <class T, class Compare, class Allocator, class GrowthPolicy, class Container>
void getSizeType(const %1%<T,Compare, Allocator, GrowthPolicy, Container> &container, size_t& returnArg);
"""
func = """
template <class T, class Compare, class Allocator, class GrowthPolicy, class Container>
void getSizeType(const %1%<T,Compare, Allocator, GrowthPolicy, Container> &containerAdapter, size_t& returnArg)
2022-12-19 14:37:51 +00:00
{
SAVE_DATA((uintptr_t)&containerAdapter);
2022-12-19 14:37:51 +00:00
// Underlying container is grabbed by recursion, store only the exclusive size.
SAVE_SIZE(sizeof(%1%<T,Compare, Allocator, GrowthPolicy, Container>) - sizeof(Container));
2022-12-19 14:37:51 +00:00
const Container &container = containerAdapter.get_container();
getSizeType(container, returnArg);
2022-12-19 14:37:51 +00:00
}
"""
traversal_func = '''
auto tail = returnArg.write((uintptr_t)&container)
.write(container.capacity())
.write(container.size());
for (const auto& el : container) {
tail = tail.delegate([&ctx, &el](auto ret) {
return OIInternal::getSizeType<Ctx>(ctx, el, ret);
});
}
return tail.finish();
'''
[[codegen.processor]]
type = "types::st::VarInt<DB>"
func = "el.pointer = std::get<ParsedData::VarInt>(d.val).value;"
[[codegen.processor]]
type = "types::st::VarInt<DB>"
func = '''
el.container_stats.emplace(result::Element::ContainerStats{ .capacity = std::get<ParsedData::VarInt>(d.val).value });
'''
[[codegen.processor]]
tbv2: replace DB template param with Ctx (#409) Summary: tbv2: replace DB template param with Ctx TreeBuilder v2 adds a DB template parameter to every function. This is used as part of the static type to decide what type of DataBuffer is being used: currently `BackInserterDataBuffer<std::vector<uint8_t>>` for OIL and it would be `DataSegmentDataBuffer` for OID. This change replaces the `DB` template parameter with a more general `Ctx`. Due to issues with dependent naming it also adds a `using DB` to each `TypeHandler` which has the same function as before. This allows us to add more "static context" (typedefs and constants) to functions without changing this signature again, because changing the signature of everything is a massive pain. Currently this change achieves nothing because Ctx contains only DB in a static wrapper. In the next change I'm going to pass a reference of type Ctx around to add a "dynamic context" to invocations which will contain the pointer array. In future we'll then be able to add either static or dynamic context without any signature adjustments. Test Plan: - CI --- Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebookexperimental/object-introspection/pull/409). * https://github.com/facebookexperimental/object-introspection/issues/410 * __->__ https://github.com/facebookexperimental/object-introspection/issues/409 Reviewed By: ajor Differential Revision: D51352092 Pulled By: JakeHillion
2023-11-15 19:28:21 +00:00
type = "types::st::List<DB, typename TypeHandler<Ctx, T0>::type>"
func = """
tbv2: replace DB template param with Ctx (#409) Summary: tbv2: replace DB template param with Ctx TreeBuilder v2 adds a DB template parameter to every function. This is used as part of the static type to decide what type of DataBuffer is being used: currently `BackInserterDataBuffer<std::vector<uint8_t>>` for OIL and it would be `DataSegmentDataBuffer` for OID. This change replaces the `DB` template parameter with a more general `Ctx`. Due to issues with dependent naming it also adds a `using DB` to each `TypeHandler` which has the same function as before. This allows us to add more "static context" (typedefs and constants) to functions without changing this signature again, because changing the signature of everything is a massive pain. Currently this change achieves nothing because Ctx contains only DB in a static wrapper. In the next change I'm going to pass a reference of type Ctx around to add a "dynamic context" to invocations which will contain the pointer array. In future we'll then be able to add either static or dynamic context without any signature adjustments. Test Plan: - CI --- Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebookexperimental/object-introspection/pull/409). * https://github.com/facebookexperimental/object-introspection/issues/410 * __->__ https://github.com/facebookexperimental/object-introspection/issues/409 Reviewed By: ajor Differential Revision: D51352092 Pulled By: JakeHillion
2023-11-15 19:28:21 +00:00
static constexpr auto childField = make_field<Ctx, T0>("[]");
auto list = std::get<ParsedData::List>(d.val);
el.container_stats->length = list.length;
el.exclusive_size += (el.container_stats->capacity - el.container_stats->length) * sizeof(T0);
for (size_t i = 0; i < list.length; i++)
stack_ins(childField);
"""