Skip to content

Commit 0a30171

Browse files
authored
Merge branch 'Tencent:master' into fix/libnode
2 parents b5461ca + 3700a56 commit 0a30171

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

unity/native/puerts/source/Puerts.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ PESAPI_MODULE_EXPORT pesapi_registry_api* GetRegisterApi()
4141
PESAPI_MODULE_EXPORT void SetLogCallback(LogCallback Log, LogCallback LogWarning, LogCallback LogError)
4242
{
4343
GLogCallback = Log;
44-
GLogWarningCallback = LogError;
45-
GLogErrorCallback = LogWarning;
44+
GLogWarningCallback = LogWarning;
45+
GLogErrorCallback = LogError;
4646
}
4747

4848
#ifdef __cplusplus

unity/nuget/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<NoWarn>NU5128</NoWarn>
66

7-
<BuildPackageVersion>3.0.0-alpha3</BuildPackageVersion>
7+
<BuildPackageVersion>3.0.0-alpha4</BuildPackageVersion>
88

99
<PackageProjectUrl>https://github.com/Tencent/puerts</PackageProjectUrl>
1010

unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,15 +2832,16 @@ v8::Local<v8::Value> FJsEnvImpl::FindOrAddContainer(
28322832
check(Ptr); // must not null
28332833

28342834
auto PersistentValuePtr = ContainerCache.Find(Ptr);
2835-
if (PersistentValuePtr)
2835+
if (PersistentValuePtr && PersistentValuePtr->Type == EArray && PersistentValuePtr->KeyProperty == Property &&
2836+
PersistentValuePtr->ValueProperty == nullptr)
28362837
{
28372838
return PersistentValuePtr->Container.Get(Isolate);
28382839
}
28392840

28402841
auto Result = ArrayTemplate.Get(Isolate)->InstanceTemplate()->NewInstance(Context).ToLocalChecked();
28412842
BindContainer(Ptr, Result,
28422843
PassByPointer ? FScriptArrayWrapper::OnGarbageCollected : FScriptArrayWrapper::OnGarbageCollectedWithFree, PassByPointer,
2843-
EArray);
2844+
EArray, Property, nullptr);
28442845
DataTransfer::SetPointer(Isolate, Result, GetContainerPropertyTranslator(Property), 1);
28452846
return Result;
28462847
}
@@ -2851,14 +2852,16 @@ v8::Local<v8::Value> FJsEnvImpl::FindOrAddContainer(
28512852
check(Ptr); // must not null
28522853

28532854
auto PersistentValuePtr = ContainerCache.Find(Ptr);
2854-
if (PersistentValuePtr)
2855+
if (PersistentValuePtr && PersistentValuePtr->Type == ESet && PersistentValuePtr->KeyProperty == Property &&
2856+
PersistentValuePtr->ValueProperty == nullptr)
28552857
{
28562858
return PersistentValuePtr->Container.Get(Isolate);
28572859
}
28582860

28592861
auto Result = SetTemplate.Get(Isolate)->InstanceTemplate()->NewInstance(Context).ToLocalChecked();
28602862
BindContainer(Ptr, Result,
2861-
PassByPointer ? FScriptSetWrapper::OnGarbageCollected : FScriptSetWrapper::OnGarbageCollectedWithFree, PassByPointer, ESet);
2863+
PassByPointer ? FScriptSetWrapper::OnGarbageCollected : FScriptSetWrapper::OnGarbageCollectedWithFree, PassByPointer, ESet,
2864+
Property, nullptr);
28622865
DataTransfer::SetPointer(Isolate, Result, GetContainerPropertyTranslator(Property), 1);
28632866
return Result;
28642867
}
@@ -2869,14 +2872,16 @@ v8::Local<v8::Value> FJsEnvImpl::FindOrAddContainer(v8::Isolate* Isolate, v8::Lo
28692872
check(Ptr); // must not null
28702873

28712874
auto PersistentValuePtr = ContainerCache.Find(Ptr);
2872-
if (PersistentValuePtr)
2875+
if (PersistentValuePtr && PersistentValuePtr->Type == EMap && PersistentValuePtr->KeyProperty == KeyProperty &&
2876+
PersistentValuePtr->ValueProperty == ValueProperty)
28732877
{
28742878
return PersistentValuePtr->Container.Get(Isolate);
28752879
}
28762880

28772881
auto Result = MapTemplate.Get(Isolate)->InstanceTemplate()->NewInstance(Context).ToLocalChecked();
28782882
BindContainer(Ptr, Result,
2879-
PassByPointer ? FScriptMapWrapper::OnGarbageCollected : FScriptMapWrapper::OnGarbageCollectedWithFree, PassByPointer, EMap);
2883+
PassByPointer ? FScriptMapWrapper::OnGarbageCollected : FScriptMapWrapper::OnGarbageCollectedWithFree, PassByPointer, EMap,
2884+
KeyProperty, ValueProperty);
28802885
DataTransfer::SetPointer(Isolate, Result, GetContainerPropertyTranslator(KeyProperty), 1);
28812886
DataTransfer::SetPointer(Isolate, Result, GetContainerPropertyTranslator(ValueProperty), 2);
28822887
return Result;
@@ -3003,11 +3008,11 @@ void FJsEnvImpl::UnBindCppObject(v8::Isolate* Isolate, JSClassDefinition* ClassD
30033008
}
30043009

30053010
void FJsEnvImpl::BindContainer(void* Ptr, v8::Local<v8::Object> JSObject, void (*Callback)(const v8::WeakCallbackInfo<void>& data),
3006-
bool PassByPointer, ContainerType Type)
3011+
bool PassByPointer, ContainerType Type, PropertyMacro* KeyProperty, PropertyMacro* ValueProperty)
30073012
{
30083013
DataTransfer::SetPointer(MainIsolate, JSObject, Ptr, 0);
3009-
ContainerCacheItem& Val =
3010-
ContainerCache.Add(Ptr, {v8::UniquePersistent<v8::Value>(MainIsolate, JSObject), !PassByPointer, Type});
3014+
ContainerCacheItem& Val = ContainerCache.Add(
3015+
Ptr, {v8::UniquePersistent<v8::Value>(MainIsolate, JSObject), !PassByPointer, Type, KeyProperty, ValueProperty});
30113016
Val.Container.SetWeak<void>(nullptr, Callback, v8::WeakCallbackType::kInternalFields);
30123017
}
30133018

unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class FJsEnvImpl : public IJsEnv, IObjectMapper, public FUObjectArray::FUObjectD
185185
};
186186

187187
void BindContainer(void* Ptr, v8::Local<v8::Object> JSObject, void (*Callback)(const v8::WeakCallbackInfo<void>& data),
188-
bool PassByPointer, ContainerType Type);
188+
bool PassByPointer, ContainerType Type, PropertyMacro* KeyProperty, PropertyMacro* ValueProperty);
189189

190190
virtual void UnBindContainer(void* Ptr) override;
191191

@@ -580,6 +580,8 @@ class FJsEnvImpl : public IJsEnv, IObjectMapper, public FUObjectArray::FUObjectD
580580
v8::UniquePersistent<v8::Value> Container;
581581
bool NeedRelease;
582582
ContainerType Type;
583+
PropertyMacro* KeyProperty;
584+
PropertyMacro* ValueProperty;
583585
};
584586

585587
TMap<void*, ContainerCacheItem> ContainerCache;

0 commit comments

Comments
 (0)