Commit e7ef4326 authored by weinig@apple.com's avatar weinig@apple.com

Move shared WebKit2 API (used by both bundle and main API) to WebKit2/Shared/API

https://bugs.webkit.org/show_bug.cgi?id=46587

Reviewed by Anders Carlsson.

WebKit2: 

- Moves shared types (WKArrayRef, WKDictionaryRef, etc) to Shared/API/c.
- Removes WKBundleBase.h and moves all opaque type declarations to WKBase.h (which
  moves to Shared/API/c).
- Adds WKSharedAPICast.h which includes shared API casting logic and is included
  by both WKAPICast.h and WKBundleAPICast.h now. Moved to using macros for API 
  mappings to reduce verbosity.
- Move windows c API files from UIProcess/API/win to UIProcess/API/C/win.

* Shared/API: Added.
* Shared/API/c: Added.
* Shared/API/c/WKArray.cpp: Copied from UIProcess/API/C/WKArray.cpp.
* Shared/API/c/WKArray.h: Copied from UIProcess/API/C/WKArray.h.
* Shared/API/c/WKBase.h: Copied from UIProcess/API/C/WKBase.h.
* Shared/API/c/WKCertificateInfo.cpp: Copied from UIProcess/API/C/WKCertificateInfo.cpp.
* Shared/API/c/WKCertificateInfo.h: Copied from UIProcess/API/C/WKCertificateInfo.h.
* Shared/API/c/WKData.cpp: Copied from UIProcess/API/C/WKData.cpp.
* Shared/API/c/WKData.h: Copied from UIProcess/API/C/WKData.h.
* Shared/API/c/WKDictionary.cpp: Copied from UIProcess/API/C/WKDictionary.cpp.
* Shared/API/c/WKDictionary.h: Copied from UIProcess/API/C/WKDictionary.h.
* Shared/API/c/WKError.cpp: Copied from UIProcess/API/C/WKError.cpp.
* Shared/API/c/WKError.h: Copied from UIProcess/API/C/WKError.h.
* Shared/API/c/WKMutableArray.cpp: Copied from UIProcess/API/C/WKMutableArray.cpp.
* Shared/API/c/WKMutableArray.h: Copied from UIProcess/API/C/WKMutableArray.h.
* Shared/API/c/WKMutableDictionary.cpp: Copied from UIProcess/API/C/WKMutableDictionary.cpp.
* Shared/API/c/WKMutableDictionary.h: Copied from UIProcess/API/C/WKMutableDictionary.h.
* Shared/API/c/WKNumber.cpp: Copied from UIProcess/API/C/WKNumber.cpp.
* Shared/API/c/WKNumber.h: Copied from UIProcess/API/C/WKNumber.h.
* Shared/API/c/WKSerializedScriptValue.cpp: Copied from UIProcess/API/C/WKSerializedScriptValue.cpp.
* Shared/API/c/WKSerializedScriptValue.h: Copied from UIProcess/API/C/WKSerializedScriptValue.h.
* Shared/API/c/WKSharedAPICast.h: Copied from UIProcess/API/C/WKAPICast.h.
* Shared/API/c/WKString.cpp: Copied from UIProcess/API/C/WKString.cpp.
* Shared/API/c/WKString.h: Copied from UIProcess/API/C/WKString.h.
* Shared/API/c/WKType.cpp: Copied from UIProcess/API/C/WKType.cpp.
* Shared/API/c/WKType.h: Copied from UIProcess/API/C/WKType.h.
* Shared/API/c/WKURL.cpp: Copied from UIProcess/API/C/WKURL.cpp.
* Shared/API/c/WKURL.h: Copied from UIProcess/API/C/WKURL.h.
* Shared/API/c/WKURLRequest.cpp: Copied from UIProcess/API/C/WKURLRequest.cpp.
* Shared/API/c/WKURLRequest.h: Copied from UIProcess/API/C/WKURLRequest.h.
* Shared/API/c/WKURLResponse.cpp: Copied from UIProcess/API/C/WKURLResponse.cpp.
* Shared/API/c/WKURLResponse.h: Copied from UIProcess/API/C/WKURLResponse.h.
* Shared/API/c/cf: Copied from UIProcess/API/C/cf.
* Shared/API/c/mac: Copied from UIProcess/API/C/mac.
* Shared/API/c/win: Added.
* Shared/API/c/win/WKBaseWin.h: Copied from UIProcess/API/win/WKBaseWin.h.
* Shared/API/c/win/WKCertificateInfoWin.cpp: Copied from UIProcess/API/C/win/WKCertificateInfoWin.cpp.
* Shared/API/c/win/WKCertificateInfoWin.h: Copied from UIProcess/API/C/win/WKCertificateInfoWin.h.
* UIProcess/API/C/WKAPICast.h: Replaced.
* UIProcess/API/C/WKArray.cpp: Removed.
* UIProcess/API/C/WKArray.h: Removed.
* UIProcess/API/C/WKBase.h: Removed.
* UIProcess/API/C/WKCertificateInfo.cpp: Removed.
* UIProcess/API/C/WKCertificateInfo.h: Removed.
* UIProcess/API/C/WKData.cpp: Removed.
* UIProcess/API/C/WKData.h: Removed.
* UIProcess/API/C/WKDictionary.cpp: Removed.
* UIProcess/API/C/WKDictionary.h: Removed.
* UIProcess/API/C/WKError.cpp: Removed.
* UIProcess/API/C/WKError.h: Removed.
* UIProcess/API/C/WKMutableArray.cpp: Removed.
* UIProcess/API/C/WKMutableArray.h: Removed.
* UIProcess/API/C/WKMutableDictionary.cpp: Removed.
* UIProcess/API/C/WKMutableDictionary.h: Removed.
* UIProcess/API/C/WKNumber.cpp: Removed.
* UIProcess/API/C/WKNumber.h: Removed.
* UIProcess/API/C/WKSerializedScriptValue.cpp: Removed.
* UIProcess/API/C/WKSerializedScriptValue.h: Removed.
* UIProcess/API/C/WKString.cpp: Removed.
* UIProcess/API/C/WKString.h: Removed.
* UIProcess/API/C/WKType.cpp: Removed.
* UIProcess/API/C/WKType.h: Removed.
* UIProcess/API/C/WKURL.cpp: Removed.
* UIProcess/API/C/WKURL.h: Removed.
* UIProcess/API/C/WKURLRequest.cpp: Removed.
* UIProcess/API/C/WKURLRequest.h: Removed.
* UIProcess/API/C/WKURLResponse.cpp: Removed.
* UIProcess/API/C/WKURLResponse.h: Removed.
* UIProcess/API/C/cf: Removed.
* UIProcess/API/C/cf/WKStringCF.cpp: Removed.
* UIProcess/API/C/cf/WKStringCF.h: Removed.
* UIProcess/API/C/cf/WKURLCF.cpp: Removed.
* UIProcess/API/C/cf/WKURLCF.h: Removed.
* UIProcess/API/C/cf/WKURLRequestCF.cpp: Removed.
* UIProcess/API/C/cf/WKURLRequestCF.h: Removed.
* UIProcess/API/C/cf/WKURLResponseCF.cpp: Removed.
* UIProcess/API/C/cf/WKURLResponseCF.h: Removed.
* UIProcess/API/C/mac: Removed.
* UIProcess/API/C/mac/WKCertificateInfoMac.h: Removed.
* UIProcess/API/C/mac/WKCertificateInfoMac.mm: Removed.
* UIProcess/API/C/mac/WKURLRequestNS.h: Removed.
* UIProcess/API/C/mac/WKURLRequestNS.mm: Removed.
* UIProcess/API/C/mac/WKURLResponseNS.h: Removed.
* UIProcess/API/C/mac/WKURLResponseNS.mm: Removed.
* UIProcess/API/C/win/WKAPICastWin.h: Copied from UIProcess/API/win/WKAPICastWin.h.
* UIProcess/API/C/win/WKBaseWin.h: Copied from UIProcess/API/win/WKBaseWin.h.
* UIProcess/API/C/win/WKCertificateInfoWin.cpp: Removed.
* UIProcess/API/C/win/WKCertificateInfoWin.h: Removed.
* UIProcess/API/C/win/WKView.cpp: Copied from UIProcess/API/win/WKView.cpp.
* UIProcess/API/C/win/WKView.h: Copied from UIProcess/API/win/WKView.h.
* UIProcess/API/win: Removed.
* UIProcess/API/win/WKAPICastWin.h: Removed.
* UIProcess/API/win/WKBaseWin.h: Removed.
* UIProcess/API/win/WKView.cpp: Removed.
* UIProcess/API/win/WKView.h: Removed.
* WebKit2.pro:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/API/c/WKBundle.h:
* WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
* WebProcess/InjectedBundle/API/c/WKBundleBase.h: Removed.
* WebProcess/InjectedBundle/API/c/WKBundleFrame.h:
* WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h:
* WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h:
* WebProcess/InjectedBundle/API/c/WKBundleInitialize.h:
* WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h:
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
* WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
* WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.h:
* WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h:
* win/WebKit2.vcproj:
* win/WebKit2Generated.make:

WebKitTools: 

* WebKitTestRunner/InjectedBundle/InjectedBundle.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 873cacdc
2010-09-26 Sam Weinig <sam@webkit.org>
Reviewed by Anders Carlsson.
Move shared WebKit2 API (used by both bundle and main API) to WebKit2/Shared/API
https://bugs.webkit.org/show_bug.cgi?id=46587
- Moves shared types (WKArrayRef, WKDictionaryRef, etc) to Shared/API/c.
- Removes WKBundleBase.h and moves all opaque type declarations to WKBase.h (which
moves to Shared/API/c).
- Adds WKSharedAPICast.h which includes shared API casting logic and is included
by both WKAPICast.h and WKBundleAPICast.h now. Moved to using macros for API
mappings to reduce verbosity.
- Move windows c API files from UIProcess/API/win to UIProcess/API/C/win.
* Shared/API: Added.
* Shared/API/c: Added.
* Shared/API/c/WKArray.cpp: Copied from UIProcess/API/C/WKArray.cpp.
* Shared/API/c/WKArray.h: Copied from UIProcess/API/C/WKArray.h.
* Shared/API/c/WKBase.h: Copied from UIProcess/API/C/WKBase.h.
* Shared/API/c/WKCertificateInfo.cpp: Copied from UIProcess/API/C/WKCertificateInfo.cpp.
* Shared/API/c/WKCertificateInfo.h: Copied from UIProcess/API/C/WKCertificateInfo.h.
* Shared/API/c/WKData.cpp: Copied from UIProcess/API/C/WKData.cpp.
* Shared/API/c/WKData.h: Copied from UIProcess/API/C/WKData.h.
* Shared/API/c/WKDictionary.cpp: Copied from UIProcess/API/C/WKDictionary.cpp.
* Shared/API/c/WKDictionary.h: Copied from UIProcess/API/C/WKDictionary.h.
* Shared/API/c/WKError.cpp: Copied from UIProcess/API/C/WKError.cpp.
* Shared/API/c/WKError.h: Copied from UIProcess/API/C/WKError.h.
* Shared/API/c/WKMutableArray.cpp: Copied from UIProcess/API/C/WKMutableArray.cpp.
* Shared/API/c/WKMutableArray.h: Copied from UIProcess/API/C/WKMutableArray.h.
* Shared/API/c/WKMutableDictionary.cpp: Copied from UIProcess/API/C/WKMutableDictionary.cpp.
* Shared/API/c/WKMutableDictionary.h: Copied from UIProcess/API/C/WKMutableDictionary.h.
* Shared/API/c/WKNumber.cpp: Copied from UIProcess/API/C/WKNumber.cpp.
* Shared/API/c/WKNumber.h: Copied from UIProcess/API/C/WKNumber.h.
* Shared/API/c/WKSerializedScriptValue.cpp: Copied from UIProcess/API/C/WKSerializedScriptValue.cpp.
* Shared/API/c/WKSerializedScriptValue.h: Copied from UIProcess/API/C/WKSerializedScriptValue.h.
* Shared/API/c/WKSharedAPICast.h: Copied from UIProcess/API/C/WKAPICast.h.
* Shared/API/c/WKString.cpp: Copied from UIProcess/API/C/WKString.cpp.
* Shared/API/c/WKString.h: Copied from UIProcess/API/C/WKString.h.
* Shared/API/c/WKType.cpp: Copied from UIProcess/API/C/WKType.cpp.
* Shared/API/c/WKType.h: Copied from UIProcess/API/C/WKType.h.
* Shared/API/c/WKURL.cpp: Copied from UIProcess/API/C/WKURL.cpp.
* Shared/API/c/WKURL.h: Copied from UIProcess/API/C/WKURL.h.
* Shared/API/c/WKURLRequest.cpp: Copied from UIProcess/API/C/WKURLRequest.cpp.
* Shared/API/c/WKURLRequest.h: Copied from UIProcess/API/C/WKURLRequest.h.
* Shared/API/c/WKURLResponse.cpp: Copied from UIProcess/API/C/WKURLResponse.cpp.
* Shared/API/c/WKURLResponse.h: Copied from UIProcess/API/C/WKURLResponse.h.
* Shared/API/c/cf: Copied from UIProcess/API/C/cf.
* Shared/API/c/mac: Copied from UIProcess/API/C/mac.
* Shared/API/c/win: Added.
* Shared/API/c/win/WKBaseWin.h: Copied from UIProcess/API/win/WKBaseWin.h.
* Shared/API/c/win/WKCertificateInfoWin.cpp: Copied from UIProcess/API/C/win/WKCertificateInfoWin.cpp.
* Shared/API/c/win/WKCertificateInfoWin.h: Copied from UIProcess/API/C/win/WKCertificateInfoWin.h.
* UIProcess/API/C/WKAPICast.h: Replaced.
* UIProcess/API/C/WKArray.cpp: Removed.
* UIProcess/API/C/WKArray.h: Removed.
* UIProcess/API/C/WKBase.h: Removed.
* UIProcess/API/C/WKCertificateInfo.cpp: Removed.
* UIProcess/API/C/WKCertificateInfo.h: Removed.
* UIProcess/API/C/WKData.cpp: Removed.
* UIProcess/API/C/WKData.h: Removed.
* UIProcess/API/C/WKDictionary.cpp: Removed.
* UIProcess/API/C/WKDictionary.h: Removed.
* UIProcess/API/C/WKError.cpp: Removed.
* UIProcess/API/C/WKError.h: Removed.
* UIProcess/API/C/WKMutableArray.cpp: Removed.
* UIProcess/API/C/WKMutableArray.h: Removed.
* UIProcess/API/C/WKMutableDictionary.cpp: Removed.
* UIProcess/API/C/WKMutableDictionary.h: Removed.
* UIProcess/API/C/WKNumber.cpp: Removed.
* UIProcess/API/C/WKNumber.h: Removed.
* UIProcess/API/C/WKSerializedScriptValue.cpp: Removed.
* UIProcess/API/C/WKSerializedScriptValue.h: Removed.
* UIProcess/API/C/WKString.cpp: Removed.
* UIProcess/API/C/WKString.h: Removed.
* UIProcess/API/C/WKType.cpp: Removed.
* UIProcess/API/C/WKType.h: Removed.
* UIProcess/API/C/WKURL.cpp: Removed.
* UIProcess/API/C/WKURL.h: Removed.
* UIProcess/API/C/WKURLRequest.cpp: Removed.
* UIProcess/API/C/WKURLRequest.h: Removed.
* UIProcess/API/C/WKURLResponse.cpp: Removed.
* UIProcess/API/C/WKURLResponse.h: Removed.
* UIProcess/API/C/cf: Removed.
* UIProcess/API/C/cf/WKStringCF.cpp: Removed.
* UIProcess/API/C/cf/WKStringCF.h: Removed.
* UIProcess/API/C/cf/WKURLCF.cpp: Removed.
* UIProcess/API/C/cf/WKURLCF.h: Removed.
* UIProcess/API/C/cf/WKURLRequestCF.cpp: Removed.
* UIProcess/API/C/cf/WKURLRequestCF.h: Removed.
* UIProcess/API/C/cf/WKURLResponseCF.cpp: Removed.
* UIProcess/API/C/cf/WKURLResponseCF.h: Removed.
* UIProcess/API/C/mac: Removed.
* UIProcess/API/C/mac/WKCertificateInfoMac.h: Removed.
* UIProcess/API/C/mac/WKCertificateInfoMac.mm: Removed.
* UIProcess/API/C/mac/WKURLRequestNS.h: Removed.
* UIProcess/API/C/mac/WKURLRequestNS.mm: Removed.
* UIProcess/API/C/mac/WKURLResponseNS.h: Removed.
* UIProcess/API/C/mac/WKURLResponseNS.mm: Removed.
* UIProcess/API/C/win/WKAPICastWin.h: Copied from UIProcess/API/win/WKAPICastWin.h.
* UIProcess/API/C/win/WKBaseWin.h: Copied from UIProcess/API/win/WKBaseWin.h.
* UIProcess/API/C/win/WKCertificateInfoWin.cpp: Removed.
* UIProcess/API/C/win/WKCertificateInfoWin.h: Removed.
* UIProcess/API/C/win/WKView.cpp: Copied from UIProcess/API/win/WKView.cpp.
* UIProcess/API/C/win/WKView.h: Copied from UIProcess/API/win/WKView.h.
* UIProcess/API/win: Removed.
* UIProcess/API/win/WKAPICastWin.h: Removed.
* UIProcess/API/win/WKBaseWin.h: Removed.
* UIProcess/API/win/WKView.cpp: Removed.
* UIProcess/API/win/WKView.h: Removed.
* WebKit2.pro:
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/InjectedBundle/API/c/WKBundle.h:
* WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
* WebProcess/InjectedBundle/API/c/WKBundleBase.h: Removed.
* WebProcess/InjectedBundle/API/c/WKBundleFrame.h:
* WebProcess/InjectedBundle/API/c/WKBundleFramePrivate.h:
* WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h:
* WebProcess/InjectedBundle/API/c/WKBundleInitialize.h:
* WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.h:
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
* WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
* WebProcess/InjectedBundle/API/c/WKBundleRangeHandle.h:
* WebProcess/InjectedBundle/API/c/WKBundleScriptWorld.h:
* win/WebKit2.vcproj:
* win/WebKit2Generated.make:
2010-09-26 Anders Carlsson <andersca@apple.com>
Fix non-Mac builds.
......
......@@ -32,6 +32,8 @@
#include <WebKit2/WKBaseWin.h>
#endif
/* WebKit2 shared types */
typedef uint32_t WKTypeID;
typedef const void* WKTypeRef;
......@@ -41,14 +43,23 @@ typedef struct OpaqueWKArray* WKMutableArrayRef;
typedef const struct OpaqueWKDictionary* WKDictionaryRef;
typedef struct OpaqueWKDictionary* WKMutableDictionaryRef;
typedef const struct OpaqueWKBackForwardList* WKBackForwardListRef;
typedef const struct OpaqueWKBackForwardListItem* WKBackForwardListItemRef;
typedef const struct OpaqueWKBoolean* WKBooleanRef;
typedef const struct OpaqueWKCertificateInfo* WKCertificateInfoRef;
typedef const struct OpaqueWKContext* WKContextRef;
typedef const struct OpaqueWKData* WKDataRef;
typedef const struct OpaqueWKDouble* WKDoubleRef;
typedef const struct OpaqueWKError* WKErrorRef;
typedef const struct OpaqueWKCertificateInfo* WKCertificateInfoRef;
typedef const struct OpaqueWKSerializedScriptValue* WKSerializedScriptValueRef;
typedef const struct OpaqueWKString* WKStringRef;
typedef const struct OpaqueWKUInt64* WKUInt64Ref;
typedef const struct OpaqueWKURL* WKURLRef;
typedef const struct OpaqueWKURLRequest* WKURLRequestRef;
typedef const struct OpaqueWKURLResponse* WKURLResponseRef;
/* WebKit2 main API types */
typedef const struct OpaqueWKBackForwardList* WKBackForwardListRef;
typedef const struct OpaqueWKBackForwardListItem* WKBackForwardListItemRef;
typedef const struct OpaqueWKContext* WKContextRef;
typedef const struct OpaqueWKFormSubmissionListener* WKFormSubmissionListenerRef;
typedef const struct OpaqueWKFrame* WKFrameRef;
typedef const struct OpaqueWKFramePolicyListener* WKFramePolicyListenerRef;
......@@ -56,12 +67,17 @@ typedef const struct OpaqueWKNavigationData* WKNavigationDataRef;
typedef const struct OpaqueWKPage* WKPageRef;
typedef const struct OpaqueWKPageNamespace* WKPageNamespaceRef;
typedef const struct OpaqueWKPreferences* WKPreferencesRef;
typedef const struct OpaqueWKSerializedScriptValue* WKSerializedScriptValueRef;
typedef const struct OpaqueWKString* WKStringRef;
typedef const struct OpaqueWKUInt64* WKUInt64Ref;
typedef const struct OpaqueWKURL* WKURLRef;
typedef const struct OpaqueWKURLRequest* WKURLRequestRef;
typedef const struct OpaqueWKURLResponse* WKURLResponseRef;
/* WebKit2 Bundle types */
typedef const struct OpaqueWKBundle* WKBundleRef;
typedef const struct OpaqueWKBundleFrame* WKBundleFrameRef;
typedef const struct OpaqueWKBundleHitTestResult* WKBundleHitTestResultRef;
typedef const struct OpaqueWKBundleNodeHandle* WKBundleNodeHandleRef;
typedef const struct OpaqueWKBundlePage* WKBundlePageRef;
typedef const struct OpaqueWKBundleRangeHandle* WKBundleRangeHandleRef;
typedef const struct OpaqueWKBundleScriptWorld* WKBundleScriptWorldRef;
typedef const struct OpaqueWKBundleDOMCSSStyleDeclaration* WKBundleCSSStyleDeclarationRef;
#undef WK_EXPORT
#if defined(WK_NO_EXPORT)
......
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WKSharedAPICast_h
#define WKSharedAPICast_h
#include "WKBase.h"
#include "WebNumber.h"
#include "WebString.h"
#include "WebURL.h"
#include <wtf/TypeTraits.h>
namespace WebKit {
class ImmutableArray;
class ImmutableDictionary;
class MutableArray;
class MutableDictionary;
class WebCertificateInfo;
class WebData;
class WebError;
class WebSerializedScriptValue;
class WebURLRequest;
class WebURLResponse;
template<typename APIType> struct APITypeInfo { };
template<typename ImplType> struct ImplTypeInfo { };
#define WK_ADD_API_MAPPING(TheAPIType, TheImplType) \
template<> struct APITypeInfo<TheAPIType> { typedef TheImplType* ImplType; }; \
template<> struct ImplTypeInfo<TheImplType*> { typedef TheAPIType APIType; };
WK_ADD_API_MAPPING(WKArrayRef, ImmutableArray)
WK_ADD_API_MAPPING(WKBooleanRef, WebBoolean)
WK_ADD_API_MAPPING(WKCertificateInfoRef, WebCertificateInfo)
WK_ADD_API_MAPPING(WKDataRef, WebData)
WK_ADD_API_MAPPING(WKDictionaryRef, ImmutableDictionary)
WK_ADD_API_MAPPING(WKDoubleRef, WebDouble)
WK_ADD_API_MAPPING(WKErrorRef, WebError)
WK_ADD_API_MAPPING(WKMutableArrayRef, MutableArray)
WK_ADD_API_MAPPING(WKMutableDictionaryRef, MutableDictionary)
WK_ADD_API_MAPPING(WKSerializedScriptValueRef, WebSerializedScriptValue)
WK_ADD_API_MAPPING(WKStringRef, WebString)
WK_ADD_API_MAPPING(WKTypeRef, APIObject)
WK_ADD_API_MAPPING(WKUInt64Ref, WebUInt64)
WK_ADD_API_MAPPING(WKURLRef, WebURL)
WK_ADD_API_MAPPING(WKURLRequestRef, WebURLRequest)
WK_ADD_API_MAPPING(WKURLResponseRef, WebURLResponse)
template<typename ImplType, typename APIType = typename ImplTypeInfo<ImplType*>::APIType>
class ProxyingRefPtr {
public:
ProxyingRefPtr(PassRefPtr<ImplType> impl)
: m_impl(impl)
{
}
operator APIType() { return toRef(m_impl.get()); }
private:
RefPtr<ImplType> m_impl;
};
/* Opaque typing convenience methods */
template<typename T>
inline typename APITypeInfo<T>::ImplType toWK(T t)
{
// An example of the conversions that take place:
// const struct OpaqueWKArray* -> const struct OpaqueWKArray -> struct OpaqueWKArray -> struct OpaqueWKArray* -> ImmutableArray*
typedef typename WTF::RemovePointer<T>::Type PotentiallyConstValueType;
typedef typename WTF::RemoveConst<PotentiallyConstValueType>::Type NonConstValueType;
return reinterpret_cast<typename APITypeInfo<T>::ImplType>(const_cast<NonConstValueType*>(t));
}
template<typename T>
inline typename ImplTypeInfo<T>::APIType toRef(T t)
{
return reinterpret_cast<typename ImplTypeInfo<T>::APIType>(t);
}
/* Special cases. */
inline ProxyingRefPtr<WebString> toRef(StringImpl* string)
{
StringImpl* impl = string ? string : StringImpl::empty();
return ProxyingRefPtr<WebString>(WebString::create(String(impl)));
}
inline ProxyingRefPtr<WebURL> toURLRef(StringImpl* string)
{
StringImpl* impl = string ? string : StringImpl::empty();
return ProxyingRefPtr<WebURL>(WebURL::create(String(impl)));
}
inline WKStringRef toCopiedRef(const String& string)
{
StringImpl* impl = string.impl() ? string.impl() : StringImpl::empty();
RefPtr<WebString> webString = WebString::create(String(impl));
return toRef(webString.release().releaseRef());
}
inline WKURLRef toCopiedURLRef(const String& string)
{
StringImpl* impl = string.impl() ? string.impl() : StringImpl::empty();
RefPtr<WebURL> webURL = WebURL::create(String(impl));
return toRef(webURL.release().releaseRef());
}
inline String toWTFString(WKStringRef stringRef)
{
if (!stringRef)
return String();
return toWK(stringRef)->string();
}
inline String toWTFString(WKURLRef urlRef)
{
if (!urlRef)
return String();
return toWK(urlRef)->string();
}
/* Enum conversions */
inline WKTypeID toRef(APIObject::Type type)
{
return static_cast<WKTypeID>(type);
}
} // namespace WebKit
#endif // WKSharedAPICast_h
......@@ -26,31 +26,16 @@
#ifndef WKAPICast_h
#define WKAPICast_h
#include "WKBase.h"
#include "WKSharedAPICast.h"
#include "WKPage.h"
#include "WebEvent.h"
#include "WebNumber.h"
#include "WebString.h"
#include "WebURL.h"
#include <WebCore/FrameLoaderTypes.h>
#include <wtf/TypeTraits.h>
#if defined(WIN32) || defined(_WIN32)
#include "WKAPICastWin.h"
#endif
namespace WebKit {
class ImmutableArray;
class ImmutableDictionary;
class MutableArray;
class MutableDictionary;
class WebBackForwardList;
class WebBackForwardListItem;
class WebCertificateInfo;
class WebContext;
class WebData;
class WebError;
class WebFormSubmissionListenerProxy;
class WebFramePolicyListenerProxy;
class WebFrameProxy;
......@@ -58,150 +43,20 @@ class WebNavigationData;
class WebPageNamespace;
class WebPageProxy;
class WebPreferences;
class WebSerializedScriptValue;
class WebURLRequest;
class WebURLResponse;
template<typename APIType> struct APITypeInfo { };
template<> struct APITypeInfo<WKArrayRef> { typedef ImmutableArray* ImplType; };
template<> struct APITypeInfo<WKBackForwardListItemRef> { typedef WebBackForwardListItem* ImplType; };
template<> struct APITypeInfo<WKBackForwardListRef> { typedef WebBackForwardList* ImplType; };
template<> struct APITypeInfo<WKBooleanRef> { typedef WebBoolean* ImplType; };
template<> struct APITypeInfo<WKCertificateInfoRef> { typedef WebCertificateInfo* ImplType; };
template<> struct APITypeInfo<WKContextRef> { typedef WebContext* ImplType; };
template<> struct APITypeInfo<WKDataRef> { typedef WebData* ImplType; };
template<> struct APITypeInfo<WKDictionaryRef> { typedef ImmutableDictionary* ImplType; };
template<> struct APITypeInfo<WKDoubleRef> { typedef WebDouble* ImplType; };
template<> struct APITypeInfo<WKFormSubmissionListenerRef> { typedef WebFormSubmissionListenerProxy* ImplType; };
template<> struct APITypeInfo<WKFramePolicyListenerRef> { typedef WebFramePolicyListenerProxy* ImplType; };
template<> struct APITypeInfo<WKFrameRef> { typedef WebFrameProxy* ImplType; };
template<> struct APITypeInfo<WKMutableArrayRef> { typedef MutableArray* ImplType; };
template<> struct APITypeInfo<WKMutableDictionaryRef> { typedef MutableDictionary* ImplType; };
template<> struct APITypeInfo<WKNavigationDataRef> { typedef WebNavigationData* ImplType; };
template<> struct APITypeInfo<WKPageNamespaceRef> { typedef WebPageNamespace* ImplType; };
template<> struct APITypeInfo<WKPageRef> { typedef WebPageProxy* ImplType; };
template<> struct APITypeInfo<WKPreferencesRef> { typedef WebPreferences* ImplType; };
template<> struct APITypeInfo<WKSerializedScriptValueRef> { typedef WebSerializedScriptValue* ImplType; };
template<> struct APITypeInfo<WKStringRef> { typedef WebString* ImplType; };
template<> struct APITypeInfo<WKTypeRef> { typedef APIObject* ImplType; };
template<> struct APITypeInfo<WKUInt64Ref> { typedef WebUInt64* ImplType; };
template<> struct APITypeInfo<WKURLRef> { typedef WebURL* ImplType; };
template<> struct APITypeInfo<WKURLRequestRef> { typedef WebURLRequest* ImplType; };
template<> struct APITypeInfo<WKURLResponseRef> { typedef WebURLResponse* ImplType; };
template<typename ImplType> struct ImplTypeInfo { };
template<> struct ImplTypeInfo<APIObject*> { typedef WKTypeRef APIType; };
template<> struct ImplTypeInfo<ImmutableArray*> { typedef WKArrayRef APIType; };
template<> struct ImplTypeInfo<ImmutableDictionary*> { typedef WKDictionaryRef APIType; };
template<> struct ImplTypeInfo<MutableArray*> { typedef WKMutableArrayRef APIType; };
template<> struct ImplTypeInfo<MutableDictionary*> { typedef WKMutableDictionaryRef APIType; };
template<> struct ImplTypeInfo<WebBackForwardList*> { typedef WKBackForwardListRef APIType; };
template<> struct ImplTypeInfo<WebBackForwardListItem*> { typedef WKBackForwardListItemRef APIType; };
template<> struct ImplTypeInfo<WebBoolean*> { typedef WKBooleanRef APIType; };
template<> struct ImplTypeInfo<WebCertificateInfo*> { typedef WKCertificateInfoRef APIType; };
template<> struct ImplTypeInfo<WebContext*> { typedef WKContextRef APIType; };
template<> struct ImplTypeInfo<WebData*> { typedef WKDataRef APIType; };
template<> struct ImplTypeInfo<WebDouble*> { typedef WKDoubleRef APIType; };
template<> struct ImplTypeInfo<WebError*> { typedef WKErrorRef APIType; };
template<> struct ImplTypeInfo<WebFormSubmissionListenerProxy*> { typedef WKFormSubmissionListenerRef APIType; };
template<> struct ImplTypeInfo<WebFramePolicyListenerProxy*> { typedef WKFramePolicyListenerRef APIType; };
template<> struct ImplTypeInfo<WebFrameProxy*> { typedef WKFrameRef APIType; };
template<> struct ImplTypeInfo<WebNavigationData*> { typedef WKNavigationDataRef APIType; };
template<> struct ImplTypeInfo<WebPageNamespace*> { typedef WKPageNamespaceRef APIType; };
template<> struct ImplTypeInfo<WebPageProxy*> { typedef WKPageRef APIType; };
template<> struct ImplTypeInfo<WebPreferences*> { typedef WKPreferencesRef APIType; };
template<> struct ImplTypeInfo<WebSerializedScriptValue*> { typedef WKSerializedScriptValueRef APIType; };
template<> struct ImplTypeInfo<WebString*> { typedef WKStringRef APIType; };
template<> struct ImplTypeInfo<WebUInt64*> { typedef WKUInt64Ref APIType; };
template<> struct ImplTypeInfo<WebURL*> { typedef WKURLRef APIType; };
template<> struct ImplTypeInfo<WebURLRequest*> { typedef WKURLRequestRef APIType; };
template<> struct ImplTypeInfo<WebURLResponse*> { typedef WKURLResponseRef APIType; };
template<typename ImplType, typename APIType = typename ImplTypeInfo<ImplType*>::APIType>
class ProxyingRefPtr {
public:
ProxyingRefPtr(PassRefPtr<ImplType> impl)
: m_impl(impl)
{
}
operator APIType() { return toRef(m_impl.get()); }
private:
RefPtr<ImplType> m_impl;
};
/* Opaque typing convenience methods */
template<typename T>
inline typename APITypeInfo<T>::ImplType toWK(T t)
{
// An example of the conversions that take place:
// const struct OpaqueWKArray* -> const struct OpaqueWKArray -> struct OpaqueWKArray -> struct OpaqueWKArray* -> ImmutableArray*
typedef typename WTF::RemovePointer<T>::Type PotentiallyConstValueType;
typedef typename WTF::RemoveConst<PotentiallyConstValueType>::Type NonConstValueType;
return reinterpret_cast<typename APITypeInfo<T>::ImplType>(const_cast<NonConstValueType*>(t));
}
template<typename T>
inline typename ImplTypeInfo<T>::APIType toRef(T t)
{
return reinterpret_cast<typename ImplTypeInfo<T>::APIType>(t);
}
/* Special cases. */
inline ProxyingRefPtr<WebString> toRef(StringImpl* string)
{
StringImpl* impl = string ? string : StringImpl::empty();
return ProxyingRefPtr<WebString>(WebString::create(String(impl)));
}
inline ProxyingRefPtr<WebURL> toURLRef(StringImpl* string)
{
StringImpl* impl = string ? string : StringImpl::empty();
return ProxyingRefPtr<WebURL>(WebURL::create(String(impl)));
}
inline WKStringRef toCopiedRef(const String& string)
{
StringImpl* impl = string.impl() ? string.impl() : StringImpl::empty();
RefPtr<WebString> webString = WebString::create(String(impl));
return toRef(webString.release().releaseRef());
}
inline WKURLRef toCopiedURLRef(const String& string)
{
StringImpl* impl = string.impl() ? string.impl() : StringImpl::empty();
RefPtr<WebURL> webURL = WebURL::create(String(impl));
return toRef(webURL.release().releaseRef());
}
inline String toWTFString(WKStringRef stringRef)
{
if (!stringRef)
return String();
return toWK(stringRef)->string();
}
inline String toWTFString(WKURLRef urlRef)
{
if (!urlRef)
return String();
return toWK(urlRef)->string();
}
WK_ADD_API_MAPPING(WKBackForwardListItemRef, WebBackForwardListItem)
WK_ADD_API_MAPPING(WKBackForwardListRef, WebBackForwardList)
WK_ADD_API_MAPPING(WKContextRef, WebContext)
WK_ADD_API_MAPPING(WKFormSubmissionListenerRef, WebFormSubmissionListenerProxy)
WK_ADD_API_MAPPING(WKFramePolicyListenerRef, WebFramePolicyListenerProxy)
WK_ADD_API_MAPPING(WKFrameRef, WebFrameProxy)
WK_ADD_API_MAPPING(WKNavigationDataRef, WebNavigationData)
WK_ADD_API_MAPPING(WKPageNamespaceRef, WebPageNamespace)
WK_ADD_API_MAPPING(WKPageRef, WebPageProxy)
WK_ADD_API_MAPPING(WKPreferencesRef, WebPreferences)
/* Enum conversions */
inline WKTypeID toRef(APIObject::Type type)
{
return static_cast<WKTypeID>(type);
}
inline WKFrameNavigationType toRef(WebCore::NavigationType type)
{
WKFrameNavigationType wkType = kWKFrameNavigationTypeOther;
......@@ -268,4 +123,8 @@ inline WKEventMouseButton toRef(WebMouseEvent::Button mouseButton)
} // namespace WebKit
#if defined(WIN32) || defined(_WIN32)
#include "WKAPICastWin.h"
#endif
#endif // WKAPICast_h
......@@ -31,17 +31,11 @@
#endif
namespace WebKit {
class WebView;
}
inline WebKit::WebView* toWK(WKViewRef v)
{
return reinterpret_cast<WebKit::WebView*>(const_cast<OpaqueWKView*>(v));
}
class WebView;
WK_ADD_API_MAPPING(WKViewRef, WebView)
inline WKViewRef toRef(WebKit::WebView* v)
{
return reinterpret_cast<WKViewRef>(v);
}