Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit 19e652a

Browse files
author
cdoucette
committed
Revert "Automatic translation to ARC for SBJson + SBJsonTests"
This reverts commit 02463ba.
1 parent 6d195db commit 19e652a

15 files changed

+66
-30
lines changed

Classes/NSObject+SBJson.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3434
@implementation NSObject (NSObject_SBJsonWriting)
3535

3636
- (NSString *)JSONRepresentation {
37-
SBJsonWriter *writer = [[SBJsonWriter alloc] init];
37+
SBJsonWriter *writer = [[[SBJsonWriter alloc] init] autorelease];
3838
NSString *json = [writer stringWithObject:self];
3939
if (!json)
4040
NSLog(@"-JSONRepresentation failed. Error is: %@", writer.error);
@@ -48,7 +48,7 @@ - (NSString *)JSONRepresentation {
4848
@implementation NSString (NSString_SBJsonParsing)
4949

5050
- (id)JSONValue {
51-
SBJsonParser *parser = [[SBJsonParser alloc] init];
51+
SBJsonParser *parser = [[[SBJsonParser alloc] init] autorelease];
5252
id repr = [parser objectWithString:self];
5353
if (!repr)
5454
NSLog(@"-JSONValue failed. Error is: %@", parser.error);

Classes/SBJsonParser.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ - (id)init {
4444
return self;
4545
}
4646

47+
- (void)dealloc {
48+
[error release];
49+
[super dealloc];
50+
}
4751

4852
#pragma mark Methods
4953

@@ -54,12 +58,12 @@ - (id)objectWithData:(NSData *)data {
5458
return nil;
5559
}
5660

57-
SBJsonStreamParserAccumulator *accumulator = [[SBJsonStreamParserAccumulator alloc] init];
61+
SBJsonStreamParserAccumulator *accumulator = [[[SBJsonStreamParserAccumulator alloc] init] autorelease];
5862

59-
SBJsonStreamParserAdapter *adapter = [[SBJsonStreamParserAdapter alloc] init];
63+
SBJsonStreamParserAdapter *adapter = [[[SBJsonStreamParserAdapter alloc] init] autorelease];
6064
adapter.delegate = accumulator;
6165

62-
SBJsonStreamParser *parser = [[SBJsonStreamParser alloc] init];
66+
SBJsonStreamParser *parser = [[[SBJsonStreamParser alloc] init] autorelease];
6367
parser.maxDepth = self.maxDepth;
6468
parser.delegate = adapter;
6569

Classes/SBJsonStreamParser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ typedef enum {
102102
SBJsonTokeniser *tokeniser;
103103
}
104104

105-
@property (nonatomic, unsafe_unretained) SBJsonStreamParserState *state; // Private
106-
@property (nonatomic, readonly, strong) NSMutableArray *stateStack; // Private
105+
@property (nonatomic, assign) SBJsonStreamParserState *state; // Private
106+
@property (nonatomic, readonly, retain) NSMutableArray *stateStack; // Private
107107

108108
/**
109109
@brief Expect multiple documents separated by whitespace
@@ -129,7 +129,7 @@ typedef enum {
129129
Usually this should be an instance of SBJsonStreamParserAdapter, but you can
130130
substitute your own implementation of the SBJsonStreamParserDelegate protocol if you need to.
131131
*/
132-
@property (unsafe_unretained) id<SBJsonStreamParserDelegate> delegate;
132+
@property (assign) id<SBJsonStreamParserDelegate> delegate;
133133

134134
/**
135135
@brief The max parse depth

Classes/SBJsonStreamParser.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ - (id)init {
5858
}
5959

6060
- (void)dealloc {
61+
self.error = nil;
6162
self.state = nil;
63+
[stateStack release];
64+
[tokeniser release];
65+
[super dealloc];
6266
}
6367

6468
#pragma mark Methods

Classes/SBJsonStreamParserAccumulator.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,19 @@ @implementation SBJsonStreamParserAccumulator
3333

3434
@synthesize value;
3535

36+
- (void)dealloc {
37+
[value release];
38+
[super dealloc];
39+
}
3640

3741
#pragma mark SBJsonStreamParserAdapterDelegate
3842

3943
- (void)parser:(SBJsonStreamParser*)parser foundArray:(NSArray *)array {
40-
value = array;
44+
value = [array retain];
4145
}
4246

4347
- (void)parser:(SBJsonStreamParser*)parser foundObject:(NSDictionary *)dict {
44-
value = dict;
48+
value = [dict retain];
4549
}
4650

4751
@end

Classes/SBJsonStreamParserAdapter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,6 @@ typedef enum {
143143
@brief Your delegate object
144144
Set this to the object you want to receive the SBJsonStreamParserAdapterDelegate messages.
145145
*/
146-
@property (unsafe_unretained) id<SBJsonStreamParserAdapterDelegate> delegate;
146+
@property (assign) id<SBJsonStreamParserAdapterDelegate> delegate;
147147

148148
@end

Classes/SBJsonStreamParserAdapter.m

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ - (id)init {
5959
return self;
6060
}
6161

62+
- (void)dealloc {
63+
[keyStack release];
64+
[stack release];
65+
[super dealloc];
66+
}
6267

6368
#pragma mark Private methods
6469

@@ -111,7 +116,7 @@ - (void)parser:(SBJsonStreamParser*)parser found:(id)obj {
111116

112117
- (void)parserFoundObjectStart:(SBJsonStreamParser*)parser {
113118
if (++depth > self.levelsToSkip) {
114-
dict = [NSMutableDictionary new];
119+
dict = [[NSMutableDictionary new] autorelease];
115120
[stack addObject:dict];
116121
currentType = SBJsonStreamParserAdapterObject;
117122
}
@@ -123,25 +128,27 @@ - (void)parser:(SBJsonStreamParser*)parser foundObjectKey:(NSString*)key_ {
123128

124129
- (void)parserFoundObjectEnd:(SBJsonStreamParser*)parser {
125130
if (depth-- > self.levelsToSkip) {
126-
id value = dict;
131+
id value = [dict retain];
127132
[self pop];
128133
[self parser:parser found:value];
134+
[value release];
129135
}
130136
}
131137

132138
- (void)parserFoundArrayStart:(SBJsonStreamParser*)parser {
133139
if (++depth > self.levelsToSkip) {
134-
array = [NSMutableArray new];
140+
array = [[NSMutableArray new] autorelease];
135141
[stack addObject:array];
136142
currentType = SBJsonStreamParserAdapterArray;
137143
}
138144
}
139145

140146
- (void)parserFoundArrayEnd:(SBJsonStreamParser*)parser {
141147
if (depth-- > self.levelsToSkip) {
142-
id value = array;
148+
id value = [array retain];
143149
[self pop];
144150
[self parser:parser found:value];
151+
[value release];
145152
}
146153
}
147154

Classes/SBJsonStreamWriter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@
8686
NSMutableDictionary *cache;
8787
}
8888

89-
@property (nonatomic, unsafe_unretained) SBJsonStreamWriterState *state; // Internal
90-
@property (nonatomic, readonly, strong) NSMutableArray *stateStack; // Internal
89+
@property (nonatomic, assign) SBJsonStreamWriterState *state; // Internal
90+
@property (nonatomic, readonly, retain) NSMutableArray *stateStack; // Internal
9191

9292
/**
9393
@brief delegate to receive JSON output
9494
Delegate that will receive messages with output.
9595
*/
96-
@property (unsafe_unretained) id<SBJsonStreamWriterDelegate> delegate;
96+
@property (assign) id<SBJsonStreamWriterDelegate> delegate;
9797

9898
/**
9999
@brief The maximum recursing depth.

Classes/SBJsonStreamWriter.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ - (id)init {
7373
}
7474

7575
- (void)dealloc {
76+
self.error = nil;
7677
self.state = nil;
78+
[stateStack release];
79+
[cache release];
80+
[super dealloc];
7781
}
7882

7983
#pragma mark Methods

Classes/SBJsonStreamWriterAccumulator.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ - (id)init {
4242
return self;
4343
}
4444

45+
- (void)dealloc {
46+
[data release];
47+
[super dealloc];
48+
}
4549

4650
#pragma mark SBJsonStreamWriterDelegate
4751

0 commit comments

Comments
 (0)