summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rc
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-05-15 19:21:28 +0000
committerMartin Storsjo <martin@martin.st>2018-05-15 19:21:28 +0000
commite241ce6f65f1c6373886a6c7f505fc59d0bf244d (patch)
tree39c14204c332c6493c05b13a82c88a2a21d748c0 /llvm/tools/llvm-rc
parent67cfbaac8973f1f0cf85bd2e90c74b42792ceada (diff)
downloadbcm5719-llvm-e241ce6f65f1c6373886a6c7f505fc59d0bf244d.tar.gz
bcm5719-llvm-e241ce6f65f1c6373886a6c7f505fc59d0bf244d.zip
[llvm-rc] Add support for the optional CLASS statement for dialogs
Differential Revision: https://reviews.llvm.org/D46875 llvm-svn: 332386
Diffstat (limited to 'llvm/tools/llvm-rc')
-rw-r--r--llvm/tools/llvm-rc/ResourceFileWriter.cpp9
-rw-r--r--llvm/tools/llvm-rc/ResourceFileWriter.h6
-rw-r--r--llvm/tools/llvm-rc/ResourceScriptParser.cpp7
-rw-r--r--llvm/tools/llvm-rc/ResourceScriptParser.h1
-rw-r--r--llvm/tools/llvm-rc/ResourceScriptStmt.cpp4
-rw-r--r--llvm/tools/llvm-rc/ResourceScriptStmt.h13
-rw-r--r--llvm/tools/llvm-rc/ResourceVisitor.h2
7 files changed, 39 insertions, 3 deletions
diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.cpp b/llvm/tools/llvm-rc/ResourceFileWriter.cpp
index 99fdb82f793..4b561940d2e 100644
--- a/llvm/tools/llvm-rc/ResourceFileWriter.cpp
+++ b/llvm/tools/llvm-rc/ResourceFileWriter.cpp
@@ -458,6 +458,11 @@ Error ResourceFileWriter::visitCaptionStmt(const CaptionStmt *Stmt) {
return Error::success();
}
+Error ResourceFileWriter::visitClassStmt(const ClassStmt *Stmt) {
+ ObjectData.Class = Stmt->Value;
+ return Error::success();
+}
+
Error ResourceFileWriter::visitHTMLResource(const RCResource *Res) {
return writeResource(Res, &ResourceFileWriter::writeHTMLBody);
}
@@ -1120,8 +1125,8 @@ Error ResourceFileWriter::writeDialogBody(const RCResource *Base) {
// think there is no menu attached to the dialog.
writeInt<uint16_t>(0);
- // Window CLASS field. Not kept here.
- writeInt<uint16_t>(0);
+ // Window CLASS field.
+ RETURN_IF_ERROR(writeIntOrString(ObjectData.Class));
// Window title or a single word equal to 0.
RETURN_IF_ERROR(writeCString(ObjectData.Caption));
diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.h b/llvm/tools/llvm-rc/ResourceFileWriter.h
index 695d455b6eb..4c31d018bde 100644
--- a/llvm/tools/llvm-rc/ResourceFileWriter.h
+++ b/llvm/tools/llvm-rc/ResourceFileWriter.h
@@ -62,6 +62,7 @@ public:
Error visitCaptionStmt(const CaptionStmt *) override;
Error visitCharacteristicsStmt(const CharacteristicsStmt *) override;
+ Error visitClassStmt(const ClassStmt *) override;
Error visitFontStmt(const FontStmt *) override;
Error visitLanguageStmt(const LanguageResource *) override;
Error visitStyleStmt(const StyleStmt *) override;
@@ -88,8 +89,11 @@ public:
uint32_t Charset;
};
Optional<FontInfo> Font;
+ IntOrString Class;
- ObjectInfo() : LanguageInfo(0), Characteristics(0), VersionInfo(0) {}
+ ObjectInfo()
+ : LanguageInfo(0), Characteristics(0), VersionInfo(0),
+ Class(StringRef()) {}
} ObjectData;
struct StringTableInfo {
diff --git a/llvm/tools/llvm-rc/ResourceScriptParser.cpp b/llvm/tools/llvm-rc/ResourceScriptParser.cpp
index cdb56f45081..8cc0b50933c 100644
--- a/llvm/tools/llvm-rc/ResourceScriptParser.cpp
+++ b/llvm/tools/llvm-rc/ResourceScriptParser.cpp
@@ -386,6 +386,8 @@ RCParser::parseSingleOptionalStatement(OptStmtType StmtsType) {
if (StmtsType != OptStmtType::BasicStmt) {
if (TypeToken->equals_lower("CAPTION"))
return parseCaptionStmt();
+ if (TypeToken->equals_lower("CLASS"))
+ return parseClassStmt();
if (TypeToken->equals_lower("FONT"))
return parseFontStmt(StmtsType);
if (TypeToken->equals_lower("STYLE"))
@@ -779,6 +781,11 @@ RCParser::ParseOptionType RCParser::parseCaptionStmt() {
return llvm::make_unique<CaptionStmt>(*Arg);
}
+RCParser::ParseOptionType RCParser::parseClassStmt() {
+ ASSIGN_OR_RETURN(Arg, readIntOrString());
+ return llvm::make_unique<ClassStmt>(*Arg);
+}
+
RCParser::ParseOptionType RCParser::parseFontStmt(OptStmtType DialogType) {
assert(DialogType != OptStmtType::BasicStmt);
diff --git a/llvm/tools/llvm-rc/ResourceScriptParser.h b/llvm/tools/llvm-rc/ResourceScriptParser.h
index 8e3cc55499e..3dd110f7e38 100644
--- a/llvm/tools/llvm-rc/ResourceScriptParser.h
+++ b/llvm/tools/llvm-rc/ResourceScriptParser.h
@@ -171,6 +171,7 @@ private:
ParseOptionType parseCharacteristicsStmt();
ParseOptionType parseVersionStmt();
ParseOptionType parseCaptionStmt();
+ ParseOptionType parseClassStmt();
ParseOptionType parseFontStmt(OptStmtType DialogType);
ParseOptionType parseStyleStmt();
diff --git a/llvm/tools/llvm-rc/ResourceScriptStmt.cpp b/llvm/tools/llvm-rc/ResourceScriptStmt.cpp
index 86826bbf7b9..728c24b3669 100644
--- a/llvm/tools/llvm-rc/ResourceScriptStmt.cpp
+++ b/llvm/tools/llvm-rc/ResourceScriptStmt.cpp
@@ -267,6 +267,10 @@ raw_ostream &CaptionStmt::log(raw_ostream &OS) const {
return OS << "Caption: " << Value << "\n";
}
+raw_ostream &ClassStmt::log(raw_ostream &OS) const {
+ return OS << "Class: " << Value << "\n";
+}
+
raw_ostream &FontStmt::log(raw_ostream &OS) const {
OS << "Font: size = " << Size << ", face = " << Name
<< ", weight = " << Weight;
diff --git a/llvm/tools/llvm-rc/ResourceScriptStmt.h b/llvm/tools/llvm-rc/ResourceScriptStmt.h
index c9a0de09f20..2071ac6a9a3 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); }
};
+// CLASS optional statement.
+//
+// Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa380883(v=vs.85).aspx
+class ClassStmt : public OptionalStmt {
+public:
+ IntOrString Value;
+
+ ClassStmt(IntOrString Class) : Value(Class) {}
+ raw_ostream &log(raw_ostream &) const override;
+ Twine getResourceTypeName() const override { return "CLASS"; }
+ Error visit(Visitor *V) const override { return V->visitClassStmt(this); }
+};
+
} // namespace rc
} // namespace llvm
diff --git a/llvm/tools/llvm-rc/ResourceVisitor.h b/llvm/tools/llvm-rc/ResourceVisitor.h
index 373b3cb7e6f..53ef3c5cf7d 100644
--- a/llvm/tools/llvm-rc/ResourceVisitor.h
+++ b/llvm/tools/llvm-rc/ResourceVisitor.h
@@ -22,6 +22,7 @@ namespace rc {
class RCResource;
class CaptionStmt;
+class ClassStmt;
class CharacteristicsStmt;
class FontStmt;
class LanguageResource;
@@ -43,6 +44,7 @@ public:
virtual Error visitVersionInfoResource(const RCResource *) = 0;
virtual Error visitCaptionStmt(const CaptionStmt *) = 0;
+ virtual Error visitClassStmt(const ClassStmt *) = 0;
virtual Error visitCharacteristicsStmt(const CharacteristicsStmt *) = 0;
virtual Error visitFontStmt(const FontStmt *) = 0;
virtual Error visitLanguageStmt(const LanguageResource *) = 0;
OpenPOWER on IntegriCloud