Title: [163630] trunk/Source/WebKit2
- Revision
- 163630
- Author
- m...@apple.com
- Date
- 2014-02-07 10:32:38 -0800 (Fri, 07 Feb 2014)
Log Message
[Cocoa] WKRemoteObjectInterface doesn’t support aribtrary argument classes
https://bugs.webkit.org/show_bug.cgi?id=128368
Reviewed by Anders Carlsson.
* Shared/API/Cocoa/WKRemoteObjectInterface.h: Declared new methods.
* Shared/API/Cocoa/WKRemoteObjectInterface.mm:
(propertyListClasses): Removed NSNull, which is not really a property list class.
(classesForSelectorArgument): Added helper function.
(-[WKRemoteObjectInterface classesForSelector:argumentIndex:]): Added.
(-[WKRemoteObjectInterface setClasses:forSelector:argumentIndex:]): Added.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (163629 => 163630)
--- trunk/Source/WebKit2/ChangeLog 2014-02-07 18:32:04 UTC (rev 163629)
+++ trunk/Source/WebKit2/ChangeLog 2014-02-07 18:32:38 UTC (rev 163630)
@@ -1,5 +1,19 @@
2014-02-07 Dan Bernstein <m...@apple.com>
+ [Cocoa] WKRemoteObjectInterface doesn’t support aribtrary argument classes
+ https://bugs.webkit.org/show_bug.cgi?id=128368
+
+ Reviewed by Anders Carlsson.
+
+ * Shared/API/Cocoa/WKRemoteObjectInterface.h: Declared new methods.
+ * Shared/API/Cocoa/WKRemoteObjectInterface.mm:
+ (propertyListClasses): Removed NSNull, which is not really a property list class.
+ (classesForSelectorArgument): Added helper function.
+ (-[WKRemoteObjectInterface classesForSelector:argumentIndex:]): Added.
+ (-[WKRemoteObjectInterface setClasses:forSelector:argumentIndex:]): Added.
+
+2014-02-07 Dan Bernstein <m...@apple.com>
+
[Cocoa] API::FrameHandle has a generic wrapper
https://bugs.webkit.org/show_bug.cgi?id=128366
Modified: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectInterface.h (163629 => 163630)
--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectInterface.h 2014-02-07 18:32:04 UTC (rev 163629)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectInterface.h 2014-02-07 18:32:38 UTC (rev 163630)
@@ -32,13 +32,16 @@
WK_API_CLASS
@interface WKRemoteObjectInterface : NSObject
++ (instancetype)remoteObjectInterfaceWithProtocol:(Protocol *)protocol;
+
+- (id)initWithProtocol:(Protocol *)protocol identifier:(NSString *)identifier;
+
@property (readonly) Protocol *protocol;
@property (readonly) NSString *identifier;
-- (id)initWithProtocol:(Protocol *)protocol identifier:(NSString *)identifier;
+- (NSSet *)classesForSelector:(SEL)selector argumentIndex:(NSUInteger)argumentIndex;
+- (void)setClasses:(NSSet *)classes forSelector:(SEL)selector argumentIndex:(NSUInteger)argumentIndex;
-+ (instancetype)remoteObjectInterfaceWithProtocol:(Protocol *)protocol;
-
@end
#endif // WK_API_ENABLED
Modified: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectInterface.mm (163629 => 163630)
--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectInterface.mm 2014-02-07 18:32:04 UTC (rev 163629)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectInterface.mm 2014-02-07 18:32:38 UTC (rev 163630)
@@ -55,7 +55,7 @@
static NSSet *propertyListClasses()
{
// FIXME: Add more property list classes if needed.
- static NSSet *propertyListClasses = [[NSSet alloc] initWithObjects:[NSArray class], [NSDictionary class], [NSNull class], [NSNumber class], [NSString class], nil];
+ static NSSet *propertyListClasses = [[NSSet alloc] initWithObjects:[NSArray class], [NSDictionary class], [NSNumber class], [NSString class], nil];
return propertyListClasses;
}
@@ -141,6 +141,28 @@
return [[[self alloc] initWithProtocol:protocol identifier:NSStringFromProtocol(protocol)] autorelease];
}
+static RetainPtr<NSSet>& classesForSelectorArgument(WKRemoteObjectInterface *interface, SEL selector, NSUInteger argumentIndex)
+{
+ auto it = interface->_allowedArgumentClasses.find(selector);
+ if (it == interface->_allowedArgumentClasses.end())
+ [NSException raise:NSInvalidArgumentException format:@"Interface does not contain selector \"%s\"", sel_getName(selector)];
+
+ if (argumentIndex >= it->value.size())
+ [NSException raise:NSInvalidArgumentException format:@"Argument index %ld is out of range for selector \"%s\"", (unsigned long)argumentIndex, sel_getName(selector)];
+
+ return it->value[argumentIndex];
+}
+
+- (NSSet *)classesForSelector:(SEL)selector argumentIndex:(NSUInteger)argumentIndex
+{
+ return [[classesForSelectorArgument(self, selector, argumentIndex).get() retain] autorelease];
+}
+
+- (void)setClasses:(NSSet *)classes forSelector:(SEL)selector argumentIndex:(NSUInteger)argumentIndex
+{
+ classesForSelectorArgument(self, selector, argumentIndex) = adoptNS([classes copy]);
+}
+
static const char* methodArgumentTypeEncodingForSelector(Protocol *protocol, SEL selector)
{
// First look at required methods.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes