Skip to content

Commit ec0a8f9

Browse files
committed
Complete expandIvarRecordTypeMembers option
1 parent 307c9d3 commit ec0a8f9

File tree

2 files changed

+47
-8
lines changed

2 files changed

+47
-8
lines changed

ClassDumpRuntime/Models/ParseTypes/CDRecordType.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,18 @@ - (NSString *)debugDescription {
9696
[self class], self, [self modifiersString], self.name, self.isUnion ? @"YES" : @"NO", self.fields.debugDescription];
9797
}
9898

99+
- (void)setExpand:(BOOL)expand {
100+
_expand = expand;
101+
102+
if (self.fields) {
103+
for (CDVariableModel *variableModel in self.fields) {
104+
if ([variableModel.type isKindOfClass:[CDRecordType class]]) {
105+
CDRecordType *recordType = (CDRecordType *)variableModel.type;
106+
recordType.indentLevel = self.indentLevel + 1;
107+
recordType.expand = expand;
108+
}
109+
}
110+
}
111+
}
112+
99113
@end

ClassDumpRuntimeTests/CDParseAdvancedTests.m

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,41 @@ - (void)testBitfields {
194194
unsigned __int128 f : 100;
195195
unsigned g : 10;
196196
unsigned h : 15;
197+
struct BitfieldTestB {
198+
unsigned a : 18;
199+
unsigned b : 2;
200+
unsigned c : 30;
201+
unsigned long d : 34;
202+
unsigned e : 1;
203+
unsigned __int128 f : 100;
204+
unsigned g : 10;
205+
unsigned h : 15;
206+
} nested;
197207
};
198-
CDRecordType *type = [CDTypeParser typeForEncoding:@encode(struct BitfieldTest)];
208+
CDRecordType *type = (CDRecordType *)[CDTypeParser typeForEncoding:@encode(struct BitfieldTest)];
199209
type.expand = YES;
200-
NSLog(@"%@", [type stringForVariableName:@"var"]);
201-
// XCTAssert([[type stringForVariableName:@"var"] isEqualToString:@"struct BitfieldTest { "
202-
// "unsigned int x0 : 18; unsigned char x1 : 2; "
203-
// "unsigned int x2 : 30; unsigned long x3 : 34; "
204-
// "unsigned char x4 : 1; unsigned __int128 x5 : 100; "
205-
// "unsigned short x6 : 10; unsigned short x7 : 15; "
206-
// "} var"]);
210+
NSString *expected =
211+
@"struct BitfieldTest { \n"\
212+
" unsigned int x0 : 18; \n"\
213+
" unsigned char x1 : 2; \n"\
214+
" unsigned int x2 : 30; \n"\
215+
" unsigned long x3 : 34; \n"\
216+
" unsigned char x4 : 1; \n"\
217+
" unsigned __int128 x5 : 100; \n"\
218+
" unsigned short x6 : 10; \n"\
219+
" unsigned short x7 : 15; \n"\
220+
" struct BitfieldTestB { \n"\
221+
" unsigned int x0 : 18; \n"\
222+
" unsigned char x1 : 2; \n"\
223+
" unsigned int x2 : 30; \n"\
224+
" unsigned long x3 : 34; \n"\
225+
" unsigned char x4 : 1; \n"\
226+
" unsigned __int128 x5 : 100; \n"\
227+
" unsigned short x6 : 10; \n"\
228+
" unsigned short x7 : 15; \n"\
229+
" } x8; \n"\
230+
"} var";
231+
XCTAssert([[type stringForVariableName:@"var"] isEqualToString:expected]);
207232
}
208233

209234
- (void)testModifiedFields {

0 commit comments

Comments
 (0)