Diff
Modified: trunk/Source/WebKit2/ChangeLog (158451 => 158452)
--- trunk/Source/WebKit2/ChangeLog 2013-11-01 20:42:25 UTC (rev 158451)
+++ trunk/Source/WebKit2/ChangeLog 2013-11-01 21:00:13 UTC (rev 158452)
@@ -1,3 +1,25 @@
+2013-11-01 Anders Carlsson <ander...@apple.com>
+
+ Begin work on encoding argument types
+ https://bugs.webkit.org/show_bug.cgi?id=123631
+
+ Reviewed by Dan Bernstein.
+
+ * Shared/API/Cocoa/WKRemoteObjectCoder.mm:
+ (-[WKRemoteObjectEncoder _encodeInvocation:forKey:]):
+ Encode argument types in an array.
+
+ (-[WKRemoteObjectEncoder _encodedObjectUsingBlock:]):
+ Add new helper method that encodes an object and returns the dictionary.
+
+ (-[WKRemoteObjectEncoder _encodeObjectForKey:usingBlock:]):
+ Implement this in terms of _encodedObjectUsingBlock:.
+
+ * Shared/MutableArray.cpp:
+ (WebKit::MutableArray::append):
+ * Shared/MutableArray.h:
+ Change append to take a PassRefPtr.
+
2013-10-31 Gavin Barraclough <barraclo...@apple.com>
Rename InWindowState -> ViewState
Modified: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm (158451 => 158452)
--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm 2013-11-01 20:42:25 UTC (rev 158451)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm 2013-11-01 21:00:13 UTC (rev 158452)
@@ -26,8 +26,10 @@
#import "config.h"
#import "WKRemoteObjectCoder.h"
+#import "MutableArray.h"
#import "MutableDictionary.h"
#import "WebData.h"
+#import "WebNumber.h"
#import <wtf/TemporaryChange.h>
#if WK_API_ENABLED
@@ -91,7 +93,53 @@
[self encodeObject:methodSignature._typeString forKey:@"typeString"];
[self encodeObject:NSStringFromSelector(invocation.selector) forKey:@"selector"];
- // FIXME: Encode arguments as well.
+ NSUInteger argumentCount = methodSignature.numberOfArguments;
+
+ // The invocation should always have have self and _cmd arguments.
+ ASSERT(argumentCount >= 2);
+
+ RefPtr<MutableArray> arguments = MutableArray::create();
+
+ // We ignore self and _cmd.
+ for (NSUInteger i = 2; i < argumentCount; ++i) {
+ const char* type = [methodSignature getArgumentTypeAtIndex:i];
+
+ switch (*type) {
+ // double
+ case 'i': {
+ int value;
+ [invocation getArgument:&value atIndex:i];
+
+ arguments->append(WebUInt64::create(value));
+ break;
+ }
+
+ // int
+ case 'd': {
+ double value;
+ [invocation getArgument:&value atIndex:i];
+
+ arguments->append(WebDouble::create(value));
+ break;
+ }
+
+ // Objective-C object
+ case '@': {
+ id value;
+ [invocation getArgument:&value atIndex:i];
+
+ arguments->append([self _encodedObjectUsingBlock:^{
+ [value encodeWithCoder:self];
+ }]);
+ break;
+ }
+
+ default:
+ [NSException raise:NSInvalidArgumentException format:@"Unsupported invocation argument type '%s'", type];
+ }
+ }
+
+ _currentDictionary->set("arguments", arguments.release());
}];
}
@@ -100,15 +148,21 @@
_currentDictionary->set(key, WebData::create(bytes, length));
}
-- (void)_encodeObjectForKey:(NSString *)key usingBlock:(void (^)())block
+- (RefPtr<MutableDictionary>)_encodedObjectUsingBlock:(void (^)())block
{
RefPtr<MutableDictionary> dictionary = MutableDictionary::create();
+
TemporaryChange<MutableDictionary*> dictionaryChange(_currentDictionary, dictionary.get());
+ block();
- dictionary->set(key, dictionary.release());
- block();
+ return dictionary;
}
+- (void)_encodeObjectForKey:(NSString *)key usingBlock:(void (^)())block
+{
+ _currentDictionary->set(key, [self _encodedObjectUsingBlock:block]);
+}
+
@end
#endif // WK_API_ENABLED
Modified: trunk/Source/WebKit2/Shared/MutableArray.cpp (158451 => 158452)
--- trunk/Source/WebKit2/Shared/MutableArray.cpp 2013-11-01 20:42:25 UTC (rev 158451)
+++ trunk/Source/WebKit2/Shared/MutableArray.cpp 2013-11-01 21:00:13 UTC (rev 158452)
@@ -36,7 +36,7 @@
{
}
-void MutableArray::append(APIObject* item)
+void MutableArray::append(PassRefPtr<APIObject> item)
{
m_entries.append(item);
}
Modified: trunk/Source/WebKit2/Shared/MutableArray.h (158451 => 158452)
--- trunk/Source/WebKit2/Shared/MutableArray.h 2013-11-01 20:42:25 UTC (rev 158451)
+++ trunk/Source/WebKit2/Shared/MutableArray.h 2013-11-01 21:00:13 UTC (rev 158452)
@@ -27,6 +27,7 @@
#define MutableArray_h
#include "ImmutableArray.h"
+#include <wtf/Forward.h>
namespace WebKit {
@@ -41,7 +42,7 @@
~MutableArray();
- void append(APIObject*);
+ void append(PassRefPtr<APIObject>);
void reserveCapacity(unsigned);
void removeItemAtIndex(unsigned);
Modified: trunk/Tools/ChangeLog (158451 => 158452)
--- trunk/Tools/ChangeLog 2013-11-01 20:42:25 UTC (rev 158451)
+++ trunk/Tools/ChangeLog 2013-11-01 21:00:13 UTC (rev 158452)
@@ -1,3 +1,15 @@
+2013-11-01 Anders Carlsson <ander...@apple.com>
+
+ Begin work on encoding argument types
+ https://bugs.webkit.org/show_bug.cgi?id=123631
+
+ Reviewed by Dan Bernstein.
+
+ Add another test method.
+
+ * TestWebKitAPI/Tests/WebKit2ObjC/WKRemoteObjectRegistry.mm:
+ * TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Shared.h:
+
2013-11-01 Afonso R. Costa Jr. <afonso.co...@samsung.com>
Expose setApplicationCacheOriginQuota via window.internals
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKRemoteObjectRegistry.mm (158451 => 158452)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKRemoteObjectRegistry.mm 2013-11-01 20:42:25 UTC (rev 158451)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2ObjC/WKRemoteObjectRegistry.mm 2013-11-01 21:00:13 UTC (rev 158452)
@@ -99,6 +99,7 @@
EXPECT_TRUE([remoteObjectProxy conformsToProtocol:@protocol(BundleInterface)]);
[remoteObjectProxy sayHello];
+ [remoteObjectProxy testMethodWithString:@"Hello" double:123.456 integer:789];
}
} // namespace TestWebKitAPI
Modified: trunk/Tools/TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Shared.h (158451 => 158452)
--- trunk/Tools/TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Shared.h 2013-11-01 20:42:25 UTC (rev 158451)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/WKRemoteObjectRegistry_Shared.h 2013-11-01 21:00:13 UTC (rev 158452)
@@ -26,5 +26,6 @@
@protocol BundleInterface <NSObject>
- (void)sayHello;
+- (void)testMethodWithString:(NSString *)string double:(double)d integer:(int)i;
@end