Skip to content

Commit

Permalink
tidy up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper Blues committed Jan 28, 2014
1 parent 5084a9e commit 11fca1b
Show file tree
Hide file tree
Showing 19 changed files with 2,879 additions and 2,882 deletions.
2 changes: 1 addition & 1 deletion .scripts/pod-update-checksum.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1418c8feb519e85f49704b9737d078ed9b42756d
ab35896de93cb629dfbb1af063a390e3b28a1d1a
48 changes: 24 additions & 24 deletions A-Typhoon.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@

#import <Foundation/Foundation.h>

@class TyphoonStackItem;
@class TyphoonStackElement;

@interface TyphoonResolutionStack : NSObject
@interface TyphoonCallStack : NSObject

+ (instancetype)stack;

- (void)push:(TyphoonStackItem*)stackItem;
- (void)push:(TyphoonStackElement*)stackItem;

- (TyphoonStackItem*)pop;
- (TyphoonStackElement*)pop;

- (TyphoonStackItem*)peek;
- (TyphoonStackElement*)peek;

- (TyphoonStackItem*)peekWithKey:(NSString*)key;
- (TyphoonStackElement*)peekForKey:(NSString*)key;

- (BOOL)isEmpty;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
////////////////////////////////////////////////////////////////////////////////


#import "TyphoonResolutionStack.h"
#import "TyphoonStackItem.h"
#import "TyphoonDefinition.h"
#import "TyphoonCallStack.h"
#import "TyphoonStackElement.h"

@implementation TyphoonResolutionStack
@implementation TyphoonCallStack
{
NSMutableArray* _storage;
}
Expand Down Expand Up @@ -45,16 +44,16 @@ - (id)init
/* ====================================================================================================================================== */
#pragma mark - Interface Methods

- (void)push:(TyphoonStackItem*)stackItem
- (void)push:(TyphoonStackElement*)stackItem
{
if (![stackItem isKindOfClass:[TyphoonStackItem class]])
if (![stackItem isKindOfClass:[TyphoonStackElement class]])
{
[NSException raise:NSInvalidArgumentException format:@"Not a TyphoonStackItem: %@", stackItem];
}
[_storage addObject:stackItem];
}

- (TyphoonStackItem*)pop
- (TyphoonStackElement*)pop
{
id element = [_storage lastObject];
if ([self isEmpty] == NO)
Expand All @@ -64,14 +63,14 @@ - (TyphoonStackItem*)pop
return element;
}

- (TyphoonStackItem*)peek
- (TyphoonStackElement*)peek
{
return [_storage lastObject];
}

- (TyphoonStackItem*)peekWithKey:(NSString*)key
- (TyphoonStackElement*)peekForKey:(NSString*)key
{
for (TyphoonStackItem* item in [_storage reverseObjectEnumerator])
for (TyphoonStackElement* item in [_storage reverseObjectEnumerator])
{
if ([item.key isEqualToString:key])
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
#import "TyphoonComponentFactoryAware.h"
#import "TyphoonParameterInjectedAsCollection.h"
#import "TyphoonComponentPostProcessor.h"
#import "TyphoonResolutionStack.h"
#import "TyphoonStackItem.h"
#import "TyphoonCallStack.h"
#import "TyphoonStackElement.h"
#import "NSObject+PropertyInjection.h"

#define AssertTypeDescriptionForPropertyOnInstance(type, property, instance) if (!type)[NSException raise:@"NSUnknownKeyException" \
Expand All @@ -56,10 +56,10 @@ @implementation TyphoonComponentFactory (InstanceBuilder)
- (id)buildInstanceWithDefinition:(TyphoonDefinition*)definition
{
__autoreleasing id <TyphoonIntrospectiveNSObject> instance = [self allocateInstance:instance withDefinition:definition];
[_currentlyResolvingReferences push:[TyphoonStackItem itemWithKey:definition.key instance:instance]];
[_stack push:[TyphoonStackElement itemWithKey:definition.key instance:instance]];
instance = [self injectInstance:instance withDefinition:definition];
instance = [self postProcessInstance:instance];
[_currentlyResolvingReferences pop];
[_stack pop];
return instance;
}

Expand Down Expand Up @@ -91,7 +91,9 @@ - (id)allocateInstance:(id)instance withDefinition:(TyphoonDefinition*)definitio
- (id)injectInstance:(id)instance withDefinition:(TyphoonDefinition*)definition
{
instance = [self initializerInjectionOn:instance withDefinition:definition];
[_stack push:[TyphoonStackElement itemWithKey:definition.key instance:instance]];
[self injectPropertyDependenciesOn:instance withDefinition:definition];
[_stack pop];
return instance;
}

Expand Down Expand Up @@ -151,15 +153,15 @@ - (id)buildSharedInstanceForDefinition:(TyphoonDefinition*)definition
{
if ([self alreadyResolvingKey:definition.key])
{
return [_currentlyResolvingReferences peekWithKey:definition.key].instance;
return [_stack peekForKey:definition.key].instance;
}
return [self buildInstanceWithDefinition:definition];
}


- (BOOL)alreadyResolvingKey:(NSString*)key
{
return [_currentlyResolvingReferences peekWithKey:key] != nil;
return [_stack peekForKey:key] != nil;
}

/* ====================================================================================================================================== */
Expand Down Expand Up @@ -283,7 +285,7 @@ - (void)injectCircularDependenciesOn:(__autoreleasing id <TyphoonIntrospectiveNS
if (!propertyValue)
{
NSString* componentKey = [circularDependentProperties objectForKey:propertyName];
id reference = [_currentlyResolvingReferences peekWithKey:componentKey].instance;
id reference = [_stack peekForKey:componentKey].instance;
[(NSObject*)instance setValue:reference forKey:propertyName];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@class TyphoonDefinition;


@interface TyphoonStackItem : NSObject
@interface TyphoonStackElement : NSObject

@property(nonatomic, strong, readonly) NSString* key;
@property(nonatomic, strong, readonly) id instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@



#import "TyphoonStackItem.h"
#import "TyphoonStackElement.h"


@implementation TyphoonStackItem
@implementation TyphoonStackElement

+ (instancetype)itemWithKey:(NSString*)key instance:(id)instance;
{
Expand Down
4 changes: 2 additions & 2 deletions Source/Factory/TyphoonComponentFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#import "TyphoonComponentFactoryPostProcessor.h"

@class TyphoonDefinition;
@class TyphoonResolutionStack;
@class TyphoonCallStack;

/**
*
Expand All @@ -31,7 +31,7 @@
NSMutableDictionary* _singletons;
NSMutableDictionary* _objectGraphSharedInstances;

TyphoonResolutionStack* _currentlyResolvingReferences;
TyphoonCallStack* _stack;
NSMutableArray* _postProcessors;
NSMutableArray* _componentPostProcessors;
BOOL _isLoading;
Expand Down
6 changes: 3 additions & 3 deletions Source/Factory/TyphoonComponentFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#import "TyphoonDefinitionRegisterer.h"
#import "TyphoonComponentFactory+TyphoonDefinitionRegisterer.h"
#import "TyphoonOrdered.h"
#import "TyphoonResolutionStack.h"
#import "TyphoonCallStack.h"
#import "TyphoonParentReferenceHydratingPostProcessor.h"

@interface TyphoonDefinition (TyphoonComponentFactory)
Expand Down Expand Up @@ -51,7 +51,7 @@ - (id)init
_registry = [[NSMutableArray alloc] init];
_singletons = [[NSMutableDictionary alloc] init];
_objectGraphSharedInstances = [[NSMutableDictionary alloc] init];
_currentlyResolvingReferences = [TyphoonResolutionStack stack];
_stack = [TyphoonCallStack stack];
_postProcessors = [[NSMutableArray alloc] init];
_componentPostProcessors = [[NSMutableArray alloc] init];
[self attachPostProcessor:[[TyphoonParentReferenceHydratingPostProcessor alloc] init]];
Expand Down Expand Up @@ -326,7 +326,7 @@ - (id)objectForDefinition:(TyphoonDefinition*)definition
break;
}

if ([_currentlyResolvingReferences isEmpty])
if ([_stack isEmpty])
{
[_objectGraphSharedInstances removeAllObjects];
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PODS:
- OCHamcrest (1.9)
- OCMockito (0.23):
- OCHamcrest
- Typhoon (1.6.8)
- Typhoon (1.7.1)

DEPENDENCIES:
- OCHamcrest (~> 1.9)
Expand All @@ -16,6 +16,6 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
OCHamcrest: f8393efd5a49d91879be573635d6183effacc0ab
OCMockito: 01560fd24319b85c223e10f52e2e41fbe2c6d434
Typhoon: 2f8b610f00eab8a447134f60ec2dc3b35eb8c1b2
Typhoon: 8399a53456a7776d5212f2a4335976e62975cab0

COCOAPODS: 0.29.0
1 change: 0 additions & 1 deletion Tests/Pods/BuildHeaders/Typhoon/TyphoonResolutionStack.h

This file was deleted.

1 change: 0 additions & 1 deletion Tests/Pods/BuildHeaders/Typhoon/TyphoonStackItem.h

This file was deleted.

1 change: 0 additions & 1 deletion Tests/Pods/Headers/Typhoon/TyphoonResolutionStack.h

This file was deleted.

1 change: 0 additions & 1 deletion Tests/Pods/Headers/Typhoon/TyphoonStackItem.h

This file was deleted.

4 changes: 2 additions & 2 deletions Tests/Pods/Local Podspecs/Typhoon.podspec

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Tests/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Tests/Pods/Pods-OS X Tests (Cocoapods)-environment.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Tests/Pods/Pods-iOS Tests (Cocoapods)-environment.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 11fca1b

Please sign in to comment.