annotate Mac/Python/macshlglue.c @ 4566:6403c94de50d legacy-trunk

Added safeguard against failure in __del__.
author Guido van Rossum <guido@python.org>
date Wed, 27 Nov 1996 19:39:58 +0000
parents 650031e1e419
children d6b292a33cfe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2316
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
1 /*
4120
650031e1e419 Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents: 4023
diff changeset
2 ** Shared library initialization code.
650031e1e419 Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents: 4023
diff changeset
3 **
650031e1e419 Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents: 4023
diff changeset
4 ** 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
5 ** 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
6 ** 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
7 ** 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
8 **
650031e1e419 Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents: 4023
diff changeset
9 ** 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
10 ** 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
11 ** 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
12 ** 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
13 */
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
14
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
15 #include <Quickdraw.h>
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
16 #include <SegLoad.h>
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
17 #include <FragLoad.h>
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
18 #include <Files.h>
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
19 #include <Resources.h>
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
20
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
21
2410
403a5631214b ported to CFM-68K
Guido van Rossum <guido@python.org>
parents: 2332
diff changeset
22 /*
403a5631214b ported to CFM-68K
Guido van Rossum <guido@python.org>
parents: 2332
diff changeset
23 ** Variables passed from shared lib initialization to PyMac_AddLibResources.
403a5631214b ported to CFM-68K
Guido van Rossum <guido@python.org>
parents: 2332
diff changeset
24 */
403a5631214b ported to CFM-68K
Guido van Rossum <guido@python.org>
parents: 2332
diff changeset
25 static int library_fss_valid;
403a5631214b ported to CFM-68K
Guido van Rossum <guido@python.org>
parents: 2332
diff changeset
26 static FSSpec library_fss;
403a5631214b ported to CFM-68K
Guido van Rossum <guido@python.org>
parents: 2332
diff changeset
27
2316
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
28 /*
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
29 ** 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
30 ** 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
31 */
2410
403a5631214b ported to CFM-68K
Guido van Rossum <guido@python.org>
parents: 2332
diff changeset
32 OSErr pascal
4120
650031e1e419 Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents: 4023
diff changeset
33 __initialize_with_resources(InitBlockPtr data)
2316
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
34 {
4016
938918ff3537 Guido: changed __sinit to __initialize for CFM68K.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3424
diff changeset
35 /* 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
36 /* #ifdef __CFM68K__ */
650031e1e419 Always call __initialize(), also on PPC
Jack Jansen <jack.jansen@cwi.nl>
parents: 4023
diff changeset
37 #if 1
4016
938918ff3537 Guido: changed __sinit to __initialize for CFM68K.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3424
diff changeset
38 __initialize();
4023
892f4561648a Fixed to work for ppc and cfm68k
Jack Jansen <jack.jansen@cwi.nl>
parents: 4016
diff changeset
39 #else
892f4561648a Fixed to work for ppc and cfm68k
Jack Jansen <jack.jansen@cwi.nl>
parents: 4016
diff changeset
40 __sinit();
892f4561648a Fixed to work for ppc and cfm68k
Jack Jansen <jack.jansen@cwi.nl>
parents: 4016
diff changeset
41 #endif
3424
24bee3783b35 Added __sinit() call, so C++ initializations in shared library work
Jack Jansen <jack.jansen@cwi.nl>
parents: 3401
diff changeset
42
2410
403a5631214b ported to CFM-68K
Guido van Rossum <guido@python.org>
parents: 2332
diff changeset
43 if ( data == nil ) return noErr;
2316
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
44 if ( data->fragLocator.where == kOnDiskFlat ) {
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
45 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
46 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
47 } else if ( data->fragLocator.where == kOnDiskSegmented ) {
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
48 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
49 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
50 }
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
51 return noErr;
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
52 }
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
53
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
54 /*
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
55 ** 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
56 ** 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
57 ** 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
58 */
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
59 void
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
60 PyMac_AddLibResources()
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
61 {
ed821a99ba39 Glue for the python shared library: an init routine that remembers
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
62 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
63 return;
3189
02c8f74d08dc Removed unused variables
Jack Jansen <jack.jansen@cwi.nl>
parents: 2727
diff changeset
64 (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
65 }
2410
403a5631214b ported to CFM-68K
Guido van Rossum <guido@python.org>
parents: 2332
diff changeset
66