2023-02-21 20:03:47 +00:00
|
|
|
includes = ["vector"]
|
|
|
|
definitions = '''
|
|
|
|
template <typename T>
|
|
|
|
class TemplatedClass1 {
|
|
|
|
T val;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename S>
|
|
|
|
class TemplatedClass2 {
|
|
|
|
TemplatedClass1<T> tc1;
|
|
|
|
S val2;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Foo {
|
|
|
|
int a;
|
|
|
|
int b;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <int N>
|
|
|
|
struct TemplatedClassVal {
|
|
|
|
int arr[N];
|
|
|
|
};
|
|
|
|
'''
|
|
|
|
|
|
|
|
[cases]
|
|
|
|
[cases.int]
|
2023-08-16 20:40:36 +01:00
|
|
|
oil_skip = "primitives are named differently in treebuilderv2" # https://github.com/facebookexperimental/object-introspection/issues/286
|
2023-02-21 20:03:47 +00:00
|
|
|
param_types = ["const TemplatedClass1<int>&"]
|
|
|
|
setup = "return {};"
|
|
|
|
expect_json = '''[{
|
2023-12-13 16:49:41 +00:00
|
|
|
"typeName":"ns_templates::TemplatedClass1<int>",
|
2023-02-21 20:03:47 +00:00
|
|
|
"staticSize":4,
|
|
|
|
"dynamicSize":0,
|
|
|
|
"members":[{
|
2023-12-13 16:49:41 +00:00
|
|
|
"typeName":"int32_t"
|
2023-02-21 20:03:47 +00:00
|
|
|
}]}]'''
|
|
|
|
[cases.vector]
|
|
|
|
param_types = ["const TemplatedClass1<std::vector<int>>&"]
|
|
|
|
setup = "return {};"
|
|
|
|
expect_json = '''[{
|
2023-12-13 16:49:41 +00:00
|
|
|
"typeName":"ns_templates::TemplatedClass1<std::vector<int, std::allocator<int> > >",
|
2023-02-21 20:03:47 +00:00
|
|
|
"staticSize":24,
|
|
|
|
"dynamicSize":0,
|
|
|
|
"members":[{
|
2023-12-13 16:49:41 +00:00
|
|
|
"typeName":"std::vector<int32_t, std::allocator<int32_t>>",
|
2023-02-21 20:03:47 +00:00
|
|
|
"staticSize":24,
|
|
|
|
"dynamicSize":0,
|
|
|
|
"length":0,
|
|
|
|
"capacity":0,
|
|
|
|
"elementStaticSize":4
|
|
|
|
}]}]'''
|
2023-08-16 20:40:36 +01:00
|
|
|
expect_json_v2 = '''[{
|
2023-12-15 12:25:30 +00:00
|
|
|
"typeName":"ns_templates::TemplatedClass1<std::vector<int, std::allocator<int> > >",
|
2023-08-16 20:40:36 +01:00
|
|
|
"staticSize":24,
|
|
|
|
"exclusiveSize":0,
|
2024-01-03 17:30:31 +00:00
|
|
|
"size":24,
|
2023-08-16 20:40:36 +01:00
|
|
|
"members":[{
|
|
|
|
"typeName":"std::vector<int32_t, std::allocator<int32_t>>",
|
|
|
|
"staticSize":24,
|
|
|
|
"exclusiveSize":24,
|
2024-01-03 17:30:31 +00:00
|
|
|
"size":24,
|
2023-08-16 20:40:36 +01:00
|
|
|
"length":0,
|
|
|
|
"capacity":0
|
|
|
|
}]}]'''
|
2023-02-21 20:03:47 +00:00
|
|
|
[cases.two]
|
2023-08-16 20:40:36 +01:00
|
|
|
oil_skip = "OIL returns better primitive names"
|
2023-02-21 20:03:47 +00:00
|
|
|
param_types = ["const TemplatedClass2<Foo, int>&"]
|
|
|
|
setup = "return {};"
|
|
|
|
expect_json = '''[{
|
2023-12-13 16:49:41 +00:00
|
|
|
"typeName":"ns_templates::TemplatedClass2<ns_templates::Foo, int>",
|
2023-02-21 20:03:47 +00:00
|
|
|
"staticSize":12,
|
|
|
|
"dynamicSize":0,
|
|
|
|
"members":[
|
2023-12-13 16:49:41 +00:00
|
|
|
{"typeName":"ns_templates::TemplatedClass1<ns_templates::Foo>", "staticSize":8, "dynamicSize":0},
|
|
|
|
{"typeName":"int32_t", "staticSize":4, "dynamicSize":0}
|
2023-02-21 20:03:47 +00:00
|
|
|
]}]'''
|
|
|
|
[cases.value]
|
|
|
|
param_types = ["const TemplatedClassVal<3>&"]
|
|
|
|
setup = "return {};"
|
|
|
|
expect_json = '''[{
|
2023-12-13 16:49:41 +00:00
|
|
|
"typeName":"ns_templates::TemplatedClassVal<3>",
|
2023-02-21 20:03:47 +00:00
|
|
|
"staticSize":12,
|
|
|
|
"dynamicSize":0,
|
|
|
|
"members":[{
|
|
|
|
"staticSize":12,
|
|
|
|
"dynamicSize":0,
|
|
|
|
"length":3,
|
|
|
|
"capacity":3,
|
|
|
|
"elementStaticSize":4
|
|
|
|
}]}]'''
|
2023-08-16 20:40:36 +01:00
|
|
|
expect_json_v2 = '''[{
|
2023-12-15 12:25:30 +00:00
|
|
|
"typeName":"ns_templates::TemplatedClassVal<3>",
|
2023-08-16 20:40:36 +01:00
|
|
|
"staticSize":12,
|
|
|
|
"exclusiveSize":0,
|
2024-01-03 17:30:31 +00:00
|
|
|
"size":12,
|
2023-08-16 20:40:36 +01:00
|
|
|
"members":[{
|
|
|
|
"staticSize":12,
|
|
|
|
"exclusiveSize":0,
|
2024-01-03 17:30:31 +00:00
|
|
|
"size":12,
|
2023-08-16 20:40:36 +01:00
|
|
|
"length":3,
|
|
|
|
"capacity":3
|
|
|
|
}]}]'''
|