Move invocation argument encoding out to a separate function
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Nov 2015 22:44:44 +0000 (22:44 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Nov 2015 22:44:44 +0000 (22:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150950

Reviewed by Tim Horton.

* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
(encodeInvocationArguments):
(encodeInvocation):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192081 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm

index 56b6fde..019be5a 100644 (file)
@@ -1,3 +1,14 @@
+2015-11-05  Anders Carlsson  <andersca@apple.com>
+
+        Move invocation argument encoding out to a separate function
+        https://bugs.webkit.org/show_bug.cgi?id=150950
+
+        Reviewed by Tim Horton.
+
+        * Shared/API/Cocoa/WKRemoteObjectCoder.mm:
+        (encodeInvocationArguments):
+        (encodeInvocation):
+
 2015-11-05  Chris Dumez  <cdumez@apple.com>
 
         [WK2] Clean up / Modernize NetworkResourceLoader
index b7a5ea7..802acd2 100644 (file)
@@ -111,18 +111,13 @@ static void encodeToObjectStream(WKRemoteObjectEncoder *encoder, id value)
     encoder->_objectStream->elements()[position] = encodedObject.release();
 }
 
-static void encodeInvocation(WKRemoteObjectEncoder *encoder, NSInvocation *invocation)
+static void encodeInvocationArguments(WKRemoteObjectEncoder *encoder, NSInvocation *invocation, NSUInteger firstArgument)
 {
     NSMethodSignature *methodSignature = invocation.methodSignature;
-    [encoder encodeObject:methodSignature._typeString forKey:typeStringKey];
-    [encoder encodeObject:NSStringFromSelector(invocation.selector) forKey:selectorKey];
-
     NSUInteger argumentCount = methodSignature.numberOfArguments;
 
-    // The invocation should always have have self and _cmd arguments.
-    ASSERT(argumentCount >= 2);
+    ASSERT(firstArgument <= argumentCount);
 
-    // We ignore self and _cmd.
     for (NSUInteger i = 2; i < argumentCount; ++i) {
         const char* type = [methodSignature getArgumentTypeAtIndex:i];
 
@@ -214,6 +209,15 @@ static void encodeInvocation(WKRemoteObjectEncoder *encoder, NSInvocation *invoc
     }
 }
 
+static void encodeInvocation(WKRemoteObjectEncoder *encoder, NSInvocation *invocation)
+{
+    NSMethodSignature *methodSignature = invocation.methodSignature;
+    [encoder encodeObject:methodSignature._typeString forKey:typeStringKey];
+    [encoder encodeObject:NSStringFromSelector(invocation.selector) forKey:selectorKey];
+
+    encodeInvocationArguments(encoder, invocation, 2);
+}
+
 static void encodeString(WKRemoteObjectEncoder *encoder, NSString *string)
 {
     encoder->_currentDictionary->set(stringKey, API::String::create(string));