diff options
Diffstat (limited to 'cocoa')
-rw-r--r-- | cocoa/InfoBar.mm | 8 | ||||
-rw-r--r-- | cocoa/PlatCocoa.mm | 49 | ||||
-rw-r--r-- | cocoa/ScintillaCocoa.mm | 87 | ||||
-rw-r--r-- | cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | cocoa/ScintillaView.h | 2 | ||||
-rw-r--r-- | cocoa/ScintillaView.mm | 47 |
6 files changed, 78 insertions, 121 deletions
diff --git a/cocoa/InfoBar.mm b/cocoa/InfoBar.mm index 945d3515e..5d6bdb176 100644 --- a/cocoa/InfoBar.mm +++ b/cocoa/InfoBar.mm @@ -185,7 +185,6 @@ static float BarFontSize = 10.0; // put it in the scrollview. [self addSubview: mZoomPopup]; - [mZoomPopup release]; // 2) The caret position label. Class oldCellClass = [NSTextField cellClass]; @@ -204,7 +203,6 @@ static float BarFontSize = 10.0; [cell setAlignment: NSCenterTextAlignment]; [self addSubview: mCaretPositionLabel]; - [mCaretPositionLabel release]; // 3) The status text. mStatusTextLabel = [[NSTextField alloc] initWithFrame: NSMakeRect(0.0, 0.0, 1.0, 1.0)]; @@ -219,7 +217,6 @@ static float BarFontSize = 10.0; [cell setPlaceholderString: @""]; [self addSubview: mStatusTextLabel]; - [mStatusTextLabel release]; // Restore original cell class so that everything else doesn't get broken [NSTextField setCellClass: oldCellClass]; @@ -227,11 +224,6 @@ static float BarFontSize = 10.0; //-------------------------------------------------------------------------------------------------- -- (void) dealloc -{ - [mBackground release]; - [super dealloc]; -} //-------------------------------------------------------------------------------------------------- diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 7a65d3d41..238e1c741 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -1111,7 +1111,7 @@ Window::~Window() bool Window::HasFocus() { - NSView* container = static_cast<NSView*>(wid); + NSView* container = (__bridge NSView *)(wid); return [[container window] firstResponder] == container; } @@ -1129,7 +1129,7 @@ PRectangle Window::GetPosition() if (wid) { NSRect rect; - id idWin = static_cast<id>(wid); + id idWin = (__bridge id)(wid); NSWindow* win; if ([idWin isKindOfClass: [NSView class]]) { @@ -1163,7 +1163,7 @@ void Window::SetPosition(PRectangle rc) { if (wid) { - id idWin = static_cast<id>(wid); + id idWin = (__bridge id)(wid); if ([idWin isKindOfClass: [NSView class]]) { // NSView @@ -1212,7 +1212,7 @@ void Window::Show(bool show) { if (wid) { - id idWin = static_cast<id>(wid); + id idWin = (__bridge id)(wid); if ([idWin isKindOfClass: [NSWindow class]]) { NSWindow* win = idWin; @@ -1237,7 +1237,7 @@ void Window::InvalidateAll() { if (wid) { - id idWin = static_cast<id>(wid); + id idWin = (__bridge id)(wid); NSView* container; if ([idWin isKindOfClass: [NSView class]]) { @@ -1263,7 +1263,7 @@ void Window::InvalidateRectangle(PRectangle rc) { if (wid) { - id idWin = static_cast<id>(wid); + id idWin = (__bridge id)(wid); NSView* container; if ([idWin isKindOfClass: [NSView class]]) { @@ -1296,7 +1296,7 @@ void Window::SetCursor(Cursor curs) { if (wid) { - id idWin = static_cast<id>(wid); + id idWin = (__bridge id)(wid); if ([idWin isKindOfClass: [SCIContentView class]]) { SCIContentView* container = idWin; @@ -1311,7 +1311,7 @@ void Window::SetTitle(const char* s) { if (wid) { - id idWin = static_cast<id>(wid); + id idWin = (__bridge id)(wid); if ([idWin isKindOfClass: [NSWindow class]]) { NSWindow* win = idWin; @@ -1327,7 +1327,7 @@ PRectangle Window::GetMonitorRect(Point) { if (wid) { - id idWin = static_cast<id>(wid); + id idWin = (__bridge id)(wid); if ([idWin isKindOfClass: [NSView class]]) { NSView* view = idWin; @@ -1561,7 +1561,6 @@ public: images = [[NSMutableDictionary alloc] init]; } ~ListBoxImpl() override { - [images release]; } // ListBox methods @@ -1613,9 +1612,8 @@ void ListBoxImpl::Create(Window& /*parent*/, int /*ctrlID*/, Scintilla::Point pt defer: NO]; [winLB setLevel:NSFloatingWindowLevel]; [winLB setHasShadow:YES]; - scroller = [NSScrollView alloc]; NSRect scRect = NSMakeRect(0, 0, lbRect.size.width, lbRect.size.height); - [scroller initWithFrame: scRect]; + scroller = [[NSScrollView alloc] initWithFrame: scRect]; [scroller setHasVerticalScroller:YES]; table = [[NSTableView alloc] initWithFrame: scRect]; [table setHeaderView:nil]; @@ -1624,7 +1622,7 @@ void ListBoxImpl::Create(Window& /*parent*/, int /*ctrlID*/, Scintilla::Point pt [colIcon setWidth: 20]; [colIcon setEditable:NO]; [colIcon setHidden:YES]; - NSImageCell* imCell = [[[NSImageCell alloc] init] autorelease]; + NSImageCell* imCell = [[NSImageCell alloc] init]; [colIcon setDataCell:imCell]; [table addTableColumn:colIcon]; colText = [[NSTableColumn alloc] initWithIdentifier:@"name"]; @@ -1640,7 +1638,7 @@ void ListBoxImpl::Create(Window& /*parent*/, int /*ctrlID*/, Scintilla::Point pt [table setTarget:ds]; [table setDoubleAction:@selector(doubleClick:)]; table.selectionHighlightStyle = NSTableViewSelectionHighlightStyleSourceList; - wid = winLB; + wid = (__bridge_retained WindowID)winLB; } void ListBoxImpl::SetFont(Font& font_) @@ -1650,7 +1648,7 @@ void ListBoxImpl::SetFont(Font& font_) QuartzTextStyle* style = static_cast<QuartzTextStyle*>(font_.GetID()); font.Release(); font.SetID(new QuartzTextStyle(*style)); - NSFont *pfont = (NSFont *)style->getFontRef(); + NSFont *pfont = (__bridge NSFont *)style->getFontRef(); [[colText dataCell] setFont: pfont]; CGFloat itemHeight = ceil([pfont boundingRectForFont].size.height); [table setRowHeight:itemHeight]; @@ -1714,15 +1712,10 @@ int ListBoxImpl::CaretFromEdge() void ListBoxImpl::ReleaseViews() { [table setDataSource:nil]; - [table release]; table = nil; - [scroller release]; scroller = nil; - [colIcon release]; colIcon = nil; - [colText release ]; colText = nil; - [ds release]; ds = nil; } @@ -1837,7 +1830,6 @@ void ListBoxImpl::RegisterImage(int type, const char* xpm_data) XPM xpm(xpm_data); NSImage* img = ImageFromXPM(&xpm); [images setObject:img forKey:@(type)]; - [img release]; } void ListBoxImpl::RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) @@ -1846,7 +1838,6 @@ void ListBoxImpl::RegisterRGBAImage(int type, int width, int height, const unsig NSImage *img = [[NSImage alloc] initWithCGImage:imageRef size: NSZeroSize]; CGImageRelease(imageRef); [images setObject:img forKey:@(type)]; - [img release]; } void ListBoxImpl::ClearRegisteredImages() @@ -1912,14 +1903,13 @@ void Window::Destroy() } if (wid) { - id idWin = static_cast<id>(wid); + id idWin = (__bridge id)(wid); if ([idWin isKindOfClass: [NSWindow class]]) { - NSWindow* win = static_cast<NSWindow*>(idWin); - [win release]; + CFBridgingRelease(wid); } } - wid = 0; + wid = nullptr; } @@ -1956,16 +1946,15 @@ Menu::Menu() void Menu::CreatePopUp() { Destroy(); - mid = [[ScintillaContextMenu alloc] initWithTitle: @""]; + mid = (__bridge_retained MenuID)[[ScintillaContextMenu alloc] initWithTitle: @""]; } //-------------------------------------------------------------------------------------------------- void Menu::Destroy() { - ScintillaContextMenu* menu = static_cast<ScintillaContextMenu*>(mid); - [menu release]; - mid = NULL; + CFBridgingRelease(mid); + mid = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 64dffbd4f..afa05a186 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -179,7 +179,7 @@ static const KeyToCommand macMapDefault[] = // A gold to slightly redder gradient to match other applications CGColorRef colGold = CGColorCreateGenericRGB(1.0, 1.0, 0, 1.0); CGColorRef colGoldRed = CGColorCreateGenericRGB(1.0, 0.8, 0, 1.0); - self.colors = [NSArray arrayWithObjects:(id)colGoldRed, (id)colGold, nil]; + self.colors = [NSArray arrayWithObjects:(__bridge id)colGoldRed, (__bridge id)colGold, nil]; CGColorRelease(colGoldRed); CGColorRelease(colGold); @@ -198,11 +198,6 @@ static const KeyToCommand macMapDefault[] = } -- (void) dealloc { - [sFind release]; - [sFont release]; - [super dealloc]; -} const CGFloat paddingHighlightX = 4; const CGFloat paddingHighlightY = 2; @@ -211,7 +206,7 @@ const CGFloat paddingHighlightY = 2; if (!sFind || !sFont) return; - CFStringRef str = CFStringRef(sFind); + CFStringRef str = (__bridge CFStringRef)(sFind); CFMutableDictionaryRef styleDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &kCFTypeDictionaryKeyCallBacks, @@ -333,8 +328,6 @@ const CGFloat paddingHighlightY = 2; { NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; [center removeObserver:self]; - [notificationQueue release]; - [super dealloc]; } //-------------------------------------------------------------------------------------------------- @@ -345,7 +338,6 @@ const CGFloat paddingHighlightY = 2; - (void) ownerDestroyed { mTarget = NULL; - [notificationQueue release]; notificationQueue = nil; } @@ -403,8 +395,8 @@ ScintillaCocoa::ScintillaCocoa(ScintillaView* sciView_, SCIContentView* viewCont // Don't retain since we're owned by view, which would cause a cycle sciView = sciView_; - wMain = viewContent; - wMargin = viewMargin; + wMain = (__bridge WindowID)viewContent; + wMargin = (__bridge WindowID)viewMargin; timerTarget = [[TimerTarget alloc] init: this]; lastMouseEvent = NULL; @@ -430,7 +422,6 @@ ScintillaCocoa::ScintillaCocoa(ScintillaView* sciView_, SCIContentView* viewCont ScintillaCocoa::~ScintillaCocoa() { [timerTarget ownerDestroyed]; - [timerTarget release]; } //-------------------------------------------------------------------------------------------------- @@ -580,10 +571,10 @@ public: } else { CFStringRef cfsVal = CFStringFromString(mixed, lenMixed, encoding); - NSString *sMapped = [(NSString *)cfsVal stringByFoldingWithOptions:NSCaseInsensitiveSearch + NSString *sMapped = [(__bridge NSString *)cfsVal stringByFoldingWithOptions:NSCaseInsensitiveSearch locale:[NSLocale currentLocale]]; - std::string encoded = EncodedBytesString((CFStringRef)sMapped, encoding); + std::string encoded = EncodedBytesString((__bridge CFStringRef)sMapped, encoding); size_t lenMapped = encoded.length(); if (lenMapped < sizeFolded) { @@ -615,10 +606,10 @@ CaseFolder *ScintillaCocoa::CaseFolderForEncoding() { if (!cfsVal) continue; - NSString *sMapped = [(NSString *)cfsVal stringByFoldingWithOptions:NSCaseInsensitiveSearch + NSString *sMapped = [(__bridge NSString *)cfsVal stringByFoldingWithOptions:NSCaseInsensitiveSearch locale:[NSLocale currentLocale]]; - std::string encoded = EncodedBytesString((CFStringRef)sMapped, encoding); + std::string encoded = EncodedBytesString((__bridge CFStringRef)sMapped, encoding); if (encoded.length() == 1) { pcf->SetTranslation(sCharacter[0], encoded[0]); @@ -661,17 +652,17 @@ std::string ScintillaCocoa::CaseMapString(const std::string &s, int caseMapping) switch (caseMapping) { case cmUpper: - sMapped = [(NSString *)cfsVal uppercaseString]; + sMapped = [(__bridge NSString *)cfsVal uppercaseString]; break; case cmLower: - sMapped = [(NSString *)cfsVal lowercaseString]; + sMapped = [(__bridge NSString *)cfsVal lowercaseString]; break; default: - sMapped = (NSString *)cfsVal; + sMapped = (__bridge NSString *)cfsVal; } // Back to encoding - std::string result = EncodedBytesString((CFStringRef)sMapped, encoding); + std::string result = EncodedBytesString((__bridge CFStringRef)sMapped, encoding); CFRelease(cfsVal); return result; } @@ -692,7 +683,7 @@ void ScintillaCocoa::CancelModes() { * Helper function to get the scrolling view. */ NSScrollView* ScintillaCocoa::ScrollContainer() const { - NSView* container = static_cast<NSView*>(wMain.GetID()); + NSView* container = (__bridge NSView*)(wMain.GetID()); return static_cast<NSScrollView*>([[container superview] superview]); } @@ -703,7 +694,7 @@ NSScrollView* ScintillaCocoa::ScrollContainer() const { */ SCIContentView* ScintillaCocoa::ContentView() { - return static_cast<SCIContentView*>(wMain.GetID()); + return (__bridge SCIContentView*)(wMain.GetID()); } //-------------------------------------------------------------------------------------------------- @@ -829,7 +820,7 @@ sptr_t ScintillaCocoa::DirectFunction(sptr_t ptr, unsigned int iMessage, uptr_t */ sptr_t scintilla_send_message(void* sci, unsigned int iMessage, uptr_t wParam, sptr_t lParam) { - ScintillaView *control = static_cast<ScintillaView*>(sci); + ScintillaView *control = (__bridge ScintillaView*)(sci); return [control message:iMessage wParam:wParam lParam:lParam]; } @@ -1008,12 +999,12 @@ bool ScintillaCocoa::SetIdle(bool on) userInfo: nil repeats: YES]; [NSRunLoop.currentRunLoop addTimer: idleTimer forMode: NSModalPanelRunLoopMode]; - idler.idlerID = idleTimer; + idler.idlerID = (__bridge IdlerID)idleTimer; } else if (idler.idlerID != NULL) { - [static_cast<NSTimer*>(idler.idlerID) invalidate]; + [(__bridge NSTimer*)(idler.idlerID) invalidate]; idler.idlerID = 0; } } @@ -1112,9 +1103,6 @@ void ScintillaCocoa::CTPaint(void* gc, NSRect rc) { return self; } -- (void) dealloc { - [super dealloc]; -} - (BOOL) isFlipped { return YES; @@ -1147,7 +1135,7 @@ void ScintillaCocoa::CTPaint(void* gc, NSRect rc) { @end void ScintillaCocoa::CallTipMouseDown(NSPoint pt) { - NSRect rectBounds = [(NSView *)(ct.wDraw.GetID()) bounds]; + NSRect rectBounds = [(__bridge NSView *)(ct.wDraw.GetID()) bounds]; Point location(static_cast<XYPOSITION>(pt.x), static_cast<XYPOSITION>(rectBounds.size.height - pt.y)); ct.MouseClick(location); @@ -1155,7 +1143,7 @@ void ScintillaCocoa::CallTipMouseDown(NSPoint pt) { } static bool HeightDifferent(WindowID wCallTip, PRectangle rc) { - NSWindow *callTip = (NSWindow *)wCallTip; + NSWindow *callTip = (__bridge NSWindow *)wCallTip; CGFloat height = NSHeight([callTip frame]); return height != rc.Height(); } @@ -1178,22 +1166,22 @@ void ScintillaCocoa::CreateCallTipWindow(PRectangle rc) { [caption setSci: this]; [[callTip contentView] addSubview: caption]; [callTip orderFront:caption]; - ct.wCallTip = callTip; - ct.wDraw = caption; + ct.wCallTip = (__bridge_retained WindowID)callTip; + ct.wDraw = (__bridge WindowID)caption; } } void ScintillaCocoa::AddToPopUp(const char *label, int cmd, bool enabled) { NSMenuItem* item; - ScintillaContextMenu *menu = static_cast<ScintillaContextMenu*>(popup.GetID()); + ScintillaContextMenu *menu = (__bridge ScintillaContextMenu*)(popup.GetID()); [menu setOwner: this]; [menu setAutoenablesItems: NO]; if (cmd == 0) { item = [NSMenuItem separatorItem]; } else { - item = [[[NSMenuItem alloc] init] autorelease]; + item = [[NSMenuItem alloc] init]; [item setTitle: [NSString stringWithUTF8String: label]]; } [item setTarget: menu]; @@ -1313,13 +1301,13 @@ void ScintillaCocoa::DragScroll() if ([type compare: NSPasteboardTypeString] == NSOrderedSame) { - [pasteboard setString:(NSString *)cfsVal forType: NSStringPboardType]; + [pasteboard setString:(__bridge NSString *)cfsVal forType: NSStringPboardType]; } else if ([type compare: ScintillaRecPboardType] == NSOrderedSame) { // This is specific to scintilla, allows us to drag rectangular selections around the document. if (selectedText.rectangular) - [pasteboard setString:(NSString *)cfsVal forType: ScintillaRecPboardType]; + [pasteboard setString:(__bridge NSString *)cfsVal forType: ScintillaRecPboardType]; } if (cfsVal) @@ -1456,13 +1444,13 @@ void ScintillaCocoa::StartDrag() NSBitmapImageRep* bitmap = NULL; CGImageRef imagePixmap = pixmap.GetImage(); if (imagePixmap) - bitmap = [[[NSBitmapImageRep alloc] initWithCGImage: imagePixmap] autorelease]; + bitmap = [[NSBitmapImageRep alloc] initWithCGImage: imagePixmap]; CGImageRelease(imagePixmap); - NSImage* image = [[[NSImage alloc] initWithSize: selectionRectangle.size] autorelease]; + NSImage* image = [[NSImage alloc] initWithSize: selectionRectangle.size]; [image addRepresentation: bitmap]; - NSImage* dragImage = [[[NSImage alloc] initWithSize: selectionRectangle.size] autorelease]; + NSImage* dragImage = [[NSImage alloc] initWithSize: selectionRectangle.size]; [dragImage setBackgroundColor: [NSColor clearColor]]; [dragImage lockFocus]; [image drawAtPoint: NSZeroPoint fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 0.5]; @@ -1473,21 +1461,20 @@ void ScintillaCocoa::StartDrag() startPoint.y = selectionRectangle.origin.y + selectionRectangle.size.height + client.top; NSPasteboardItem *pbItem = [NSPasteboardItem new]; - DragProviderSource *dps = [[[DragProviderSource alloc] initWithSelectedText:&selectedText] autorelease]; + DragProviderSource *dps = [[DragProviderSource alloc] initWithSelectedText:&selectedText]; NSArray *pbTypes = selectedText.rectangular ? @[NSPasteboardTypeString, ScintillaRecPboardType] : @[NSPasteboardTypeString]; [pbItem setDataProvider:dps forTypes:pbTypes]; NSDraggingItem *dragItem = [[NSDraggingItem alloc ]initWithPasteboardWriter:pbItem]; - [pbItem release]; NSScrollView *scrollContainer = ScrollContainer(); NSRect contentRect = [[scrollContainer contentView] bounds]; NSRect draggingRect = NSOffsetRect(selectionRectangle, contentRect.origin.x, contentRect.origin.y); [dragItem setDraggingFrame:draggingRect contents:dragImage]; NSDraggingSession *dragSession = - [content beginDraggingSessionWithItems:@[[dragItem autorelease]] + [content beginDraggingSessionWithItems:@[dragItem] event:lastMouseEvent source:content]; dragSession.animatesToStartingPositionsOnCancelOrFail = YES; @@ -1600,10 +1587,10 @@ void ScintillaCocoa::SetPasteboardData(NSPasteboard* board, const SelectionText if (selectedText.rectangular) { // This is specific to scintilla, allows us to drag rectangular selections around the document. - [board setString: (NSString *)cfsVal forType: ScintillaRecPboardType]; + [board setString: (__bridge NSString *)cfsVal forType: ScintillaRecPboardType]; } - [board setString: (NSString *)cfsVal forType: NSStringPboardType]; + [board setString: (__bridge NSString *)cfsVal forType: NSStringPboardType]; if (cfsVal) CFRelease(cfsVal); @@ -1698,7 +1685,7 @@ NSString *ScintillaCocoa::RangeTextAsString(NSRange rangePositions) const { vs.styles[STYLE_DEFAULT].characterSet); CFStringRef cfsVal = CFStringFromString(text.c_str(), text.length(), encoding); - return (NSString *)cfsVal; + return (__bridge NSString *)cfsVal; } } @@ -1827,7 +1814,7 @@ bool ScintillaCocoa::SyncPaint(void* gc, PRectangle rc) paintState = notPainting; if (!succeeded) { - NSView *marginView = static_cast<NSView*>(wMargin.GetID()); + NSView *marginView = (__bridge NSView*)(wMargin.GetID()); [marginView setNeedsDisplay:YES]; } return succeeded; @@ -2276,7 +2263,7 @@ int ScintillaCocoa::InsertText(NSString* input) { CFStringEncoding encoding = EncodingFromCharacterSet(IsUnicodeMode(), vs.styles[STYLE_DEFAULT].characterSet); - std::string encoded = EncodedBytesString((CFStringRef)input, encoding); + std::string encoded = EncodedBytesString((__bridge CFStringRef)input, encoding); if (encoded.length() > 0) { @@ -2543,7 +2530,7 @@ NSMenu* ScintillaCocoa::CreateContextMenu(NSEvent* /* event */) // Call ScintillaBase to create the context menu. ContextMenu(Point(0, 0)); - return static_cast<NSMenu*>(popup.GetID()); + return (__bridge NSMenu*)(popup.GetID()); } //-------------------------------------------------------------------------------------------------- @@ -2615,7 +2602,7 @@ void ScintillaCocoa::ShowFindIndicatorForRange(NSRange charRange, BOOL retaining pdoc->GetCharRange(&buffer[0], static_cast<int>(charRange.location), static_cast<int>(charRange.length)); CFStringRef cfsFind = CFStringFromString(&buffer[0], charRange.length, encoding); - layerFindIndicator.sFind = (NSString *)cfsFind; + layerFindIndicator.sFind = (__bridge NSString *)cfsFind; if (cfsFind) CFRelease(cfsFind); layerFindIndicator.retaining = retaining; diff --git a/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj b/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj index 309416ec6..e491ef619 100644 --- a/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj +++ b/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj @@ -216,7 +216,6 @@ 28BC38EC1B74C6AD008BF9EB /* Sci_Position.h in Headers */ = {isa = PBXBuildFile; fileRef = 28BC38EB1B74C6AD008BF9EB /* Sci_Position.h */; settings = {ATTRIBUTES = (Public, ); }; }; 28C40CA81CB7321200B089F2 /* LexJSON.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28C40CA71CB7321200B089F2 /* LexJSON.cxx */; }; 28D191A21DEA72C800159938 /* LexEDIFACT.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28D191A11DEA72C800159938 /* LexEDIFACT.cxx */; }; - 28D1919E1DE69FC100159938 /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; }; 28D516D81830FFCA0047C93D /* info_bar_bg@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 28D516D51830FFCA0047C93D /* info_bar_bg@2x.png */; }; 28D516D91830FFCA0047C93D /* mac_cursor_busy@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 28D516D61830FFCA0047C93D /* mac_cursor_busy@2x.png */; }; 28D516DA1830FFCA0047C93D /* mac_cursor_flipped@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 28D516D71830FFCA0047C93D /* mac_cursor_flipped@2x.png */; }; @@ -423,6 +422,7 @@ 280056F9188DDD2C00F200AE /* StringCopy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringCopy.h; path = ../../lexlib/StringCopy.h; sourceTree = "<group>"; }; 280056FA188DDD2C00F200AE /* SubStyles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SubStyles.h; path = ../../lexlib/SubStyles.h; sourceTree = "<group>"; }; 28064A04190F12E100E6E47F /* LexDMIS.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexDMIS.cxx; path = ../../lexers/LexDMIS.cxx; sourceTree = "<group>"; }; + 282E41F3B9E2BFEDD6A05BE7 /* LexIndent.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexIndent.cxx; path = ../../lexers/LexIndent.cxx; sourceTree = SOURCE_ROOT; }; 28A067101A36B42600B4966A /* LexHex.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexHex.cxx; path = ../../lexers/LexHex.cxx; sourceTree = "<group>"; }; 28A1DD4E196BE0CA006EFCDD /* EditModel.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EditModel.cxx; path = ../../src/EditModel.cxx; sourceTree = "<group>"; }; 28A1DD4F196BE0CA006EFCDD /* EditView.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EditView.cxx; path = ../../src/EditView.cxx; sourceTree = "<group>"; }; @@ -439,6 +439,7 @@ 28B6470B1B54C0720009DC49 /* LexProps.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexProps.cxx; path = ../../lexers/LexProps.cxx; sourceTree = "<group>"; }; 28BC38EB1B74C6AD008BF9EB /* Sci_Position.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Sci_Position.h; path = ../../include/Sci_Position.h; sourceTree = "<group>"; }; 28C40CA71CB7321200B089F2 /* LexJSON.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexJSON.cxx; path = ../../lexers/LexJSON.cxx; sourceTree = "<group>"; }; + 28D1919E1DE69FC100159938 /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; }; 28D191A11DEA72C800159938 /* LexEDIFACT.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexEDIFACT.cxx; path = ../../lexers/LexEDIFACT.cxx; sourceTree = "<group>"; }; 28D516D51830FFCA0047C93D /* info_bar_bg@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "info_bar_bg@2x.png"; sourceTree = "<group>"; }; 28D516D61830FFCA0047C93D /* mac_cursor_busy@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "mac_cursor_busy@2x.png"; sourceTree = "<group>"; }; @@ -448,7 +449,6 @@ 8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 8DC2EF5B0486A6940098B216 /* Scintilla.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Scintilla.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D2F7E79907B2D74100F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; }; - 282E41F3B9E2BFEDD6A05BE7 /* LexIndent.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexIndent.cxx; path = ../../lexers/LexIndent.cxx; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -1118,6 +1118,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; DEFINES_MODULE = YES; @@ -1154,6 +1155,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; diff --git a/cocoa/ScintillaView.h b/cocoa/ScintillaView.h index 8c4cdfe2e..1bd9637a2 100644 --- a/cocoa/ScintillaView.h +++ b/cocoa/ScintillaView.h @@ -71,7 +71,7 @@ extern NSString *const SCIUpdateUINotification; */ @interface ScintillaView : NSView <InfoBarCommunicator, ScintillaNotificationProtocol>; -@property (nonatomic, assign) id<ScintillaNotificationProtocol> delegate; +@property (nonatomic, unsafe_unretained) id<ScintillaNotificationProtocol> delegate; @property (nonatomic, readonly) NSScrollView *scrollView; + (Class) contentViewClass; diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index 2e35a5492..ad88f2097 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -55,12 +55,12 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) // Add marginWidth and owner properties as a private category. @interface SCIMarginView () @property (assign) int marginWidth; -@property (nonatomic, assign) ScintillaView* owner; +@property (nonatomic, weak) ScintillaView* owner; @end @implementation SCIMarginView { int marginWidth; - ScintillaView *owner; + ScintillaView *__weak owner; NSMutableArray *currentCursors; } @@ -73,10 +73,10 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) { owner = nil; marginWidth = 20; - currentCursors = [[NSMutableArray arrayWithCapacity:0] retain]; + currentCursors = [NSMutableArray arrayWithCapacity:0]; for (size_t i=0; i<=SC_MAX_MARGIN; i++) { - [currentCursors addObject: [reverseArrowCursor retain]]; + [currentCursors addObject: reverseArrowCursor]; } [self setClientView:[aScrollView documentView]]; if ([self respondsToSelector: @selector(setAccessibilityLabel:)]) @@ -85,11 +85,6 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) return self; } -- (void) dealloc -{ - [currentCursors release]; - [super dealloc]; -} - (void) setFrame: (NSRect) frame { @@ -195,11 +190,11 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) // Add owner property as a private category. @interface SCIContentView () -@property (nonatomic, assign) ScintillaView* owner; +@property (nonatomic, weak) ScintillaView* owner; @end @implementation SCIContentView { - ScintillaView* mOwner; + ScintillaView* __weak mOwner; NSCursor* mCurrentCursor; NSTrackingArea *trackingArea; @@ -218,7 +213,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) if (self != nil) { // Some initialization for our view. - mCurrentCursor = [[NSCursor arrowCursor] retain]; + mCurrentCursor = [NSCursor arrowCursor]; trackingArea = nil; mMarkedTextRange = NSMakeRange(NSNotFound, 0); @@ -250,7 +245,6 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) if (trackingArea) { [self removeTrackingArea:trackingArea]; - [trackingArea release]; } int opts = (NSTrackingActiveAlways | NSTrackingInVisibleRect | NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved); @@ -282,9 +276,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (void) setCursor: (int) cursor { Window::Cursor eCursor = (Window::Cursor)cursor; - [mCurrentCursor autorelease]; mCurrentCursor = cursorFromEnum(eCursor); - [mCurrentCursor retain]; // Trigger recreation of the cursor rectangle(s). [[self window] invalidateCursorRectsForView: self]; @@ -443,7 +435,7 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) [mOwner message: SCI_TARGETASUTF8 wParam: 0 lParam: reinterpret_cast<sptr_t>(&text[0])]; text = FixInvalidUTF8(text); NSString *result = [NSString stringWithUTF8String: text.c_str()]; - NSMutableAttributedString *asResult = [[[NSMutableAttributedString alloc] initWithString:result] autorelease]; + NSMutableAttributedString *asResult = [[NSMutableAttributedString alloc] initWithString:result]; const NSRange rangeAS = NSMakeRange(0, [asResult length]); // SCI_GETSTYLEAT reports a signed byte but want an unsigned to index into styles @@ -485,8 +477,11 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) - (void) doCommandBySelector: (SEL) selector { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" if ([self respondsToSelector: @selector(selector)]) [self performSelector: selector withObject: nil]; +#pragma clang diagnostic pop } //-------------------------------------------------------------------------------------------------- @@ -1211,7 +1206,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context - (NSAttributedString *) accessibilityAttributedStringForRange:(NSRange)range { const NSRange posRange = mOwner.backend->PositionsFromCharacters(range); NSString *result = mOwner.backend->RangeTextAsString(posRange); - return [[[NSMutableAttributedString alloc] initWithString:result] autorelease]; + return [[NSMutableAttributedString alloc] initWithString:result]; } //-------------------------------------------------------------------------------------------------- @@ -1245,12 +1240,6 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context //-------------------------------------------------------------------------------------------------- -- (void) dealloc -{ - [mCurrentCursor release]; - [trackingArea release]; - [super dealloc]; -} @end @@ -1273,7 +1262,7 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context NSView <InfoBarCommunicator>* mInfoBar; BOOL mInfoBarAtTop; - id<ScintillaNotificationProtocol> mDelegate; + id<ScintillaNotificationProtocol> __unsafe_unretained mDelegate; } @synthesize backend = mBackend; @@ -1298,11 +1287,11 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context NSBundle* bundle = [NSBundle bundleForClass: [ScintillaView class]]; NSString* path = [bundle pathForResource: @"mac_cursor_busy" ofType: @"tiff" inDirectory: nil]; - NSImage* image = [[[NSImage alloc] initWithContentsOfFile: path] autorelease]; + NSImage* image = [[NSImage alloc] initWithContentsOfFile: path]; waitCursor = [[NSCursor alloc] initWithImage: image hotSpot: NSMakePoint(2, 2)]; path = [bundle pathForResource: @"mac_cursor_flipped" ofType: @"tiff" inDirectory: nil]; - image = [[[NSImage alloc] initWithContentsOfFile: path] autorelease]; + image = [[NSImage alloc] initWithContentsOfFile: path]; reverseArrowCursor = [[NSCursor alloc] initWithImage: image hotSpot: NSMakePoint(12, 2)]; } } @@ -1501,14 +1490,14 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context self = [super initWithFrame:frame]; if (self) { - mContent = [[[[[self class] contentViewClass] alloc] initWithFrame:NSZeroRect] autorelease]; + mContent = [[[[self class] contentViewClass] alloc] initWithFrame:NSZeroRect]; mContent.owner = self; // Initialize the scrollers but don't show them yet. // Pick an arbitrary size, just to make NSScroller selecting the proper scroller direction // (horizontal or vertical). NSRect scrollerRect = NSMakeRect(0, 0, 100, 10); - scrollView = [[[NSScrollView alloc] initWithFrame: scrollerRect] autorelease]; + scrollView = [[NSScrollView alloc] initWithFrame: scrollerRect]; [scrollView setDocumentView: mContent]; [scrollView setHasVerticalScroller:YES]; [scrollView setHasHorizontalScroller:YES]; @@ -1570,8 +1559,6 @@ sourceOperationMaskForDraggingContext: (NSDraggingContext) context mContent.owner = nil; [marginView setClientView:nil]; [scrollView removeFromSuperview]; - [marginView release]; - [super dealloc]; } //-------------------------------------------------------------------------------------------------- |