mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[llvm-rc] Support EXSTYLE statement.
Patch by Jacek Caban! Differential Revision: https://reviews.llvm.org/D55020 llvm-svn: 347858
This commit is contained in:
parent
a900121de4
commit
d9380b2548
Binary file not shown.
@ -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
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -172,6 +172,7 @@ private:
|
||||
ParseOptionType parseVersionStmt();
|
||||
ParseOptionType parseCaptionStmt();
|
||||
ParseOptionType parseClassStmt();
|
||||
ParseOptionType parseExStyleStmt();
|
||||
ParseOptionType parseFontStmt(OptStmtType DialogType);
|
||||
ParseOptionType parseStyleStmt();
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user