teak-llvm/llvm/tools/llvm-rc/ResourceScriptStmt.cpp
Marek Sokolowski 7f11052741 [llvm-rc] Add ACCELERATORS parsing ability. (parser, pt 3/8).
This improves the current llvm-rc parser by the ability of parsing
ACCELERATORS statement.

Moreover, some small improvements to the original parsing commit
were made.

Thanks for Nico Weber for his original work in this area.

Differential Revision: https://reviews.llvm.org/D36894

llvm-svn: 311946
2017-08-28 22:58:31 +00:00

86 lines
2.4 KiB
C++

//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===---------------------------------------------------------------------===//
//
// This implements methods defined in ResourceScriptStmt.h.
//
// Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa380599(v=vs.85).aspx
//
//===---------------------------------------------------------------------===//
#include "ResourceScriptStmt.h"
namespace llvm {
namespace rc {
raw_ostream &operator<<(raw_ostream &OS, const IntOrString &Item) {
if (Item.IsInt)
return OS << Item.Data.Int;
else
return OS << Item.Data.String;
}
raw_ostream &OptionalStmtList::log(raw_ostream &OS) const {
for (const auto &Stmt : Statements) {
OS << " Option: ";
Stmt->log(OS);
}
return OS;
}
raw_ostream &LanguageResource::log(raw_ostream &OS) const {
return OS << "Language: " << Lang << ", Sublanguage: " << SubLang << "\n";
}
StringRef AcceleratorsResource::Accelerator::OptionsStr
[AcceleratorsResource::Accelerator::NumFlags] = {
"ASCII", "VIRTKEY", "NOINVERT", "ALT", "SHIFT", "CONTROL"};
raw_ostream &AcceleratorsResource::log(raw_ostream &OS) const {
OS << "Accelerators (" << ResName << "): \n";
OptStatements.log(OS);
for (const auto &Acc : Accelerators) {
OS << " Accelerator: " << Acc.Event << " " << Acc.Id;
for (size_t i = 0; i < Accelerator::NumFlags; ++i)
if (Acc.Flags & (1U << i))
OS << " " << Accelerator::OptionsStr[i];
OS << "\n";
}
return OS;
}
raw_ostream &CursorResource::log(raw_ostream &OS) const {
return OS << "Cursor (" << ResName << "): " << CursorLoc << "\n";
}
raw_ostream &IconResource::log(raw_ostream &OS) const {
return OS << "Icon (" << ResName << "): " << IconLoc << "\n";
}
raw_ostream &HTMLResource::log(raw_ostream &OS) const {
return OS << "HTML (" << ResName << "): " << HTMLLoc << "\n";
}
raw_ostream &StringTableResource::log(raw_ostream &OS) const {
OS << "StringTable:\n";
OptStatements.log(OS);
for (const auto &String : Table)
OS << " " << String.first << " => " << String.second << "\n";
return OS;
}
raw_ostream &CharacteristicsStmt::log(raw_ostream &OS) const {
return OS << "Characteristics: " << Value << "\n";
}
raw_ostream &VersionStmt::log(raw_ostream &OS) const {
return OS << "Version: " << Value << "\n";
}
} // namespace rc
} // namespace llvm