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

Side by Side Diff: third_party/ocmock/OCMock/NSMethodSignature+OCMAdditions.m

Issue 2410583002: Test update OCMock (Closed)
Patch Set: Patch in exactly 3.1.5 Created 3 years, 11 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
OLDNEW
1 //------------------------------------------------------------------------------ --------- 1 /*
2 // $Id$ 2 * Copyright (c) 2009-2015 Erik Doernenburg and contributors
3 // Copyright (c) 2009 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 "NSMethodSignature+OCMAdditions.h" 17 #import "NSMethodSignature+OCMAdditions.h"
7 18 #import "OCMFunctions.h"
19 #import <objc/runtime.h>
8 20
9 @implementation NSMethodSignature(OCMAdditions) 21 @implementation NSMethodSignature(OCMAdditions)
10 22
11 - (const char *)methodReturnTypeWithoutQualifiers 23 - (BOOL)usesSpecialStructureReturn {
12 { 24 const char* types = OCMTypeWithoutQualifiers([self methodReturnType]);
13 » const char *returnType = [self methodReturnType]; 25
14 » while(strchr("rnNoORV", returnType[0]) != NULL) 26 if ((types == NULL) || (types[0] != '{'))
15 » » returnType += 1; 27 return NO;
16 » return returnType; 28
29 /* In some cases structures are returned by ref. The rules are complex and
30 depend on the
31 architecture, see:
32
33 http://sealiesoftware.com/blog/archive/2008/10/30/objc_explain_objc_msgSend _stret.html
34 http://developer.apple.com/library/mac/#documentation/DeveloperTools/Concep tual/LowLevelABI/000-Introduction/introduction.html
35 https://github.com/atgreen/libffi/blob/master/src/x86/ffi64.c
36 http://www.uclibc.org/docs/psABI-x86_64.pdf
37 http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pd f
38
39 NSMethodSignature knows the details but has no API to return it, though it
40 is in
41 the debugDescription. Horribly kludgy.
42 */
43 NSRange range =
44 [[self debugDescription] rangeOfString:@"is special struct return? YES"];
45 return range.length > 0;
46 }
47
48 - (NSString*)fullTypeString {
49 NSMutableString* typeString = [NSMutableString string];
50 [typeString appendFormat:@"%s", [self methodReturnType]];
51 for (NSUInteger i = 0; i < [self numberOfArguments]; i++)
52 [typeString appendFormat:@"%s", [self getArgumentTypeAtIndex:i]];
53 return typeString;
54 }
55
56 - (const char*)fullObjCTypes {
57 return [[self fullTypeString] UTF8String];
17 } 58 }
18 59
19 @end 60 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698