From 26cc95c84119ac21a395c197904f62237e48a1be Mon Sep 17 00:00:00 2001 From: Dmitry Lobanov Date: Thu, 3 Nov 2022 17:18:51 +0300 Subject: [PATCH] Refactoring. MRC removal. Part two. (#857) * kit: interface node mrc has been removed. * kit: core repository reflog mrc has been removed. * kit: core snapshot mrc has been removed. * kit: interface graph view mrc has been removed. * kit: macos target has been updated. --- GitUpKit/Core/GCRepository+Reflog.m | 39 ++++--------- GitUpKit/Core/GCSnapshot.m | 55 +++++++----------- GitUpKit/GitUpKit.xcodeproj/project.pbxproj | 8 +-- GitUpKit/Interface/GIGraphView.m | 63 +++++++++------------ GitUpKit/Interface/GINode.m | 23 +++----- 5 files changed, 72 insertions(+), 116 deletions(-) diff --git a/GitUpKit/Core/GCRepository+Reflog.m b/GitUpKit/Core/GCRepository+Reflog.m index 0505df97..a8c1e8c0 100644 --- a/GitUpKit/Core/GCRepository+Reflog.m +++ b/GitUpKit/Core/GCRepository+Reflog.m @@ -13,10 +13,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#if __has_feature(objc_arc) -#error This file requires MRC -#endif - #import "GCPrivate.h" @implementation GCReflogEntry { @@ -44,12 +40,12 @@ - (id)initWithRepository:(GCRepository*)repository entry:(const git_reflog_entry git_oid_cpy(&_fromOID, git_reflog_entry_id_old(entry)); if (!git_oid_iszero(&_fromOID)) { - _fromSHA1 = [GCGitOIDToSHA1(&_fromOID) retain]; + _fromSHA1 = [GCGitOIDToSHA1(&_fromOID) copy]; _fromCommit = _LoadCommit(_repository, &_fromOID); } git_oid_cpy(&_toOID, git_reflog_entry_id_new(entry)); if (!git_oid_iszero(&_toOID)) { - _toSHA1 = [GCGitOIDToSHA1(&_toOID) retain]; + _toSHA1 = [GCGitOIDToSHA1(&_toOID) copy]; _toCommit = _LoadCommit(_repository, &_toOID); } else { XLOG_DEBUG_UNREACHABLE(); @@ -65,20 +61,6 @@ - (id)initWithRepository:(GCRepository*)repository entry:(const git_reflog_entry return self; } -- (void)dealloc { - [_fromSHA1 release]; - [_fromCommit release]; - [_toSHA1 release]; - [_toCommit release]; - [_committerName release]; - [_committerEmail release]; - - [_references release]; - [_messages release]; - - [super dealloc]; -} - - (const git_oid*)fromOID { return &_fromOID; } @@ -198,13 +180,13 @@ static inline BOOL _EqualEntries(GCReflogEntry* entry1, GCReflogEntry* entry2) { } static Boolean _EntryEqualCallBack(const void* value1, const void* value2) { - GCReflogEntry* entry1 = (GCReflogEntry*)value1; - GCReflogEntry* entry2 = (GCReflogEntry*)value2; + GCReflogEntry* entry1 = (__bridge GCReflogEntry*)value1; + GCReflogEntry* entry2 = (__bridge GCReflogEntry*)value2; return _EqualEntries(entry1, entry2); } static CFHashCode _EntryHashCallBack(const void* value) { - GCReflogEntry* entry = (GCReflogEntry*)value; + GCReflogEntry* entry = (__bridge GCReflogEntry*)value; return *((CFHashCode*)&entry->_fromOID); } @@ -238,13 +220,12 @@ - (NSArray*)loadReflogEntriesForReference:(GCReference*)reference error:(NSError GCReflogEntry* reflogEntry = [[GCReflogEntry alloc] initWithRepository:self entry:entry]; [reflogEntry addReference:reference withMessage:git_reflog_entry_message(entry)]; [entries addObject:reflogEntry]; - [reflogEntry release]; } } git_reflog_free(reflog); [entries sortUsingSelector:@selector(reverseTimeCompare:)]; } - return [entries autorelease]; + return entries; } - (NSArray*)loadAllReflogEntries:(NSError**)error { @@ -283,11 +264,11 @@ - (NSArray*)loadAllReflogEntries:(NSError**)error { [entries addObject:reflogEntry]; CFSetAddValue(cache, (const void*)reflogEntry); } - [reflogEntry release]; + reflogEntry = nil; } } - [reference release]; + reference = nil; git_reflog_free(reflog); } else { git_reference_free(rawReference); @@ -296,11 +277,11 @@ - (NSArray*)loadAllReflogEntries:(NSError**)error { }]; CFRelease(cache); if (!success) { - [entries release]; + entries = nil; return nil; } [entries sortUsingSelector:@selector(reverseTimeCompare:)]; - return [entries autorelease]; + return entries; } @end diff --git a/GitUpKit/Core/GCSnapshot.m b/GitUpKit/Core/GCSnapshot.m index 694c9d80..394fcacd 100644 --- a/GitUpKit/Core/GCSnapshot.m +++ b/GitUpKit/Core/GCSnapshot.m @@ -13,10 +13,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#if __has_feature(objc_arc) -#error This file requires MRC -#endif - #import "GCPrivate.h" // SPIs from libgit2 @@ -89,7 +85,7 @@ + (BOOL)supportsSecureCoding { - (id)initWithReference:(git_reference*)reference resolvedObject:(git_object*)object { if ((self = [super init])) { - _name = [_NSDataFromCString(git_reference_name(reference)) retain]; + _name = [_NSDataFromCString(git_reference_name(reference)) copy]; _type = git_reference_type(reference); switch (_type) { case GIT_REF_OID: { @@ -99,14 +95,13 @@ - (id)initWithReference:(git_reference*)reference resolvedObject:(git_object*)ob } case GIT_REF_SYMBOLIC: { - _symbol = [_NSDataFromCString(git_reference_symbolic_target(reference)) retain]; + _symbol = [_NSDataFromCString(git_reference_symbolic_target(reference)) copy]; XLOG_DEBUG_CHECK(_symbol.length); break; } default: { XLOG_DEBUG_UNREACHABLE(); - [self release]; return nil; } } @@ -123,10 +118,8 @@ - (id)initWithReference:(git_reference*)reference resolvedObject:(git_object*)ob } - (void)dealloc { - [_symbol release]; - [_name release]; - - [super dealloc]; + _symbol = nil; + _name = nil; } - (void)encodeWithCoder:(NSCoder*)coder { @@ -140,7 +133,7 @@ - (void)encodeWithCoder:(NSCoder*)coder { - (id)initWithCoder:(NSCoder*)decoder { if ((self = [super init])) { - _name = [[decoder decodeObjectOfClass:[NSData class] forKey:@"name"] retain]; + _name = [[decoder decodeObjectOfClass:[NSData class] forKey:@"name"] copy]; XLOG_DEBUG_CHECK(_name); _type = [decoder decodeIntForKey:@"type"]; XLOG_DEBUG_CHECK((_type == GIT_REF_OID) || (_type == GIT_REF_SYMBOLIC)); @@ -153,7 +146,7 @@ - (id)initWithCoder:(NSCoder*)decoder { XLOG_DEBUG_UNREACHABLE(); } - _symbol = [[decoder decodeObjectOfClass:[NSData class] forKey:@"symbol"] retain]; + _symbol = [[decoder decodeObjectOfClass:[NSData class] forKey:@"symbol"] copy]; _resolvedType = [decoder decodeIntForKey:@"resolved_type"]; @@ -268,7 +261,7 @@ + (BOOL)supportsSecureCoding { - (id)initWithRepository:(GCRepository*)repository error:(NSError**)error { if ((self = [super init])) { // Capture local config - _config = [_LoadRepositoryConfig(repository, error) retain]; + _config = _LoadRepositoryConfig(repository, error); if (_config == nil) { return nil; } @@ -292,8 +285,7 @@ - (id)initWithRepository:(GCRepository*)repository error:(NSError**)error { GCSerializedReference* serializedReference = [[GCSerializedReference alloc] initWithReference:reference resolvedObject:object]; [_serializedReferences addObject:serializedReference]; XLOG_DEBUG_CHECK(!CFDictionaryContainsKey(_cache, serializedReference.name)); - CFDictionarySetValue(_cache, serializedReference.name, serializedReference); - [serializedReference release]; + CFDictionarySetValue(_cache, serializedReference.name, (__bridge const void *)(serializedReference)); git_object_free(object); return YES; @@ -309,11 +301,9 @@ - (id)initWithRepository:(GCRepository*)repository error:(NSError**)error { - (void)dealloc { CFRelease(_cache); - [_info release]; - [_serializedReferences release]; - [_config release]; - - [super dealloc]; + _info = nil; + _serializedReferences = nil; + _config = nil; } - (void)encodeWithCoder:(NSCoder*)coder { @@ -324,18 +314,18 @@ - (void)encodeWithCoder:(NSCoder*)coder { - (id)initWithCoder:(NSCoder*)decoder { if ((self = [super init])) { - _config = [[decoder decodeObjectOfClass:[NSMutableDictionary class] forKey:@"config"] retain]; + _config = [decoder decodeObjectOfClass:[NSMutableDictionary class] forKey:@"config"]; XLOG_DEBUG_CHECK(_config); - _serializedReferences = [[decoder decodeObjectOfClass:[NSMutableArray class] forKey:@"serialized_references"] retain]; + _serializedReferences = [decoder decodeObjectOfClass:[NSMutableArray class] forKey:@"serialized_references"]; XLOG_DEBUG_CHECK(_serializedReferences); - _info = [[decoder decodeObjectOfClass:[NSMutableDictionary class] forKey:@"info"] retain]; + _info = [decoder decodeObjectOfClass:[NSMutableDictionary class] forKey:@"info"]; XLOG_DEBUG_CHECK(_info); CFDictionaryKeyCallBacks callbacks = {0, NULL, NULL, NULL, GCCStringEqualCallBack, GCCStringHashCallBack}; _cache = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &callbacks, NULL); for (GCSerializedReference* serializedReference in _serializedReferences) { XLOG_DEBUG_CHECK(!CFDictionaryContainsKey(_cache, serializedReference.name)); - CFDictionarySetValue(_cache, serializedReference.name, serializedReference); + CFDictionarySetValue(_cache, serializedReference.name, (__bridge const void *)(serializedReference)); } } return self; @@ -350,7 +340,7 @@ - (NSString*)description { for (GCSerializedReference* serializedReference in _serializedReferences) { [description appendFormat:@"\n %s = %s", serializedReference.name, serializedReference.symbolicTarget ? serializedReference.symbolicTarget : git_oid_tostr_s(serializedReference.directTarget)]; } - return [description autorelease]; + return description; } @end @@ -469,7 +459,7 @@ - (BOOL)isEqual:(id)object { @implementation GCRepository (GCSnapshot) - (GCSnapshot*)takeSnapshot:(NSError**)error { - return [[[GCSnapshot alloc] initWithRepository:self error:error] autorelease]; + return [[GCSnapshot alloc] initWithRepository:self error:error]; } static BOOL _UpdateRepositoryConfig(GCRepository* repository, NSDictionary* changes, NSError** error) { @@ -524,8 +514,6 @@ static void _DiffConfigsForLocalBranch(const char* name, NSDictionary* fromConfi [changes setObject:copy[toVariable] forKey:toVariable]; } } - - [copy release]; } - (BOOL)_restoreFromReferences:(NSArray*)fromReferences @@ -579,7 +567,7 @@ - (BOOL)_restoreFromReferences:(NSArray*)fromReferences // Finally recreate references present in "to" but missing in "from" GCDictionaryApplyBlock(copy, ^(const void* key, const void* value) { - GCSerializedReference* toSerializedReference = (const void*)value; + GCSerializedReference* toSerializedReference = (__bridge GCSerializedReference *)value; if (!_ShouldSkipReference(toSerializedReference.name, options)) { switch (toSerializedReference.type) { case GIT_REF_OID: @@ -623,9 +611,9 @@ - (BOOL)_restoreFromReferences:(NSArray*)fromReferences success = YES; cleanup: - [changes release]; + changes = nil; CFRelease(copy); - [transform release]; + transform = nil; return success; } @@ -644,13 +632,12 @@ - (BOOL)restoreSnapshot:(GCSnapshot*)snapshot usingBlock:^BOOL(git_reference* reference) { GCSerializedReference* serializedReference = [[GCSerializedReference alloc] initWithReference:reference resolvedObject:NULL]; [references addObject:serializedReference]; - [serializedReference release]; return YES; }]; if (result) { result = [self _restoreFromReferences:references andConfig:config toSnapshot:snapshot withOptions:options reflogMessage:message didUpdateReferences:didUpdateReferences error:error]; } - [references release]; + references = nil; return result; } diff --git a/GitUpKit/GitUpKit.xcodeproj/project.pbxproj b/GitUpKit/GitUpKit.xcodeproj/project.pbxproj index 3e6ef953..4dec92ca 100644 --- a/GitUpKit/GitUpKit.xcodeproj/project.pbxproj +++ b/GitUpKit/GitUpKit.xcodeproj/project.pbxproj @@ -180,10 +180,10 @@ E267E1E21B84D83100BAB377 /* GCRepository+Config.m in Sources */ = {isa = PBXBuildFile; fileRef = E24508FF1A9A50EA003E602D /* GCRepository+Config.m */; }; E267E1E31B84D83100BAB377 /* GCRepository+HEAD.m in Sources */ = {isa = PBXBuildFile; fileRef = E27F9B731A549097009C9B3D /* GCRepository+HEAD.m */; }; E267E1E41B84D83100BAB377 /* GCRepository+Mock.m in Sources */ = {isa = PBXBuildFile; fileRef = E299D0121A749C26005035F7 /* GCRepository+Mock.m */; }; - E267E1E51B84D83100BAB377 /* GCRepository+Reflog.m in Sources */ = {isa = PBXBuildFile; fileRef = E27B6D651A84451900D05452 /* GCRepository+Reflog.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + E267E1E51B84D83100BAB377 /* GCRepository+Reflog.m in Sources */ = {isa = PBXBuildFile; fileRef = E27B6D651A84451900D05452 /* GCRepository+Reflog.m */; }; E267E1E61B84D83100BAB377 /* GCRepository+Reset.m in Sources */ = {isa = PBXBuildFile; fileRef = E20EB08A19FC75CA0031A075 /* GCRepository+Reset.m */; }; E267E1E71B84D83100BAB377 /* GCRepository+Status.m in Sources */ = {isa = PBXBuildFile; fileRef = E20EB08E19FC76160031A075 /* GCRepository+Status.m */; }; - E267E1E81B84D83100BAB377 /* GCSnapshot.m in Sources */ = {isa = PBXBuildFile; fileRef = E2F5C27D1A8171C900C30739 /* GCSnapshot.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + E267E1E81B84D83100BAB377 /* GCSnapshot.m in Sources */ = {isa = PBXBuildFile; fileRef = E2F5C27D1A8171C900C30739 /* GCSnapshot.m */; }; E267E1E91B84D83100BAB377 /* GCSQLiteRepository.m in Sources */ = {isa = PBXBuildFile; fileRef = E299D00A1A71F0E9005035F7 /* GCSQLiteRepository.m */; }; E267E1EA1B84D83100BAB377 /* GCStash.m in Sources */ = {isa = PBXBuildFile; fileRef = E2C338E719F85C8600063D95 /* GCStash.m */; }; E267E1EB1B84D83100BAB377 /* GCSubmodule.m in Sources */ = {isa = PBXBuildFile; fileRef = E21739FD1A51FA6200EC6777 /* GCSubmodule.m */; }; @@ -210,10 +210,10 @@ E267E2161B84DB6E00BAB377 /* GIDiffView.m in Sources */ = {isa = PBXBuildFile; fileRef = E2891AB51AE1684A00E58C77 /* GIDiffView.m */; }; E267E2171B84DB6E00BAB377 /* GIFunctions.m in Sources */ = {isa = PBXBuildFile; fileRef = E2B1BF321A85923800A999DF /* GIFunctions.m */; }; E267E2181B84DB6E00BAB377 /* GIGraph.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEA11A4D562300B6AF66 /* GIGraph.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; - E267E2191B84DB6E00BAB377 /* GIGraphView.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEA31A4D562300B6AF66 /* GIGraphView.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + E267E2191B84DB6E00BAB377 /* GIGraphView.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEA31A4D562300B6AF66 /* GIGraphView.m */; }; E267E21A1B84DB6E00BAB377 /* GILayer.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEB11A4D599200B6AF66 /* GILayer.m */; }; E267E21B1B84DB6E00BAB377 /* GILine.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEAB1A4D587800B6AF66 /* GILine.m */; }; - E267E21C1B84DB6E00BAB377 /* GINode.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEA71A4D57AA00B6AF66 /* GINode.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + E267E21C1B84DB6E00BAB377 /* GINode.m in Sources */ = {isa = PBXBuildFile; fileRef = E2D4DEA71A4D57AA00B6AF66 /* GINode.m */; }; E267E21D1B84DB6E00BAB377 /* GIPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = E21A88F21A9471B300255AC3 /* GIPrivate.m */; }; E267E21E1B84DB6E00BAB377 /* GISplitDiffView.m in Sources */ = {isa = PBXBuildFile; fileRef = E2891AB21AE15BB600E58C77 /* GISplitDiffView.m */; }; E267E21F1B84DB6E00BAB377 /* GIUnifiedDiffView.m in Sources */ = {isa = PBXBuildFile; fileRef = E2C9FF871AA510170051B2AE /* GIUnifiedDiffView.m */; }; diff --git a/GitUpKit/Interface/GIGraphView.m b/GitUpKit/Interface/GIGraphView.m index 3bce3610..3a83cc49 100644 --- a/GitUpKit/Interface/GIGraphView.m +++ b/GitUpKit/Interface/GIGraphView.m @@ -13,10 +13,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#if __has_feature(objc_arc) -#error This file requires MRC -#endif - #import #import "GIPrivate.h" @@ -122,10 +118,8 @@ - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResignKeyNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidBecomeKeyNotification object:nil]; - [_graph release]; - [_dateFormatter release]; - - [super dealloc]; + _graph = nil; + _dateFormatter = nil; } #pragma mark - Subclassing @@ -204,8 +198,7 @@ - (void)_updateView { - (void)setGraph:(GIGraph*)graph { if (graph != _graph) { _selectedNode = nil; - [_graph autorelease]; - _graph = [graph retain]; + _graph = graph; [self _updateView]; @@ -902,7 +895,7 @@ - (void)drawLine:(GILine*)line inContext:(CGContextRef)context clampedToRect:(CG if (recompute) { data = [[NSData alloc] initWithBytesNoCopy:pointList length:(pointCount * sizeof(CGPoint)) freeWhenDone:YES]; objc_setAssociatedObject(line, _associatedObjectDataKey, data, OBJC_ASSOCIATION_RETAIN_NONATOMIC); - [data release]; + data = nil; } } @@ -913,13 +906,13 @@ static void _DrawBranchTitle(CGContextRef context, CGFloat x, CGFloat y, CGPoint multilineTitleAttributes = [[NSMutableDictionary alloc] init]; CTFontRef titleFont = CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, 13.0, CFSTR("en-US")); - multilineTitleAttributes[NSFontAttributeName] = (id)titleFont; + multilineTitleAttributes[NSFontAttributeName] = (__bridge id)titleFont; CFRelease(titleFont); NSMutableParagraphStyle* style = [[NSMutableParagraphStyle alloc] init]; style.lineHeightMultiple = 0.85; multilineTitleAttributes[NSParagraphStyleAttributeName] = style; - [style release]; + style = nil; } multilineTitleAttributes[NSForegroundColorAttributeName] = [color shadowWithLevel:0.2]; // Cache bold font and calculate darker color for building multiline string @@ -936,49 +929,49 @@ static void _DrawBranchTitle(CGContextRef context, CGFloat x, CGFloat y, CGPoint for (GCHistoryLocalBranch* localBranch in branch.localBranches) { NSString* branchName = localBranch.name; NSRange branchNameRange = NSMakeRange(multilineTitle.length, branchName.length); - _AppendAttributedString((CFMutableAttributedStringRef)multilineTitle, [NSString stringWithFormat:@"%@\n", branchName], multilineTitleAttributes); - [multilineTitle addAttribute:NSFontAttributeName value:(id)boldFont range:branchNameRange]; + _AppendAttributedString((__bridge CFMutableAttributedStringRef)multilineTitle, [NSString stringWithFormat:@"%@\n", branchName], multilineTitleAttributes); + [multilineTitle addAttribute:NSFontAttributeName value:(__bridge id)boldFont range:branchNameRange]; [multilineTitle addAttribute:NSForegroundColorAttributeName value:darkColor range:branchNameRange]; GCBranch* upstream = localBranch.upstream; if (upstream) { - _AppendAttributedString((CFMutableAttributedStringRef)multilineTitle, [NSString stringWithFormat:@"⬅ %@\n", upstream.name], multilineTitleAttributes); + _AppendAttributedString((__bridge CFMutableAttributedStringRef)multilineTitle, [NSString stringWithFormat:@"⬅ %@\n", upstream.name], multilineTitleAttributes); NSString* upstreamName = [upstream isKindOfClass:GCRemoteBranch.class] ? [(GCRemoteBranch*)upstream branchName] : upstream.name; NSRange upstreamNameRange = NSMakeRange(multilineTitle.length - upstreamName.length - 1, upstreamName.length); // -1 to exclude '\n' [multilineTitle addAttribute:NSForegroundColorAttributeName value:darkColor range:upstreamNameRange]; } - _AppendAttributedString((CFMutableAttributedStringRef)multilineTitle, @"\n", nil); + _AppendAttributedString((__bridge CFMutableAttributedStringRef)multilineTitle, @"\n", nil); } for (GCHistoryRemoteBranch* remoteBranch in branch.remoteBranches) { NSString* branchName = remoteBranch.branchName; - _AppendAttributedString((CFMutableAttributedStringRef)multilineTitle, [NSString stringWithFormat:@"%@\n", remoteBranch.name], multilineTitleAttributes); + _AppendAttributedString((__bridge CFMutableAttributedStringRef)multilineTitle, [NSString stringWithFormat:@"%@\n", remoteBranch.name], multilineTitleAttributes); NSRange branchNameRange = NSMakeRange(multilineTitle.length - branchName.length - 1, branchName.length); // -1 to exclude '\n' - [multilineTitle addAttribute:NSFontAttributeName value:(id)boldFont range:branchNameRange]; + [multilineTitle addAttribute:NSFontAttributeName value:(__bridge id)boldFont range:branchNameRange]; [multilineTitle addAttribute:NSForegroundColorAttributeName value:darkColor range:branchNameRange]; } if (branch.remoteBranches.count) { - _AppendAttributedString((CFMutableAttributedStringRef)multilineTitle, @"\n", nil); + _AppendAttributedString((__bridge CFMutableAttributedStringRef)multilineTitle, @"\n", nil); } for (GCHistoryTag* tag in branch.tags) { NSString* tagName = tag.name; - _AppendAttributedString((CFMutableAttributedStringRef)multilineTitle, [NSString stringWithFormat:@"[%@]\n", tagName], multilineTitleAttributes); + _AppendAttributedString((__bridge CFMutableAttributedStringRef)multilineTitle, [NSString stringWithFormat:@"[%@]\n", tagName], multilineTitleAttributes); NSRange tagNameRange = NSMakeRange(multilineTitle.length - tagName.length - 2, tagName.length); // -2 to exclude char ']' plus '\n' - [multilineTitle addAttribute:NSFontAttributeName value:(id)boldFont range:tagNameRange]; + [multilineTitle addAttribute:NSFontAttributeName value:(__bridge id)boldFont range:tagNameRange]; [multilineTitle addAttribute:NSForegroundColorAttributeName value:darkColor range:tagNameRange]; } if (branch.tags.count) { - _AppendAttributedString((CFMutableAttributedStringRef)multilineTitle, @"\n", nil); + _AppendAttributedString((__bridge CFMutableAttributedStringRef)multilineTitle, @"\n", nil); } [multilineTitle endEditing]; if (multilineTitle.length == 0) { - [multilineTitle release]; + multilineTitle = nil; return; // This should only happen if we have a detached HEAD with no other references pointing to the commit } @@ -1087,7 +1080,7 @@ static void _DrawBranchTitle(CGContextRef context, CGFloat x, CGFloat y, CGPoint } // Clean up - [multilineTitle release]; + multilineTitle = nil; CGPathRelease(path); CFRelease(ellipsisToken); CFRelease(ellipsis); @@ -1227,7 +1220,7 @@ static void _DrawNodeLabels(CGContextRef context, CGFloat x, CGFloat y, GINode* } // Clean up - [label release]; + label = nil; } static void _DrawHead(CGContextRef context, CGFloat x, CGFloat y, BOOL isDetached, CGColorRef color, NSDictionary* attributes) { @@ -1474,29 +1467,29 @@ - (void)drawRect:(NSRect)dirtyRect { static NSDictionary* tagAttributes = nil; if (tagAttributes == nil) { CTFontRef font = CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, 11.0, CFSTR("en-US")); - tagAttributes = [@{(id)kCTForegroundColorFromContextAttributeName : (id)kCFBooleanTrue, - (id)kCTFontAttributeName : (id)font} retain]; + tagAttributes = @{(id)kCTForegroundColorFromContextAttributeName : (id)kCFBooleanTrue, + (id)kCTFontAttributeName : (__bridge id)font}; CFRelease(font); } static NSDictionary* branchAttributes = nil; if (branchAttributes == nil) { CTFontRef font = CTFontCreateUIFontForLanguage(kCTFontUIFontEmphasizedSystem, 11.0, CFSTR("en-US")); - branchAttributes = [@{(id)kCTForegroundColorFromContextAttributeName : (id)kCFBooleanTrue, - (id)kCTFontAttributeName : (id)font} retain]; + branchAttributes = @{(id)kCTForegroundColorFromContextAttributeName : (id)kCFBooleanTrue, + (id)kCTFontAttributeName : (__bridge id)font}; CFRelease(font); } static NSDictionary* selectedAttributes1 = nil; if (selectedAttributes1 == nil) { CTFontRef font = CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, 10.0, CFSTR("en-US")); - selectedAttributes1 = [@{(id)kCTForegroundColorFromContextAttributeName : (id)kCFBooleanTrue, - (id)kCTFontAttributeName : (id)font} retain]; + selectedAttributes1 = @{(id)kCTForegroundColorFromContextAttributeName : (id)kCFBooleanTrue, + (id)kCTFontAttributeName : (__bridge id)font}; CFRelease(font); } static NSDictionary* selectedAttributes2 = nil; if (selectedAttributes2 == nil) { CTFontRef font = CTFontCreateUIFontForLanguage(kCTFontUIFontEmphasizedSystem, 10.0, CFSTR("en-US")); - selectedAttributes2 = [@{(id)kCTForegroundColorFromContextAttributeName : (id)kCFBooleanTrue, - (id)kCTFontAttributeName : (id)font} retain]; + selectedAttributes2 = @{(id)kCTForegroundColorFromContextAttributeName : (id)kCFBooleanTrue, + (id)kCTFontAttributeName : (__bridge id)font}; CFRelease(font); } @@ -1726,7 +1719,7 @@ - (void)drawRect:(NSRect)dirtyRect { CGContextRestoreGState(context); // Clean up - [lines release]; + lines = nil; } @end diff --git a/GitUpKit/Interface/GINode.m b/GitUpKit/Interface/GINode.m index ad8b8d32..fa108ba0 100644 --- a/GitUpKit/Interface/GINode.m +++ b/GitUpKit/Interface/GINode.m @@ -13,9 +13,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#if __has_feature(objc_arc) -#error This file requires MRC -#endif #import "GIPrivate.h" @@ -28,9 +25,9 @@ - (instancetype)initWithLayer:(GILayer*)layer primaryLine:(GILine*)line commit:( if ((self = [super init])) { _primaryLine = line; _layer = layer; - _commit = [commit retain]; + _commit = commit; _dummy = dummy; - _alternateCommit = [alternateCommit retain]; + _alternateCommit = alternateCommit; } return self; } @@ -39,10 +36,8 @@ - (void)dealloc { if (_parentCount > 2) { CFRelease(_additionalParents); } - [_alternateCommit release]; - [_commit release]; - - [super dealloc]; + _alternateCommit = nil; + _commit = nil; } - (GINode*)parentAtIndex:(NSUInteger)index { @@ -51,7 +46,7 @@ - (GINode*)parentAtIndex:(NSUInteger)index { return _mainParent; } if (_parentCount == 2) { - return index ? _additionalParents : _mainParent; + return index ? (__bridge GINode *)_additionalParents : _mainParent; } return CFArrayGetValueAtIndex(_additionalParents, index); } @@ -60,16 +55,16 @@ - (void)addParent:(GINode*)parent { if (_parentCount == 0) { _mainParent = parent; } else if (_parentCount == 1) { - _additionalParents = parent; + _additionalParents = (__bridge void *)parent; } else if (_parentCount == 2) { CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0, NULL); - CFArrayAppendValue(array, _mainParent); + CFArrayAppendValue(array, (__bridge const void *)(_mainParent)); CFArrayAppendValue(array, _additionalParents); - CFArrayAppendValue(array, parent); + CFArrayAppendValue(array, (__bridge const void *)(parent)); _additionalParents = array; } else { XLOG_DEBUG_CHECK(CFArrayGetCount(_additionalParents) == (CFIndex)_parentCount); - CFArrayAppendValue(_additionalParents, parent); + CFArrayAppendValue(_additionalParents, (__bridge const void *)(parent)); } _parentCount += 1; }