Mercurial > projects > dstep
view dstep/foundation/NSURLRequest.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.NSURLRequest; import dstep.foundation.NSCoder; import dstep.foundation.NSData; import dstep.foundation.NSDate; import dstep.foundation.NSDictionary; import dstep.foundation.NSObjCRuntime; import dstep.foundation.NSObject; import dstep.foundation.NSStream; import dstep.foundation.NSString; import dstep.foundation.NSURL; import dstep.foundation.NSZone; import dstep.objc.bridge.Bridge; import dstep.objc.objc; alias NSUInteger NSURLRequestCachePolicy; enum { NSURLRequestUseProtocolCachePolicy = 0, NSURLRequestReloadIgnoringLocalCacheData = 1, NSURLRequestReloadIgnoringLocalAndRemoteCacheData = 4, NSURLRequestReloadIgnoringCacheData = NSURLRequestReloadIgnoringLocalCacheData, NSURLRequestReturnCacheDataElseLoad = 2, NSURLRequestReturnCacheDataDontLoad = 3, NSURLRequestReloadRevalidatingCacheData = 5 } const TNSHTTPURLRequest = ` NSString HTTPMethod () { return invokeObjcSelf!(NSString, "HTTPMethod"); } NSDictionary allHTTPHeaderFields () { return invokeObjcSelf!(NSDictionary, "allHTTPHeaderFields"); } NSString valueForHTTPHeaderField (NSString field) { return invokeObjcSelf!(NSString, "valueForHTTPHeaderField:", NSString)(field); } NSData HTTPBody () { return invokeObjcSelf!(NSData, "HTTPBody"); } NSInputStream HTTPBodyStream () { return invokeObjcSelf!(NSInputStream, "HTTPBodyStream"); } bool HTTPShouldHandleCookies () { return invokeObjcSelf!(bool, "HTTPShouldHandleCookies"); } `; const TNSMutableHTTPURLRequest = ` void setHTTPMethod (NSString method) { return invokeObjcSelf!(void, "setHTTPMethod:", NSString)(method); } void setAllHTTPHeaderFields (NSDictionary headerFields) { return invokeObjcSelf!(void, "setAllHTTPHeaderFields:", NSDictionary)(headerFields); } void setValue (NSString value, NSString field) { return invokeObjcSelf!(void, "setValue:forHTTPHeaderField:", NSString, NSString)(value, field); } void addValue (NSString value, NSString field) { return invokeObjcSelf!(void, "addValue:forHTTPHeaderField:", NSString, NSString)(value, field); } void setHTTPBody (NSData data) { return invokeObjcSelf!(void, "setHTTPBody:", NSData)(data); } void setHTTPBodyStream (NSInputStream inputStream) { return invokeObjcSelf!(void, "setHTTPBodyStream:", NSInputStream)(inputStream); } void setHTTPShouldHandleCookies (bool should) { return invokeObjcSelf!(void, "setHTTPShouldHandleCookies:", bool)(should); } `; class NSURLRequest : NSObject, INSCoding, INSCopying, INSMutableCopying { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } static Object requestWithURL (NSURL URL) { return invokeObjcSuperClass!(Object, "requestWithURL:", NSURL)(URL); } static Object requestWithURL (NSURL URL, uint cachePolicy, double timeoutInterval) { return invokeObjcSuperClass!(Object, "requestWithURL:cachePolicy:timeoutInterval:", NSURL, uint, double)(URL, cachePolicy, timeoutInterval); } Object initWithURL (NSURL URL) { return invokeObjcSelf!(Object, "initWithURL:", NSURL)(URL); } this (NSURL URL) { typeof(this).alloc.initWithURL(URL); } Object initWithURL (NSURL URL, uint cachePolicy, double timeoutInterval) { return invokeObjcSelf!(Object, "initWithURL:cachePolicy:timeoutInterval:", NSURL, uint, double)(URL, cachePolicy, timeoutInterval); } this (NSURL URL, uint cachePolicy, double timeoutInterval) { typeof(this).alloc.initWithURL(URL, cachePolicy, timeoutInterval); } NSURL URL () { return invokeObjcSelf!(NSURL, "URL"); } uint cachePolicy () { return invokeObjcSelf!(uint, "cachePolicy"); } double timeoutInterval () { return invokeObjcSelf!(double, "timeoutInterval"); } NSURL mainDocumentURL () { return invokeObjcSelf!(NSURL, "mainDocumentURL"); } 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); } Object copyWithZone (NSZone* zone) { return invokeObjcSelf!(Object, "copyWithZone:", NSZone*)(zone); } Object mutableCopyWithZone (NSZone* zone) { return invokeObjcSelf!(Object, "mutableCopyWithZone:", NSZone*)(zone); } // TNSHTTPURLRequest NSString HTTPMethod () { return invokeObjcSelf!(NSString, "HTTPMethod"); } NSDictionary allHTTPHeaderFields () { return invokeObjcSelf!(NSDictionary, "allHTTPHeaderFields"); } NSString valueForHTTPHeaderField (NSString field) { return invokeObjcSelf!(NSString, "valueForHTTPHeaderField:", NSString)(field); } NSData HTTPBody () { return invokeObjcSelf!(NSData, "HTTPBody"); } NSInputStream HTTPBodyStream () { return invokeObjcSelf!(NSInputStream, "HTTPBodyStream"); } bool HTTPShouldHandleCookies () { return invokeObjcSelf!(bool, "HTTPShouldHandleCookies"); } } class NSMutableURLRequest : NSURLRequest { mixin (ObjcWrap); this () { super(typeof(this).alloc.init.objcObject); } typeof(this) init () { return invokeObjcSelf!(typeof(this), "init"); } void setURL (NSURL URL) { return invokeObjcSelf!(void, "setURL:", NSURL)(URL); } void setCachePolicy (uint policy) { return invokeObjcSelf!(void, "setCachePolicy:", uint)(policy); } void setTimeoutInterval (double seconds) { return invokeObjcSelf!(void, "setTimeoutInterval:", double)(seconds); } void setMainDocumentURL (NSURL URL) { return invokeObjcSelf!(void, "setMainDocumentURL:", NSURL)(URL); } // TNSMutableHTTPURLRequest void setHTTPMethod (NSString method) { return invokeObjcSelf!(void, "setHTTPMethod:", NSString)(method); } void setAllHTTPHeaderFields (NSDictionary headerFields) { return invokeObjcSelf!(void, "setAllHTTPHeaderFields:", NSDictionary)(headerFields); } void setValue (NSString value, NSString field) { return invokeObjcSelf!(void, "setValue:forHTTPHeaderField:", NSString, NSString)(value, field); } void addValue (NSString value, NSString field) { return invokeObjcSelf!(void, "addValue:forHTTPHeaderField:", NSString, NSString)(value, field); } void setHTTPBody (NSData data) { return invokeObjcSelf!(void, "setHTTPBody:", NSData)(data); } void setHTTPBodyStream (NSInputStream inputStream) { return invokeObjcSelf!(void, "setHTTPBodyStream:", NSInputStream)(inputStream); } void setHTTPShouldHandleCookies (bool should) { return invokeObjcSelf!(void, "setHTTPShouldHandleCookies:", bool)(should); } }