[llvm] r347858 - [llvm-rc] Support EXSTYLE statement.
Martin Storsjo via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 29 04:17:39 PST 2018
Author: mstorsjo
Date: Thu Nov 29 04:17:39 2018
New Revision: 347858
URL: http://llvm.org/viewvc/llvm-project?rev=347858&view=rev
Log:
[llvm-rc] Support EXSTYLE statement.
Patch by Jacek Caban!
Differential Revision: https://reviews.llvm.org/D55020
Modified:
llvm/trunk/test/tools/llvm-rc/Inputs/tag-dialog-headers.rc
llvm/trunk/test/tools/llvm-rc/tag-dialog.test
llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp
llvm/trunk/tools/llvm-rc/ResourceFileWriter.h
llvm/trunk/tools/llvm-rc/ResourceScriptParser.cpp
llvm/trunk/tools/llvm-rc/ResourceScriptParser.h
llvm/trunk/tools/llvm-rc/ResourceScriptStmt.cpp
llvm/trunk/tools/llvm-rc/ResourceScriptStmt.h
llvm/trunk/tools/llvm-rc/ResourceVisitor.h
Modified: llvm/trunk/test/tools/llvm-rc/Inputs/tag-dialog-headers.rc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-rc/Inputs/tag-dialog-headers.rc?rev=347858&r1=347857&r2=347858&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-rc/Inputs/tag-dialog-headers.rc (original)
+++ llvm/trunk/test/tools/llvm-rc/Inputs/tag-dialog-headers.rc Thu Nov 29 04:17:39 2018
@@ -54,3 +54,8 @@ CAPTION "CAPTION" STYLE 0 {}
27 DIALOGEX 5, 5, 5, 5 CLASS "Foobar" {}
28 DIALOG 5, 5, 5, 5 CLASS 42 {}
+29 DIALOGEX 0, 1, 0, 9 EXSTYLE 0x01234567 {}
+30 DIALOG 0, 1, 0, 9 EXSTYLE 0x01234567 {}
+
+31 DIALOGEX 0, 1, 0, 9 STYLE 0x76543210 EXSTYLE 0x01234567 {}
+32 DIALOG 0, 1, 0, 9 EXSTYLE 0x0123456 STYLE 0x76543210 {}
Modified: llvm/trunk/test/tools/llvm-rc/tag-dialog.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-rc/tag-dialog.test?rev=347858&r1=347857&r2=347858&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-rc/tag-dialog.test (original)
+++ llvm/trunk/test/tools/llvm-rc/tag-dialog.test Thu Nov 29 04:17:39 2018
@@ -579,6 +579,62 @@
; HEADERS-NEXT: 0010: 05000000 FFFF2A00 0000 |......*...|
; HEADERS-NEXT: )
+; HEADERS-DAG: Resource type (int): 5
+; HEADERS-NEXT: Resource name (int): 29
+; HEADERS-NEXT: Data version: 0
+; HEADERS-NEXT: Memory flags: 0x1030
+; HEADERS-NEXT: Language ID: 1033
+; HEADERS-NEXT: Version (major): 0
+; HEADERS-NEXT: Version (minor): 0
+; HEADERS-NEXT: Characteristics: 0
+; HEADERS-NEXT: Data size: 32
+; HEADERS-NEXT: Data: (
+; HEADERS-NEXT: 0000: 0100FFFF 00000000 67452301 00008880 |........gE#.....|
+; HEADERS-NEXT: 0010: 00000000 01000000 09000000 00000000 |................|
+; HEADERS-NEXT: )
+
+; HEADERS-DAG: Resource type (int): 5
+; HEADERS-NEXT: Resource name (int): 30
+; HEADERS-NEXT: Data version: 0
+; HEADERS-NEXT: Memory flags: 0x1030
+; HEADERS-NEXT: Language ID: 1033
+; HEADERS-NEXT: Version (major): 0
+; HEADERS-NEXT: Version (minor): 0
+; HEADERS-NEXT: Characteristics: 0
+; HEADERS-NEXT: Data size: 24
+; HEADERS-NEXT: Data: (
+; HEADERS-NEXT: 0000: 00008880 67452301 00000000 01000000 |....gE#.........|
+; HEADERS-NEXT: 0010: 09000000 00000000 |........|
+; HEADERS-NEXT: )
+
+; HEADERS-DAG: Resource type (int): 5
+; HEADERS-NEXT: Resource name (int): 31
+; HEADERS-NEXT: Data version: 0
+; HEADERS-NEXT: Memory flags: 0x1030
+; HEADERS-NEXT: Language ID: 1033
+; HEADERS-NEXT: Version (major): 0
+; HEADERS-NEXT: Version (minor): 0
+; HEADERS-NEXT: Characteristics: 0
+; HEADERS-NEXT: Data size: 32
+; HEADERS-NEXT: Data: (
+; HEADERS-NEXT: 0000: 0100FFFF 00000000 67452301 10325476 |........gE#..2Tv|
+; HEADERS-NEXT: 0010: 00000000 01000000 09000000 00000000 |................|
+; HEADERS-NEXT: )
+
+; HEADERS-DAG: Resource type (int): 5
+; HEADERS-NEXT: Resource name (int): 32
+; HEADERS-NEXT: Data version: 0
+; HEADERS-NEXT: Memory flags: 0x1030
+; HEADERS-NEXT: Language ID: 1033
+; HEADERS-NEXT: Version (major): 0
+; HEADERS-NEXT: Version (minor): 0
+; HEADERS-NEXT: Characteristics: 0
+; HEADERS-NEXT: Data size: 24
+; HEADERS-NEXT: Data: (
+; HEADERS-NEXT: 0000: 10325476 56341200 00000000 01000000 |.2TvV4..........|
+; HEADERS-NEXT: 0010: 09000000 00000000 |........|
+; HEADERS-NEXT: )
+
; RUN: not llvm-rc /FO %t %p/Inputs/tag-dialog-large-coord.rc 2>&1 | FileCheck %s --check-prefix COORD1
Modified: llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp?rev=347858&r1=347857&r2=347858&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp (original)
+++ llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp Thu Nov 29 04:17:39 2018
@@ -514,6 +514,11 @@ Error ResourceFileWriter::visitCharacter
return Error::success();
}
+Error ResourceFileWriter::visitExStyleStmt(const ExStyleStmt *Stmt) {
+ ObjectData.ExStyle = Stmt->Value;
+ return Error::success();
+}
+
Error ResourceFileWriter::visitFontStmt(const FontStmt *Stmt) {
RETURN_IF_ERROR(checkNumberFits<uint16_t>(Stmt->Size, "Font size"));
RETURN_IF_ERROR(checkNumberFits<uint16_t>(Stmt->Weight, "Font weight"));
@@ -1065,6 +1070,7 @@ Error ResourceFileWriter::writeDialogBod
UsedStyle |= StyleCaptionFlag;
const uint16_t DialogExMagic = 0xFFFF;
+ uint32_t ExStyle = ObjectData.ExStyle.getValueOr(0);
// Write DIALOG(EX) header prefix. These are pretty different.
if (!Res->IsExtended) {
@@ -1083,7 +1089,7 @@ Error ResourceFileWriter::writeDialogBod
ulittle32_t Style;
ulittle32_t ExtStyle;
} Prefix{ulittle32_t(UsedStyle),
- ulittle32_t(0)}; // As of now, we don't keep EXSTYLE.
+ ulittle32_t(ExStyle)};
writeObject(Prefix);
} else {
@@ -1094,7 +1100,7 @@ Error ResourceFileWriter::writeDialogBod
ulittle32_t ExtStyle;
ulittle32_t Style;
} Prefix{ulittle16_t(1), ulittle16_t(DialogExMagic),
- ulittle32_t(Res->HelpID), ulittle32_t(0), ulittle32_t(UsedStyle)};
+ ulittle32_t(Res->HelpID), ulittle32_t(ExStyle), ulittle32_t(UsedStyle)};
writeObject(Prefix);
}
Modified: llvm/trunk/tools/llvm-rc/ResourceFileWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/ResourceFileWriter.h?rev=347858&r1=347857&r2=347858&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/ResourceFileWriter.h (original)
+++ llvm/trunk/tools/llvm-rc/ResourceFileWriter.h Thu Nov 29 04:17:39 2018
@@ -63,6 +63,7 @@ public:
Error visitCaptionStmt(const CaptionStmt *) override;
Error visitCharacteristicsStmt(const CharacteristicsStmt *) override;
Error visitClassStmt(const ClassStmt *) override;
+ Error visitExStyleStmt(const ExStyleStmt *) override;
Error visitFontStmt(const FontStmt *) override;
Error visitLanguageStmt(const LanguageResource *) override;
Error visitStyleStmt(const StyleStmt *) override;
@@ -80,6 +81,7 @@ public:
uint32_t VersionInfo;
Optional<uint32_t> Style;
+ Optional<uint32_t> ExStyle;
StringRef Caption;
struct FontInfo {
uint32_t Size;
Modified: llvm/trunk/tools/llvm-rc/ResourceScriptParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/ResourceScriptParser.cpp?rev=347858&r1=347857&r2=347858&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/ResourceScriptParser.cpp (original)
+++ llvm/trunk/tools/llvm-rc/ResourceScriptParser.cpp Thu Nov 29 04:17:39 2018
@@ -388,6 +388,8 @@ RCParser::parseSingleOptionalStatement(O
return parseCaptionStmt();
if (TypeToken->equals_lower("CLASS"))
return parseClassStmt();
+ if (TypeToken->equals_lower("EXSTYLE"))
+ return parseExStyleStmt();
if (TypeToken->equals_lower("FONT"))
return parseFontStmt(StmtsType);
if (TypeToken->equals_lower("STYLE"))
@@ -817,6 +819,11 @@ RCParser::ParseOptionType RCParser::pars
return llvm::make_unique<StyleStmt>(*Arg);
}
+RCParser::ParseOptionType RCParser::parseExStyleStmt() {
+ ASSIGN_OR_RETURN(Arg, readInt());
+ return llvm::make_unique<ExStyleStmt>(*Arg);
+}
+
Error RCParser::getExpectedError(const Twine &Message, bool IsAlreadyRead) {
return make_error<ParserError>(
Message, IsAlreadyRead ? std::prev(CurLoc) : CurLoc, End);
Modified: llvm/trunk/tools/llvm-rc/ResourceScriptParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/ResourceScriptParser.h?rev=347858&r1=347857&r2=347858&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/ResourceScriptParser.h (original)
+++ llvm/trunk/tools/llvm-rc/ResourceScriptParser.h Thu Nov 29 04:17:39 2018
@@ -172,6 +172,7 @@ private:
ParseOptionType parseVersionStmt();
ParseOptionType parseCaptionStmt();
ParseOptionType parseClassStmt();
+ ParseOptionType parseExStyleStmt();
ParseOptionType parseFontStmt(OptStmtType DialogType);
ParseOptionType parseStyleStmt();
Modified: llvm/trunk/tools/llvm-rc/ResourceScriptStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/ResourceScriptStmt.cpp?rev=347858&r1=347857&r2=347858&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/ResourceScriptStmt.cpp (original)
+++ llvm/trunk/tools/llvm-rc/ResourceScriptStmt.cpp Thu Nov 29 04:17:39 2018
@@ -283,5 +283,9 @@ raw_ostream &StyleStmt::log(raw_ostream
return OS << "Style: " << Value << "\n";
}
+raw_ostream &ExStyleStmt::log(raw_ostream &OS) const {
+ return OS << "ExStyle: " << Value << "\n";
+}
+
} // namespace rc
} // namespace llvm
Modified: llvm/trunk/tools/llvm-rc/ResourceScriptStmt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/ResourceScriptStmt.h?rev=347858&r1=347857&r2=347858&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/ResourceScriptStmt.h (original)
+++ llvm/trunk/tools/llvm-rc/ResourceScriptStmt.h Thu Nov 29 04:17:39 2018
@@ -866,6 +866,19 @@ public:
Error visit(Visitor *V) const override { return V->visitStyleStmt(this); }
};
+// EXSTYLE optional statement.
+//
+// Ref: docs.microsoft.com/en-us/windows/desktop/menurc/exstyle-statement
+class ExStyleStmt : public OptionalStmt {
+public:
+ uint32_t Value;
+
+ ExStyleStmt(uint32_t ExStyle) : Value(ExStyle) {}
+ raw_ostream &log(raw_ostream &) const override;
+ Twine getResourceTypeName() const override { return "EXSTYLE"; }
+ Error visit(Visitor *V) const override { return V->visitExStyleStmt(this); }
+};
+
// CLASS optional statement.
//
// Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa380883(v=vs.85).aspx
Modified: llvm/trunk/tools/llvm-rc/ResourceVisitor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/ResourceVisitor.h?rev=347858&r1=347857&r2=347858&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/ResourceVisitor.h (original)
+++ llvm/trunk/tools/llvm-rc/ResourceVisitor.h Thu Nov 29 04:17:39 2018
@@ -24,6 +24,7 @@ class RCResource;
class CaptionStmt;
class ClassStmt;
class CharacteristicsStmt;
+class ExStyleStmt;
class FontStmt;
class LanguageResource;
class StyleStmt;
@@ -46,6 +47,7 @@ public:
virtual Error visitCaptionStmt(const CaptionStmt *) = 0;
virtual Error visitClassStmt(const ClassStmt *) = 0;
virtual Error visitCharacteristicsStmt(const CharacteristicsStmt *) = 0;
+ virtual Error visitExStyleStmt(const ExStyleStmt *) = 0;
virtual Error visitFontStmt(const FontStmt *) = 0;
virtual Error visitLanguageStmt(const LanguageResource *) = 0;
virtual Error visitStyleStmt(const StyleStmt *) = 0;
More information about the llvm-commits
mailing list