Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: third_party/ocmock/OCMock/OCProtocolMockObject.m

Issue 2624143003: Update OCMock to 3.1.5 (Closed)
Patch Set: Patches in more commits Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/ocmock/OCMock/OCProtocolMockObject.h ('k') | third_party/ocmock/README.chromium » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //------------------------------------------------------------------------------ --------- 1 /*
2 // $Id$ 2 * Copyright (c) 2005-2015 Erik Doernenburg and contributors
3 // Copyright (c) 2005-2008 by Mulle Kybernetik. See License file for details. 3 *
4 //------------------------------------------------------------------------------ --------- 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may
5 * not use these files except in compliance with the License. You may obtain
6 * a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
14 * under the License.
15 */
5 16
6 #import <objc/runtime.h> 17 #import <objc/runtime.h>
7 #import "NSMethodSignature+OCMAdditions.h" 18 #import "NSMethodSignature+OCMAdditions.h"
8 #import "OCProtocolMockObject.h" 19 #import "OCProtocolMockObject.h"
9 20
10 @implementation OCProtocolMockObject 21 @implementation OCProtocolMockObject
11 22
12 #pragma mark Initialisers, description, accessors, etc. 23 #pragma mark Initialisers, description, accessors, etc.
13 24
14 - (id)initWithProtocol:(Protocol *)aProtocol 25 - (id)initWithProtocol:(Protocol *)aProtocol
15 { 26 {
27 NSParameterAssert(aProtocol != nil);
16 [super init]; 28 [super init];
17 mockedProtocol = aProtocol; 29 mockedProtocol = aProtocol;
18 return self; 30 return self;
19 } 31 }
20 32
21 - (NSString *)description 33 - (NSString *)description
22 { 34 {
23 const char* name = protocol_getName(mockedProtocol); 35 const char* name = protocol_getName(mockedProtocol);
24 return [NSString stringWithFormat:@"OCMockObject[%s]", name]; 36 return [NSString stringWithFormat:@"OCMockObject(%s)", name];
25 } 37 }
26 38
27 #pragma mark Proxy API 39 #pragma mark Proxy API
28 40
29 - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector 41 - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
30 { 42 {
31 » struct objc_method_description methodDescription = protocol_getMethodDes cription(mockedProtocol, aSelector, YES, YES); 43 struct { BOOL isRequired; BOOL isInstance; } opts[4] = { {YES, YES}, {NO, YE S}, {YES, NO}, {NO, NO} };
32 if(methodDescription.name == NULL) 44 for(int i = 0; i < 4; i++)
33 » { 45 {
34 methodDescription = protocol_getMethodDescription(mockedProtocol, aSelec tor, NO, YES); 46 struct objc_method_description methodDescription = protocol_getMethodDes cription(mockedProtocol, aSelector, opts[i].isRequired, opts[i].isInstance);
47 if(methodDescription.name != NULL)
48 return [NSMethodSignature signatureWithObjCTypes:methodDescription.t ypes];
35 } 49 }
36 if(methodDescription.name == NULL) 50 return nil;
37 » {
38 return nil;
39 }
40 » return [NSMethodSignature signatureWithObjCTypes:methodDescription.types ];
41 } 51 }
42 52
43 - (BOOL)conformsToProtocol:(Protocol *)aProtocol 53 - (BOOL)conformsToProtocol:(Protocol *)aProtocol
44 { 54 {
45 return protocol_conformsToProtocol(mockedProtocol, aProtocol); 55 return protocol_conformsToProtocol(mockedProtocol, aProtocol);
46 } 56 }
47 57
48 - (BOOL)respondsToSelector:(SEL)selector 58 - (BOOL)respondsToSelector:(SEL)selector
49 { 59 {
50 return ([self methodSignatureForSelector:selector] != nil); 60 return ([self methodSignatureForSelector:selector] != nil);
51 } 61 }
52 62
53 @end 63 @end
OLDNEW
« no previous file with comments | « third_party/ocmock/OCMock/OCProtocolMockObject.h ('k') | third_party/ocmock/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698