Mercurial > cpython-lru_cache-weakref
annotate Mac/PythonLauncher/doscript.m @ 58765:2ba7677bfa95 legacy-trunk
testCopysign was defined twice in test_math; combine the definitions
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sat, 06 Feb 2010 23:11:25 +0000 |
| parents | 3f84e6ae36da |
| children | 5d41ebc79738 |
| rev | line source |
|---|---|
|
24447
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1 /* |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
2 * doscript.c |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
3 * PythonLauncher |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
4 * |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
5 * Created by Jack Jansen on Wed Jul 31 2002. |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
6 * Copyright (c) 2002 __MyCompanyName__. All rights reserved. |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
7 * |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
8 */ |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
9 |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
10 #import <Cocoa/Cocoa.h> |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
11 #import <ApplicationServices/ApplicationServices.h> |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
12 #import "doscript.h" |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
13 |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
14 extern int |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
15 doscript(const char *command) |
|
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
16 { |
|
46629
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
17 char *bundleID = "com.apple.Terminal"; |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
18 AppleEvent evt, res; |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
19 AEDesc desc; |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
20 OSStatus err; |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
21 |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
22 [[NSWorkspace sharedWorkspace] launchApplication:@"/Applications/Utilities/Terminal.app/"]; |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
23 |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
24 // Build event |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
25 err = AEBuildAppleEvent(kAECoreSuite, kAEDoScript, |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
26 typeApplicationBundleID, |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
27 bundleID, strlen(bundleID), |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
28 kAutoGenerateReturnID, |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
29 kAnyTransactionID, |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
30 &evt, NULL, |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
31 "'----':utf8(@)", strlen(command), |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
32 command); |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
33 if (err) { |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
34 NSLog(@"AEBuildAppleEvent failed: %d\n", err); |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
35 return err; |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
36 } |
|
24447
ddd6ff0693c4
Implemented starting Python in a terminal window. The implementation isn't
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
37 |
|
46629
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
38 // Send event and check for any Apple Event Manager errors |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
39 err = AESendMessage(&evt, &res, kAEWaitReply, kAEDefaultTimeout); |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
40 AEDisposeDesc(&evt); |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
41 if (err) { |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
42 NSLog(@"AESendMessage failed: %d\n", err); |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
43 return err; |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
44 } |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
45 // Check for any application errors |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
46 err = AEGetParamDesc(&res, keyErrorNumber, typeSInt32, &desc); |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
47 AEDisposeDesc(&res); |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
48 if (!err) { |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
49 AEGetDescData(&desc, &err, sizeof(err)); |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
50 NSLog(@"Terminal returned an error: %d", err); |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
51 AEDisposeDesc(&desc); |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
52 } else if (err == errAEDescNotFound) { |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
53 err = noErr; |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
54 } else { |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
55 NSLog(@"AEGetPArmDesc returned an error: %d", err); |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
56 } |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
57 |
|
3f84e6ae36da
Fix for #1905: PythonLauncher not working correctly on OSX 10.5/Leopard
Ronald Oussoren <ronaldoussoren@mac.com>
parents:
38644
diff
changeset
|
58 return err; |
|
27088
abb5a69d60cb
correct comment (and add newline at end)
Just van Rossum <just@letterror.com>
parents:
24447
diff
changeset
|
59 } |
