Mercurial > projects > dstep
view dstep/foundation/NSConnection.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.NSConnection; import dstep.foundation.NSArray; import dstep.foundation.NSData; import dstep.foundation.NSDate; import dstep.foundation.NSDictionary; import dstep.foundation.NSDistantObject; import dstep.foundation.NSException; import dstep.foundation.NSInvocation; import dstep.foundation.NSObject; import dstep.foundation.NSPort; import dstep.foundation.NSPortNameServer; import dstep.foundation.NSRunLoop; import dstep.foundation.NSString; import dstep.objc.bridge.Bridge; import dstep.objc.objc; import bindings = dstep.foundation.NSConnection_bindings; private { NSString NSConnectionReplyMode_; NSString NSConnectionDidDieNotification_; NSString NSFailedAuthenticationException_; NSString NSConnectionDidInitializeNotification_; } NSString NSConnectionReplyMode () { if (NSConnectionReplyMode_) return NSConnectionReplyMode_; return NSConnectionReplyMode_ = new NSString(bindings.NSConnectionReplyMode); } NSString NSConnectionDidDieNotification () { if (NSConnectionDidDieNotification_) return NSConnectionDidDieNotification_; return NSConnectionDidDieNotification_ = new NSString(bindings.NSConnectionDidDieNotification); } NSString NSFailedAuthenticationException () { if (NSFailedAuthenticationException_) return NSFailedAuthenticationException_; return NSFailedAuthenticationException_ = new NSString(bindings.NSFailedAuthenticationException); } NSString NSConnectionDidInitializeNotification () { if (NSConnectionDidInitializeNotification_) return NSConnectionDidInitializeNotification_; return NSConnectionDidInitializeNotification_ = new NSString(bindings.NSConnectionDidInitializeNotification); } const TNSDistantObjectRequestMethods = ` bool connection (NSConnection connection, NSDistantObjectRequest doreq) { return invokeObjcSelf!(bool, "connection:handleRequest:", NSConnection, NSDistantObjectRequest)(connection, doreq); } //mixin ObjcBindMethod!(connection, "connection:handleRequest:"); `; const TNSConnectionDelegateMethods = ` bool makeNewConnection (NSConnection conn, NSConnection ancestor) { return invokeObjcSelf!(bool, "makeNewConnection:sender:")(conn, ancestor); } bool connection (NSConnection ancestor, NSConnection conn) { return invokeObjcSelf!(bool, "connection:shouldMakeNewConnection:", NSConnection, NSConnection)(ancestor, conn); } NSData authenticationDataForComponents (NSArray components) { return invokeObjcSelf!(NSData, "authenticationDataForComponents:", NSArray)(components); } bool authenticateComponents (NSArray components, NSData signature) { return invokeObjcSelf!(bool, "authenticateComponents:withData:")(components, signature); } Object createConversationForConnection (NSConnection conn) { return invokeObjcSelf!(Object, "createConversationForConnection:")(conn); } //mixin ObjcBindMethod!(makeNewConnection, "makeNewConnection:sender:"); //mixin ObjcBindMethod!(connection, "connection:shouldMakeNewConnection:"); //mixin ObjcBindMethod!(authenticationDataForComponents, "authenticationDataForComponents:"); //mixin ObjcBindMethod!(authenticateComponents, "authenticateComponents:withData:"); //mixin ObjcBindMethod!(createConversationForConnection, "createConversationForConnection:"); `; class NSDistantObjectRequest : NSObject { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } NSInvocation invocation () { return invokeObjcSelf!(NSInvocation, "invocation"); } NSConnection connection () { return invokeObjcSelf!(NSConnection, "connection"); } Object conversation () { return invokeObjcSelf!(Object, "conversation"); } void replyWithException (NSException exception) { return invokeObjcSelf!(void, "replyWithException:", NSException)(exception); } } class NSConnection : NSObject { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } NSDictionary statistics () { return invokeObjcSelf!(NSDictionary, "statistics"); } static NSArray allConnections () { return invokeObjcSuperClass!(NSArray, "allConnections"); } static NSConnection defaultConnection () { return invokeObjcSuperClass!(NSConnection, "defaultConnection"); } static Object connectionWithRegisteredName (NSString name, NSString hostName) { return invokeObjcSuperClass!(Object, "connectionWithRegisteredName:host:", NSString, NSString)(name, hostName); } static Object connectionWithRegisteredName (NSString name, NSString hostName, NSPortNameServer server) { return invokeObjcSuperClass!(Object, "connectionWithRegisteredName:host:usingNameServer:", NSString, NSString, NSPortNameServer)(name, hostName, server); } static NSDistantObject rootProxyForConnectionWithRegisteredName (NSString name, NSString hostName) { return invokeObjcSuperClass!(NSDistantObject, "rootProxyForConnectionWithRegisteredName:host:", NSString, NSString)(name, hostName); } static NSDistantObject rootProxyForConnectionWithRegisteredName (NSString name, NSString hostName, NSPortNameServer server) { return invokeObjcSuperClass!(NSDistantObject, "rootProxyForConnectionWithRegisteredName:host:usingNameServer:", NSString, NSString, NSPortNameServer)(name, hostName, server); } static Object serviceConnectionWithName (NSString name, Object root, NSPortNameServer server) { return invokeObjcSuperClass!(Object, "serviceConnectionWithName:rootObject:usingNameServer:", NSString, Object, NSPortNameServer)(name, root, server); } static Object serviceConnectionWithName (NSString name, Object root) { return invokeObjcSuperClass!(Object, "serviceConnectionWithName:rootObject:", NSString, Object)(name, root); } void setRequestTimeout (double ti) { return invokeObjcSelf!(void, "setRequestTimeout:", double)(ti); } double requestTimeout () { return invokeObjcSelf!(double, "requestTimeout"); } void setReplyTimeout (double ti) { return invokeObjcSelf!(void, "setReplyTimeout:", double)(ti); } double replyTimeout () { return invokeObjcSelf!(double, "replyTimeout"); } void setRootObject (Object anObject) { return invokeObjcSelf!(void, "setRootObject:", Object)(anObject); } Object rootObject () { return invokeObjcSelf!(Object, "rootObject"); } NSDistantObject rootProxy () { return invokeObjcSelf!(NSDistantObject, "rootProxy"); } void setDelegate (Object anObject) { return invokeObjcSelf!(void, "setDelegate:", Object)(anObject); } Object delegate_ () { return invokeObjcSelf!(Object, "delegate"); } void setIndependentConversationQueueing (bool yorn) { return invokeObjcSelf!(void, "setIndependentConversationQueueing:", bool)(yorn); } bool independentConversationQueueing () { return invokeObjcSelf!(bool, "independentConversationQueueing"); } bool isValid () { return invokeObjcSelf!(bool, "isValid"); } void invalidate () { return invokeObjcSelf!(void, "invalidate"); } void addRequestMode (NSString rmode) { return invokeObjcSelf!(void, "addRequestMode:", NSString)(rmode); } void removeRequestMode (NSString rmode) { return invokeObjcSelf!(void, "removeRequestMode:", NSString)(rmode); } NSArray requestModes () { return invokeObjcSelf!(NSArray, "requestModes"); } bool registerName (NSString name) { return invokeObjcSelf!(bool, "registerName:", NSString)(name); } bool registerName (NSString name, NSPortNameServer server) { return invokeObjcSelf!(bool, "registerName:withNameServer:", NSString, NSPortNameServer)(name, server); } static Object connectionWithReceivePort (NSPort receivePort, NSPort sendPort) { return invokeObjcSuperClass!(Object, "connectionWithReceivePort:sendPort:", NSPort, NSPort)(receivePort, sendPort); } static Object currentConversation () { return invokeObjcSuperClass!(Object, "currentConversation"); } Object initWithReceivePort (NSPort receivePort, NSPort sendPort) { return invokeObjcSelf!(Object, "initWithReceivePort:sendPort:", NSPort, NSPort)(receivePort, sendPort); } this (NSPort receivePort, NSPort sendPort) { typeof(this).alloc.initWithReceivePort(receivePort, sendPort); } NSPort sendPort () { return invokeObjcSelf!(NSPort, "sendPort"); } NSPort receivePort () { return invokeObjcSelf!(NSPort, "receivePort"); } void enableMultipleThreads () { return invokeObjcSelf!(void, "enableMultipleThreads"); } bool multipleThreadsEnabled () { return invokeObjcSelf!(bool, "multipleThreadsEnabled"); } void addRunLoop (NSRunLoop runloop) { return invokeObjcSelf!(void, "addRunLoop:", NSRunLoop)(runloop); } void removeRunLoop (NSRunLoop runloop) { return invokeObjcSelf!(void, "removeRunLoop:", NSRunLoop)(runloop); } void runInNewThread () { return invokeObjcSelf!(void, "runInNewThread"); } NSArray remoteObjects () { return invokeObjcSelf!(NSArray, "remoteObjects"); } NSArray localObjects () { return invokeObjcSelf!(NSArray, "localObjects"); } }