tbv2: calculate total memory footprint

Add the option to calculate total size (inclusive size) by wrapping the
existing iterator. This change provides a new iterator, `SizedIterator`, which
wraps an existing iterator and adds a new field `size` to the output element.

This is achieved with a two pass algorithm on the existing iterator:
1. Gather metadata for each element. This includes the total size up until that
   element and the range of elements that should be included in the size.
2. Return the result from the underlying iterator with the additional
   field.

This algorithm is `O(N)` time on the number of elements in the iterator and
`O(N)` time, storing 16 bytes per element. This isn't super expensive but is a
lot more than the current algorithm which requires close to constant space.
Because of this I've implemented it as a wrapper on the iterator rather than on
by default, though it is now on in every one of our integration test cases.

Test plan:
- Added to the integration tests for full coverage.
This commit is contained in:
Jake Hillion 2024-01-03 17:30:31 +00:00 committed by Jake Hillion
parent 6c90103278
commit 71e734b120
50 changed files with 795 additions and 454 deletions

View File

@ -17,8 +17,10 @@
#define INCLUDED_OI_EXPORTERS_JSON_H 1
#include <oi/IntrospectionResult.h>
#include <oi/result/SizedResult.h>
#include <ostream>
#include <string_view>
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 <typename Res>
void print(const Res& r) {
auto begin = r.begin();
auto end = r.end();
return print(begin, end);
}
template <typename It>
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 <typename Rng>
void printListField(std::string_view name,
const Rng& range,
std::string_view indent);
void printFields(const result::Element&, std::string_view indent);
template <typename El>
void printFields(const result::SizedElement<El>&, 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 <typename Rng>
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 <typename El>
void Json::printFields(const result::SizedElement<El>& 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<result::Element::Scalar>(&el.data)) {
printUnsignedField("data", s->n, indent);
} else if (const auto* p = std::get_if<result::Element::Pointer>(&el.data)) {
printPointerField("data", p->p, indent);
} else if (const auto* str = std::get_if<std::string>(&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 <typename It>
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

View File

@ -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 <utility>
#include <vector>
#include "SizedResult.h"
namespace oi::result {
template <typename Res>
SizedResult<Res>::SizedResult(Res res) : res_{std::move(res)} {
}
template <typename Res>
typename SizedResult<Res>::const_iterator SizedResult<Res>::begin() const {
return ++const_iterator{res_.begin(), res_.end()};
}
template <typename Res>
typename SizedResult<Res>::const_iterator SizedResult<Res>::end() const {
return res_.end();
}
template <typename Res>
SizedResult<Res>::const_iterator::const_iterator(It it, const It& end)
: data_{it} {
struct StackEntry {
size_t index;
size_t depth;
};
std::vector<StackEntry> 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 <typename Res>
SizedResult<Res>::const_iterator::const_iterator(It end) : data_{end} {
}
template <typename Res>
typename SizedResult<Res>::const_iterator
SizedResult<Res>::const_iterator::operator++(int) {
auto old = *this;
operator++();
return old;
}
template <typename Res>
typename SizedResult<Res>::const_iterator&
SizedResult<Res>::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 <typename Res>
const typename SizedResult<Res>::Element&
SizedResult<Res>::const_iterator::operator*() const {
return *next_;
}
template <typename Res>
const typename SizedResult<Res>::Element*
SizedResult<Res>::const_iterator::operator->() const {
return &*next_;
}
template <typename Res>
bool SizedResult<Res>::const_iterator::operator==(
const SizedResult<Res>::const_iterator& that) const {
return this->data_ == that.data_;
}
template <typename Res>
bool SizedResult<Res>::const_iterator::operator!=(
const SizedResult<Res>::const_iterator& that) const {
return !(*this == that);
}
template <typename El>
SizedElement<El>::SizedElement(const El& el, size_t size_)
: El{el}, size{size_} {
}
template <typename El>
const El& SizedElement<El>::inner() const {
return static_cast<const El&>(*this);
}
} // namespace oi::result

View File

@ -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 <cstddef>
#include <optional>
#include <type_traits>
#include <vector>
namespace oi::result {
template <typename El>
struct SizedElement : public El {
SizedElement(const El& el, size_t size);
const El& inner() const;
size_t size;
};
template <typename Res>
class SizedResult {
private:
using It = std::decay_t<decltype(std::declval<Res&>().begin())>;
using ParentEl = std::decay_t<decltype(std::declval<It&>().operator*())>;
public:
using Element = SizedElement<ParentEl>;
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<SizeHelper> helpers_;
size_t count_ = 0;
std::optional<Element> next_;
};
SizedResult(Res res);
const_iterator begin() const;
const_iterator end() const;
private:
Res res_;
};
} // namespace oi::result
#include "SizedResult-inl.h"
#endif

View File

@ -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)

View File

@ -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 <oi/exporters/Json.h>
#include <algorithm>
#include <stdexcept>
#include <variant>
template <class>
inline constexpr bool always_false_v = false;
namespace oi::exporters {
namespace {
template <typename It>
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<result::Element::Scalar>(&it->data)) {
out_ << tab << "\"data\":" << space << s->n << ',' << endl << indent;
} else if (auto* p = std::get_if<result::Element::Pointer>(&it->data)) {
out_ << tab << "\"data\":" << space << "\"0x" << std::hex << p->p
<< std::dec << "\"," << endl
<< indent;
} else if (auto* str = std::get_if<std::string>(&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

View File

@ -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})

View File

@ -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"]}
]
}]'''

View File

@ -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"

View File

@ -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<ScopedEnumUint8, uint8_t>"]
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}
]}
]'''

View File

@ -39,20 +39,20 @@ definitions = '''
param_types = ["const std::array<int, static_cast<size_t>(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<MyNS::ScopedEnum::One>&"]
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<MyNS::EnumWithGaps::Twenty>&"]
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<MyNS::EnumWithGaps::MinusTwo>&"]
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<MyNS::UNSCOPED_ENUM>&"]
@ -61,4 +61,4 @@ definitions = '''
param_types = ["const std::array<int, MyNS::ONE>&"]
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}]'

View File

@ -28,6 +28,7 @@ includes = ["folly/FBString.h", "utility"]
"typeNames": ["folly::basic_fbstring<int8_t, std::char_traits<int8_t>, std::allocator<int8_t>, folly::fbstring_core<int8_t>>"],
"staticSize": 24,
"exclusiveSize": 24,
"size": 24,
"length": 0,
"capacity": 23
}]'''
@ -60,6 +61,7 @@ includes = ["folly/FBString.h", "utility"]
"typeNames": ["folly::basic_fbstring<int8_t, std::char_traits<int8_t>, std::allocator<int8_t>, folly::fbstring_core<int8_t>>"],
"staticSize": 24,
"exclusiveSize": 24,
"size": 24,
"length": 6,
"capacity": 23
}]'''
@ -92,6 +94,7 @@ includes = ["folly/FBString.h", "utility"]
"typeNames": ["folly::basic_fbstring<int8_t, std::char_traits<int8_t>, std::allocator<int8_t>, folly::fbstring_core<int8_t>>"],
"staticSize": 24,
"exclusiveSize": 50,
"size": 50,
"length": 26,
"capacity": 26
}]'''
@ -124,6 +127,7 @@ includes = ["folly/FBString.h", "utility"]
"typeNames": ["folly::basic_fbstring<int8_t, std::char_traits<int8_t>, std::allocator<int8_t>, folly::fbstring_core<int8_t>>"],
"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<int8_t, std::char_traits<int8_t>, std::allocator<int8_t>, folly::fbstring_core<int8_t>>"],
"staticSize": 24,
"exclusiveSize": 1056,
"size": 1056,
"length": 1024,
"capacity": 1024
}, {
"typeNames": ["folly::basic_fbstring<int8_t, std::char_traits<int8_t>, std::allocator<int8_t>, folly::fbstring_core<int8_t>>"],
"staticSize": 24,
"exclusiveSize": 24,
"size": 24,
"length": 1024,
"capacity": 1024
}

View File

@ -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}
]
}]
}]'''

View File

@ -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}
]}]'''

View File

@ -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}
]
}]
}]'''

View File

@ -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}
]}]'''

View File

@ -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}
]
}]
}]'''

View File

@ -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}
]}]'''

View File

@ -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}
]
}]
}]'''

View File

@ -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}
]}]'''

View File

@ -4,23 +4,23 @@ includes = ["folly/small_vector.h", "vector"]
param_types = ["const folly::small_vector<int>&"]
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<int>&"]
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<int>&"]
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<std::vector<int>, 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<std::vector<int>, 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<std::vector<int>, 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<int, 0>&"]
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}]'

View File

@ -4,19 +4,19 @@ includes = ["folly/sorted_vector_types.h", "vector"]
param_types = ["const folly::sorted_vector_map<int, int>&"]
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<int, int>&"]
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}
]}
]}]'''

View File

@ -40,6 +40,7 @@ def add_headers(f, custom_headers, thrift_headers):
#include <oi/oi.h>
#include <oi/exporters/Json.h>
#include <oi/result/SizedResult.h>
"""
)
@ -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(

View File

@ -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"}
]}]'''

View File

@ -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}
]}]'''

View File

@ -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}
]}]'''

View File

@ -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
}]'''

View File

@ -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"

View File

@ -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}]'

View File

@ -365,6 +365,8 @@ void IntegrationBase::compare_json(const bpt::ptree& expected_json,
}
} else if (key == "dynamicSize" && val.get_value<size_t>() == 0) {
continue;
} else if (key == "size") {
continue;
}
ADD_FAILURE() << "Expected key not found in output: " << curr_key;

View File

@ -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
}]'''

View File

@ -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
}]'''

View File

@ -13,30 +13,30 @@ definitions = '''
param_types = ["const std::list<int>&"]
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<int>&"]
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<SimpleStruct>&"]
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<std::list<int>>&"]
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<std::list<int>>&"]
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}
]}]'''

View File

@ -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}
]}]'''

View File

@ -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}
]}]'''

View File

@ -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}
]}]'''

View File

@ -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}
]}]'''

View File

@ -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
}

View File

@ -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<uint64_t, uint64_t*>&"]
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<uint64_t, std::allocator<uint64_t>>"], "staticSize": 24, "exclusiveSize": 24},
{"typeNames": ["std::vector<uint64_t, std::allocator<uint64_t>>"], "staticSize": 24, "exclusiveSize": 24}
{"staticSize": 48, "exclusiveSize": 0, "size": 104, "members": [
{"typeNames": ["std::vector<uint64_t, std::allocator<uint64_t>>"], "staticSize": 24, "exclusiveSize": 24, "size": 48},
{"typeNames": ["std::vector<uint64_t, std::allocator<uint64_t>>"], "staticSize": 24, "exclusiveSize": 24, "size": 56}
]}
]'''

View File

@ -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}
]}]'''

View File

@ -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<void>&"]
setup = "return std::weak_ptr<void>();"
@ -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<std::uint64_t>&"]
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<std::uint64_t>&"]
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<std::uint64_t>&"]
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<std::uint64_t>&"]
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":[]}]'''

View File

@ -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}
]}]'''

View File

@ -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}
]}]'''

View File

@ -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}
]}]'''

View File

@ -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}
]}]'''

View File

@ -13,24 +13,24 @@ definitions = '''
param_types = ["const std::vector<int>&"]
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<int>&"]
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<SimpleStruct>&"]
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<std::vector<int>>&"]
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<std::vector<int>>&"]
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<int>&"]
@ -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}
]}]'''

View File

@ -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":[]}
]}
]}
]

View File

@ -53,10 +53,12 @@ definitions = '''
"typeName":"ns_templates::TemplatedClass1<std::vector<int, std::allocator<int> > >",
"staticSize":24,
"exclusiveSize":0,
"size":24,
"members":[{
"typeName":"std::vector<int32_t, std::allocator<int32_t>>",
"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
}]}]'''

View File

@ -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<cpp2::StaticUnion::Type>", "type", "int32_t"], "name":"type_", "staticSize":4, "exclusiveSize":4}
{"typeNames":["storage_type"], "name":"value_", "staticSize":4, "exclusiveSize":4, "size":4},
{"typeNames":["underlying_type_t<cpp2::StaticUnion::Type>", "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<cpp2::DynamicUnion::Type>", "type", "int32_t"], "name":"type_", "staticSize":4, "exclusiveSize":4}
{"typeNames":["storage_type"], "name":"value_", "staticSize":24, "exclusiveSize":24, "size":24},
{"typeNames":["underlying_type_t<cpp2::DynamicUnion::Type>", "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<cpp2::DynamicUnion::Type>", "type", "int32_t"], "name":"type_", "staticSize":4, "exclusiveSize":4}
{"typeNames":["storage_type"], "name":"value_", "staticSize":24, "exclusiveSize":24, "size":24},
{"typeNames":["underlying_type_t<cpp2::DynamicUnion::Type>", "type", "int32_t"], "name":"type_", "staticSize":4, "exclusiveSize":4, "size":4}
]}]'''

View File

@ -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}
]}]'''

View File

@ -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<std::string, std::string>{{"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":[]}
]}]'''