Changeset 163630 in webkit


Ignore:
Timestamp:
Feb 7, 2014 10:32:38 AM (10 years ago)
Author:
mitz@apple.com
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.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r163629 r163630  
     12014-02-07  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] WKRemoteObjectInterface doesn’t support aribtrary argument classes
     4        https://bugs.webkit.org/show_bug.cgi?id=128368
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * Shared/API/Cocoa/WKRemoteObjectInterface.h: Declared new methods.
     9        * Shared/API/Cocoa/WKRemoteObjectInterface.mm:
     10        (propertyListClasses): Removed NSNull, which is not really a property list class.
     11        (classesForSelectorArgument): Added helper function.
     12        (-[WKRemoteObjectInterface classesForSelector:argumentIndex:]): Added.
     13        (-[WKRemoteObjectInterface setClasses:forSelector:argumentIndex:]): Added.
     14
    1152014-02-07  Dan Bernstein  <mitz@apple.com>
    216
  • trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectInterface.h

    r159788 r163630  
    3333@interface WKRemoteObjectInterface : NSObject
    3434
     35+ (instancetype)remoteObjectInterfaceWithProtocol:(Protocol *)protocol;
     36
     37- (id)initWithProtocol:(Protocol *)protocol identifier:(NSString *)identifier;
     38
    3539@property (readonly) Protocol *protocol;
    3640@property (readonly) NSString *identifier;
    3741
    38 - (id)initWithProtocol:(Protocol *)protocol identifier:(NSString *)identifier;
    39 
    40 + (instancetype)remoteObjectInterfaceWithProtocol:(Protocol *)protocol;
     42- (NSSet *)classesForSelector:(SEL)selector argumentIndex:(NSUInteger)argumentIndex;
     43- (void)setClasses:(NSSet *)classes forSelector:(SEL)selector argumentIndex:(NSUInteger)argumentIndex;
    4144
    4245@end
  • trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectInterface.mm

    r163470 r163630  
    5656{
    5757    // FIXME: Add more property list classes if needed.
    58     static NSSet *propertyListClasses = [[NSSet alloc] initWithObjects:[NSArray class], [NSDictionary class], [NSNull class], [NSNumber class], [NSString class], nil];
     58    static NSSet *propertyListClasses = [[NSSet alloc] initWithObjects:[NSArray class], [NSDictionary class], [NSNumber class], [NSString class], nil];
    5959
    6060    return propertyListClasses;
     
    142142}
    143143
     144static RetainPtr<NSSet>& classesForSelectorArgument(WKRemoteObjectInterface *interface, SEL selector, NSUInteger argumentIndex)
     145{
     146    auto it = interface->_allowedArgumentClasses.find(selector);
     147    if (it == interface->_allowedArgumentClasses.end())
     148        [NSException raise:NSInvalidArgumentException format:@"Interface does not contain selector \"%s\"", sel_getName(selector)];
     149
     150    if (argumentIndex >= it->value.size())
     151        [NSException raise:NSInvalidArgumentException format:@"Argument index %ld is out of range for selector \"%s\"", (unsigned long)argumentIndex, sel_getName(selector)];
     152
     153    return it->value[argumentIndex];
     154}
     155
     156- (NSSet *)classesForSelector:(SEL)selector argumentIndex:(NSUInteger)argumentIndex
     157{
     158    return [[classesForSelectorArgument(self, selector, argumentIndex).get() retain] autorelease];
     159}
     160
     161- (void)setClasses:(NSSet *)classes forSelector:(SEL)selector argumentIndex:(NSUInteger)argumentIndex
     162{
     163    classesForSelectorArgument(self, selector, argumentIndex) = adoptNS([classes copy]);
     164}
     165
    144166static const char* methodArgumentTypeEncodingForSelector(Protocol *protocol, SEL selector)
    145167{
Note: See TracChangeset for help on using the changeset viewer.