3
3
#include " Translator.h"
4
4
#include " JavascriptStats.h"
5
5
#include " UObject/GCObject.h"
6
+ #include " ../../Launch/Resources/Version.h"
7
+ #include " v8-version.h"
6
8
7
9
PRAGMA_DISABLE_SHADOW_VARIABLE_WARNINGS
8
10
@@ -106,29 +108,31 @@ class FJavascriptDelegate : public FGCObject, public TSharedFromThis<FJavascript
106
108
auto toJSON = [](const FunctionCallbackInfo<Value>& info) {
107
109
auto payload = reinterpret_cast <FJavascriptDelegate*>(Local<External>::Cast (info.Data ())->Value ());
108
110
109
- uint32_t Index = 0 ;
110
- auto arr = Array::New (info.GetIsolate (), payload->DelegateObjects .Num ());
111
+ uint32_t Index = 0 ;
112
+ auto isolate_ = info.GetIsolate ();
113
+ auto context_ = isolate_->GetCurrentContext ();
114
+ auto arr = Array::New (isolate_, payload->DelegateObjects .Num ());
111
115
const bool bIsMulticastDelegate = payload->Property ->IsA (UMulticastDelegateProperty::StaticClass ());
112
116
113
117
for (auto DelegateObject : payload->DelegateObjects )
114
118
{
115
119
auto JavascriptFunction = payload->functions .Find (DelegateObject->UniqueId );
116
120
if (JavascriptFunction)
117
121
{
118
- auto function = Local<Function>::New (info. GetIsolate () , *JavascriptFunction);
122
+ auto function = Local<Function>::New (isolate_ , *JavascriptFunction);
119
123
if (!bIsMulticastDelegate)
120
124
{
121
125
info.GetReturnValue ().Set (function);
122
126
return ;
123
127
}
124
128
125
- arr->Set (Index++, function);
129
+ arr->Set (context_, Index++, function);
126
130
}
127
131
}
128
132
129
133
if (!bIsMulticastDelegate)
130
134
{
131
- info.GetReturnValue ().Set (Null (info. GetIsolate () ));
135
+ info.GetReturnValue ().Set (Null (isolate_ ));
132
136
}
133
137
else
134
138
{
@@ -224,8 +228,12 @@ class FJavascriptDelegate : public FGCObject, public TSharedFromThis<FJavascript
224
228
FScriptDelegate Delegate;
225
229
Delegate.BindUFunction (DelegateObject, NAME_Fire);
226
230
231
+ #if ENGINE_MINOR_VERSION > 22
232
+ p->AddDelegate (Delegate, WeakObject.Get ());
233
+ #else
227
234
auto Target = p->GetPropertyValuePtr_InContainer (WeakObject.Get ());
228
235
Target->Add (Delegate);
236
+ #endif
229
237
}
230
238
else if (auto p = Cast<UDelegateProperty>(Property))
231
239
{
@@ -250,9 +258,12 @@ class FJavascriptDelegate : public FGCObject, public TSharedFromThis<FJavascript
250
258
{
251
259
FScriptDelegate Delegate;
252
260
Delegate.BindUFunction (DelegateObject, NAME_Fire);
253
-
261
+ #if ENGINE_MINOR_VERSION > 22
262
+ p->RemoveDelegate (Delegate, WeakObject.Get ());
263
+ #else
254
264
auto Target = p->GetPropertyValuePtr_InContainer (WeakObject.Get ());
255
265
Target->Remove (Delegate);
266
+ #endif
256
267
}
257
268
else if (auto p = Cast<UDelegateProperty>(Property))
258
269
{
@@ -374,17 +385,18 @@ struct FDelegateManager : IDelegateManager
374
385
virtual Local<Value> GetProxy (Local<Object> This, UObject* Object, UProperty* Property) override
375
386
{
376
387
auto cache_id = V8_KeywordString (isolate_, FString::Printf (TEXT (" $internal_%s" ), *(Property->GetName ())));
377
- auto cached = This->Get (cache_id);
378
- if (cached.IsEmpty () || cached->IsUndefined ())
388
+ auto context_ = isolate_->GetCurrentContext ();
389
+ auto maybe_cached = This->Get (context_, cache_id);
390
+ if (maybe_cached.IsEmpty () || maybe_cached.ToLocalChecked ()->IsUndefined ())
379
391
{
380
392
auto created = CreateDelegate (Object, Property);
381
393
382
- This->Set (cache_id, created);
394
+ This->Set (context_, cache_id, created);
383
395
return created;
384
396
}
385
397
else
386
398
{
387
- return cached ;
399
+ return maybe_cached. ToLocalChecked () ;
388
400
}
389
401
}
390
402
};
0 commit comments