Mercurial > projects > dstep
view dstep/foundation/NSFileHandle.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 | 89f3c3ef1fd2 |
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.NSFileHandle; import dstep.foundation.NSArray; import dstep.foundation.NSData; import dstep.foundation.NSObjCRuntime; import dstep.foundation.NSObject; import dstep.foundation.NSRange; import dstep.foundation.NSString; import dstep.objc.bridge.Bridge; import dstep.objc.objc; import bindings = dstep.foundation.NSFileHandle_bindings; private { NSString NSFileHandleOperationException_; NSString NSFileHandleReadCompletionNotification_; NSString NSFileHandleReadToEndOfFileCompletionNotification_; NSString NSFileHandleConnectionAcceptedNotification_; NSString NSFileHandleDataAvailableNotification_; NSString NSFileHandleNotificationDataItem_; NSString NSFileHandleNotificationFileHandleItem_; NSString NSFileHandleNotificationMonitorModes_; } NSString NSFileHandleOperationException () { if (NSFileHandleOperationException_) return NSFileHandleOperationException_; return NSFileHandleOperationException_ = new NSString(bindings.NSFileHandleOperationException); } NSString NSFileHandleReadCompletionNotification () { if (NSFileHandleReadCompletionNotification_) return NSFileHandleReadCompletionNotification_; return NSFileHandleReadCompletionNotification_ = new NSString(bindings.NSFileHandleReadCompletionNotification); } NSString NSFileHandleReadToEndOfFileCompletionNotification () { if (NSFileHandleReadToEndOfFileCompletionNotification_) return NSFileHandleReadToEndOfFileCompletionNotification_; return NSFileHandleReadToEndOfFileCompletionNotification_ = new NSString(bindings.NSFileHandleReadToEndOfFileCompletionNotification); } NSString NSFileHandleConnectionAcceptedNotification () { if (NSFileHandleConnectionAcceptedNotification_) return NSFileHandleConnectionAcceptedNotification_; return NSFileHandleConnectionAcceptedNotification_ = new NSString(bindings.NSFileHandleConnectionAcceptedNotification); } NSString NSFileHandleDataAvailableNotification () { if (NSFileHandleDataAvailableNotification_) return NSFileHandleDataAvailableNotification_; return NSFileHandleDataAvailableNotification_ = new NSString(bindings.NSFileHandleDataAvailableNotification); } NSString NSFileHandleNotificationDataItem () { if (NSFileHandleNotificationDataItem_) return NSFileHandleNotificationDataItem_; return NSFileHandleNotificationDataItem_ = new NSString(bindings.NSFileHandleNotificationDataItem); } NSString NSFileHandleNotificationFileHandleItem () { if (NSFileHandleNotificationFileHandleItem_) return NSFileHandleNotificationFileHandleItem_; return NSFileHandleNotificationFileHandleItem_ = new NSString(bindings.NSFileHandleNotificationFileHandleItem); } NSString NSFileHandleNotificationMonitorModes () { if (NSFileHandleNotificationMonitorModes_) return NSFileHandleNotificationMonitorModes_; return NSFileHandleNotificationMonitorModes_ = new NSString(bindings.NSFileHandleNotificationMonitorModes); } const TNSFileHandleAsynchronousAccess = ` void readInBackgroundAndNotifyForModes (NSArray modes) { return invokeObjcSelf!(void, "readInBackgroundAndNotifyForModes:", NSArray)(modes); } void readInBackgroundAndNotify () { return invokeObjcSelf!(void, "readInBackgroundAndNotify"); } void readToEndOfFileInBackgroundAndNotifyForModes (NSArray modes) { return invokeObjcSelf!(void, "readToEndOfFileInBackgroundAndNotifyForModes:", NSArray)(modes); } void readToEndOfFileInBackgroundAndNotify () { return invokeObjcSelf!(void, "readToEndOfFileInBackgroundAndNotify"); } void acceptConnectionInBackgroundAndNotifyForModes (NSArray modes) { return invokeObjcSelf!(void, "acceptConnectionInBackgroundAndNotifyForModes:", NSArray)(modes); } void acceptConnectionInBackgroundAndNotify () { return invokeObjcSelf!(void, "acceptConnectionInBackgroundAndNotify"); } void waitForDataInBackgroundAndNotifyForModes (NSArray modes) { return invokeObjcSelf!(void, "waitForDataInBackgroundAndNotifyForModes:", NSArray)(modes); } void waitForDataInBackgroundAndNotify () { return invokeObjcSelf!(void, "waitForDataInBackgroundAndNotify"); } `; const TNSFileHandleCreation = ` static Object fileHandleWithStandardInput () { return invokeObjcSuperClass!(Object, "fileHandleWithStandardInput"); } static Object fileHandleWithStandardOutput () { return invokeObjcSuperClass!(Object, "fileHandleWithStandardOutput"); } static Object fileHandleWithStandardError () { return invokeObjcSuperClass!(Object, "fileHandleWithStandardError"); } static Object fileHandleWithNullDevice () { return invokeObjcSuperClass!(Object, "fileHandleWithNullDevice"); } static Object fileHandleForReadingAtPath (NSString path) { return invokeObjcSuperClass!(Object, "fileHandleForReadingAtPath:", NSString)(path); } static Object fileHandleForWritingAtPath (NSString path) { return invokeObjcSuperClass!(Object, "fileHandleForWritingAtPath:", NSString)(path); } static Object fileHandleForUpdatingAtPath (NSString path) { return invokeObjcSuperClass!(Object, "fileHandleForUpdatingAtPath:", NSString)(path); } `; const TNSFileHandlePlatformSpecific = ` Object initWithFileDescriptor (int fd, bool closeopt) { return invokeObjcSelf!(Object, "initWithFileDescriptor:closeOnDealloc:", int, bool)(fd, closeopt); } this (int fd, bool closeopt) { typeof(this).alloc.initWithFileDescriptor(fd, closeopt); } Object initWithFileDescriptor (int fd) { return invokeObjcSelf!(Object, "initWithFileDescriptor:", int)(fd); } this (int fd) { typeof(this).alloc.initWithFileDescriptor(fd); } int fileDescriptor () { return invokeObjcSelf!(int, "fileDescriptor"); } `; class NSPipe : NSObject { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } NSFileHandle fileHandleForReading () { return invokeObjcSelf!(NSFileHandle, "fileHandleForReading"); } NSFileHandle fileHandleForWriting () { return invokeObjcSelf!(NSFileHandle, "fileHandleForWriting"); } static Object pipe () { return invokeObjcSuperClass!(Object, "pipe"); } } class NSFileHandle : NSObject { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } NSData availableData () { return invokeObjcSelf!(NSData, "availableData"); } NSData readDataToEndOfFile () { return invokeObjcSelf!(NSData, "readDataToEndOfFile"); } NSData readDataOfLength (NSUInteger length) { return invokeObjcSelf!(NSData, "readDataOfLength:", NSUInteger)(length); } void writeData (NSData data) { return invokeObjcSelf!(void, "writeData:", NSData)(data); } ulong offsetInFile () { return invokeObjcSelf!(ulong, "offsetInFile"); } ulong seekToEndOfFile () { return invokeObjcSelf!(ulong, "seekToEndOfFile"); } void seekToFileOffset (ulong offset) { return invokeObjcSelf!(void, "seekToFileOffset:", ulong)(offset); } void truncateFileAtOffset (ulong offset) { return invokeObjcSelf!(void, "truncateFileAtOffset:", ulong)(offset); } void synchronizeFile () { return invokeObjcSelf!(void, "synchronizeFile"); } void closeFile () { return invokeObjcSelf!(void, "closeFile"); } // TNSFileHandleAsynchronousAccess void readInBackgroundAndNotifyForModes (NSArray modes) { return invokeObjcSelf!(void, "readInBackgroundAndNotifyForModes:", NSArray)(modes); } void readInBackgroundAndNotify () { return invokeObjcSelf!(void, "readInBackgroundAndNotify"); } void readToEndOfFileInBackgroundAndNotifyForModes (NSArray modes) { return invokeObjcSelf!(void, "readToEndOfFileInBackgroundAndNotifyForModes:", NSArray)(modes); } void readToEndOfFileInBackgroundAndNotify () { return invokeObjcSelf!(void, "readToEndOfFileInBackgroundAndNotify"); } void acceptConnectionInBackgroundAndNotifyForModes (NSArray modes) { return invokeObjcSelf!(void, "acceptConnectionInBackgroundAndNotifyForModes:", NSArray)(modes); } void acceptConnectionInBackgroundAndNotify () { return invokeObjcSelf!(void, "acceptConnectionInBackgroundAndNotify"); } void waitForDataInBackgroundAndNotifyForModes (NSArray modes) { return invokeObjcSelf!(void, "waitForDataInBackgroundAndNotifyForModes:", NSArray)(modes); } void waitForDataInBackgroundAndNotify () { return invokeObjcSelf!(void, "waitForDataInBackgroundAndNotify"); } // TNSFileHandleCreation static Object fileHandleWithStandardInput () { return invokeObjcSuperClass!(Object, "fileHandleWithStandardInput"); } static Object fileHandleWithStandardOutput () { return invokeObjcSuperClass!(Object, "fileHandleWithStandardOutput"); } static Object fileHandleWithStandardError () { return invokeObjcSuperClass!(Object, "fileHandleWithStandardError"); } static Object fileHandleWithNullDevice () { return invokeObjcSuperClass!(Object, "fileHandleWithNullDevice"); } static Object fileHandleForReadingAtPath (NSString path) { return invokeObjcSuperClass!(Object, "fileHandleForReadingAtPath:", NSString)(path); } static Object fileHandleForWritingAtPath (NSString path) { return invokeObjcSuperClass!(Object, "fileHandleForWritingAtPath:", NSString)(path); } static Object fileHandleForUpdatingAtPath (NSString path) { return invokeObjcSuperClass!(Object, "fileHandleForUpdatingAtPath:", NSString)(path); } // TNSFileHandlePlatformSpecific Object initWithFileDescriptor (int fd, bool closeopt) { return invokeObjcSelf!(Object, "initWithFileDescriptor:closeOnDealloc:", int, bool)(fd, closeopt); } this (int fd, bool closeopt) { typeof(this).alloc.initWithFileDescriptor(fd, closeopt); } Object initWithFileDescriptor (int fd) { return invokeObjcSelf!(Object, "initWithFileDescriptor:", int)(fd); } this (int fd) { typeof(this).alloc.initWithFileDescriptor(fd); } int fileDescriptor () { return invokeObjcSelf!(int, "fileDescriptor"); } }