2022-12-19 14:37:51 +00:00
|
|
|
includes = ["memory", "optional"]
|
|
|
|
|
|
|
|
definitions = '''
|
|
|
|
struct IncompleteType;
|
|
|
|
struct IncompleteTypeContainer {
|
|
|
|
IncompleteType *ptrundef;
|
|
|
|
// std::unique_ptr<IncompleteType> unundef; // std::unique_ptr requires its template param to have a size
|
|
|
|
char __makePad1;
|
|
|
|
std::shared_ptr<IncompleteType> shundef;
|
|
|
|
char __makePad2;
|
|
|
|
std::optional<std::shared_ptr<IncompleteType>> shoptundef;
|
|
|
|
char __makePad3;
|
|
|
|
std::optional<IncompleteType *> optundef;
|
|
|
|
};
|
|
|
|
|
|
|
|
void incomplete_type_deleter(IncompleteType *ptr) {
|
|
|
|
::operator delete(ptr);
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
[cases]
|
|
|
|
[cases.raw]
|
2022-12-30 22:41:09 +00:00
|
|
|
oid_skip = "oid codegen fails on this" # https://github.com/facebookexperimental/object-introspection/issues/17
|
2024-01-16 11:15:05 +00:00
|
|
|
oil_skip = "oil codegen fails on top level incomplete objects" # https://github.com/facebookexperimental/object-introspection/issues/459
|
2022-12-19 14:37:51 +00:00
|
|
|
param_types = ["IncompleteType*"]
|
|
|
|
setup = "return static_cast<IncompleteType*>(::operator new(5));"
|
2024-01-16 11:15:05 +00:00
|
|
|
features = ["chase-raw-pointers"]
|
2022-12-19 14:37:51 +00:00
|
|
|
expect_json = '''[{
|
2024-01-16 11:15:05 +00:00
|
|
|
"typeName": "IncompleteType",
|
|
|
|
"staticSize": 0,
|
2022-12-19 14:37:51 +00:00
|
|
|
"dynamicSize": 0,
|
|
|
|
"NOT": "members"
|
|
|
|
}]'''
|
|
|
|
[cases.raw_no_follow]
|
2024-01-16 11:15:05 +00:00
|
|
|
oid_skip = "oid codegen fails on this" # https://github.com/facebookexperimental/object-introspection/issues/17
|
|
|
|
oil_skip = "oil codegen fails on top level incomplete objects" # https://github.com/facebookexperimental/object-introspection/issues/459
|
2022-12-19 14:37:51 +00:00
|
|
|
param_types = ["IncompleteType*"]
|
|
|
|
setup = "return static_cast<IncompleteType*>(::operator new(5));"
|
|
|
|
expect_json = '''[{
|
2024-01-16 11:15:05 +00:00
|
|
|
"typeName": "IncompleteType",
|
|
|
|
"staticSize": 0,
|
2022-12-19 14:37:51 +00:00
|
|
|
"dynamicSize": 0,
|
|
|
|
"NOT": "members"
|
|
|
|
}]'''
|
|
|
|
[cases.raw_null]
|
2024-01-16 11:15:05 +00:00
|
|
|
oid_skip = "oid codegen fails on this" # https://github.com/facebookexperimental/object-introspection/issues/17
|
|
|
|
oil_skip = "oil codegen fails on top level incomplete objects" # https://github.com/facebookexperimental/object-introspection/issues/459
|
2022-12-19 14:37:51 +00:00
|
|
|
param_types = ["IncompleteType*"]
|
|
|
|
setup = "return nullptr;"
|
|
|
|
expect_json = '''[{
|
2024-01-16 11:15:05 +00:00
|
|
|
"typeName": "IncompleteType",
|
|
|
|
"staticSize": 0,
|
2022-12-19 14:37:51 +00:00
|
|
|
"dynamicSize": 0,
|
|
|
|
"NOT": "members"
|
|
|
|
}]'''
|
|
|
|
|
|
|
|
[cases.unique_ptr]
|
|
|
|
param_types = ["const std::unique_ptr<IncompleteType, decltype(&incomplete_type_deleter)>&"]
|
|
|
|
setup = '''
|
|
|
|
auto raw_ptr = static_cast<IncompleteType*>(::operator new(5));
|
|
|
|
return std::unique_ptr<IncompleteType, decltype(&incomplete_type_deleter)>(
|
|
|
|
raw_ptr, &incomplete_type_deleter);
|
|
|
|
'''
|
|
|
|
expect_json = '[{"staticSize":16, "dynamicSize":0, "NOT":"members"}]'
|
2024-01-04 17:01:52 +00:00
|
|
|
expect_json_v2 = '[{"staticSize":16, "exclusiveSize":16}]'
|
2022-12-19 14:37:51 +00:00
|
|
|
[cases.unique_ptr_null]
|
|
|
|
param_types = ["const std::unique_ptr<IncompleteType, decltype(&incomplete_type_deleter)>&"]
|
|
|
|
setup = '''
|
|
|
|
return std::unique_ptr<IncompleteType, decltype(&incomplete_type_deleter)>(
|
|
|
|
nullptr, &incomplete_type_deleter);
|
|
|
|
'''
|
|
|
|
expect_json = '[{"staticSize":16, "dynamicSize":0, "NOT":"members"}]'
|
2024-01-04 17:01:52 +00:00
|
|
|
expect_json_v2 = '[{"staticSize":16, "exclusiveSize":16}]'
|
2022-12-19 14:37:51 +00:00
|
|
|
|
|
|
|
[cases.shared_ptr]
|
|
|
|
param_types = ["const std::shared_ptr<IncompleteType>&"]
|
|
|
|
setup = '''
|
|
|
|
auto raw_ptr = static_cast<IncompleteType*>(::operator new(5));
|
|
|
|
return std::shared_ptr<IncompleteType>(raw_ptr , &incomplete_type_deleter);
|
|
|
|
'''
|
|
|
|
expect_json = '[{"staticSize":16, "dynamicSize":0, "NOT":"members"}]'
|
2024-01-04 17:01:52 +00:00
|
|
|
expect_json_v2 = '[{"staticSize":16, "exclusiveSize":16}]'
|
2022-12-19 14:37:51 +00:00
|
|
|
[cases.shared_ptr_null]
|
|
|
|
param_types = ["const std::shared_ptr<IncompleteType>"]
|
|
|
|
setup = "return nullptr;"
|
|
|
|
expect_json = '[{"staticSize":16, "dynamicSize":0, "NOT":"members"}]'
|
2024-01-04 17:01:52 +00:00
|
|
|
expect_json_v2 = '[{"staticSize":16, "exclusiveSize":16}]'
|
2022-12-19 14:37:51 +00:00
|
|
|
|
|
|
|
[cases.containing_struct]
|
|
|
|
param_types = ["const IncompleteTypeContainer&"]
|
|
|
|
setup = "return IncompleteTypeContainer{};"
|
2024-01-16 11:15:05 +00:00
|
|
|
features = ["chase-raw-pointers"]
|
2022-12-19 14:37:51 +00:00
|
|
|
expect_json = '''[{
|
|
|
|
"staticSize": 88,
|
|
|
|
"dynamicSize": 0,
|
|
|
|
"members": [
|
|
|
|
{ "name": "ptrundef", "staticSize": 8, "dynamicSize": 0 },
|
|
|
|
{ "name": "__makePad1", "staticSize": 1, "dynamicSize": 0 },
|
|
|
|
{ "name": "shundef", "staticSize": 16, "dynamicSize": 0 },
|
|
|
|
{ "name": "__makePad2", "staticSize": 1, "dynamicSize": 0 },
|
|
|
|
{ "name": "shoptundef",
|
|
|
|
"staticSize": 24,
|
|
|
|
"dynamicSize": 0,
|
|
|
|
"length": 0,
|
|
|
|
"capacity": 1,
|
|
|
|
"elementStaticSize": 16
|
|
|
|
},
|
|
|
|
{ "name": "__makePad3", "staticSize": 1, "dynamicSize": 0 },
|
|
|
|
{ "name": "optundef",
|
|
|
|
"staticSize": 16,
|
|
|
|
"dynamicSize": 0,
|
|
|
|
"length": 0,
|
|
|
|
"capacity": 1,
|
|
|
|
"elementStaticSize": 8
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}]'''
|
2024-01-16 19:10:16 +00:00
|
|
|
expect_json_v2 = '''[{
|
|
|
|
"staticSize": 88,
|
|
|
|
"exclusiveSize": 21,
|
|
|
|
"size": 88,
|
|
|
|
"members": [
|
|
|
|
{ "name": "ptrundef", "staticSize": 8, "exclusiveSize": 8, "size": 8 },
|
|
|
|
{ "name": "__makePad1", "staticSize": 1, "exclusiveSize": 1, "size": 1 },
|
|
|
|
{ "name": "shundef", "staticSize": 16, "exclusiveSize": 16, "size": 16 },
|
|
|
|
{ "name": "__makePad2", "staticSize": 1, "exclusiveSize": 1, "size": 1 },
|
|
|
|
{ "name": "shoptundef",
|
|
|
|
"staticSize": 24,
|
|
|
|
"exclusiveSize": 24,
|
|
|
|
"size": 24,
|
|
|
|
"length": 0,
|
|
|
|
"capacity": 1
|
|
|
|
},
|
|
|
|
{ "name": "__makePad3", "staticSize": 1, "exclusiveSize": 1, "size": 1 },
|
|
|
|
{ "name": "optundef",
|
|
|
|
"staticSize": 16,
|
|
|
|
"exclusiveSize": 16,
|
|
|
|
"size": 16,
|
|
|
|
"length": 0,
|
|
|
|
"capacity": 1
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}]'''
|
2024-01-04 17:01:52 +00:00
|
|
|
|
|
|
|
[cases.containing_struct_no_follow]
|
|
|
|
param_types = ["const IncompleteTypeContainer&"]
|
|
|
|
setup = "return IncompleteTypeContainer{};"
|
|
|
|
expect_json = '''[{
|
|
|
|
"staticSize": 88,
|
|
|
|
"members": [
|
|
|
|
{ "name": "ptrundef", "staticSize": 8 },
|
|
|
|
{ "name": "__makePad1", "staticSize": 1 },
|
|
|
|
{ "name": "shundef", "staticSize": 16 },
|
|
|
|
{ "name": "__makePad2", "staticSize": 1 },
|
|
|
|
{ "name": "shoptundef",
|
|
|
|
"staticSize": 24,
|
|
|
|
"length": 0,
|
|
|
|
"capacity": 1
|
|
|
|
},
|
|
|
|
{ "name": "__makePad3", "staticSize": 1 },
|
|
|
|
{ "name": "optundef",
|
|
|
|
"staticSize": 16,
|
|
|
|
"length": 0,
|
|
|
|
"capacity": 1
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}]'''
|