Mercurial > cpython-lru_cache-weakref
annotate Mac/Python/macglue.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 | fcb649b1004d |
| children | 5f2dcdd09329 |
| rev | line source |
|---|---|
|
2224
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
1 /*********************************************************** |
|
5079
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4522
diff
changeset
|
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, |
|
2224
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
3 The Netherlands. |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
4 |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
5 All Rights Reserved |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
6 |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
12 Centrum or CWI not be used in advertising or publicity pertaining to |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
13 distribution of the software without specific, written prior permission. |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
14 |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
22 |
|
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
23 ******************************************************************/ |
| 2035 | 24 |
| 4024 | 25 |
| 2035 | 26 #include "Python.h" |
| 2337 | 27 |
| 2035 | 28 #include "macglue.h" |
|
2350
a2054933775b
Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
29 #include "marshal.h" |
|
a2054933775b
Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
30 #include "import.h" |
|
5737
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
31 #include "importdl.h" |
|
17862
97ece9321c53
Merged mactoolboxglue.c into macglue.c. A later step will be to separate out
Jack Jansen <jack.jansen@cwi.nl>
parents:
17814
diff
changeset
|
32 #include "pymactoolbox.h" |
| 2035 | 33 |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
34 #include "pythonresources.h" |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
35 |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
36 #ifdef WITHOUT_FRAMEWORKS |
| 2035 | 37 #include <OSUtils.h> /* for Set(Current)A5 */ |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
38 #include <Files.h> |
|
2312
40aec48cd1e2
Added PyMac_GetPythonDir routine which obtains python home directory
Jack Jansen <jack.jansen@cwi.nl>
parents:
2276
diff
changeset
|
39 #include <StandardFile.h> |
| 2035 | 40 #include <Resources.h> |
| 41 #include <Memory.h> | |
| 42 #include <Windows.h> | |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
43 #include <Traps.h> |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
44 #include <Processes.h> |
|
2382
6450d8828d2b
added applet initialization;
Guido van Rossum <guido@python.org>
parents:
2350
diff
changeset
|
45 #include <Fonts.h> |
|
6450d8828d2b
added applet initialization;
Guido van Rossum <guido@python.org>
parents:
2350
diff
changeset
|
46 #include <Menus.h> |
|
2747
e41669a1dea0
Added code to obtain sys.path from a resource
Jack Jansen <jack.jansen@cwi.nl>
parents:
2668
diff
changeset
|
47 #include <TextUtils.h> |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
48 #include <LowMem.h> |
|
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
49 #include <Events.h> |
|
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
50 #else |
|
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
51 #include <Carbon/Carbon.h> |
|
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
52 #endif |
|
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
53 |
|
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
54 #if !TARGET_API_MAC_OS8 |
|
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
55 /* Unfortunately this call is probably slower... */ |
|
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
56 #define LMGetTicks() TickCount() |
|
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
57 #endif |
|
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
58 |
|
2443
2dcf7538347a
Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
59 #ifdef __MWERKS__ |
|
2dcf7538347a
Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
60 #include <SIOUX.h> |
|
13547
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
61 extern void SIOUXSetupMenus(void); |
|
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
62 extern void SIOUXDoAboutBox(void); |
|
2443
2dcf7538347a
Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
63 #endif |
|
13547
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
64 #ifdef USE_GUSI |
|
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
65 /* Functions we redefine because they're in obscure libraries */ |
|
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
66 extern void SpinCursor(short x); |
|
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
67 extern void RotateCursor(short x); |
|
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
68 extern pascal void PLstrcpy(unsigned char *, unsigned char *); |
|
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
69 extern pascal int PLstrcmp(unsigned char *, unsigned char *); |
|
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
70 extern pascal unsigned char *PLstrrchr(unsigned char *, unsigned char); |
|
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
71 |
|
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
72 #endif |
|
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
73 |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
74 #ifdef USE_GUSI1 |
|
3431
26bec9e22e5d
Added code to make fsspecs work for gusi-python
Jack Jansen <jack.jansen@cwi.nl>
parents:
3278
diff
changeset
|
75 #include <TFileSpec.h> /* For Path2FSSpec */ |
| 4197 | 76 #include <GUSI.h> |
|
3431
26bec9e22e5d
Added code to make fsspecs work for gusi-python
Jack Jansen <jack.jansen@cwi.nl>
parents:
3278
diff
changeset
|
77 #endif |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
78 |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
79 /* The ID of the Sioux apple menu */ |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
80 #define SIOUX_APPLEID 32000 |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
81 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
82 #include <signal.h> |
|
2350
a2054933775b
Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
83 #include <stdio.h> |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
84 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
85 /* |
|
3914
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
86 ** When less than this amount of stackspace is left we |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
87 ** raise a MemoryError. |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
88 */ |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
89 #ifndef MINIMUM_STACK_SIZE |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
90 #define MINIMUM_STACK_SIZE 8192 |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
91 #endif |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
92 |
|
16437
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
93 #if TARGET_API_MAC_CARBON |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
94 /* |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
95 ** On MacOSX StackSpace() lies: it gives the distance from heap end to stack pointer, |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
96 ** but the stack cannot grow that far due to rlimit values. We cannot get at this value |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
97 ** from Carbon, so we set a maximum to the stack here that is based on the default |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
98 ** stack limit of 512K. |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
99 */ |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
100 #define MAXIMUM_STACK_SIZE (256*1024) |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
101 #endif |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
102 |
|
3914
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
103 /* |
|
2443
2dcf7538347a
Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
104 ** We have to be careful, since we can't handle |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
105 ** things like updates (and they'll keep coming back if we don't |
|
2443
2dcf7538347a
Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
106 ** handle them). Note that we don't know who has windows open, so |
|
2dcf7538347a
Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
107 ** even handing updates off to SIOUX under MW isn't going to work. |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
108 */ |
|
6162
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
109 #define MAINLOOP_EVENTMASK (mDownMask|keyDownMask|osMask|activMask) |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
110 |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
111 #include <signal.h> |
| 2035 | 112 |
|
2224
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
113 /* XXX We should include Errors.h here, but it has a name conflict |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
114 ** with the python errors.h. */ |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
115 #define fnfErr -43 |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
116 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
117 /* Interrupt code variables: */ |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
118 static int interrupted; /* Set to true when cmd-. seen */ |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12855
diff
changeset
|
119 static RETSIGTYPE intcatcher(int); |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
120 |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
121 #if !TARGET_API_MAC_OSX |
|
13542
ddd6138c9e6f
ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents:
12855
diff
changeset
|
122 static int PyMac_Yield(void); |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
123 #endif |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
124 |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
125 /* |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
126 ** These are the real scheduling parameters that control what we check |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
127 ** in the event loop, and how often we check. The values are initialized |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
128 ** from pyMac_SchedParamStruct. |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
129 */ |
| 4197 | 130 |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
131 struct real_sched_param_struct { |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
132 int check_interrupt; /* if true check for command-dot */ |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
133 int process_events; /* if nonzero enable evt processing, this mask */ |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
134 int besocial; /* if nonzero be a little social with CPU */ |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
135 unsigned long check_interval; /* how often to check, in ticks */ |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
136 unsigned long bg_yield; /* yield so long when in background */ |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
137 /* these are computed from previous and clock and such */ |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
138 int enabled; /* check_interrupt OR process_event OR yield */ |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
139 unsigned long next_check; /* when to check/yield next, in ticks */ |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
140 }; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
141 |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
142 static struct real_sched_param_struct schedparams = |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
143 { 1, MAINLOOP_EVENTMASK, 1, 15, 15, 1, 0}; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
144 |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
145 /* |
| 4197 | 146 ** Workaround for sioux/gusi combo: set when we are exiting |
| 147 */ | |
| 148 int PyMac_ConsoleIsDead; | |
| 149 | |
| 150 /* | |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
151 ** Sioux menu bar, saved early so we can restore it |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
152 */ |
|
16647
728c11562187
More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents:
16557
diff
changeset
|
153 static MenuBarHandle sioux_mbar; |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
154 |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
155 /* |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
156 ** Some stuff for our GetDirectory and PromptGetFile routines |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
157 */ |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
158 struct hook_args { |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
159 int selectcur_hit; /* Set to true when "select current" selected */ |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
160 char *prompt; /* The prompt */ |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
161 }; |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17629
diff
changeset
|
162 #if !TARGET_API_MAC_OS8 |
|
12833
41c0c60dcaf5
Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents:
12281
diff
changeset
|
163 /* The StandardFile hooks don't exist in Carbon. This breaks GetDirectory, |
|
41c0c60dcaf5
Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents:
12281
diff
changeset
|
164 ** but the macfsn code will replace it by a NavServices version anyway. |
|
41c0c60dcaf5
Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents:
12281
diff
changeset
|
165 */ |
|
41c0c60dcaf5
Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents:
12281
diff
changeset
|
166 #define myhook_upp NULL |
|
41c0c60dcaf5
Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents:
12281
diff
changeset
|
167 #else |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
168 static DlgHookYDUPP myhook_upp; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
169 static int upp_inited = 0; |
|
12833
41c0c60dcaf5
Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents:
12281
diff
changeset
|
170 #endif |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
171 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
172 /* |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
173 ** The python-code event handler |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
174 */ |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
175 static PyObject *python_event_handler; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
176 |
|
11529
f83b74273da2
First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents:
8790
diff
changeset
|
177 /* |
|
f83b74273da2
First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents:
8790
diff
changeset
|
178 ** Set to true if we're appearance-compliant |
|
f83b74273da2
First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents:
8790
diff
changeset
|
179 */ |
|
f83b74273da2
First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents:
8790
diff
changeset
|
180 int PyMac_AppearanceCompliant; |
|
f83b74273da2
First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents:
8790
diff
changeset
|
181 |
|
17866
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
182 /* Given an FSSpec, return the FSSpec of the parent folder */ |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
183 |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
184 static OSErr |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
185 get_folder_parent (FSSpec * fss, FSSpec * parent) |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
186 { |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
187 CInfoPBRec rec; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
188 short err; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
189 |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
190 * parent = * fss; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
191 rec.hFileInfo.ioNamePtr = parent->name; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
192 rec.hFileInfo.ioVRefNum = parent->vRefNum; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
193 rec.hFileInfo.ioDirID = parent->parID; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
194 rec.hFileInfo.ioFDirIndex = -1; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
195 rec.hFileInfo.ioFVersNum = 0; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
196 if (err = PBGetCatInfoSync (& rec)) |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
197 return err; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
198 parent->parID = rec.dirInfo.ioDrParID; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
199 /* parent->name[0] = 0; */ |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
200 return 0; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
201 } |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
202 |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
203 /* Given an FSSpec return a full, colon-separated pathname */ |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
204 |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
205 OSErr |
|
19850
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
206 PyMac_GetFullPathname (FSSpec *fss, char *buf, int length) |
|
17866
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
207 { |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
208 short err; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
209 FSSpec fss_parent, fss_current; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
210 char tmpbuf[1024]; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
211 int plen; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
212 |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
213 fss_current = *fss; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
214 plen = fss_current.name[0]; |
|
19850
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
215 if ( plen+2 > length ) { |
|
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
216 *buf = 0; |
|
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
217 return errFSNameTooLong; |
|
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
218 } |
|
17866
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
219 memcpy(buf, &fss_current.name[1], plen); |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
220 buf[plen] = 0; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
221 /* Special case for disk names */ |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
222 if ( fss_current.parID <= 1 ) { |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
223 buf[plen++] = ':'; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
224 buf[plen] = 0; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
225 return 0; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
226 } |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
227 while (fss_current.parID > 1) { |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
228 /* Get parent folder name */ |
|
19850
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
229 if (err = get_folder_parent(&fss_current, &fss_parent)) { |
|
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
230 *buf = 0; |
|
17866
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
231 return err; |
|
19850
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
232 } |
|
17866
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
233 fss_current = fss_parent; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
234 /* Prepend path component just found to buf */ |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
235 plen = fss_current.name[0]; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
236 if (strlen(buf) + plen + 1 > 1024) { |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
237 /* Oops... Not enough space (shouldn't happen) */ |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
238 *buf = 0; |
|
19850
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
239 return errFSNameTooLong; |
|
17866
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
240 } |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
241 memcpy(tmpbuf, &fss_current.name[1], plen); |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
242 tmpbuf[plen] = ':'; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
243 strcpy(&tmpbuf[plen+1], buf); |
|
19850
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
244 if ( strlen(tmpbuf) > length ) { |
|
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
245 *buf = 0; |
|
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
246 return errFSNameTooLong; |
|
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
247 } |
|
17866
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
248 strcpy(buf, tmpbuf); |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
249 } |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
250 return 0; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
251 } |
|
13701
c68003efb796
Added PyMac_getscript() which returns the pythonic name of the current script. Not ideal and not complete, but good enough for the time being. Idea and most of the code by Fredrik Lund.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
252 |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
253 #ifdef USE_GUSI1 |
|
3433
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
254 /* |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
255 ** GUSI (1.6.0 and earlier, at the least) do not set the MacOS idea of |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
256 ** the working directory. Hence, we call this routine after each call |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
257 ** to chdir() to rectify things. |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
258 */ |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
259 void |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
260 PyMac_FixGUSIcd() |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
261 { |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
262 WDPBRec pb; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
263 FSSpec curdirfss; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
264 |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
265 if ( Path2FSSpec(":x", &curdirfss) != noErr ) |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
266 return; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
267 |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
268 /* Set MacOS "working directory" */ |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
269 pb.ioNamePtr= "\p"; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
270 pb.ioVRefNum= curdirfss.vRefNum; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
271 pb.ioWDDirID= curdirfss.parID; |
|
5270
de9d0c5249b0
Changed the few old routine names still used to the new ones
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
272 if (PBHSetVolSync(&pb) != noErr) |
|
3433
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
273 return; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
274 } |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
275 #endif |
|
4013
aa9548885b3f
Dummy SpinCursor() if __CFM68K__ is defined
Jack Jansen <jack.jansen@cwi.nl>
parents:
3914
diff
changeset
|
276 |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
277 #ifdef USE_GUSI |
|
4238
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4215
diff
changeset
|
278 /* |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4215
diff
changeset
|
279 ** SpinCursor (needed by GUSI) drags in heaps of stuff, so we |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4215
diff
changeset
|
280 ** provide a dummy here. |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4215
diff
changeset
|
281 */ |
| 4018 | 282 void SpinCursor(short x) { /* Dummy */ } |
|
7438
cd11690cb14b
- Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents:
6461
diff
changeset
|
283 void RotateCursor(short x) { /* Dummy */ } |
| 4018 | 284 |
| 4197 | 285 /* |
| 286 ** Replacement GUSI Spin function | |
| 287 */ | |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
288 #ifdef USE_GUSI1 |
| 4197 | 289 static int |
| 290 PyMac_GUSISpin(spin_msg msg, long arg) | |
| 291 { | |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
292 static Boolean inForeground = true; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
293 int maxsleep = 6; /* 6 ticks is "normal" sleeptime */ |
| 4197 | 294 |
| 295 if (PyMac_ConsoleIsDead) return 0; | |
| 296 #if 0 | |
| 297 if (inForeground) | |
| 298 SpinCursor(msg == SP_AUTO_SPIN ? short(arg) : 1); | |
| 299 #endif | |
| 300 | |
| 301 | |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
302 if ( msg == SP_AUTO_SPIN ) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
303 maxsleep = 0; |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
304 if ( msg==SP_SLEEP||msg==SP_SELECT ) { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
305 maxsleep = arg; |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
306 /* |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
307 ** We force-scan for interrupts. Not pretty, but otherwise |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
308 ** a program may hang in select or sleep forever. |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
309 */ |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
310 scan_event_queue(1); |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
311 } |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
312 if (interrupted) { |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
313 interrupted = 0; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
314 return -1; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
315 } |
| 4197 | 316 |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
317 PyMac_DoYield(maxsleep, 0); /* XXXX or is it safe to call python here? */ |
| 4197 | 318 |
| 319 return 0; | |
| 320 } | |
| 321 | |
| 322 void | |
| 323 PyMac_SetGUSISpin() { | |
| 324 GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin); | |
| 325 } | |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
326 #endif |
| 4197 | 327 |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
328 /* Called at exit() time thru atexit(), to stop event processing */ |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
329 void |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
330 PyMac_StopGUSISpin() { |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
331 PyMac_ConsoleIsDead = 1; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
332 } |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
333 |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17629
diff
changeset
|
334 #if TARGET_API_MAC_OS8 |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
335 /* |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
336 ** Replacement routines for the PLstr... functions so we don't need |
|
15825
4328ffe647bf
Disabled a few other routines that are available in CarbonLib.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15786
diff
changeset
|
337 ** StdCLib. |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
338 */ |
|
11548
c042e4140f1e
Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
339 pascal void |
|
13547
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
340 PLstrcpy(unsigned char *to, unsigned char *fr) |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
341 { |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
342 memcpy(to, fr, fr[0]+1); |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
343 } |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
344 |
|
11548
c042e4140f1e
Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
345 pascal int |
|
13547
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
346 PLstrcmp(unsigned char *s1, unsigned char *s2) |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
347 { |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
348 int res; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
349 int l = s1[0] < s2[0] ? s1[0] : s2[0]; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
350 |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
351 res = memcmp(s1+1, s2+1, l); |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
352 if ( res != 0 ) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
353 return res; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
354 |
|
8790
1076a028365a
New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents:
8665
diff
changeset
|
355 if ( s1[0] < s2[0] ) |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
356 return -1; |
|
8790
1076a028365a
New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents:
8665
diff
changeset
|
357 else if ( s1[0] > s2[0] ) |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
358 return 1; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
359 else |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
360 return 0; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
361 } |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
362 |
|
11548
c042e4140f1e
Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
363 pascal unsigned char * |
|
13547
db963a615bc9
ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents:
13542
diff
changeset
|
364 PLstrrchr(unsigned char *str, unsigned char chr) |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
365 { |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
366 unsigned char *ptr = 0; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
367 unsigned char *p; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
368 |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
369 for(p=str+1; p<str+str[0]; p++) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
370 if ( *p == chr ) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
371 ptr = p; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
372 return ptr; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
373 } |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
374 |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17629
diff
changeset
|
375 #endif /* TARGET_API_MAC_OS8 */ |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
376 #endif /* USE_GUSI */ |
|
3433
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
377 |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
378 |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
379 /* Convert C to Pascal string. Returns pointer to static buffer. */ |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
380 unsigned char * |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
381 Pstring(char *str) |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
382 { |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
383 static Str255 buf; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
384 int len; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
385 |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
386 len = strlen(str); |
|
2209
4053d4cb50e0
renamed Get routines to PyMac_Get; added macfs to config.c
Guido van Rossum <guido@python.org>
parents:
2183
diff
changeset
|
387 if (len > 255) |
|
4053d4cb50e0
renamed Get routines to PyMac_Get; added macfs to config.c
Guido van Rossum <guido@python.org>
parents:
2183
diff
changeset
|
388 len = 255; |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
389 buf[0] = (unsigned char)len; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
390 strncpy((char *)buf+1, str, len); |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
391 return buf; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
392 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
393 |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17629
diff
changeset
|
394 #if TARGET_API_MAC_OS8 |
|
21563
fcb649b1004d
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
21329
diff
changeset
|
395 Point |
|
fcb649b1004d
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
21329
diff
changeset
|
396 LMGetMouse(void) |
|
fcb649b1004d
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
21329
diff
changeset
|
397 { |
|
fcb649b1004d
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
21329
diff
changeset
|
398 return LMGetMouseLocation(); |
|
fcb649b1004d
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
21329
diff
changeset
|
399 } |
|
fcb649b1004d
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
21329
diff
changeset
|
400 |
|
fcb649b1004d
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
21329
diff
changeset
|
401 long LMGetExpandMem(void) |
|
fcb649b1004d
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
21329
diff
changeset
|
402 { |
|
fcb649b1004d
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
21329
diff
changeset
|
403 return 0; |
|
fcb649b1004d
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
21329
diff
changeset
|
404 } |
|
fcb649b1004d
This commit was manufactured by cvs2svn to create branch
cvs2svn <tools@python.org>
parents:
21329
diff
changeset
|
405 |
|
15529
a93d79da4f8c
Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14476
diff
changeset
|
406 void |
|
a93d79da4f8c
Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14476
diff
changeset
|
407 c2pstrcpy(unsigned char *dst, const char *src) |
|
a93d79da4f8c
Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14476
diff
changeset
|
408 { |
|
a93d79da4f8c
Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14476
diff
changeset
|
409 int len; |
|
a93d79da4f8c
Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14476
diff
changeset
|
410 |
|
a93d79da4f8c
Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14476
diff
changeset
|
411 len = strlen(src); |
|
a93d79da4f8c
Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14476
diff
changeset
|
412 if ( len > 255 ) len = 255; |
|
a93d79da4f8c
Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14476
diff
changeset
|
413 strncpy((char *)dst+1, src, len); |
|
a93d79da4f8c
Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14476
diff
changeset
|
414 dst[0] = len; |
|
a93d79da4f8c
Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14476
diff
changeset
|
415 } |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17629
diff
changeset
|
416 #endif /* TARGET_API_MAC_OS8 */ |
|
15529
a93d79da4f8c
Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14476
diff
changeset
|
417 |
|
3786
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
418 #ifdef USE_STACKCHECK |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
419 /* Check for stack overflow */ |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
420 int |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
421 PyOS_CheckStack() |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
422 { |
|
14197
2787e93817c6
Cheaper implementation of PyOS_CheckStack: only call StackSpace once and keep a sentinel in a static variable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13701
diff
changeset
|
423 char here; |
|
2787e93817c6
Cheaper implementation of PyOS_CheckStack: only call StackSpace once and keep a sentinel in a static variable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13701
diff
changeset
|
424 static char *sentinel = 0; |
|
14476
71456782d8fd
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14197
diff
changeset
|
425 static PyThreadState *thread_for_sentinel = 0; |
|
3786
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
426 |
|
16437
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
427 if ( sentinel == 0 ) { |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
428 unsigned long stackspace = StackSpace(); |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
429 |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
430 #ifdef MAXIMUM_STACK_SIZE |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
431 /* See the comment at the definition */ |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
432 if ( stackspace > MAXIMUM_STACK_SIZE ) |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
433 stackspace = MAXIMUM_STACK_SIZE; |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
434 #endif |
|
679f826b24ca
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents:
15839
diff
changeset
|
435 sentinel = &here - stackspace + MINIMUM_STACK_SIZE; |
|
14197
2787e93817c6
Cheaper implementation of PyOS_CheckStack: only call StackSpace once and keep a sentinel in a static variable.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13701
diff
changeset
|
436 } |
|
14476
71456782d8fd
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14197
diff
changeset
|
437 if ( thread_for_sentinel == 0 ) { |
|
71456782d8fd
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14197
diff
changeset
|
438 thread_for_sentinel = PyThreadState_Get(); |
|
71456782d8fd
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14197
diff
changeset
|
439 } |
|
71456782d8fd
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14197
diff
changeset
|
440 if ( &here < sentinel ) { |
|
71456782d8fd
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14197
diff
changeset
|
441 if (thread_for_sentinel == PyThreadState_Get()) { |
|
71456782d8fd
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14197
diff
changeset
|
442 return -1; |
|
71456782d8fd
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14197
diff
changeset
|
443 #if 0 |
|
71456782d8fd
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14197
diff
changeset
|
444 } else { |
|
71456782d8fd
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14197
diff
changeset
|
445 /* Else we are unsure... */ |
|
71456782d8fd
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14197
diff
changeset
|
446 fprintf(stderr, "Stackcheck in other thread (was %x now %x)\n", thread_for_sentinel,PyThreadState_Get()); |
|
71456782d8fd
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14197
diff
changeset
|
447 #endif |
|
71456782d8fd
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14197
diff
changeset
|
448 } |
|
71456782d8fd
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14197
diff
changeset
|
449 } |
|
3786
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
450 return 0; |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
451 } |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
452 #endif /* USE_STACKCHECK */ |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
453 |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
454 #if !TARGET_API_MAC_OSX |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
455 /* The catcher routine (which may not be used for all compilers) */ |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
456 static RETSIGTYPE |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
457 intcatcher(sig) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
458 int sig; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
459 { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
460 interrupted = 1; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
461 signal(SIGINT, intcatcher); |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
462 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
463 |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
464 void |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
465 PyOS_InitInterrupts() |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
466 { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
467 if (signal(SIGINT, SIG_IGN) != SIG_IGN) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
468 signal(SIGINT, intcatcher); |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
469 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
470 |
|
5962
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
471 void |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
472 PyOS_FiniInterrupts() |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
473 { |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
474 } |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
475 |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
476 /* Check whether we are in the foreground */ |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
477 static int |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
478 PyMac_InForeground(void) |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
479 { |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
480 static ProcessSerialNumber ours; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
481 static inited; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
482 ProcessSerialNumber curfg; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
483 Boolean eq; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
484 |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
485 if ( inited == 0 ) { |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
486 (void)GetCurrentProcess(&ours); |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
487 inited = 1; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
488 } |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
489 if ( GetFrontProcess(&curfg) < 0 ) |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
490 eq = 1; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
491 else if ( SameProcess(&ours, &curfg, &eq) < 0 ) |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
492 eq = 1; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
493 return (int)eq; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
494 } |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
495 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
496 /* |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
497 ** This routine scans the event queue looking for cmd-. |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
498 */ |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
499 static void |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
500 scan_event_queue(force) |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
501 int force; |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
502 { |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17629
diff
changeset
|
503 #if !TARGET_API_MAC_OS8 |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
504 if ( interrupted || (!schedparams.check_interrupt && !force) ) |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
505 return; |
|
15839
3b643653e078
Fixed Carbon command-dot handling. There is still a problem, though, and you may have to hit it repeatedly.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15825
diff
changeset
|
506 if ( CheckEventQueueForUserCancel() ) |
|
3b643653e078
Fixed Carbon command-dot handling. There is still a problem, though, and you may have to hit it repeatedly.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15825
diff
changeset
|
507 interrupted = 1; |
|
12833
41c0c60dcaf5
Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents:
12281
diff
changeset
|
508 #else |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
509 register EvQElPtr q; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
510 |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
511 if ( interrupted || (!schedparams.check_interrupt && !force) || !PyMac_InForeground() ) |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
512 return; |
|
7438
cd11690cb14b
- Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents:
6461
diff
changeset
|
513 q = (EvQElPtr) LMGetEventQueue()->qHead; |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
514 |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
515 for (; q; q = (EvQElPtr)q->qLink) { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
516 if (q->evtQWhat == keyDown && |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
517 (char)q->evtQMessage == '.' && |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
518 (q->evtQModifiers & cmdKey) != 0) { |
|
21113
ed3dce17fc79
Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents:
20949
diff
changeset
|
519 FlushEvents(keyDownMask, 0); |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
520 interrupted = 1; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
521 break; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
522 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
523 } |
|
12833
41c0c60dcaf5
Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents:
12281
diff
changeset
|
524 #endif |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
525 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
526 |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
527 int |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
528 PyErr_CheckSignals() |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
529 { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
530 if (schedparams.enabled) { |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
531 if ( interrupted || (unsigned long)LMGetTicks() > schedparams.next_check ) { |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
532 scan_event_queue(0); |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
533 if (interrupted) { |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
534 interrupted = 0; |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
535 PyErr_SetNone(PyExc_KeyboardInterrupt); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
536 return -1; |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
537 } |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
538 if ( PyMac_Yield() < 0) |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
539 return -1; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
540 schedparams.next_check = (unsigned long)LMGetTicks() |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
541 + schedparams.check_interval; |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
542 } |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
543 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
544 return 0; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
545 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
546 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
547 int |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
548 PyOS_InterruptOccurred() |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
549 { |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
550 scan_event_queue(0); |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
551 if ( !interrupted ) |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
552 return 0; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
553 interrupted = 0; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
554 return 1; |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
555 } |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
556 #endif |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
557 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
558 int |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
559 PyMac_SetEventHandler(PyObject *evh) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
560 { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
561 if ( evh && python_event_handler ) { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
562 PyErr_SetString(PyExc_RuntimeError, "Python event handler already set"); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
563 return 0; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
564 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
565 if ( python_event_handler ) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
566 Py_DECREF(python_event_handler); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
567 if ( evh ) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
568 Py_INCREF(evh); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
569 python_event_handler = evh; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
570 return 1; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
571 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
572 |
| 2035 | 573 /* |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
574 ** Handle an event, either one found in the mainloop eventhandler or |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
575 ** one passed back from the python program. |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
576 */ |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
577 void |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
578 PyMac_HandleEventIntern(evp) |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
579 EventRecord *evp; |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
580 { |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17629
diff
changeset
|
581 #if TARGET_API_MAC_OS8 |
|
6162
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
582 if ( evp->what == mouseDown ) { |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
583 WindowPtr wp; |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
584 |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
585 if ( FindWindow(evp->where, &wp) == inSysWindow ) { |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
586 SystemClick(evp, wp); |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
587 return; |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
588 } |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
589 } |
|
12833
41c0c60dcaf5
Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents:
12281
diff
changeset
|
590 #endif |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
591 #ifdef __MWERKS__ |
|
3248
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
592 { |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
593 int siouxdidit; |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
594 |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
595 /* If SIOUX wants it we're done */ |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
596 siouxdidit = SIOUXHandleOneEvent(evp); |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
597 if ( siouxdidit ) |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
598 return; |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
599 } |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
600 #else |
|
6162
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
601 /* Other compilers are just unlucky... */ |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
602 #endif /* !__MWERKS__ */ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
603 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
604 |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
605 /* |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
606 ** Handle an event, either through HandleEvent or by passing it to the Python |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
607 ** event handler. |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
608 */ |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
609 int |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
610 PyMac_HandleEvent(evp) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
611 EventRecord *evp; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
612 { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
613 PyObject *rv; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
614 |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
615 if ( python_event_handler ) { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
616 rv = PyObject_CallFunction(python_event_handler, "(O&)", |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
617 PyMac_BuildEventRecord, evp); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
618 if ( rv ) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
619 Py_DECREF(rv); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
620 else |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
621 return -1; /* Propagate exception */ |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
622 } else { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
623 PyMac_HandleEventIntern(evp); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
624 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
625 return 0; |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
626 } |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
627 |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
628 #if !TARGET_API_MAC_OSX |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
629 /* |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
630 ** Yield the CPU to other tasks without processing events. |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
631 */ |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
632 int |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
633 PyMac_DoYield(int maxsleep, int maycallpython) |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
634 { |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
635 EventRecord ev; |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
636 int gotone; |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
637 long latest_time_ready; |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
638 static int in_here = 0; |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
639 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
640 in_here++; |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
641 |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
642 /* |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
643 ** Check which of the eventloop cases we have: |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
644 ** - process events |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
645 ** - don't process events but do yield |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
646 ** - do neither |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
647 */ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
648 if( in_here > 1 || !schedparams.process_events || |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
649 (python_event_handler && !maycallpython) ) { |
|
17629
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
650 if ( maxsleep >= 0 ) { |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17629
diff
changeset
|
651 #if TARGET_API_MAC_OS8 |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
652 SystemTask(); |
|
17629
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
653 #else |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
654 int xxx = 0; |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
655 #endif |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
656 } |
| 4197 | 657 } else { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
658 latest_time_ready = LMGetTicks() + maxsleep; |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
659 do { |
|
6162
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
660 /* XXXX Hack by Jack. |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
661 ** In time.sleep() you can click to another application |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
662 ** once only. If you come back to Python you cannot get away |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
663 ** again. |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
664 **/ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
665 gotone = WaitNextEvent(schedparams.process_events, &ev, maxsleep, NULL); |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
666 /* Get out quickly if nothing interesting is happening */ |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
667 if ( !gotone || ev.what == nullEvent ) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
668 break; |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
669 if ( PyMac_HandleEvent(&ev) < 0 ) { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
670 in_here--; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
671 return -1; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
672 } |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
673 maxsleep = latest_time_ready - LMGetTicks(); |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
674 } while ( maxsleep > 0 ); |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
675 } |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
676 in_here--; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
677 return 0; |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
678 } |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
679 |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
680 /* |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
681 ** Process events and/or yield the CPU to other tasks if opportune |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
682 */ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
683 int |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
684 PyMac_Yield() { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
685 unsigned long maxsleep; |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
686 |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
687 if( PyMac_InForeground() ) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
688 maxsleep = 0; |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
689 else |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
690 maxsleep = schedparams.bg_yield; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
691 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
692 return PyMac_DoYield(maxsleep, 1); |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
693 } |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
694 |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
695 /* |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
696 ** Return current scheduler parameters |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
697 */ |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
698 void |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
699 PyMac_GetSchedParams(PyMacSchedParams *sp) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
700 { |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
701 sp->check_interrupt = schedparams.check_interrupt; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
702 sp->process_events = schedparams.process_events; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
703 sp->besocial = schedparams.besocial; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
704 sp->check_interval = schedparams.check_interval / 60.0; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
705 sp->bg_yield = schedparams.bg_yield / 60.0; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
706 } |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
707 |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
708 /* |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
709 ** Set current scheduler parameters |
| 2035 | 710 */ |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
711 void |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
712 PyMac_SetSchedParams(PyMacSchedParams *sp) |
| 2035 | 713 { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
714 schedparams.check_interrupt = sp->check_interrupt; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
715 schedparams.process_events = sp->process_events; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
716 schedparams.besocial = sp->besocial; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
717 schedparams.check_interval = (unsigned long)(sp->check_interval*60); |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
718 schedparams.bg_yield = (unsigned long)(sp->bg_yield*60); |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
719 if ( schedparams.check_interrupt || schedparams.process_events || |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
720 schedparams.besocial ) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
721 schedparams.enabled = 1; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
722 else |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
723 schedparams.enabled = 0; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
724 schedparams.next_check = 0; /* Check immedeately */ |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
725 } |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
726 |
|
2350
a2054933775b
Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
727 /* |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
728 ** Install our menu bar. |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
729 */ |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
730 void |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
731 PyMac_InitMenuBar() |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
732 { |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
733 MenuHandle applemenu; |
|
21329
848f6988829f
The new menu initialization code would also add the SIOUX menus if a (frozen) Python program had installed its own menubar previously. We now guard against this, with a bit of a hack: FrameWork uses the same Menu ID as Sioux, and the init code checks that the text in the menu is "About SIOUX" before replacing it.
Jack Jansen <jack.jansen@cwi.nl>
parents:
21113
diff
changeset
|
734 Str255 about_text; |
|
848f6988829f
The new menu initialization code would also add the SIOUX menus if a (frozen) Python program had installed its own menubar previously. We now guard against this, with a bit of a hack: FrameWork uses the same Menu ID as Sioux, and the init code checks that the text in the menu is "About SIOUX" before replacing it.
Jack Jansen <jack.jansen@cwi.nl>
parents:
21113
diff
changeset
|
735 static unsigned char about_sioux[] = "\pAbout SIOUX"; |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
736 |
|
17629
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
737 if ( sioux_mbar ) return; |
|
20828
6f259f7bbed8
We always install the Sioux menubar, in stead of only when no menubar
Jack Jansen <jack.jansen@cwi.nl>
parents:
19850
diff
changeset
|
738 #if 0 |
|
6f259f7bbed8
We always install the Sioux menubar, in stead of only when no menubar
Jack Jansen <jack.jansen@cwi.nl>
parents:
19850
diff
changeset
|
739 /* This code does not seem to work anymore: apparently |
|
6f259f7bbed8
We always install the Sioux menubar, in stead of only when no menubar
Jack Jansen <jack.jansen@cwi.nl>
parents:
19850
diff
changeset
|
740 ** we now always have a menubar (since MacOS9?). |
|
6f259f7bbed8
We always install the Sioux menubar, in stead of only when no menubar
Jack Jansen <jack.jansen@cwi.nl>
parents:
19850
diff
changeset
|
741 ** So we simply always setup the Sioux menus here. |
|
6f259f7bbed8
We always install the Sioux menubar, in stead of only when no menubar
Jack Jansen <jack.jansen@cwi.nl>
parents:
19850
diff
changeset
|
742 */ |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
743 if ( (sioux_mbar=GetMenuBar()) == NULL ) { |
|
20828
6f259f7bbed8
We always install the Sioux menubar, in stead of only when no menubar
Jack Jansen <jack.jansen@cwi.nl>
parents:
19850
diff
changeset
|
744 #else |
|
21113
ed3dce17fc79
Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents:
20949
diff
changeset
|
745 if ( (sioux_mbar=GetMenuBar()) == NULL || GetMenuHandle(SIOUX_APPLEID) == NULL) { |
|
20828
6f259f7bbed8
We always install the Sioux menubar, in stead of only when no menubar
Jack Jansen <jack.jansen@cwi.nl>
parents:
19850
diff
changeset
|
746 #endif |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
747 /* Sioux menu not installed yet. Do so */ |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
748 SIOUXSetupMenus(); |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
749 if ( (sioux_mbar=GetMenuBar()) == NULL ) |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
750 return; |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
751 } |
|
5270
de9d0c5249b0
Changed the few old routine names still used to the new ones
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
752 if ( (applemenu=GetMenuHandle(SIOUX_APPLEID)) == NULL ) return; |
|
21329
848f6988829f
The new menu initialization code would also add the SIOUX menus if a (frozen) Python program had installed its own menubar previously. We now guard against this, with a bit of a hack: FrameWork uses the same Menu ID as Sioux, and the init code checks that the text in the menu is "About SIOUX" before replacing it.
Jack Jansen <jack.jansen@cwi.nl>
parents:
21113
diff
changeset
|
753 GetMenuItemText(applemenu, 1, about_text); |
|
848f6988829f
The new menu initialization code would also add the SIOUX menus if a (frozen) Python program had installed its own menubar previously. We now guard against this, with a bit of a hack: FrameWork uses the same Menu ID as Sioux, and the init code checks that the text in the menu is "About SIOUX" before replacing it.
Jack Jansen <jack.jansen@cwi.nl>
parents:
21113
diff
changeset
|
754 if ( about_text[0] == about_sioux[0] && |
|
848f6988829f
The new menu initialization code would also add the SIOUX menus if a (frozen) Python program had installed its own menubar previously. We now guard against this, with a bit of a hack: FrameWork uses the same Menu ID as Sioux, and the init code checks that the text in the menu is "About SIOUX" before replacing it.
Jack Jansen <jack.jansen@cwi.nl>
parents:
21113
diff
changeset
|
755 strncmp((char *)(about_text+1), (char *)(about_sioux+1), about_text[0]) == 0 ) |
|
848f6988829f
The new menu initialization code would also add the SIOUX menus if a (frozen) Python program had installed its own menubar previously. We now guard against this, with a bit of a hack: FrameWork uses the same Menu ID as Sioux, and the init code checks that the text in the menu is "About SIOUX" before replacing it.
Jack Jansen <jack.jansen@cwi.nl>
parents:
21113
diff
changeset
|
756 SetMenuItemText(applemenu, 1, "\pAbout Python..."); |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
757 } |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
758 |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
759 /* |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
760 ** Restore sioux menu bar |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
761 */ |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
762 void |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
763 PyMac_RestoreMenuBar() |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
764 { |
|
17629
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
765 #if 1 |
|
16647
728c11562187
More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents:
16557
diff
changeset
|
766 /* This doesn't seem to work anymore? Or only for Carbon? */ |
|
728c11562187
More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents:
16557
diff
changeset
|
767 MenuBarHandle curmenubar; |
|
728c11562187
More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents:
16557
diff
changeset
|
768 |
|
728c11562187
More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents:
16557
diff
changeset
|
769 curmenubar = GetMenuBar(); |
|
5737
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
770 if ( sioux_mbar ) { |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
771 SetMenuBar(sioux_mbar); |
|
5737
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
772 DrawMenuBar(); |
|
16647
728c11562187
More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents:
16557
diff
changeset
|
773 } else { |
|
7438
cd11690cb14b
- Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents:
6461
diff
changeset
|
774 PyMac_InitMenuBar(); |
|
16647
728c11562187
More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents:
16557
diff
changeset
|
775 DrawMenuBar(); |
|
728c11562187
More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents:
16557
diff
changeset
|
776 } |
|
728c11562187
More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents:
16557
diff
changeset
|
777 #endif |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
778 } |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
779 |
|
17629
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
780 void |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
781 PyMac_RaiseConsoleWindow() |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
782 { |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
783 /* Note: this is a hack. SIOUXTextWindow is SIOUX's internal structure |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
784 ** and we happen to know that the first entry is the window pointer. |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
785 */ |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
786 extern WindowRef *SIOUXTextWindow; |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
787 |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
788 if ( SIOUXTextWindow == NULL || *SIOUXTextWindow == NULL ) |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
789 return; |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
790 if ( FrontWindow() != *SIOUXTextWindow ) |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
791 BringToFront(*SIOUXTextWindow); |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
792 } |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
793 |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
794 /* |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
795 ** Our replacement about box |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
796 */ |
|
8790
1076a028365a
New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents:
8665
diff
changeset
|
797 |
|
1076a028365a
New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents:
8665
diff
changeset
|
798 #include "patchlevel.h" |
|
1076a028365a
New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents:
8665
diff
changeset
|
799 |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
800 void |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
801 SIOUXDoAboutBox(void) |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
802 { |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
803 DialogPtr theDialog; |
|
8790
1076a028365a
New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents:
8665
diff
changeset
|
804 WindowPtr theWindow; |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
805 short item; |
|
8790
1076a028365a
New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents:
8665
diff
changeset
|
806 short fontID; |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
807 |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
808 if( (theDialog = GetNewDialog(ABOUT_ID, NULL, (WindowPtr)-1)) == NULL ) |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
809 return; |
|
4325
12c3865aeaa0
Changed default background yield time to 1 tick
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
810 theWindow = GetDialogWindow(theDialog); |
|
8790
1076a028365a
New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents:
8665
diff
changeset
|
811 SetPortWindowPort(theWindow); |
|
1076a028365a
New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents:
8665
diff
changeset
|
812 GetFNum("\pPython-Sans", &fontID); |
|
1076a028365a
New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents:
8665
diff
changeset
|
813 if (fontID == 0) |
|
1076a028365a
New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents:
8665
diff
changeset
|
814 fontID = kFontIDGeneva; |
|
1076a028365a
New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents:
8665
diff
changeset
|
815 TextFont(fontID); |
|
1076a028365a
New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents:
8665
diff
changeset
|
816 TextSize(9); |
|
19393
0f873d06ac13
PATCHLEVEL is outdated, use PY_VERSION.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19064
diff
changeset
|
817 ParamText(Pstring(PY_VERSION), "\p", "\p", "\p"); |
|
4325
12c3865aeaa0
Changed default background yield time to 1 tick
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
818 ShowWindow(theWindow); |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
819 ModalDialog(NULL, &item); |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
820 DisposeDialog(theDialog); |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
821 } |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
822 |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
823 #endif /* !TARGET_API_MAC_OSX */ |
|
5737
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
824 |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
825 #if TARGET_API_MAC_OS8 |
|
5737
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
826 /* |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
827 ** Helper routine for GetDirectory |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
828 */ |
|
2412
75ae104f7e6c
ported to MPW, moved main() here
Guido van Rossum <guido@python.org>
parents:
2403
diff
changeset
|
829 static pascal short |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
830 myhook_proc(short item, DialogPtr theDialog, struct hook_args *dataptr) |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
831 { |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
832 if ( item == sfHookFirstCall && dataptr->prompt) { |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
833 Handle prompth; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
834 short type; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
835 Rect rect; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
836 |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
837 GetDialogItem(theDialog, PROMPT_ITEM, &type, &prompth, &rect); |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
838 if ( prompth ) |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
839 SetDialogItemText(prompth, (unsigned char *)dataptr->prompt); |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
840 } else |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
841 if ( item == SELECTCUR_ITEM ) { |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
842 item = sfItemCancelButton; |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
843 dataptr->selectcur_hit = 1; |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
844 } |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
845 return item; |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
846 } |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
847 |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
848 /* |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
849 ** Ask the user for a directory. I still can't understand |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
850 ** why Apple doesn't provide a standard solution for this... |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
851 */ |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
852 int |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
853 PyMac_GetDirectory(dirfss, prompt) |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
854 FSSpec *dirfss; |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
855 char *prompt; |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
856 { |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
857 static SFTypeList list = {'fldr', 0, 0, 0}; |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
858 static Point where = {-1, -1}; |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
859 StandardFileReply reply; |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
860 struct hook_args hook_args; |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
861 |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
862 if ( !upp_inited ) { |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
863 myhook_upp = NewDlgHookYDProc(myhook_proc); |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
864 upp_inited = 1; |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
865 } |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
866 if ( prompt && *prompt ) |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
867 hook_args.prompt = (char *)Pstring(prompt); |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
868 else |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
869 hook_args.prompt = NULL; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
870 hook_args.selectcur_hit = 0; |
|
2412
75ae104f7e6c
ported to MPW, moved main() here
Guido van Rossum <guido@python.org>
parents:
2403
diff
changeset
|
871 CustomGetFile((FileFilterYDUPP)0, 1, list, &reply, GETDIR_ID, where, myhook_upp, |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
872 NULL, NULL, NULL, (void *)&hook_args); |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
873 |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
874 reply.sfFile.name[0] = 0; |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
875 if( FSMakeFSSpec(reply.sfFile.vRefNum, reply.sfFile.parID, reply.sfFile.name, dirfss) ) |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
876 return 0; |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
877 return hook_args.selectcur_hit; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
878 } |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
879 |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
880 /* |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
881 ** Slightly extended StandardGetFile: accepts a prompt */ |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
882 void PyMac_PromptGetFile(short numTypes, ConstSFTypeListPtr typeList, |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
883 StandardFileReply *reply, char *prompt) |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
884 { |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
885 static Point where = {-1, -1}; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
886 struct hook_args hook_args; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
887 |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
888 if ( !upp_inited ) { |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
889 myhook_upp = NewDlgHookYDProc(myhook_proc); |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
890 upp_inited = 1; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
891 } |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
892 if ( prompt && *prompt ) |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
893 hook_args.prompt = (char *)Pstring(prompt); |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
894 else |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
895 hook_args.prompt = NULL; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
896 hook_args.selectcur_hit = 0; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
897 CustomGetFile((FileFilterYDUPP)0, numTypes, typeList, reply, GETFILEPROMPT_ID, where, |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
898 myhook_upp, NULL, NULL, NULL, (void *)&hook_args); |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
899 } |
|
17813
8cd8741ebec0
Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17629
diff
changeset
|
900 #endif /* TARGET_API_MAC_OS8 */ |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
901 |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
902 |
