Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 110 lines (88 sloc) 2.869 kB
289bb97 @tomaz Implemented declared files handling in model layer.
authored
1 //
2 // GBModelBase.m
3 // appledoc
4 //
5 // Created by Tomaz Kragelj on 28.7.10.
6 // Copyright (C) 2010, Gentle Bytes. All rights reserved.
7 //
8
d8eff23 @tomaz Refactored comments handling to use GBComment class instead of simply…
authored
9 #import "GBComment.h"
49bc255 @tomaz Implemented debugDescription method for returning detailed object des…
authored
10 #import "GBSourceInfo.h"
289bb97 @tomaz Implemented declared files handling in model layer.
authored
11 #import "GBModelBase.h"
12
13 @implementation GBModelBase
14
15 #pragma mark Initialization & disposal
16
17 - (id)init {
18 self = [super init];
19 if (self) {
0dd2364 @tomaz Renamed GBDeclaredFileData to GBSourceInfo to better convey the purpo…
authored
20 _sourceInfos = [[NSMutableSet alloc] init];
21 _sourceInfosByFilenames = [[NSMutableDictionary alloc] init];
e0f477a @lhunath Added support for excluding paths from the output.
lhunath authored
22 _includeInOutput = YES;
289bb97 @tomaz Implemented declared files handling in model layer.
authored
23 }
24 return self;
25 }
26
4b79136 @tomaz Implemented top-level objects comments registration.
authored
27 #pragma mark Merging handling
28
29 - (void)mergeDataFromObject:(id)source {
30 NSParameterAssert([source isKindOfClass:[self class]]);
77b0066 @tomaz Implemented declared file data that includes file name and line number.
authored
31
32 // Merge declared files.
0dd2364 @tomaz Renamed GBDeclaredFileData to GBSourceInfo to better convey the purpo…
authored
33 NSArray *sourceFiles = [[source sourceInfos] allObjects];
34 for (GBSourceInfo *filedata in sourceFiles) {
35 GBSourceInfo *ourfiledata = [_sourceInfosByFilenames objectForKey:filedata.filename];
77b0066 @tomaz Implemented declared file data that includes file name and line number.
authored
36 if (ourfiledata) {
37 if (ourfiledata.lineNumber < filedata.lineNumber) {
0dd2364 @tomaz Renamed GBDeclaredFileData to GBSourceInfo to better convey the purpo…
authored
38 [_sourceInfosByFilenames setObject:filedata forKey:filedata.filename];
39 [_sourceInfos removeObject:ourfiledata];
40 [_sourceInfos addObject:filedata];
77b0066 @tomaz Implemented declared file data that includes file name and line number.
authored
41 }
42 continue;
43 }
0dd2364 @tomaz Renamed GBDeclaredFileData to GBSourceInfo to better convey the purpo…
authored
44 [_sourceInfosByFilenames setObject:filedata forKey:filedata.filename];
45 [_sourceInfos addObject:filedata];
77b0066 @tomaz Implemented declared file data that includes file name and line number.
authored
46 }
47
48 // Merge comment.
a136f4d @tomaz Fixed compiler warnings after upgrading to Xcode 4.3. Closes #186.
authored
49 GBComment *theComment = [(GBModelBase *)source comment];
50 if (self.comment && theComment) {
7c481a0 @commandtab Make 'comment found' entries log at INFO level
commandtab authored
51 GBLogXInfo(self.prefferedSourceInfo, @"%@: Comment found in %@ and %@", self, self.comment.sourceInfo, theComment.sourceInfo);
4b79136 @tomaz Implemented top-level objects comments registration.
authored
52 return;
53 }
a136f4d @tomaz Fixed compiler warnings after upgrading to Xcode 4.3. Closes #186.
authored
54 if (!self.comment && theComment) self.comment = theComment;
4b79136 @tomaz Implemented top-level objects comments registration.
authored
55 }
56
2f02d3a @tomaz Added cross reference regexes to registered objects.
authored
57 #pragma mark Source information handling
289bb97 @tomaz Implemented declared files handling in model layer.
authored
58
0dd2364 @tomaz Renamed GBDeclaredFileData to GBSourceInfo to better convey the purpo…
authored
59 - (void)registerSourceInfo:(GBSourceInfo *)data {
77b0066 @tomaz Implemented declared file data that includes file name and line number.
authored
60 NSParameterAssert(data != nil);
61
62 // Ignore already registered objects.
0dd2364 @tomaz Renamed GBDeclaredFileData to GBSourceInfo to better convey the purpo…
authored
63 if ([_sourceInfos member:data]) return;
77b0066 @tomaz Implemented declared file data that includes file name and line number.
authored
64
65 // Replace data with same filename.
0dd2364 @tomaz Renamed GBDeclaredFileData to GBSourceInfo to better convey the purpo…
authored
66 GBSourceInfo *existing = [_sourceInfosByFilenames objectForKey:data.filename];
67 if (existing) [_sourceInfos removeObject:existing];
77b0066 @tomaz Implemented declared file data that includes file name and line number.
authored
68
69 // Add object.
0dd2364 @tomaz Renamed GBDeclaredFileData to GBSourceInfo to better convey the purpo…
authored
70 [_sourceInfosByFilenames setObject:data forKey:data.filename];
71 [_sourceInfos addObject:data];
289bb97 @tomaz Implemented declared files handling in model layer.
authored
72 }
73
1efedb6 @tomaz Implemented better support for declared in info.
authored
74 - (GBSourceInfo *)prefferedSourceInfo {
75 if (self.comment && self.comment.sourceInfo) return self.comment.sourceInfo;
76 if ([self.sourceInfos count] > 0) {
77 NSArray *infos = [self sourceInfosSortedByName];
78 for (GBSourceInfo *info in infos) {
79 if ([[info.filename pathExtension] isEqualToString:@"h"]) return info;
80 }
81 return [infos objectAtIndex:0];
82 }
83 return nil;
84 }
85
0dd2364 @tomaz Renamed GBDeclaredFileData to GBSourceInfo to better convey the purpo…
authored
86 - (NSArray *)sourceInfosSortedByName {
87 return [[self.sourceInfos allObjects] sortedArrayUsingSelector:@selector(compare:)];
289bb97 @tomaz Implemented declared files handling in model layer.
authored
88 }
89
a35467a @tomaz Moved most of HTML dealing code to GBHTMLOutputGenerator.
authored
90 #pragma Helper methods
91
97db241 @tomaz Implemented possibility to add arbitrary documentation. Closes #7.
authored
92 - (BOOL)isStaticDocument {
93 return NO;
94 }
95
a35467a @tomaz Moved most of HTML dealing code to GBHTMLOutputGenerator.
authored
96 - (BOOL)isTopLevelObject {
97 return NO;
98 }
99
4b79136 @tomaz Implemented top-level objects comments registration.
authored
100 #pragma mark Properties
101
9047fcf @tomaz Refactored comment handling with GBModelBase by removing registerComm…
authored
102 @synthesize comment;
0dd2364 @tomaz Renamed GBDeclaredFileData to GBSourceInfo to better convey the purpo…
authored
103 @synthesize sourceInfos = _sourceInfos;
89f0413 @tomaz Implemented ivar and method parent object handling.
authored
104 @synthesize parentObject;
7d6a323 @tomaz Copied all the changes from the old generating branch.
authored
105 @synthesize htmlLocalReference;
106 @synthesize htmlReferenceName;
e0f477a @lhunath Added support for excluding paths from the output.
lhunath authored
107 @synthesize includeInOutput = _includeInOutput;
289bb97 @tomaz Implemented declared files handling in model layer.
authored
108
109 @end
Something went wrong with that request. Please try again.