Init
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "CodeGenerator.generated.h"
|
||||
|
||||
// This class does not need to be modified.
|
||||
UINTERFACE(MinimalAPI)
|
||||
class UCodeGenerator : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class DECLARATIONGENERATOR_API ICodeGenerator
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
|
||||
public:
|
||||
UFUNCTION(BlueprintNativeEvent)
|
||||
void Gen() const;
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making Puerts available.
|
||||
* Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
* Puerts is licensed under the BSD 3-Clause License, except for the third-party components listed in the file 'LICENSE' which may
|
||||
* be subject to their corresponding license terms. This file is subject to the terms and conditions defined in file 'LICENSE',
|
||||
* which is part of this source code package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Framework/Commands/Commands.h"
|
||||
#include "GenDTSStyle.h"
|
||||
|
||||
class FGenDTSCommands : public TCommands<FGenDTSCommands>
|
||||
{
|
||||
public:
|
||||
FGenDTSCommands()
|
||||
: TCommands<FGenDTSCommands>(
|
||||
TEXT("GenDTS"), NSLOCTEXT("Contexts", "GenDTS", "GenDTS Plugin"), NAME_None, FGenDTSStyle::GetStyleSetName())
|
||||
{
|
||||
}
|
||||
|
||||
// TCommands<> interface
|
||||
void RegisterCommands() override;
|
||||
|
||||
public:
|
||||
TSharedPtr<FUICommandInfo> PluginAction;
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making Puerts available.
|
||||
* Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
* Puerts is licensed under the BSD 3-Clause License, except for the third-party components listed in the file 'LICENSE' which may
|
||||
* be subject to their corresponding license terms. This file is subject to the terms and conditions defined in file 'LICENSE',
|
||||
* which is part of this source code package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Styling/SlateStyle.h"
|
||||
|
||||
class FGenDTSStyle
|
||||
{
|
||||
public:
|
||||
static void Initialize();
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
/** reloads textures used by slate renderer */
|
||||
static void ReloadTextures();
|
||||
|
||||
/** @return The Slate style set for the Shooter game */
|
||||
static const ISlateStyle& Get();
|
||||
|
||||
static FName GetStyleSetName();
|
||||
|
||||
private:
|
||||
static TSharedRef<class FSlateStyleSet> Create();
|
||||
|
||||
private:
|
||||
static TSharedPtr<class FSlateStyleSet> StyleInstance;
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making Puerts available.
|
||||
* Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
* Puerts is licensed under the BSD 3-Clause License, except for the third-party components listed in the file 'LICENSE' which may
|
||||
* be subject to their corresponding license terms. This file is subject to the terms and conditions defined in file 'LICENSE',
|
||||
* which is part of this source code package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "Modules/ModuleManager.h"
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
class IDeclarationGenerator : public IModuleInterface //: public IScriptGeneratorPluginInterface
|
||||
{
|
||||
public:
|
||||
static inline IDeclarationGenerator& Get()
|
||||
{
|
||||
return FModuleManager::LoadModuleChecked<IDeclarationGenerator>("DeclarationGenerator");
|
||||
}
|
||||
|
||||
static inline bool IsAvailable()
|
||||
{
|
||||
return FModuleManager::Get().IsModuleLoaded("DeclarationGenerator");
|
||||
}
|
||||
|
||||
virtual void GenTypeScriptDeclaration(bool InGenFull, FName InSearchPath) = 0;
|
||||
|
||||
virtual void GenReactDeclaration() = 0;
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CodeGenerator.h"
|
||||
#include "TypeScriptDeclarationGenerator.h"
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/NoExportTypes.h"
|
||||
#include "TemplateBindingGenerator.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class DECLARATIONGENERATOR_API UTemplateBindingGenerator : public UObject, public ICodeGenerator
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintNativeEvent)
|
||||
void Gen() const;
|
||||
|
||||
virtual void Gen_Implementation() const override;
|
||||
};
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making Puerts available.
|
||||
* Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
* Puerts is licensed under the BSD 3-Clause License, except for the third-party components listed in the file 'LICENSE' which may
|
||||
* be subject to their corresponding license terms. This file is subject to the terms and conditions defined in file 'LICENSE',
|
||||
* which is part of this source code package.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "PropertyMacros.h"
|
||||
|
||||
struct DECLARATIONGENERATOR_API FStringBuffer
|
||||
{
|
||||
FString Buffer;
|
||||
|
||||
FString Prefix;
|
||||
|
||||
FStringBuffer& operator<<(const FString& InText);
|
||||
|
||||
FStringBuffer& operator<<(const TCHAR* InText);
|
||||
|
||||
FStringBuffer& operator<<(const char* InText);
|
||||
|
||||
FStringBuffer& operator<<(const FStringBuffer& Other);
|
||||
|
||||
void Indent(int Num);
|
||||
};
|
||||
|
||||
struct DECLARATIONGENERATOR_API FTypeScriptDeclarationGenerator
|
||||
{
|
||||
FStringBuffer Output{"", ""};
|
||||
TSet<UObject*> Processed;
|
||||
TSet<FString> ProcessedByName;
|
||||
std::map<UStruct*, std::vector<UFunction*>> ExtensionMethodsMap;
|
||||
struct FunctionKey
|
||||
{
|
||||
FunctionKey(const FString& InFunctioName, bool InIsStatic) : FunctionName(InFunctioName), IsStatic(InIsStatic)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator<(const FunctionKey& other) const
|
||||
{
|
||||
return IsStatic != other.IsStatic ? IsStatic < other.IsStatic : FunctionName < other.FunctionName;
|
||||
}
|
||||
|
||||
FString FunctionName;
|
||||
bool IsStatic;
|
||||
};
|
||||
typedef TArray<FString> FunctionOverloads;
|
||||
typedef std::map<FunctionKey, FunctionOverloads> FunctionOutputs;
|
||||
std::map<UStruct*, FunctionOutputs> AllFuncionOutputs;
|
||||
|
||||
std::map<UObject*, FString> NamespaceMap;
|
||||
|
||||
std::map<UObject*, bool> PathIsValidMap;
|
||||
|
||||
struct BlueprintTypeDeclInfo
|
||||
{
|
||||
TMap<FName, FString> NameToDecl;
|
||||
FString FileVersionString;
|
||||
bool IsExist;
|
||||
bool Changed;
|
||||
bool IsAssociation;
|
||||
};
|
||||
|
||||
TMap<FName, BlueprintTypeDeclInfo> BlueprintTypeDeclInfoCache;
|
||||
|
||||
TArray<FAssetData> AssetList;
|
||||
|
||||
bool RefFromOuter = false;
|
||||
|
||||
bool BeginGenAssetData = false;
|
||||
|
||||
const FString& GetNamespace(UObject* Obj);
|
||||
|
||||
FString GetNameWithNamespace(UObject* Obj);
|
||||
|
||||
void NamespaceBegin(UObject* Obj, FStringBuffer& Buff);
|
||||
|
||||
void NamespaceEnd(UObject* Obj, FStringBuffer& Buff);
|
||||
|
||||
void WriteOutput(UObject* Obj, const FStringBuffer& Buff);
|
||||
|
||||
void RestoreBlueprintTypeDeclInfos(bool InGenFull);
|
||||
|
||||
void RestoreBlueprintTypeDeclInfos(const FString& FileContent, bool InGenFull);
|
||||
|
||||
void LoadAllWidgetBlueprint(FName InSearchPath, bool InGenFull);
|
||||
|
||||
void InitExtensionMethodsMap();
|
||||
|
||||
virtual void Begin(FString Namespace = TEXT("ue"));
|
||||
|
||||
void GenTypeScriptDeclaration(bool InGenStruct, bool InGenEnum);
|
||||
|
||||
virtual void Gen(UObject* ToGen);
|
||||
|
||||
virtual bool GenTypeDecl(FStringBuffer& StringBuffer, PropertyMacro* Property, TArray<UObject*>& AddToGen,
|
||||
bool ArrayDimProcessed = false, bool TreatAsRawFunction = false);
|
||||
|
||||
virtual bool GenFunction(FStringBuffer& OwnerBuffer, UFunction* Function, bool WithName = true, bool ForceOneway = false,
|
||||
bool IgnoreOut = false, bool IsExtensionMethod = false);
|
||||
|
||||
void GatherExtensions(UStruct* Struct, FStringBuffer& Buff);
|
||||
|
||||
void GenResolvedFunctions(UStruct* Struct, FStringBuffer& Buff);
|
||||
|
||||
FunctionOutputs& GetFunctionOutputs(UStruct* Struct);
|
||||
|
||||
FunctionOverloads& GetFunctionOverloads(FunctionOutputs& Outputs, const FString& FunctionName, bool IsStatic);
|
||||
|
||||
void TryToAddOverload(FunctionOutputs& Outputs, const FString& FunctionName, bool IsStatic, const FString& Overload);
|
||||
|
||||
virtual void GenClass(UClass* Class);
|
||||
|
||||
virtual void GenEnum(UEnum* Enum);
|
||||
|
||||
virtual void GenStruct(UStruct* Struct);
|
||||
|
||||
virtual void End();
|
||||
|
||||
FString ToString();
|
||||
|
||||
virtual ~FTypeScriptDeclarationGenerator()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
bool HasUENamespace(const char* name);
|
||||
|
||||
bool HadNamespace(const char* name);
|
||||
Reference in New Issue
Block a user