Remove the default clause from a fully-covering switch
[llvm-core.git] / tools / llvm-rc / ResourceScriptStmt.cpp
blobcfbd2f8f7a388b91773c6b6f617f8d6abd09ed95
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===---------------------------------------------------------------------===//
8 //
9 // This implements methods defined in ResourceScriptStmt.h.
11 // Ref: msdn.microsoft.com/en-us/library/windows/desktop/aa380599(v=vs.85).aspx
13 //===---------------------------------------------------------------------===//
15 #include "ResourceScriptStmt.h"
17 namespace llvm {
18 namespace rc {
20 raw_ostream &operator<<(raw_ostream &OS, const IntOrString &Item) {
21 if (Item.IsInt)
22 return OS << Item.Data.Int;
23 else
24 return OS << Item.Data.String;
27 raw_ostream &OptionalStmtList::log(raw_ostream &OS) const {
28 for (const auto &Stmt : Statements) {
29 OS << " Option: ";
30 Stmt->log(OS);
32 return OS;
35 raw_ostream &LanguageResource::log(raw_ostream &OS) const {
36 return OS << "Language: " << Lang << ", Sublanguage: " << SubLang << "\n";
39 StringRef AcceleratorsResource::Accelerator::OptionsStr
40 [AcceleratorsResource::Accelerator::NumFlags] = {
41 "ASCII", "VIRTKEY", "NOINVERT", "ALT", "SHIFT", "CONTROL"};
43 raw_ostream &AcceleratorsResource::log(raw_ostream &OS) const {
44 OS << "Accelerators (" << ResName << "): \n";
45 OptStatements.log(OS);
46 for (const auto &Acc : Accelerators) {
47 OS << " Accelerator: " << Acc.Event << " " << Acc.Id;
48 for (size_t i = 0; i < Accelerator::NumFlags; ++i)
49 if (Acc.Flags & (1U << i))
50 OS << " " << Accelerator::OptionsStr[i];
51 OS << "\n";
53 return OS;
56 raw_ostream &CursorResource::log(raw_ostream &OS) const {
57 return OS << "Cursor (" << ResName << "): " << CursorLoc << "\n";
60 raw_ostream &IconResource::log(raw_ostream &OS) const {
61 return OS << "Icon (" << ResName << "): " << IconLoc << "\n";
64 raw_ostream &HTMLResource::log(raw_ostream &OS) const {
65 return OS << "HTML (" << ResName << "): " << HTMLLoc << "\n";
68 StringRef MenuDefinition::OptionsStr[MenuDefinition::NumFlags] = {
69 "CHECKED", "GRAYED", "HELP", "INACTIVE", "MENUBARBREAK", "MENUBREAK"};
71 raw_ostream &MenuDefinition::logFlags(raw_ostream &OS, uint8_t Flags) {
72 for (size_t i = 0; i < NumFlags; ++i)
73 if (Flags & (1U << i))
74 OS << " " << OptionsStr[i];
75 return OS;
78 raw_ostream &MenuDefinitionList::log(raw_ostream &OS) const {
79 OS << " Menu list starts\n";
80 for (auto &Item : Definitions)
81 Item->log(OS);
82 return OS << " Menu list ends\n";
85 raw_ostream &MenuItem::log(raw_ostream &OS) const {
86 OS << " MenuItem (" << Name << "), ID = " << Id;
87 logFlags(OS, Flags);
88 return OS << "\n";
91 raw_ostream &MenuSeparator::log(raw_ostream &OS) const {
92 return OS << " Menu separator\n";
95 raw_ostream &PopupItem::log(raw_ostream &OS) const {
96 OS << " Popup (" << Name << ")";
97 logFlags(OS, Flags);
98 OS << ":\n";
99 return SubItems.log(OS);
102 raw_ostream &MenuResource::log(raw_ostream &OS) const {
103 OS << "Menu (" << ResName << "):\n";
104 OptStatements.log(OS);
105 return Elements.log(OS);
108 raw_ostream &StringTableResource::log(raw_ostream &OS) const {
109 OS << "StringTable:\n";
110 OptStatements.log(OS);
111 for (const auto &String : Table)
112 OS << " " << String.first << " => " << String.second << "\n";
113 return OS;
116 const StringSet<> Control::SupportedCtls = {
117 "LTEXT", "RTEXT", "CTEXT", "PUSHBUTTON", "DEFPUSHBUTTON", "EDITTEXT"};
119 const StringSet<> Control::CtlsWithTitle = {"LTEXT", "RTEXT", "CTEXT",
120 "PUSHBUTTON", "DEFPUSHBUTTON"};
122 raw_ostream &Control::log(raw_ostream &OS) const {
123 OS << " Control (" << ID << "): " << Type << ", title: " << Title
124 << ", loc: (" << X << ", " << Y << "), size: [" << Width << ", " << Height
125 << "]";
126 if (Style)
127 OS << ", style: " << *Style;
128 if (ExtStyle)
129 OS << ", ext. style: " << *ExtStyle;
130 if (HelpID)
131 OS << ", help ID: " << *HelpID;
132 return OS << "\n";
135 raw_ostream &DialogResource::log(raw_ostream &OS) const {
136 OS << "Dialog" << (IsExtended ? "Ex" : "") << " (" << ResName << "): loc: ("
137 << X << ", " << Y << "), size: [" << Width << ", " << Height
138 << "], help ID: " << HelpID << "\n";
139 OptStatements.log(OS);
140 for (auto &Ctl : Controls)
141 Ctl.log(OS);
142 return OS;
145 raw_ostream &CharacteristicsStmt::log(raw_ostream &OS) const {
146 return OS << "Characteristics: " << Value << "\n";
149 raw_ostream &VersionStmt::log(raw_ostream &OS) const {
150 return OS << "Version: " << Value << "\n";
153 raw_ostream &CaptionStmt::log(raw_ostream &OS) const {
154 return OS << "Caption: " << Value << "\n";
157 raw_ostream &FontStmt::log(raw_ostream &OS) const {
158 return OS << "Font: size = " << Size << ", face = " << Typeface << "\n";
161 raw_ostream &StyleStmt::log(raw_ostream &OS) const {
162 return OS << "Style: " << Value << "\n";
165 } // namespace rc
166 } // namespace llvm