Mercurial > cpython-lru_cache-weakref
annotate Mac/Python/macapplication.c @ 12853:21553bd2e875 legacy-trunk
Removed THINK_C support.
Added a CARBON indicator to the version string.
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Sun, 04 Jun 2000 21:51:36 +0000 |
| parents | 86890c073c3b |
| children | db963a615bc9 |
| rev | line source |
|---|---|
|
2426
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
1 /*********************************************************** |
|
5079
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4021
diff
changeset
|
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, |
|
2426
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
3 The Netherlands. |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
4 |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
5 All Rights Reserved |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
6 |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
12 Centrum or CWI not be used in advertising or publicity pertaining to |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
13 distribution of the software without specific, written prior permission. |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
14 |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
22 |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
23 ******************************************************************/ |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
24 |
|
10171
73e5e3f51b87
(finally) unified the interpreter and the applet as Just suggested ages ago. The
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
25 /* Macintosh Python main program for both applets and interpreter */ |
|
2426
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
26 |
|
10171
73e5e3f51b87
(finally) unified the interpreter and the applet as Just suggested ages ago. The
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
27 #include <Resources.h> |
|
11643
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
28 #include <CodeFragments.h> |
|
10171
73e5e3f51b87
(finally) unified the interpreter and the applet as Just suggested ages ago. The
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
29 |
|
73e5e3f51b87
(finally) unified the interpreter and the applet as Just suggested ages ago. The
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
30 #ifdef __CFM68K__ |
|
2426
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
31 #pragma lib_export on |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
32 #endif |
|
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
33 |
|
10171
73e5e3f51b87
(finally) unified the interpreter and the applet as Just suggested ages ago. The
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
34 extern void PyMac_InitApplet(); |
|
10174
744db86e0311
Put the applet code inside USE_MAC_APPLET_SUPPORT ifdefs, to make 68k standalone Python compile.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10171
diff
changeset
|
35 #ifdef USE_MAC_APPLET_SUPPORT |
|
2426
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
36 extern void PyMac_InitApplication(); |
|
10174
744db86e0311
Put the applet code inside USE_MAC_APPLET_SUPPORT ifdefs, to make 68k standalone Python compile.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10171
diff
changeset
|
37 #endif /* USE_MAC_APPLET_SUPPORT */ |
|
2426
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
38 |
|
11643
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
39 |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
40 /* |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
41 ** Alternative initialization entry point for some very special cases. |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
42 ** Use this in stead of __initialize in the PEF settings to remember (and |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
43 ** re-open as resource file) the application. This is needed if we link against |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
44 ** a dynamic library that, in its own __initialize routine, opens a resource |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
45 ** file. This would mess up our finding of override preferences. |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
46 ** Only set this entrypoint in your apps if you notice sys.path or some such is |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
47 ** messed up. |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
48 */ |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
49 static int application_fss_valid; |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
50 static FSSpec application_fss; |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
51 |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
52 OSErr pascal |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
53 __initialize_remember_app_fsspec(CFragInitBlockPtr data) |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
54 { |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
55 /* Call the MW runtime's initialization routine */ |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
56 __initialize(); |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
57 if ( data == nil ) return noErr; |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
58 if ( data->fragLocator.where == kDataForkCFragLocator ) { |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
59 application_fss = *data->fragLocator.u.onDisk.fileSpec; |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
60 application_fss_valid = 1; |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
61 } else if ( data->fragLocator.where == kResourceCFragLocator ) { |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
62 application_fss = *data->fragLocator.u.inSegs.fileSpec; |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
63 application_fss_valid = 1; |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
64 } |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
65 return noErr; |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
66 } |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
67 |
| 4021 | 68 void |
|
2426
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
69 main() { |
|
11643
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
70 if ( application_fss_valid ) |
|
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
71 (void)FSpOpenResFile(&application_fss, fsRdPerm); |
|
10174
744db86e0311
Put the applet code inside USE_MAC_APPLET_SUPPORT ifdefs, to make 68k standalone Python compile.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10171
diff
changeset
|
72 #ifdef USE_MAC_APPLET_SUPPORT |
|
11643
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
73 { |
|
10171
73e5e3f51b87
(finally) unified the interpreter and the applet as Just suggested ages ago. The
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
74 Handle mainpyc; |
|
73e5e3f51b87
(finally) unified the interpreter and the applet as Just suggested ages ago. The
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
75 |
|
73e5e3f51b87
(finally) unified the interpreter and the applet as Just suggested ages ago. The
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
76 mainpyc = Get1NamedResource('PYC ', "\p__main__"); |
|
73e5e3f51b87
(finally) unified the interpreter and the applet as Just suggested ages ago. The
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
77 if (mainpyc != NULL) |
|
73e5e3f51b87
(finally) unified the interpreter and the applet as Just suggested ages ago. The
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
78 PyMac_InitApplet(); |
|
73e5e3f51b87
(finally) unified the interpreter and the applet as Just suggested ages ago. The
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
79 else |
|
73e5e3f51b87
(finally) unified the interpreter and the applet as Just suggested ages ago. The
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
80 PyMac_InitApplication(); |
|
11643
86890c073c3b
Added initializer routine optionally to be used as PEF fragment initialization routine, which allows us to get at our own resource fork even if some shared library init routine opens other resource files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10174
diff
changeset
|
81 } |
|
10174
744db86e0311
Put the applet code inside USE_MAC_APPLET_SUPPORT ifdefs, to make 68k standalone Python compile.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10171
diff
changeset
|
82 #else |
|
744db86e0311
Put the applet code inside USE_MAC_APPLET_SUPPORT ifdefs, to make 68k standalone Python compile.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10171
diff
changeset
|
83 PyMac_InitApplication(); |
|
744db86e0311
Put the applet code inside USE_MAC_APPLET_SUPPORT ifdefs, to make 68k standalone Python compile.
Jack Jansen <jack.jansen@cwi.nl>
parents:
10171
diff
changeset
|
84 #endif /* USE_MAC_APPLET_SUPPORT */ |
|
2426
9bf18996eed8
MAde a few things more orthogonal and did some cleanups:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
85 } |
