2023-01-20 14:05:36 +00:00
|
|
|
includes = ["vector"]
|
|
|
|
definitions = '''
|
|
|
|
class Root {
|
|
|
|
public:
|
2023-02-02 23:19:48 +00:00
|
|
|
virtual ~Root() = default;
|
2023-01-20 14:05:36 +00:00
|
|
|
virtual void myfunc() {}
|
|
|
|
int int_root;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Middle1 : public Root {
|
|
|
|
public:
|
2023-02-02 23:19:48 +00:00
|
|
|
virtual ~Middle1() = default;
|
2023-01-20 14:05:36 +00:00
|
|
|
virtual void myfunc() override {}
|
|
|
|
std::vector<int> vec_middle1;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Middle2 : public Root {
|
|
|
|
public:
|
2023-02-02 23:19:48 +00:00
|
|
|
virtual ~Middle2() = default;
|
2023-01-20 14:05:36 +00:00
|
|
|
virtual void myfunc() override {}
|
|
|
|
std::vector<int> vec_middle2;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Child : public Middle1, public Middle2 {
|
|
|
|
public:
|
2023-02-02 23:19:48 +00:00
|
|
|
virtual ~Child() = default;
|
2023-01-20 14:05:36 +00:00
|
|
|
virtual void myfunc() override {}
|
|
|
|
int int_child;
|
|
|
|
};
|
|
|
|
'''
|
|
|
|
[cases]
|
|
|
|
[cases.root_as_root]
|
2023-01-25 14:37:16 +00:00
|
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
2023-06-22 13:24:39 +01:00
|
|
|
cli_options = ["-fpolymorphic-inheritance"]
|
2023-01-20 14:05:36 +00:00
|
|
|
param_types = ["const Root&"]
|
|
|
|
arg_types = ["Root"]
|
|
|
|
setup = "return {};"
|
|
|
|
expect_json = '''[{
|
|
|
|
"typeName":"Root",
|
|
|
|
"staticSize":16,
|
|
|
|
"dynamicSize":0,
|
|
|
|
"members":[
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0}
|
|
|
|
]}]'''
|
|
|
|
|
|
|
|
[cases.middle1_as_root]
|
2023-01-25 14:37:16 +00:00
|
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
2023-06-22 13:24:39 +01:00
|
|
|
cli_options = ["-fpolymorphic-inheritance"]
|
2023-01-20 14:05:36 +00:00
|
|
|
param_types = ["const Root&"]
|
|
|
|
arg_types = ["Middle1"]
|
|
|
|
setup = '''
|
|
|
|
Middle1 m;
|
|
|
|
m.vec_middle1 = {1,2,3};
|
|
|
|
return m;
|
|
|
|
'''
|
|
|
|
expect_json = '''[{
|
2023-01-25 14:37:16 +00:00
|
|
|
"typeName":"Middle1",
|
|
|
|
"staticSize":40,
|
|
|
|
"dynamicSize":12,
|
2023-01-20 14:05:36 +00:00
|
|
|
"members":[
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
2023-01-25 14:37:16 +00:00
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
|
|
{"name":"vec_middle1", "staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4}
|
2023-01-20 14:05:36 +00:00
|
|
|
]}]'''
|
|
|
|
[cases.middle1_as_middle1]
|
2023-01-25 14:37:16 +00:00
|
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
2023-06-22 13:24:39 +01:00
|
|
|
cli_options = ["-fpolymorphic-inheritance"]
|
2023-01-20 14:05:36 +00:00
|
|
|
param_types = ["const Middle1&"]
|
|
|
|
arg_types = ["Middle1"]
|
|
|
|
setup = '''
|
|
|
|
Middle1 m;
|
|
|
|
m.vec_middle1 = {1,2,3};
|
|
|
|
return m;
|
|
|
|
'''
|
|
|
|
expect_json = '''[{
|
|
|
|
"typeName":"Middle1",
|
|
|
|
"staticSize":40,
|
|
|
|
"dynamicSize":12,
|
|
|
|
"members":[
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
|
|
{"name":"vec_middle1", "staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4}
|
|
|
|
]}]'''
|
|
|
|
|
|
|
|
[cases.middle2_as_root]
|
2023-01-25 14:37:16 +00:00
|
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
2023-06-22 13:24:39 +01:00
|
|
|
cli_options = ["-fpolymorphic-inheritance"]
|
2023-01-20 14:05:36 +00:00
|
|
|
param_types = ["const Root&"]
|
|
|
|
arg_types = ["Middle2"]
|
|
|
|
setup = '''
|
|
|
|
Middle2 m;
|
|
|
|
m.vec_middle2 = {4,5};
|
|
|
|
return m;
|
|
|
|
'''
|
|
|
|
expect_json = '''[{
|
2023-01-25 14:37:16 +00:00
|
|
|
"typeName":"Middle2",
|
|
|
|
"staticSize":40,
|
|
|
|
"dynamicSize":8,
|
2023-01-20 14:05:36 +00:00
|
|
|
"members":[
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
2023-01-25 14:37:16 +00:00
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
|
|
{"name":"vec_middle2", "staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4}
|
2023-01-20 14:05:36 +00:00
|
|
|
]}]'''
|
|
|
|
[cases.middle2_as_middle2]
|
2023-01-25 14:37:16 +00:00
|
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
2023-06-22 13:24:39 +01:00
|
|
|
cli_options = ["-fpolymorphic-inheritance"]
|
2023-01-20 14:05:36 +00:00
|
|
|
param_types = ["const Middle2&"]
|
|
|
|
arg_types = ["Middle2"]
|
|
|
|
setup = '''
|
|
|
|
Middle2 m;
|
|
|
|
m.vec_middle2 = {4,5};
|
|
|
|
return m;
|
|
|
|
'''
|
|
|
|
expect_json = '''[{
|
|
|
|
"typeName":"Middle2",
|
|
|
|
"staticSize":40,
|
|
|
|
"dynamicSize":8,
|
|
|
|
"members":[
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
|
|
{"name":"vec_middle2", "staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4}
|
|
|
|
]}]'''
|
|
|
|
|
|
|
|
[cases.child_as_middle1_root]
|
2023-01-25 14:37:16 +00:00
|
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
2023-06-22 13:24:39 +01:00
|
|
|
cli_options = ["-fpolymorphic-inheritance"]
|
2023-01-20 14:05:36 +00:00
|
|
|
# We need to explicitly cast from Child to Middle1 before going to root to
|
|
|
|
# resolve the diamond problem
|
|
|
|
param_types = ["const Root&"]
|
|
|
|
arg_types = ["Middle1&"]
|
|
|
|
setup = '''
|
|
|
|
auto c = new Child{};
|
|
|
|
c->vec_middle1 = {1,2,3};
|
|
|
|
c->vec_middle2 = {4,5};
|
|
|
|
return static_cast<Middle1&>(*c);
|
|
|
|
'''
|
|
|
|
expect_json = '''[{
|
2023-01-25 14:37:16 +00:00
|
|
|
"typeName":"Child",
|
|
|
|
"staticSize":88,
|
|
|
|
"dynamicSize":20,
|
2023-01-20 14:05:36 +00:00
|
|
|
"members":[
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
2023-01-25 14:37:16 +00:00
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
|
|
{"name":"vec_middle1", "staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4},
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
|
|
{"name":"vec_middle2", "staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4},
|
|
|
|
{"name":"int_child", "staticSize":4, "dynamicSize":0}
|
2023-01-20 14:05:36 +00:00
|
|
|
]}]'''
|
|
|
|
[cases.child_as_middle2_root]
|
2023-01-25 14:37:16 +00:00
|
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
2023-06-22 13:24:39 +01:00
|
|
|
cli_options = ["-fpolymorphic-inheritance"]
|
2023-01-20 14:05:36 +00:00
|
|
|
# We need to explicitly cast from Child to Middle2 before going to root to
|
|
|
|
# resolve the diamond problem
|
|
|
|
param_types = ["const Root&"]
|
|
|
|
arg_types = ["Middle2&"]
|
|
|
|
setup = '''
|
|
|
|
auto c = new Child{};
|
|
|
|
c->vec_middle1 = {1,2,3};
|
|
|
|
c->vec_middle2 = {4,5};
|
|
|
|
return static_cast<Middle2&>(*c);
|
|
|
|
'''
|
|
|
|
expect_json = '''[{
|
2023-01-25 14:37:16 +00:00
|
|
|
"typeName":"Child",
|
|
|
|
"staticSize":88,
|
|
|
|
"dynamicSize":20,
|
2023-01-20 14:05:36 +00:00
|
|
|
"members":[
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
2023-01-25 14:37:16 +00:00
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
|
|
{"name":"vec_middle1", "staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4},
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
|
|
{"name":"vec_middle2", "staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4},
|
|
|
|
{"name":"int_child", "staticSize":4, "dynamicSize":0}
|
2023-01-20 14:05:36 +00:00
|
|
|
]}]'''
|
|
|
|
[cases.child_as_middle1]
|
2023-01-25 14:37:16 +00:00
|
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
2023-06-22 13:24:39 +01:00
|
|
|
cli_options = ["-fpolymorphic-inheritance"]
|
2023-01-20 14:05:36 +00:00
|
|
|
param_types = ["const Middle1&"]
|
|
|
|
arg_types = ["Child"]
|
|
|
|
setup = '''
|
|
|
|
Child c;
|
|
|
|
c.vec_middle1 = {1,2,3};
|
|
|
|
c.vec_middle2 = {4,5};
|
|
|
|
return c;
|
|
|
|
'''
|
|
|
|
expect_json = '''[{
|
2023-01-25 14:37:16 +00:00
|
|
|
"typeName":"Child",
|
|
|
|
"staticSize":88,
|
|
|
|
"dynamicSize":20,
|
2023-01-20 14:05:36 +00:00
|
|
|
"members":[
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
2023-01-25 14:37:16 +00:00
|
|
|
{"name":"vec_middle1", "staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4},
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
|
|
{"name":"vec_middle2", "staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4},
|
|
|
|
{"name":"int_child", "staticSize":4, "dynamicSize":0}
|
2023-01-20 14:05:36 +00:00
|
|
|
]}]'''
|
|
|
|
[cases.child_as_middle2]
|
2023-01-25 14:37:16 +00:00
|
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
2023-06-22 13:24:39 +01:00
|
|
|
cli_options = ["-fpolymorphic-inheritance"]
|
2023-01-20 14:05:36 +00:00
|
|
|
param_types = ["const Middle2&"]
|
|
|
|
arg_types = ["Child"]
|
|
|
|
setup = '''
|
|
|
|
Child c;
|
|
|
|
c.vec_middle1 = {1,2,3};
|
|
|
|
c.vec_middle2 = {4,5};
|
|
|
|
return c;
|
|
|
|
'''
|
|
|
|
expect_json = '''[{
|
2023-01-25 14:37:16 +00:00
|
|
|
"typeName":"Child",
|
|
|
|
"staticSize":88,
|
|
|
|
"dynamicSize":20,
|
2023-01-20 14:05:36 +00:00
|
|
|
"members":[
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
2023-01-25 14:37:16 +00:00
|
|
|
{"name":"vec_middle1", "staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4},
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
|
|
{"name":"vec_middle2", "staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4},
|
|
|
|
{"name":"int_child", "staticSize":4, "dynamicSize":0}
|
2023-01-20 14:05:36 +00:00
|
|
|
]}]'''
|
|
|
|
[cases.child_as_child]
|
2023-01-25 14:37:16 +00:00
|
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
2023-06-22 13:24:39 +01:00
|
|
|
cli_options = ["-fpolymorphic-inheritance"]
|
2023-01-20 14:05:36 +00:00
|
|
|
param_types = ["const Child&"]
|
|
|
|
arg_types = ["Child"]
|
|
|
|
setup = '''
|
|
|
|
Child c;
|
|
|
|
c.vec_middle1 = {1,2,3};
|
|
|
|
c.vec_middle2 = {4,5};
|
|
|
|
return c;
|
|
|
|
'''
|
|
|
|
expect_json = '''[{
|
|
|
|
"typeName":"Child",
|
|
|
|
"staticSize":88,
|
|
|
|
"dynamicSize":20,
|
|
|
|
"members":[
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
|
|
{"name":"vec_middle1", "staticSize":24, "dynamicSize":12, "length":3, "capacity":3, "elementStaticSize":4},
|
|
|
|
{"staticSize":8, "dynamicSize":0},
|
|
|
|
{"name":"int_root", "staticSize":4, "dynamicSize":0},
|
|
|
|
{"name":"vec_middle2", "staticSize":24, "dynamicSize":8, "length":2, "capacity":2, "elementStaticSize":4},
|
|
|
|
{"name":"int_child", "staticSize":4, "dynamicSize":0}
|
|
|
|
]}]'''
|