2022-12-19 14:37:51 +00:00
|
|
|
definitions = '''
|
|
|
|
struct Foo {
|
|
|
|
int a, b, c;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Bar {
|
|
|
|
std::string a, b, c;
|
|
|
|
};
|
2024-02-07 15:41:52 +00:00
|
|
|
|
|
|
|
struct FooBar {
|
|
|
|
Foo a;
|
|
|
|
Bar b;
|
|
|
|
};
|
2022-12-19 14:37:51 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
[cases]
|
2024-02-07 15:41:52 +00:00
|
|
|
[cases.roottype]
|
2022-12-19 14:37:51 +00:00
|
|
|
param_types = ["const Bar&"]
|
|
|
|
setup = """
|
|
|
|
return Bar{
|
|
|
|
"The first member of the struct Bar",
|
|
|
|
"The second member of the struct Bar",
|
|
|
|
"The 3rd member of the struct Bar"
|
|
|
|
};
|
|
|
|
"""
|
2023-04-17 19:13:59 +01:00
|
|
|
config_suffix = """
|
2022-12-19 14:37:51 +00:00
|
|
|
[[codegen.ignore]]
|
2024-02-07 15:41:52 +00:00
|
|
|
type = "ns_ignored::Bar"
|
|
|
|
|
|
|
|
"""
|
|
|
|
expect_json_v2 = '''[{
|
|
|
|
"staticSize":96,
|
|
|
|
"exclusiveSize":96,
|
|
|
|
"members":[]
|
|
|
|
}]'''
|
|
|
|
|
|
|
|
expect_json ='''
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"name": "a0",
|
|
|
|
"typePath": "a0",
|
|
|
|
"typeName": "ns_ignored::Bar",
|
|
|
|
"isTypedef": false,
|
|
|
|
"staticSize": 96,
|
|
|
|
"dynamicSize": 0,
|
|
|
|
"exclusiveSize": 96
|
|
|
|
}
|
|
|
|
]
|
|
|
|
'''
|
|
|
|
|
|
|
|
[cases.subtype]
|
|
|
|
param_types = ["const FooBar&"]
|
|
|
|
setup = """
|
|
|
|
return FooBar{
|
|
|
|
{ 1, 2, 3}, {
|
|
|
|
"The first member of the struct Bar",
|
|
|
|
"The second member of the struct Bar",
|
|
|
|
"The 3rd member of the struct Bar"
|
|
|
|
}} ;
|
|
|
|
"""
|
|
|
|
config_suffix = """
|
|
|
|
[[codegen.ignore]]
|
|
|
|
type = "ns_ignored::Bar"
|
|
|
|
|
|
|
|
"""
|
|
|
|
expect_json_v2 = '''[{
|
|
|
|
"staticSize":112,
|
|
|
|
"exclusiveSize":4,
|
|
|
|
"members":[
|
|
|
|
{
|
|
|
|
"name": "a",
|
|
|
|
"staticSize": 12,
|
|
|
|
"exclusiveSize": 0,
|
|
|
|
"members": [
|
|
|
|
{ "name":"a", "staticSize":4, "exclusiveSize":4 },
|
|
|
|
{ "name":"b", "staticSize":4, "exclusiveSize":4 },
|
|
|
|
{ "name":"c", "staticSize":4, "exclusiveSize":4 }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name":"b",
|
|
|
|
"staticSize":96,
|
|
|
|
"exclusiveSize":96
|
|
|
|
}
|
|
|
|
]}]'''
|
|
|
|
|
|
|
|
expect_json = '''
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"name": "a0",
|
|
|
|
"typePath": "a0",
|
|
|
|
"typeName": "ns_ignored::FooBar",
|
|
|
|
"isTypedef": false,
|
|
|
|
"staticSize": 112,
|
|
|
|
"dynamicSize": 0,
|
|
|
|
"exclusiveSize": 4,
|
|
|
|
"members": [
|
|
|
|
{
|
|
|
|
"name": "a",
|
|
|
|
"typePath": "a",
|
|
|
|
"typeName": "ns_ignored::Foo",
|
|
|
|
"isTypedef": false,
|
|
|
|
"staticSize": 12,
|
|
|
|
"dynamicSize": 0,
|
|
|
|
"exclusiveSize": 0,
|
|
|
|
"members": [
|
|
|
|
{
|
|
|
|
"name": "a",
|
|
|
|
"typePath": "a",
|
|
|
|
"typeName": "int32_t",
|
|
|
|
"isTypedef": false,
|
|
|
|
"staticSize": 4,
|
|
|
|
"dynamicSize": 0,
|
|
|
|
"exclusiveSize": 4
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "b",
|
|
|
|
"typePath": "b",
|
|
|
|
"typeName": "int32_t",
|
|
|
|
"isTypedef": false,
|
|
|
|
"staticSize": 4,
|
|
|
|
"dynamicSize": 0,
|
|
|
|
"exclusiveSize": 4
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "c",
|
|
|
|
"typePath": "c",
|
|
|
|
"typeName": "int32_t",
|
|
|
|
"isTypedef": false,
|
|
|
|
"staticSize": 4,
|
|
|
|
"dynamicSize": 0,
|
|
|
|
"exclusiveSize": 4
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "b",
|
|
|
|
"typePath": "b",
|
|
|
|
"typeName": "ns_ignored::Bar",
|
|
|
|
"isTypedef": false,
|
|
|
|
"staticSize": 96,
|
|
|
|
"dynamicSize": 0,
|
|
|
|
"exclusiveSize": 96
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
'''
|
2022-12-19 14:37:51 +00:00
|
|
|
|
2024-02-07 15:41:52 +00:00
|
|
|
|
|
|
|
[cases.member]
|
|
|
|
param_types = ["const Bar&"]
|
|
|
|
setup = """
|
|
|
|
return Bar{
|
|
|
|
"The first member of the struct Bar",
|
|
|
|
"The second member of the struct Bar",
|
|
|
|
"The 3rd member of the struct Bar"
|
|
|
|
};
|
|
|
|
"""
|
|
|
|
config_suffix = """
|
2022-12-19 14:37:51 +00:00
|
|
|
[[codegen.ignore]]
|
2024-02-07 15:41:52 +00:00
|
|
|
type = "ns_ignored::Bar"
|
|
|
|
members = ["a"]
|
|
|
|
|
2022-12-19 14:37:51 +00:00
|
|
|
"""
|
2024-02-07 15:41:52 +00:00
|
|
|
expect_json_v2 = '''[{
|
2022-12-19 14:37:51 +00:00
|
|
|
"staticSize":96,
|
2024-02-07 15:41:52 +00:00
|
|
|
"exclusiveSize":32,
|
2022-12-19 14:37:51 +00:00
|
|
|
"members":[
|
2024-02-07 15:41:52 +00:00
|
|
|
{ "name":"b", "staticSize":32, "exclusiveSize":67 },
|
|
|
|
{ "name":"c", "staticSize":32, "exclusiveSize":64 }
|
2022-12-19 14:37:51 +00:00
|
|
|
]}]'''
|
2024-02-07 15:41:52 +00:00
|
|
|
|
|
|
|
expect_json = '''
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"staticSize": 96,
|
|
|
|
"dynamicSize": 67,
|
|
|
|
"exclusiveSize": 32,
|
|
|
|
"members": [
|
|
|
|
{
|
|
|
|
"name": "b",
|
|
|
|
"typePath": "b",
|
|
|
|
"typeName": "string",
|
|
|
|
"isTypedef": true,
|
|
|
|
"staticSize": 32,
|
|
|
|
"dynamicSize": 35,
|
|
|
|
"exclusiveSize": 0,
|
|
|
|
"members": [
|
|
|
|
{
|
|
|
|
"name": "",
|
|
|
|
"typePath": "",
|
|
|
|
"typeName": "std::__cxx11::basic_string<int8_t, std::char_traits<int8_t>, std::allocator<int8_t>>",
|
|
|
|
"isTypedef": false,
|
|
|
|
"staticSize": 32,
|
|
|
|
"dynamicSize": 35,
|
|
|
|
"exclusiveSize": 67,
|
|
|
|
"length": 35,
|
|
|
|
"capacity": 35,
|
|
|
|
"elementStaticSize": 1
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "c",
|
|
|
|
"typePath": "c",
|
|
|
|
"typeName": "string",
|
|
|
|
"isTypedef": true,
|
|
|
|
"staticSize": 32,
|
|
|
|
"dynamicSize": 32,
|
|
|
|
"exclusiveSize": 0,
|
|
|
|
"members": [
|
|
|
|
{
|
|
|
|
"name": "",
|
|
|
|
"typePath": "",
|
|
|
|
"typeName": "std::__cxx11::basic_string<int8_t, std::char_traits<int8_t>, std::allocator<int8_t>>",
|
|
|
|
"isTypedef": false,
|
|
|
|
"staticSize": 32,
|
|
|
|
"dynamicSize": 32,
|
|
|
|
"exclusiveSize": 64,
|
|
|
|
"length": 32,
|
|
|
|
"capacity": 32,
|
|
|
|
"elementStaticSize": 1
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
'''
|
|
|
|
|
|
|
|
|