Commit 14d43022 authored by Mark Cogan's avatar Mark Cogan Committed by Commit Bot

[iOS] Rename CallableDispatcher -> HandlerForProtocol

Change-Id: I252546eaea91551d7a2d08f0f8290a2cb62f8278
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1893065
Commit-Queue: Mark Cogan <marq@chromium.org>
Auto-Submit: Mark Cogan <marq@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712619}
parent 516cf923
......@@ -18,9 +18,9 @@
// be passed into objects that need to call, but not configure, the dispatcher
// (anything other than a coordinator). To create such a pointer in a way that
// both compiles and is checked for correctness at runtime, use the provided
// function-like macro CallableDispatcher, defined below. Usage is as follows:
// function-like macro HandlerForProtocol, defined below. Usage is as follows:
//
// id<SomeProtocol> callable = CallableDispatcher(dispatcher, SomeProtocol);
// id<SomeProtocol> handler = HandlerForProtocol(dispatcher, SomeProtocol);
//
// |dispatcher| should be a CommandDispatcher object, and SomeProtocol is
// the *name* of a protocol (not a string, not a Protocol* pointer, and not
......@@ -29,9 +29,9 @@
// This will typecast |dispatcher| to an id<SomeProtocol> (for compile-time
// type checking), and verify that |dispatcher| is currently dispatching
// for |protocol| (for run-time verification). If |dispatcher| isn't dispatching
// for |protocol|, CallableDispatcher() returns nil and DCHECKs.
// for |protocol|, HandlerForProtocol() returns nil and DCHECKs.
//
#define CallableDispatcher(Dispatcher, ProtocolName) \
#define HandlerForProtocol(Dispatcher, ProtocolName) \
static_cast<id<ProtocolName>>( \
[Dispatcher strictCallableForProtocol:@protocol(ProtocolName)])
......
......@@ -419,20 +419,20 @@ TEST_F(CommandDispatcherTest, DispatchingForProtocol) {
EXPECT_TRUE([dispatcher dispatchingForProtocol:@protocol(HideProtocol)]);
}
TEST_F(CommandDispatcherTest, CallableDispatcher) {
TEST_F(CommandDispatcherTest, HandlerForProtocol) {
CommandDispatcher* dispatcher = [[CommandDispatcher alloc] init];
NSObject* target = [[NSObject alloc] init];
[dispatcher startDispatchingToTarget:target
forProtocol:@protocol(ShowProtocol)];
id<ShowProtocol> callable = CallableDispatcher(dispatcher, ShowProtocol);
EXPECT_EQ(callable, dispatcher);
id<ShowProtocol> handler = HandlerForProtocol(dispatcher, ShowProtocol);
EXPECT_EQ(handler, dispatcher);
[dispatcher startDispatchingToTarget:target
forProtocol:@protocol(HideProtocol)];
[dispatcher startDispatchingToTarget:target
forProtocol:@protocol(CompositeProtocolWithMethods)];
id<EmptyContainerProtocol> container_callable =
CallableDispatcher(dispatcher, EmptyContainerProtocol);
EXPECT_EQ(container_callable, dispatcher);
id<EmptyContainerProtocol> container_handler =
HandlerForProtocol(dispatcher, EmptyContainerProtocol);
EXPECT_EQ(container_handler, dispatcher);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment