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