Skip to content

Commit

Permalink
Merge branch 'Tencent:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnoChenFx authored Jun 4, 2024
2 parents 8b1f3da + 238aaca commit 0c36b4b
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unreal_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
env:
Engine: "https://github.com/chexiongsheng/Mini427/releases/download/v1.0.0/Mini427_wami.tgz"
V8_URL: "https://github.com/puerts/backend-v8/releases/download/V8_8.4.371.19_230822/v8_bin_8.4.371.19.tgz"
QJS_URL: "https://github.com/puerts/backend-quickjs/releases/download/QJS_240419/qjs_v8_bin.tgz"
QJS_URL: "https://github.com/puerts/backend-quickjs/releases/download/QJS_240603/qjs_v8_bin.tgz"
NODE_URL: "https://github.com/puerts/backend-nodejs/releases/download/NodeJS_16.16.0_221228/nodejs_bin_16.16.0.tgz"

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unreal_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
UE424_V8: "https://github.com/puerts/backend-v8/releases/download/v8_for_ue424_or_below/v8_for_ue424_or_below.tgz"
V8_84: "https://github.com/puerts/backend-v8/releases/download/V8_8.4.371.19_230822/v8_bin_8.4.371.19.tgz"
V8_94: "https://github.com/puerts/backend-v8/releases/download/V8_9.4.146.24_230822/v8_bin_9.4.146.24.tgz"
quickjs: "https://github.com/puerts/backend-quickjs/releases/download/QJS_240419/qjs_v8_bin.tgz"
quickjs: "https://github.com/puerts/backend-quickjs/releases/download/QJS_240603/qjs_v8_bin.tgz"
nodejs: "https://github.com/puerts/backend-nodejs/releases/download/NodeJS_16.16.0_221228/nodejs_bin_16.16.0.tgz"

jobs:
Expand Down
8 changes: 4 additions & 4 deletions doc/unreal/en/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

* 下载v8

- UE4.25及以上版本:[V8 8.4.371.19](https://github.com/puerts/backend-v8/releases/tag/V8_8.4.371.19_230822), [V8 9.4.146.24 (支持M1)](https://github.com/puerts/backend-v8/releases/tag/V8_9.4.146.24_230822)
- UE4.25及以上版本:[V8 backends](https://github.com/puerts/backend-v8/releases)

- UE4.24及以下版本:[V8 for ue 4.24 or below](https://github.com/puerts/backend-v8/releases/tag/v8_for_ue424_or_below)

Expand All @@ -31,7 +31,7 @@ find . -name "*.dylib" | xargs sudo xattr -r -d com.apple.quarantine

纯蓝图工程不会自动编译Plugins,而Puerts目前的源码或者发布包内,都是C++源码。

可以clone puerts的demo,在vs编译工程后拷贝到纯蓝图工程
一个纯蓝图如何使用一个C++ Plugins是个UE通用问题,目前已知可行的方式是添加一个C++代码把这纯蓝图工程转为C++工程,另外一个比较有可能(但未验证的方式)是自行编译UE引擎,而且编译引擎时把puerts放进去一起编译

### 虚拟机切换

Expand All @@ -41,9 +41,9 @@ puerts支持多种脚本后端:V8,quickjs,nodejs
* 对于包大小苛刻的场景,可以选用quickjs
* nodejs相比v8版本,可以使用更多的npm模块,但包体比v8还要大些

quickjs后端[下载](https://github.com/puerts/backend-quickjs/releases/tag/QJS_231011)
quickjs后端[下载](https://github.com/puerts/backend-quickjs/releases)

nodejs后端[下载](https://github.com/puerts/backend-nodejs/releases/tag/NodeJS_16.16.0_230216)
nodejs后端[下载](https://github.com/puerts/backend-nodejs/releases)

解压到`YouProject/Plugins/Puerts/ThirdParty`

Expand Down
6 changes: 3 additions & 3 deletions doc/unreal/zhcn/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

* 下载v8

- UE4.25及以上版本:[V8 8.4.371.19](https://github.com/puerts/backend-v8/releases/tag/V8_8.4.371.19_230822), [V8 9.4.146.24 (支持M1)](https://github.com/puerts/backend-v8/releases/tag/V8_9.4.146.24_230822)
- UE4.25及以上版本:[V8 backends](https://github.com/puerts/backend-v8/releases)

- UE4.24及以下版本:[V8 for ue 4.24 or below](https://github.com/puerts/backend-v8/releases/tag/v8_for_ue424_or_below)

Expand Down Expand Up @@ -41,9 +41,9 @@ puerts支持多种脚本后端:V8,quickjs,nodejs
* 对于包大小苛刻的场景,可以选用quickjs
* nodejs相比v8版本,可以使用更多的npm模块,但包体比v8还要大些

quickjs后端[下载](https://github.com/puerts/backend-quickjs/releases/tag/QJS_231011)
quickjs后端[下载](https://github.com/puerts/backend-quickjs/releases)

nodejs后端[下载](https://github.com/puerts/backend-nodejs/releases/tag/NodeJS_16.16.0_230216)
nodejs后端[下载](https://github.com/puerts/backend-nodejs/releases)

解压到`YouProject/Plugins/Puerts/ThirdParty`

Expand Down
4 changes: 2 additions & 2 deletions unity/cli/backends.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"quickjs": {
"url": "https://github.com/puerts/backend-quickjs/releases/download/QJS_240424/qjs_v8_bin.tgz",
"url": "https://github.com/puerts/backend-quickjs/releases/download/QJS_240604/qjs_v8_bin.tgz",
"config": {
"definition": [
"V8_94_OR_NEWER",
Expand Down Expand Up @@ -380,7 +380,7 @@
}
},
"mult": {
"url": "https://github.com/puerts/backend-mult/releases/download/MULT_240516/mult_backends.tgz",
"url": "https://github.com/puerts/backend-mult/releases/download/MULT_240604/mult_backends.tgz",
"config": {
"definition": [
"V8_94_OR_NEWER"
Expand Down
90 changes: 90 additions & 0 deletions unity/test/Src/Cases/ExceptionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,5 +314,95 @@ public void UnhandledRejectionCancel()
// Assert.True(jsErrorMessage == "hello error");
// jsEnv.Dispose();
// }

[Test]
public void ThrowNull()
{
var jsEnv = UnitTestEnv.GetEnv();
Assert.Catch(() =>
{
jsEnv.Eval(@"
(function() {
throw null;
})()
");
});
jsEnv.Tick();
}

[Test]
public void ThrowUndefined()
{
var jsEnv = UnitTestEnv.GetEnv();
Assert.Catch(() =>
{
jsEnv.Eval(@"
(function() {
throw undefined;
})()
");
});
jsEnv.Tick();
}

[Test]
public void ThrowNullInModule()
{
var loader = UnitTestEnv.GetLoader();
loader.AddMockFileContent("throw-null/whatever.mjs", @"(function() {throw null;})()");
var jsEnv = UnitTestEnv.GetEnv();
Assert.Catch(() =>
{
jsEnv.ExecuteModule("throw-null/whatever.mjs");
});
jsEnv.Tick();
}

[Test]
public void ThrowUndefinedInModule()
{
var loader = UnitTestEnv.GetLoader();
loader.AddMockFileContent("throw-undefined/whatever.mjs", @"(function() {throw undefined;})()");
var jsEnv = UnitTestEnv.GetEnv();
Assert.Catch(() =>
{
jsEnv.ExecuteModule("throw-undefined/whatever.mjs");
});
jsEnv.Tick();
}

[Test]
public void ThrowNullInFunction()
{
var jsEnv = UnitTestEnv.GetEnv();
Assert.Catch(() =>
{
var foo = jsEnv.Eval<Action>(@"
function t() {
throw null;
}
t;
");
foo();
});
jsEnv.Tick();
}

[Test]
public void ThrowUndefinedInFunction()
{
var jsEnv = UnitTestEnv.GetEnv();
Assert.Catch(() =>
{
var foo = jsEnv.Eval<Action>(@"
function t() {
throw undefined;
}
t;
");
foo();
});
jsEnv.Tick();
}
}
}
7 changes: 4 additions & 3 deletions unreal/Puerts/Content/JavaScript/PuertsEditor/CodeAnalyze.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 41 additions & 19 deletions unreal/Puerts/Source/PuertsEditor/Private/PEBlueprintAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#include "Kismet2/ComponentEditorUtils.h"
#include "Editor.h"
#include "HAL/PlatformFileManager.h"
#include "Framework/Application/SlateApplication.h"
#include "Misc/MessageDialog.h"

#define LOCTEXT_NAMESPACE "UPEBlueprintAsset"

Expand Down Expand Up @@ -548,7 +550,7 @@ void UPEBlueprintAsset::AddFunction(FName InName, bool IsVoid, FPEGraphPinType I
if (EventGraph && !Iter)
{
CanChangeCheck();
//处理标签改变的情况
// 处理标签改变的情况
Blueprint->FunctionGraphs.RemoveAll([&](UEdGraph* Graph) { return Graph->GetFName() == InName; });

UEdGraph* ExistingGraph = FindObject<UEdGraph>(Blueprint, *(InName.ToString()));
Expand Down Expand Up @@ -1080,8 +1082,22 @@ void UPEBlueprintAsset::AddMemberVariable(FName NewVarName, FPEGraphPinType InGr
if (VarIndex == INDEX_NONE)
{
CanChangeCheck();
FBlueprintEditorUtils::AddMemberVariable(Blueprint, NewVarName, PinType);
NeedSave = true;
if (NewVarName == NAME_None)
{
FString Message = FString::Printf(TEXT("VariableName is None, unable to add variable"));
FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(Message));
}
else if (FBlueprintEditorUtils::AddMemberVariable(Blueprint, NewVarName, PinType))
{
NeedSave = true;
}
else
{
FString Message = FString::Printf(
TEXT("Failed to add variable: %s. Please check if the parent class already has a variable with the same name."),
*NewVarName.ToString());
FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(Message));
}
}
else
{
Expand Down Expand Up @@ -1127,24 +1143,36 @@ void UPEBlueprintAsset::AddMemberVariable(FName NewVarName, FPEGraphPinType InGr
NeedSave = true;
}

if ((Variable.PropertyFlags & CPF_DisableEditOnInstance) != (InFlags & CPF_DisableEditOnInstance))
if (InLifetimeCondition < COND_Max && Variable.ReplicationCondition != InLifetimeCondition)
{
CanChangeCheck();
if (InFlags & CPF_DisableEditOnInstance)
{
Blueprint->NewVariables[VarIndex].PropertyFlags |= CPF_DisableEditOnInstance;
}
else
Variable.ReplicationCondition = (ELifetimeCondition) InLifetimeCondition;
NeedSave = true;
}

// Variables added to the blueprint via FBlueprintEditorUtils::AddMemberVariable come with some default flags. To make the
// TS implementation consistent with C++, some of these default flags have been removed. InFlags |= (CPF_Edit |
// CPF_BlueprintVisible);
if (Blueprint->NewVariables[VarIndex].VarType.PinCategory == UEdGraphSchema_K2::PC_MCDelegate)
{
InFlags |= CPF_BlueprintAssignable | CPF_BlueprintCallable;
}
else if ((Blueprint->NewVariables[VarIndex].VarType.PinCategory == UEdGraphSchema_K2::PC_Object) ||
(Blueprint->NewVariables[VarIndex].VarType.PinCategory == UEdGraphSchema_K2::PC_Interface))
{
check(Blueprint->NewVariables[VarIndex].VarType.PinSubCategoryObject.IsValid());
const UClass* ClassObject = Cast<UClass>(Blueprint->NewVariables[VarIndex].VarType.PinSubCategoryObject.Get());
check(ClassObject != nullptr);
if (ClassObject->IsChildOf(AActor::StaticClass()))
{
Blueprint->NewVariables[VarIndex].PropertyFlags &= ~CPF_DisableEditOnInstance;
InFlags |= CPF_DisableEditOnTemplate;
}
NeedSave = true;
}

if (InLifetimeCondition < COND_Max && Variable.ReplicationCondition != InLifetimeCondition)
if (Variable.PropertyFlags != InFlags)
{
CanChangeCheck();
Variable.ReplicationCondition = (ELifetimeCondition) InLifetimeCondition;
Blueprint->NewVariables[VarIndex].PropertyFlags = InFlags;
NeedSave = true;
}
}
Expand All @@ -1159,12 +1187,6 @@ void UPEBlueprintAsset::AddMemberVariableWithMetaData(FName InNewVarName, FPEGra
EPropertyFlags InputFlags = static_cast<EPropertyFlags>((static_cast<uint64>(InHFLags) << 32) + InLFlags);

InputFlags |= InMetaData->PropertyFlags;
// meta data has instanced specifier
if (InMetaData->MetaData.Contains(TEXT("EditInline")))
{
InputFlags &= ~CPF_DisableEditOnInstance;
}

InLFlags = (static_cast<uint64>(InputFlags) & 0xffffffff);
InHFLags = (static_cast<uint64>(InputFlags) >> 32);
}
Expand Down

0 comments on commit 0c36b4b

Please sign in to comment.