mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-25 06:43:24 +03:00
Use CFData more
This commit is contained in:
parent
216066d120
commit
ce248642a7
@ -15,7 +15,8 @@
|
||||
nvimArgs:(NSArray<NSString *> *)nvimArgs;
|
||||
|
||||
- (void)sendMessageWithId:(NvimServerMsgId)msgid;
|
||||
- (void)sendMessageWithId:(NvimServerMsgId)msgid data:(NSData *)data;
|
||||
|
||||
- (void)sendMessageWithId:(NvimServerMsgId)msgid data:(CFDataRef)data;
|
||||
- (void)notifyReadiness;
|
||||
|
||||
@end
|
||||
|
@ -176,33 +176,31 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
}
|
||||
|
||||
- (void)sendMessageWithId:(NvimServerMsgId)msgid {
|
||||
[self sendMessageWithId:msgid data:nil];
|
||||
[self sendMessageWithId:msgid data:NULL];
|
||||
}
|
||||
|
||||
- (void)sendMessageWithId:(NvimServerMsgId)msgid data:(NSData *)data {
|
||||
- (void)sendMessageWithId:(NvimServerMsgId)msgid data:(CFDataRef)data {
|
||||
#ifdef DEBUG_NEOVIM_SERVER_STANDALONE
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (_remoteServerPort == NULL) {
|
||||
WLOG("Remote server is null: The msg (%lu:%s) could not be sent.", (unsigned long) msgid, data.cdesc);
|
||||
WLOG("Remote server is null: The msg (%lu) could not be sent.", (unsigned long) msgid);
|
||||
return;
|
||||
}
|
||||
|
||||
SInt32 responseCode = CFMessagePortSendRequest(
|
||||
_remoteServerPort, msgid, (__bridge CFDataRef) data, qTimeout, qTimeout, NULL, NULL
|
||||
);
|
||||
SInt32 responseCode = CFMessagePortSendRequest(_remoteServerPort, msgid, data, qTimeout, qTimeout, NULL, NULL);
|
||||
|
||||
if (responseCode == kCFMessagePortSuccess) {
|
||||
return;
|
||||
}
|
||||
|
||||
WLOG("The msg (%lu:%s) could not be sent: %d", (unsigned long) msgid, data.cdesc, responseCode);
|
||||
WLOG("The msg (%lu) could not be sent: %d", (unsigned long) msgid, responseCode);
|
||||
}
|
||||
|
||||
- (void)notifyReadiness {
|
||||
#ifndef DEBUG_NEOVIM_SERVER_STANDALONE
|
||||
[self sendMessageWithId:NvimServerMsgIdServerReady data:nil];
|
||||
[self sendMessageWithId:NvimServerMsgIdServerReady data:NULL];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -298,19 +298,19 @@ static void server_ui_main(UIBridgeData *bridge, UI *ui) {
|
||||
#pragma mark NeoVim's UI callbacks
|
||||
|
||||
static void server_ui_flush(UI *ui __unused) {
|
||||
@autoreleasepool {
|
||||
if (flush_sbuffer.size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
let data = [[NSData alloc] initWithBytesNoCopy:flush_sbuffer.data length:flush_sbuffer.size freeWhenDone:false];
|
||||
[_neovim_server sendMessageWithId:NvimServerMsgIdFlush data:data];
|
||||
[data release];
|
||||
|
||||
msgpack_sbuffer_clear(&flush_sbuffer);
|
||||
msgpack_packer_free(flush_packer);
|
||||
flush_packer = msgpack_packer_new(&flush_sbuffer, msgpack_sbuffer_write);
|
||||
if (flush_sbuffer.size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
let data = CFDataCreateWithBytesNoCopy(
|
||||
kCFAllocatorDefault, (const UInt8 *) flush_sbuffer.data, flush_sbuffer.size, kCFAllocatorNull
|
||||
);
|
||||
[_neovim_server sendMessageWithId:NvimServerMsgIdFlush data:data];
|
||||
CFRelease(data);
|
||||
|
||||
msgpack_sbuffer_clear(&flush_sbuffer);
|
||||
msgpack_packer_free(flush_packer);
|
||||
flush_packer = msgpack_packer_new(&flush_sbuffer, msgpack_sbuffer_write);
|
||||
}
|
||||
|
||||
static void server_ui_resize(UI *ui __unused, Integer width, Integer height) {
|
||||
|
Loading…
Reference in New Issue
Block a user