虚幻4 UHT查找各种宏的地方

来源:互联网 发布:统计 数据分析 pdf 编辑:程序博客网 时间:2024/05/04 08:33

while (1){ClearComment();GetToken( Token );if (EAccessSpecifier AccessSpecifier = ParseAccessProtectionSpecifier(Token)){CurrentAccessSpecifier = AccessSpecifier;}else if (Token.Matches(TEXT("UPROPERTY"), ESearchCase::CaseSensitive)){CompileVariableDeclaration(AllClasses, Struct);}else if (Token.Matches(TEXT("UFUNCTION"), ESearchCase::CaseSensitive)){FError::Throwf(TEXT("USTRUCTs cannot contain UFUNCTIONs."));}else if (Token.Matches(TEXT("GENERATED_USTRUCT_BODY")) || Token.Matches(TEXT("GENERATED_BODY"))){// Match 'GENERATED_USTRUCT_BODY' '(' [StructName] ')' or 'GENERATED_BODY' '(' [StructName] ')'if (CurrentAccessSpecifier != ACCESS_Public){FError::Throwf(TEXT("%s must be in the public scope of '%s', not private or protected."), Token.Identifier, *StructNameInScript);}if (Struct->StructMacroDeclaredLineNumber != INDEX_NONE){FError::Throwf(TEXT("Multiple %s declarations found in '%s'"), Token.Identifier, *StructNameInScript);}Struct->StructMacroDeclaredLineNumber = InputLine;RequireSymbol(TEXT("("), TEXT("'struct'"));CompileVersionDeclaration(SourceFile, Struct);RequireSymbol(TEXT(")"), TEXT("'struct'"));// Eat a semicolon if present (not required)SafeMatchSymbol(TEXT(";"));}else if ( Token.Matches(TEXT("#")) && MatchIdentifier(TEXT("ifdef")) ){PushCompilerDirective(ECompilerDirective::Insignificant);}else if ( Token.Matches(TEXT("#")) && MatchIdentifier(TEXT("ifndef")) ){PushCompilerDirective(ECompilerDirective::Insignificant);}else if (Token.Matches(TEXT("#")) && MatchIdentifier(TEXT("endif"))){if (CompilerDirectiveStack.Num() < 1){FError::Throwf(TEXT("Unmatched '#endif' in class or global scope"));}CompilerDirectiveStack.Pop();// Do nothing and hope that the if code below worked out OK earlier}else if ( Token.Matches(TEXT("#")) && MatchIdentifier(TEXT("if")) ){//@TODO: This parsing should be combined with CompileDirective and probably happen much much higher up!bool bInvertConditional = MatchSymbol(TEXT("!"));bool bConsumeAsCppText = false;if (MatchIdentifier(TEXT("WITH_EDITORONLY_DATA")) ){if (bInvertConditional){FError::Throwf(TEXT("Cannot use !WITH_EDITORONLY_DATA"));}PushCompilerDirective(ECompilerDirective::WithEditorOnlyData);}else if (MatchIdentifier(TEXT("WITH_EDITOR")) ){if (bInvertConditional){FError::Throwf(TEXT("Cannot use !WITH_EDITOR"));}PushCompilerDirective(ECompilerDirective::WithEditor);}else if (MatchIdentifier(TEXT("CPP"))){bConsumeAsCppText = !bInvertConditional;PushCompilerDirective(ECompilerDirective::Insignificant);//@todo: UCREMOVAL, !CPP should be interpreted as noexport and you should not need the no export.// this applies to structs, enums, and everything else}else{FError::Throwf(TEXT("'struct': Unsupported preprocessor directive inside a struct.") );}if (bConsumeAsCppText){// Skip over the text, it is not recorded or processedint32 nest = 1;while (nest > 0){TCHAR ch = GetChar(1);if ( ch==0 ){FError::Throwf(TEXT("Unexpected end of struct definition %s"), *Struct->GetName());}else if ( ch=='{' || (ch=='#' && (PeekIdentifier(TEXT("if")) || PeekIdentifier(TEXT("ifdef")))) ){nest++;}else if ( ch=='}' || (ch=='#' && PeekIdentifier(TEXT("endif"))) ){nest--;}if (nest==0){RequireIdentifier(TEXT("endif"),TEXT("'if'"));}}}}else{if ( !Token.Matches( TEXT("}") ) ){FToken DeclarationFirstToken = Token;if (!SkipDeclaration(Token)){FError::Throwf(TEXT("'struct': Unexpected '%s'"), DeclarationFirstToken.Identifier );}}else{MatchSemi();break;}}

D:\Projects\Program\Engine\Engine\Source\Programs\UnrealHeaderTool\Private\HeaderParser.cpp


虚幻对于头文件在编译器编译前的操作。

查找特定的宏定义。

0 0