Skip to content

Commit

Permalink
Added struct name handling in store objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaz committed May 7, 2012
1 parent 7c1a32f commit 8d8e668
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
13 changes: 13 additions & 0 deletions AppledocTests/Store/StoreTests.mm
Expand Up @@ -393,6 +393,19 @@ static void runWithStore(void(^handler)(Store *store)) {
store.storeStructs should contain(store.currentRegistrationObject);
});
});

it(@"should forward append struct name to current registration object", ^{
runWithStore(^(Store *store) {
// setup
id mock = [OCMockObject mockForClass:[Store class]];
[[mock expect] appendStructName:@"value"];
[store pushRegistrationObject:mock];
// execute
[store appendStructName:@"value"];
// verify
^{ [mock verify]; } should_not raise_exception();
});
});
});

describe(@"constant related registration", ^{
Expand Down
11 changes: 11 additions & 0 deletions AppledocTests/Store/StructInfoTests.mm
Expand Up @@ -28,6 +28,17 @@ static void runWithStructInfo(void(^handler)(StructInfo *info)) {
});
});

describe(@"struct data registration", ^{
it(@"should assign struct name", ^{
runWithStructInfo(^(StructInfo *info) {
// execute
[info appendStructName:@"name"];
// verify
info.nameOfStruct should equal(@"name");
});
});
});

describe(@"constant registration", ^{
it(@"should create new constant info and add it to struct items", ^{
runWithStructInfo(^(StructInfo *info) {
Expand Down
3 changes: 3 additions & 0 deletions appledoc/Store/Store.m
Expand Up @@ -300,6 +300,9 @@ - (void)beginStruct {
}

- (void)appendStructName:(NSString *)name {
if (![self expectCurrentRegistrationObjectRespondTo:_cmd]) return;
LogStoVerbose(@"Forwarding struct name registration to %@...", self.currentRegistrationObject);
[self.currentRegistrationObject appendStructName:name];
}

#pragma mark - Constants
Expand Down
1 change: 1 addition & 0 deletions appledoc/Store/StructInfo.h
Expand Up @@ -14,6 +14,7 @@
*/
@interface StructInfo : ObjectInfoBase

@property (nonatomic, copy) NSString *nameOfStruct;
@property (nonatomic, strong) NSMutableArray *structItems;

@end
6 changes: 6 additions & 0 deletions appledoc/Store/StructInfo.m
Expand Up @@ -13,6 +13,7 @@

@implementation StructInfo

@synthesize nameOfStruct = _nameOfStruct;
@synthesize structItems = _structItems;

#pragma mark - Properties
Expand All @@ -30,6 +31,11 @@ - (NSMutableArray *)structItems {

@implementation StructInfo (Registrations)

- (void)appendStructName:(NSString *)name {
LogStoInfo(@"Appending struct name %@...", name);
self.nameOfStruct = name;
}

- (void)beginConstant {
LogStoVerbose(@"Starting constant...");
ConstantInfo *info = [[ConstantInfo alloc] initWithRegistrar:self.objectRegistrar];
Expand Down

0 comments on commit 8d8e668

Please sign in to comment.