Deprecate WKConnection
[WebKit-https.git] / Source / WebKit / UIProcess / API / Cocoa / WKConnection.mm
index 217628d..1769a50 100644 (file)
 #import "WKRetainPtr.h"
 #import "WKSharedAPICast.h"
 #import "WKStringCF.h"
-#import "WeakObjCPtr.h"
 #import <wtf/RetainPtr.h>
+#import <wtf/WeakObjCPtr.h>
 #import <wtf/text/WTFString.h>
 
-using namespace WebKit;
-
 @implementation WKConnection {
     WeakObjCPtr<id <WKConnectionDelegate>> _delegate;
 }
@@ -51,32 +49,36 @@ using namespace WebKit;
 
 static void didReceiveMessage(WKConnectionRef, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo)
 {
-    WKConnection *connection = (WKConnection *)clientInfo;
+    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+    auto connection = (__bridge WKConnection *)clientInfo;
+    ALLOW_DEPRECATED_DECLARATIONS_END
     auto delegate = connection->_delegate.get();
 
     if ([delegate respondsToSelector:@selector(connection:didReceiveMessageWithName:body:)]) {
         RetainPtr<CFStringRef> nsMessageName = adoptCF(WKStringCopyCFString(kCFAllocatorDefault, messageName));
-        RetainPtr<id> nsMessageBody = static_cast<ObjCObjectGraph*>(toImpl(messageBody))->rootObject();
-        [delegate connection:connection didReceiveMessageWithName:(NSString *)nsMessageName.get() body:nsMessageBody.get()];
+        RetainPtr<id> nsMessageBody = static_cast<WebKit::ObjCObjectGraph*>(WebKit::toImpl(messageBody))->rootObject();
+        [delegate connection:connection didReceiveMessageWithName:(__bridge NSString *)nsMessageName.get() body:nsMessageBody.get()];
     }
 }
 
 static void didClose(WKConnectionRef, const void* clientInfo)
 {
-    WKConnection *connection = (WKConnection *)clientInfo;
+    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+    auto connection = (__bridge WKConnection *)clientInfo;
+    ALLOW_DEPRECATED_DECLARATIONS_END
     auto delegate = connection->_delegate.get();
 
     if ([delegate respondsToSelector:@selector(connectionDidClose:)])
         [delegate connectionDidClose:connection];
 }
 
-static void setUpClient(WKConnection *wrapper, WebConnection& connection)
+static void setUpClient(WKConnection *wrapper, WebKit::WebConnection& connection)
 {
     WKConnectionClientV0 client;
     memset(&client, 0, sizeof(client));
 
     client.base.version = 0;
-    client.base.clientInfo = wrapper;
+    client.base.clientInfo = (__bridge void*)wrapper;
     client.didReceiveMessage = didReceiveMessage;
     client.didClose = didClose;
 
@@ -99,20 +101,20 @@ static void setUpClient(WKConnection *wrapper, WebConnection& connection)
 
 - (void)sendMessageWithName:(NSString *)messageName body:(id)messageBody
 {
-    RefPtr<ObjCObjectGraph> wkMessageBody = ObjCObjectGraph::create(messageBody);
+    RefPtr<WebKit::ObjCObjectGraph> wkMessageBody = WebKit::ObjCObjectGraph::create(messageBody);
     self._connection.postMessage(messageName, wkMessageBody.get());
 }
 
-- (WebConnection&)_connection
+- (WebKit::WebConnection&)_connection
 {
-    return *static_cast<WebConnection*>(object_getIndexedIvars(self));
+    return static_cast<WebKit::WebConnection&>(API::Object::fromWKObjectExtraSpace(self));
 }
 
 #pragma mark WKObject protocol implementation
 
 - (API::Object&)_apiObject
 {
-    return *static_cast<API::Object*>(object_getIndexedIvars(self));
+    return API::Object::fromWKObjectExtraSpace(self);
 }
 
 @end