Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOOXPVerifier(OOPrivate) Category Reference

Instance Methods

(id) - initWithPath:
 
(void) - run
 
(void) - setUpLogOverrides
 
(void) - registerBaseStages
 
(void) - buildDependencyGraph
 
(void) - runStages
 
(BOOL) - setUpDependencies:forStage:
 
(void) - setUpDependents:forStage:
 
(void) - dumpDebugGraphviz
 

Detailed Description

Definition at line 48 of file OOOXPVerifier.m.

Method Documentation

◆ buildDependencyGraph

- (void) buildDependencyGraph

Extends class OOOXPVerifier.

Definition at line 727 of file OOOXPVerifier.m.

378{
379 NSAutoreleasePool *pool = nil;
380 NSArray *stageKeys = nil;
381 NSEnumerator *stageEnum = nil;
382 NSString *stageKey = nil;
383 OOOXPVerifierStage *stage = nil;
384 NSString *name = nil;
385 NSMutableDictionary *dependenciesByStage = nil,
386 *dependentsByStage = nil;
387 NSSet *dependencies = nil,
388 *dependents = nil;
389 NSValue *key = nil;
390
391 pool = [[NSAutoreleasePool alloc] init];
392
393 /* Iterate over all stages, getting dependency and dependent sets.
394 This is done in advance so that -dependencies and -dependents may
395 register stages.
396 */
397 dependenciesByStage = [NSMutableDictionary dictionary];
398 dependentsByStage = [NSMutableDictionary dictionary];
399
400 for (;;)
401 {
402 /* Loop while there are stages whose dependency lists haven't been
403 checked. This is an indeterminate loop since new ones can be
404 added.
405 */
406 stage = [_waitingStages anyObject];
407 if (stage == nil) break;
408 [_waitingStages removeObject:stage];
409
410 key = [NSValue valueWithNonretainedObject:stage];
411
412 dependencies = [stage dependencies];
413 if (dependencies != nil)
414 {
415 [dependenciesByStage setObject:dependencies
416 forKey:key];
417 }
418
419 dependents = [stage dependents];
420 if (dependents != nil)
421 {
422 [dependentsByStage setObject:dependents
423 forKey:key];
424 }
425 }
426 [_waitingStages release];
427 _waitingStages = nil;
428 _openForRegistration = NO;
429
430 // Iterate over all stages, resolving dependencies.
431 stageKeys = [_stagesByName allKeys]; // Get the keys up front because we may need to remove entries from dictionary.
432
433 for (stageEnum = [stageKeys objectEnumerator]; (stageKey = [stageEnum nextObject]); )
434 {
435 stage = [_stagesByName objectForKey:stageKey];
436 if (stage == nil) continue;
437
438 // Sanity check
439 name = [stage name];
440 if (![stageKey isEqualToString:name])
441 {
442 OOLog(@"verifyOXP.buildDependencyGraph.badName", @"***** Stage name appears to have changed from \"%@\" to \"%@\" for verifier stage %@, removing.", stageKey, name, stage);
443 [_stagesByName removeObjectForKey:stageKey];
444 continue;
445 }
446
447 // Get dependency set
448 key = [NSValue valueWithNonretainedObject:stage];
449 dependencies = [dependenciesByStage objectForKey:key];
450
451 if (dependencies != nil && ![self setUpDependencies:dependencies forStage:stage])
452 {
453 [_stagesByName removeObjectForKey:stageKey];
454 }
455 }
456
457 /* Iterate over all stages again, resolving reverse dependencies.
458 This is done in a separate pass because reverse dependencies are "weak"
459 while forward dependencies are "strong".
460 */
461 stageKeys = [_stagesByName allKeys];
462
463 for (stageEnum = [stageKeys objectEnumerator]; (stageKey = [stageEnum nextObject]); )
464 {
465 stage = [_stagesByName objectForKey:stageKey];
466 if (stage == nil) continue;
467
468 // Get dependent set
469 key = [NSValue valueWithNonretainedObject:stage];
470 dependents = [dependentsByStage objectForKey:key];
471
472 if (dependents != nil)
473 {
474 [self setUpDependents:dependents forStage:stage];
475 }
476 }
477
478 _waitingStages = [[NSMutableSet alloc] initWithArray:[_stagesByName allValues]];
479 [_waitingStages makeObjectsPerformSelector:@selector(dependencyRegistrationComplete)];
480
481 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"oxp-verifier-dump-debug-graphviz"])
482 {
483 [self dumpDebugGraphviz];
484 }
485
486 [pool release];
487}
#define OOLog(class, format,...)
Definition OOLogging.h:88
return nil

References OOLogHandlerGetLogPath().

+ Here is the call graph for this function:

◆ dumpDebugGraphviz

- (void) dumpDebugGraphviz

Extends class OOOXPVerifier.

Definition at line 727 of file OOOXPVerifier.m.

628{
629 NSMutableString *graphViz = nil;
630 NSDictionary *graphVizTemplate = nil;
631 NSString *template = nil,
632 *startTemplate = nil,
633 *endTemplate = nil;
634 NSEnumerator *stageEnum = nil;
635 OOOXPVerifierStage *stage = nil;
636 NSSet *deps = nil;
637 NSEnumerator *depEnum = nil;
638 OOOXPVerifierStage *dep = nil;
639
640 graphVizTemplate = [self configurationDictionaryForKey:@"debugGraphvizTempate"];
641 graphViz = [NSMutableString stringWithFormat:[graphVizTemplate oo_stringForKey:@"preamble"], [NSDate date]];
642
643 /* Pass 1: enumerate over graph setting node attributes for each stage.
644 We use pointers as node names for simplicity of generation.
645 */
646 template = [graphVizTemplate oo_stringForKey:@"node"];
647 for (stageEnum = [_stagesByName objectEnumerator]; (stage = [stageEnum nextObject]); )
648 {
649 [graphViz appendFormat:template, stage, [stage class], [stage name]];
650 }
651
652 [graphViz appendString:[graphVizTemplate oo_stringForKey:@"forwardPreamble"]];
653
654 /* Pass 2: enumerate over graph setting forward arcs for each dependency.
655 */
656 template = [graphVizTemplate oo_stringForKey:@"forwardArc"];
657 startTemplate = [graphVizTemplate oo_stringForKey:@"startArc"];
658 for (stageEnum = [_stagesByName objectEnumerator]; (stage = [stageEnum nextObject]); )
659 {
660 deps = [stage resolvedDependencies];
661 if ([deps count] != 0)
662 {
663 for (depEnum = [deps objectEnumerator]; (dep = [depEnum nextObject]); )
664 {
665 [graphViz appendFormat:template, dep, stage];
666 }
667 }
668 else
669 {
670 [graphViz appendFormat:startTemplate, stage];
671 }
672 }
673
674 [graphViz appendString:[graphVizTemplate oo_stringForKey:@"backwardPreamble"]];
675
676 /* Pass 3: enumerate over graph setting backward arcs for each dependent.
677 */
678 template = [graphVizTemplate oo_stringForKey:@"backwardArc"];
679 endTemplate = [graphVizTemplate oo_stringForKey:@"endArc"];
680 for (stageEnum = [_stagesByName objectEnumerator]; (stage = [stageEnum nextObject]); )
681 {
682 deps = [stage resolvedDependents];
683 if ([deps count] != 0)
684 {
685 for (depEnum = [deps objectEnumerator]; (dep = [depEnum nextObject]); )
686 {
687 [graphViz appendFormat:template, dep, stage];
688 }
689 }
690 else
691 {
692 [graphViz appendFormat:endTemplate, stage];
693 }
694 }
695
696 [graphViz appendString:[graphVizTemplate oo_stringForKey:@"postamble"]];
697
698 // Write file
699 [ResourceManager writeDiagnosticString:graphViz toFileNamed:@"OXPVerifierStageDependencies.dot"];
700}
unsigned count
BOOL writeDiagnosticString:toFileNamed:(NSString *string,[toFileNamed] NSString *name)

◆ initWithPath:

- (id) initWithPath: (NSString *) path

Extends class OOOXPVerifier.

Definition at line 727 of file OOOXPVerifier.m.

251 :(NSString *)path
252{
253 self = [super init];
254
256
257 NSString *verifierPListPath = [[[ResourceManager builtInPath] stringByAppendingPathComponent:@"Config"] stringByAppendingPathComponent:@"verifyOXP.plist"];
258 _verifierPList = [[NSDictionary dictionaryWithContentsOfFile:verifierPListPath] retain];
259
260 _basePath = [path copy];
261 _displayName = [[NSFileManager defaultManager] displayNameAtPath:_basePath];
262 if (_displayName == nil) _displayName = [_basePath lastPathComponent];
263 [_displayName retain];
264
265 _stagesByName = [[NSMutableDictionary alloc] init];
266 _waitingStages = [[NSMutableSet alloc] init];
267
268 if (_verifierPList == nil ||
269 _basePath == nil)
270 {
271 OOLog(@"verifyOXP.setup.failed", @"%@", @"***** ERROR: failed to set up OXP verifier.");
272 [self release];
273 return nil;
274 }
275
276 _openForRegistration = YES;
277
278 return self;
279}
void OOSetStandardsForOXPVerifierMode(void)
NSString * builtInPath()

◆ registerBaseStages

- (void) registerBaseStages

Extends class OOOXPVerifier.

Definition at line 727 of file OOOXPVerifier.m.

338{
339 NSAutoreleasePool *pool = nil;
340 NSSet *stages = nil;
341 NSSet *excludeStages = nil;
342 NSEnumerator *stageEnum = nil;
343 NSString *stageName = nil;
344 Class stageClass = Nil;
345 OOOXPVerifierStage *stage = nil;
346
347 pool = [[NSAutoreleasePool alloc] init];
348
349 // Load stages specified as array of class names in verifyOXP.plist
350 stages = [self configurationSetForKey:@"stages"];
351 excludeStages = [self configurationSetForKey:@"excludeStages"];
352 if ([excludeStages count] != 0)
353 {
354 stages = [[stages mutableCopy] autorelease];
355 [(NSMutableSet *)stages minusSet:excludeStages];
356 }
357 for (stageEnum = [stages objectEnumerator]; (stageName = [stageEnum nextObject]); )
358 {
359 if ([stageName isKindOfClass:[NSString class]])
360 {
361 stageClass = NSClassFromString(stageName);
362 if (stageClass == Nil)
363 {
364 OOLog(@"verifyOXP.registration.failed", @"Attempt to register unknown class %@ as a verifier stage, ignoring.", stageName);
365 continue;
366 }
367 stage = [[stageClass alloc] init];
368 [self registerStage:stage];
369 [stage release];
370 }
371 }
372
373 [pool release];
374}

◆ run

- (void) run

Extends class OOOXPVerifier.

Definition at line 727 of file OOOXPVerifier.m.

283{
284 NoteVerificationStage(_displayName, @"");
285
286 [self setUpLogOverrides];
287
288 /* We need to be able to look up internal files, but not other OXP files.
289 To do this without clobbering the disk cache, we disable cache writes.
290 */
293 /* FIXME: the OXP verifier should load files from OXPs which have
294 * been explicitly listed as required_oxps in the
295 * manifest. Reading the manifest from the OXP being verified and
296 * setting 'id:<its identifier>' below will do this. */
297 [ResourceManager setUseAddOns:SCENARIO_OXP_DEFINITION_NONE];
298
299 SwitchLogFile(_displayName);
300 OOLog(@"verifyOXP.start", @"Running OXP verifier for %@", _basePath);//_displayName);
301
302 [self registerBaseStages];
303 [self buildDependencyGraph];
304 [self runStages];
305
306 NoteVerificationStage(_displayName, @"");
307 OOLog(@"verifyOXP.done", @"%@", @"OXP verification complete.");
308
309 OpenLogFile(_displayName);
310}
static void SwitchLogFile(NSString *name)
static void NoteVerificationStage(NSString *displayName, NSString *stage)
static void OpenLogFile(NSString *name)
void setAllowCacheWrites:(BOOL flag)
OOCacheManager * sharedCache()
void setUseAddOns:(NSString *useAddOns)

◆ runStages

- (void) runStages

Extends class OOOXPVerifier.

Definition at line 727 of file OOOXPVerifier.m.

491{
492 NSAutoreleasePool *pool = nil;
493 NSEnumerator *stageEnum = nil;
494 OOOXPVerifierStage *candidateStage = nil,
495 *stageToRun = nil;
496 NSString *stageName = nil;
497
498 // Loop while there are still stages to run.
499 for (;;)
500 {
501 pool = [[NSAutoreleasePool alloc] init];
502
503 // Look through queue for a stage that's ready
504 stageToRun = nil;
505 for (stageEnum = [_waitingStages objectEnumerator]; (candidateStage = [stageEnum nextObject]); )
506 {
507 if ([candidateStage canRun])
508 {
509 stageToRun = candidateStage;
510 break;
511 }
512 }
513 if (stageToRun == nil)
514 {
515 // No more runnable stages
516 [pool release];
517 break;
518 }
519
520 stageName = nil;
522 @try
523 {
524 stageName = [stageToRun name];
525 if ([stageToRun shouldRun])
526 {
527 NoteVerificationStage(_displayName, stageName);
528 OOLog(@"verifyOXP.runStage", @"%@", stageName);
529 OOLogIndent();
530 [stageToRun performRun];
531 }
532 else
533 {
534 OOLog(@"verifyOXP.verbose.skipStage", @"- Skipping stage: %@ (nothing to do).", stageName);
535 [stageToRun noteSkipped];
536 }
537 }
538 @catch (NSException *exception)
539 {
540 if (stageName == nil) stageName = [[stageToRun class] description];
541 OOLog(@"verifyOXP.exception", @"***** Exception occurred when running OXP verifier stage \"%@\": %@: %@", stageName, [exception name], [exception reason]);
542 }
544
545 [_waitingStages removeObject:stageToRun];
546 [pool release];
547 }
548
549 pool = [[NSAutoreleasePool alloc] init];
550
551 if ([_waitingStages count] != 0)
552 {
553 OOLog(@"verifyOXP.incomplete", @"%@", @"Some verifier stages could not be run:");
554 OOLogIndent();
555 for (stageEnum = [_waitingStages objectEnumerator]; (candidateStage = [stageEnum nextObject]); )
556 {
557 OOLog(@"verifyOXP.incomplete.item", @"%@", candidateStage);
558 }
559 OOLogOutdent();
560 }
561 [_waitingStages release];
562 _waitingStages = nil;
563
564 [pool release];
565}
void OOLogPushIndent(void)
Definition OOLogging.m:316
void OOLogPopIndent(void)
Definition OOLogging.m:340
void OOLogOutdent(void)
Definition OOLogging.m:376
void OOLogIndent(void)
Definition OOLogging.m:366

◆ setUpDependencies:forStage:

- (BOOL) setUpDependencies: (NSSet *) dependencies
forStage: (OOOXPVerifierStage *) stage 

Extends class OOOXPVerifier.

Definition at line 727 of file OOOXPVerifier.m.

568 :(NSSet *)dependencies
569 forStage:(OOOXPVerifierStage *)stage
570{
571 NSString *depName = nil;
572 NSEnumerator *depEnum = nil;
573 OOOXPVerifierStage *depStage = nil;
574
575 // Iterate over dependencies, connecting them up.
576 for (depEnum = [dependencies objectEnumerator]; (depName = [depEnum nextObject]); )
577 {
578 depStage = [_stagesByName objectForKey:depName];
579 if (depStage == nil)
580 {
581 OOLog(@"verifyOXP.buildDependencyGraph.unresolved", @"Verifier stage %@ has unresolved dependency \"%@\", skipping.", stage, depName);
582 return NO;
583 }
584
585 if ([depStage isDependentOf:stage])
586 {
587 OOLog(@"verifyOXP.buildDependencyGraph.circularReference", @"Verifier stages %@ and %@ have a dependency loop, skipping.", stage, depStage);
588 [_stagesByName removeObjectForKey:depName];
589 return NO;
590 }
591
592 [stage registerDependency:depStage];
593 }
594
595 return YES;
596}

◆ setUpDependents:forStage:

- (void) setUpDependents: (NSSet *) dependents
forStage: (OOOXPVerifierStage *) stage 

Extends class OOOXPVerifier.

Definition at line 727 of file OOOXPVerifier.m.

599 :(NSSet *)dependents
600 forStage:(OOOXPVerifierStage *)stage
601{
602 NSString *depName = nil;
603 NSEnumerator *depEnum = nil;
604 OOOXPVerifierStage *depStage = nil;
605
606 // Iterate over dependents, connecting them up.
607 for (depEnum = [dependents objectEnumerator]; (depName = [depEnum nextObject]); )
608 {
609 depStage = [_stagesByName objectForKey:depName];
610 if (depStage == nil)
611 {
612 OOLog(@"verifyOXP.buildDependencyGraph.unresolved", @"Verifier stage %@ has unresolved dependent \"%@\".", stage, depName);
613 continue; // Unresolved/conflicting dependents are non-fatal
614 }
615
616 if ([stage isDependentOf:depStage])
617 {
618 OOLog(@"verifyOXP.buildDependencyGraph.circularReference", @"Verifier stage %@ lists %@ as both dependent and dependency (possibly indirectly); will execute %@ after %@.", stage, depStage, stage, depStage);
619 continue;
620 }
621
622 [depStage registerDependency:stage];
623 }
624}

◆ setUpLogOverrides

- (void) setUpLogOverrides

Extends class OOOXPVerifier.

Definition at line 727 of file OOOXPVerifier.m.

314{
315 NSDictionary *overrides = nil;
316 NSEnumerator *messageClassEnum = nil;
317 NSString *messageClass = nil;
318 id verbose = nil;
319
320 OOLogSetShowMessageClassTemporary([_verifierPList oo_boolForKey:@"logShowMessageClassOverride" defaultValue:NO]);
321
322 overrides = [_verifierPList oo_dictionaryForKey:@"logControlOverride"];
323 for (messageClassEnum = [overrides keyEnumerator]; (messageClass = [messageClassEnum nextObject]); )
324 {
325 OOLogSetDisplayMessagesInClass(messageClass, [overrides oo_boolForKey:messageClass defaultValue:NO]);
326 }
327
328 /* Since actually editing logControlOverride is a pain, we also allow
329 overriding verifyOXP.verbose through user defaults. This is at least
330 as much a pain under GNUstep, but very convenient under OS X.
331 */
332 verbose = [[NSUserDefaults standardUserDefaults] objectForKey:@"oxp-verifier-verbose-logging"];
333 if (verbose != nil) OOLogSetDisplayMessagesInClass(@"verifyOXP.verbose", OOBooleanFromObject(verbose, NO));
334}
BOOL OOBooleanFromObject(id object, BOOL defaultValue)
void OOLogSetDisplayMessagesInClass(NSString *inClass, BOOL inFlag)
Definition OOLogging.m:182
void OOLogSetShowMessageClassTemporary(BOOL flag)
Definition OOLogging.m:579

The documentation for this category was generated from the following file: