Skip to content

Commit c2146ff

Browse files
committed
Added note about Automatic Reference Counting (ARC) to README.md and some preprocessor-foo to JSONKit.m to check if JSONKit is being compiled with ARC / -fobjc-arc and #error if it is.
1 parent 4656c2d commit c2146ff

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

JSONKit.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ The code in isValidCodePoint() is derived from the ICU code in
124124
#import <Foundation/NSNull.h>
125125
#import <Foundation/NSObjCRuntime.h>
126126

127+
#ifndef __has_feature
128+
#define __has_feature(x) 0
129+
#endif
130+
127131
#ifdef JK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS
128132
#warning As of JSONKit v1.4, JK_ENABLE_CF_TRANSFER_OWNERSHIP_CALLBACKS is no longer required. It is no longer a valid option.
129133
#endif
@@ -132,6 +136,10 @@ The code in isValidCodePoint() is derived from the ICU code in
132136
#error JSONKit does not support Objective-C Garbage Collection
133137
#endif
134138

139+
#if __has_feature(objc_arc)
140+
#error JSONKit does not support Objective-C Automatic Reference Counting (ARC)
141+
#endif
142+
135143
// The following checks are really nothing more than sanity checks.
136144
// JSONKit technically has a few problems from a "strictly C99 conforming" standpoint, though they are of the pedantic nitpicking variety.
137145
// In practice, though, for the compilers and architectures we can reasonably expect this code to be compiled for, these pedantic nitpicks aren't really a problem.

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ The author requests that you do not file a bug report with JSONKit regarding pro
131131

132132
### Important Details
133133

134-
* JSONKit is not designed to be used with the Mac OS X Garbage Collection. The behavior of JSONKit when compiled with `-fobj-gc` is `undefined`. It is extremely unlikely that Mac OS X Garbage Collection will ever be supported.
134+
* JSONKit is not designed to be used with the Mac OS X Garbage Collection. The behavior of JSONKit when compiled with `-fobjc-gc` is `undefined`. It is extremely unlikely that Mac OS X Garbage Collection will ever be supported.
135+
136+
* JSONKit is not designed to be used with [Objective-C Automatic Reference Counting (ARC)][ARC]. The behavior of JSONKit when compiled with `-fobjc-arc` is `undefined`. The behavior of JSONKit compiled without [ARC][] mixed with code that has been compiled with [ARC][] is normatively `undefined` since at this time no analysis has been done to understand if this configuration is safe to use. At this time, there are no plans to support [ARC][] in JSONKit. Although tenative, it is extremely unlikely that [ARC][] will ever be supported, for many of the same reasons that Mac OS X Garbage Collection is not supported.
135137

136138
* The JSON to be parsed by JSONKit MUST be encoded as Unicode. In the unlikely event you end up with JSON that is not encoded as Unicode, you must first convert the JSON to Unicode, preferably as `UTF8`. One way to accomplish this is with the [`NSString`][NSString] methods [`-initWithBytes:length:encoding:`][NSString_initWithBytes] and [`-initWithData:encoding:`][NSString_initWithData].
137139

@@ -266,6 +268,7 @@ Example | Result | Argument
266268
[Single Precision]: http://en.wikipedia.org/wiki/Single_precision_floating-point_format
267269
[Double Precision]: http://en.wikipedia.org/wiki/Double_precision_floating-point_format
268270
[wiki_invariant]: http://en.wikipedia.org/wiki/Invariant_(computer_science)
271+
[ARC]: http://clang.llvm.org/docs/AutomaticReferenceCounting.html
269272
[CFBoolean]: http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFBooleanRef/index.html
270273
[kCFBooleanTrue]: http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFBooleanRef/Reference/reference.html#//apple_ref/doc/c_ref/kCFBooleanTrue
271274
[kCFBooleanFalse]: http://developer.apple.com/mac/library/documentation/CoreFoundation/Reference/CFBooleanRef/Reference/reference.html#//apple_ref/doc/c_ref/kCFBooleanFalse

0 commit comments

Comments
 (0)