Mercurial > cpython-lru_cache-weakref
annotate Mac/Python/macglue.c @ 27998:e27f58a50737 legacy-trunk
SF bug #690377: Dud footnote reference in distutils docs
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 21 Feb 2003 02:47:09 +0000 |
| parents | 74d1ad61f843 |
| children | 17ce12369477 |
| 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 |
|
2443
2dcf7538347a
Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
54 #ifdef __MWERKS__ |
|
2dcf7538347a
Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
55 #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
|
56 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
|
57 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
|
58 #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
|
59 #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
|
60 /* 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
|
61 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
|
62 extern void RotateCursor(short x); |
|
24012
e8a263db1be0
Changed some prototypes to match the exact definition in some faraway Apple
Jack Jansen <jack.jansen@cwi.nl>
parents:
22958
diff
changeset
|
63 extern pascal unsigned char * PLstrcpy(unsigned char *, const unsigned char *); |
|
e8a263db1be0
Changed some prototypes to match the exact definition in some faraway Apple
Jack Jansen <jack.jansen@cwi.nl>
parents:
22958
diff
changeset
|
64 extern pascal short PLstrcmp(const unsigned char *, const unsigned char *); |
|
e8a263db1be0
Changed some prototypes to match the exact definition in some faraway Apple
Jack Jansen <jack.jansen@cwi.nl>
parents:
22958
diff
changeset
|
65 extern pascal char *PLstrrchr(const unsigned char *, short); |
|
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
|
66 |
|
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 #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
|
68 |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
69 /* 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
|
70 #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
|
71 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
72 #include <signal.h> |
|
2350
a2054933775b
Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
73 #include <stdio.h> |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
74 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
75 /* |
|
3914
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
76 ** 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
|
77 ** raise a MemoryError. |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
78 */ |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
79 #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
|
80 #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
|
81 #endif |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
82 |
|
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
|
83 /* |
|
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
|
84 ** 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
|
85 ** 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
|
86 ** 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
|
87 ** 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
|
88 */ |
|
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
|
89 #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
|
90 |
|
3914
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
91 /* |
|
2443
2dcf7538347a
Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
92 ** 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
|
93 ** 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
|
94 ** 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
|
95 ** 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
|
96 */ |
|
6162
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
97 #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
|
98 |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
99 #include <signal.h> |
| 2035 | 100 |
|
2224
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
101 /* 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
|
102 ** with the python errors.h. */ |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
103 #define fnfErr -43 |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
104 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
105 /* Interrupt code variables: */ |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
106 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
|
107 static RETSIGTYPE intcatcher(int); |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
108 |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
109 #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
|
110 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
|
111 #endif |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
112 |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
113 /* |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
114 ** 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
|
115 ** 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
|
116 ** from pyMac_SchedParamStruct. |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
117 */ |
| 4197 | 118 |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 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
|
123 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
|
124 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
|
125 /* 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
|
126 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
|
127 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
|
128 }; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
129 |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
130 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
|
131 { 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
|
132 |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
133 /* |
| 4197 | 134 ** Workaround for sioux/gusi combo: set when we are exiting |
| 135 */ | |
| 136 int PyMac_ConsoleIsDead; | |
| 137 | |
| 138 /* | |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
139 ** 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
|
140 */ |
|
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
|
141 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
|
142 |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
143 /* |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
144 ** 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
|
145 */ |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
146 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
|
147 |
|
17866
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
148 /* 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
|
149 |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
150 static OSErr |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
151 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
|
152 { |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
153 CInfoPBRec rec; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
154 short err; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
155 |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
156 * parent = * fss; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
157 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
|
158 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
|
159 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
|
160 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
|
161 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
|
162 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
|
163 return err; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
164 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
|
165 /* 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
|
166 return 0; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
167 } |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
168 |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
169 /* 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
|
170 |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
171 OSErr |
|
19850
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
172 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
|
173 { |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
174 short err; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
175 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
|
176 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
|
177 int plen; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
178 |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
179 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
|
180 plen = fss_current.name[0]; |
|
19850
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
181 if ( plen+2 > length ) { |
|
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
182 *buf = 0; |
|
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
183 return errFSNameTooLong; |
|
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
184 } |
|
17866
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
185 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
|
186 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
|
187 /* 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
|
188 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
|
189 buf[plen++] = ':'; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
190 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
|
191 return 0; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
192 } |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
193 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
|
194 /* Get parent folder name */ |
|
19850
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
195 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
|
196 *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
|
197 return err; |
|
19850
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
198 } |
|
17866
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
199 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
|
200 /* 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
|
201 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
|
202 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
|
203 /* 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
|
204 *buf = 0; |
|
19850
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
205 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
|
206 } |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
207 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
|
208 tmpbuf[plen] = ':'; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
209 strcpy(&tmpbuf[plen+1], buf); |
|
19850
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
210 if ( strlen(tmpbuf) > length ) { |
|
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
211 *buf = 0; |
|
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
212 return errFSNameTooLong; |
|
2b581f4c69b4
Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19641
diff
changeset
|
213 } |
|
17866
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
214 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
|
215 } |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
216 return 0; |
|
042dca1d4526
Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents:
17862
diff
changeset
|
217 } |
|
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
|
218 |
|
4013
aa9548885b3f
Dummy SpinCursor() if __CFM68K__ is defined
Jack Jansen <jack.jansen@cwi.nl>
parents:
3914
diff
changeset
|
219 |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
220 #ifdef USE_GUSI |
|
4238
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4215
diff
changeset
|
221 /* |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4215
diff
changeset
|
222 ** 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
|
223 ** provide a dummy here. |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4215
diff
changeset
|
224 */ |
| 4018 | 225 void SpinCursor(short x) { /* Dummy */ } |
|
7438
cd11690cb14b
- Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents:
6461
diff
changeset
|
226 void RotateCursor(short x) { /* Dummy */ } |
| 4018 | 227 |
| 4197 | 228 |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
229 /* Called at exit() time thru atexit(), to stop event processing */ |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
230 void |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
231 PyMac_StopGUSISpin() { |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
232 PyMac_ConsoleIsDead = 1; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
233 } |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
234 |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
235 #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
|
236 |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
237 |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
238 /* 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
|
239 unsigned char * |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
240 Pstring(char *str) |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
241 { |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
242 static Str255 buf; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
243 int len; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
244 |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
245 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
|
246 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
|
247 len = 255; |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
248 buf[0] = (unsigned char)len; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
249 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
|
250 return buf; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
251 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
252 |
|
15529
a93d79da4f8c
Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14476
diff
changeset
|
253 |
|
3786
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
254 #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
|
255 /* 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
|
256 int |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
257 PyOS_CheckStack() |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
258 { |
|
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
|
259 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
|
260 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
|
261 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
|
262 |
|
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
|
263 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
|
264 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
|
265 |
|
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
|
266 #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
|
267 /* 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
|
268 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
|
269 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
|
270 #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
|
271 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
|
272 } |
|
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
|
273 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
|
274 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
|
275 } |
|
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
|
276 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
|
277 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
|
278 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
|
279 } |
|
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
|
280 } |
|
3786
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
281 return 0; |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
282 } |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
283 #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
|
284 |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
285 #if !TARGET_API_MAC_OSX |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
286 /* 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
|
287 static RETSIGTYPE |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
288 intcatcher(sig) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
289 int sig; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
290 { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
291 interrupted = 1; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
292 signal(SIGINT, intcatcher); |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
293 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
294 |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
295 void |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
296 PyOS_InitInterrupts() |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
297 { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
298 if (signal(SIGINT, SIG_IGN) != SIG_IGN) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
299 signal(SIGINT, intcatcher); |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
300 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
301 |
|
5962
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
302 void |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
303 PyOS_FiniInterrupts() |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
304 { |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
305 } |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
306 |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
307 /* 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
|
308 static int |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
309 PyMac_InForeground(void) |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
310 { |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
311 static ProcessSerialNumber ours; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
312 static inited; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
313 ProcessSerialNumber curfg; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
314 Boolean eq; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
315 |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
316 if ( inited == 0 ) { |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
317 (void)GetCurrentProcess(&ours); |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
318 inited = 1; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
319 } |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
320 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
|
321 eq = 1; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
322 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
|
323 eq = 1; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
324 return (int)eq; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
325 } |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
326 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
327 /* |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
328 ** 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
|
329 */ |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
330 static void |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
331 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
|
332 int force; |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
333 { |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
334 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
|
335 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
|
336 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
|
337 interrupted = 1; |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
338 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
339 |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
340 int |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
341 PyErr_CheckSignals() |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
342 { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
343 if (schedparams.enabled) { |
|
26610
74d1ad61f843
Getting rid of pre-Carbon (MacOS8) support. All code depending on
Jack Jansen <jack.jansen@cwi.nl>
parents:
24012
diff
changeset
|
344 if ( interrupted || (unsigned long)TickCount() > schedparams.next_check ) { |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
345 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
|
346 if (interrupted) { |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
347 interrupted = 0; |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
348 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
|
349 return -1; |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
350 } |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
351 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
|
352 return -1; |
|
26610
74d1ad61f843
Getting rid of pre-Carbon (MacOS8) support. All code depending on
Jack Jansen <jack.jansen@cwi.nl>
parents:
24012
diff
changeset
|
353 schedparams.next_check = (unsigned long)TickCount() |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
354 + schedparams.check_interval; |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
355 } |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
356 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
357 return 0; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
358 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
359 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
360 int |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
361 PyOS_InterruptOccurred() |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
362 { |
|
20949
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
363 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
|
364 if ( !interrupted ) |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
365 return 0; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
366 interrupted = 0; |
|
d27ce8fe43f8
Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents:
20828
diff
changeset
|
367 return 1; |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
368 } |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
369 #endif |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
370 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
371 int |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
372 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
|
373 { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
374 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
|
375 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
|
376 return 0; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
377 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
378 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
|
379 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
|
380 if ( evh ) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
381 Py_INCREF(evh); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
382 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
|
383 return 1; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
384 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
385 |
| 2035 | 386 /* |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
387 ** 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
|
388 ** 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
|
389 */ |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
390 void |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
391 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
|
392 EventRecord *evp; |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
393 { |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
394 #ifdef __MWERKS__ |
|
3248
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
395 { |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
396 int siouxdidit; |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
397 |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
398 /* If SIOUX wants it we're done */ |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
399 siouxdidit = SIOUXHandleOneEvent(evp); |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
400 if ( siouxdidit ) |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
401 return; |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
402 } |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
403 #else |
|
6162
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
404 /* 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
|
405 #endif /* !__MWERKS__ */ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
406 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
407 |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
408 /* |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
409 ** 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
|
410 ** event handler. |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
411 */ |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
412 int |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
413 PyMac_HandleEvent(evp) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
414 EventRecord *evp; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
415 { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
416 PyObject *rv; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
417 |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
418 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
|
419 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
|
420 PyMac_BuildEventRecord, evp); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
421 if ( rv ) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
422 Py_DECREF(rv); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
423 else |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
424 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
|
425 } else { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
426 PyMac_HandleEventIntern(evp); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
427 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
428 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
|
429 } |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
430 |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
431 #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
|
432 /* |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
433 ** 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
|
434 */ |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
435 int |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
436 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
|
437 { |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
438 EventRecord ev; |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
439 int gotone; |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
440 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
|
441 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
|
442 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
443 in_here++; |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
444 |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
445 /* |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
446 ** 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
|
447 ** - process events |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
448 ** - 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
|
449 ** - do neither |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
450 */ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
451 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
|
452 (python_event_handler && !maycallpython) ) { |
|
17629
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
453 if ( maxsleep >= 0 ) { |
|
26610
74d1ad61f843
Getting rid of pre-Carbon (MacOS8) support. All code depending on
Jack Jansen <jack.jansen@cwi.nl>
parents:
24012
diff
changeset
|
454 /* XXXX Need to do something here */ |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
455 } |
| 4197 | 456 } else { |
|
26610
74d1ad61f843
Getting rid of pre-Carbon (MacOS8) support. All code depending on
Jack Jansen <jack.jansen@cwi.nl>
parents:
24012
diff
changeset
|
457 latest_time_ready = TickCount() + maxsleep; |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
458 do { |
|
6162
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
459 /* 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
|
460 ** 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
|
461 ** 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
|
462 ** again. |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
463 **/ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
464 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
|
465 /* 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
|
466 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
|
467 break; |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
468 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
|
469 in_here--; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
470 return -1; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
471 } |
|
26610
74d1ad61f843
Getting rid of pre-Carbon (MacOS8) support. All code depending on
Jack Jansen <jack.jansen@cwi.nl>
parents:
24012
diff
changeset
|
472 maxsleep = latest_time_ready - TickCount(); |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
473 } while ( maxsleep > 0 ); |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
474 } |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
475 in_here--; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
476 return 0; |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
477 } |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
478 |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
479 /* |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
480 ** 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
|
481 */ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
482 int |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
483 PyMac_Yield() { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
484 unsigned long maxsleep; |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
485 |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
486 if( PyMac_InForeground() ) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
487 maxsleep = 0; |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
488 else |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
489 maxsleep = schedparams.bg_yield; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
490 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
491 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
|
492 } |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
493 |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
494 /* |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
495 ** Return current scheduler parameters |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
496 */ |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
497 void |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
498 PyMac_GetSchedParams(PyMacSchedParams *sp) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
499 { |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
500 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
|
501 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
|
502 sp->besocial = schedparams.besocial; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
503 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
|
504 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
|
505 } |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
506 |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
507 /* |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
508 ** Set current scheduler parameters |
| 2035 | 509 */ |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
510 void |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
511 PyMac_SetSchedParams(PyMacSchedParams *sp) |
| 2035 | 512 { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
513 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
|
514 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
|
515 schedparams.besocial = sp->besocial; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
516 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
|
517 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
|
518 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
|
519 schedparams.besocial ) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
520 schedparams.enabled = 1; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
521 else |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
522 schedparams.enabled = 0; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
523 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
|
524 } |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
525 |
|
2350
a2054933775b
Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
526 /* |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
527 ** 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
|
528 */ |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
529 void |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
530 PyMac_InitMenuBar() |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
531 { |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
532 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
|
533 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
|
534 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
|
535 |
|
17629
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
536 if ( sioux_mbar ) return; |
|
21113
ed3dce17fc79
Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents:
20949
diff
changeset
|
537 if ( (sioux_mbar=GetMenuBar()) == NULL || GetMenuHandle(SIOUX_APPLEID) == NULL) { |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
538 /* 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
|
539 SIOUXSetupMenus(); |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
540 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
|
541 return; |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
542 } |
|
5270
de9d0c5249b0
Changed the few old routine names still used to the new ones
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
543 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
|
544 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
|
545 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
|
546 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
|
547 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
|
548 } |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
549 |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
550 /* |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
551 ** 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
|
552 */ |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
553 void |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
554 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
|
555 { |
|
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
|
556 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
|
557 |
|
728c11562187
More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents:
16557
diff
changeset
|
558 curmenubar = GetMenuBar(); |
|
5737
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
559 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
|
560 SetMenuBar(sioux_mbar); |
|
5737
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
561 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
|
562 } else { |
|
7438
cd11690cb14b
- Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents:
6461
diff
changeset
|
563 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
|
564 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
|
565 } |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
566 } |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
567 |
|
17629
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
568 void |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
569 PyMac_RaiseConsoleWindow() |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
570 { |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
571 /* 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
|
572 ** 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
|
573 */ |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
574 extern WindowRef *SIOUXTextWindow; |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
575 |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
576 if ( SIOUXTextWindow == NULL || *SIOUXTextWindow == NULL ) |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
577 return; |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
578 if ( FrontWindow() != *SIOUXTextWindow ) |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
579 BringToFront(*SIOUXTextWindow); |
|
a9485d404f05
- Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents:
16647
diff
changeset
|
580 } |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
581 |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
582 /* |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
583 ** 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
|
584 */ |
|
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
|
585 |
|
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
|
586 #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
|
587 |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
588 void |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
589 SIOUXDoAboutBox(void) |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
590 { |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
591 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
|
592 WindowPtr theWindow; |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
593 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
|
594 short fontID; |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
595 |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
596 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
|
597 return; |
|
4325
12c3865aeaa0
Changed default background yield time to 1 tick
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
598 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
|
599 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
|
600 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
|
601 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
|
602 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
|
603 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
|
604 TextSize(9); |
|
19393
0f873d06ac13
PATCHLEVEL is outdated, use PY_VERSION.
Jack Jansen <jack.jansen@cwi.nl>
parents:
19064
diff
changeset
|
605 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
|
606 ShowWindow(theWindow); |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
607 ModalDialog(NULL, &item); |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
608 DisposeDialog(theDialog); |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
609 } |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
610 |
|
17814
2211c8995a5f
Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
611 #endif /* !TARGET_API_MAC_OSX */ |
