2022-12-19 14:37:51 +00:00
|
|
|
definitions = '''
|
|
|
|
struct Foo {
|
|
|
|
int *a;
|
|
|
|
bool b;
|
|
|
|
long c;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Bar {
|
|
|
|
int *a;
|
|
|
|
bool b;
|
|
|
|
long c;
|
|
|
|
Foo d;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* The names generated for parent's padding use their own index,
|
|
|
|
* which can conflict with the child's generated name.
|
|
|
|
* We must ensure there are no such conflicts, even across multiple parents.
|
|
|
|
*/
|
|
|
|
struct PaddedGrandParentA {
|
|
|
|
bool x;
|
|
|
|
short y;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PaddedGrandParentB {
|
|
|
|
bool x;
|
|
|
|
int y;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PaddedParentA : public PaddedGrandParentA {
|
|
|
|
bool a;
|
|
|
|
int b;
|
|
|
|
short c;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PaddedParentB : public PaddedGrandParentA, public PaddedGrandParentB {
|
|
|
|
bool a;
|
|
|
|
long b;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Create lots of padding holes so there is a colision between the child and
|
|
|
|
* its parent generated padding names.
|
|
|
|
*/
|
|
|
|
struct PaddedChild : public PaddedParentA, public PaddedParentB {
|
|
|
|
bool a;
|
|
|
|
long long b;
|
|
|
|
bool c; short d;
|
|
|
|
bool e; short f;
|
|
|
|
bool g; short h;
|
|
|
|
bool i; short j;
|
|
|
|
bool k; short l;
|
|
|
|
bool m; short n;
|
|
|
|
bool o; short p;
|
|
|
|
bool q; short r;
|
|
|
|
bool s; short t;
|
|
|
|
bool u; short v;
|
|
|
|
bool w; short x;
|
|
|
|
bool y; short z;
|
|
|
|
};
|
|
|
|
'''
|
|
|
|
|
|
|
|
[cases]
|
|
|
|
[cases.bool_padding]
|
|
|
|
param_types = ["const Foo&"]
|
|
|
|
setup = "return Foo{0, false, 0};"
|
|
|
|
expect_json = '''[{
|
|
|
|
"staticSize":24,
|
|
|
|
"dynamicSize":0,
|
2024-01-03 17:30:31 +00:00
|
|
|
"exclusiveSize": 7,
|
2022-12-19 14:37:51 +00:00
|
|
|
"members":[
|
2024-01-03 17:30:31 +00:00
|
|
|
{ "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 }
|
2022-12-19 14:37:51 +00:00
|
|
|
]}]'''
|
|
|
|
|
|
|
|
[cases.nested_padding]
|
|
|
|
param_types = ["const Bar&"]
|
|
|
|
setup = "return Bar{0, false, 0, Foo { 0, false, 0 }};"
|
|
|
|
expect_json = '''[{
|
|
|
|
"staticSize":48,
|
|
|
|
"dynamicSize":0,
|
2024-01-03 17:30:31 +00:00
|
|
|
"exclusiveSize":7,
|
|
|
|
"size":48,
|
2022-12-19 14:37:51 +00:00
|
|
|
"members":[
|
2024-01-03 17:30:31 +00:00
|
|
|
{ "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 },
|
2022-12-19 14:37:51 +00:00
|
|
|
{
|
|
|
|
"name":"d",
|
|
|
|
"staticSize":24,
|
|
|
|
"dynamicSize":0,
|
2024-01-03 17:30:31 +00:00
|
|
|
"exclusiveSize":7,
|
|
|
|
"size":24,
|
2022-12-19 14:37:51 +00:00
|
|
|
"members": [
|
2024-01-03 17:30:31 +00:00
|
|
|
{ "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 }
|
2022-12-19 14:37:51 +00:00
|
|
|
]}
|
|
|
|
]}]'''
|
|
|
|
|
|
|
|
[cases.parent_padding]
|
2023-08-16 20:40:36 +01:00
|
|
|
oid_skip = 'calculating incorrectly'
|
2022-12-19 14:37:51 +00:00
|
|
|
param_types = ["const PaddedChild&"]
|
|
|
|
setup = "return PaddedChild{};"
|
|
|
|
expect_json = '''[{
|
|
|
|
"staticSize": 104,
|
|
|
|
"dynamicSize": 0,
|
|
|
|
"paddingSavingsSize": 19
|
|
|
|
}]'''
|
2023-08-16 20:40:36 +01:00
|
|
|
expect_json_v2 = '''[{
|
|
|
|
"staticSize": 104,
|
2024-01-03 17:30:31 +00:00
|
|
|
"exclusiveSize": 32,
|
|
|
|
"size": 104
|
2023-08-16 20:40:36 +01:00
|
|
|
}]'''
|