mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-14 14:26:55 +00:00
9e72ada131
i.e. classes which contain virtual functions and use a virtual pointer
245 lines
8.3 KiB
TOML
245 lines
8.3 KiB
TOML
includes = ["vector"]
|
|
definitions = '''
|
|
class Root {
|
|
public:
|
|
virtual void myfunc() {}
|
|
int int_root;
|
|
};
|
|
|
|
class Middle1 : public Root {
|
|
public:
|
|
virtual void myfunc() override {}
|
|
std::vector<int> vec_middle1;
|
|
};
|
|
|
|
class Middle2 : public Root {
|
|
public:
|
|
virtual void myfunc() override {}
|
|
std::vector<int> vec_middle2;
|
|
};
|
|
|
|
class Child : public Middle1, public Middle2 {
|
|
public:
|
|
virtual void myfunc() override {}
|
|
int int_child;
|
|
};
|
|
'''
|
|
[cases]
|
|
[cases.root_as_root]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
cli_options = ["--polymorphic-inheritance"]
|
|
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]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
cli_options = ["--polymorphic-inheritance"]
|
|
param_types = ["const Root&"]
|
|
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.middle1_as_middle1]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
cli_options = ["--polymorphic-inheritance"]
|
|
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]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
cli_options = ["--polymorphic-inheritance"]
|
|
param_types = ["const Root&"]
|
|
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.middle2_as_middle2]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
cli_options = ["--polymorphic-inheritance"]
|
|
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]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
cli_options = ["--polymorphic-inheritance"]
|
|
# 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 = '''[{
|
|
"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}
|
|
]}]'''
|
|
[cases.child_as_middle2_root]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
cli_options = ["--polymorphic-inheritance"]
|
|
# 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 = '''[{
|
|
"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}
|
|
]}]'''
|
|
[cases.child_as_middle1]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
cli_options = ["--polymorphic-inheritance"]
|
|
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 = '''[{
|
|
"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}
|
|
]}]'''
|
|
[cases.child_as_middle2]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
cli_options = ["--polymorphic-inheritance"]
|
|
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 = '''[{
|
|
"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}
|
|
]}]'''
|
|
[cases.child_as_child]
|
|
oil_skip = "Polymorphic inheritance disabled in OIL"
|
|
cli_options = ["--polymorphic-inheritance"]
|
|
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}
|
|
]}]'''
|