Mercurial > projects > dwt-mac
view dwt/internal/cocoa/NSURLHandle.d @ 1:8b48be5454ce
The internal cocoa classes compile now
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Tue, 19 Aug 2008 17:35:17 +0200 |
parents | 380af2bdd8e5 |
children | f565d3a95c0a |
line wrap: on
line source
/******************************************************************************* * Copyright (c) 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * * Port to the D Programming language: * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.internal.cocoa.NSURLHandle; import dwt.internal.cocoa.id; import dwt.internal.cocoa.NSData; import dwt.internal.cocoa.NSInteger; import dwt.internal.cocoa.NSObject; import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.NSURL; import dwt.internal.cocoa.OS; import objc = dwt.internal.objc.runtime; enum NSURLHandleStatus : NSUInteger { NSURLHandleNotLoaded = 0, NSURLHandleLoadSucceeded, NSURLHandleLoadInProgress, NSURLHandleLoadFailed } alias NSURLHandleStatus.NSURLHandleNotLoaded NSURLHandleNotLoaded; alias NSURLHandleStatus.NSURLHandleLoadSucceeded NSURLHandleLoadSucceeded; alias NSURLHandleStatus.NSURLHandleLoadInProgress NSURLHandleLoadInProgress; alias NSURLHandleStatus.NSURLHandleLoadFailed NSURLHandleLoadFailed; public class NSURLHandle : NSObject { public this () { super(); } public this (objc.id id) { super(id); } public static objc.Class URLHandleClassForURL (NSURL anURL) { return cast(objc.Class) OS.objc_msgSend(OS.class_NSURLHandle, OS.sel_URLHandleClassForURL_1, anURL !is null ? anURL.id_ : null); } public void addClient (id client) { OS.objc_msgSend(this.id_, OS.sel_addClient_1, client !is null ? client.id_ : null); } public NSData availableResourceData () { objc.id result = OS.objc_msgSend(this.id_, OS.sel_availableResourceData); return result !is null ? new NSData(result) : null; } public void backgroundLoadDidFailWithReason (NSString reason) { OS.objc_msgSend(this.id_, OS.sel_backgroundLoadDidFailWithReason_1, reason !is null ? reason.id_ : null); } public void beginLoadInBackground () { OS.objc_msgSend(this.id_, OS.sel_beginLoadInBackground); } public static NSURLHandle cachedHandleForURL (NSURL anURL) { objc.id result = OS.objc_msgSend(OS.class_NSURLHandle, OS.sel_cachedHandleForURL_1, anURL !is null ? anURL.id_ : null); return result !is null ? new NSURLHandle(result) : null; } public static bool canInitWithURL (NSURL anURL) { return OS.objc_msgSend(OS.class_NSURLHandle, OS.sel_canInitWithURL_1, anURL !is null ? anURL.id_ : null) !is null; } public void cancelLoadInBackground () { OS.objc_msgSend(this.id_, OS.sel_cancelLoadInBackground); } public void didLoadBytes (NSData newBytes, bool yorn) { OS.objc_msgSend(this.id_, OS.sel_didLoadBytes_1loadComplete_1, newBytes !is null ? newBytes.id_ : null, yorn); } public void endLoadInBackground () { OS.objc_msgSend(this.id_, OS.sel_endLoadInBackground); } public long expectedResourceDataSize () { return cast(long) OS.objc_msgSend(this.id_, OS.sel_expectedResourceDataSize); } public NSString failureReason () { objc.id result = OS.objc_msgSend(this.id_, OS.sel_failureReason); return result !is null ? new NSString(result) : null; } public void flushCachedData () { OS.objc_msgSend(this.id_, OS.sel_flushCachedData); } public id initWithURL (NSURL anURL, bool willCache) { objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithURL_1cached_1, anURL !is null ? anURL.id_ : null, willCache); return result !is null ? new id(result) : null; } public void loadInBackground () { OS.objc_msgSend(this.id_, OS.sel_loadInBackground); } public NSData loadInForeground () { objc.id result = OS.objc_msgSend(this.id_, OS.sel_loadInForeground); return result !is null ? new NSData(result) : null; } public id propertyForKey (NSString propertyKey) { objc.id result = OS.objc_msgSend(this.id_, OS.sel_propertyForKey_1, propertyKey !is null ? propertyKey.id_ : null); return result !is null ? new id(result) : null; } public id propertyForKeyIfAvailable (NSString propertyKey) { objc.id result = OS.objc_msgSend(this.id_, OS.sel_propertyForKeyIfAvailable_1, propertyKey !is null ? propertyKey.id_ : null); return result !is null ? new id(result) : null; } public static void registerURLHandleClass (objc.Class anURLHandleSubclass) { OS.objc_msgSend(OS.class_NSURLHandle, OS.sel_registerURLHandleClass_1, anURLHandleSubclass); } public void removeClient (id client) { OS.objc_msgSend(this.id_, OS.sel_removeClient_1, client !is null ? client.id_ : null); } public NSData resourceData () { objc.id result = OS.objc_msgSend(this.id_, OS.sel_resourceData); return result !is null ? new NSData(result) : null; } public NSURLHandleStatus status () { return cast(NSURLHandleStatus) OS.objc_msgSend(this.id_, OS.sel_status); } public bool writeData (NSData data) { return OS.objc_msgSend(this.id_, OS.sel_writeData_1, data !is null ? data.id_ : null) !is null; } public bool writeProperty (id propertyValue, NSString propertyKey) { return OS.objc_msgSend(this.id_, OS.sel_writeProperty_1forKey_1, propertyValue !is null ? propertyValue.id_ : null, propertyKey !is null ? propertyKey.id_ : null) !is null; } }