115- (void)validateAI:(NSString*)aiName
117 NSString* path =
nil;
118 NSDictionary* aiStateMachine =
nil;
119 NSString* stateKey =
nil;
120 NSDictionary* stateHandlers =
nil;
121 NSString* handlerKey =
nil;
122 NSArray* handlerActions =
nil;
123 NSString* action =
nil;
125 NSString* selector =
nil;
126 NSMutableSet* badSelectors =
nil;
127 NSString* badSelectorDesc =
nil;
128 NSUInteger index = 0;
130 OOLog(
@"verifyOXP.verbose.validateAI",
@"- Validating AI \"%@\
".", aiName);
141 if (aiStateMachine ==
nil) {
142 OOLog(
@"verifyOXP.validateAI.failed.notDictPlist",
@"***** ERROR: could not interpret \"%@\
" as a dictionary.", path);
150 if (![stateHandlers isKindOfClass:[NSDictionary
class]]) {
151 OOLog(
@"verifyOXP.validateAI.failed.invalidFormat.state",
@"***** ERROR: state \"%@\
" in AI \"%@\" is not a dictionary.", stateKey, aiName);
159 if (![handlerActions isKindOfClass:[NSArray
class]]) {
160 OOLog(
@"verifyOXP.validateAI.failed.invalidFormat.handler",
@"***** ERROR: handler \"%@\
" for state \"%@\" in AI \"%@\" is not an array, ignoring.", handlerKey, stateKey, aiName);
166 foreach (action, handlerActions) {
168 if (![action isKindOfClass:[NSString
class]]) {
169 OOLog(
@"verifyOXP.validateAI.failed.invalidFormat.action",
@"***** ERROR: action %zu in handler \"%@\
" for state \"%@\" in AI \"%@\" is not a string, ignoring.", index - 1, handlerKey, stateKey, aiName);
177 spaceRange = [
action rangeOfString:@" "];
178 if (spaceRange.location == NSNotFound)
181 selector = [
action substringToIndex:spaceRange.location];
184 if (![_whitelist containsObject:selector]) {
191 if ([badSelectors
count] != 0) {
192 badSelectorDesc = [[[
badSelectors allObjects] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)] componentsJoinedByString:@", "];
193 OOLog(
@"verifyOXP.validateAI.failed.badSelector",
@"***** ERROR: the AI \"%@\
" uses %zu unpermitted method%s: %@", aiName, [badSelectors
count], ([badSelectors
count] == 1) ?
"" :
"s", badSelectorDesc);