Mercurial > projects > dstep
view dstep/foundation/NSURLHandle.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.NSURLHandle; import dstep.foundation.NSData; import dstep.foundation.NSObjCRuntime; import dstep.foundation.NSObject; import dstep.foundation.NSString; import dstep.foundation.NSURL; import dstep.internal.Version; import dstep.objc.bridge.Bridge; import dstep.objc.objc; alias NSUInteger NSURLHandleStatus; enum { NSURLHandleNotLoaded = 0, NSURLHandleLoadSucceeded, NSURLHandleLoadInProgress, NSURLHandleLoadFailed } class NSURLHandle : NSObject { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } static void registerURLHandleClass (Class anURLHandleSubclass) { return invokeObjcSuperClass!(void, "registerURLHandleClass:", Class)(anURLHandleSubclass); } static Class URLHandleClassForURL (NSURL anURL) { return invokeObjcSuperClass!(Class, "URLHandleClassForURL:", NSURL)(anURL); } uint status () { return invokeObjcSelf!(uint, "status"); } NSString failureReason () { return invokeObjcSelf!(NSString, "failureReason"); } void addClient (INSURLHandleClient client) { return invokeObjcSelf!(void, "addClient:", INSURLHandleClient)(client); } void removeClient (INSURLHandleClient client) { return invokeObjcSelf!(void, "removeClient:", INSURLHandleClient)(client); } void loadInBackground () { return invokeObjcSelf!(void, "loadInBackground"); } void cancelLoadInBackground () { return invokeObjcSelf!(void, "cancelLoadInBackground"); } NSData resourceData () { return invokeObjcSelf!(NSData, "resourceData"); } NSData availableResourceData () { return invokeObjcSelf!(NSData, "availableResourceData"); } long expectedResourceDataSize () { return invokeObjcSelf!(long, "expectedResourceDataSize"); } void flushCachedData () { return invokeObjcSelf!(void, "flushCachedData"); } void backgroundLoadDidFailWithReason (NSString reason) { return invokeObjcSelf!(void, "backgroundLoadDidFailWithReason:", NSString)(reason); } void didLoadBytes (NSData newBytes, bool yorn) { return invokeObjcSelf!(void, "didLoadBytes:loadComplete:", NSData, bool)(newBytes, yorn); } static bool canInitWithURL (NSURL anURL) { return invokeObjcSuperClass!(bool, "canInitWithURL:", NSURL)(anURL); } static NSURLHandle cachedHandleForURL (NSURL anURL) { return invokeObjcSuperClass!(NSURLHandle, "cachedHandleForURL:", NSURL)(anURL); } Object initWithURL (NSURL anURL, bool willCache) { return invokeObjcSelf!(Object, "initWithURL:cached:", NSURL, bool)(anURL, willCache); } this (NSURL anURL, bool willCache) { typeof(this).alloc.initWithURL(anURL, willCache); } Object propertyForKey (NSString propertyKey) { return invokeObjcSelf!(Object, "propertyForKey:", NSString)(propertyKey); } Object propertyForKeyIfAvailable (NSString propertyKey) { return invokeObjcSelf!(Object, "propertyForKeyIfAvailable:", NSString)(propertyKey); } bool writeProperty (Object propertyValue, NSString propertyKey) { return invokeObjcSelf!(bool, "writeProperty:forKey:", Object, NSString)(propertyValue, propertyKey); } bool writeData (NSData data) { return invokeObjcSelf!(bool, "writeData:", NSData)(data); } NSData loadInForeground () { return invokeObjcSelf!(NSData, "loadInForeground"); } void beginLoadInBackground () { return invokeObjcSelf!(void, "beginLoadInBackground"); } void endLoadInBackground () { return invokeObjcSelf!(void, "endLoadInBackground"); } } interface INSURLHandleClient { void URLHandle (NSURLHandle sender, NSData newBytes); void URLHandleResourceDidBeginLoading (NSURLHandle sender); void URLHandleResourceDidFinishLoading (NSURLHandle sender); void URLHandleResourceDidCancelLoading (NSURLHandle sender); void URLHandle (NSURLHandle sender, NSString reason); }