Files
UnrealEngineUWP/Engine/Plugins/ScriptPlugin/Source/ScriptGeneratorPlugin/Private/ScriptCodeGeneratorBase.h
Marc Audy 360d078ca3 Second batch of remaining Engine copyright updates.
#rnx
#rb none

[CL 10871248 by Marc Audy in Main branch]
2019-12-27 09:26:59 -05:00

64 lines
2.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
/**
* Base for script code generators.
* Contains utility functions that may be common to more specialized script glue generators.
*/
class FScriptCodeGeneratorBase
{
/** List of temporary header files crated by SaveHeaderIfChanged */
TArray<FString> TempHeaders;
protected:
/** Path where generated script glue goes **/
FString GeneratedCodePath;
/** Local root path **/
FString RootLocalPath;
/** Build root path - may be different to RootBuildPath if we're building remotely. **/
FString RootBuildPath;
/** Base include directory */
FString IncludeBase;
/** Set of all exported class names */
TSet<FName> ExportedClasses;
/** Default ctor */
FScriptCodeGeneratorBase(const FString& InRootLocalPath, const FString& InRootBuildPath, const FString& OutputDirectory, const FString& InIncludeBase);
/** Saves generated script glue heade to a temporary file if its contents is different from the eexisting one. */
bool SaveHeaderIfChanged(const FString& HeaderPath, const FString& NewHeaderContents);
/** Renames/replaces all existing script glue files with the temporary (new) ones */
void RenameTempFiles();
/** Re-bases the local path to build path */
FString RebaseToBuildPath(const FString& FileName) const;
/** Converts a UClass name to C++ class name (with U/A prefix) */
FString GetClassNameCPP(UClass* Class);
/** Gets C++ friendly property type name. */
FString GetPropertyTypeCPP(FProperty* Property, uint32 PortFlags = 0);
virtual FString GenerateFunctionDispatch(UFunction* Function);
virtual FString InitializeFunctionDispatchParam(UFunction* Function, FProperty* Param, int32 ParamIndex);
/** Generates a script glue header filename for the specified class */
virtual FString GetScriptHeaderForClass(UClass* Class);
/** Returns true if the specified class can be exported */
virtual bool CanExportClass(UClass* Class);
/** Returns true if the specified function can be exported */
virtual bool CanExportFunction(const FString& ClassNameCPP, UClass* Class, UFunction* Function);
/** Returns true if the specified property can be exported */
virtual bool CanExportProperty(const FString& ClassNameCPP, UClass* Class, FProperty* Property);
public:
virtual ~FScriptCodeGeneratorBase() {}
// IScriptGeneratorPlugin interface
virtual void ExportClass(UClass* Class, const FString& SourceHeaderFilename, const FString& GeneratedHeaderFilename, bool bHasChanged) = 0;
virtual void FinishExport() = 0;
};