]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/expression_command/call-throws/call-throws.m
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / expression_command / call-throws / call-throws.m
1 #import <Foundation/Foundation.h>
2
3 @interface MyClass : NSObject
4 {
5 }
6 - (int) callMeIThrow;
7 - (int) iCatchMyself;
8 @end
9
10 @implementation MyClass
11 - (int) callMeIThrow
12 {
13     NSException *e = [NSException
14                        exceptionWithName:@"JustForTheHeckOfItException"
15                        reason:@"I felt like it"
16                        userInfo:nil];
17     @throw e;
18     return 56;
19 }
20
21 - (int) iCatchMyself
22 {
23   int return_value = 55;
24   @try
25     {
26       return_value = [self callMeIThrow];
27     }
28   @catch (NSException *e)
29     {
30       return_value = 57;
31     }
32   return return_value;
33 }
34 @end
35
36 int
37 main ()
38 {
39   int return_value;
40   MyClass *my_class = [[MyClass alloc] init];
41
42   NSLog (@"I am about to throw.");
43
44   return_value = [my_class iCatchMyself];
45
46   return return_value;
47 }