Mercurial > cpython-lru_cache-weakref
annotate Mac/Python/macgetargv.c @ 25838:8540887bcec6 2.2
Backport of 2.183:
Fix memory leak in add_subclass() found by NealN with valgrind.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 18 Oct 2002 13:42:21 +0000 |
| parents | d8dd75e3b304 |
| children | b9246f8fb8fd 74d1ad61f843 |
| rev | line source |
|---|---|
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /*********************************************************** |
|
5079
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4552
diff
changeset
|
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 The Netherlands. |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 All Rights Reserved |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 Centrum or CWI not be used in advertising or publicity pertaining to |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 distribution of the software without specific, written prior permission. |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 ******************************************************************/ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 /* Construct argc and argv for main() by using Apple Events */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 /* From Jack's implementation for STDWIN */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 #include <stdlib.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
30 #ifdef WITHOUT_FRAMEWORKS |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 #include <Types.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 #include <Files.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 #include <Events.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 #include <Memory.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 #include <Processes.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 #include <Errors.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 #include <AppleEvents.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 #include <AEObjects.h> |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 #include <Fonts.h> |
|
2399
438a8c265eb9
ported back to Think C
Guido van Rossum <guido@python.org>
parents:
2393
diff
changeset
|
40 #include <TextEdit.h> |
|
438a8c265eb9
ported back to Think C
Guido van Rossum <guido@python.org>
parents:
2393
diff
changeset
|
41 #include <Menus.h> |
|
438a8c265eb9
ported back to Think C
Guido van Rossum <guido@python.org>
parents:
2393
diff
changeset
|
42 #include <Dialogs.h> |
|
438a8c265eb9
ported back to Think C
Guido van Rossum <guido@python.org>
parents:
2393
diff
changeset
|
43 #include <Windows.h> |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
44 #else |
|
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
45 #include <Carbon/Carbon.h> |
|
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
46 #endif /* WITHOUT_FRAMEWORKS */ |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 |
|
18177
826000a40866
Adapted for Universal Headers 3.4: refcon type has changed (sigh) and use modern (UPP in stead of Proc) names for callback object creation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17931
diff
changeset
|
48 #if UNIVERSAL_INTERFACES_VERSION >= 0x0340 |
|
826000a40866
Adapted for Universal Headers 3.4: refcon type has changed (sigh) and use modern (UPP in stead of Proc) names for callback object creation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17931
diff
changeset
|
49 typedef long refcontype; |
|
826000a40866
Adapted for Universal Headers 3.4: refcon type has changed (sigh) and use modern (UPP in stead of Proc) names for callback object creation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17931
diff
changeset
|
50 #else |
|
826000a40866
Adapted for Universal Headers 3.4: refcon type has changed (sigh) and use modern (UPP in stead of Proc) names for callback object creation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17931
diff
changeset
|
51 typedef unsigned long refcontype; |
|
826000a40866
Adapted for Universal Headers 3.4: refcon type has changed (sigh) and use modern (UPP in stead of Proc) names for callback object creation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17931
diff
changeset
|
52 #endif |
|
826000a40866
Adapted for Universal Headers 3.4: refcon type has changed (sigh) and use modern (UPP in stead of Proc) names for callback object creation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17931
diff
changeset
|
53 |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
54 #include "Python.h" |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
55 #include "macglue.h" |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
56 |
|
19841
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19748
diff
changeset
|
57 #ifdef TARGET_API_MAC_OSX |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19748
diff
changeset
|
58 #define PATHNAMELEN 1024 |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19748
diff
changeset
|
59 #else |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19748
diff
changeset
|
60 #define PATHNAMELEN 256 |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19748
diff
changeset
|
61 #endif |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19748
diff
changeset
|
62 |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 static int arg_count; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 static char *arg_vector[256]; |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
65 FSSpec PyMac_ApplicationFSSpec; |
|
19841
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19748
diff
changeset
|
66 char PyMac_ApplicationPath[PATHNAMELEN]; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 |
|
3215
3b2be811a66a
Export strdup (parsermodule needs it)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3054
diff
changeset
|
68 /* Duplicate a string to the heap. We also export this since it isn't standard |
|
3b2be811a66a
Export strdup (parsermodule needs it)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3054
diff
changeset
|
69 ** and others use it |
|
3b2be811a66a
Export strdup (parsermodule needs it)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3054
diff
changeset
|
70 */ |
|
13547
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
12962
diff
changeset
|
71 #ifndef HAVE_STRDUP |
|
3215
3b2be811a66a
Export strdup (parsermodule needs it)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3054
diff
changeset
|
72 char * |
|
13547
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
12962
diff
changeset
|
73 strdup(const char *src) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
74 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
75 char *dst = malloc(strlen(src) + 1); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 if (dst) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 strcpy(dst, src); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 return dst; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
79 } |
|
13547
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
12962
diff
changeset
|
80 #endif |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
81 |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
82 |
|
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
83 #if !TARGET_API_MAC_OSX |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
84 /* Initialize FSSpec and full name of current application */ |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
85 |
|
3054
2cb1416010b3
Python will now attempt (again) to create at least a minimal
Jack Jansen <jack.jansen@cwi.nl>
parents:
2874
diff
changeset
|
86 OSErr |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
87 PyMac_init_process_location(void) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 ProcessSerialNumber currentPSN; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
90 ProcessInfoRec info; |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
91 OSErr err; |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
92 static int applocation_inited; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
93 |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
94 if ( applocation_inited ) return 0; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 currentPSN.highLongOfPSN = 0; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
96 currentPSN.lowLongOfPSN = kCurrentProcess; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
97 info.processInfoLength = sizeof(ProcessInfoRec); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 info.processName = NULL; |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
99 info.processAppSpec = &PyMac_ApplicationFSSpec; |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
100 if ( err=GetProcessInformation(¤tPSN, &info)) |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
101 return err; |
|
19841
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19748
diff
changeset
|
102 if ( err=PyMac_GetFullPathname(&PyMac_ApplicationFSSpec, PyMac_ApplicationPath, PATHNAMELEN) ) |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
103 return err; |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
104 applocation_inited = 1; |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
105 return 0; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 } |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
107 #endif /* !TARGET_API_MAC_OSX */ |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
109 /* Check that there aren't any args remaining in the event */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
110 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 static OSErr |
|
12832
b90d601d4d59
Fixed callback function arguments to be carbon-compatible.
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
112 get_missing_params(const AppleEvent *theAppleEvent) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
113 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
114 DescType theType; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 Size actualSize; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
116 OSErr err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
117 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
118 err = AEGetAttributePtr(theAppleEvent, keyMissedKeywordAttr, typeWildCard, |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
119 &theType, nil, 0, &actualSize); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
120 if (err == errAEDescNotFound) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
121 return noErr; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 else |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
123 return errAEEventNotHandled; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
124 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
125 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
126 static int got_one; /* Flag that we can stop getting events */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
127 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
128 /* Handle the Print or Quit events (by failing) */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
129 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 static pascal OSErr |
|
18177
826000a40866
Adapted for Universal Headers 3.4: refcon type has changed (sigh) and use modern (UPP in stead of Proc) names for callback object creation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17931
diff
changeset
|
131 handle_not(const AppleEvent *theAppleEvent, AppleEvent *reply, refcontype refCon) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
132 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
133 #pragma unused (reply, refCon) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
134 got_one = 1; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
135 return errAEEventNotHandled; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
136 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 /* Handle the Open Application event (by ignoring it) */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
139 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 static pascal OSErr |
|
18177
826000a40866
Adapted for Universal Headers 3.4: refcon type has changed (sigh) and use modern (UPP in stead of Proc) names for callback object creation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17931
diff
changeset
|
141 handle_open_app(const AppleEvent *theAppleEvent, AppleEvent *reply, refcontype refCon) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
142 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
143 #pragma unused (reply, refCon) |
|
3249
1cf6e10522e0
Continue looking for "open doc" events even after "open app". This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3215
diff
changeset
|
144 #if 0 |
|
1cf6e10522e0
Continue looking for "open doc" events even after "open app". This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3215
diff
changeset
|
145 /* Test by Jack: would removing this facilitate debugging? */ |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
146 got_one = 1; |
|
3249
1cf6e10522e0
Continue looking for "open doc" events even after "open app". This
Jack Jansen <jack.jansen@cwi.nl>
parents:
3215
diff
changeset
|
147 #endif |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
148 return get_missing_params(theAppleEvent); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
149 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
150 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
151 /* Handle the Open Document event, by adding an argument */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
152 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
153 static pascal OSErr |
|
18177
826000a40866
Adapted for Universal Headers 3.4: refcon type has changed (sigh) and use modern (UPP in stead of Proc) names for callback object creation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17931
diff
changeset
|
154 handle_open_doc(const AppleEvent *theAppleEvent, AppleEvent *reply, refcontype refCon) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
155 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
156 #pragma unused (reply, refCon) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
157 OSErr err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
158 AEDescList doclist; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
159 AEKeyword keywd; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
160 DescType rttype; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
161 long i, ndocs, size; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
162 FSSpec fss; |
|
19841
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19748
diff
changeset
|
163 char path[PATHNAMELEN]; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
164 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
165 got_one = 1; |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
166 if ((err = AEGetParamDesc(theAppleEvent, |
|
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
167 keyDirectObject, typeAEList, &doclist))) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
168 return err; |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
169 if ((err = get_missing_params(theAppleEvent))) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 return err; |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
171 if ((err = AECountItems(&doclist, &ndocs))) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 return err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 for(i = 1; i <= ndocs; i++) { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
174 err = AEGetNthPtr(&doclist, i, typeFSS, |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
175 &keywd, &rttype, &fss, sizeof(fss), &size); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 if (err) |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 break; |
|
19841
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19748
diff
changeset
|
178 PyMac_GetFullPathname(&fss, path, PATHNAMELEN); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
179 arg_vector[arg_count++] = strdup(path); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
181 return err; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
183 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
184 /* Install standard core event handlers */ |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
185 AEEventHandlerUPP open_doc_upp; |
|
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
186 AEEventHandlerUPP open_app_upp; |
|
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
187 AEEventHandlerUPP not_upp; |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
188 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
189 static void |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
190 set_ae_handlers(void) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
191 { |
|
18177
826000a40866
Adapted for Universal Headers 3.4: refcon type has changed (sigh) and use modern (UPP in stead of Proc) names for callback object creation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17931
diff
changeset
|
192 open_doc_upp = NewAEEventHandlerUPP(&handle_open_doc); |
|
826000a40866
Adapted for Universal Headers 3.4: refcon type has changed (sigh) and use modern (UPP in stead of Proc) names for callback object creation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17931
diff
changeset
|
193 open_app_upp = NewAEEventHandlerUPP(&handle_open_app); |
|
826000a40866
Adapted for Universal Headers 3.4: refcon type has changed (sigh) and use modern (UPP in stead of Proc) names for callback object creation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17931
diff
changeset
|
194 not_upp = NewAEEventHandlerUPP(&handle_not); |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
195 |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
196 AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
197 open_app_upp, 0L, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
198 AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
199 open_doc_upp, 0L, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
200 AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
201 not_upp, 0L, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
202 AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
203 not_upp, 0L, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
205 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
206 /* Uninstall standard core event handlers */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
207 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
208 static void |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
209 reset_ae_handlers(void) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
210 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
211 AERemoveEventHandler(kCoreEventClass, kAEOpenApplication, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
212 open_app_upp, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
213 AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
214 open_doc_upp, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 AERemoveEventHandler(kCoreEventClass, kAEPrintDocuments, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
216 not_upp, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
217 AERemoveEventHandler(kCoreEventClass, kAEQuitApplication, |
|
2874
927f4839fbfa
Un-installing of AE handlers fixed (AE is very picky that you specify
Jack Jansen <jack.jansen@cwi.nl>
parents:
2794
diff
changeset
|
218 not_upp, false); |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 /* Wait for events until a core event has been handled */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
222 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
223 static void |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
224 event_loop(void) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
225 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
226 EventRecord event; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
227 int n; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
228 int ok; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
229 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
230 got_one = 0; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
231 for (n = 0; n < 100 && !got_one; n++) { |
|
13608
a901c2c0166b
Test for TARGET_API_MAC_CARBON with #if in stead of #ifdef.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13547
diff
changeset
|
232 #if !TARGET_API_MAC_CARBON |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
233 SystemTask(); |
|
12962
bac045b85263
Made argc/argv processing work again under carbon.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12859
diff
changeset
|
234 #endif |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
235 ok = GetNextEvent(everyEvent, &event); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
236 if (ok && event.what == kHighLevelEvent) { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
237 AEProcessAppleEvent(&event); |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
238 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
239 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
240 } |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
241 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
242 /* Get the argv vector, return argc */ |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
243 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
244 int |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
245 PyMac_GetArgv(char ***pargv, int noevents) |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
246 { |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
247 arg_count = 0; |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
248 #if TARGET_API_MAC_OSX |
|
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
249 /* In an OSX bundle argv[0] is okay */ |
|
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
250 arg_count++; |
|
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
251 #else |
|
4523
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
252 (void)PyMac_init_process_location(); |
|
4d0681f7cf6b
Got rid of nfullpath in favor of PyMac_GetFullPath (which was pretty
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
253 arg_vector[arg_count++] = strdup(PyMac_ApplicationPath); |
|
19748
c93d7d0857a2
Changes to make these work under OSX as the main program for a
Jack Jansen <jack.jansen@cwi.nl>
parents:
18177
diff
changeset
|
254 #endif /* TARGET_API_MAC_OSX */ |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
255 |
|
4238
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
256 if( !noevents ) { |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
257 set_ae_handlers(); |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
258 event_loop(); |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
259 reset_ae_handlers(); |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4020
diff
changeset
|
260 } |
|
2393
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
261 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
262 arg_vector[arg_count] = NULL; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
263 |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
264 *pargv = arg_vector; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
265 return arg_count; |
|
b156bf4be62f
get argc/argv from AppleEvents
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
266 } |
