diff --git a/src/TreeBuilder.cpp b/src/TreeBuilder.cpp index 12fdcfe..e704fc9 100644 --- a/src/TreeBuilder.cpp +++ b/src/TreeBuilder.cpp @@ -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: diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index 1ec1d8d..a5a6bfc 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -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 diff --git a/test/integration/sorted_vector_set.toml b/test/integration/sorted_vector_set.toml new file mode 100644 index 0000000..0260c8d --- /dev/null +++ b/test/integration/sorted_vector_set.toml @@ -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&"] + 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&"] + setup = ''' + sorted_vector_set 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 + }]}] + ''' diff --git a/types/sorted_vec_set_type.toml b/types/sorted_vec_set_type.toml index e30f03d..2f013ac 100644 --- a/types/sorted_vec_set_type.toml +++ b/types/sorted_vec_set_type.toml @@ -14,19 +14,14 @@ void getSizeType(const %1% &conta func = """ template -void getSizeType(const %1% &container, size_t& returnArg) +void getSizeType(const %1% &containerAdapter, size_t& returnArg) { - SAVE_SIZE(sizeof(%1%)); + 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%) - sizeof(Container)); - SAVE_SIZE((container.capacity() - container.size()) * sizeof(T)); - - // The double ampersand is needed otherwise this loop doesn't work with vector - for (auto&& it: container) { - getSizeType(it, returnArg); - } + const Container &container = containerAdapter.get_container(); + getSizeType(container, returnArg); } """