1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-24 22:33:52 +03:00

Use ARC in NeoVimServer

This commit is contained in:
Tae Won Ha 2016-07-10 14:24:45 +02:00
parent c45e351a09
commit 52f528b33b
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
4 changed files with 17 additions and 25 deletions

View File

@ -4,7 +4,6 @@
*/
#import "NeoVimServer.h"
#import "NeoVimMsgIds.h"
#import "server_globals.h"
@ -30,10 +29,11 @@ data_to_array(NSInteger)
static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info) {
@autoreleasepool {
NeoVimServer *neoVimServer = (NeoVimServer *) info;
[neoVimServer handleMessageWithId:msgid data:(NSData *) data];
return NULL;
NeoVimServer *neoVimServer = (__bridge NeoVimServer *) info;
[neoVimServer handleMessageWithId:msgid data:(__bridge NSData *) data];
}
return NULL;
}
@ -57,33 +57,26 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
return nil;
}
_uuid = [uuid retain];
_localServerName = [localServerName retain];
_remoteServerName = [remoteServerName retain];
_uuid = uuid;
_localServerName = localServerName;
_remoteServerName = remoteServerName;
_localServerThread = [[NSThread alloc] initWithTarget:self selector:@selector(runLocalServer) object:nil];
[_localServerThread start];
_remoteServerPort = CFMessagePortCreateRemote(kCFAllocatorDefault, (CFStringRef) _remoteServerName);
_remoteServerPort = CFMessagePortCreateRemote(kCFAllocatorDefault, (__bridge CFStringRef) _remoteServerName);
return self;
}
- (void)dealloc {
[_uuid release];
[_localServerName release];
[_remoteServerName release];
CFMessagePortInvalidate(_localServerPort);
CFRelease(_localServerPort);
[_localServerThread cancel];
[_localServerThread release];
CFMessagePortInvalidate(_remoteServerPort);
CFRelease(_remoteServerPort);
[super dealloc];
}
- (void)runLocalServer {
@ -91,7 +84,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
unsigned char shouldFree = false;
CFMessagePortContext localContext = {
.version = 0,
.info = (void *) self,
.info = (__bridge void *) self,
.retain = NULL,
.release = NULL,
.copyDescription = NULL
@ -99,7 +92,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
_localServerPort = CFMessagePortCreateLocal(
kCFAllocatorDefault,
(CFStringRef) _localServerName,
(__bridge CFStringRef) _localServerName,
local_server_callback,
&localContext,
&shouldFree
@ -126,7 +119,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
}
SInt32 responseCode = CFMessagePortSendRequest(
_remoteServerPort, msgid, (CFDataRef) data, qTimeout, qTimeout, NULL, NULL
_remoteServerPort, msgid, (__bridge CFDataRef) data, qTimeout, qTimeout, NULL, NULL
);
if (responseCode == kCFMessagePortSuccess) {
@ -150,7 +143,6 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
case NeoVimAgentMsgIdInput: {
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
server_vim_input(string);
[string release];
return;
}
@ -158,7 +150,6 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
case NeoVimAgentMsgIdInputMarked: {
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
server_vim_input_marked_text(string);
[string release];
return;
}

View File

@ -8,7 +8,7 @@
#import "NeoVimUiBridgeProtocol.h"
static const int qTimeout = 10;
static const double qTimeout = 10;
#define data_to_array(type) \
static type *data_to_ ## type ## _array(NSData *data, NSUInteger count) { \
@ -33,8 +33,9 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
@autoreleasepool {
NeoVimAgent *agent = (__bridge NeoVimAgent *) info;
[agent handleMessageWithId:msgid data:(__bridge NSData *) (data)];
return NULL;
}
return NULL;
}

View File

@ -35,7 +35,7 @@
4B9A15251D2993DA009F9F67 /* Quick.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B56F29C1D29926600C1F92E /* Quick.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
4B9A15261D2993DF009F9F67 /* SwiftNeoVim.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B2A2BF71D0351810074CE9A /* SwiftNeoVim.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
4BCADE081D11ED12004DAD0F /* CocoaExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BCADE071D11ED12004DAD0F /* CocoaExtensions.swift */; };
4BDCFACB1D31449700F62670 /* NeoVimServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BDCFACA1D31449700F62670 /* NeoVimServer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
4BDCFACB1D31449700F62670 /* NeoVimServer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BDCFACA1D31449700F62670 /* NeoVimServer.m */; };
4BDCFACD1D3145AC00F62670 /* libnvim.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFACC1D3145AC00F62670 /* libnvim.a */; };
4BDCFAD51D3145E500F62670 /* libjemalloc_pic.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFACE1D3145E500F62670 /* libjemalloc_pic.a */; };
4BDCFAD61D3145E500F62670 /* libjemalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BDCFACF1D3145E500F62670 /* libjemalloc.a */; };

View File

@ -15,8 +15,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NeoVimViewDelegate {
let view = NeoVimView(forAutoLayout: ())
@IBAction func debugSomething(sender: AnyObject!) {
// let font = NSFont(name: "Courier", size: 14)!
// self.neoVim.view.setFont(font)
let font = NSFont(name: "Courier", size: 14)!
self.view.setFont(font)
}
func applicationDidFinishLaunching(aNotification: NSNotification) {