Skip to content

Commit a9c4583

Browse files
committed
Support5.3
1 parent ffdcd0f commit a9c4583

File tree

5 files changed

+104
-2
lines changed

5 files changed

+104
-2
lines changed

Plugins/UnLua/Source/UnLua/Private/LuaFunction.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "LuaOverridesClass.h"
1919
#include "UnLuaModule.h"
2020
#include "ReflectionUtils/PropertyDesc.h"
21+
#include "Misc/EngineVersionComparison.h"
2122

2223
static constexpr uint8 ScriptMagicHeader[] = {EX_StringConst, 'L', 'U', 'A', '\0', EX_UInt64Const};
2324
static constexpr size_t ScriptMagicHeaderSize = sizeof ScriptMagicHeader;
@@ -285,6 +286,8 @@ void ULuaFunction::Bind()
285286
}
286287
else
287288
{
289+
#if UE_VERSION_OLDER_THAN(5, 3, 0)
288290
SetNativeFunc(ProcessInternal);
291+
#endif
289292
}
290293
}

Plugins/UnLua/Source/UnLua/Private/LuaOverridesClass.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "LuaOverridesClass.h"
1616
#include "LuaFunction.h"
17+
#include "Misc/EngineVersionComparison.h"
1718

1819
ULuaOverridesClass* ULuaOverridesClass::Create(UClass* Class)
1920
{
@@ -62,7 +63,16 @@ void ULuaOverridesClass::AddToOwner()
6263
if (!Class)
6364
return;
6465

65-
auto Field = &Class->Children;
66+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
67+
UField** Field = nullptr;
68+
69+
if (auto ChildrenPtr = Class->Children.Get())
70+
{
71+
Field = &ChildrenPtr;
72+
}
73+
#else
74+
auto Field = &(Class->Children);
75+
#endif
6676
while (*Field)
6777
Field = &(*Field)->Next;
6878
*Field = this;
@@ -77,7 +87,16 @@ void ULuaOverridesClass::RemoveFromOwner()
7787
if (!Class)
7888
return;
7989

90+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
91+
UField** Field = nullptr;
92+
93+
if (auto ChildrenPtr = Class->Children.Get())
94+
{
95+
Field = &ChildrenPtr;
96+
}
97+
#else
8098
auto Field = &Class->Children;
99+
#endif
81100
while (*Field)
82101
{
83102
if (*Field == this)

Plugins/UnLua/Source/UnLua/Private/Registries/PropertyRegistry.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,22 @@ namespace UnLua
103103
CPF_None,
104104
UECodeGen_Private::EPropertyGenFlags::Bool | UECodeGen_Private::EPropertyGenFlags::NativeBool,
105105
RF_Transient,
106+
#if UE_VERSION_OLDER_THAN(5, 3, 0)
106107
1,
108+
#endif
107109
nullptr,
108110
nullptr,
111+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
112+
1,
113+
#endif
109114
sizeof(bool),
110115
sizeof(FPropertyCollector),
111116
nullptr,
117+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
118+
METADATA_PARAMS(0, nullptr)
119+
#else
112120
METADATA_PARAMS(nullptr, 0)
121+
#endif
113122
};
114123
const auto Property = new FBoolProperty(PropertyCollector, Params);
115124
#endif
@@ -132,11 +141,20 @@ namespace UnLua
132141
CPF_HasGetValueTypeHash,
133142
UECodeGen_Private::EPropertyGenFlags::Int,
134143
RF_Transient,
144+
#if UE_VERSION_OLDER_THAN(5, 3, 0)
135145
1,
146+
#endif
136147
nullptr,
137148
nullptr,
149+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
150+
1,
151+
#endif
138152
0,
153+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
154+
METADATA_PARAMS(0, nullptr)
155+
#else
139156
METADATA_PARAMS(nullptr, 0)
157+
#endif
140158
};
141159
const auto Property = new FIntProperty(PropertyCollector, Params);
142160
#endif
@@ -159,11 +177,20 @@ namespace UnLua
159177
CPF_HasGetValueTypeHash,
160178
UECodeGen_Private::EPropertyGenFlags::Float,
161179
RF_Transient,
180+
#if UE_VERSION_OLDER_THAN(5, 3, 0)
162181
1,
182+
#endif
163183
nullptr,
164184
nullptr,
185+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
186+
1,
187+
#endif
165188
0,
189+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
190+
METADATA_PARAMS(0, nullptr)
191+
#else
166192
METADATA_PARAMS(nullptr, 0)
193+
#endif
167194
};
168195
const auto Property = new FFloatProperty(PropertyCollector, Params);
169196
#endif
@@ -186,11 +213,20 @@ namespace UnLua
186213
CPF_HasGetValueTypeHash,
187214
UECodeGen_Private::EPropertyGenFlags::Str,
188215
RF_Transient,
216+
#if UE_VERSION_OLDER_THAN(5, 3, 0)
189217
1,
218+
#endif
190219
nullptr,
191220
nullptr,
221+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
222+
1,
223+
#endif
192224
0,
225+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
226+
METADATA_PARAMS(0, nullptr)
227+
#else
193228
METADATA_PARAMS(nullptr, 0)
229+
#endif
194230
};
195231
const auto Property = new FStrProperty(PropertyCollector, Params);
196232
#endif
@@ -213,11 +249,20 @@ namespace UnLua
213249
CPF_HasGetValueTypeHash,
214250
UECodeGen_Private::EPropertyGenFlags::Name,
215251
RF_Transient,
252+
#if UE_VERSION_OLDER_THAN(5, 3, 0)
216253
1,
254+
#endif
217255
nullptr,
218256
nullptr,
257+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
258+
1,
259+
#endif
219260
0,
261+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
262+
METADATA_PARAMS(0, nullptr)
263+
#else
220264
METADATA_PARAMS(nullptr, 0)
265+
#endif
221266
};
222267
const auto Property = new FNameProperty(PropertyCollector, Params);
223268
#endif
@@ -240,13 +285,26 @@ namespace UnLua
240285
CPF_HasGetValueTypeHash,
241286
UECodeGen_Private::EPropertyGenFlags::Text,
242287
RF_Transient,
288+
#if UE_VERSION_OLDER_THAN(5, 3, 0)
243289
1,
290+
#endif
244291
nullptr,
245292
nullptr,
293+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
294+
1,
295+
#endif
246296
0,
297+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
298+
METADATA_PARAMS(0, nullptr)
299+
#else
247300
METADATA_PARAMS(nullptr, 0)
301+
#endif
248302
};
303+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
304+
const auto Property = new FTextProperty(PropertyCollector, "", RF_Transient);
305+
#else
249306
const auto Property = new FTextProperty(PropertyCollector, Params);
307+
#endif
250308
#endif
251309
TextProperty = TSharedPtr<ITypeInterface>(FPropertyDesc::Create(Property));
252310
}
@@ -271,12 +329,21 @@ namespace UnLua
271329
CPF_HasGetValueTypeHash,
272330
UECodeGen_Private::EPropertyGenFlags::Object,
273331
RF_Transient,
332+
#if UE_VERSION_OLDER_THAN(5, 3, 0)
274333
1,
334+
#endif
275335
nullptr,
276336
nullptr,
337+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
338+
1,
339+
#endif
277340
0,
278341
nullptr,
342+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
343+
METADATA_PARAMS(0, nullptr)
344+
#else
279345
METADATA_PARAMS(nullptr, 0)
346+
#endif
280347
};
281348
const auto ObjectProperty = new FObjectProperty(PropertyCollector, Params);
282349
ObjectProperty->PropertyClass = Class;
@@ -297,12 +364,21 @@ namespace UnLua
297364
: CPF_HasGetValueTypeHash,
298365
UECodeGen_Private::EPropertyGenFlags::Struct,
299366
RF_Transient,
367+
#if UE_VERSION_OLDER_THAN(5, 3, 0)
300368
1,
369+
#endif
301370
nullptr,
302371
nullptr,
372+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
373+
1,
374+
#endif
303375
0,
304376
nullptr,
377+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
378+
METADATA_PARAMS(0, nullptr)
379+
#else
305380
METADATA_PARAMS(nullptr, 0)
381+
#endif
306382
};
307383
const auto StructProperty = new FStructProperty(PropertyCollector, Params);
308384
StructProperty->Struct = ScriptStruct;

Plugins/UnLua/Source/UnLua/Public/UnLuaTemplate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ namespace UnLua
9191
template <typename T> struct TArgTypeTraits
9292
{
9393
typedef typename TDecay<T>::Type RT;
94-
typedef typename TChooseClass<TIsPrimitiveTypeOrPointer<RT>::Value, RT, typename TRemoveCV<T>::Type>::Result Type;
94+
typedef typename TChooseClass<TIsPrimitiveTypeOrPointer<RT>::Value, RT, typename std::remove_cv<T>::type>::Result Type;
9595
};
9696

9797

Plugins/UnLua/Source/UnLuaEditor/Private/UnLuaIntelliSenseGenerator.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414

1515
#include "Misc/EngineVersionComparison.h"
1616
#include "UnLuaIntelliSenseGenerator.h"
17+
#if UE_VERSION_NEWER_THAN(5, 2, 0)
18+
#include "AssetRegistry/AssetRegistryModule.h"
19+
#else
1720
#include "AssetRegistryModule.h"
21+
#endif
1822
#include "CoreUObject.h"
1923
#include "UnLua.h"
2024
#include "UnLuaEditorSettings.h"

0 commit comments

Comments
 (0)