@@ -168,7 +168,7 @@ @interface MMChannel : NSObject {
168168 CFRunLoopSourceRef runLoopSource;
169169}
170170
171- - (id )initWithIndex : ( int ) idx fileDescriptor : ( int ) fd ;
171+ - (id )initWithChannel : (channel_T *) channel ;
172172@end
173173
174174
@@ -1684,20 +1684,17 @@ - (void)setImState:(BOOL)activated
16841684 [self flushQueue: YES ];
16851685}
16861686
1687- - (void )addChannel : (int ) idx fileDescriptor : ( int ) fd
1687+ - (void )addChannel : (channel_T *) channel
16881688{
1689- if (fd == -1 )
1690- return ;
1691-
1692- NSNumber *key = [NSNumber numberWithInt: idx];
1693- MMChannel *channel =
1694- [[[MMChannel alloc ] initWithIndex: idx fileDescriptor: fd] autorelease ];
1695- [channelDict setObject: channel forKey: key];
1689+ NSValue *key = [NSValue valueWithPointer: channel];
1690+ MMChannel *mmChannel =
1691+ [[[MMChannel alloc ] initWithChannel: channel] autorelease ];
1692+ [channelDict setObject: mmChannel forKey: key];
16961693}
16971694
1698- - (void )removeChannel : (int ) idx
1695+ - (void )removeChannel : (channel_T *) channel
16991696{
1700- NSNumber *key = [NSNumber numberWithInt: idx ];
1697+ NSValue *key = [NSValue valueWithPointer: channel ];
17011698 [channelDict removeObjectForKey: key];
17021699}
17031700
@@ -3432,20 +3429,19 @@ static void socketReadCallback(CFSocketRef s,
34323429 void *info)
34333430{
34343431#ifdef FEAT_CHANNEL
3435- int idx = (int )(intptr_t )info;
3436- channel_read (idx, FALSE , " socketReadCallback" );
3432+ channel_read ((channel_T *)info, FALSE , " socketReadCallback" );
34373433#endif
34383434}
34393435
3440- - (id )initWithIndex : ( int ) idx fileDescriptor : ( int ) fd
3436+ - (id )initWithChannel : (channel_T *) channel
34413437{
34423438 self = [super init ];
34433439 if (!self) return nil ;
34443440
34453441 // Tell CFRunLoop that we are interested in channel socket input.
3446- CFSocketContext ctx = {0 , ( void *)( intptr_t )idx , NULL , NULL , NULL };
3442+ CFSocketContext ctx = {0 , channel , NULL , NULL , NULL };
34473443 socket = CFSocketCreateWithNative (kCFAllocatorDefault ,
3448- fd ,
3444+ channel-> ch_sock ,
34493445 kCFSocketReadCallBack ,
34503446 &socketReadCallback,
34513447 &ctx);
0 commit comments