Mercurial > cpython-lru_cache-weakref
annotate Mac/Python/macshlglue.c @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | 2329ccf0e581 |
| children | 33d59336e7e6 |
| rev | line source |
|---|---|
|
5079
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
1 /*********************************************************** |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
3 The Netherlands. |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
4 |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
5 All Rights Reserved |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
6 |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
12 Centrum or CWI or Corporation for National Research Initiatives or |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
13 CNRI not be used in advertising or publicity pertaining to |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
14 distribution of the software without specific, written prior |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
15 permission. |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
16 |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
17 While CWI is the initial source for this software, a modified version |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
18 is made available by the Corporation for National Research Initiatives |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
19 (CNRI) at the Internet address ftp://ftp.python.org. |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
20 |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
28 PERFORMANCE OF THIS SOFTWARE. |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
29 |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
30 ******************************************************************/ |
|
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4120
diff
changeset
|
31 |
|
2316
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
32 /* |
|
4120
650031e1e419
Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents:
4023
diff
changeset
|
33 ** Shared library initialization code. |
|
650031e1e419
Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents:
4023
diff
changeset
|
34 ** |
|
650031e1e419
Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents:
4023
diff
changeset
|
35 ** This code calls the MetroWerks shared-library initialization code |
|
650031e1e419
Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents:
4023
diff
changeset
|
36 ** and performs one extra step: it remembers the FSSpec of the file |
|
650031e1e419
Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents:
4023
diff
changeset
|
37 ** we are loaded from, so we can later call PyMac_AddLibResources to |
|
650031e1e419
Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents:
4023
diff
changeset
|
38 ** add the file to our resource file chain. |
|
650031e1e419
Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents:
4023
diff
changeset
|
39 ** |
|
650031e1e419
Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents:
4023
diff
changeset
|
40 ** This file is needed for PythonCore and for any dynamically loaded |
|
650031e1e419
Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents:
4023
diff
changeset
|
41 ** module that has interesting resources in its .slb file. |
|
650031e1e419
Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents:
4023
diff
changeset
|
42 ** Use by replacing __initialize in the "CFM preferences" init field |
|
650031e1e419
Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents:
4023
diff
changeset
|
43 ** by __initialize_with_resources. |
|
2316
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
44 */ |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
45 |
|
5430
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
46 #include <Types.h> |
|
2316
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
47 #include <Quickdraw.h> |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
48 #include <SegLoad.h> |
|
5153
1ae7e2ebc2f3
- Changed GestaltEqu.h to Gestalt.h
Jack Jansen <jack.jansen@cwi.nl>
parents:
5079
diff
changeset
|
49 #include <CodeFragments.h> |
|
2316
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
50 #include <Files.h> |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
51 #include <Resources.h> |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
52 |
| 2410 | 53 /* |
| 54 ** Variables passed from shared lib initialization to PyMac_AddLibResources. | |
| 55 */ | |
| 56 static int library_fss_valid; | |
| 57 static FSSpec library_fss; | |
| 58 | |
|
2316
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
59 /* |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
60 ** Routine called upon fragment load. We attempt to save the FSSpec from which we're |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
61 ** loaded. We always return noErr (we just continue without the resources). |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
62 */ |
| 2410 | 63 OSErr pascal |
|
5430
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
64 __initialize_with_resources(CFragInitBlockPtr data) |
|
2316
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
65 { |
|
4016
938918ff3537
Guido: changed __sinit to __initialize for CFM68K.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3424
diff
changeset
|
66 /* Call the MW runtime's initialization routine */ |
|
4120
650031e1e419
Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents:
4023
diff
changeset
|
67 /* #ifdef __CFM68K__ */ |
|
650031e1e419
Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents:
4023
diff
changeset
|
68 #if 1 |
|
4016
938918ff3537
Guido: changed __sinit to __initialize for CFM68K.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3424
diff
changeset
|
69 __initialize(); |
|
4023
892f4561648a
Fixed to work for ppc and cfm68k
Jack Jansen <jack.jansen@cwi.nl>
parents:
4016
diff
changeset
|
70 #else |
|
892f4561648a
Fixed to work for ppc and cfm68k
Jack Jansen <jack.jansen@cwi.nl>
parents:
4016
diff
changeset
|
71 __sinit(); |
|
892f4561648a
Fixed to work for ppc and cfm68k
Jack Jansen <jack.jansen@cwi.nl>
parents:
4016
diff
changeset
|
72 #endif |
|
3424
24bee3783b35
Added __sinit() call, so C++ initializations in shared library work
Jack Jansen <jack.jansen@cwi.nl>
parents:
3401
diff
changeset
|
73 |
| 2410 | 74 if ( data == nil ) return noErr; |
|
5430
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
75 if ( data->fragLocator.where == kDataForkCFragLocator ) { |
|
2316
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
76 library_fss = *data->fragLocator.u.onDisk.fileSpec; |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
77 library_fss_valid = 1; |
|
5430
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
78 } else if ( data->fragLocator.where == kResourceCFragLocator ) { |
|
2316
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
79 library_fss = *data->fragLocator.u.inSegs.fileSpec; |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
80 library_fss_valid = 1; |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
81 } |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
82 return noErr; |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
83 } |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
84 |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
85 /* |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
86 ** Insert the library resources into the search path. Put them after |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
87 ** the resources from the application (which we assume is the current |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
88 ** resource file). Again, we ignore errors. |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
89 */ |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
90 void |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
91 PyMac_AddLibResources() |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
92 { |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
93 if ( !library_fss_valid ) |
|
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
94 return; |
| 3189 | 95 (void)FSpOpenResFile(&library_fss, fsRdPerm); |
|
2316
ed821a99ba39
Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff
changeset
|
96 } |
| 2410 | 97 |
|
5430
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
98 /* |
|
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
99 ** Dummy main() program to keep linker happy: we want to |
|
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
100 ** use the MW AppRuntime in our shared library (better than building |
|
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
101 ** custom runtime libraries as we did before) but AppRuntime |
|
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
102 ** expects a main program. Note that it |
|
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
103 */ |
|
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
104 |
|
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
105 #pragma export off |
|
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
106 int |
|
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
107 main(int argc, char **argv) { |
|
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
108 DebugStr("\pCannot happen: PythonCore dummy main called!"); |
|
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
109 } |
|
2329ccf0e581
- Various names in CodeFragments.h have changed
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
110 #pragma export reset |
