Skip to content

Commit bb8e4cb

Browse files
committed
fix: clang build
1 parent 5d4fa32 commit bb8e4cb

File tree

10 files changed

+46
-20
lines changed

10 files changed

+46
-20
lines changed

src/attribute.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44

55
using namespace netlm;
66

7+
Attribute::~Attribute() {
8+
delete _type;
9+
}
10+
711
Type& Attribute::GetType() {
812
if (!_type) {
9-
_type = std::make_unique<Type>();
13+
_type = new Type();
1014
Managed.GetAttributeTypeFptr(_handle, &_type->_handle);
1115
}
1216

src/attribute.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ namespace netlm {
77

88
class Attribute {
99
public:
10+
~Attribute();
11+
1012
Type& GetType();
1113

1214
template<typename TReturn>
@@ -25,7 +27,7 @@ namespace netlm {
2527

2628
private:
2729
ManagedHandle _handle{};
28-
std::unique_ptr<Type> _type;
30+
Type* _type = nullptr;
2931

3032
friend class Type;
3133
friend class MethodInfo;

src/field_info.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
using namespace netlm;
77

8+
FieldInfo::~FieldInfo() {
9+
delete _type;
10+
}
11+
812
std::string FieldInfo::GetName() const {
913
auto name = Managed.GetFieldInfoNameFptr(_handle);
1014
std::string str(name);
@@ -14,7 +18,7 @@ std::string FieldInfo::GetName() const {
1418

1519
Type& FieldInfo::GetType() {
1620
if (!_type) {
17-
_type = std::make_unique<Type>();
21+
_type = new Type();
1822
Managed.GetFieldInfoTypeFptr(_handle, &_type->_handle);
1923
}
2024

src/field_info.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace netlm {
99

1010
class FieldInfo {
1111
public:
12+
~FieldInfo();
13+
1214
std::string GetName() const;
1315
Type& GetType();
1416

@@ -22,7 +24,7 @@ namespace netlm {
2224

2325
private:
2426
ManagedHandle _handle{};
25-
std::unique_ptr<Type> _type;
27+
Type* _type = nullptr;
2628

2729
friend class Type;
2830
friend class ManagedObject;

src/method_info.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
using namespace netlm;
77

8+
MethodInfo::~MethodInfo() {
9+
delete _parameterTypes;
10+
delete _returnType;
11+
}
12+
813
std::string MethodInfo::GetName() const {
914
auto name = Managed.GetMethodInfoNameFptr(_handle);
1015
std::string str(name);
@@ -18,28 +23,27 @@ void* MethodInfo::GetFunctionAddress() const {
1823

1924
Type& MethodInfo::GetReturnType() {
2025
if (!_returnType) {
21-
_returnType = std::make_unique<Type>();
26+
_returnType = new Type();
2227
Managed.GetMethodInfoReturnTypeFptr(_handle, &_returnType->_handle);
2328
}
2429

2530
return *_returnType;
2631
}
2732

2833
const std::vector<Type>& MethodInfo::GetParameterTypes() {
29-
if (_parameterTypes.empty()) {
34+
if (!_parameterTypes) {
3035
int32_t parameterCount;
3136
Managed.GetMethodInfoParameterTypesFptr(_handle, nullptr, &parameterCount);
3237
std::vector<ManagedHandle> parameterTypes(static_cast<size_t>(parameterCount));
3338
Managed.GetMethodInfoParameterTypesFptr(_handle, parameterTypes.data(), &parameterCount);
3439

35-
_parameterTypes.reserve(parameterTypes.size());
36-
37-
for (ManagedHandle parameterType : parameterTypes) {
38-
_parameterTypes.emplace_back(parameterType);
39-
}
40+
_parameterTypes = new std::vector<Type>();
41+
_parameterTypes->reserve(parameterTypes.size());
42+
for (size_t i = 0; i < parameterTypes.size(); i++)
43+
_parameterTypes->emplace_back(parameterTypes[i]);
4044
}
4145

42-
return _parameterTypes;
46+
return *_parameterTypes;
4347
}
4448

4549
TypeAccessibility MethodInfo::GetAccessibility() const {

src/method_info.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
#include "core.hpp"
44
#include "native_string.hpp"
55

6+
#include "plg/inplace_vector.hpp"
7+
68
namespace netlm {
79
class Type;
810
class Attribute;
911

1012
class MethodInfo {
1113
public:
14+
~MethodInfo();
15+
1216
std::string GetName() const;
1317
void* GetFunctionAddress() const;
1418

@@ -27,8 +31,8 @@ namespace netlm {
2731

2832
private:
2933
ManagedHandle _handle{};
30-
std::unique_ptr<Type> _returnType;
31-
std::vector<Type> _parameterTypes;
34+
Type* _returnType = nullptr;
35+
std::vector<Type>* _parameterTypes = nullptr;
3236

3337
friend class Type;
3438
friend class ManagedObject;

src/property_info.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
using namespace netlm;
77

8+
PropertyInfo::~PropertyInfo() {
9+
delete _type;
10+
}
11+
812
std::string PropertyInfo::GetName() const {
913
auto name = Managed.GetPropertyInfoNameFptr(_handle);
1014
std::string str(name);
@@ -14,7 +18,7 @@ std::string PropertyInfo::GetName() const {
1418

1519
Type& PropertyInfo::GetType() {
1620
if (!_type) {
17-
_type = std::make_unique<Type>();
21+
_type = new Type();
1822
Managed.GetPropertyInfoTypeFptr(_handle, &_type->_handle);
1923
}
2024

src/property_info.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ namespace netlm {
99

1010
class PropertyInfo {
1111
public:
12+
~PropertyInfo();
13+
1214
std::string GetName() const;
1315
Type& GetType();
1416

@@ -20,7 +22,7 @@ namespace netlm {
2022

2123
private:
2224
ManagedHandle _handle{};
23-
std::unique_ptr<Type> _type;
25+
Type* _type = nullptr;
2426

2527
friend class Type;
2628
friend class ManagedObject;

src/type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ std::string Type::GetAssemblyQualifiedName() const {
2020

2121
Type& Type::GetBaseType() {
2222
if (!_baseType) {
23-
_baseType = std::make_unique<Type>();
23+
_baseType = new Type();
2424
Managed.GetBaseTypeFptr(_handle, &_baseType->_handle);
2525
}
2626

@@ -183,7 +183,7 @@ std::vector<int> Type::GetEnumValues() const {
183183

184184
Type& Type::GetElementType() {
185185
if (!_elementType) {
186-
_elementType = std::make_unique<Type>();
186+
_elementType = new Type();
187187
Managed.GetElementTypeFptr(_handle, &_elementType->_handle);
188188
}
189189

src/type.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ namespace netlm {
118118

119119
private:
120120
ManagedHandle _handle{};
121-
std::unique_ptr<Type> _baseType;
122-
std::unique_ptr<Type> _elementType;
121+
Type* _baseType = nullptr;
122+
Type* _elementType = nullptr;
123123

124124
friend class ManagedAssembly;
125125
friend class MethodInfo;

0 commit comments

Comments
 (0)