Skip to content

Commit 40f6670

Browse files
authored
Merge pull request #132 from kornilova-l/inheritance-cleanup
Inheritance cleanup
2 parents 09cd905 + 5519df1 commit 40f6670

File tree

6 files changed

+6
-18
lines changed

6 files changed

+6
-18
lines changed

bindgen/ir/Enum.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Enumerator {
1818
int64_t value;
1919
};
2020

21-
class Enum : public PrimitiveType, public std::enable_shared_from_this<Enum> {
21+
class Enum : public PrimitiveType {
2222
public:
2323
Enum(std::string name, std::string type,
2424
std::vector<Enumerator> enumerators,

bindgen/ir/Struct.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Field : public TypeAndName {
2424
uint64_t offsetInBits = 0;
2525
};
2626

27-
class StructOrUnion {
27+
class StructOrUnion : public virtual Type {
2828
public:
2929
StructOrUnion(std::string name, std::vector<std::shared_ptr<Field>> fields,
3030
std::shared_ptr<Location> location);
@@ -47,9 +47,7 @@ class StructOrUnion {
4747
std::shared_ptr<Location> location;
4848
};
4949

50-
class Struct : public StructOrUnion,
51-
public Type,
52-
public std::enable_shared_from_this<Struct> {
50+
class Struct : public StructOrUnion {
5351
public:
5452
Struct(std::string name, std::vector<std::shared_ptr<Field>> fields,
5553
uint64_t typeSize, std::shared_ptr<Location> location, bool isPacked,
@@ -103,9 +101,7 @@ class Struct : public StructOrUnion,
103101
std::string generateGetterForArrayRepresentation(unsigned fieldIndex) const;
104102
};
105103

106-
class Union : public StructOrUnion,
107-
public ArrayType,
108-
public std::enable_shared_from_this<Union> {
104+
class Union : public StructOrUnion, public ArrayType {
109105
public:
110106
Union(std::string name, std::vector<std::shared_ptr<Field>> fields,
111107
uint64_t maxSize, std::shared_ptr<Location> location);

bindgen/ir/types/ArrayType.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33

44
#include "Type.h"
55

6-
class ArrayType : public Type {
6+
class ArrayType : public virtual Type {
77
public:
88
ArrayType(std::shared_ptr<Type> elementsType, uint64_t size);
99

10-
~ArrayType() override = default;
11-
1210
bool usesType(const std::shared_ptr<Type> &type,
1311
bool stopOnTypeDefs) const override;
1412

bindgen/ir/types/FunctionPointerType.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ class FunctionPointerType : public Type {
1111
const std::vector<std::shared_ptr<Type>> &parametersTypes,
1212
bool isVariadic);
1313

14-
~FunctionPointerType() override = default;
15-
1614
bool usesType(const std::shared_ptr<Type> &type,
1715
bool stopOnTypeDefs) const override;
1816

bindgen/ir/types/PointerType.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ class PointerType : public Type {
77
public:
88
explicit PointerType(std::shared_ptr<Type> type);
99

10-
~PointerType() override = default;
11-
1210
bool usesType(const std::shared_ptr<Type> &type,
1311
bool stopOnTypeDefs) const override;
1412

bindgen/ir/types/Type.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
/**
88
* Base class for types.
99
*/
10-
class Type {
10+
class Type : public std::enable_shared_from_this<Type> {
1111
public:
12-
virtual ~Type() = default;
13-
1412
virtual std::string str() const = 0;
1513

1614
/**

0 commit comments

Comments
 (0)