1 #import <Foundation/Foundation.h>
5 NSString *str = @"some string";
7 const char *directCallConflictingName() {
8 return "wrong function";
11 @interface Foo : NSObject {
20 // Try calling directly with self. Same as in the main method otherwise.
21 return 0; //%self.expect_expr("[self directCallNoArgs]", result_summary='"called directCallNoArgs"')
22 //%self.expect_expr("[self directCallArgs: 1111]", result_value="2345")
23 //%self.expect_expr("side_effect = 0; [self directCallVoidReturn]; side_effect", result_value="4321")
24 //%self.expect_expr("[self directCallNSStringArg: str]", result_summary='@"some string"')
25 //%self.expect_expr("[self directCallIdArg: (id)str]", result_summary='@"some string appendix"')
26 //%self.expect_expr("[self directCallConflictingName]", result_summary='"correct function"')
27 //%self.expect_expr("[self directCallWithCategory]", result_summary='"called function with category"')
30 // Declare several objc_direct functions we can test.
31 -(const char *) directCallNoArgs __attribute__((objc_direct))
33 return "called directCallNoArgs";
36 -(void) directCallVoidReturn __attribute__((objc_direct))
41 -(int) directCallArgs:(int)i __attribute__((objc_direct))
43 // Use the arg in some way to make sure that gets passed correctly.
47 -(NSString *) directCallNSStringArg:(NSString *)str __attribute__((objc_direct))
52 -(NSString *) directCallIdArg:(id)param __attribute__((objc_direct))
54 return [param stringByAppendingString:@" appendix"];
57 // We have another function with the same name above. Make sure this doesn't influence
59 -(const char *) directCallConflictingName __attribute__((objc_direct))
61 return "correct function";
69 @implementation Foo (Cat)
70 -(const char *) directCallWithCategory __attribute__((objc_direct))
72 return "called function with category";
78 Foo *foo = [[Foo alloc] init];
79 [foo directCallNoArgs];
80 [foo directCallArgs: 1];
81 [foo directCallVoidReturn];
82 [foo directCallNSStringArg: str];
83 [foo directCallIdArg: (id)str];
84 [foo entryPoint]; //%self.expect_expr("[foo directCallNoArgs]", result_summary='"called directCallNoArgs"')
85 //%self.expect_expr("[foo directCallArgs: 1111]", result_value="2345")
86 //%self.expect_expr("side_effect = 0; [foo directCallVoidReturn]; side_effect", result_value="4321")
87 //%self.expect_expr("[foo directCallNSStringArg: str]", result_summary='@"some string"')
88 //%self.expect_expr("[foo directCallIdArg: (id)str]", result_summary='@"some string appendix"')
89 //%self.expect_expr("[foo directCallConflictingName]", result_summary='"correct function"')
90 //%self.expect_expr("[foo directCallWithCategory]", result_summary='"called function with category"')