123 :(NSString *)aiName
124{
125 NSString *path =
nil;
126 NSDictionary *aiStateMachine =
nil;
127 NSEnumerator *stateEnum =
nil;
128 NSString *stateKey =
nil;
129 NSDictionary *stateHandlers =
nil;
130 NSEnumerator *handlerEnum =
nil;
131 NSString *handlerKey =
nil;
132 NSArray *handlerActions =
nil;
133 NSEnumerator *actionEnum =
nil;
134 NSString *action =
nil;
135 NSRange spaceRange;
136 NSString *selector =
nil;
137 NSMutableSet *badSelectors =
nil;
138 NSString *badSelectorDesc =
nil;
139 NSUInteger index = 0;
140
141 OOLog(
@"verifyOXP.verbose.validateAI",
@"- Validating AI \"%@\
".", aiName);
143
144
145 path = [[[self verifier] fileScannerStage] pathForFile:aiName inFolder:@"AIs" referencedFrom:@"AI list" checkBuiltIn:NO];
146 if (path ==
nil)
return;
147
148 badSelectors = [NSMutableSet set];
149
151 if (aiStateMachine ==
nil)
152 {
153 OOLog(
@"verifyOXP.validateAI.failed.notDictPlist",
@"***** ERROR: could not interpret \"%@\
" as a dictionary.", path);
154 return;
155 }
156
157
158 for (stateEnum = [aiStateMachine keyEnumerator]; (stateKey = [stateEnum nextObject]); )
159 {
160 stateHandlers = [aiStateMachine objectForKey:stateKey];
161 if (![stateHandlers isKindOfClass:[NSDictionary class]])
162 {
163 OOLog(
@"verifyOXP.validateAI.failed.invalidFormat.state",
@"***** ERROR: state \"%@\
" in AI \"%@\" is not a dictionary.", stateKey, aiName);
164 continue;
165 }
166
167
168 for (handlerEnum = [stateHandlers keyEnumerator]; (handlerKey = [handlerEnum nextObject]); )
169 {
170 handlerActions = [stateHandlers objectForKey:handlerKey];
171 if (![handlerActions isKindOfClass:[NSArray class]])
172 {
173 OOLog(
@"verifyOXP.validateAI.failed.invalidFormat.handler",
@"***** ERROR: handler \"%@\
" for state \"%@\" in AI \"%@\" is not an array, ignoring.", handlerKey, stateKey, aiName);
174 continue;
175 }
176
177
178 index = 0;
179 for (actionEnum = [handlerActions objectEnumerator]; (action = [actionEnum nextObject]); )
180 {
181 index++;
182 if (![action isKindOfClass:[NSString class]])
183 {
184 OOLog(
@"verifyOXP.validateAI.failed.invalidFormat.action",
@"***** ERROR: action %lu in handler \"%@\
" for state \"%@\" in AI \"%@\" is not a string, ignoring.", index - 1, handlerKey, stateKey, aiName);
185 continue;
186 }
187
188
189 action = [action stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
190
191
192 spaceRange = [action rangeOfString:@" "];
193 if (spaceRange.location == NSNotFound) selector = action;
194 else selector = [action substringToIndex:spaceRange.location];
195
196
197 if (![_whitelist containsObject:selector])
198 {
199 [badSelectors addObject:selector];
200 }
201 }
202 }
203 }
204
205 if ([badSelectors
count] != 0)
206 {
207 badSelectorDesc = [[[badSelectors allObjects] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)] componentsJoinedByString:@", "];
208 OOLog(
@"verifyOXP.validateAI.failed.badSelector",
@"***** ERROR: the AI \"%@\
" uses %lu unpermitted method%s: %@", aiName, [badSelectors
count], ([badSelectors
count] == 1) ?
"" :
"s", badSelectorDesc);
209 }
210
212}
#define OOLogOutdentIf(class)
#define OOLog(class, format,...)
#define OOLogIndentIf(class)
NSDictionary * OODictionaryFromFile(NSString *path)