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 Nov 13, 2024
2 parents 438a284 + 9bc54f7 commit e27c87b
Show file tree
Hide file tree
Showing 28 changed files with 828 additions and 16,347 deletions.
11 changes: 4 additions & 7 deletions unity/Assets/core/upm/Editor/Src/Generator/IL2Cpp/UnityMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ namespace Generator {
public class UnityMenu {
[MenuItem(Puerts.Editor.Generator.UnityMenu.PUERTS_MENU_PREFIX + "/Generate For xIl2cpp mode (all in one)", false, 2)]
public static void GenV2() {
PuertsIl2cpp.Editor.Generator.UnityMenu.GenerateCppWrappers();
PuertsIl2cpp.Editor.Generator.UnityMenu.GenerateExtensionMethodInfos();
PuertsIl2cpp.Editor.Generator.UnityMenu.GenerateLinkXML();
PuertsIl2cpp.Editor.Generator.UnityMenu.GenerateCppPlugin();
GenerateCppWrappers();
GenerateExtensionMethodInfos();
GenerateLinkXML();
GenerateCppPlugin();
Puerts.Editor.Generator.UnityMenu.GenRegisterInfo();
#if !PUERTS_CPP_OUTPUT_TO_UPM
UnityEngine.Debug.LogWarning("[Puer W001] You are not using upm to install PuerTS or did not add 'PUERTS_CPP_OUTPUT_TO_UPM' definition. Please copy Gen/FunctionBridge.h and Gen/Plugins to the directory of PuerTS to compile native plugin");
#endif
}

[MenuItem(Puerts.Editor.Generator.UnityMenu.PUERTS_MENU_PREFIX + "/Generate/il2cpp c file", false, 6)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "Engine/Blueprint.h"
#include "CodeGenerator.h"
#include "JSClassRegister.h"
#include "UECompatible.h"
#include "Engine/CollisionProfile.h"
#if (ENGINE_MAJOR_VERSION >= 5)
#include "ToolMenus.h"
Expand Down Expand Up @@ -1089,7 +1090,10 @@ void FTypeScriptDeclarationGenerator::GatherExtensions(UStruct* Struct, FStringB
while (PropertyInfo && PropertyInfo->Name && PropertyInfo->Type)
{
if (Struct->FindPropertyByName(UTF8_TO_TCHAR(PropertyInfo->Name)))
{
++PropertyInfo;
continue;
}
Buff << " " << PropertyInfo->Name << ": " << GetNamePrefix(PropertyInfo->Type) << PropertyInfo->Type->Name()
<< ";\n";
++PropertyInfo;
Expand Down Expand Up @@ -1366,7 +1370,6 @@ void FTypeScriptDeclarationGenerator::GenEnum(UEnum* Enum)

void FTypeScriptDeclarationGenerator::GenStruct(UStruct* Struct)
{
#include "ExcludeStructs.h"
FStringBuffer StringBuffer{"", ""};
const FString SafeStructName =
Struct->IsNative() ? SafeName(Struct->GetName()) : PUERTS_NAMESPACE::FilenameToTypeScriptVariableName(Struct->GetName());
Expand Down Expand Up @@ -1396,6 +1399,31 @@ void FTypeScriptDeclarationGenerator::GenStruct(UStruct* Struct)

auto GenConstrutor = [&]()
{
auto ClassDefinition = PUERTS_NAMESPACE::FindClassByType(Struct);
if (ClassDefinition && ClassDefinition->ConstructorInfos)
{
PUERTS_NAMESPACE::NamedFunctionInfo* ConstructorInfo = ClassDefinition->ConstructorInfos;
while (ConstructorInfo && ConstructorInfo->Name && ConstructorInfo->Type)
{
FStringBuffer Tmp;
Tmp << "constructor(";
GenArgumentsForFunctionInfo(ConstructorInfo->Type, Tmp);
Tmp << ")";
StringBuffer << " " << Tmp.Buffer << ";\n";
for (unsigned int i = 0; i < ConstructorInfo->Type->ArgumentCount(); i++)
{
auto argInfo = ConstructorInfo->Type->Argument(i);
if (argInfo->IsUEType())
{
UScriptStruct* UsedStruct = PUERTS_NAMESPACE::FindAnyType<UScriptStruct>(UTF8_TO_TCHAR(argInfo->Name()));
if (UsedStruct)
Gen(UsedStruct);
}
}
++ConstructorInfo;
}
return;
}
FStringBuffer TmpBuff;
TmpBuff << "constructor(";
bool First = true;
Expand Down

This file was deleted.

6 changes: 6 additions & 0 deletions unreal/Puerts/Source/JsEnv/JsEnv.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ public JsEnv(ReadOnlyTargetRules Target) : base(Target)
string coreJSPath = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", "..", "Content"));
string destDirName = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", "..", "..", "..", "Content"));
DirectoryCopy(coreJSPath, destDirName, true);

// 每次build时拷贝一些手写的.d.ts到Typing目录以同步更新
string srcDtsDirName = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", "..", "Typing"));
string dstDtsDirName = Path.GetFullPath(Path.Combine(ModuleDirectory, "..", "..", "..", "..", "Typing"));
DirectoryCopy(srcDtsDirName, dstDtsDirName, true);

}

void OldThirdParty(ReadOnlyTargetRules Target)
Expand Down
5 changes: 0 additions & 5 deletions unreal/Puerts/Source/JsEnv/Private/CppObjectMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@

namespace PUERTS_NAMESPACE
{
template <typename T>
inline void __USE(T&&)
{
}

static void ThrowException(v8::Isolate* Isolate, const char* Message)
{
auto ExceptionStr = v8::String::NewFromUtf8(Isolate, Message, v8::NewStringType::kNormal).ToLocalChecked();
Expand Down
Loading

0 comments on commit e27c87b

Please sign in to comment.