sorted_vec_set: finish changing to a container adapter

This commit is contained in:
Jake Hillion 2023-02-23 15:32:37 -08:00 committed by Jake Hillion
parent b1c43c2b42
commit 3a236aa4f2
4 changed files with 55 additions and 12 deletions

View File

@ -607,6 +607,7 @@ void TreeBuilder::processContainer(const Variable &variable, Node &node) {
return;
}
break;
case SORTED_VEC_SET_TYPE:
case CONTAINER_ADAPTER_TYPE: {
node.pointer = next();
@ -673,7 +674,6 @@ void TreeBuilder::processContainer(const Variable &variable, Node &node) {
break;
case SEQ_TYPE:
case MICROLIST_TYPE:
case SORTED_VEC_SET_TYPE:
case FEED_QUICK_HASH_SET:
case FEED_QUICK_HASH_MAP:
case FB_HASH_MAP_TYPE:

View File

@ -18,6 +18,7 @@ set(INTEGRATION_TEST_CONFIGS
primitives.toml
references.toml
simple_struct.toml
sorted_vector_set.toml
std_array.toml
std_conditional.toml
std_deque_del_allocator.toml

View File

@ -0,0 +1,47 @@
includes = ["folly/sorted_vector_types.h"]
definitions = '''
using folly::sorted_vector_set;
'''
[cases]
[cases.no_ints]
param_types = ["const sorted_vector_set<int>&"]
setup = "return {};"
expect_json = '''[{
"staticSize":24,
"dynamicSize":0,
"length":0,
"capacity":0,
"elementStaticSize":4,
"members":[{
"staticSize": 24,
"dynamicSize": 0,
"length": 0,
"capacity": 0,
"elementStaticSize": 4
}]}]'''
[cases.some_ints]
param_types = ["const sorted_vector_set<int>&"]
setup = '''
sorted_vector_set<int> is;
is.insert(1);
is.insert(3);
is.insert(2);
is.insert(3);
return is;
'''
expect_json = '''[{
"staticSize": 24,
"dynamicSize": 16,
"length":3,
"capacity":4,
"elementStaticSize":4,
"members": [{
"staticSize": 24,
"dynamicSize": 16,
"length": 3,
"capacity": 4,
"elementStaticSize": 4
}]}]
'''

View File

@ -14,19 +14,14 @@ void getSizeType(const %1%<T,Compare, Allocator, GrowthPolicy, Container> &conta
func = """
template <class T, class Compare, class Allocator, class GrowthPolicy, class Container>
void getSizeType(const %1%<T,Compare, Allocator, GrowthPolicy, Container> &container, size_t& returnArg)
void getSizeType(const %1%<T,Compare, Allocator, GrowthPolicy, Container> &containerAdapter, size_t& returnArg)
{
SAVE_SIZE(sizeof(%1%<T,Compare, Allocator, GrowthPolicy, Container>));
SAVE_DATA((uintptr_t)&containerAdapter);
SAVE_DATA((uintptr_t)&container);
SAVE_DATA((uintptr_t)container.capacity());
SAVE_DATA((uintptr_t)container.size());
// Underlying container is grabbed by recursion, store only the exclusive size.
SAVE_SIZE(sizeof(%1%<T,Compare, Allocator, GrowthPolicy, Container>) - sizeof(Container));
SAVE_SIZE((container.capacity() - container.size()) * sizeof(T));
// The double ampersand is needed otherwise this loop doesn't work with vector<bool>
for (auto&& it: container) {
getSizeType(it, returnArg);
}
const Container &container = containerAdapter.get_container();
getSizeType(container, returnArg);
}
"""