Index: test/tools/llvm-rc/Inputs/tag-dialog.rc =================================================================== --- test/tools/llvm-rc/Inputs/tag-dialog.rc +++ test/tools/llvm-rc/Inputs/tag-dialog.rc @@ -28,6 +28,21 @@ EDITTEXT 2001, 2002, 2003, 2004, 2005 LTEXT 65535, 3001, 3002, 3003, 3004, 3005 + + AUTO3STATE "A3", 12, 2, 3, 4, 5 + AUTOCHECKBOX "AC", 13, 2, 3, 4, 5 + AUTORADIOBUTTON "AR", 14, 2, 3, 4, 5 + CHECKBOX "C", 15, 2, 3, 4, 5 + COMBOBOX 16, 2, 3, 4, 5 + GROUPBOX "G", 17, 2, 3, 4, 5 + ICON "I", 18, 2, 3, 4, 5 + LISTBOX 19, 2, 3, 4, 5 + RADIOBUTTON "R", 20, 2, 3, 4, 5 + COMBOBOX 21, 2, 3, 4, 5 + SCROLLBAR 22, 2, 3, 4, 5 + STATE3 "S", 23, 2, 3, 4, 5 + PUSHBOX "P", 24, 2, 3, 4, 5 + CONTROL "C", 25, "Class", 42, 2, 3, 4, 5 } EmptyOld DIALOG 1, 2, 3, 4 {} Index: test/tools/llvm-rc/tag-dialog.test =================================================================== --- test/tools/llvm-rc/tag-dialog.test +++ test/tools/llvm-rc/tag-dialog.test @@ -70,10 +70,10 @@ ; DIALOG-NEXT: Version (major): 0 ; DIALOG-NEXT: Version (minor): 0 ; DIALOG-NEXT: Characteristics: 0 -; DIALOG-NEXT: Data size: 282 +; DIALOG-NEXT: Data size: 778 ; DIALOG-NEXT: Data: ( ; DIALOG-NEXT: 0000: 0100FFFF 54535251 00000000 00008880 |....TSRQ........| -; DIALOG-NEXT: 0010: 07003930 31D43412 ED1E0000 00000000 |..901.4.........| +; DIALOG-NEXT: 0010: 15003930 31D43412 ED1E0000 00000000 |..901.4.........| ; DIALOG-NEXT: 0020: 00000000 00000000 00000250 02000300 |...........P....| ; DIALOG-NEXT: 0030: 04000500 01000000 FFFF8200 4C000000 |............L...| ; DIALOG-NEXT: 0040: 00000000 00000000 00000000 01000250 |...............P| @@ -89,7 +89,38 @@ ; DIALOG-NEXT: 00E0: 00008150 D207D307 D407D507 D1070000 |...P............| ; DIALOG-NEXT: 00F0: FFFF8100 00000000 00000000 00000000 |................| ; DIALOG-NEXT: 0100: 00000250 BA0BBB0B BC0BBD0B B90B0000 |...P............| -; DIALOG-NEXT: 0110: FFFF8200 FFFFFFFF 0000 |..........| +; DIALOG-NEXT: 0110: FFFF8200 FFFFFFFF 00000000 00000000 |................| +; DIALOG-NEXT: 0120: 00000000 06000150 02000300 04000500 |.......P........| +; DIALOG-NEXT: 0130: 0C000000 FFFF8000 41003300 00000000 |........A.3.....| +; DIALOG-NEXT: 0140: 00000000 00000000 03000150 02000300 |...........P....| +; DIALOG-NEXT: 0150: 04000500 0D000000 FFFF8000 41004300 |............A.C.| +; DIALOG-NEXT: 0160: 00000000 00000000 00000000 09000050 |...............P| +; DIALOG-NEXT: 0170: 02000300 04000500 0E000000 FFFF8000 |................| +; DIALOG-NEXT: 0180: 41005200 00000000 00000000 00000000 |A.R.............| +; DIALOG-NEXT: 0190: 02000150 02000300 04000500 0F000000 |...P............| +; DIALOG-NEXT: 01A0: FFFF8000 43000000 00000000 00000000 |....C...........| +; DIALOG-NEXT: 01B0: 00000000 00000050 02000300 04000500 |.......P........| +; DIALOG-NEXT: 01C0: 10000000 FFFF8500 00000000 00000000 |................| +; DIALOG-NEXT: 01D0: 00000000 07000050 02000300 04000500 |.......P........| +; DIALOG-NEXT: 01E0: 11000000 FFFF8000 47000000 00000000 |........G.......| +; DIALOG-NEXT: 01F0: 00000000 00000000 03000050 02000300 |...........P....| +; DIALOG-NEXT: 0200: 04000500 12000000 FFFF8200 49000000 |............I...| +; DIALOG-NEXT: 0210: 00000000 00000000 00000000 01008050 |...............P| +; DIALOG-NEXT: 0220: 02000300 04000500 13000000 FFFF8300 |................| +; DIALOG-NEXT: 0230: 00000000 00000000 00000000 04000050 |...............P| +; DIALOG-NEXT: 0240: 02000300 04000500 14000000 FFFF8000 |................| +; DIALOG-NEXT: 0250: 52000000 00000000 00000000 00000000 |R...............| +; DIALOG-NEXT: 0260: 00000050 02000300 04000500 15000000 |...P............| +; DIALOG-NEXT: 0270: FFFF8500 00000000 00000000 00000000 |................| +; DIALOG-NEXT: 0280: 00000050 02000300 04000500 16000000 |...P............| +; DIALOG-NEXT: 0290: FFFF8400 00000000 00000000 00000000 |................| +; DIALOG-NEXT: 02A0: 05000150 02000300 04000500 17000000 |...P............| +; DIALOG-NEXT: 02B0: FFFF8000 53000000 00000000 00000000 |....S...........| +; DIALOG-NEXT: 02C0: 00000000 0A000150 02000300 04000500 |.......P........| +; DIALOG-NEXT: 02D0: 18000000 FFFF8000 50000000 00000000 |........P.......| +; DIALOG-NEXT: 02E0: 00000000 00000000 2A000050 02000300 |........*..P....| +; DIALOG-NEXT: 02F0: 04000500 19000000 43006C00 61007300 |........C.l.a.s.| +; DIALOG-NEXT: 0300: 73000000 43000000 0000 |s...C.....| ; DIALOG-NEXT: ) ; DIALOG-DAG: Resource type (int): 5 Index: tools/llvm-rc/ResourceFileWriter.cpp =================================================================== --- tools/llvm-rc/ResourceFileWriter.cpp +++ tools/llvm-rc/ResourceFileWriter.cpp @@ -1019,7 +1019,7 @@ } // Window class - either 0xFFFF + 16-bit integer or a string. - RETURN_IF_ERROR(writeIntOrString(IntOrString(TypeInfo.CtlClass))); + RETURN_IF_ERROR(writeIntOrString(Ctl.Class)); // Element caption/reference ID. ID is preceded by 0xFFFF. RETURN_IF_ERROR(checkIntOrString(Ctl.Title, "Control reference ID")); Index: tools/llvm-rc/ResourceScriptParser.cpp =================================================================== --- tools/llvm-rc/ResourceScriptParser.cpp +++ tools/llvm-rc/ResourceScriptParser.cpp @@ -486,15 +486,46 @@ Caption = *CaptionResult; } - ASSIGN_OR_RETURN(Args, readIntsWithCommas(5, 8)); + ASSIGN_OR_RETURN(ID, readInt()); + RETURN_IF_ERROR(consumeType(Kind::Comma)); - auto TakeOptArg = [&Args](size_t Id) -> Optional { - return Args->size() > Id ? (uint32_t)(*Args)[Id] : Optional(); - }; + IntOrString Class; + Optional Style; + if (ClassUpper == "CONTROL") { + // CONTROL text, id, class, style, x, y, width, height [, exstyle] [, helpID] + ASSIGN_OR_RETURN(ClassStr, readString()); + RETURN_IF_ERROR(consumeType(Kind::Comma)); + Class = *ClassStr; + ASSIGN_OR_RETURN(StyleVal, readInt()); + RETURN_IF_ERROR(consumeType(Kind::Comma)); + Style = *StyleVal; + } else { + Class = CtlInfo->getValue().CtlClass; + } + + // x, y, width, height + ASSIGN_OR_RETURN(Args, readIntsWithCommas(4, 4)); + + if (ClassUpper != "CONTROL") { + if (consumeOptionalType(Kind::Comma)) { + ASSIGN_OR_RETURN(Val, readInt()); + Style = *Val; + } + } + + Optional ExStyle; + if (consumeOptionalType(Kind::Comma)) { + ASSIGN_OR_RETURN(Val, readInt()); + ExStyle = *Val; + } + Optional HelpID; + if (consumeOptionalType(Kind::Comma)) { + ASSIGN_OR_RETURN(Val, readInt()); + HelpID = *Val; + } - return Control(*ClassResult, Caption, (*Args)[0], (*Args)[1], (*Args)[2], - (*Args)[3], (*Args)[4], TakeOptArg(5), TakeOptArg(6), - TakeOptArg(7)); + return Control(*ClassResult, Caption, *ID, (*Args)[0], (*Args)[1], + (*Args)[2], (*Args)[3], Style, ExStyle, HelpID, Class); } RCParser::ParseType RCParser::parseBitmapResource() { Index: tools/llvm-rc/ResourceScriptStmt.h =================================================================== --- tools/llvm-rc/ResourceScriptStmt.h +++ tools/llvm-rc/ResourceScriptStmt.h @@ -542,6 +542,7 @@ IntOrString Title; uint32_t ID, X, Y, Width, Height; Optional Style, ExtStyle, HelpID; + IntOrString Class; // Control classes as described in DLGITEMTEMPLATEEX documentation. // @@ -565,10 +566,10 @@ Control(StringRef CtlType, IntOrString CtlTitle, uint32_t CtlID, uint32_t PosX, uint32_t PosY, uint32_t ItemWidth, uint32_t ItemHeight, Optional ItemStyle, Optional ExtItemStyle, - Optional CtlHelpID) + Optional CtlHelpID, IntOrString CtlClass) : Type(CtlType), Title(CtlTitle), ID(CtlID), X(PosX), Y(PosY), Width(ItemWidth), Height(ItemHeight), Style(ItemStyle), - ExtStyle(ExtItemStyle), HelpID(CtlHelpID) {} + ExtStyle(ExtItemStyle), HelpID(CtlHelpID), Class(CtlClass) {} static const StringMap SupportedCtls; Index: tools/llvm-rc/ResourceScriptStmt.cpp =================================================================== --- tools/llvm-rc/ResourceScriptStmt.cpp +++ tools/llvm-rc/ResourceScriptStmt.cpp @@ -128,9 +128,22 @@ {"LTEXT", CtlInfo{0x50020000, ClsStatic, true}}, {"CTEXT", CtlInfo{0x50020001, ClsStatic, true}}, {"RTEXT", CtlInfo{0x50020002, ClsStatic, true}}, + {"ICON", CtlInfo{0x50000003, ClsStatic, true}}, {"PUSHBUTTON", CtlInfo{0x50010000, ClsButton, true}}, {"DEFPUSHBUTTON", CtlInfo{0x50010001, ClsButton, true}}, + {"AUTO3STATE", CtlInfo{0x50010006, ClsButton, true}}, + {"AUTOCHECKBOX", CtlInfo{0x50010003, ClsButton, true}}, + {"AUTORADIOBUTTON", CtlInfo{0x50000009, ClsButton, true}}, + {"CHECKBOX", CtlInfo{0x50010002, ClsButton, true}}, + {"GROUPBOX", CtlInfo{0x50000007, ClsButton, true}}, + {"RADIOBUTTON", CtlInfo{0x50000004, ClsButton, true}}, + {"STATE3", CtlInfo{0x50010005, ClsButton, true}}, + {"PUSHBOX", CtlInfo{0x5001000A, ClsButton, true}}, {"EDITTEXT", CtlInfo{0x50810000, ClsEdit, false}}, + {"COMBOBOX", CtlInfo{0x50000000, ClsComboBox, false}}, + {"LISTBOX", CtlInfo{0x50800001, ClsListBox, false}}, + {"SCROLLBAR", CtlInfo{0x50000000, ClsScrollBar, false}}, + {"CONTROL", CtlInfo{0x50000000, 0, true}}, }; raw_ostream &Control::log(raw_ostream &OS) const {