An Objective-C wrapper for Mac OS X’s FSEvents C API.
リビジョン | 69a2adcaaffc073e4c8d9d51583dc042e3146351 (tree) |
---|---|
日時 | 2011-08-18 03:35:37 |
作者 | Aron Cedercrantz <aron@cede...> |
コミッター | Aron Cedercrantz |
Updated project for ARC.
@@ -71,8 +71,8 @@ typedef FSEventStreamEventFlags CDEventFlags; | ||
71 | 71 | @interface CDEvent : NSObject <NSCoding, NSCopying> { |
72 | 72 | @private |
73 | 73 | CDEventIdentifier _identifier; |
74 | - NSDate *_date; | |
75 | - NSURL *_URL; | |
74 | + NSDate *__weak _date; | |
75 | + NSURL *__weak _URL; | |
76 | 76 | CDEventFlags _flags; |
77 | 77 | } |
78 | 78 |
@@ -96,7 +96,7 @@ typedef FSEventStreamEventFlags CDEventFlags; | ||
96 | 96 | * |
97 | 97 | * @since 1.0.0 |
98 | 98 | */ |
99 | -@property (readonly) NSDate *date; | |
99 | +@property (weak, readonly) NSDate *date; | |
100 | 100 | |
101 | 101 | /** |
102 | 102 | * The URL of the item which changed. |
@@ -105,7 +105,7 @@ typedef FSEventStreamEventFlags CDEventFlags; | ||
105 | 105 | * |
106 | 106 | * @since 1.0.0 |
107 | 107 | */ |
108 | -@property (readonly) NSURL *URL; | |
108 | +@property (weak, readonly) NSURL *URL; | |
109 | 109 | |
110 | 110 | |
111 | 111 | /** @name Getting Event Flags */ |
@@ -44,22 +44,14 @@ | ||
44 | 44 | URL:(NSURL *)URL |
45 | 45 | flags:(CDEventFlags)flags |
46 | 46 | { |
47 | - return [[[CDEvent alloc] initWithIdentifier:identifier | |
47 | + return [[CDEvent alloc] initWithIdentifier:identifier | |
48 | 48 | date:date |
49 | 49 | URL:URL |
50 | - flags:flags] | |
51 | - autorelease]; | |
50 | + flags:flags]; | |
52 | 51 | } |
53 | 52 | |
54 | 53 | |
55 | 54 | #pragma mark Init/dealloc methods |
56 | -- (void)dealloc | |
57 | -{ | |
58 | - [_date release]; | |
59 | - [_URL release]; | |
60 | - | |
61 | - [super dealloc]; | |
62 | -} | |
63 | 55 | |
64 | 56 | - (id)initWithIdentifier:(NSUInteger)identifier |
65 | 57 | date:(NSDate *)date |
@@ -69,8 +61,8 @@ | ||
69 | 61 | if ((self = [super init])) { |
70 | 62 | _identifier = identifier; |
71 | 63 | _flags = flags; |
72 | - _date = [date retain]; | |
73 | - _URL = [URL retain]; | |
64 | + _date = date; | |
65 | + _URL = URL; | |
74 | 66 | } |
75 | 67 | |
76 | 68 | return self; |
@@ -101,7 +93,7 @@ | ||
101 | 93 | - (id)copyWithZone:(NSZone *)zone |
102 | 94 | { |
103 | 95 | // We can do this since we are immutable. |
104 | - return [self retain]; | |
96 | + return self; | |
105 | 97 | } |
106 | 98 | |
107 | 99 |
@@ -107,20 +107,20 @@ extern const CDEventIdentifier kCDEventsSinceEventNow; | ||
107 | 107 | */ |
108 | 108 | @interface CDEvents : NSObject <NSCopying> { |
109 | 109 | @private |
110 | - __weak id<CDEventsDelegate> _delegate; | |
110 | + //__weak id<CDEventsDelegate> _delegate; | |
111 | 111 | |
112 | 112 | FSEventStreamRef _eventStream; |
113 | - CFTimeInterval _notificationLatency; | |
113 | + //CFTimeInterval _notificationLatency; | |
114 | 114 | |
115 | - CDEventIdentifier _sinceEventIdentifier; | |
115 | + //CDEventIdentifier _sinceEventIdentifier; | |
116 | 116 | NSUInteger _eventStreamCreationFlags; |
117 | 117 | |
118 | - BOOL _ignoreEventsFromSubDirectories; | |
118 | + //BOOL _ignoreEventsFromSubDirectories; | |
119 | 119 | |
120 | - CDEvent *_lastEvent; | |
120 | + //CDEvent *_lastEvent; | |
121 | 121 | |
122 | - NSArray *_watchedURLs; | |
123 | - NSArray *_excludedURLs; | |
122 | + //NSArray *_watchedURLs; | |
123 | + //NSArray *_excludedURLs; | |
124 | 124 | } |
125 | 125 | |
126 | 126 | #pragma mark Properties |
@@ -135,7 +135,7 @@ extern const CDEventIdentifier kCDEventsSinceEventNow; | ||
135 | 135 | * |
136 | 136 | * @since 1.0.0 |
137 | 137 | */ |
138 | -@property (assign) __weak id<CDEventsDelegate> delegate; | |
138 | +@property (weak) id<CDEventsDelegate> delegate; | |
139 | 139 | |
140 | 140 | /** @name Getting Event Watcher Properties */ |
141 | 141 | /** |
@@ -163,7 +163,7 @@ extern const CDEventIdentifier kCDEventsSinceEventNow; | ||
163 | 163 | * |
164 | 164 | * @since 1.0.0 |
165 | 165 | */ |
166 | -@property (retain, readonly) CDEvent *lastEvent; | |
166 | +@property (strong, readonly) CDEvent *lastEvent; | |
167 | 167 | |
168 | 168 | /** |
169 | 169 | * The URLs that we watch for events. |
@@ -172,7 +172,7 @@ extern const CDEventIdentifier kCDEventsSinceEventNow; | ||
172 | 172 | * |
173 | 173 | * @since 1.0.0 |
174 | 174 | */ |
175 | -@property (readonly) NSArray *watchedURLs; | |
175 | +@property (strong, readonly) NSArray *watchedURLs; | |
176 | 176 | |
177 | 177 | |
178 | 178 | /** @name Configuring the Event watcher */ |
@@ -27,7 +27,8 @@ const CDEventIdentifier kCDEventsSinceEventNow = kFSEventStreamEventIdSinceNow; | ||
27 | 27 | // Private API |
28 | 28 | @interface CDEvents () |
29 | 29 | |
30 | -@property (retain, readwrite) CDEvent *lastEvent; | |
30 | +@property (strong, readwrite) CDEvent *lastEvent; | |
31 | +@property (strong, readwrite) NSArray *watchedURLs; | |
31 | 32 | |
32 | 33 | // The FSEvents callback function |
33 | 34 | static void CDEventsCallback( |
@@ -74,11 +75,7 @@ static void CDEventsCallback( | ||
74 | 75 | |
75 | 76 | _delegate = nil; |
76 | 77 | |
77 | - [_lastEvent release]; | |
78 | - [_watchedURLs release]; | |
79 | - [_excludedURLs release]; | |
80 | 78 | |
81 | - [super dealloc]; | |
82 | 79 | } |
83 | 80 | |
84 | 81 | - (void)finalize |
@@ -193,10 +190,10 @@ ignoreEventsFromSubDirs:(BOOL)ignoreEventsFromSubDirs | ||
193 | 190 | - (NSString *)streamDescription |
194 | 191 | { |
195 | 192 | CFStringRef streamDescriptionCF = FSEventStreamCopyDescription(_eventStream); |
196 | - NSString *returnString = [[NSString alloc] initWithString:(NSString *)streamDescriptionCF]; | |
193 | + NSString *returnString = [[NSString alloc] initWithString:(__bridge NSString *)streamDescriptionCF]; | |
197 | 194 | CFRelease(streamDescriptionCF); |
198 | 195 | |
199 | - return [returnString autorelease]; | |
196 | + return returnString; | |
200 | 197 | } |
201 | 198 | |
202 | 199 |
@@ -205,7 +202,7 @@ ignoreEventsFromSubDirs:(BOOL)ignoreEventsFromSubDirs | ||
205 | 202 | { |
206 | 203 | FSEventStreamContext callbackCtx; |
207 | 204 | callbackCtx.version = 0; |
208 | - callbackCtx.info = (void *)self; | |
205 | + callbackCtx.info = (__bridge void *)self; | |
209 | 206 | callbackCtx.retain = NULL; |
210 | 207 | callbackCtx.release = NULL; |
211 | 208 | callbackCtx.copyDescription = NULL; |
@@ -218,7 +215,7 @@ ignoreEventsFromSubDirs:(BOOL)ignoreEventsFromSubDirs | ||
218 | 215 | _eventStream = FSEventStreamCreate(kCFAllocatorDefault, |
219 | 216 | &CDEventsCallback, |
220 | 217 | &callbackCtx, |
221 | - (CFArrayRef)watchedPaths, | |
218 | + (__bridge CFArrayRef)watchedPaths, | |
222 | 219 | (FSEventStreamEventId)[self sinceEventIdentifier], |
223 | 220 | [self notificationLatency], |
224 | 221 | _eventStreamCreationFlags); |
@@ -244,11 +241,11 @@ static void CDEventsCallback( | ||
244 | 241 | const FSEventStreamEventFlags eventFlags[], |
245 | 242 | const FSEventStreamEventId eventIds[]) |
246 | 243 | { |
247 | - CDEvents *watcher = (CDEvents *)callbackCtxInfo; | |
244 | + CDEvents *watcher = (__bridge CDEvents *)callbackCtxInfo; | |
248 | 245 | |
249 | 246 | NSArray *watchedURLs = [watcher watchedURLs]; |
250 | 247 | NSArray *excludedURLs = [watcher excludedURLs]; |
251 | - NSArray *eventPathsArray = (NSArray *)eventPaths; | |
248 | + NSArray *eventPathsArray = (__bridge NSArray *)eventPaths; | |
252 | 249 | BOOL shouldIgnore = NO; |
253 | 250 | |
254 | 251 | for (NSUInteger i = 0; i < numEvents; ++i) { |
@@ -293,7 +290,6 @@ static void CDEventsCallback( | ||
293 | 290 | [watcher setLastEvent:event]; |
294 | 291 | } |
295 | 292 | |
296 | - [event release]; | |
297 | 293 | } |
298 | 294 | } |
299 | 295 |
@@ -321,13 +321,14 @@ | ||
321 | 321 | isa = XCBuildConfiguration; |
322 | 322 | buildSettings = { |
323 | 323 | ALWAYS_SEARCH_USER_PATHS = NO; |
324 | + CLANG_ENABLE_OBJC_ARC = YES; | |
324 | 325 | COPY_PHASE_STRIP = NO; |
325 | 326 | DYLIB_COMPATIBILITY_VERSION = 1; |
326 | 327 | DYLIB_CURRENT_VERSION = 1; |
327 | 328 | FRAMEWORK_VERSION = A; |
328 | 329 | GCC_DYNAMIC_NO_PIC = NO; |
329 | 330 | GCC_ENABLE_FIX_AND_CONTINUE = YES; |
330 | - GCC_ENABLE_OBJC_GC = supported; | |
331 | + GCC_ENABLE_OBJC_GC = unsupported; | |
331 | 332 | GCC_MODEL_TUNING = G5; |
332 | 333 | GCC_OPTIMIZATION_LEVEL = 0; |
333 | 334 | GCC_PRECOMPILE_PREFIX_HEADER = YES; |
@@ -344,11 +345,12 @@ | ||
344 | 345 | isa = XCBuildConfiguration; |
345 | 346 | buildSettings = { |
346 | 347 | ALWAYS_SEARCH_USER_PATHS = NO; |
348 | + CLANG_ENABLE_OBJC_ARC = YES; | |
347 | 349 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; |
348 | 350 | DYLIB_COMPATIBILITY_VERSION = 1; |
349 | 351 | DYLIB_CURRENT_VERSION = 1; |
350 | 352 | FRAMEWORK_VERSION = A; |
351 | - GCC_ENABLE_OBJC_GC = supported; | |
353 | + GCC_ENABLE_OBJC_GC = unsupported; | |
352 | 354 | GCC_MODEL_TUNING = G5; |
353 | 355 | GCC_PRECOMPILE_PREFIX_HEADER = YES; |
354 | 356 | GCC_PREFIX_HEADER = CDEvents_Prefix.pch; |
@@ -363,16 +365,13 @@ | ||
363 | 365 | 1DEB91B208733DA50010E9CD /* Debug */ = { |
364 | 366 | isa = XCBuildConfiguration; |
365 | 367 | buildSettings = { |
366 | - ARCHS = ( | |
367 | - x86_64, | |
368 | - i386, | |
369 | - ); | |
368 | + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; | |
370 | 369 | GCC_C_LANGUAGE_STANDARD = gnu99; |
371 | 370 | GCC_OPTIMIZATION_LEVEL = 0; |
372 | 371 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; |
373 | 372 | GCC_WARN_ABOUT_RETURN_TYPE = YES; |
374 | 373 | GCC_WARN_UNUSED_VARIABLE = YES; |
375 | - MACOSX_DEPLOYMENT_TARGET = 10.5; | |
374 | + MACOSX_DEPLOYMENT_TARGET = 10.7; | |
376 | 375 | ONLY_ACTIVE_ARCH = YES; |
377 | 376 | PREBINDING = NO; |
378 | 377 | RUN_CLANG_STATIC_ANALYZER = YES; |
@@ -383,15 +382,12 @@ | ||
383 | 382 | 1DEB91B308733DA50010E9CD /* Release */ = { |
384 | 383 | isa = XCBuildConfiguration; |
385 | 384 | buildSettings = { |
386 | - ARCHS = ( | |
387 | - x86_64, | |
388 | - i386, | |
389 | - ); | |
385 | + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; | |
390 | 386 | GCC_C_LANGUAGE_STANDARD = gnu99; |
391 | 387 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; |
392 | 388 | GCC_WARN_ABOUT_RETURN_TYPE = YES; |
393 | 389 | GCC_WARN_UNUSED_VARIABLE = YES; |
394 | - MACOSX_DEPLOYMENT_TARGET = 10.5; | |
390 | + MACOSX_DEPLOYMENT_TARGET = 10.7; | |
395 | 391 | PREBINDING = NO; |
396 | 392 | RUN_CLANG_STATIC_ANALYZER = YES; |
397 | 393 | SDKROOT = macosx; |