Mercurial > projects > dstep
view dstep/foundation/NSPort.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | 7ff919f595d5 |
children | b9de51448c6b |
line wrap: on
line source
/** * Copyright: Copyright (c) 2009 Jacob Carlborg. * Authors: Jacob Carlborg * Version: Initial created: Aug 3, 2009 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) */ module dstep.foundation.NSPort; import dstep.foundation.NSArray; import dstep.foundation.NSCoder; import dstep.foundation.NSConnection; import dstep.foundation.NSData; import dstep.foundation.NSDate; import dstep.foundation.NSObjCRuntime; import dstep.foundation.NSObject; import dstep.foundation.NSPortMessage; import dstep.foundation.NSRunLoop; import dstep.foundation.NSString; import dstep.foundation.NSZone; import dstep.objc.bridge.Bridge; import dstep.objc.objc; import bindings = dstep.foundation.NSPort_bindings; alias int NSSocketNativeHandle; private NSString NSPortDidBecomeInvalidNotification_; NSString NSPortDidBecomeInvalidNotification () { if (NSPortDidBecomeInvalidNotification_) return NSPortDidBecomeInvalidNotification_; return NSPortDidBecomeInvalidNotification_ = new NSString(bindings.NSPortDidBecomeInvalidNotification); } enum { NSMachPortDeallocateNone = 0, NSMachPortDeallocateSendRight = (1 << 0), NSMachPortDeallocateReceiveRight = (1 << 1) } const TNSMachPortDelegateMethods = ` void handleMachMessage (void* msg) { return invokeObjcSelf!(void, "handleMachMessage:", void*)(msg); } //mixin ObjcBindMethod!(handleMachMessage, "handleMachMessage:"); `; const TNSPortDelegateMethods = ` void handlePortMessage (NSPortMessage message) { return invokeObjcSelf!(void, "handlePortMessage:", NSPortMessage)(message); } //mixin ObjcBindMethod!(handlePortMessage, "handlePortMessage:"); `; class NSPort : NSObject, INSCopying, INSCoding { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } static Object allocWithZone (NSZone* zone) { return invokeObjcSuperClass!(Object, "allocWithZone:", NSZone*)(zone); } static NSPort port () { return invokeObjcSuperClass!(NSPort, "port"); } void invalidate () { return invokeObjcSelf!(void, "invalidate"); } bool isValid () { return invokeObjcSelf!(bool, "isValid"); } void setDelegate (Object anId) { return invokeObjcSelf!(void, "setDelegate:", Object)(anId); } Object delegate_ () { return invokeObjcSelf!(Object, "delegate"); } void scheduleInRunLoop (NSRunLoop runLoop, NSString mode) { return invokeObjcSelf!(void, "scheduleInRunLoop:forMode:", NSRunLoop, NSString)(runLoop, mode); } void removeFromRunLoop (NSRunLoop runLoop, NSString mode) { return invokeObjcSelf!(void, "removeFromRunLoop:forMode:", NSRunLoop, NSString)(runLoop, mode); } NSUInteger reservedSpaceLength () { return invokeObjcSelf!(NSUInteger, "reservedSpaceLength"); } bool sendBeforeDate (NSDate limitDate, NSMutableArray components, NSPort receivePort, NSUInteger headerSpaceReserved) { return invokeObjcSelf!(bool, "sendBeforeDate:components:from:reserved:", NSDate, NSMutableArray, NSPort, NSUInteger)(limitDate, components, receivePort, headerSpaceReserved); } bool sendBeforeDate (NSDate limitDate, NSUInteger msgID, NSMutableArray components, NSPort receivePort, NSUInteger headerSpaceReserved) { return invokeObjcSelf!(bool, "sendBeforeDate:msgid:components:from:reserved:", NSDate, NSUInteger, NSMutableArray, NSPort, NSUInteger)(limitDate, msgID, components, receivePort, headerSpaceReserved); } void addConnection (NSConnection conn, NSRunLoop runLoop, NSString mode) { return invokeObjcSelf!(void, "addConnection:toRunLoop:forMode:", NSConnection, NSRunLoop, NSString)(conn, runLoop, mode); } void removeConnection (NSConnection conn, NSRunLoop runLoop, NSString mode) { return invokeObjcSelf!(void, "removeConnection:fromRunLoop:forMode:", NSConnection, NSRunLoop, NSString)(conn, runLoop, mode); } Object copyWithZone (NSZone* zone) { return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); } void encodeWithCoder (NSCoder aCoder) { return invokeObjcSelf!(void, "encodeWithCoder:", NSCoder)(aCoder); } Object initWithCoder (NSCoder aDecoder) { return invokeObjcSelf!(Object, "initWithCoder:", NSCoder)(aDecoder); } this (NSCoder aDecoder) { typeof(this).alloc.initWithCoder(aDecoder); } } class NSSocketPort : NSPort { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } Object initWithTCPPort (ushort port) { return invokeObjcSelf!(Object, "initWithTCPPort:", ushort)(port); } this (ushort port) { typeof(this).alloc.initWithTCPPort(port); } Object initWithProtocolFamily (int family, int type, int protocol, NSData address) { return invokeObjcSelf!(Object, "initWithProtocolFamily:socketType:protocol:address:", int, int, int, NSData)(family, type, protocol, address); } this (int family, int type, int protocol, NSData address) { typeof(this).alloc.initWithProtocolFamily(family, type, protocol, address); } Object initWithProtocolFamily (int family, int type, int protocol, int sock) { return invokeObjcSelf!(Object, "initWithProtocolFamily:socketType:protocol:socket:", int, int, int, int)(family, type, protocol, sock); } this (int family, int type, int protocol, int sock) { typeof(this).alloc.initWithProtocolFamily(family, type, protocol, sock); } Object initRemoteWithTCPPort (ushort port, NSString hostName) { return invokeObjcSelf!(Object, "initRemoteWithTCPPort:host:", ushort, NSString)(port, hostName); } this (ushort port, NSString hostName) { typeof(this).alloc.initRemoteWithTCPPort(port, hostName); } Object initRemoteWithProtocolFamily (int family, int type, int protocol, NSData address) { return invokeObjcSelf!(Object, "initRemoteWithProtocolFamily:socketType:protocol:address:", int, int, int, NSData)(family, type, protocol, address); } int protocolFamily () { return invokeObjcSelf!(int, "protocolFamily"); } int socketType () { return invokeObjcSelf!(int, "socketType"); } int protocol () { return invokeObjcSelf!(int, "protocol"); } NSData address () { return invokeObjcSelf!(NSData, "address"); } int socket () { return invokeObjcSelf!(int, "socket"); } } class NSMachPort : NSPort { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } static NSPort portWithMachPort (uint machPort) { return invokeObjcSuperClass!(NSPort, "portWithMachPort:", uint)(machPort); } Object initWithMachPort (uint machPort) { return invokeObjcSelf!(Object, "initWithMachPort:", uint)(machPort); } this (uint machPort) { typeof(this).alloc.initWithMachPort(machPort); } static NSPort portWithMachPort (uint machPort, NSUInteger f) { return invokeObjcSuperClass!(NSPort, "portWithMachPort:options:", uint, NSUInteger)(machPort, f); } Object initWithMachPort (uint machPort, NSUInteger f) { return invokeObjcSelf!(Object, "initWithMachPort:options:", uint, NSUInteger)(machPort, f); } this (uint machPort, NSUInteger f) { typeof(this).alloc.initWithMachPort(machPort, f); } uint machPort () { return invokeObjcSelf!(uint, "machPort"); } void scheduleInRunLoop (NSRunLoop runLoop, NSString mode) { return invokeObjcSelf!(void, "scheduleInRunLoop:forMode:", NSRunLoop, NSString)(runLoop, mode); } void removeFromRunLoop (NSRunLoop runLoop, NSString mode) { return invokeObjcSelf!(void, "removeFromRunLoop:forMode:", NSRunLoop, NSString)(runLoop, mode); } }