diff options
author | Martin Storsjo <martin@martin.st> | 2018-11-29 12:17:39 +0000 |
---|---|---|
committer | Martin Storsjo <martin@martin.st> | 2018-11-29 12:17:39 +0000 |
commit | a876b5c0f5d6a522ad3020149599a4e4d5330fb9 (patch) | |
tree | 57ea7bc681d6dc04ba4bdcb53c4e4ee169ba02cf /llvm/tools/llvm-rc | |
parent | 373a4ccf6cdd69993fbcef7384b741373374269b (diff) | |
download | bcm5719-llvm-a876b5c0f5d6a522ad3020149599a4e4d5330fb9.tar.gz bcm5719-llvm-a876b5c0f5d6a522ad3020149599a4e4d5330fb9.zip |
[llvm-rc] Support EXSTYLE statement.
Patch by Jacek Caban!
Differential Revision: https://reviews.llvm.org/D55020
llvm-svn: 347858
Diffstat (limited to 'llvm/tools/llvm-rc')
-rw-r--r-- | llvm/tools/llvm-rc/ResourceFileWriter.cpp | 10 | ||||
-rw-r--r-- | llvm/tools/llvm-rc/ResourceFileWriter.h | 2 | ||||
-rw-r--r-- | llvm/tools/llvm-rc/ResourceScriptParser.cpp | 7 | ||||
-rw-r--r-- | llvm/tools/llvm-rc/ResourceScriptParser.h | 1 | ||||
-rw-r--r-- | llvm/tools/llvm-rc/ResourceScriptStmt.cpp | 4 | ||||
-rw-r--r-- | llvm/tools/llvm-rc/ResourceScriptStmt.h | 13 | ||||
-rw-r--r-- | llvm/tools/llvm-rc/ResourceVisitor.h | 2 |
7 files changed, 37 insertions, 2 deletions
diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.cpp b/llvm/tools/llvm-rc/ResourceFileWriter.cpp index 95d92a93c89..e69d4793dd1 100644 --- a/llvm/tools/llvm-rc/ResourceFileWriter.cpp +++ b/llvm/tools/llvm-rc/ResourceFileWriter.cpp @@ -514,6 +514,11 @@ Error ResourceFileWriter::visitCharacteristicsStmt( 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::writeDialogBody(const RCResource *Base) { 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::writeDialogBody(const RCResource *Base) { 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::writeDialogBody(const RCResource *Base) { 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); } diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.h b/llvm/tools/llvm-rc/ResourceFileWriter.h index 4c31d018bde..36d57da11eb 100644 --- a/llvm/tools/llvm-rc/ResourceFileWriter.h +++ b/llvm/tools/llvm-rc/ResourceFileWriter.h @@ -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; diff --git a/llvm/tools/llvm-rc/ResourceScriptParser.cpp b/llvm/tools/llvm-rc/ResourceScriptParser.cpp index 8cc0b50933c..09c88ff879a 100644 --- a/llvm/tools/llvm-rc/ResourceScriptParser.cpp +++ b/llvm/tools/llvm-rc/ResourceScriptParser.cpp @@ -388,6 +388,8 @@ RCParser::parseSingleOptionalStatement(OptStmtType StmtsType) { 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::parseStyleStmt() { 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); diff --git a/llvm/tools/llvm-rc/ResourceScriptParser.h b/llvm/tools/llvm-rc/ResourceScriptParser.h index 3dd110f7e38..4f047f34fc0 100644 --- a/llvm/tools/llvm-rc/ResourceScriptParser.h +++ b/llvm/tools/llvm-rc/ResourceScriptParser.h @@ -172,6 +172,7 @@ private: ParseOptionType parseVersionStmt(); ParseOptionType parseCaptionStmt(); ParseOptionType parseClassStmt(); + ParseOptionType parseExStyleStmt(); ParseOptionType parseFontStmt(OptStmtType DialogType); ParseOptionType parseStyleStmt(); diff --git a/llvm/tools/llvm-rc/ResourceScriptStmt.cpp b/llvm/tools/llvm-rc/ResourceScriptStmt.cpp index 728c24b3669..325707226c4 100644 --- a/llvm/tools/llvm-rc/ResourceScriptStmt.cpp +++ b/llvm/tools/llvm-rc/ResourceScriptStmt.cpp @@ -283,5 +283,9 @@ raw_ostream &StyleStmt::log(raw_ostream &OS) const { return OS << "Style: " << Value << "\n"; } +raw_ostream &ExStyleStmt::log(raw_ostream &OS) const { + return OS << "ExStyle: " << Value << "\n"; +} + } // namespace rc } // namespace llvm diff --git a/llvm/tools/llvm-rc/ResourceScriptStmt.h b/llvm/tools/llvm-rc/ResourceScriptStmt.h index 2071ac6a9a3..0051f83fcf2 100644 --- a/llvm/tools/llvm-rc/ResourceScriptStmt.h +++ b/llvm/tools/llvm-rc/ResourceScriptStmt.h @@ -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 diff --git a/llvm/tools/llvm-rc/ResourceVisitor.h b/llvm/tools/llvm-rc/ResourceVisitor.h index 53ef3c5cf7d..2117b12d8f5 100644 --- a/llvm/tools/llvm-rc/ResourceVisitor.h +++ b/llvm/tools/llvm-rc/ResourceVisitor.h @@ -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; |