You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
========================== MAJOR FEATURES + CHANGES ========================== Change 2946506 on 2016/04/18 by Steven.Hutton Update to Crash Reporter buggs table to add new search fields and inclusion of packages needed for e-mail reports. Change 3017807 on 2016/06/17 by Chris.Wood Improved Crash Report Process folder delete code as it could sometimes fail. [UE-30349] - Crash Report Process is leaving crashes in the landing zone that build up and block the queue Also added logging to Slack when stop request received instead of just when stop is complete. Change 3019367 on 2016/06/20 by Chris.Wood Improve Crash Report Process logging to track bad reads from S3. Also, better logging when CleanReport fails to delete folders. Change 3019376 on 2016/06/20 by Steve.Robb Clarification of assert message and comments which talk about 'null' TFunctions. Tidy-up of dead code. Change 3019409 on 2016/06/20 by Steve.Robb New Find and FindByPredicate algorithms for finding stuff in arbitrary containers. Change 3022658 on 2016/06/22 by Chris.Wood Discarding duplicated crash reports earlier in read from Data Router process to avoid clashes in the landing zone (CRP v1.1.11) [UE-30349] - Crash Report Process is leaving crashes in the landing zone that build up and block the queue Also improved logging to Slack with better layout, fixed event ordering and counting duplicates. Change 3022840 on 2016/06/22 by Steve.Robb Skipped UHT attributes removed. Change 3022907 on 2016/06/22 by Robert.Manuszewski Fixing crash when adding a new C++ class to project #jira UE-32333 Change 3023169 on 2016/06/22 by Steve.Robb Checks for UTHINGs in skipped preprocessor blocks. Fixes for skipped UTHINGs and some other parsing accidents. #jira UE-31627 Change 3023239 on 2016/06/22 by Steve.Robb Fix for JSON date parsing reported here: https://udn.unrealengine.com/questions/299342/fdatetime-json-serialization-bug.html Change 3026812 on 2016/06/24 by Mieszko.Zielinski Marked FEnvQueryInstance::AddItemData UEnvQueryItemType_Point specialization as AIMODULE_API #UE4 Change3028235on 2016/06/27 by Robert.Manuszewski PR #2535: BUGFIX: FPS pop-up updates when loading new stat file (Contributed by projectgheist) Change 3028282 on 2016/06/27 by Steve.Robb Fix for missing UFUNCTION check in skipped preprocessor blocks. #jira UE-31627 Change 3028284 on 2016/06/27 by Steve.Robb Debuggability improvements and coding standards changes. Change 3028343 on 2016/06/27 by Steve.Robb Fix for UHT error in WEX. #jira UE-32464 Change 3028393 on 2016/06/27 by Steve.Robb Fix for hot reload of enums finding the old enum. Fix to stop SPropertyEditorNumeric caching the enum flags. #jira UE-31658 Change 3030362 on 2016/06/28 by Robert.Manuszewski Fixing hang when cooking. Change 3030462 on 2016/06/28 by Steve.Robb Assert added to PackageTools::GetFilteredPackageList() to help with catching a bug reported in the wild. #jira UE-32001 Change 3034341 on 2016/06/30 by Robert.Manuszewski Modified crash handling code (on Windows) to handle two threads crashing at the same time properly. Previously the second crash would force the process to exit before generating the crash report. Added 'debug twothreadsgpf' command to test the functionality. Change 3034342 on 2016/06/30 by John.Mahoney Fix for crash when loading an empty cached asset registry. #jira UE-32232 Change 3035599 on 2016/07/01 by Chris.Wood Added support for CrashType string to Crash Report Process. CRP v1.1.12 [UE-30592] - Crash Reporter should determine crash type on client and pass string to server Also fixes problem with reports falling back on the legacy WER metadata when a crash context exists. They now only read the error message from metadata if available and keep crash context data when possible. Added in missing crash context parameters that have been added to clients but not known by the server. Change 3035787 on 2016/07/01 by John.Mahoney Fix for crash when DuplicateRedirects does not contain the DependentObject when saving dependencies. It will still fall through to the assertion below, but it will now fail with a useful error message instead of a generic 'Pair != nullptr' from Map.h. #jira UE-30189 Change 3036933 on 2016/07/04 by Steve.Robb Proper forwarding constructor for FAsyncTask. Change 3036938 on 2016/07/04 by Steve.Robb Fix for CDO hot reload corrupting memory when replacing references inside structs. #jira UE-29335 Change 3036960 on 2016/07/04 by Steve.Robb Fix for FAnsiAllocator::ResizeAllocation when resizing to zero. Change 3037423 on 2016/07/05 by Steve.Robb FModuleManager::UnloadOrAbandonModuleWithCallback split into two instead of switching behavior with a bool. Change 3037464 on 2016/07/05 by Steve.Robb HotReload.cpp cleanup: Deep nesting flattened. Linear array searches replaced with maps. FHotReloadModule::GetGameModules made into a non-member function and split into two. Comment and coding standard fixes. Change 3037741 on 2016/07/05 by John.Mahoney Fix for COTF not checking the correct timestamps on startup. #jira UE-31023 Change3037846on 2016/07/05 by Steve.Robb Fix for compile button disappearing on a bad compile. #jira UE-31575 Change 3037994 on 2016/07/05 by Steve.Robb Static analysis fixes: warning C6308: 'realloc' might return null pointer: assigning null pointer to 'Data', which is passed as an argument to 'realloc', will cause the original memory block to be leaked. Change 3039186 on 2016/07/06 by Robert.Manuszewski Enabling crash callstack logging by default. Change 3039220 on 2016/07/06 by Steve.Robb Static analysis fixes: warning C28159: Consider using 'InitiateSystemShutdownEx' instead of 'ExitWindowsEx'. Reason: Legacy API. Rearchitect to avoid Reboot warning C6001: Using uninitialized memory 'UserNameLength' warning C6001: Using uninitialized memory 'DomainNameLength' Change 3039230 on 2016/07/06 by Steve.Robb Fix for VC internal compiler errors. Change 3039237 on 2016/07/06 by Steve.Robb Static analysis fix: warning C6385: Reading invalid data from 'Path': the readable size is '400' bytes, but 'PathCurrentDepth' bytes may be read. Change 3039287 on 2016/07/06 by Steve.Robb Static analysis fixes: warning C6509: Invalid annotation: 'return' cannot be referenced in some contexts warning C6101: Returning uninitialized memory '*lpdwExitCode'. A successful path through the function does not set the named _Out_ parameter. warning C6387: '_Param_(1)' could be '0': this does not adhere to the specification for the function 'IMoniker::BindToStorage'. warning C6387: '_Param_(1)' could be '0': this does not adhere to the specification for the function 'IMoniker::BindToObject'. warning C6031: Return value ignored: 'CoCreateInstance'. Change 3039359 on 2016/07/06 by Graeme.Thornton Compile error fix for FAsyncTask, courtesy of SteveR Change 3039534 on 2016/07/06 by Steve.Robb Static analysis fix: warning C6319: Use of the comma-operator in a tested expression causes the left argument to be ignored when it has no side-effects. Change 3039545 on 2016/07/06 by Steve.Robb Static analysis fix: warning C6297: Arithmetic overflow: 32-bit value is shifted, then cast to 64-bit value. Results might not be an expected value. Change 3039578 on 2016/07/06 by Steve.Robb Static analysis fix: warning C6263: Using _alloca in a loop: this can quickly overflow stack. Change 3039623 on 2016/07/06 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'X' warning C6308:'realloc' might return null pointer: assigning null pointer to 'X', which is passed as an argument to 'realloc', will cause the original memory block to be leaked. warning C6385: Reading invalid data from 'X': the readable size is 'Y' bytes, but 'Z' bytes may be read. warning C6386: Buffer overrun while writing to 'X': the writable size is 'Y' bytes, but 'Z' bytes might be written. warning C28182: Dereferencing NULL pointer. 'X' contains the same NULL value as 'Y' did. Change 3039630 on 2016/07/06 by John.Mahoney Fix for crash when spawning an actor using a template object that has instance components. UActorComponent::PostInitProperties was adding itself to the owner's InstanceComponents array, resulting in a realloc of that array and invalidating the reference that the owner's ObjectInitializer was trying to replace while instantiating that property. The new instance component will be added to the array as part of the owner's initialization anyway, so it is not necessary to do it here. #jira UE-29123 Change 3039664 on 2016/07/06 by Steve.Robb Static analysis fixes: warning C6386: Buffer overrun while writing to 'NewKeys': the writable size is 'NewIndexSize*4' bytes, but '8' bytes might be written. warning C6386: Buffer overrun while writing to 'NewHeapIndexes': the writable size is 'NewIndexSize*4' bytes, but '8' bytes might be written. Change 3039673 on 2016/07/06 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'v'. Change 3039690 on 2016/07/06 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'X'. warning C6246: Local declaration of 'X' hides declaration of the same name in outer scope. warning C6262: Function uses '121180' bytes of stack: exceeds /analyze:stacksize '81940'. Consider moving some data to heap. warning C6263: Using _alloca in a loop: this can quickly overflow stack. Change 3040868 on 2016/07/07 by Graeme.Thornton Config based class stripping for server builds Change 3040872 on 2016/07/07 by Graeme.Thornton Remove "return false" NeedsLoadForServer functions from engine code Change3040997on 2016/07/07 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'Landscape'. warning C6011: Dereferencing NULL pointer 'rhs.Allocation.LayerInfo'. warning C6011: Dereferencing NULL pointer 'lhs.Allocation.LayerInfo'. Change 3041004 on 2016/07/07 by Steve.Robb Static analysis fix: warning C6336: Arithmetic operator has precedence over question operator, use parentheses to clarify intent. Change 3041014 on 2016/07/07 by Steve.Robb Static analysis fix: warning C6287: Redundant code: the left and right sub-expressions are identical. Change 3041111 on 2016/07/07 by Steve.Robb Removal of an obsolete error message about INI file case sensitivity. Change 3041150 on 2016/07/07 by Steve.Robb Static analysis fix: warning C6289: Incorrect operator: mutual exclusion over || is always a non-zero constant. Did you intend to use && instead? Change 3041274 on 2016/07/07 by Steve.Robb Static analysis fixes: warning C6001: Using uninitialized memory 'X'. Change 3041294 on 2016/07/07 by Chris.Wood Fixed protocol buffer and decompression errors in Crash Report Process (v.1.1.14) [UE-32151] - High number of crashes read from S3 by Crash Report Process are failing to unpack Size of buffer received from S3 is incorrect for some records. Fixed read problems by using size header value instead of stream length. Increased buffer size for decompression as this was sometimes too small. Modified S3 reading code to look for multiple records in each downloaded file. Change 3041472 on 2016/07/07 by Steve.Robb Static analysis fixes: warning C6294: Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed. warning C6201: Index '1' is out of valid index range '0' to '0' for possibly stack allocated buffer 'NewHistory.Nodes'. Change 3043074 on 2016/07/08 by John.Mahoney Fix for COTF incorrectly reconstructing the original asset path based on the sandbox path when the game name differs from the game folder name. Fix for COTF GetFiles not handling absolute GameDir paths properly. #jira UE-31023 Change 3044461 on 2016/07/11 by Steve.Robb Static analysis fix: warning C6386: Buffer overrun while writing to 'Attributes': the writable size is '16384' bytes, but '-8' bytes might be written. Change 3044470 on 2016/07/11 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Node.Sequence'. Change 3044476 on 2016/07/11 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Property'. Change 3044551 on 2016/07/11 by Steve.Robb Static analysis fix: warning C28182: Dereferencing NULL pointer. 'Node' contains the same NULL value as 'KeyAreaNode' did. Change 3044664 on 2016/07/11 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'ToLandscape->SplineComponent'. warning C28182: Dereferencing NULL pointer. 'SplinesComponent' contains the same NULL value as 'Landscape->SplineComponent' did. warning C6011: Dereferencing NULL pointer 'Landscape->SplineComponent'. warning C6385: Reading invalid data from 'out': the readable size is 'sizeof(kiss_fft_cpx)*Dims[0]*Dims[1]' bytes, but '16' bytes may be read. Change 3044716 on 2016/07/11 by Steve.Robb Static analysis fix: warning C6385: Reading invalid data from 'this->ScreenSize': the readable size is '32' bytes, but '-4' bytes may be read. Change 3044717 on 2016/07/11 by Steve.Robb Static analysis fix: warning C28182: Dereferencing NULL pointer. 'Window' contains the same NULL value as 'ElementType * Window=AllWindows.FindByPredicate((*FStaticMeshEditorTest::RunTest::<lambda_46fd0093f3912289e870263afe1fcb2e>(ExpectedTitle)))' did. This appears to be a false positive. Change 3044787 on 2016/07/11 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'FbxObject'. warning C28182: Dereferencing NULL pointer. 'Node' contains the same NULL value as 'RigidMeshNode' did. warning C28182: Dereferencing NULL pointer. 'Node' contains the same NULL value as 'Result' did. Change 3045933 on 2016/07/12 by Steve.Robb Overloading support for TSharedPtr, TSharedRef and TWeakPtr. Change 3045960 on 2016/07/12 by Robert.Manuszewski Fixing a crash in Portal (and any other program that uses UObjects and GCs, with the exception of UHT) caused by classes not having their token stream assembled. Change 3045963 on 2016/07/12 by Steve.Robb PLATFORM_COMPILER_HAS_EXPLICIT_OPERATORS, FORCEINLINE_EXPLICIT_OPERATOR_BOOL and SAFE_BOOL_OPERATORS macros removed. THasOperatorEquals and THasOperatorNotEquals traits moved to their own header. Change3045967on 2016/07/12 by Steve.Robb Initializer list support for TArray and TSet. Change 3045968 on 2016/07/12 by Robert.Manuszewski Fixing an ensure after typing 'stat dumphitches' in console. Change 3045992 on 2016/07/12 by Robert.Manuszewski Making sure CoreUObject headers are included for programs that don't include the engine (fixing MinidumpDiagnostics CIS failure) Change 3047870 on 2016/07/13 by Steven.Hutton Updated CRW to entity framework with repository models. #rb none Change 3047871 on 2016/07/13 by Steven.Hutton Add repository models #rb none Change 3049468 on 2016/07/14 by Steven.Hutton Fix broken project files. #rb none #lockdown Nick.Penwarden [CL 3050320 by Robert Manuszewski in Main branch]
748 lines
25 KiB
C++
748 lines
25 KiB
C++
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "ParserHelper.h"
|
|
#include "BaseParser.h"
|
|
#include "CompilationResult.h"
|
|
#include "ScopedTimers.h"
|
|
#include "Scope.h"
|
|
#include "GeneratedCodeVersion.h"
|
|
|
|
class FClass;
|
|
class FClasses;
|
|
class FScope;
|
|
class FHeaderProvider;
|
|
class FUHTMakefile;
|
|
|
|
extern double GPluginOverheadTime;
|
|
extern double GHeaderCodeGenTime;
|
|
|
|
/*-----------------------------------------------------------------------------
|
|
Constants & types.
|
|
-----------------------------------------------------------------------------*/
|
|
|
|
enum {MAX_NEST_LEVELS = 16};
|
|
|
|
/* Code nesting types. */
|
|
enum class ENestType
|
|
{
|
|
GlobalScope,
|
|
Class,
|
|
FunctionDeclaration,
|
|
Interface,
|
|
NativeInterface
|
|
};
|
|
|
|
/** Types of statements to allow within a particular nesting block. */
|
|
enum class ENestAllowFlags
|
|
{
|
|
None = 0,
|
|
Function = 1, // Allow Event declarations at this level.
|
|
VarDecl = 2, // Allow variable declarations at this level.
|
|
Class = 4, // Allow class definition heading.
|
|
Return = 8, // Allow 'return' within a function.
|
|
TypeDecl = 16, // Allow declarations which do not affect memory layout, such as structs, enums, and consts, but not implicit delegates
|
|
ImplicitDelegateDecl = 32, // Allow implicit delegates (i.e. those not decorated with UDELEGATE) to be declared
|
|
};
|
|
|
|
ENUM_CLASS_FLAGS(ENestAllowFlags)
|
|
|
|
namespace EDelegateSpecifierAction
|
|
{
|
|
enum Type
|
|
{
|
|
DontParse,
|
|
Parse
|
|
};
|
|
}
|
|
|
|
/** The category of variable declaration being parsed */
|
|
namespace EVariableCategory
|
|
{
|
|
enum Type
|
|
{
|
|
RegularParameter,
|
|
ReplicatedParameter,
|
|
Return,
|
|
Member
|
|
};
|
|
}
|
|
|
|
/** Information for a particular nesting level. */
|
|
class FNestInfo
|
|
{
|
|
/** Link to the stack node. */
|
|
FScope* Scope;
|
|
|
|
public:
|
|
/**
|
|
* Gets nesting scope.
|
|
*/
|
|
FScope* GetScope() const
|
|
{
|
|
return Scope;
|
|
}
|
|
|
|
/**
|
|
* Sets nesting scope.
|
|
*/
|
|
void SetScope(FScope* InScope)
|
|
{
|
|
this->Scope = InScope;
|
|
}
|
|
|
|
/** Statement that caused the nesting. */
|
|
ENestType NestType;
|
|
|
|
/** Types of statements to allow at this nesting level. */
|
|
ENestAllowFlags Allow;
|
|
};
|
|
|
|
struct FIndexRange
|
|
{
|
|
int32 StartIndex;
|
|
int32 Count;
|
|
};
|
|
|
|
|
|
struct ClassDefinitionRange
|
|
{
|
|
ClassDefinitionRange(const TCHAR* InStart, const TCHAR* InEnd)
|
|
: Start(InStart)
|
|
, End(InEnd)
|
|
, bHasGeneratedBody(false)
|
|
{ }
|
|
|
|
ClassDefinitionRange()
|
|
: Start(nullptr)
|
|
, End(nullptr)
|
|
, bHasGeneratedBody(false)
|
|
{ }
|
|
|
|
void Validate()
|
|
{
|
|
if (End <= Start)
|
|
{
|
|
FError::Throwf(TEXT("The class definition range is invalid. Most probably caused by previous parsing error."));
|
|
}
|
|
}
|
|
|
|
const TCHAR* Start;
|
|
const TCHAR* End;
|
|
bool bHasGeneratedBody;
|
|
};
|
|
|
|
extern TMap<UClass*, ClassDefinitionRange> ClassDefinitionRanges;
|
|
|
|
/////////////////////////////////////////////////////
|
|
// FHeaderParser
|
|
|
|
//
|
|
// Header parser class. Extracts metadata from annotated C++ headers and gathers enough
|
|
// information to autogenerate additional headers and other boilerplate code.
|
|
//
|
|
class FHeaderParser : public FBaseParser, public FContextSupplier
|
|
{
|
|
public:
|
|
// Default version of generated code. Defaults to oldest possible, unless specified otherwise in config.
|
|
static EGeneratedCodeVersion DefaultGeneratedCodeVersion;
|
|
|
|
// Compute the function parameter size and save the return offset
|
|
static void ComputeFunctionParametersSize(UClass* InClass);
|
|
|
|
// Parse all headers for classes that are inside LimitOuter.
|
|
static ECompilationResult::Type ParseAllHeadersInside(
|
|
FClasses& ModuleClasses,
|
|
FFeedbackContext* Warn,
|
|
UPackage* LimitOuter,
|
|
const FManifestModule& Module,
|
|
TArray<class IScriptGeneratorPluginInterface*>& ScriptPlugins
|
|
#if WITH_HOT_RELOAD_CTORS
|
|
, bool bExportVTableConstructors
|
|
#endif // WITH_HOT_RELOAD_CTORS
|
|
, FUHTMakefile& UHTMakefile
|
|
);
|
|
|
|
// Performs a preliminary parse of the text in the specified buffer, pulling out:
|
|
// Class name and parent class name
|
|
// Is it an interface
|
|
// The list of other classes/interfaces it is dependent on
|
|
//
|
|
// It also splits the buffer up into:
|
|
// ScriptText (text outside of #if CPP and #if DEFAULTS blocks)
|
|
static void SimplifiedClassParse(const TCHAR* Filename, const TCHAR* Buffer, TArray<FSimplifiedParsingClassInfo>& OutParsedClassArray, TArray<FHeaderProvider>& DependentOn, FStringOutputDevice& ScriptText);
|
|
|
|
/**
|
|
* Returns True if the given class name includes a valid Unreal prefix and matches up with the given original class Name.
|
|
*
|
|
* @param InNameToCheck - Name w/ potential prefix to check
|
|
* @param OriginalClassName - Name of class w/ no prefix to check against
|
|
*/
|
|
static bool ClassNameHasValidPrefix(const FString InNameToCheck, const FString OriginalClassName);
|
|
|
|
/**
|
|
* Tries to convert the header file name to a class name (with 'U' prefix)
|
|
*
|
|
* @param HeaderFilename Filename.
|
|
* @param OutClass The resulting class name (if successfull)
|
|
* @return true if the filename was a header filename (.h), false otherwise (in which case OutClassName is unmodified).
|
|
*/
|
|
static bool DependentClassNameFromHeader(const TCHAR* HeaderFilename, FString& OutClassName);
|
|
|
|
/**
|
|
* Transforms CPP-formated string containing default value, to inner formated string
|
|
* If it cannot be transformed empty string is returned.
|
|
*
|
|
* @param Property The property that owns the default value.
|
|
* @param CppForm A CPP-formated string.
|
|
* @param out InnerForm Inner formated string
|
|
* @return true on success, false otherwise.
|
|
*/
|
|
static bool DefaultValueStringCppFormatToInnerFormat(const UProperty* Property, const FString& CppForm, FString &InnerForm);
|
|
|
|
/**
|
|
* Parse Class's annotated headers and optionally its child classes. Marks the class as CLASS_Parsed.
|
|
*
|
|
* @param AllClasses the class tree containing all classes in the current package
|
|
* @param HeaderParser the header parser
|
|
* @param SourceFile Source file info.
|
|
*
|
|
* @return Result enumeration.
|
|
*/
|
|
static ECompilationResult::Type ParseHeaders(FClasses& AllClasses, FHeaderParser& HeaderParser, FUnrealSourceFile* SourceFile, FUHTMakefile& UHTMakefile);
|
|
|
|
protected:
|
|
friend struct FScriptLocation;
|
|
|
|
// For compiling messages and errors.
|
|
FFeedbackContext* Warn;
|
|
|
|
// Filename currently being parsed
|
|
FString Filename;
|
|
|
|
// Makefile to which parsing intermediate data will be saved.
|
|
FUHTMakefile& UHTMakefile;
|
|
|
|
// Was the first include in the file a validly formed auto-generated header include?
|
|
bool bSpottedAutogeneratedHeaderInclude;
|
|
|
|
// Current nest level, starts at 0.
|
|
int32 NestLevel;
|
|
|
|
// Top nesting level.
|
|
FNestInfo* TopNest;
|
|
|
|
/**
|
|
* Gets current nesting scope.
|
|
*/
|
|
FScope* GetCurrentScope() const
|
|
{
|
|
return TopNest->GetScope();
|
|
}
|
|
|
|
/**
|
|
* Gets current file scope.
|
|
*/
|
|
FFileScope* GetCurrentFileScope() const
|
|
{
|
|
int32 Index = 0;
|
|
if (!TopNest)
|
|
{
|
|
check(!NestLevel);
|
|
return nullptr;
|
|
}
|
|
while (TopNest[Index].NestType != ENestType::GlobalScope)
|
|
{
|
|
--Index;
|
|
}
|
|
|
|
return (FFileScope*)TopNest[Index].GetScope();
|
|
}
|
|
|
|
/**
|
|
* Gets current source file.
|
|
*/
|
|
FUnrealSourceFile* GetCurrentSourceFile() const
|
|
{
|
|
return CurrentSourceFile;
|
|
}
|
|
|
|
void SetCurrentSourceFile(FUnrealSourceFile* UnrealSourceFile)
|
|
{
|
|
CurrentSourceFile = UnrealSourceFile;
|
|
}
|
|
|
|
/**
|
|
* Gets current class scope.
|
|
*/
|
|
FStructScope* GetCurrentClassScope() const
|
|
{
|
|
check(TopNest->NestType == ENestType::Class || TopNest->NestType == ENestType::Interface || TopNest->NestType == ENestType::NativeInterface);
|
|
|
|
return (FStructScope*)TopNest->GetScope();
|
|
}
|
|
|
|
/**
|
|
* Tells if parser is currently in a class.
|
|
*/
|
|
bool IsInAClass() const
|
|
{
|
|
int32 Index = 0;
|
|
while (TopNest[Index].NestType != ENestType::GlobalScope)
|
|
{
|
|
if (TopNest[Index].NestType == ENestType::Class || TopNest->NestType == ENestType::Interface || TopNest->NestType == ENestType::NativeInterface)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
--Index;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Gets current class.
|
|
*/
|
|
UClass* GetCurrentClass() const
|
|
{
|
|
return (UClass*)GetCurrentClassScope()->GetStruct();
|
|
}
|
|
|
|
/**
|
|
* Gets current class's metadata.
|
|
*/
|
|
FClassMetaData* GetCurrentClassData()
|
|
{
|
|
return GScriptHelper.FindClassData(GetCurrentClass());
|
|
}
|
|
|
|
// Information about all nesting levels.
|
|
FNestInfo Nest[MAX_NEST_LEVELS];
|
|
|
|
// enum for complier directives used to build up the directive stack
|
|
struct ECompilerDirective
|
|
{
|
|
enum Type
|
|
{
|
|
// this directive is insignificant and does not change the code generation at all
|
|
Insignificant = 0,
|
|
// this indicates we are in a WITH_EDITOR #if-Block
|
|
WithEditor = 1<<0,
|
|
// this indicates we are in a WITH_EDITORONLY_DATA #if-Block
|
|
WithEditorOnlyData = 1<<1,
|
|
};
|
|
};
|
|
|
|
/**
|
|
* Compiler directive nest in which the parser currently is
|
|
* NOTE: compiler directives are combined when more are added onto the stack, so
|
|
* checking the only the top of stack is enough to determine in which #if-Block(s) the current code
|
|
* is.
|
|
*
|
|
* ex. Stack.Num() == 1 while entering #if WITH_EDITOR:
|
|
* CompilerDirectiveStack[1] == CompilerDirectiveStack[0] | ECompilerDirective::WithEditor ==
|
|
* CompilerDirecitveStack[1] == CompilerDirectiveStack.Num()-1 | ECompilerDirective::WithEditor
|
|
*
|
|
* ex. Stack.Num() == 2 while entering #if WITH_EDITOR:
|
|
* CompilerDirectiveStack[3] == CompilerDirectiveStack[0] | CompilerDirectiveStack[1] | CompilerDirectiveStack[2] | ECompilerDirective::WithEditor ==
|
|
* CompilerDirecitveStack[3] == CompilerDirectiveStack.Num()-1 | ECompilerDirective::WithEditor
|
|
*/
|
|
TArray<uint32> CompilerDirectiveStack;
|
|
|
|
// Pushes the Directive specified to the CompilerDirectiveStack according to the rules described above
|
|
void FORCEINLINE PushCompilerDirective(ECompilerDirective::Type Directive)
|
|
{
|
|
CompilerDirectiveStack.Push(CompilerDirectiveStack.Num()>0 ? (CompilerDirectiveStack[CompilerDirectiveStack.Num()-1] | Directive) : Directive);
|
|
}
|
|
|
|
/**
|
|
* The starting class flags (i.e. the class flags that were set before the
|
|
* CLASS_RecompilerClear mask was applied) for the class currently being compiled
|
|
*/
|
|
uint32 PreviousClassFlags;
|
|
|
|
// For new-style classes, used to keep track of an unmatched {} pair
|
|
bool bEncounteredNewStyleClass_UnmatchedBrackets;
|
|
|
|
// Indicates that UCLASS/USTRUCT/UINTERFACE has already been parsed in this .h file..
|
|
bool bHaveSeenUClass;
|
|
|
|
// Indicates that a GENERATED_UCLASS_BODY or GENERATED_BODY has been found in the UClass.
|
|
bool bClassHasGeneratedBody;
|
|
|
|
// Indicates that a GENERATED_UINTERFACE_BODY has been found in the UClass.
|
|
bool bClassHasGeneratedUInterfaceBody;
|
|
|
|
// Indicates that a GENERATED_IINTERFACE_BODY has been found in the UClass.
|
|
bool bClassHasGeneratedIInterfaceBody;
|
|
|
|
// public, private, etc at the current parse spot
|
|
EAccessSpecifier CurrentAccessSpecifier;
|
|
|
|
////////////////////////////////////////////////////
|
|
|
|
// Special parsed struct names that do not require a prefix
|
|
TArray<FString> StructsWithNoPrefix;
|
|
|
|
// Special parsed struct names that have a 'T' prefix
|
|
TArray<FString> StructsWithTPrefix;
|
|
|
|
// Mapping from 'human-readable' macro substring to # of parameters for delegate declarations
|
|
// Index 0 is 1 parameter, Index 1 is 2, etc...
|
|
TArray<FString> DelegateParameterCountStrings;
|
|
|
|
// List of all used identifiers for net service function declarations (every function must be unique)
|
|
TMap<int32, FString> UsedRPCIds;
|
|
// List of all net service functions with undeclared response functions
|
|
TMap<int32, FString> RPCsNeedingHookup;
|
|
|
|
protected:
|
|
// Constructor.
|
|
FHeaderParser(FFeedbackContext* InWarn, FUHTMakefile& InUHTMakefile);
|
|
|
|
~FHeaderParser()
|
|
{
|
|
if ( FScriptLocation::Compiler == this )
|
|
{
|
|
FScriptLocation::Compiler = NULL;
|
|
}
|
|
}
|
|
|
|
// Returns true if the token is a dynamic delegate declaration
|
|
bool IsValidDelegateDeclaration(const FToken& Token) const;
|
|
|
|
// Returns true if the current token is a bitfield type
|
|
bool IsBitfieldProperty();
|
|
|
|
// Parse the parameter list of a function or delegate declaration
|
|
void ParseParameterList(FClasses& AllClasses, UFunction* Function, bool bExpectCommaBeforeName = false, TMap<FName, FString>* MetaData = NULL);
|
|
|
|
public:
|
|
// Throws if a specifier value wasn't provided
|
|
static void RequireSpecifierValue(const FPropertySpecifier& Specifier, bool bRequireExactlyOne = false);
|
|
static FString RequireExactlyOneSpecifierValue(const FPropertySpecifier& Specifier);
|
|
|
|
protected:
|
|
|
|
/**
|
|
* Parse rest of the module's source files.
|
|
*
|
|
* @param AllClasses The class tree containing all classes in the current package.
|
|
* @param ModulePackage Current package.
|
|
* @param HeaderParser The header parser.
|
|
* @param UHTMakefile Makefile to which parsing data is saved.
|
|
*
|
|
* @return Result enumeration.
|
|
*/
|
|
static ECompilationResult::Type ParseRestOfModulesSourceFiles(FClasses& AllClasses, UPackage* ModulePackage, FHeaderParser& HeaderParser, FUHTMakefile& UHTMakefile);
|
|
|
|
//@TODO: Remove this method
|
|
static void ParseClassName(const TCHAR* Temp, FString& ClassName);
|
|
|
|
/**
|
|
* @param Input An input string, expected to be a script comment.
|
|
* @return The input string, reformatted in such a way as to be appropriate for use as a tooltip.
|
|
*/
|
|
static FString FormatCommentForToolTip(const FString& Input);
|
|
|
|
/**
|
|
* Begins the process of exporting C++ class declarations for native classes in the specified package
|
|
*
|
|
* @param CurrentPackage The package being compiled.
|
|
* @param AllClasses The class tree for CurrentPackage.
|
|
* @param UHTMakefile Makefile to which parsing data is saved.
|
|
* @param Module Currently exported module.
|
|
*/
|
|
static void ExportNativeHeaders(
|
|
UPackage* CurrentPackage,
|
|
FClasses& AllClasses,
|
|
bool bAllowSaveExportedHeaders
|
|
#if WITH_HOT_RELOAD_CTORS
|
|
, bool bExportVTableConstructors
|
|
#endif // WITH_HOT_RELOAD_CTORS
|
|
, FUHTMakefile& UHTMakefile
|
|
, const FManifestModule& Module
|
|
);
|
|
|
|
// FContextSupplier interface.
|
|
virtual FString GetContext() override;
|
|
// End of FContextSupplier interface.
|
|
|
|
// High-level compiling functions.
|
|
/**
|
|
* Parses given source file.
|
|
*
|
|
* @param AllClasses The class tree for current package.
|
|
* @param SourceFile Source file to parse.
|
|
*
|
|
* @returns Compilation result enum.
|
|
*/
|
|
ECompilationResult::Type ParseHeader(FClasses& AllClasses, FUnrealSourceFile* SourceFile);
|
|
void CompileDirective(FClasses& AllClasses);
|
|
void FinalizeScriptExposedFunctions(UClass* Class);
|
|
UEnum* CompileEnum();
|
|
UScriptStruct* CompileStructDeclaration(FClasses& AllClasses);
|
|
bool CompileDeclaration(FClasses& AllClasses, TArray<UDelegateFunction*>& DelegatesToFixup, FToken& Token);
|
|
|
|
/** Skip C++ (noexport) declaration. */
|
|
bool SkipDeclaration(FToken& Token);
|
|
/** Similar to MatchSymbol() but will return to the exact location as on entry if the symbol was not found. */
|
|
bool SafeMatchSymbol(const TCHAR* Match);
|
|
void HandleOneInheritedClass(FClasses& AllClasses, UClass* Class, FString InterfaceName);
|
|
FClass* ParseClassNameDeclaration(FClasses& AllClasses, FString& DeclaredClassName, FString& RequiredAPIMacroIfPresent);
|
|
|
|
/** The property style of a variable declaration being parsed */
|
|
struct EPropertyDeclarationStyle
|
|
{
|
|
enum Type
|
|
{
|
|
None,
|
|
UPROPERTY
|
|
};
|
|
};
|
|
|
|
/**
|
|
* Resets current class data back to its defaults.
|
|
*/
|
|
void ResetClassData();
|
|
|
|
/**
|
|
* Create new function object based on given info structure.
|
|
*/
|
|
UFunction* CreateFunction(const FFuncInfo &FuncInfo) const;
|
|
|
|
/**
|
|
* Create new delegate function object based on given info structure.
|
|
*/
|
|
UDelegateFunction* CreateDelegateFunction(const FFuncInfo &FuncInfo) const;
|
|
|
|
void CompileClassDeclaration(FClasses& AllClasses);
|
|
UDelegateFunction* CompileDelegateDeclaration(FClasses& AllClasses, const TCHAR* DelegateIdentifier, EDelegateSpecifierAction::Type SpecifierAction = EDelegateSpecifierAction::DontParse);
|
|
void CompileFunctionDeclaration(FClasses& AllClasses);
|
|
void CompileVariableDeclaration (FClasses& AllClasses, UStruct* Struct);
|
|
void CompileInterfaceDeclaration(FClasses& AllClasses);
|
|
|
|
FClass* ParseInterfaceNameDeclaration(FClasses& AllClasses, FString& DeclaredInterfaceName, FString& RequiredAPIMacroIfPresent);
|
|
bool TryParseIInterfaceClass(FClasses& AllClasses);
|
|
|
|
bool CompileStatement(FClasses& AllClasses, TArray<UDelegateFunction*>& DelegatesToFixup);
|
|
|
|
// Checks to see if a particular kind of command is allowed on this nesting level.
|
|
bool IsAllowedInThisNesting(ENestAllowFlags AllowFlags);
|
|
|
|
// Make sure that a particular kind of command is allowed on this nesting level.
|
|
// If it's not, issues a compiler error referring to the token and the current
|
|
// nesting level.
|
|
void CheckAllow(const TCHAR* Thing, ENestAllowFlags AllowFlags);
|
|
|
|
UStruct* GetSuperScope( UStruct* CurrentScope, const FName& SearchName );
|
|
|
|
/**
|
|
* Find a field in the specified context. Starts with the specified scope, then iterates
|
|
* through the Outer chain until the field is found.
|
|
*
|
|
* @param InScope scope to start searching for the field in
|
|
* @param InIdentifier name of the field we're searching for
|
|
* @param bIncludeParents whether to allow searching in the scope of a parent struct
|
|
* @param FieldClass class of the field to search for. used to e.g. search for functions only
|
|
* @param Thing hint text that will be used in the error message if an error is encountered
|
|
*
|
|
* @return a pointer to a UField with a name matching InIdentifier, or NULL if it wasn't found
|
|
*/
|
|
UField* FindField( UStruct* InScope, const TCHAR* InIdentifier, bool bIncludeParents=true, UClass* FieldClass=UField::StaticClass(), const TCHAR* Thing=NULL );
|
|
void SkipStatements( int32 SubCount, const TCHAR* ErrorTag );
|
|
|
|
/**
|
|
* Parses a variable or return value declaration and determines the variable type and property flags.
|
|
*
|
|
* @param AllClasses the class tree for CurrentPackage
|
|
* @param Scope struct to create the property in
|
|
* @param VarProperty will be filled in with type and property flag data for the property declaration that was parsed
|
|
* @param Disallow contains a mask of variable modifiers that are disallowed in this context
|
|
* @param OuterPropertyType only specified when compiling the inner properties for arrays or maps. corresponds to the FToken for the outer property declaration.
|
|
* @param PropertyDeclarationStyle if the variable is defined with a UPROPERTY
|
|
* @param VariableCategory what kind of variable is being parsed
|
|
* @param ParsedVarIndexRange The source text [Start, End) index range for the parsed type.
|
|
*/
|
|
void GetVarType(
|
|
FClasses& AllClasses,
|
|
FScope* Scope,
|
|
FPropertyBase& VarProperty,
|
|
uint64 Disallow,
|
|
FToken* OuterPropertyType,
|
|
EPropertyDeclarationStyle::Type PropertyDeclarationStyle,
|
|
EVariableCategory::Type VariableCategory,
|
|
FIndexRange* ParsedVarIndexRange = nullptr);
|
|
|
|
/**
|
|
* Parses a variable name declaration and creates a new UProperty object.
|
|
*
|
|
* @param Scope struct to create the property in
|
|
* @param VarProperty type and propertyflag info for the new property (inout)
|
|
* @param VariableCategory what kind of variable is being created
|
|
*
|
|
* @return a pointer to the new UProperty if successful, or NULL if there was no property to parse
|
|
*/
|
|
UProperty* GetVarNameAndDim(
|
|
UStruct* Struct,
|
|
FToken& VarProperty,
|
|
EVariableCategory::Type VariableCategory);
|
|
|
|
/**
|
|
* Returns whether the specified class can be referenced from the class currently being compiled.
|
|
*
|
|
* @param Scope The scope we are currently parsing.
|
|
* @param CheckClass The class we want to reference.
|
|
*
|
|
* @return true if the specified class is an intrinsic type or if the class has successfully been parsed
|
|
*/
|
|
bool AllowReferenceToClass(UStruct* Scope, UClass* CheckClass) const;
|
|
|
|
/**
|
|
* @return true if Scope has UProperty objects in its list of fields
|
|
*/
|
|
static bool HasMemberProperties( const UStruct* Scope );
|
|
|
|
/**
|
|
* Parses optional metadata text.
|
|
*
|
|
* @param MetaData the metadata map to store parsed metadata in
|
|
* @param FieldName the field being parsed (used for logging)
|
|
*
|
|
* @return true if metadata was specified
|
|
*/
|
|
void ParseFieldMetaData(TMap<FName, FString>& MetaData, const TCHAR* FieldName);
|
|
|
|
/**
|
|
* Formats the current comment, if any, and adds it to the metadata as a tooltip.
|
|
*
|
|
* @param MetaData the metadata map to store the tooltip in
|
|
*/
|
|
void AddFormattedPrevCommentAsTooltipMetaData(TMap<FName, FString>& MetaData);
|
|
|
|
/**
|
|
* Tries to parse the token as an access protection specifier (public:, protected:, or private:)
|
|
*
|
|
* @return EAccessSpecifier this is, or zero if it is none
|
|
*/
|
|
EAccessSpecifier ParseAccessProtectionSpecifier(FToken& Token);
|
|
|
|
const TCHAR* NestTypeName( ENestType NestType );
|
|
|
|
FClass* GetQualifiedClass(const FClasses& AllClasses, const TCHAR* Thing);
|
|
|
|
/**
|
|
* Increase the nesting level, setting the new top nesting level to
|
|
* the one specified. If pushing a function or state and it overrides a similar
|
|
* thing declared on a lower nesting level, verifies that the override is legal.
|
|
*
|
|
* @param NestType the new nesting type
|
|
* @param InNode @todo
|
|
*/
|
|
void PushNest(ENestType NestType, UStruct* InNode, FUnrealSourceFile* SourceFile = nullptr);
|
|
void PopNest(ENestType NestType, const TCHAR* Descr);
|
|
|
|
/**
|
|
* Tasks that need to be done after popping function declaration
|
|
* from parsing stack.
|
|
*
|
|
* @param AllClasses The class tree for current package.
|
|
* @param PoppedFunction Function that have just been popped.
|
|
*/
|
|
void PostPopFunctionDeclaration(FClasses& AllClasses, UFunction* PoppedFunction);
|
|
|
|
/**
|
|
* Tasks that need to be done after popping interface definition
|
|
* from parsing stack.
|
|
*
|
|
* @param AllClasses The class tree for current package.
|
|
* @param CurrentInterface Interface that have just been popped.
|
|
*/
|
|
void PostPopNestInterface(FClasses& AllClasses, UClass* CurrentInterface);
|
|
|
|
/**
|
|
* Tasks that need to be done after popping class definition
|
|
* from parsing stack.
|
|
*
|
|
* @param CurrentClass Class that have just been popped.
|
|
*/
|
|
void PostPopNestClass(UClass* CurrentClass);
|
|
|
|
/**
|
|
* Binds all delegate properties declared in ValidationScope the delegate functions specified in the variable declaration, verifying that the function is a valid delegate
|
|
* within the current scope. This must be done once the entire class has been parsed because instance delegate properties must be declared before the delegate declaration itself.
|
|
*
|
|
* @todo: this function will no longer be required once the post-parse fixup phase is added (TTPRO #13256)
|
|
*
|
|
* @param AllClasses the class tree for CurrentPackage
|
|
* @param Struct the struct to validate delegate properties for
|
|
* @param Scope the current scope
|
|
* @param DelegateCache cached map of delegates that have already been found; used for faster lookup.
|
|
*/
|
|
void FixupDelegateProperties(FClasses& AllClasses, UStruct* ValidationScope, FScope& Scope, TMap<FName, UFunction*>& DelegateCache);
|
|
|
|
/**
|
|
* Verifies that all specified class's UProperties with CFG_RepNotify have valid callback targets with no parameters nor return values
|
|
*
|
|
* @param TargetClass class to verify rep notify properties for
|
|
*/
|
|
void VerifyRepNotifyCallbacks( UClass* TargetClass );
|
|
|
|
// Retry functions.
|
|
void InitScriptLocation( FScriptLocation& Retry );
|
|
void ReturnToLocation( const FScriptLocation& Retry, bool Binary=1, bool Text=1 );
|
|
|
|
/**
|
|
* If the property has already been seen during compilation, then return add. If not,
|
|
* then return replace so that INI files don't mess with header exporting
|
|
*
|
|
* @param PropertyName the string token for the property
|
|
*
|
|
* @return FNAME_Replace_Not_Safe_For_Threading or FNAME_Add
|
|
*/
|
|
EFindName GetFindFlagForPropertyName(const TCHAR* PropertyName);
|
|
|
|
static void ValidatePropertyIsDeprecatedIfNecessary(FPropertyBase& VarProperty, FToken* OuterPropertyType);
|
|
|
|
private:
|
|
// Source file currently parsed by UHT.
|
|
FUnrealSourceFile* CurrentSourceFile;
|
|
|
|
// Module currently parsed by UHT.
|
|
const FManifestModule* CurrentlyParsedModule;
|
|
|
|
/**
|
|
* Tries to match constructor parameter list. Assumes that constructor
|
|
* name is already matched.
|
|
*
|
|
* If fails it reverts all parsing done.
|
|
*
|
|
* @param Token Token to start parsing from.
|
|
*
|
|
* @returns True if matched. False otherwise.
|
|
*/
|
|
bool TryToMatchConstructorParameterList(FToken Token);
|
|
void SkipDeprecatedMacroIfNecessary();
|
|
|
|
// Parses possible version declaration in generated code, e.g. GENERATED_BODY(<some_version>).
|
|
void CompileVersionDeclaration(UStruct* Struct);
|
|
};
|
|
|
|
/////////////////////////////////////////////////////
|
|
// FHeaderPreParser
|
|
|
|
class FHeaderPreParser : public FBaseParser
|
|
{
|
|
public:
|
|
FHeaderPreParser()
|
|
{
|
|
}
|
|
|
|
void ParseClassDeclaration(const TCHAR* InputText, int32 InLineNumber, const TCHAR* StartingMatchID, FString& out_ClassName, FString& out_BaseClassName, TArray<FHeaderProvider>& out_ClassNames, const TArray<FSimplifiedParsingClassInfo>& ParsedClassArray);
|
|
|
|
private:
|
|
void AddDependencyIfNeeded(const TArray<FSimplifiedParsingClassInfo>& ParsedClassArray, const FString& DependencyClassName, TArray<FHeaderProvider>& RequiredIncludes) const;
|
|
};
|