diff --git a/include/oi/exporters/Json.h b/include/oi/exporters/Json.h index 31aa808..dd88ade 100644 --- a/include/oi/exporters/Json.h +++ b/include/oi/exporters/Json.h @@ -17,8 +17,10 @@ #define INCLUDED_OI_EXPORTERS_JSON_H 1 #include +#include #include +#include namespace oi::exporters { @@ -26,19 +28,173 @@ class Json { public: Json(std::ostream& out); - void print(const IntrospectionResult&); - void print(IntrospectionResult::const_iterator& it, - IntrospectionResult::const_iterator& end); + template + void print(const Res& r) { + auto begin = r.begin(); + auto end = r.end(); + return print(begin, end); + } + template + void print(It& it, const It& end); void setPretty(bool pretty) { pretty_ = pretty; } private: + std::string_view tab() const; + std::string_view space() const; + std::string_view endl() const; + static std::string makeIndent(size_t depth); + + void printStringField(std::string_view name, + std::string_view value, + std::string_view indent); + void printBoolField(std::string_view name, + bool value, + std::string_view indent); + void printUnsignedField(std::string_view name, + uint64_t value, + std::string_view indent); + void printPointerField(std::string_view name, + uintptr_t value, + std::string_view indent); + template + void printListField(std::string_view name, + const Rng& range, + std::string_view indent); + + void printFields(const result::Element&, std::string_view indent); + template + void printFields(const result::SizedElement&, std::string_view indent); + bool pretty_ = false; std::ostream& out_; }; +inline Json::Json(std::ostream& out) : out_(out) { +} + +inline std::string_view Json::tab() const { + return pretty_ ? " " : ""; +} +inline std::string_view Json::space() const { + return pretty_ ? " " : ""; +} +inline std::string_view Json::endl() const { + return pretty_ ? "\n" : ""; +} +inline std::string Json::makeIndent(size_t depth) { + depth = std::max(depth, 1UL); + return std::string((depth - 1) * 4, ' '); +} + +inline void Json::printStringField(std::string_view name, + std::string_view value, + std::string_view indent) { + out_ << tab() << '"' << name << '"' << ':' << space() << "\"" << value + << "\"," << endl() << indent; +} +inline void Json::printBoolField(std::string_view name, + bool value, + std::string_view indent) { + out_ << tab() << '"' << name << "\":" << space() << value << ',' << endl() + << indent; +} +inline void Json::printUnsignedField(std::string_view name, + uint64_t value, + std::string_view indent) { + out_ << tab() << '"' << name << "\":" << space() << value << ',' << endl() + << indent; +} +inline void Json::printPointerField(std::string_view name, + uintptr_t value, + std::string_view indent) { + out_ << tab() << '"' << name << "\":" << space() << "\"0x" << std::hex + << value << std::dec << "\"," << endl() << indent; +} +template +void Json::printListField(std::string_view name, + const Rng& range, + std::string_view indent) { + out_ << tab() << '"' << name << '"' << ':' << space() << '['; + bool first = true; + for (const auto& el : range) { + if (!std::exchange(first, false)) + out_ << ',' << space(); + out_ << '"' << el << '"'; + } + out_ << "]," << endl() << indent; +} + +template +void Json::printFields(const result::SizedElement& el, + std::string_view indent) { + printUnsignedField("size", el.size, indent); + + printFields(el.inner(), indent); +} + +inline void Json::printFields(const result::Element& el, + std::string_view indent) { + printStringField("name", el.name, indent); + printListField("typePath", el.type_path, indent); + printListField("typeNames", el.type_names, indent); + printUnsignedField("staticSize", el.static_size, indent); + printUnsignedField("exclusiveSize", el.exclusive_size, indent); + if (el.pointer.has_value()) + printUnsignedField("pointer", *el.pointer, indent); + + if (const auto* s = std::get_if(&el.data)) { + printUnsignedField("data", s->n, indent); + } else if (const auto* p = std::get_if(&el.data)) { + printPointerField("data", p->p, indent); + } else if (const auto* str = std::get_if(&el.data)) { + printStringField("data", *str, indent); + } + + if (el.container_stats.has_value()) { + printUnsignedField("length", el.container_stats->length, indent); + printUnsignedField("capacity", el.container_stats->capacity, indent); + } + if (el.is_set_stats.has_value()) + printUnsignedField("is_set", el.is_set_stats->is_set, indent); +} + +template +void Json::print(It& it, const It& end) { + const auto depth = it->type_path.size(); + + const auto thisIndent = pretty_ ? makeIndent(depth) : ""; + const auto lastIndent = pretty_ ? makeIndent(depth - 1) : ""; + + out_ << '[' << endl() << thisIndent; + + bool first = true; + while (it != end && it->type_path.size() >= depth) { + if (!std::exchange(first, false)) + out_ << ',' << endl() << thisIndent; + + out_ << '{' << endl() << thisIndent; + + printFields(*it, thisIndent); + + out_ << tab() << "\"members\":" << space(); + if (++it != end && it->type_path.size() > depth) { + print(it, end); + } else { + out_ << "[]" << endl(); + } + + out_ << thisIndent << "}"; + } + if (depth == 1) { + out_ << endl() << ']' << endl(); + } else { + out_ << endl() << lastIndent << tab() << ']' << endl(); + } +} + } // namespace oi::exporters #endif diff --git a/include/oi/result/SizedResult-inl.h b/include/oi/result/SizedResult-inl.h new file mode 100644 index 0000000..f86ff0c --- /dev/null +++ b/include/oi/result/SizedResult-inl.h @@ -0,0 +1,144 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#if defined(INCLUDED_OI_RESULT_SIZED_ELEMENT_INL_H) || \ + !defined(INCLUDED_OI_RESULT_SIZED_ELEMENT_H) +static_assert(false, + "SizedResult-inl.h provides inline declarations for " + "SizedResult.h and should only " + "be included by SizedResult.h"); +#endif +#define INCLUDED_OI_RESULT_SIZED_ELEMENT_INL_H 1 + +#include +#include + +#include "SizedResult.h" + +namespace oi::result { + +template +SizedResult::SizedResult(Res res) : res_{std::move(res)} { +} + +template +typename SizedResult::const_iterator SizedResult::begin() const { + return ++const_iterator{res_.begin(), res_.end()}; +} +template +typename SizedResult::const_iterator SizedResult::end() const { + return res_.end(); +} + +template +SizedResult::const_iterator::const_iterator(It it, const It& end) + : data_{it} { + struct StackEntry { + size_t index; + size_t depth; + }; + std::vector stack; + + size_t size = 0; + size_t count = -1; + for (; it != end; ++it) { + ++count; + + auto depth = it->type_path.size(); + while (!stack.empty() && stack.back().depth >= depth) { + auto i = stack.back().index; + stack.pop_back(); + helpers_[i].last_child = count - 1; + } + + size += it->exclusive_size; + helpers_.emplace_back(SizeHelper{.size = size}); + stack.emplace_back(StackEntry{.index = count, .depth = depth}); + } + while (!stack.empty()) { + auto i = stack.back().index; + stack.pop_back(); + helpers_[i].last_child = count; + } +} + +template +SizedResult::const_iterator::const_iterator(It end) : data_{end} { +} + +template +typename SizedResult::const_iterator +SizedResult::const_iterator::operator++(int) { + auto old = *this; + operator++(); + return old; +} + +template +typename SizedResult::const_iterator& +SizedResult::const_iterator::operator++() { + // The below iterator is already pointing at the first element while this + // iterator is not. Skip incrementing it the first time around. + if (count_ != 0) + ++data_; + + if (count_ == helpers_.size()) { + next_.reset(); + return *this; + } + + size_t size = helpers_[helpers_[count_].last_child].size; + if (count_ != 0) + size -= helpers_[count_ - 1].size; + + next_.emplace(*data_, size); + ++count_; + return *this; +} + +template +const typename SizedResult::Element& +SizedResult::const_iterator::operator*() const { + return *next_; +} +template +const typename SizedResult::Element* +SizedResult::const_iterator::operator->() const { + return &*next_; +} + +template +bool SizedResult::const_iterator::operator==( + const SizedResult::const_iterator& that) const { + return this->data_ == that.data_; +} + +template +bool SizedResult::const_iterator::operator!=( + const SizedResult::const_iterator& that) const { + return !(*this == that); +} + +template +SizedElement::SizedElement(const El& el, size_t size_) + : El{el}, size{size_} { +} + +template +const El& SizedElement::inner() const { + return static_cast(*this); +} + +} // namespace oi::result diff --git a/include/oi/result/SizedResult.h b/include/oi/result/SizedResult.h new file mode 100644 index 0000000..983b804 --- /dev/null +++ b/include/oi/result/SizedResult.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef INCLUDED_OI_RESULT_SIZED_ELEMENT_H +#define INCLUDED_OI_RESULT_SIZED_ELEMENT_H 1 + +#include +#include +#include +#include + +namespace oi::result { + +template +struct SizedElement : public El { + SizedElement(const El& el, size_t size); + const El& inner() const; + + size_t size; +}; + +template +class SizedResult { + private: + using It = std::decay_t().begin())>; + using ParentEl = std::decay_t().operator*())>; + + public: + using Element = SizedElement; + + private: + struct SizeHelper { + size_t size = -1; + size_t last_child = -1; + }; + + public: + class const_iterator { + friend SizedResult; + + public: + bool operator==(const const_iterator& that) const; + bool operator!=(const const_iterator& that) const; + const Element& operator*() const; + const Element* operator->() const; + const_iterator& operator++(); + const_iterator operator++(int); + + private: + const_iterator(It start, const It& end); + const_iterator(It end); + + It data_; + + std::vector helpers_; + size_t count_ = 0; + std::optional next_; + }; + + SizedResult(Res res); + + const_iterator begin() const; + const_iterator end() const; + + private: + Res res_; +}; + +} // namespace oi::result + +#include "SizedResult-inl.h" +#endif diff --git a/oi/CMakeLists.txt b/oi/CMakeLists.txt index 3754f41..64dbcae 100644 --- a/oi/CMakeLists.txt +++ b/oi/CMakeLists.txt @@ -55,10 +55,6 @@ target_link_libraries(codegen glog::glog ) -add_library(exporters_json exporters/Json.cpp) -target_include_directories(exporters_json PUBLIC ${CMAKE_SOURCE_DIR}/include) -target_link_libraries(exporters_json oil) - add_library(exporters_csv exporters/CSV.cpp) target_include_directories(exporters_csv PUBLIC ${CMAKE_SOURCE_DIR}/include) target_link_libraries(exporters_csv oil) diff --git a/oi/exporters/Json.cpp b/oi/exporters/Json.cpp deleted file mode 100644 index 8a4d33c..0000000 --- a/oi/exporters/Json.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include - -#include -#include -#include - -template -inline constexpr bool always_false_v = false; - -namespace oi::exporters { -namespace { - -template -void printStringList(std::ostream& out, It it, It end, bool pretty) { - out << '['; - for (; it != end; ++it) { - out << '"' << (*it) << '"'; - if (it != end - 1) - out << (pretty ? ", " : ","); - } - out << ']'; -} - -std::string makeIndent(size_t depth) { - depth = std::max(depth, 1UL); - return std::string((depth - 1) * 4, ' '); -} - -} // namespace - -Json::Json(std::ostream& out) : out_(out) { -} - -void Json::print(const IntrospectionResult& r) { - auto begin = r.cbegin(); - auto end = r.cend(); - return print(begin, end); -} - -void Json::print(IntrospectionResult::const_iterator& it, - IntrospectionResult::const_iterator& end) { - const auto firstTypePathSize = it->type_path.size(); - - const auto indent = pretty_ ? makeIndent(firstTypePathSize) : ""; - const auto lastIndent = - pretty_ ? makeIndent(std::max(firstTypePathSize, 1UL) - 1) : ""; - const auto* tab = pretty_ ? " " : ""; - const auto* space = pretty_ ? " " : ""; - const auto* endl = pretty_ ? "\n" : ""; - - out_ << '[' << endl << indent; - - bool first = true; - while (it != end) { - if (it->type_path.size() < firstTypePathSize) { - // no longer a sibling, must be a sibling of the type we're printing - break; - } - - if (!first) - out_ << ',' << endl << indent; - first = false; - - out_ << '{' << endl << indent; - - out_ << tab << "\"name\"" << space << ':' << space << "\"" << it->name - << "\"," << endl - << indent; - - out_ << tab << "\"typePath\"" << space << ':' << space << ""; - printStringList(out_, it->type_path.begin(), it->type_path.end(), pretty_); - out_ << (pretty_ ? ",\n" : ",") << indent; - - out_ << tab << "\"typeNames\"" << space << ':' << space; - printStringList( - out_, it->type_names.begin(), it->type_names.end(), pretty_); - out_ << ',' << endl << indent; - - out_ << tab << "\"staticSize\":" << space << it->static_size << ',' << endl - << indent; - out_ << tab << "\"exclusiveSize\":" << space << it->exclusive_size << ',' - << endl - << indent; - - if (it->pointer.has_value()) { - out_ << tab << "\"pointer\":" << space << *(it->pointer) << ',' << endl - << indent; - } - - if (auto* s = std::get_if(&it->data)) { - out_ << tab << "\"data\":" << space << s->n << ',' << endl << indent; - } else if (auto* p = std::get_if(&it->data)) { - out_ << tab << "\"data\":" << space << "\"0x" << std::hex << p->p - << std::dec << "\"," << endl - << indent; - } else if (auto* str = std::get_if(&it->data)) { - out_ << tab << "\"data\":" << space << "\"" << *str << "\"," << endl - << indent; - } - - if (it->container_stats.has_value()) { - out_ << tab << "\"length\":" << space << it->container_stats->length - << ',' << endl - << indent; - out_ << tab << "\"capacity\":" << space << it->container_stats->capacity - << ',' << endl - << indent; - } - if (it->is_set_stats.has_value()) { - out_ << tab << "\"is_set\":" << space << it->is_set_stats->is_set << ',' - << endl - << indent; - } - - out_ << tab << "\"members\":" << space; - if (++it != end && it->type_path.size() > firstTypePathSize) { - print(it, end); - } else { - out_ << "[]" << endl; - } - - out_ << indent << "}"; - } - if (firstTypePathSize == 1) { - out_ << endl << ']' << endl; - } else { - out_ << endl << lastIndent << tab << ']' << endl; - } -} - -} // namespace oi::exporters diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index 12cb239..4d235b5 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -50,7 +50,7 @@ add_executable(integration_test_target ${INTEGRATION_TEST_TARGET_SRC} folly_shims.cpp) target_compile_options(integration_test_target PRIVATE -O1) -target_link_libraries(integration_test_target PRIVATE oil_jit exporters_json Boost::headers ${Boost_LIBRARIES}) +target_link_libraries(integration_test_target PRIVATE oil_jit Boost::headers ${Boost_LIBRARIES}) add_executable(integration_test_runner ${INTEGRATION_TEST_RUNNER_SRC} runner_common.cpp) target_include_directories(integration_test_runner PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/test/integration/anonymous.toml b/test/integration/anonymous.toml index 6a91293..15b9f10 100644 --- a/test/integration/anonymous.toml +++ b/test/integration/anonymous.toml @@ -88,10 +88,12 @@ definitions = ''' expect_json = '''[{ "staticSize":12, "dynamicSize":0, + "exclusiveSize":0, + "size": 12, "members":[ - {"name":"a", "staticSize":4, "dynamicSize":0}, - {"name":"b", "staticSize":4, "dynamicSize":0}, - {"name":"c", "staticSize":4, "dynamicSize":0} + {"name":"a", "staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4}, + {"name":"b", "staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4}, + {"name":"c", "staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4} ]}]''' [cases.anon_struct] @@ -207,10 +209,11 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize": 24, "exclusiveSize": 10, + "size": 24, "members": [ - {"name":"__oi_anon_0", "staticSize":2, "exclusiveSize":2}, - {"name":"__oi_anon_2", "staticSize":8, "exclusiveSize":8}, - {"name":"e", "staticSize":4, "exclusiveSize":4, "typeNames":["int32_t"]} + {"name":"__oi_anon_0", "staticSize":2, "exclusiveSize":2, "size":2}, + {"name":"__oi_anon_2", "staticSize":8, "exclusiveSize":8, "size":8}, + {"name":"e", "staticSize":4, "exclusiveSize":4, "size":4, "typeNames":["int32_t"]} ] }]''' diff --git a/test/integration/arrays.toml b/test/integration/arrays.toml index 4a06b13..5074b62 100644 --- a/test/integration/arrays.toml +++ b/test/integration/arrays.toml @@ -33,9 +33,11 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize":40, "exclusiveSize":0, + "size":40, "members":[{ "staticSize":40, "exclusiveSize":0, + "size":40, "length":10, "capacity":10 }]}]''' @@ -56,9 +58,11 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize":1, "exclusiveSize":1, + "size":1, "members":[{ "staticSize":0, - "exclusiveSize":0 + "exclusiveSize":0, + "size":1 }]}]''' [cases.multidim_legacy] # Test for legacy behaviour. Remove with OICodeGen oil_disable = 'oil only runs on codegen v2' @@ -86,10 +90,10 @@ definitions = ''' {"staticSize":12, "dynamicSize":0, "exclusiveSize":12, "length":3, "capacity":3, "elementStaticSize":4}] }]}]''' expect_json_v2 = '''[ - {"staticSize":24, "exclusiveSize":0, "members":[ - {"staticSize":24, "exclusiveSize":0, "length":2, "capacity":2, "members":[ - {"staticSize":12, "exclusiveSize":0, "length":3, "capacity":3}, - {"staticSize":12, "exclusiveSize":0, "length":3, "capacity":3}] + {"staticSize":24, "exclusiveSize":0, "size":24, "members":[ + {"staticSize":24, "exclusiveSize":0, "size":24, "length":2, "capacity":2, "members":[ + {"staticSize":12, "exclusiveSize":0, "size":12, "length":3, "capacity":3}, + {"staticSize":12, "exclusiveSize":0, "size":12, "length":3, "capacity":3}] }]}]''' [cases.direct_int10] skip = "Direct array arguments don't work" diff --git a/test/integration/enums.toml b/test/integration/enums.toml index f112b66..fa91cbc 100644 --- a/test/integration/enums.toml +++ b/test/integration/enums.toml @@ -36,31 +36,31 @@ definitions = ''' param_types = ["ScopedEnum"] setup = "return {};" expect_json = '[{"staticSize":4, "dynamicSize":0}]' - expect_json_v2 = '[{"typeNames": ["ScopedEnum"], "staticSize":4, "exclusiveSize":4}]' + expect_json_v2 = '[{"typeNames": ["ScopedEnum"], "staticSize":4, "exclusiveSize":4, "size":4}]' [cases.scoped_uint8] param_types = ["ScopedEnumUint8"] setup = "return {};" expect_json = '[{"staticSize":1, "dynamicSize":0}]' - expect_json_v2 = '[{"typeNames": ["ScopedEnumUint8"], "staticSize":1, "exclusiveSize":1}]' + expect_json_v2 = '[{"typeNames": ["ScopedEnumUint8"], "staticSize":1, "exclusiveSize":1, "size":1}]' [cases.unscoped] param_types = ["UNSCOPED_ENUM"] setup = "return {};" - expect_json = '[{"staticSize":4, "dynamicSize":0}]' + expect_json = '[{"staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4}]' [cases.anonymous] skip = "TreeBuilder crashes" # https://github.com/facebookexperimental/object-introspection/issues/232 param_types = ["Holder&"] setup = "return {};" expect_json = '''[ - {"staticSize":4, "dynamicSize":0, "exclusiveSize":0, "members":[ - {"name":"e", "staticSize":4, "dynamicSize":0, "exclusiveSize":4} + {"staticSize":4, "dynamicSize":0, "exclusiveSize":0, "size":4, "members":[ + {"name":"e", "staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4} ]}]''' [cases.paired_with_element] param_types = ["Pair"] setup = "return {};" expect_json = '[{"staticSize":2, "dynamicSize":0}]' expect_json_v2 = '''[ - {"staticSize": 2, "exclusiveSize": 0, "members": [ - {"typeNames": ["ScopedEnumUint8"], "staticSize":1, "exclusiveSize":1}, - {"typeNames": ["uint8_t"], "staticSize":1, "exclusiveSize":1} + {"staticSize": 2, "exclusiveSize": 0, "size":2, "members": [ + {"typeNames": ["ScopedEnumUint8"], "staticSize":1, "exclusiveSize":1, "size":1}, + {"typeNames": ["uint8_t"], "staticSize":1, "exclusiveSize":1, "size":1} ]} ]''' diff --git a/test/integration/enums_params.toml b/test/integration/enums_params.toml index cf61d6f..dd66f31 100644 --- a/test/integration/enums_params.toml +++ b/test/integration/enums_params.toml @@ -39,20 +39,20 @@ definitions = ''' param_types = ["const std::array(MyNS::ScopedEnum::Two)>&"] setup = "return {};" expect_json = '[{"staticSize":8, "length":2, "capacity":2, "elementStaticSize":4}]' - expect_json_v2 = '[{"staticSize":8, "dynamicSize":0, "length":2, "capacity":2}]' + expect_json_v2 = '[{"staticSize":8, "exclusiveSize":0, "size":8, "length":2, "capacity":2}]' [cases.scoped_enum_val] param_types = ["const MyClass&"] setup = "return {};" - expect_json = '[{"staticSize":4, "dynamicSize":0, "exclusiveSize":0}]' + expect_json = '[{"staticSize":4, "dynamicSize":0, "exclusiveSize":0, "size":4}]' [cases.scoped_enum_val_gaps] param_types = ["const ClassGaps&"] setup = "return {};" - expect_json = '[{"staticSize":4, "dynamicSize":0, "exclusiveSize":0}]' + expect_json = '[{"staticSize":4, "dynamicSize":0, "exclusiveSize":0, "size":4}]' [cases.scoped_enum_val_negative] param_types = ["const ClassGaps&"] setup = "return {};" - expect_json = '[{"staticSize":4, "dynamicSize":0, "exclusiveSize":0}]' + expect_json = '[{"staticSize":4, "dynamicSize":0, "exclusiveSize":0, "size":4}]' [cases.unscoped_enum_type] param_types = ["const std::vector&"] @@ -61,4 +61,4 @@ definitions = ''' param_types = ["const std::array&"] setup = "return {};" expect_json = '[{"staticSize":4, "length":1, "capacity":1, "elementStaticSize":4}]' - expect_json_v2 = '[{"staticSize":4, "length":1, "capacity":1}]' + expect_json_v2 = '[{"staticSize":4, "exclusiveSize":0, "size":4, "length":1, "capacity":1}]' diff --git a/test/integration/fbstring.toml b/test/integration/fbstring.toml index 6e68d99..cec73ca 100644 --- a/test/integration/fbstring.toml +++ b/test/integration/fbstring.toml @@ -28,6 +28,7 @@ includes = ["folly/FBString.h", "utility"] "typeNames": ["folly::basic_fbstring, std::allocator, folly::fbstring_core>"], "staticSize": 24, "exclusiveSize": 24, + "size": 24, "length": 0, "capacity": 23 }]''' @@ -60,6 +61,7 @@ includes = ["folly/FBString.h", "utility"] "typeNames": ["folly::basic_fbstring, std::allocator, folly::fbstring_core>"], "staticSize": 24, "exclusiveSize": 24, + "size": 24, "length": 6, "capacity": 23 }]''' @@ -92,6 +94,7 @@ includes = ["folly/FBString.h", "utility"] "typeNames": ["folly::basic_fbstring, std::allocator, folly::fbstring_core>"], "staticSize": 24, "exclusiveSize": 50, + "size": 50, "length": 26, "capacity": 26 }]''' @@ -124,6 +127,7 @@ includes = ["folly/FBString.h", "utility"] "typeNames": ["folly::basic_fbstring, std::allocator, folly::fbstring_core>"], "staticSize": 24, "exclusiveSize": 1056, + "size": 1056, "length": 1024, "capacity": 1024 }]''' @@ -137,17 +141,20 @@ includes = ["folly/FBString.h", "utility"] expect_json_v2 = '''[{ "staticSize": 48, "exclusiveSize": 0, + "size": 1080, "members": [ { "typeNames": ["folly::basic_fbstring, std::allocator, folly::fbstring_core>"], "staticSize": 24, "exclusiveSize": 1056, + "size": 1056, "length": 1024, "capacity": 1024 }, { "typeNames": ["folly::basic_fbstring, std::allocator, folly::fbstring_core>"], "staticSize": 24, "exclusiveSize": 24, + "size": 24, "length": 1024, "capacity": 1024 } diff --git a/test/integration/folly_f14_fast_map.toml b/test/integration/folly_f14_fast_map.toml index 5f9e509..273c222 100644 --- a/test/integration/folly_f14_fast_map.toml +++ b/test/integration/folly_f14_fast_map.toml @@ -70,26 +70,28 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize":96, "exclusiveSize": 0, + "size": 464, "members":[ - {"name":"m1", "staticSize":24, "exclusiveSize": 48, "length": 3, "capacity": 3}, - {"name":"m2", "staticSize":24, "exclusiveSize": 44, "length": 5, "capacity": 5}, - {"name":"m3", "staticSize":24, "exclusiveSize": 48, "length": 7, "capacity": 7}, + {"name":"m1", "staticSize":24, "exclusiveSize": 48, "size": 72, "length": 3, "capacity": 3}, + {"name":"m2", "staticSize":24, "exclusiveSize": 44, "size": 104, "length": 5, "capacity": 5}, + {"name":"m3", "staticSize":24, "exclusiveSize": 48, "size": 104,"length": 7, "capacity": 7}, { "name":"m4", "staticSize":24, "exclusiveSize": 40, + "size": 184, "length": 9, "capacity": 9, "members":[ - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4} + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16} ] }] }]''' diff --git a/test/integration/folly_f14_fast_set.toml b/test/integration/folly_f14_fast_set.toml index 486b9ba..24d8abe 100644 --- a/test/integration/folly_f14_fast_set.toml +++ b/test/integration/folly_f14_fast_set.toml @@ -75,9 +75,10 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize":96, "exclusiveSize": 0, + "size":304, "members":[ - {"name":"m1", "staticSize":24, "exclusiveSize": 44, "length": 3, "capacity": 3}, - {"name":"m2", "staticSize":24, "exclusiveSize": 48, "length": 5, "capacity": 5}, - {"name":"m3", "staticSize":24, "exclusiveSize": 44, "length": 7, "capacity": 7}, - {"name":"m4", "staticSize":24, "exclusiveSize": 52, "length": 9, "capacity": 9} + {"name":"m1", "staticSize":24, "exclusiveSize": 44, "size":56, "length": 3, "capacity": 3}, + {"name":"m2", "staticSize":24, "exclusiveSize": 48, "size":88, "length": 5, "capacity": 5}, + {"name":"m3", "staticSize":24, "exclusiveSize": 44, "size":72, "length": 7, "capacity": 7}, + {"name":"m4", "staticSize":24, "exclusiveSize": 52, "size":88, "length": 9, "capacity": 9} ]}]''' diff --git a/test/integration/folly_f14_node_map.toml b/test/integration/folly_f14_node_map.toml index 78d414d..07b5b89 100644 --- a/test/integration/folly_f14_node_map.toml +++ b/test/integration/folly_f14_node_map.toml @@ -70,26 +70,28 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize":96, "exclusiveSize": 0, + "size":668, "members":[ - {"name":"m1", "staticSize":24, "exclusiveSize": 72, "length": 3, "capacity": 3}, - {"name":"m2", "staticSize":24, "exclusiveSize": 88, "length": 5, "capacity": 5}, - {"name":"m3", "staticSize":24, "exclusiveSize": 104, "length": 7, "capacity": 7}, + {"name":"m1", "staticSize":24, "exclusiveSize": 72, "size": 96, "length": 3, "capacity": 3}, + {"name":"m2", "staticSize":24, "exclusiveSize": 88, "size": 148, "length": 5, "capacity": 5}, + {"name":"m3", "staticSize":24, "exclusiveSize": 104, "size": 160, "length": 7, "capacity": 7}, { "name":"m4", "staticSize":24, "exclusiveSize": 120, + "size": 264, "length": 9, "capacity": 9, "members":[ - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4} + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16} ] }] }]''' diff --git a/test/integration/folly_f14_node_set.toml b/test/integration/folly_f14_node_set.toml index 497976c..a68cc7b 100644 --- a/test/integration/folly_f14_node_set.toml +++ b/test/integration/folly_f14_node_set.toml @@ -75,9 +75,10 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize":96, "exclusiveSize": 0, + "size": 500, "members":[ - {"name":"m1", "staticSize":24, "exclusiveSize": 72, "length": 3, "capacity": 3}, - {"name":"m2", "staticSize":24, "exclusiveSize": 88, "length": 5, "capacity": 5}, - {"name":"m3", "staticSize":24, "exclusiveSize": 104, "length": 7, "capacity": 7}, - {"name":"m4", "staticSize":24, "exclusiveSize": 120, "length": 9, "capacity": 9} + {"name":"m1", "staticSize":24, "exclusiveSize": 72, "size": 84, "length": 3, "capacity": 3}, + {"name":"m2", "staticSize":24, "exclusiveSize": 88, "size": 128, "length": 5, "capacity": 5}, + {"name":"m3", "staticSize":24, "exclusiveSize": 104, "size": 132, "length": 7, "capacity": 7}, + {"name":"m4", "staticSize":24, "exclusiveSize": 120, "size": 156, "length": 9, "capacity": 9} ]}]''' diff --git a/test/integration/folly_f14_value_map.toml b/test/integration/folly_f14_value_map.toml index fac9829..a1a09e8 100644 --- a/test/integration/folly_f14_value_map.toml +++ b/test/integration/folly_f14_value_map.toml @@ -70,26 +70,28 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize":96, "exclusiveSize": 0, + "size": 464, "members":[ - {"name":"m1", "staticSize":24, "exclusiveSize": 48, "length": 3, "capacity": 3}, - {"name":"m2", "staticSize":24, "exclusiveSize": 44, "length": 5, "capacity": 5}, - {"name":"m3", "staticSize":24, "exclusiveSize": 48, "length": 7, "capacity": 7}, + {"name":"m1", "staticSize":24, "exclusiveSize": 48, "size": 72, "length": 3, "capacity": 3}, + {"name":"m2", "staticSize":24, "exclusiveSize": 44, "size": 104, "length": 5, "capacity": 5}, + {"name":"m3", "staticSize":24, "exclusiveSize": 48, "size": 104, "length": 7, "capacity": 7}, { "name":"m4", "staticSize":24, "exclusiveSize": 40, + "size": 184, "length": 9, "capacity": 9, "members":[ - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4} + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16} ] }] }]''' diff --git a/test/integration/folly_f14_value_set.toml b/test/integration/folly_f14_value_set.toml index 3f19b31..2cf03df 100644 --- a/test/integration/folly_f14_value_set.toml +++ b/test/integration/folly_f14_value_set.toml @@ -75,9 +75,10 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize":96, "exclusiveSize": 0, + "size": 304, "members":[ - {"name":"m1", "staticSize":24, "exclusiveSize": 44, "length": 3, "capacity": 3}, - {"name":"m2", "staticSize":24, "exclusiveSize": 48, "length": 5, "capacity": 5}, - {"name":"m3", "staticSize":24, "exclusiveSize": 44, "length": 7, "capacity": 7}, - {"name":"m4", "staticSize":24, "exclusiveSize": 52, "length": 9, "capacity": 9} + {"name":"m1", "staticSize":24, "exclusiveSize": 44, "size": 56, "length": 3, "capacity": 3}, + {"name":"m2", "staticSize":24, "exclusiveSize": 48, "size": 88, "length": 5, "capacity": 5}, + {"name":"m3", "staticSize":24, "exclusiveSize": 44, "size": 72, "length": 7, "capacity": 7}, + {"name":"m4", "staticSize":24, "exclusiveSize": 52, "size": 88, "length": 9, "capacity": 9} ]}]''' diff --git a/test/integration/folly_f14_vector_map.toml b/test/integration/folly_f14_vector_map.toml index 9912141..4126243 100644 --- a/test/integration/folly_f14_vector_map.toml +++ b/test/integration/folly_f14_vector_map.toml @@ -70,26 +70,28 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize":96, "exclusiveSize": 0, + "size": 576, "members":[ - {"name":"m1", "staticSize":24, "exclusiveSize": 64, "length": 3, "capacity": 3}, - {"name":"m2", "staticSize":24, "exclusiveSize": 60, "length": 5, "capacity": 5}, - {"name":"m3", "staticSize":24, "exclusiveSize": 80, "length": 7, "capacity": 7}, + {"name":"m1", "staticSize":24, "exclusiveSize": 64, "size": 88, "length": 3, "capacity": 3}, + {"name":"m2", "staticSize":24, "exclusiveSize": 60, "size": 120, "length": 5, "capacity": 5}, + {"name":"m3", "staticSize":24, "exclusiveSize": 80, "size": 136, "length": 7, "capacity": 7}, { "name":"m4", "staticSize":24, "exclusiveSize": 88, + "size": 232, "length": 9, "capacity": 9, "members":[ - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4}, - {"staticSize":16, "exclusiveSize": 4} + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16}, + {"staticSize":16, "exclusiveSize": 4, "size":16} ] }] }]''' diff --git a/test/integration/folly_f14_vector_set.toml b/test/integration/folly_f14_vector_set.toml index 3ffad84..c67f649 100644 --- a/test/integration/folly_f14_vector_set.toml +++ b/test/integration/folly_f14_vector_set.toml @@ -75,9 +75,10 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize":96, "exclusiveSize": 0, + "size": 400, "members":[ - {"name":"m1", "staticSize":24, "exclusiveSize": 60, "length": 3, "capacity": 3}, - {"name":"m2", "staticSize":24, "exclusiveSize": 64, "length": 5, "capacity": 5}, - {"name":"m3", "staticSize":24, "exclusiveSize": 76, "length": 7, "capacity": 7}, - {"name":"m4", "staticSize":24, "exclusiveSize": 84, "length": 9, "capacity": 9} + {"name":"m1", "staticSize":24, "exclusiveSize": 60, "size": 72, "length": 3, "capacity": 3}, + {"name":"m2", "staticSize":24, "exclusiveSize": 64, "size": 104, "length": 5, "capacity": 5}, + {"name":"m3", "staticSize":24, "exclusiveSize": 76, "size": 104, "length": 7, "capacity": 7}, + {"name":"m4", "staticSize":24, "exclusiveSize": 84, "size": 120, "length": 9, "capacity": 9} ]}]''' diff --git a/test/integration/folly_small_vector.toml b/test/integration/folly_small_vector.toml index 5ae53f3..b97b5ff 100644 --- a/test/integration/folly_small_vector.toml +++ b/test/integration/folly_small_vector.toml @@ -4,23 +4,23 @@ includes = ["folly/small_vector.h", "vector"] param_types = ["const folly::small_vector&"] setup = "return {};" expect_json = '[{"staticSize":16, "dynamicSize":0, "exclusiveSize":16, "length":0, "capacity":2, "elementStaticSize":4}]' - expect_json_v2 = '[{"staticSize":16, "exclusiveSize":16, "length":0, "capacity":2}]' + expect_json_v2 = '[{"staticSize":16, "exclusiveSize":16, "size":16, "length":0, "capacity":2}]' [cases.int_default_inlined] param_types = ["const folly::small_vector&"] setup = "return {{1,2}};" expect_json = '[{"staticSize":16, "dynamicSize":0, "exclusiveSize":16, "length":2, "capacity":2, "elementStaticSize":4}]' - expect_json_v2 = '[{"staticSize":16, "exclusiveSize":8, "length":2, "capacity":2}]' + expect_json_v2 = '[{"staticSize":16, "exclusiveSize":8, "size":16, "length":2, "capacity":2}]' [cases.int_default_overflow] param_types = ["const folly::small_vector&"] setup = "return {{1,2,3,4}};" expect_json = '[{"staticSize":16, "dynamicSize":24, "exclusiveSize":40, "length":4, "capacity":6, "elementStaticSize":4}]' - expect_json_v2 = '[{"staticSize":16, "exclusiveSize":24, "length":4, "capacity":6}]' + expect_json_v2 = '[{"staticSize":16, "exclusiveSize":24, "size":40, "length":4, "capacity":6}]' [cases.vector_3_empty] param_types = ["const folly::small_vector, 3>&"] setup = "return {};" expect_json = '[{"staticSize":80, "dynamicSize":0, "exclusiveSize":80, "length":0, "capacity":3, "elementStaticSize":24}]' - expect_json_v2 = '[{"staticSize":80, "exclusiveSize":80, "length":0, "capacity":3}]' + expect_json_v2 = '[{"staticSize":80, "exclusiveSize":80, "size":80, "length":0, "capacity":3}]' [cases.vector_3_inlined] param_types = ["const folly::small_vector, 3>&"] setup = "return {{ {1,2,3}, {4}, {5,6} }};" @@ -31,10 +31,10 @@ includes = ["folly/small_vector.h", "vector"] {"staticSize":24, "dynamicSize":8, "exclusiveSize":32, "length":2, "capacity":2, "elementStaticSize":4} ]}]''' expect_json_v2 = '''[ - {"staticSize":80, "length":3, "exclusiveSize":8, "capacity":3, "members":[ - {"staticSize":24, "exclusiveSize":24, "length":3, "capacity":3}, - {"staticSize":24, "exclusiveSize":24, "length":1, "capacity":1}, - {"staticSize":24, "exclusiveSize":24, "length":2, "capacity":2} + {"staticSize":80, "length":3, "exclusiveSize":8, "size":104, "capacity":3, "members":[ + {"staticSize":24, "exclusiveSize":24, "size":36, "length":3, "capacity":3}, + {"staticSize":24, "exclusiveSize":24, "size":28, "length":1, "capacity":1}, + {"staticSize":24, "exclusiveSize":24, "size":32, "length":2, "capacity":2} ]}]''' [cases.vector_3_overflow] param_types = ["const folly::small_vector, 3>&"] @@ -47,15 +47,15 @@ includes = ["folly/small_vector.h", "vector"] {"staticSize":24, "dynamicSize":4, "exclusiveSize":28, "length":1, "capacity":1, "elementStaticSize":4} ]}]''' expect_json_v2 = '''[ - {"staticSize":80, "exclusiveSize":104, "length":4, "capacity":5, "members":[ - {"staticSize":24, "exclusiveSize":24, "length":3, "capacity":3}, - {"staticSize":24, "exclusiveSize":24, "length":1, "capacity":1}, - {"staticSize":24, "exclusiveSize":24, "length":2, "capacity":2}, - {"staticSize":24, "exclusiveSize":24, "length":1, "capacity":1} + {"staticSize":80, "exclusiveSize":104, "size":228, "length":4, "capacity":5, "members":[ + {"staticSize":24, "exclusiveSize":24, "size":36, "length":3, "capacity":3}, + {"staticSize":24, "exclusiveSize":24, "size":28, "length":1, "capacity":1}, + {"staticSize":24, "exclusiveSize":24, "size":32, "length":2, "capacity":2}, + {"staticSize":24, "exclusiveSize":24, "size":28, "length":1, "capacity":1} ]}]''' [cases.int_always_heap] param_types = ["const folly::small_vector&"] setup = "return {{1}};" expect_json = '[{"staticSize":16, "dynamicSize":4, "exclusiveSize":20, "length":1, "capacity":1, "elementStaticSize":4}]' - expect_json_v2 = '[{"staticSize":16, "exclusiveSize":16, "length":1, "capacity":1}]' + expect_json_v2 = '[{"staticSize":16, "exclusiveSize":16, "size":20, "length":1, "capacity":1}]' diff --git a/test/integration/folly_sorted_vector_map.toml b/test/integration/folly_sorted_vector_map.toml index 6d3a2a5..44f91e0 100644 --- a/test/integration/folly_sorted_vector_map.toml +++ b/test/integration/folly_sorted_vector_map.toml @@ -4,19 +4,19 @@ includes = ["folly/sorted_vector_types.h", "vector"] param_types = ["const folly::sorted_vector_map&"] setup = "return {};" expect_json = '[{"staticSize":24, "dynamicSize":0, "exclusiveSize":24, "length":0, "capacity":0, "elementStaticSize":8}]' - expect_json_v2 = '[{"staticSize":24, "exclusiveSize":24, "length":0, "capacity":0, "members":[]}]' + expect_json_v2 = '[{"staticSize":24, "exclusiveSize":24, "size":24, "length":0, "capacity":0, "members":[]}]' [cases.int_int_some] param_types = ["const folly::sorted_vector_map&"] setup = "return {{ {1,2}, {3,4} }};" expect_json = '[{"staticSize":24, "dynamicSize":16, "exclusiveSize":40, "length":2, "capacity":2, "elementStaticSize":8}]' - expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "length":2, "capacity":2, "members":[ - {"staticSize":8, "exclusiveSize":0, "members": [ - {"name":"key", "staticSize":4, "exclusiveSize":4}, - {"name":"value", "staticSize":4, "exclusiveSize":4} + expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":40, "length":2, "capacity":2, "members":[ + {"staticSize":8, "exclusiveSize":0, "size":8, "members": [ + {"name":"key", "staticSize":4, "exclusiveSize":4, "size":4}, + {"name":"value", "staticSize":4, "exclusiveSize":4, "size":4} ]}, - {"staticSize":8, "exclusiveSize":0, "members": [ - {"name":"key", "staticSize":4, "exclusiveSize":4}, - {"name":"value", "staticSize":4, "exclusiveSize":4} + {"staticSize":8, "exclusiveSize":0, "size":8, "members": [ + {"name":"key", "staticSize":4, "exclusiveSize":4, "size":4}, + {"name":"value", "staticSize":4, "exclusiveSize":4, "size":4} ]} ]}]''' [cases.int_int_reserve] @@ -27,14 +27,14 @@ includes = ["folly/sorted_vector_types.h", "vector"] return m; ''' expect_json = '[{"staticSize":24, "dynamicSize":80, "exclusiveSize":104, "length":2, "capacity":10, "elementStaticSize":8}]' - expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":88, "length":2, "capacity":10, "members":[ - {"staticSize":8, "exclusiveSize":0, "members": [ - {"name":"key", "staticSize":4, "exclusiveSize":4}, - {"name":"value", "staticSize":4, "exclusiveSize":4} + expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":88, "size":104, "length":2, "capacity":10, "members":[ + {"staticSize":8, "exclusiveSize":0, "size":8, "members": [ + {"name":"key", "staticSize":4, "exclusiveSize":4, "size":4}, + {"name":"value", "staticSize":4, "exclusiveSize":4, "size":4} ]}, - {"staticSize":8, "exclusiveSize":0, "members": [ - {"name":"key", "staticSize":4, "exclusiveSize":4}, - {"name":"value", "staticSize":4, "exclusiveSize":4} + {"staticSize":8, "exclusiveSize":0, "size":8, "members": [ + {"name":"key", "staticSize":4, "exclusiveSize":4, "size":4}, + {"name":"value", "staticSize":4, "exclusiveSize":4, "size":4} ]} ]}]''' diff --git a/test/integration/gen_tests.py b/test/integration/gen_tests.py index 2dbc3ff..b72e371 100644 --- a/test/integration/gen_tests.py +++ b/test/integration/gen_tests.py @@ -40,6 +40,7 @@ def add_headers(f, custom_headers, thrift_headers): #include #include +#include """ ) @@ -145,8 +146,8 @@ def add_test_setup(f, config): oil_func_body += " auto pr = oi::exporters::Json(std::cout);\n" oil_func_body += " pr.setPretty(true);\n" for i in range(len(case["param_types"])): - oil_func_body += f" auto ret{i} = oi::setupAndIntrospect(a{i}, opts);\n" - oil_func_body += f" pr.print(*ret{i});\n" + oil_func_body += f" auto ret{i} = oi::result::SizedResult(*oi::setupAndIntrospect(a{i}, opts));\n" + oil_func_body += f" pr.print(ret{i});\n" f.write( define_traceable_func( diff --git a/test/integration/inheritance_access.toml b/test/integration/inheritance_access.toml index faeb35c..9751052 100644 --- a/test/integration/inheritance_access.toml +++ b/test/integration/inheritance_access.toml @@ -21,27 +21,33 @@ definitions = ''' setup = "return {};" expect_json = '''[{ "staticSize":8, + "exclusiveSize":0, + "size":8, "members":[ - {"name":"base_int", "staticSize":4, "typeName": "int32_t"}, - {"name":"public_int", "staticSize":4, "typeName": "int32_t"} + {"name":"base_int", "staticSize":4, "exclusiveSize":4, "size":4, "typeName": "int32_t"}, + {"name":"public_int", "staticSize":4, "exclusiveSize":4, "size":4, "typeName": "int32_t"} ]}]''' [cases.protected] param_types = ["const Protected&"] setup = "return {};" expect_json = '''[{ "staticSize":8, + "exclusiveSize":0, + "size":8, "members":[ - {"name":"base_int", "staticSize":4, "typeName": "int32_t"}, - {"name":"protected_int", "staticSize":4, "typeName": "int32_t"} + {"name":"base_int", "staticSize":4, "exclusiveSize":4, "size":4, "typeName": "int32_t"}, + {"name":"protected_int", "staticSize":4, "exclusiveSize":4, "size":4, "typeName": "int32_t"} ]}]''' [cases.private] param_types = ["const Private&"] setup = "return {};" expect_json = '''[{ "staticSize":8, + "exclusiveSize":0, + "size":8, "members":[ - {"name":"base_int", "staticSize":4, "typeName": "int32_t"}, - {"name":"private_int", "staticSize":4, "typeName": "int32_t"} + {"name":"base_int", "staticSize":4, "exclusiveSize":4, "size":4, "typeName": "int32_t"}, + {"name":"private_int", "staticSize":4, "exclusiveSize":4, "size":4, "typeName": "int32_t"} ]}]''' [cases.public_as_base] param_types = ["const Base&"] @@ -49,6 +55,8 @@ definitions = ''' setup = "return {};" expect_json = '''[{ "staticSize":4, + "exclusiveSize":0, + "size":4, "members":[ - {"name":"base_int", "staticSize":4, "typeName": "int32_t"} + {"name":"base_int", "staticSize":4, "exclusiveSize":4, "size":4, "typeName": "int32_t"} ]}]''' diff --git a/test/integration/inheritance_multiple.toml b/test/integration/inheritance_multiple.toml index 61d725f..53f956f 100644 --- a/test/integration/inheritance_multiple.toml +++ b/test/integration/inheritance_multiple.toml @@ -37,11 +37,12 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize":24, "exclusiveSize":0, + "size":24, "members":[ - {"name":"a", "staticSize":4, "exclusiveSize":4}, - {"name":"b", "staticSize":4, "exclusiveSize":4}, - {"name":"c", "staticSize":4, "exclusiveSize":4}, - {"name":"d", "staticSize":4, "exclusiveSize":4}, - {"name":"e", "staticSize":4, "exclusiveSize":4}, - {"name":"f", "staticSize":4, "exclusiveSize":4} + {"name":"a", "staticSize":4, "exclusiveSize":4, "size":4}, + {"name":"b", "staticSize":4, "exclusiveSize":4, "size":4}, + {"name":"c", "staticSize":4, "exclusiveSize":4, "size":4}, + {"name":"d", "staticSize":4, "exclusiveSize":4, "size":4}, + {"name":"e", "staticSize":4, "exclusiveSize":4, "size":4}, + {"name":"f", "staticSize":4, "exclusiveSize":4, "size":4} ]}]''' diff --git a/test/integration/packed.toml b/test/integration/packed.toml index 2bbef02..0e45479 100644 --- a/test/integration/packed.toml +++ b/test/integration/packed.toml @@ -12,8 +12,10 @@ definitions = ''' expect_json = '''[{ "staticSize":17, "dynamicSize":0, + "exclusiveSize":0, + "size":17, "members":[ - {"name":"p", "staticSize":8, "dynamicSize":0}, - {"name":"c", "staticSize":1, "dynamicSize":0}, - {"name":"x", "staticSize":8, "dynamicSize":0} + {"name":"p", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8}, + {"name":"c", "staticSize":1, "dynamicSize":0, "exclusiveSize":1, "size":1}, + {"name":"x", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8} ]}]''' diff --git a/test/integration/padding.toml b/test/integration/padding.toml index 6cc17d1..5001be6 100644 --- a/test/integration/padding.toml +++ b/test/integration/padding.toml @@ -65,10 +65,11 @@ definitions = ''' expect_json = '''[{ "staticSize":24, "dynamicSize":0, + "exclusiveSize": 7, "members":[ - { "name":"a", "staticSize":8, "dynamicSize":0 }, - { "name":"b", "staticSize":1, "dynamicSize":0 }, - { "name":"c", "staticSize":8, "dynamicSize":0 } + { "name":"a", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8 }, + { "name":"b", "staticSize":1, "dynamicSize":0, "exclusiveSize":1, "size":1 }, + { "name":"c", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8 } ]}]''' [cases.nested_padding] @@ -77,18 +78,22 @@ definitions = ''' expect_json = '''[{ "staticSize":48, "dynamicSize":0, + "exclusiveSize":7, + "size":48, "members":[ - { "name":"a", "staticSize":8, "dynamicSize":0 }, - { "name":"b", "staticSize":1, "dynamicSize":0 }, - { "name":"c", "staticSize":8, "dynamicSize":0 }, + { "name":"a", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8 }, + { "name":"b", "staticSize":1, "dynamicSize":0, "exclusiveSize":1, "size":1 }, + { "name":"c", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8 }, { "name":"d", "staticSize":24, "dynamicSize":0, + "exclusiveSize":7, + "size":24, "members": [ - { "name":"a", "staticSize":8, "dynamicSize":0 }, - { "name":"b", "staticSize":1, "dynamicSize":0 }, - { "name":"c", "staticSize":8, "dynamicSize":0 } + { "name":"a", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8 }, + { "name":"b", "staticSize":1, "dynamicSize":0, "exclusiveSize":1, "size":1 }, + { "name":"c", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8 } ]} ]}]''' @@ -103,5 +108,6 @@ definitions = ''' }]''' expect_json_v2 = '''[{ "staticSize": 104, - "exclusiveSize": 32 + "exclusiveSize": 32, + "size": 104 }]''' diff --git a/test/integration/pointers.toml b/test/integration/pointers.toml index 389ba29..71bf2ad 100644 --- a/test/integration/pointers.toml +++ b/test/integration/pointers.toml @@ -153,10 +153,12 @@ definitions = ''' expect_json = '''[{ "staticSize":24, "dynamicSize":0, + "exclusiveSize":4, + "size":24, "members":[ - {"name":"a", "staticSize":4, "dynamicSize":0}, - {"name":"b", "staticSize":8, "dynamicSize":0}, - {"name":"c", "staticSize":8, "dynamicSize":0} + {"name":"a", "staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4}, + {"name":"b", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8}, + {"name":"c", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8} ]}]''' [cases.struct_primitive_ptrs_null] param_types = ["const PrimitivePtrs&"] @@ -165,10 +167,12 @@ definitions = ''' expect_json = '''[{ "staticSize":24, "dynamicSize":0, + "exclusiveSize":4, + "size":24, "members":[ - {"name":"a", "staticSize":4, "dynamicSize":0}, - {"name":"b", "staticSize":8, "dynamicSize":0}, - {"name":"c", "staticSize":8, "dynamicSize":0} + {"name":"a", "staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4}, + {"name":"b", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8}, + {"name":"c", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8} ]}]''' @@ -189,8 +193,10 @@ definitions = ''' expect_json = '''[{ "staticSize":8, "dynamicSize":0, + "exclusiveSize":0, + "size":8, "members":[ - {"name":"vec", "staticSize":8, "dynamicSize":0} + {"name":"vec", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8} ]}]''' [cases.struct_vector_ptr_null] param_types = ["const VectorPtr&"] @@ -199,8 +205,10 @@ definitions = ''' expect_json = '''[{ "staticSize":8, "dynamicSize":0, + "exclusiveSize":0, + "size":8, "members":[ - {"name":"vec", "staticSize":8, "dynamicSize":0} + {"name":"vec", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8} ]}]''' @@ -242,10 +250,12 @@ definitions = ''' expect_json = '''[{ "staticSize":24, "dynamicSize":0, + "exclusiveSize":4, + "size":24, "members":[ - {"name":"a", "staticSize":4, "dynamicSize":0}, - {"name":"b", "staticSize":8, "dynamicSize":0}, - {"name":"c", "staticSize":8, "dynamicSize":0} + {"name":"a", "staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4}, + {"name":"b", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8}, + {"name":"c", "staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8} ]}]''' [cases.feature_config] oil_disable = "oil can't chase raw pointers safely" diff --git a/test/integration/primitives.toml b/test/integration/primitives.toml index 429712f..94784fb 100644 --- a/test/integration/primitives.toml +++ b/test/integration/primitives.toml @@ -2,76 +2,76 @@ [cases.short] param_types = ["short"] setup = "return 123;" - expect_json = '[{"staticSize":2, "dynamicSize":0}]' + expect_json = '[{"staticSize":2, "dynamicSize":0, "exclusiveSize":2, "size":2}]' [cases.ushort] param_types = ["unsigned short"] setup = "return 123;" - expect_json = '[{"staticSize":2, "dynamicSize":0}]' + expect_json = '[{"staticSize":2, "dynamicSize":0, "exclusiveSize":2, "size":2}]' [cases.int] param_types = ["int"] setup = "return 123;" - expect_json = '[{"staticSize":4, "dynamicSize":0}]' + expect_json = '[{"staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4}]' [cases.uint] param_types = ["unsigned int"] setup = "return 123;" - expect_json = '[{"staticSize":4, "dynamicSize":0}]' + expect_json = '[{"staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4}]' [cases.long] param_types = ["long"] setup = "return 123;" - expect_json = '[{"staticSize":8, "dynamicSize":0}]' + expect_json = '[{"staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8}]' [cases.ulong] param_types = ["unsigned long"] setup = "return 123;" - expect_json = '[{"staticSize":8, "dynamicSize":0}]' + expect_json = '[{"staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8}]' [cases.longlong] param_types = ["long long"] setup = "return 123;" - expect_json = '[{"staticSize":8, "dynamicSize":0}]' + expect_json = '[{"staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8}]' [cases.ulonglong] param_types = ["unsigned long long"] setup = "return 123;" - expect_json = '[{"staticSize":8, "dynamicSize":0}]' + expect_json = '[{"staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8}]' [cases.bool] param_types = ["bool"] setup = "return true;" - expect_json = '[{"staticSize":1, "dynamicSize":0}]' + expect_json = '[{"staticSize":1, "dynamicSize":0, "exclusiveSize":1, "size":1}]' [cases.char] param_types = ["char"] setup = "return 'a';" - expect_json = '[{"staticSize":1, "dynamicSize":0}]' + expect_json = '[{"staticSize":1, "dynamicSize":0, "exclusiveSize":1, "size":1}]' [cases.uchar] param_types = ["unsigned char"] setup = "return 'a';" - expect_json = '[{"staticSize":1, "dynamicSize":0}]' + expect_json = '[{"staticSize":1, "dynamicSize":0, "exclusiveSize":1, "size":1}]' [cases.schar] param_types = ["signed char"] setup = "return 'a';" - expect_json = '[{"staticSize":1, "dynamicSize":0}]' + expect_json = '[{"staticSize":1, "dynamicSize":0, "exclusiveSize":1, "size":1}]' [cases.wchar_t] param_types = ["wchar_t"] setup = "return 'a';" - expect_json = '[{"staticSize":4, "dynamicSize":0}]' + expect_json = '[{"staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4}]' [cases.char8_t] param_types = ["char8_t"] setup = "return 'a';" - expect_json = '[{"staticSize":1, "dynamicSize":0}]' + expect_json = '[{"staticSize":1, "dynamicSize":0, "exclusiveSize":1, "size":1}]' [cases.char16_t] param_types = ["char16_t"] setup = "return 'a';" - expect_json = '[{"staticSize":2, "dynamicSize":0}]' + expect_json = '[{"staticSize":2, "dynamicSize":0, "exclusiveSize":2, "size":2}]' [cases.char32_t] param_types = ["char32_t"] setup = "return 'a';" - expect_json = '[{"staticSize":4, "dynamicSize":0}]' + expect_json = '[{"staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4}]' [cases.float] param_types = ["float"] setup = "return 3.14;" - expect_json = '[{"staticSize":4, "dynamicSize":0}]' + expect_json = '[{"staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4}]' [cases.double] param_types = ["double"] setup = "return 3.14;" - expect_json = '[{"staticSize":8, "dynamicSize":0}]' + expect_json = '[{"staticSize":8, "dynamicSize":0, "exclusiveSize":8, "size":8}]' [cases.long_double] param_types = ["long double"] setup = "return 3.14;" - expect_json = '[{"staticSize":16, "dynamicSize":0}]' + expect_json = '[{"staticSize":16, "dynamicSize":0, "exclusiveSize":16, "size":16}]' diff --git a/test/integration/runner_common.cpp b/test/integration/runner_common.cpp index c86bd59..3c8525a 100644 --- a/test/integration/runner_common.cpp +++ b/test/integration/runner_common.cpp @@ -365,6 +365,8 @@ void IntegrationBase::compare_json(const bpt::ptree& expected_json, } } else if (key == "dynamicSize" && val.get_value() == 0) { continue; + } else if (key == "size") { + continue; } ADD_FAILURE() << "Expected key not found in output: " << curr_key; diff --git a/test/integration/simple.toml b/test/integration/simple.toml index 71a215a..0945f70 100644 --- a/test/integration/simple.toml +++ b/test/integration/simple.toml @@ -23,10 +23,12 @@ definitions = ''' expect_json = '''[{ "staticSize":16, "dynamicSize":0, + "exclusiveSize": 3, + "size": 16, "members":[ - {"name":"a", "staticSize":4, "dynamicSize":0}, - {"name":"b", "staticSize":1, "dynamicSize":0}, - {"name":"c", "staticSize":8, "dynamicSize":0} + {"name":"a", "staticSize":4, "dynamicSize":0, "exclusiveSize": 4, "size": 4}, + {"name":"b", "staticSize":1, "dynamicSize":0, "exclusiveSize": 1, "size": 1}, + {"name":"c", "staticSize":8, "dynamicSize":0, "exclusiveSize": 8, "size": 8} ]}]''' [cases.class] param_types = ["const SimpleClass&"] @@ -34,15 +36,19 @@ definitions = ''' expect_json = '''[{ "staticSize":16, "dynamicSize":0, + "exclusiveSize": 3, + "size": 16, "members":[ - {"name":"a", "staticSize":4, "dynamicSize":0}, - {"name":"b", "staticSize":1, "dynamicSize":0}, - {"name":"c", "staticSize":8, "dynamicSize":0} + {"name":"a", "staticSize":4, "dynamicSize":0, "exclusiveSize": 4, "size": 4}, + {"name":"b", "staticSize":1, "dynamicSize":0, "exclusiveSize": 1, "size": 1}, + {"name":"c", "staticSize":8, "dynamicSize":0, "exclusiveSize": 8, "size": 8} ]}]''' [cases.union] param_types = ["const SimpleUnion&"] setup = "return {};" expect_json = '''[{ "staticSize":8, - "dynamicSize":0 + "dynamicSize":0, + "exclusiveSize":8, + "size":8 }]''' diff --git a/test/integration/sorted_vector_set.toml b/test/integration/sorted_vector_set.toml index 8e37abd..0a4e416 100644 --- a/test/integration/sorted_vector_set.toml +++ b/test/integration/sorted_vector_set.toml @@ -23,6 +23,7 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize": 24, "exclusiveSize": 24, + "size": 24, "length": 0, "capacity": 0 }]''' @@ -56,6 +57,7 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize": 24, "exclusiveSize": 28, + "size": 40, "length": 3, "capacity": 4 }]''' diff --git a/test/integration/std_list.toml b/test/integration/std_list.toml index dfe2d8f..92c039a 100644 --- a/test/integration/std_list.toml +++ b/test/integration/std_list.toml @@ -13,30 +13,30 @@ definitions = ''' param_types = ["const std::list&"] setup = "return {};" expect_json = '[{"staticSize":24, "dynamicSize":0, "length":0, "capacity":0, "elementStaticSize":4}]' - expect_json_v2 = '[{"staticSize":24, "exclusiveSize":24, "length":0, "capacity":0, "members":[]}]' + expect_json_v2 = '[{"staticSize":24, "exclusiveSize":24, "size":24, "length":0, "capacity":0, "members":[]}]' [cases.int_some] param_types = ["const std::list&"] setup = "return {{1,2,3}};" expect_json = '[{"staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4}]' - expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "length":3, "capacity":3, "members":[ - {"staticSize":4, "exclusiveSize":4}, - {"staticSize":4, "exclusiveSize":4}, - {"staticSize":4, "exclusiveSize":4} + expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":36, "length":3, "capacity":3, "members":[ + {"staticSize":4, "exclusiveSize":4, "size":4}, + {"staticSize":4, "exclusiveSize":4, "size":4}, + {"staticSize":4, "exclusiveSize":4, "size":4} ]}]''' [cases.struct_some] param_types = ["const std::list&"] setup = "return {{{}, {}, {}}};" expect_json = '[{"staticSize":24, "dynamicSize":48, "length":3, "capacity":3, "elementStaticSize":16}]' - expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "length":3, "capacity":3, "members":[ - {"staticSize":16, "exclusiveSize":3}, - {"staticSize":16, "exclusiveSize":3}, - {"staticSize":16, "exclusiveSize":3} + expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":72, "length":3, "capacity":3, "members":[ + {"staticSize":16, "exclusiveSize":3, "size":16}, + {"staticSize":16, "exclusiveSize":3, "size":16}, + {"staticSize":16, "exclusiveSize":3, "size":16} ]}]''' [cases.list_int_empty] param_types = ["const std::list>&"] setup = "return {};" expect_json = '[{"staticSize":24, "dynamicSize":0, "length":0, "capacity":0, "elementStaticSize":24}]' - expect_json_v2 = '[{"staticSize":24, "exclusiveSize":24, "length":0, "capacity":0, "members":[]}]' + expect_json_v2 = '[{"staticSize":24, "exclusiveSize":24, "size":24, "length":0, "capacity":0, "members":[]}]' [cases.list_int_some] param_types = ["const std::list>&"] setup = "return {{{1,2,3},{4},{5,6}}};" @@ -52,8 +52,8 @@ definitions = ''' {"staticSize":24, "dynamicSize":4, "exclusiveSize":28, "length":1, "capacity":1, "elementStaticSize":4}, {"staticSize":24, "dynamicSize":8, "exclusiveSize":32, "length":2, "capacity":2, "elementStaticSize":4} ]}]''' - expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "length":3, "capacity": 3, "members":[ - {"staticSize":24, "exclusiveSize":24, "length":3, "capacity": 3, "members":[]}, - {"staticSize":24, "exclusiveSize":24, "length":1, "capacity": 1, "members":[]}, - {"staticSize":24, "exclusiveSize":24, "length":2, "capacity": 2, "members":[]} + expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":120, "length":3, "capacity": 3, "members":[ + {"staticSize":24, "exclusiveSize":24, "size":36, "length":3, "capacity": 3}, + {"staticSize":24, "exclusiveSize":24, "size":28, "length":1, "capacity": 1}, + {"staticSize":24, "exclusiveSize":24, "size":32, "length":2, "capacity": 2} ]}]''' diff --git a/test/integration/std_list_del_allocator.toml b/test/integration/std_list_del_allocator.toml index b986996..c85d3ab 100644 --- a/test/integration/std_list_del_allocator.toml +++ b/test/integration/std_list_del_allocator.toml @@ -60,7 +60,8 @@ includes = ["list"] expect_json_v2 = '''[{ "staticSize": 48, "exclusiveSize": 0, + "size": 60, "members": [ - {"name": "v1", "staticSize": 24, "exclusiveSize": 24, "length": 1, "capacity": 1}, - {"name": "v2", "staticSize": 24, "exclusiveSize": 24, "length": 2, "capacity": 2} + {"name": "v1", "staticSize": 24, "exclusiveSize": 24, "size": 28, "length": 1, "capacity": 1}, + {"name": "v2", "staticSize": 24, "exclusiveSize": 24, "size": 32, "length": 2, "capacity": 2} ]}]''' diff --git a/test/integration/std_map_custom_comparator.toml b/test/integration/std_map_custom_comparator.toml index f8edd24..5f30b36 100644 --- a/test/integration/std_map_custom_comparator.toml +++ b/test/integration/std_map_custom_comparator.toml @@ -70,10 +70,12 @@ includes = ["map", "functional"] expect_json_v2 = '''[{ "staticSize":8184, "exclusiveSize":0, + "size":9168, "members":[ {"name":"m1", "staticSize":48, "exclusiveSize":48, + "size":192, "length":3, "capacity":3, "members": [ @@ -81,7 +83,7 @@ includes = ["map", "functional"] {}, {} ]}, - {"name":"m2", "staticSize":48, "exclusiveSize":48, "length":5, "capacity":5}, - {"name":"m3", "staticSize":48, "exclusiveSize":48, "length":7, "capacity":7}, - {"name":"m4", "staticSize":8040, "exclusiveSize":8040, "length":9, "capacity":9} + {"name":"m2", "staticSize":48, "exclusiveSize":48, "size":248, "length":5, "capacity":5}, + {"name":"m3", "staticSize":48, "exclusiveSize":48, "size":328, "length":7, "capacity":7}, + {"name":"m4", "staticSize":8040, "exclusiveSize":8040, "size":8400, "length":9, "capacity":9} ]}]''' diff --git a/test/integration/std_multimap_custom_comparator.toml b/test/integration/std_multimap_custom_comparator.toml index 7f8171f..883c4cd 100644 --- a/test/integration/std_multimap_custom_comparator.toml +++ b/test/integration/std_multimap_custom_comparator.toml @@ -38,16 +38,18 @@ includes = ["map"] expect_json_v2 = '''[{ "staticSize":96, "exclusiveSize":0, + "size":440, "members":[ {"name":"m1", "staticSize":48, "exclusiveSize":48, + "size":192, "length":3, "capacity":3, "members": [ - {"name":"[]", "staticSize":48, "exclusiveSize":36}, + {"name":"[]", "staticSize":48, "exclusiveSize":36, "size":48}, {}, {} ]}, - {"name":"m2", "staticSize":48, "exclusiveSize":48, "length":5, "capacity":5} + {"name":"m2", "staticSize":48, "exclusiveSize":48, "size":248, "length":5, "capacity":5} ]}]''' diff --git a/test/integration/std_multiset_custom_comparator.toml b/test/integration/std_multiset_custom_comparator.toml index 04d5da8..e8ef1aa 100644 --- a/test/integration/std_multiset_custom_comparator.toml +++ b/test/integration/std_multiset_custom_comparator.toml @@ -65,9 +65,10 @@ includes = ["set", "functional"] expect_json_v2 = '''[{ "staticSize":8184, "exclusiveSize": 0, + "size":9144, "members":[ - {"name":"m1", "staticSize":48, "exclusiveSize": 156, "length": 3, "capacity": 3}, - {"name":"m2", "staticSize":48, "exclusiveSize": 228, "length": 5, "capacity": 5}, - {"name":"m3", "staticSize":48, "exclusiveSize": 300, "length": 7, "capacity": 7}, - {"name":"m4", "staticSize":8040, "exclusiveSize": 8364, "length": 9, "capacity": 9} + {"name":"m1", "staticSize":48, "exclusiveSize": 156, "size": 168, "length": 3, "capacity": 3}, + {"name":"m2", "staticSize":48, "exclusiveSize": 228, "size": 248, "length": 5, "capacity": 5}, + {"name":"m3", "staticSize":48, "exclusiveSize": 300, "size": 328, "length": 7, "capacity": 7}, + {"name":"m4", "staticSize":8040, "exclusiveSize": 8364, "size": 8400, "length": 9, "capacity": 9} ]}]''' diff --git a/test/integration/std_optional.toml b/test/integration/std_optional.toml index 7475e28..9da0271 100644 --- a/test/integration/std_optional.toml +++ b/test/integration/std_optional.toml @@ -20,6 +20,7 @@ includes = ["optional", "cstdint", "vector"] { "staticSize": 16, "exclusiveSize": 16, + "size": 16, "length": 0, "capacity": 1, "members": [] @@ -46,6 +47,7 @@ includes = ["optional", "cstdint", "vector"] { "staticSize": 16, "exclusiveSize": 8, + "size": 16, "length": 1, "capacity": 1, "members": [ @@ -77,6 +79,7 @@ includes = ["optional", "cstdint", "vector"] { "staticSize": 32, "exclusiveSize": 32, + "size": 32, "length": 0, "capacity": 1, "members": [] @@ -111,12 +114,14 @@ includes = ["optional", "cstdint", "vector"] { "staticSize": 32, "exclusiveSize": 8, + "size": 72, "length": 1, "capacity": 1, "members": [ { "staticSize": 24, "exclusiveSize": 24, + "size": 64, "length": 5, "capacity": 5 } diff --git a/test/integration/std_pair.toml b/test/integration/std_pair.toml index c60e784..1780951 100644 --- a/test/integration/std_pair.toml +++ b/test/integration/std_pair.toml @@ -14,9 +14,9 @@ includes = ["vector", "utility", "cstdint"] ] ''' expect_json_v2 = '''[ - {"staticSize": 16, "exclusiveSize": 0, "members": [ - {"typeNames": ["uint64_t"], "staticSize": 8, "exclusiveSize": 8}, - {"typeNames": ["uint64_t"], "staticSize": 8, "exclusiveSize": 8} + {"staticSize": 16, "exclusiveSize": 0, "size": 16, "members": [ + {"typeNames": ["uint64_t"], "staticSize": 8, "exclusiveSize": 8, "size": 8}, + {"typeNames": ["uint64_t"], "staticSize": 8, "exclusiveSize": 8, "size": 8} ]} ]''' [cases.uint64_uint32] @@ -34,9 +34,9 @@ includes = ["vector", "utility", "cstdint"] ] ''' expect_json_v2 = '''[ - {"staticSize": 16, "exclusiveSize": 4, "members": [ - {"typeNames": ["uint64_t"], "staticSize": 8, "exclusiveSize": 8}, - {"typeNames": ["uint32_t"], "staticSize": 4, "exclusiveSize": 4} + {"staticSize": 16, "exclusiveSize": 4, "size": 16, "members": [ + {"typeNames": ["uint64_t"], "staticSize": 8, "exclusiveSize": 8, "size": 8}, + {"typeNames": ["uint32_t"], "staticSize": 4, "exclusiveSize": 4, "size": 4} ]} ]''' @@ -48,9 +48,9 @@ includes = ["vector", "utility", "cstdint"] param_types = ["std::pair&"] setup = "return {{0, nullptr}};" expect_json_v2 = '''[ - {"staticSize": 16, "exclusiveSize": 0, "members": [ - {"typeNames": ["uint64_t"], "staticSize": 8, "exclusiveSize": 8}, - {"typeNames": ["uintptr_t (stubbed)"], "staticSize": 8, "exclusiveSize": 8} + {"staticSize": 16, "exclusiveSize": 0, "size": 16, "members": [ + {"typeNames": ["uint64_t"], "staticSize": 8, "exclusiveSize": 8, "size": 8}, + {"typeNames": ["uintptr_t (stubbed)"], "staticSize": 8, "exclusiveSize": 8, "size": 8} ]} ]''' @@ -82,8 +82,8 @@ includes = ["vector", "utility", "cstdint"] ] ''' expect_json_v2 = '''[ - {"staticSize": 48, "exclusiveSize": 0, "members": [ - {"typeNames": ["std::vector>"], "staticSize": 24, "exclusiveSize": 24}, - {"typeNames": ["std::vector>"], "staticSize": 24, "exclusiveSize": 24} + {"staticSize": 48, "exclusiveSize": 0, "size": 104, "members": [ + {"typeNames": ["std::vector>"], "staticSize": 24, "exclusiveSize": 24, "size": 48}, + {"typeNames": ["std::vector>"], "staticSize": 24, "exclusiveSize": 24, "size": 56} ]} ]''' diff --git a/test/integration/std_set_custom_comparator.toml b/test/integration/std_set_custom_comparator.toml index 66031f7..49d07f8 100644 --- a/test/integration/std_set_custom_comparator.toml +++ b/test/integration/std_set_custom_comparator.toml @@ -65,9 +65,10 @@ includes = ["set", "functional"] expect_json_v2 = '''[{ "staticSize":8184, "exclusiveSize": 0, + "size": 9144, "members":[ - {"name":"m1", "staticSize":48, "exclusiveSize": 156, "length": 3, "capacity": 3}, - {"name":"m2", "staticSize":48, "exclusiveSize": 228, "length": 5, "capacity": 5}, - {"name":"m3", "staticSize":48, "exclusiveSize": 300, "length": 7, "capacity": 7}, - {"name":"m4", "staticSize":8040, "exclusiveSize": 8364, "length": 9, "capacity": 9} + {"name":"m1", "staticSize":48, "exclusiveSize": 156, "size": 168, "length": 3, "capacity": 3}, + {"name":"m2", "staticSize":48, "exclusiveSize": 228, "size": 248, "length": 5, "capacity": 5}, + {"name":"m3", "staticSize":48, "exclusiveSize": 300, "size": 328, "length": 7, "capacity": 7}, + {"name":"m4", "staticSize":8040, "exclusiveSize": 8364, "size": 8400, "length": 9, "capacity": 9} ]}]''' diff --git a/test/integration/std_smart_ptr.toml b/test/integration/std_smart_ptr.toml index 8fc66bf..dfb86ae 100644 --- a/test/integration/std_smart_ptr.toml +++ b/test/integration/std_smart_ptr.toml @@ -26,6 +26,7 @@ definitions = ''' { "staticSize": 8, "exclusiveSize": 8, + "size": 8, "length": 0, "capacity": 1 } @@ -50,6 +51,7 @@ definitions = ''' { "staticSize": 8, "exclusiveSize": 8, + "size": 16, "length": 1, "capacity": 1 } @@ -74,6 +76,7 @@ definitions = ''' { "staticSize": 8, "exclusiveSize": 8, + "size": 8, "length": 0, "capacity": 1 } @@ -106,6 +109,7 @@ definitions = ''' { "staticSize": 8, "exclusiveSize": 8, + "size": 72, "length": 1, "capacity": 1, "members": [ @@ -134,7 +138,8 @@ definitions = ''' [ { "staticSize": 16, - "exclusiveSize": 16 + "exclusiveSize": 16, + "size": 16 } ] ''' @@ -153,7 +158,8 @@ definitions = ''' [ { "staticSize": 16, - "exclusiveSize": 16 + "exclusiveSize": 16, + "size": 16 } ] ''' @@ -176,6 +182,7 @@ definitions = ''' { "staticSize": 16, "exclusiveSize": 16, + "size": 16, "length": 0, "capacity": 1 } @@ -200,6 +207,7 @@ definitions = ''' { "staticSize": 16, "exclusiveSize": 16, + "size": 24, "length": 1, "capacity": 1, "members": [ @@ -227,6 +235,7 @@ definitions = ''' { "staticSize": 16, "exclusiveSize": 16, + "size": 16, "length": 0, "capacity": 1 } @@ -257,12 +266,14 @@ definitions = ''' { "staticSize": 16, "exclusiveSize": 16, + "size": 80, "length": 1, "capacity": 1, "members": [ { "staticSize": 24, "exclusiveSize": 24, + "size": 64, "length": 5, "capacity": 5 } @@ -278,7 +289,8 @@ definitions = ''' { "staticSize": 16, "dynamicSize": 0, - "exclusiveSize": 16 + "exclusiveSize": 16, + "size": 16 } ] ''' @@ -290,7 +302,8 @@ definitions = ''' { "staticSize": 16, "dynamicSize": 0, - "exclusiveSize": 16 + "exclusiveSize": 16, + "size": 16 } ] ''' @@ -307,7 +320,7 @@ definitions = ''' } ] ''' - expect_json_v2 = '''[{ "staticSize": 16, "exclusiveSize": 16, "members":[]}]''' + expect_json_v2 = '''[{ "staticSize": 16, "exclusiveSize": 16, "size": 16, "members":[]}]''' [cases.weak_ptr_int64_void_empty] param_types = ["std::weak_ptr&"] setup = "return std::weak_ptr();" @@ -321,7 +334,7 @@ definitions = ''' } ] ''' - expect_json_v2 = '''[{ "staticSize": 16, "exclusiveSize": 16, "members":[]}]''' + expect_json_v2 = '''[{ "staticSize": 16, "exclusiveSize": 16, "size": 16, "members":[]}]''' [cases.weak_ptr_int64_present] param_types = ["std::weak_ptr&"] setup = ''' @@ -339,7 +352,7 @@ definitions = ''' } ] ''' - expect_json_v2 = '''[{ "staticSize": 16, "exclusiveSize": 16, "members":[]}]''' + expect_json_v2 = '''[{ "staticSize": 16, "exclusiveSize": 16, "size": 16, "members":[]}]''' [cases.weak_ptr_int64_expired] param_types = ["std::weak_ptr&"] setup = ''' @@ -357,7 +370,7 @@ definitions = ''' } ] ''' - expect_json_v2 = '''[{ "staticSize": 16, "exclusiveSize": 16, "members":[]}]''' + expect_json_v2 = '''[{ "staticSize": 16, "exclusiveSize": 16, "size": 16, "members":[]}]''' [cases.weak_ptr_int64_present_chase] param_types = ["std::weak_ptr&"] cli_options = ["-fchase-raw-pointers"] @@ -376,7 +389,7 @@ definitions = ''' } ] ''' - expect_json_v2 = '''[{ "staticSize": 16, "exclusiveSize": 16, "members":[]}]''' + expect_json_v2 = '''[{ "staticSize": 16, "exclusiveSize": 16, "size": 16, "members":[]}]''' [cases.weak_ptr_int64_expired_chase] param_types = ["std::weak_ptr&"] cli_options = ["-fchase-raw-pointers"] @@ -393,4 +406,4 @@ definitions = ''' } ] ''' - expect_json_v2 = '''[{ "staticSize": 16, "exclusiveSize": 16, "members":[]}]''' + expect_json_v2 = '''[{ "staticSize": 16, "exclusiveSize": 16, "size": 16, "members":[]}]''' diff --git a/test/integration/std_unordered_map_custom_operator.toml b/test/integration/std_unordered_map_custom_operator.toml index 3dcf55d..ea78bff 100644 --- a/test/integration/std_unordered_map_custom_operator.toml +++ b/test/integration/std_unordered_map_custom_operator.toml @@ -66,9 +66,11 @@ includes = ["unordered_map"] ]}]''' expect_json_v2 = '''[{ "staticSize":480, + "exclusiveSize": 0, + "size": 1952, "members":[ - {"name":"m1", "staticSize":56, "exclusiveSize":220, "length":3, "capacity":3}, - {"name":"m2", "staticSize":120, "exclusiveSize":324, "length":5, "capacity":5}, - {"name":"m3", "staticSize":120, "exclusiveSize":364, "length":7, "capacity":7}, - {"name":"m4", "staticSize":184, "exclusiveSize":468, "length":9, "capacity":9} + {"name":"m1", "staticSize":56, "exclusiveSize":220, "size":292, "length":3, "capacity":3}, + {"name":"m2", "staticSize":120, "exclusiveSize":324, "size":444, "length":5, "capacity":5}, + {"name":"m3", "staticSize":120, "exclusiveSize":364, "size":532, "length":7, "capacity":7}, + {"name":"m4", "staticSize":184, "exclusiveSize":468, "size":684, "length":9, "capacity":9} ]}]''' diff --git a/test/integration/std_unordered_multimap_custom_operator.toml b/test/integration/std_unordered_multimap_custom_operator.toml index 37fe213..f36a296 100644 --- a/test/integration/std_unordered_multimap_custom_operator.toml +++ b/test/integration/std_unordered_multimap_custom_operator.toml @@ -66,9 +66,11 @@ includes = ["unordered_map"] ]}]''' expect_json_v2 = '''[{ "staticSize":480, + "exclusiveSize":0, + "size":1952, "members":[ - {"name":"m1", "staticSize":56, "exclusiveSize":220, "length":3, "capacity":3}, - {"name":"m2", "staticSize":120, "exclusiveSize":324, "length":5, "capacity":5}, - {"name":"m3", "staticSize":120, "exclusiveSize":364, "length":7, "capacity":7}, - {"name":"m4", "staticSize":184, "exclusiveSize":468, "length":9, "capacity":9} + {"name":"m1", "staticSize":56, "exclusiveSize":220, "size":292, "length":3, "capacity":3}, + {"name":"m2", "staticSize":120, "exclusiveSize":324, "size":444, "length":5, "capacity":5}, + {"name":"m3", "staticSize":120, "exclusiveSize":364, "size":532, "length":7, "capacity":7}, + {"name":"m4", "staticSize":184, "exclusiveSize":468, "size":684, "length":9, "capacity":9} ]}]''' diff --git a/test/integration/std_unordered_multiset_custom_operator.toml b/test/integration/std_unordered_multiset_custom_operator.toml index ef08dcb..d9ce1cc 100644 --- a/test/integration/std_unordered_multiset_custom_operator.toml +++ b/test/integration/std_unordered_multiset_custom_operator.toml @@ -66,9 +66,11 @@ includes = ["unordered_set"] ]}]''' expect_json_v2 = '''[{ "staticSize":480, + "exclusiveSize":0, + "size":1472, "members":[ - {"name":"m1", "staticSize":56, "exclusiveSize":220, "length":3, "capacity":3}, - {"name":"m2", "staticSize":120, "exclusiveSize":324, "length":5, "capacity":5}, - {"name":"m3", "staticSize":120, "exclusiveSize":364, "length":7, "capacity":7}, - {"name":"m4", "staticSize":184, "exclusiveSize":468, "length":9, "capacity":9} + {"name":"m1", "staticSize":56, "exclusiveSize":220, "size":232, "length":3, "capacity":3}, + {"name":"m2", "staticSize":120, "exclusiveSize":324, "size":344, "length":5, "capacity":5}, + {"name":"m3", "staticSize":120, "exclusiveSize":364, "size":392, "length":7, "capacity":7}, + {"name":"m4", "staticSize":184, "exclusiveSize":468, "size":504, "length":9, "capacity":9} ]}]''' diff --git a/test/integration/std_unordered_set_custom_operator.toml b/test/integration/std_unordered_set_custom_operator.toml index 3c01f6c..797c5ea 100644 --- a/test/integration/std_unordered_set_custom_operator.toml +++ b/test/integration/std_unordered_set_custom_operator.toml @@ -66,9 +66,11 @@ includes = ["unordered_set"] ]}]''' expect_json_v2 = '''[{ "staticSize":480, + "exclusiveSize":0, + "size":1472, "members":[ - {"name":"m1", "staticSize":56, "exclusiveSize":220, "length":3, "capacity":3}, - {"name":"m2", "staticSize":120, "exclusiveSize":324, "length":5, "capacity":5}, - {"name":"m3", "staticSize":120, "exclusiveSize":364, "length":7, "capacity":7}, - {"name":"m4", "staticSize":184, "exclusiveSize":468, "length":9, "capacity":9} + {"name":"m1", "staticSize":56, "exclusiveSize":220, "size":232,"length":3, "capacity":3}, + {"name":"m2", "staticSize":120, "exclusiveSize":324, "size":344, "length":5, "capacity":5}, + {"name":"m3", "staticSize":120, "exclusiveSize":364, "size":392, "length":7, "capacity":7}, + {"name":"m4", "staticSize":184, "exclusiveSize":468, "size":504, "length":9, "capacity":9} ]}]''' diff --git a/test/integration/std_vector.toml b/test/integration/std_vector.toml index d466891..20e00d8 100644 --- a/test/integration/std_vector.toml +++ b/test/integration/std_vector.toml @@ -13,24 +13,24 @@ definitions = ''' param_types = ["const std::vector&"] setup = "return {};" expect_json = '[{"staticSize":24, "dynamicSize":0, "length":0, "capacity":0, "elementStaticSize":4}]' - expect_json_v2 = '[{"staticSize":24, "exclusiveSize":24, "length":0, "capacity":0, "members":[]}]' + expect_json_v2 = '[{"staticSize":24, "exclusiveSize":24, "size": 24, "length":0, "capacity":0, "members":[]}]' [cases.int_some] param_types = ["const std::vector&"] setup = "return {{1,2,3}};" expect_json = '[{"staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4}]' - expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "length":3, "capacity":3, "members":[ - {"staticSize":4, "exclusiveSize":4}, - {"staticSize":4, "exclusiveSize":4}, - {"staticSize":4, "exclusiveSize":4} + expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":36,"length":3, "capacity":3, "members":[ + {"staticSize":4, "exclusiveSize":4, "size":4}, + {"staticSize":4, "exclusiveSize":4, "size":4}, + {"staticSize":4, "exclusiveSize":4, "size":4} ]}]''' [cases.struct_some] param_types = ["const std::vector&"] setup = "return {{{}, {}, {}}};" expect_json = '[{"staticSize":24, "dynamicSize":48, "length":3, "capacity":3, "elementStaticSize":16}]' - expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "length":3, "capacity":3, "members":[ - {"staticSize":16, "exclusiveSize":3}, - {"staticSize":16, "exclusiveSize":3}, - {"staticSize":16, "exclusiveSize":3} + expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":72, "length":3, "capacity":3, "members":[ + {"staticSize":16, "exclusiveSize":3, "size":16}, + {"staticSize":16, "exclusiveSize":3, "size":16}, + {"staticSize":16, "exclusiveSize":3, "size":16} ]}]''' [cases.bool_empty] skip = true # https://github.com/facebookexperimental/object-introspection/issues/14 @@ -46,7 +46,7 @@ definitions = ''' param_types = ["const std::vector>&"] setup = "return {};" expect_json = '[{"staticSize":24, "dynamicSize":0, "length":0, "capacity":0, "elementStaticSize":24}]' - expect_json_v2 = '[{"staticSize":24, "exclusiveSize":24, "length":0, "capacity":0, "members":[]}]' + expect_json_v2 = '[{"staticSize":24, "exclusiveSize":24, "size":24, "length":0, "capacity":0, "members":[]}]' [cases.vector_int_some] param_types = ["const std::vector>&"] setup = "return {{{1,2,3},{4},{5,6}}};" @@ -62,10 +62,10 @@ definitions = ''' {"staticSize":24, "dynamicSize":4, "exclusiveSize":28, "length":1, "capacity":1, "elementStaticSize":4}, {"staticSize":24, "dynamicSize":8, "exclusiveSize":32, "length":2, "capacity":2, "elementStaticSize":4} ]}]''' - expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "length":3, "capacity": 3, "members":[ - {"staticSize":24, "exclusiveSize":24, "length":3, "capacity": 3, "members":[]}, - {"staticSize":24, "exclusiveSize":24, "length":1, "capacity": 1, "members":[]}, - {"staticSize":24, "exclusiveSize":24, "length":2, "capacity": 2, "members":[]} + expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":24, "size":120, "length":3, "capacity": 3, "members":[ + {"staticSize":24, "exclusiveSize":24, "size":36, "length":3, "capacity": 3, "members":[]}, + {"staticSize":24, "exclusiveSize":24, "size":28, "length":1, "capacity": 1, "members":[]}, + {"staticSize":24, "exclusiveSize":24, "size":32, "length":2, "capacity": 2, "members":[]} ]}]''' [cases.reserve] param_types = ["const std::vector&"] @@ -75,8 +75,8 @@ definitions = ''' return ret; ''' expect_json = '[{"staticSize":24, "dynamicSize":40, "exclusiveSize":64, "length":3, "capacity":10, "elementStaticSize":4}]' - expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":52, "length":3, "capacity":10, "members":[ - {"staticSize":4, "exclusiveSize":4}, - {"staticSize":4, "exclusiveSize":4}, - {"staticSize":4, "exclusiveSize":4} + expect_json_v2 = '''[{"staticSize":24, "exclusiveSize":52, "size":64, "length":3, "capacity":10, "members":[ + {"staticSize":4, "exclusiveSize":4, "size":4}, + {"staticSize":4, "exclusiveSize":4, "size":4}, + {"staticSize":4, "exclusiveSize":4, "size":4} ]}]''' diff --git a/test/integration/std_vector_del_allocator.toml b/test/integration/std_vector_del_allocator.toml index 934bd34..32edcc2 100644 --- a/test/integration/std_vector_del_allocator.toml +++ b/test/integration/std_vector_del_allocator.toml @@ -60,18 +60,19 @@ includes = ["vector"] expect_json_v2 = '''[{ "staticSize":48, "exclusiveSize":0, + "size":60, "members":[ - {"name":"v1", "staticSize":24, "exclusiveSize":24, "length":1, "capacity":1, "members":[ - {"name":"[]", "staticSize":4, "exclusiveSize":0, "members":[ - {"name":"a", "staticSize":4, "exclusiveSize":4, "members":[]} + {"name":"v1", "staticSize":24, "exclusiveSize":24, "size": 28, "length":1, "capacity":1, "members":[ + {"name":"[]", "staticSize":4, "exclusiveSize":0, "size": 4, "members":[ + {"name":"a", "staticSize":4, "exclusiveSize":4, "size": 4, "members":[]} ]} ]}, - {"name":"v2", "staticSize":24, "exclusiveSize":24, "length":2, "capacity":2, "members":[ - {"name":"[]", "staticSize":4, "exclusiveSize":0, "members":[ - {"name":"b", "staticSize":4, "exclusiveSize":4, "members":[]} + {"name":"v2", "staticSize":24, "exclusiveSize":24, "size": 32, "length":2, "capacity":2, "members":[ + {"name":"[]", "staticSize":4, "exclusiveSize":0, "size": 4, "members":[ + {"name":"b", "staticSize":4, "exclusiveSize":4, "size": 4, "members":[]} ]}, - {"name":"[]", "staticSize":4, "exclusiveSize":0, "members":[ - {"name":"b", "staticSize":4, "exclusiveSize":4, "members":[]} + {"name":"[]", "staticSize":4, "exclusiveSize":0, "size": 4, "members":[ + {"name":"b", "staticSize":4, "exclusiveSize":4, "size": 4, "members":[]} ]} ]} ] diff --git a/test/integration/templates.toml b/test/integration/templates.toml index b02cfc8..8be4dc9 100644 --- a/test/integration/templates.toml +++ b/test/integration/templates.toml @@ -53,10 +53,12 @@ definitions = ''' "typeName":"ns_templates::TemplatedClass1 > >", "staticSize":24, "exclusiveSize":0, + "size":24, "members":[{ "typeName":"std::vector>", "staticSize":24, "exclusiveSize":24, + "size":24, "length":0, "capacity":0 }]}]''' @@ -90,9 +92,11 @@ definitions = ''' "typeName":"ns_templates::TemplatedClassVal<3>", "staticSize":12, "exclusiveSize":0, + "size":12, "members":[{ "staticSize":12, "exclusiveSize":0, + "size":12, "length":3, "capacity":3 }]}]''' diff --git a/test/integration/thrift_unions.toml b/test/integration/thrift_unions.toml index 5f0ba1f..651869b 100644 --- a/test/integration/thrift_unions.toml +++ b/test/integration/thrift_unions.toml @@ -37,9 +37,10 @@ namespace cpp2 { expect_json_v2 = '''[{ "staticSize":8, "exclusiveSize":0, + "size":8, "members":[ - {"typeNames":["storage_type"], "name":"value_", "staticSize":4, "exclusiveSize":4}, - {"typeNames":["underlying_type_t", "type", "int32_t"], "name":"type_", "staticSize":4, "exclusiveSize":4} + {"typeNames":["storage_type"], "name":"value_", "staticSize":4, "exclusiveSize":4, "size":4}, + {"typeNames":["underlying_type_t", "type", "int32_t"], "name":"type_", "staticSize":4, "exclusiveSize":4, "size":4} ]}]''' [cases.dynamic_int] param_types = ["const cpp2::DynamicUnion&"] @@ -58,9 +59,10 @@ namespace cpp2 { expect_json_v2 = '''[{ "staticSize":32, "exclusiveSize":4, + "size":32, "members":[ - {"typeNames":["storage_type"], "name":"value_", "staticSize":24, "exclusiveSize":24}, - {"typeNames":["underlying_type_t", "type", "int32_t"], "name":"type_", "staticSize":4, "exclusiveSize":4} + {"typeNames":["storage_type"], "name":"value_", "staticSize":24, "exclusiveSize":24, "size":24}, + {"typeNames":["underlying_type_t", "type", "int32_t"], "name":"type_", "staticSize":4, "exclusiveSize":4, "size":4} ]}]''' [cases.dynamic_vec] param_types = ["const cpp2::DynamicUnion&"] @@ -79,7 +81,8 @@ namespace cpp2 { expect_json_v2 = '''[{ "staticSize":32, "exclusiveSize":4, + "size":32, "members":[ - {"typeNames":["storage_type"], "name":"value_", "staticSize":24, "exclusiveSize":24}, - {"typeNames":["underlying_type_t", "type", "int32_t"], "name":"type_", "staticSize":4, "exclusiveSize":4} + {"typeNames":["storage_type"], "name":"value_", "staticSize":24, "exclusiveSize":24, "size":24}, + {"typeNames":["underlying_type_t", "type", "int32_t"], "name":"type_", "staticSize":4, "exclusiveSize":4, "size":4} ]}]''' diff --git a/test/integration/typedefed_parent.toml b/test/integration/typedefed_parent.toml index 72c4a57..25631f9 100644 --- a/test/integration/typedefed_parent.toml +++ b/test/integration/typedefed_parent.toml @@ -30,9 +30,10 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize":48, "exclusiveSize":0, + "size":80, "members":[ - {"name":"a", "staticSize":24, "exclusiveSize":24, "length":3, "capacity":3}, - {"name":"b", "staticSize":24, "exclusiveSize":24, "length":5, "capacity":5} + {"name":"a", "staticSize":24, "exclusiveSize":24, "length":3, "capacity":3, "size":36}, + {"name":"b", "staticSize":24, "exclusiveSize":24, "length":5, "capacity":5, "size":44} ]}]''' [cases.multilevel_typedef_parent] param_types = ["const Bar_2&"] @@ -50,7 +51,8 @@ definitions = ''' expect_json_v2 = '''[{ "staticSize":48, "exclusiveSize":0, + "size":80, "members":[ - {"name":"a", "staticSize":24, "exclusiveSize":24, "length":3, "capacity":3}, - {"name":"c", "staticSize":24, "exclusiveSize":24, "length":5, "capacity":5} + {"name":"a", "staticSize":24, "exclusiveSize":24, "length":3, "capacity":3, "size":36}, + {"name":"c", "staticSize":24, "exclusiveSize":24, "length":5, "capacity":5, "size":44} ]}]''' diff --git a/test/integration/unions.toml b/test/integration/unions.toml index 42341de..66df45e 100644 --- a/test/integration/unions.toml +++ b/test/integration/unions.toml @@ -45,17 +45,17 @@ definitions = ''' param_types = ["const MyUnion&"] setup = "return 123;" expect_json = '[{"staticSize":56, "dynamicSize":0, "exclusiveSize":56, "NOT":"members"}]' - expect_json_v2 = '[{"staticSize":56, "dynamicSize":0, "exclusiveSize":56, "members":[]}]' + expect_json_v2 = '[{"staticSize":56, "dynamicSize":0, "exclusiveSize":56, "size":56, "members":[]}]' [cases.vector] param_types = ["const MyUnion&"] setup = "return std::vector{1,2,3};" expect_json = '[{"staticSize":56, "dynamicSize":0, "exclusiveSize":56, "NOT":"members"}]' - expect_json_v2 = '[{"staticSize":56, "dynamicSize":0, "exclusiveSize":56, "members":[]}]' + expect_json_v2 = '[{"staticSize":56, "dynamicSize":0, "exclusiveSize":56, "size":56, "members":[]}]' [cases.unordered_map] param_types = ["const MyUnion&"] setup = 'return std::unordered_map{{"a", "b"}, {"c","d"}};' expect_json = '[{"staticSize":56, "dynamicSize":0, "exclusiveSize":56, "NOT":"members"}]' - expect_json_v2 = '[{"staticSize":56, "dynamicSize":0, "exclusiveSize":56, "members":[]}]' + expect_json_v2 = '[{"staticSize":56, "dynamicSize":0, "exclusiveSize":56, "size":56, "members":[]}]' [cases.alignment] # Wrap the union in a pair as a way of inferring its alignment @@ -67,9 +67,9 @@ definitions = ''' {"staticSize":56, "dynamicSize":0, "exclusiveSize":56, "NOT":"members"} ]}]''' expect_json_v2 = '''[ - {"staticSize":64, "dynamicSize":0, "exclusiveSize":7, "members":[ - {"staticSize":1, "dynamicSize":0, "exclusiveSize":1}, - {"staticSize":56, "dynamicSize":0, "exclusiveSize":56, "members":[]} + {"staticSize":64, "dynamicSize":0, "exclusiveSize":7, "size":64, "members":[ + {"staticSize":1, "dynamicSize":0, "exclusiveSize":1, "size":1}, + {"staticSize":56, "dynamicSize":0, "exclusiveSize":56, "size":56, "members":[]} ]}]''' [cases.tagged_int] @@ -81,9 +81,9 @@ definitions = ''' {"name":"tag", "staticSize":1, "dynamicSize":0, "exclusiveSize":1, "NOT":"members"} ]}]''' expect_json_v2 = '''[ - {"staticSize":64, "dynamicSize":0, "exclusiveSize":7, "members":[ - {"name":"storage", "staticSize":56, "dynamicSize":0, "exclusiveSize":56, "members":[]}, - {"name":"tag", "staticSize":1, "dynamicSize":0, "exclusiveSize":1, "members":[]} + {"staticSize":64, "dynamicSize":0, "exclusiveSize":7, "size":64, "members":[ + {"name":"storage", "staticSize":56, "dynamicSize":0, "exclusiveSize":56, "size":56, "members":[]}, + {"name":"tag", "staticSize":1, "dynamicSize":0, "exclusiveSize":1, "size":1, "members":[]} ]}]''' [cases.tagged_vector] param_types = ["const TaggedUnion&"] @@ -94,9 +94,9 @@ definitions = ''' {"name":"tag", "staticSize":1, "dynamicSize":0, "exclusiveSize":1, "NOT":"members"} ]}]''' expect_json_v2 = '''[ - {"staticSize":64, "dynamicSize":0, "exclusiveSize":7, "members":[ - {"name":"storage", "staticSize":56, "dynamicSize":0, "exclusiveSize":56, "members":[]}, - {"name":"tag", "staticSize":1, "dynamicSize":0, "exclusiveSize":1, "members":[]} + {"staticSize":64, "dynamicSize":0, "exclusiveSize":7, "size":64, "members":[ + {"name":"storage", "staticSize":56, "dynamicSize":0, "exclusiveSize":56, "size":56, "members":[]}, + {"name":"tag", "staticSize":1, "dynamicSize":0, "exclusiveSize":1, "size":1, "members":[]} ]}]''' [cases.tagged_unordered_map] param_types = ["const TaggedUnion&"] @@ -107,7 +107,7 @@ definitions = ''' {"name":"tag", "staticSize":1, "dynamicSize":0, "exclusiveSize":1, "NOT":"members"} ]}]''' expect_json_v2 = '''[ - {"staticSize":64, "dynamicSize":0, "exclusiveSize":7, "members":[ - {"name":"storage", "staticSize":56, "dynamicSize":0, "exclusiveSize":56, "members":[]}, - {"name":"tag", "staticSize":1, "dynamicSize":0, "exclusiveSize":1, "members":[]} + {"staticSize":64, "dynamicSize":0, "exclusiveSize":7, "size":64, "members":[ + {"name":"storage", "staticSize":56, "dynamicSize":0, "exclusiveSize":56, "size":56, "members":[]}, + {"name":"tag", "staticSize":1, "dynamicSize":0, "exclusiveSize":1, "size":1, "members":[]} ]}]'''