forked from keysight-eggplant/libs-xcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GSXCBuildContext.m
72 lines (61 loc) · 1.44 KB
/
GSXCBuildContext.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#import "GSXCBuildContext.h"
id _sharedBuildContext = nil;
@implementation GSXCBuildContext
+ (id) sharedBuildContext
{
if(_sharedBuildContext == nil)
{
_sharedBuildContext = [[GSXCBuildContext alloc] init];
}
return _sharedBuildContext;
}
- (id) init
{
if((self = [super init]) != nil)
{
stack = [[NSMutableArray alloc] initWithCapacity: 10];
contextDictionary = [[NSMutableDictionary alloc] init];
}
return self;
}
- (void) dealloc
{
[stack release];
[contextDictionary release];
[super dealloc];
}
- (NSMutableDictionary *) currentContext
{
return currentContext;
}
- (NSMutableDictionary *) contextDictionaryForName: (NSString *)name
{
currentContext = [contextDictionary objectForKey: name];
if(currentContext == nil)
{
currentContext = [NSMutableDictionary dictionary];
[contextDictionary setObject: currentContext forKey: name];
[stack addObject: currentContext];
}
return currentContext;
}
- (NSMutableDictionary *) popCurrentContext
{
NSMutableDictionary *popped = [stack lastObject];
[stack removeLastObject];
currentContext = [stack lastObject];
return popped;
}
- (void) setObject: (id)object forKey: (id)key
{
[currentContext setObject: object forKey: key];
}
- (id) objectForKey: (id)key
{
return [currentContext objectForKey: key];
}
- (void) addEntriesFromDictionary: (NSDictionary *)dict;
{
[currentContext addEntriesFromDictionary: dict];
}
@end