Mercurial > projects > dwt-mac
view dwt/internal/cocoa/NSURLProtocol.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.NSURLProtocol; import dwt.internal.cocoa.id; import dwt.internal.cocoa.NSCachedURLResponse; import dwt.internal.cocoa.NSMutableURLRequest; import dwt.internal.cocoa.NSObject; import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.NSURLRequest; import dwt.internal.cocoa.OS; import objc = dwt.internal.objc.runtime; public class NSURLProtocol : NSObject { public this () { super(); } public this (objc.id id) { super(id); } public NSCachedURLResponse cachedResponse () { objc.id result = OS.objc_msgSend(this.id_, OS.sel_cachedResponse); return result !is null ? new NSCachedURLResponse(result) : null; } public static bool canInitWithRequest (NSURLRequest request) { return OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_canInitWithRequest_1, request !is null ? request.id_ : null) !is null; } public static NSURLRequest canonicalRequestForRequest (NSURLRequest request) { objc.id result = OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_canonicalRequestForRequest_1, request !is null ? request.id_ : null); return result !is null ? new NSURLRequest(result) : null; } public id client () { objc.id result = OS.objc_msgSend(this.id_, OS.sel_client); return result !is null ? new id(result) : null; } public id initWithRequest (NSURLRequest request, NSCachedURLResponse cachedResponse, id client) { objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithRequest_1cachedResponse_1client_1, request !is null ? request.id_ : null, cachedResponse !is null ? cachedResponse.id_ : null, client !is null ? client.id_ : null); return result !is null ? new id(result) : null; } public static id propertyForKey (NSString key, NSURLRequest request) { objc.id result = OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_propertyForKey_1inRequest_1, key !is null ? key.id_ : null, request !is null ? request.id_ : null); return result !is null ? new id(result) : null; } public static bool registerClass (objc.Class protocolClass) { return OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_registerClass_1, protocolClass) !is null; } public static void removePropertyForKey (NSString key, NSMutableURLRequest request) { OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_removePropertyForKey_1inRequest_1, key !is null ? key.id_ : null, request !is null ? request.id_ : null); } public NSURLRequest request () { objc.id result = OS.objc_msgSend(this.id_, OS.sel_request); return result !is null ? new NSURLRequest(result) : null; } public static bool requestIsCacheEquivalent (NSURLRequest a, NSURLRequest b) { return OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_requestIsCacheEquivalent_1toRequest_1, a !is null ? a.id_ : null, b !is null ? b.id_ : null) !is null; } public static void setProperty (id value, NSString key, NSMutableURLRequest request) { OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_setProperty_1forKey_1inRequest_1, value !is null ? value.id_ : null, key !is null ? key.id_ : null, request !is null ? request.id_ : null); } public void startLoading () { OS.objc_msgSend(this.id_, OS.sel_startLoading); } public void stopLoading () { OS.objc_msgSend(this.id_, OS.sel_stopLoading); } public static void unregisterClass (objc.Class protocolClass) { OS.objc_msgSend(OS.class_NSURLProtocol, OS.sel_unregisterClass_1, protocolClass); } }