annotate Mac/PythonLauncher/doscript.m @ 87690:66c1c9f32567 default tip

Add use_weakref option to functools.lru_cache The use_weakref option makes lru_cache create weak references to the function arguments when creating the cache key, which prevents them from staying in the memory forever even after all other references to them are gone. This is a proof of concept for http://bugs.python.org/issue19859
author Radomir Dopieralski <devel@sheep.art.pl>
date Tue, 03 Dec 2013 16:02:48 +0100
parents 738cba2bf849
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38673
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
1 /*
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
2 * doscript.c
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
3 * PythonLauncher
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
4 *
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
5 * Created by Jack Jansen on Wed Jul 31 2002.
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
6 * Copyright (c) 2002 __MyCompanyName__. All rights reserved.
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
7 *
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
8 */
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
9
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
10 #import <Cocoa/Cocoa.h>
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
11 #import <ApplicationServices/ApplicationServices.h>
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
12 #import "doscript.h"
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
13
84479
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
14 extern int
38673
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
15 doscript(const char *command)
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
16 {
84479
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
17 char *bundleID = "com.apple.Terminal";
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
18 AppleEvent evt, res;
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
19 AEDesc desc;
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
20 OSStatus err;
46664
031dfe455585 Merged revisions 62425-62429,62434-62436,62441,62444,62446-62448,62450-62455,62463,62465-62466,62469,62474,62476-62478,62480,62485,62492,62497-62498,62500,62507,62513-62514,62516,62521,62531,62535,62545-62546,62548-62551,62553-62559,62569,62574,62577,62593,62595,62604-62606,62608,62616,62626-62627,62636,62638,62644-62645,62647-62648,62651-62653,62656,62661,62663,62680,62686-62687,62696,62699-62703,62711 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 38673
diff changeset
21
84479
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
22 [[NSWorkspace sharedWorkspace] launchApplication:@"/Applications/Utilities/Terminal.app/"];
46664
031dfe455585 Merged revisions 62425-62429,62434-62436,62441,62444,62446-62448,62450-62455,62463,62465-62466,62469,62474,62476-62478,62480,62485,62492,62497-62498,62500,62507,62513-62514,62516,62521,62531,62535,62545-62546,62548-62551,62553-62559,62569,62574,62577,62593,62595,62604-62606,62608,62616,62626-62627,62636,62638,62644-62645,62647-62648,62651-62653,62656,62661,62663,62680,62686-62687,62696,62699-62703,62711 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 38673
diff changeset
23
84479
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
24 // Build event
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
25 err = AEBuildAppleEvent(kAECoreSuite, kAEDoScript,
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
26 typeApplicationBundleID,
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
27 bundleID, strlen(bundleID),
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
28 kAutoGenerateReturnID,
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
29 kAnyTransactionID,
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
30 &evt, NULL,
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
31 "'----':utf8(@)", strlen(command),
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
32 command);
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
33 if (err) {
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
34 NSLog(@"AEBuildAppleEvent failed: %ld\n", (long)err);
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
35 return err;
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
36 }
38673
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
37
84479
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
38 // Send event and check for any Apple Event Manager errors
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
39 err = AESendMessage(&evt, &res, kAEWaitReply, kAEDefaultTimeout);
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
40 AEDisposeDesc(&evt);
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
41 if (err) {
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
42 NSLog(@"AESendMessage failed: %ld\n", (long)err);
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
43 return err;
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
44 }
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
45 // Check for any application errors
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
46 err = AEGetParamDesc(&res, keyErrorNumber, typeSInt32, &desc);
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
47 AEDisposeDesc(&res);
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
48 if (!err) {
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
49 AEGetDescData(&desc, &err, sizeof(err));
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
50 NSLog(@"Terminal returned an error: %ld", (long)err);
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
51 AEDisposeDesc(&desc);
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
52 } else if (err == errAEDescNotFound) {
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
53 err = noErr;
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
54 } else {
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
55 NSLog(@"AEGetPArmDesc returned an error: %ld", (long)err);
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
56 }
46664
031dfe455585 Merged revisions 62425-62429,62434-62436,62441,62444,62446-62448,62450-62455,62463,62465-62466,62469,62474,62476-62478,62480,62485,62492,62497-62498,62500,62507,62513-62514,62516,62521,62531,62535,62545-62546,62548-62551,62553-62559,62569,62574,62577,62593,62595,62604-62606,62608,62616,62626-62627,62636,62638,62644-62645,62647-62648,62651-62653,62656,62661,62663,62680,62686-62687,62696,62699-62703,62711 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 38673
diff changeset
57
84479
738cba2bf849 Issue #18377: Code cleanup in Python Launcher
Ronald Oussoren <ronaldoussoren@mac.com>
parents: 46664
diff changeset
58 return err;
38673
a19c20c5e5c7 Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
diff changeset
59 }