includes = ["vector"] definitions = ''' class Root { public: virtual ~Root() = default; virtual void myfunc() {} int int_root; }; class Middle1 : public Root { public: virtual ~Middle1() = default; virtual void myfunc() override {} std::vector vec_middle1; }; class Middle2 : public Root { public: virtual ~Middle2() = default; virtual void myfunc() override {} std::vector vec_middle2; }; class Child : public Middle1, public Middle2 { public: virtual ~Child() = default; virtual void myfunc() override {} int int_child; }; ''' [cases] [cases.root_as_root] oil_skip = "Polymorphic inheritance disabled in OIL" cli_options = ["-fpolymorphic-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 = ["-fpolymorphic-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 = ["-fpolymorphic-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 = ["-fpolymorphic-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 = ["-fpolymorphic-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 = ["-fpolymorphic-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(*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 = ["-fpolymorphic-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(*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 = ["-fpolymorphic-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 = ["-fpolymorphic-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 = ["-fpolymorphic-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} ]}]'''