Mercurial > cpython-lru_cache-weakref
annotate Mac/Python/macglue.c @ 10072:ecebcd84df37 legacy-trunk
put the preferences file in a folder called "Python" inside the prefs folder, just like the IDE does -- jvr
| author | Just van Rossum <just@lettererror.com> |
|---|---|
| date | Tue, 02 Feb 1999 15:49:03 +0000 |
| parents | 1076a028365a |
| children | f83b74273da2 |
| 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 #ifdef __CFM68K__ |
| 26 /* cfm68k InterfaceLib exports GetEventQueue, but Events.h doesn't know this | |
| 27 ** and defines it as GetEvQHdr (which is correct for PPC). This fix is for | |
| 28 ** CW9, check that the workaround is still needed for the next release. | |
| 29 */ | |
| 30 #define GetEvQHdr GetEventQueue | |
| 31 #endif /* __CFM68K__ */ | |
| 32 | |
| 33 #include <Events.h> | |
| 34 | |
| 35 #ifdef __CFM68K__ | |
| 36 #undef GetEventQueue | |
| 37 #endif /* __CFM68K__ */ | |
| 38 | |
| 2035 | 39 #include "Python.h" |
| 2337 | 40 |
| 2035 | 41 #include "macglue.h" |
|
2350
a2054933775b
Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
42 #include "marshal.h" |
|
a2054933775b
Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
43 #include "import.h" |
|
5737
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
44 #include "importdl.h" |
| 2035 | 45 |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
46 #include "pythonresources.h" |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
47 |
| 2035 | 48 #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
|
49 #include <Files.h> |
|
2312
40aec48cd1e2
Added PyMac_GetPythonDir routine which obtains python home directory
Jack Jansen <jack.jansen@cwi.nl>
parents:
2276
diff
changeset
|
50 #include <StandardFile.h> |
| 2035 | 51 #include <Resources.h> |
| 52 #include <Memory.h> | |
| 53 #include <Windows.h> | |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
54 #include <Traps.h> |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
55 #include <Processes.h> |
|
2382
6450d8828d2b
added applet initialization;
Guido van Rossum <guido@python.org>
parents:
2350
diff
changeset
|
56 #include <Fonts.h> |
|
6450d8828d2b
added applet initialization;
Guido van Rossum <guido@python.org>
parents:
2350
diff
changeset
|
57 #include <Menus.h> |
|
2747
e41669a1dea0
Added code to obtain sys.path from a resource
Jack Jansen <jack.jansen@cwi.nl>
parents:
2668
diff
changeset
|
58 #include <TextUtils.h> |
|
2265
4bcc92916fab
added <OSEvents.h> for Think C
Guido van Rossum <guido@python.org>
parents:
2262
diff
changeset
|
59 #ifdef THINK_C |
|
4bcc92916fab
added <OSEvents.h> for Think C
Guido van Rossum <guido@python.org>
parents:
2262
diff
changeset
|
60 #include <OSEvents.h> /* For EvQElPtr */ |
|
4bcc92916fab
added <OSEvents.h> for Think C
Guido van Rossum <guido@python.org>
parents:
2262
diff
changeset
|
61 #endif |
|
2443
2dcf7538347a
Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
62 #ifdef __MWERKS__ |
|
2dcf7538347a
Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
63 #include <SIOUX.h> |
|
2dcf7538347a
Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
64 #endif |
|
3431
26bec9e22e5d
Added code to make fsspecs work for gusi-python
Jack Jansen <jack.jansen@cwi.nl>
parents:
3278
diff
changeset
|
65 #ifdef USE_GUSI |
|
26bec9e22e5d
Added code to make fsspecs work for gusi-python
Jack Jansen <jack.jansen@cwi.nl>
parents:
3278
diff
changeset
|
66 #include <TFileSpec.h> /* For Path2FSSpec */ |
|
3433
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
67 #include <LowMem.h> /* For SetSFCurDir, etc */ |
| 4197 | 68 #include <GUSI.h> |
|
3431
26bec9e22e5d
Added code to make fsspecs work for gusi-python
Jack Jansen <jack.jansen@cwi.nl>
parents:
3278
diff
changeset
|
69 #endif |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
70 |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
71 /* 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
|
72 #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
|
73 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
74 #include <signal.h> |
|
2350
a2054933775b
Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
75 #include <stdio.h> |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
76 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
77 /* |
|
3914
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
78 ** 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
|
79 ** raise a MemoryError. |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
80 */ |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
81 #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
|
82 #ifdef __powerc |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
83 #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
|
84 #else |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
85 #define MINIMUM_STACK_SIZE 4096 |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
86 #endif |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
87 #endif |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
88 |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
89 /* |
|
2443
2dcf7538347a
Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
90 ** 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
|
91 ** 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
|
92 ** 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
|
93 ** 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
|
94 */ |
|
6162
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
95 #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
|
96 |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
97 #include <signal.h> |
| 2035 | 98 |
|
2224
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
99 /* 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
|
100 ** with the python errors.h. */ |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
101 #define fnfErr -43 |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
102 |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
103 /* Declared in macfsmodule.c: */ |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
104 extern FSSpec *mfs_GetFSSpecFSSpec(); |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
105 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
106 /* Interrupt code variables: */ |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
107 static int interrupted; /* Set to true when cmd-. seen */ |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
108 static RETSIGTYPE intcatcher Py_PROTO((int)); |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
109 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
110 static int PyMac_DoYield Py_PROTO((int, int)); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
111 static int PyMac_Yield Py_PROTO((void)); |
|
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 */ |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
141 static Handle sioux_mbar; |
|
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 /* |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
144 ** Some stuff for our GetDirectory and PromptGetFile routines |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
145 */ |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
146 struct hook_args { |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
147 int selectcur_hit; /* Set to true when "select current" selected */ |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
148 char *prompt; /* The prompt */ |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
149 }; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
150 static DlgHookYDUPP myhook_upp; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
151 static int upp_inited = 0; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
152 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
153 /* |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
154 ** 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
|
155 */ |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
156 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
|
157 |
|
3433
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
158 #ifdef USE_GUSI |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
159 /* |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
160 ** GUSI (1.6.0 and earlier, at the least) do not set the MacOS idea of |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
161 ** the working directory. Hence, we call this routine after each call |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
162 ** to chdir() to rectify things. |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
163 */ |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
164 void |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
165 PyMac_FixGUSIcd() |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
166 { |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
167 WDPBRec pb; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
168 FSSpec curdirfss; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
169 |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
170 if ( Path2FSSpec(":x", &curdirfss) != noErr ) |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
171 return; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
172 |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
173 /* Set MacOS "working directory" */ |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
174 pb.ioNamePtr= "\p"; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
175 pb.ioVRefNum= curdirfss.vRefNum; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
176 pb.ioWDDirID= curdirfss.parID; |
|
5270
de9d0c5249b0
Changed the few old routine names still used to the new ones
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
177 if (PBHSetVolSync(&pb) != noErr) |
|
3433
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
178 return; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
179 } |
|
4013
aa9548885b3f
Dummy SpinCursor() if __CFM68K__ is defined
Jack Jansen <jack.jansen@cwi.nl>
parents:
3914
diff
changeset
|
180 |
|
4238
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4215
diff
changeset
|
181 /* |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4215
diff
changeset
|
182 ** 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
|
183 ** provide a dummy here. |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4215
diff
changeset
|
184 */ |
| 4018 | 185 void SpinCursor(short x) { /* Dummy */ } |
|
7438
cd11690cb14b
- Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents:
6461
diff
changeset
|
186 void RotateCursor(short x) { /* Dummy */ } |
| 4018 | 187 |
| 4197 | 188 /* |
| 189 ** Replacement GUSI Spin function | |
| 190 */ | |
| 191 static int | |
| 192 PyMac_GUSISpin(spin_msg msg, long arg) | |
| 193 { | |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
194 static Boolean inForeground = true; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
195 int maxsleep = 6; /* 6 ticks is "normal" sleeptime */ |
| 4197 | 196 |
| 197 if (PyMac_ConsoleIsDead) return 0; | |
| 198 #if 0 | |
| 199 if (inForeground) | |
| 200 SpinCursor(msg == SP_AUTO_SPIN ? short(arg) : 1); | |
| 201 #endif | |
| 202 | |
| 203 if (interrupted) return -1; | |
| 204 | |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
205 if ( msg == SP_AUTO_SPIN ) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
206 maxsleep = 0; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
207 if ( msg==SP_SLEEP||msg==SP_SELECT ) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
208 maxsleep = arg; |
| 4197 | 209 |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
210 PyMac_DoYield(maxsleep, 0); /* XXXX or is it safe to call python here? */ |
| 4197 | 211 |
| 212 return 0; | |
| 213 } | |
| 214 | |
| 215 void | |
| 216 PyMac_SetGUSISpin() { | |
| 217 GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin); | |
| 218 } | |
| 219 | |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
220 /* Called at exit() time thru atexit(), to stop event processing */ |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
221 void |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
222 PyMac_StopGUSISpin() { |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
223 PyMac_ConsoleIsDead = 1; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
224 } |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
225 |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
226 /* |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
227 ** Replacement routines for the PLstr... functions so we don't need |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
228 ** StdCLib. Moreover, that implementation is broken under cfm68k... |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
229 */ |
|
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 PLstrcpy(to, fr) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
232 unsigned char *to, *fr; |
|
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 memcpy(to, fr, fr[0]+1); |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
235 } |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
236 |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
237 int |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
238 PLstrcmp(s1, s2) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
239 unsigned char *s1, *s2; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
240 { |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
241 int res; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
242 int l = s1[0] < s2[0] ? s1[0] : s2[0]; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
243 |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
244 res = memcmp(s1+1, s2+1, l); |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
245 if ( res != 0 ) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
246 return res; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
247 |
|
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
|
248 if ( s1[0] < s2[0] ) |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
249 return -1; |
|
8790
1076a028365a
New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents:
8665
diff
changeset
|
250 else if ( s1[0] > s2[0] ) |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
251 return 1; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
252 else |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
253 return 0; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
254 } |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
255 |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
256 unsigned char * |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
257 PLstrrchr(str, chr) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
258 unsigned char *str; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
259 unsigned char chr; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
260 { |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
261 unsigned char *ptr = 0; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
262 unsigned char *p; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
263 |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
264 for(p=str+1; p<str+str[0]; p++) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
265 if ( *p == chr ) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
266 ptr = p; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
267 return ptr; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
268 } |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
269 |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
270 #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
|
271 |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
272 |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
273 /* 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
|
274 unsigned char * |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
275 Pstring(char *str) |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
276 { |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
277 static Str255 buf; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
278 int len; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
279 |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
280 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
|
281 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
|
282 len = 255; |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
283 buf[0] = (unsigned char)len; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
284 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
|
285 return buf; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
286 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
287 |
|
2382
6450d8828d2b
added applet initialization;
Guido van Rossum <guido@python.org>
parents:
2350
diff
changeset
|
288 /* Like strerror() but for Mac OS error numbers */ |
|
6450d8828d2b
added applet initialization;
Guido van Rossum <guido@python.org>
parents:
2350
diff
changeset
|
289 char *PyMac_StrError(int err) |
| 2035 | 290 { |
| 291 static char buf[256]; | |
| 292 Handle h; | |
| 293 char *str; | |
| 294 | |
| 295 h = GetResource('Estr', err); | |
| 296 if ( h ) { | |
| 297 HLock(h); | |
| 298 str = (char *)*h; | |
| 299 memcpy(buf, str+1, (unsigned char)str[0]); | |
|
2324
faaece7ccd6e
null-terminate the error string in macstrerror
Guido van Rossum <guido@python.org>
parents:
2312
diff
changeset
|
300 buf[(unsigned char)str[0]] = '\0'; |
| 2035 | 301 HUnlock(h); |
| 302 ReleaseResource(h); | |
| 303 } else { | |
| 304 sprintf(buf, "Mac OS error code %d", err); | |
| 305 } | |
| 306 return buf; | |
| 307 } | |
| 308 | |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
309 /* Exception object shared by all Mac specific modules for Mac OS errors */ |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
310 PyObject *PyMac_OSErrException; |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
311 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
312 /* Initialize and return PyMac_OSErrException */ |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
313 PyObject * |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
314 PyMac_GetOSErrException() |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
315 { |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
316 if (PyMac_OSErrException == NULL) |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
317 PyMac_OSErrException = PyString_FromString("Mac OS Error"); |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
318 return PyMac_OSErrException; |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
319 } |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
320 |
| 2035 | 321 /* Set a MAC-specific error from errno, and return NULL; return None if no error */ |
| 322 PyObject * | |
| 2136 | 323 PyErr_Mac(PyObject *eobj, int err) |
| 2035 | 324 { |
| 325 char *msg; | |
| 326 PyObject *v; | |
| 327 | |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
328 if (err == 0 && !PyErr_Occurred()) { |
| 2035 | 329 Py_INCREF(Py_None); |
| 330 return Py_None; | |
| 331 } | |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
332 if (err == -1 && PyErr_Occurred()) |
|
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
333 return NULL; |
|
2382
6450d8828d2b
added applet initialization;
Guido van Rossum <guido@python.org>
parents:
2350
diff
changeset
|
334 msg = PyMac_StrError(err); |
| 2035 | 335 v = Py_BuildValue("(is)", err, msg); |
| 336 PyErr_SetObject(eobj, v); | |
| 337 Py_DECREF(v); | |
| 338 return NULL; | |
| 339 } | |
| 340 | |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
341 /* Call PyErr_Mac with PyMac_OSErrException */ |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
342 PyObject * |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
343 PyMac_Error(OSErr err) |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
344 { |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
345 return PyErr_Mac(PyMac_GetOSErrException(), err); |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
346 } |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
347 |
|
3786
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
348 #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
|
349 /* 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
|
350 int |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
351 PyOS_CheckStack() |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
352 { |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
353 long left; |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
354 |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
355 left = StackSpace(); |
|
3914
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
356 if ( left < MINIMUM_STACK_SIZE ) |
|
3786
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
357 return -1; |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
358 return 0; |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
359 } |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
360 #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
|
361 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
362 /* 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
|
363 static RETSIGTYPE |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
364 intcatcher(sig) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
365 int sig; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
366 { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
367 interrupted = 1; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
368 signal(SIGINT, intcatcher); |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
369 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
370 |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
371 void |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
372 PyOS_InitInterrupts() |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
373 { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
374 if (signal(SIGINT, SIG_IGN) != SIG_IGN) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
375 signal(SIGINT, intcatcher); |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
376 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
377 |
|
5962
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
378 void |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
379 PyOS_FiniInterrupts() |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
380 { |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
381 } |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
382 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
383 /* |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
384 ** 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
|
385 ** This is the only way to get an interrupt under THINK (since it |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
386 ** doesn't do SIGINT handling), but is also used under MW, when |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
387 ** the full-fledged event loop is disabled. This way, we can at least |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
388 ** interrupt a runaway python program. |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
389 */ |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
390 static void |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
391 scan_event_queue(flush) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
392 int flush; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
393 { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
394 register EvQElPtr q; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
395 |
|
7438
cd11690cb14b
- Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents:
6461
diff
changeset
|
396 q = (EvQElPtr) LMGetEventQueue()->qHead; |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
397 |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
398 for (; q; q = (EvQElPtr)q->qLink) { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
399 if (q->evtQWhat == keyDown && |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
400 (char)q->evtQMessage == '.' && |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
401 (q->evtQModifiers & cmdKey) != 0) { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
402 if ( flush ) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
403 FlushEvents(keyDownMask, 0); |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
404 interrupted = 1; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
405 break; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
406 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
407 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
408 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
409 |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
410 int |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
411 PyErr_CheckSignals() |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
412 { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
413 if (schedparams.enabled) { |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
414 if ( (unsigned long)LMGetTicks() > schedparams.next_check ) { |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
415 if ( PyMac_Yield() < 0) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
416 return -1; |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
417 schedparams.next_check = (unsigned long)LMGetTicks() |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
418 + schedparams.check_interval; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
419 if (interrupted) { |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
420 scan_event_queue(1); /* Eat events up to cmd-. */ |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
421 interrupted = 0; |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
422 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
|
423 return -1; |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
424 } |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
425 } |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
426 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
427 return 0; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
428 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
429 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
430 int |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
431 PyOS_InterruptOccurred() |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
432 { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
433 scan_event_queue(1); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
434 return interrupted; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
435 } |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
436 /* Check whether we are in the foreground */ |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
437 int |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
438 PyMac_InForeground() |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
439 { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
440 static ProcessSerialNumber ours; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
441 static inited; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
442 ProcessSerialNumber curfg; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
443 Boolean eq; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
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 if ( inited == 0 ) { |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
446 (void)GetCurrentProcess(&ours); |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
447 inited = 1; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
448 } |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
449 if ( GetFrontProcess(&curfg) < 0 ) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
450 eq = 1; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
451 else if ( SameProcess(&ours, &curfg, &eq) < 0 ) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
452 eq = 1; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
453 return (int)eq; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
454 |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
455 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
456 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
457 int |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
458 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
|
459 { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
460 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
|
461 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
|
462 return 0; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
463 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
464 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
|
465 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
|
466 if ( evh ) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
467 Py_INCREF(evh); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
468 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
|
469 return 1; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
470 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
471 |
| 2035 | 472 /* |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
473 ** 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
|
474 ** 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
|
475 */ |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
476 void |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
477 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
|
478 EventRecord *evp; |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
479 { |
|
6162
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
480 if ( evp->what == mouseDown ) { |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
481 WindowPtr wp; |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
482 |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
483 if ( FindWindow(evp->where, &wp) == inSysWindow ) { |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
484 SystemClick(evp, wp); |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
485 return; |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
486 } |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
487 } |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
488 #ifdef __MWERKS__ |
|
3248
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
489 { |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
490 int siouxdidit; |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
491 |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
492 /* If SIOUX wants it we're done */ |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
493 siouxdidit = SIOUXHandleOneEvent(evp); |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
494 if ( siouxdidit ) |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
495 return; |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
496 } |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
497 #else |
|
6162
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
498 /* 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
|
499 #endif /* !__MWERKS__ */ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
500 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
501 |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
502 /* |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
503 ** 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
|
504 ** event handler. |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
505 */ |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
506 int |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
507 PyMac_HandleEvent(evp) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
508 EventRecord *evp; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
509 { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
510 PyObject *rv; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
511 |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
512 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
|
513 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
|
514 PyMac_BuildEventRecord, evp); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
515 if ( rv ) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
516 Py_DECREF(rv); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
517 else |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
518 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
|
519 } else { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
520 PyMac_HandleEventIntern(evp); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
521 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
522 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
|
523 } |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
524 |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
525 /* |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
526 ** 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
|
527 */ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
528 static int |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
529 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
|
530 { |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
531 EventRecord ev; |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
532 int gotone; |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
533 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
|
534 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
|
535 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
536 in_here++; |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
537 /* |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
538 ** First check for interrupts, if wanted. |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
539 ** This sets a flag that will be picked up at an appropriate |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
540 ** moment in the mainloop. |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
541 */ |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
542 if (schedparams.check_interrupt) |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
543 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
|
544 |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
545 /* XXXX Implementing an idle routine goes here */ |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
546 |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
547 /* |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
548 ** 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
|
549 ** - process events |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
550 ** - 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
|
551 ** - do neither |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
552 */ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
553 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
|
554 (python_event_handler && !maycallpython) ) { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
555 if ( maxsleep >= 0 ) { |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
556 SystemTask(); |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
557 } |
| 4197 | 558 } else { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
559 latest_time_ready = LMGetTicks() + maxsleep; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
560 while ( maxsleep >= 0 ) { |
|
6162
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
561 /* 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
|
562 ** 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
|
563 ** 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
|
564 ** again. |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
565 **/ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
566 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
|
567 /* 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
|
568 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
|
569 break; |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
570 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
|
571 in_here--; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
572 return -1; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
573 } |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
574 maxsleep = latest_time_ready - LMGetTicks(); |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
575 } |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
576 } |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
577 in_here--; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
578 return 0; |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
579 } |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
580 |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
581 /* |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
582 ** 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
|
583 */ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
584 int |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
585 PyMac_Yield() { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
586 unsigned long maxsleep; |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
587 |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
588 if( PyMac_InForeground() ) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
589 maxsleep = 0; |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
590 else |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
591 maxsleep = schedparams.bg_yield; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
592 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
593 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
|
594 } |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
595 |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
596 /* |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
597 ** Return current scheduler parameters |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
598 */ |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
599 void |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
600 PyMac_GetSchedParams(PyMacSchedParams *sp) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
601 { |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
602 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
|
603 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
|
604 sp->besocial = schedparams.besocial; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
605 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
|
606 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
|
607 } |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
608 |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
609 /* |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
610 ** Set current scheduler parameters |
| 2035 | 611 */ |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
612 void |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
613 PyMac_SetSchedParams(PyMacSchedParams *sp) |
| 2035 | 614 { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
615 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
|
616 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
|
617 schedparams.besocial = sp->besocial; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
618 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
|
619 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
|
620 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
|
621 schedparams.besocial ) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
622 schedparams.enabled = 1; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
623 else |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
624 schedparams.enabled = 0; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
625 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
|
626 } |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
627 |
|
2350
a2054933775b
Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
628 /* |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
629 ** 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
|
630 */ |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
631 void |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
632 PyMac_InitMenuBar() |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
633 { |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
634 MenuHandle applemenu; |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
635 |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
636 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
|
637 /* 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
|
638 SIOUXSetupMenus(); |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
639 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
|
640 return; |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
641 } |
|
5270
de9d0c5249b0
Changed the few old routine names still used to the new ones
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
642 if ( (applemenu=GetMenuHandle(SIOUX_APPLEID)) == NULL ) return; |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
643 SetMenuItemText(applemenu, 1, "\pAbout Python..."); |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
644 } |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
645 |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
646 /* |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
647 ** 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
|
648 */ |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
649 void |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
650 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
|
651 { |
|
5737
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
652 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
|
653 SetMenuBar(sioux_mbar); |
|
5737
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
654 DrawMenuBar(); |
|
7438
cd11690cb14b
- Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents:
6461
diff
changeset
|
655 } else |
|
cd11690cb14b
- Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents:
6461
diff
changeset
|
656 PyMac_InitMenuBar(); |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
657 } |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
658 |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
659 |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
660 /* |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
661 ** 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
|
662 */ |
|
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
|
663 |
|
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
|
664 #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
|
665 |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
666 void |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
667 SIOUXDoAboutBox(void) |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
668 { |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
669 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
|
670 WindowPtr theWindow; |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
671 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
|
672 short fontID; |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
673 |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
674 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
|
675 return; |
|
4325
12c3865aeaa0
Changed default background yield time to 1 tick
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
676 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
|
677 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
|
678 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
|
679 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
|
680 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
|
681 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
|
682 TextSize(9); |
|
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
|
683 ParamText(Pstring(PATCHLEVEL), "\p", "\p", "\p"); |
|
4325
12c3865aeaa0
Changed default background yield time to 1 tick
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
684 ShowWindow(theWindow); |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
685 ModalDialog(NULL, &item); |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
686 DisposeDialog(theDialog); |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
687 } |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
688 |
|
5737
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
689 #if 0 |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
690 int |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
691 PyMac_FileExists(char *name) |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
692 { |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
693 FSSpec fss; |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
694 |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
695 if ( FSMakeFSSpec(0, 0, Pstring(name), &fss) == noErr ) |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
696 return 1; |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
697 return 0; |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
698 } |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
699 #endif |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
700 |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
701 /* |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
702 ** Helper routine for GetDirectory |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
703 */ |
|
2412
75ae104f7e6c
ported to MPW, moved main() here
Guido van Rossum <guido@python.org>
parents:
2403
diff
changeset
|
704 static pascal short |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
705 myhook_proc(short item, DialogPtr theDialog, struct hook_args *dataptr) |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
706 { |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
707 if ( item == sfHookFirstCall && dataptr->prompt) { |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
708 Handle prompth; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
709 short type; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
710 Rect rect; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
711 |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
712 GetDialogItem(theDialog, PROMPT_ITEM, &type, &prompth, &rect); |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
713 if ( prompth ) |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
714 SetDialogItemText(prompth, (unsigned char *)dataptr->prompt); |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
715 } else |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
716 if ( item == SELECTCUR_ITEM ) { |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
717 item = sfItemCancelButton; |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
718 dataptr->selectcur_hit = 1; |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
719 } |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
720 return item; |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
721 } |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
722 |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
723 /* |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
724 ** Ask the user for a directory. I still can't understand |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
725 ** why Apple doesn't provide a standard solution for this... |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
726 */ |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
727 int |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
728 PyMac_GetDirectory(dirfss, prompt) |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
729 FSSpec *dirfss; |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
730 char *prompt; |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
731 { |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
732 static SFTypeList list = {'fldr', 0, 0, 0}; |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
733 static Point where = {-1, -1}; |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
734 StandardFileReply reply; |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
735 struct hook_args hook_args; |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
736 |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
737 if ( !upp_inited ) { |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
738 myhook_upp = NewDlgHookYDProc(myhook_proc); |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
739 upp_inited = 1; |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
740 } |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
741 if ( prompt && *prompt ) |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
742 hook_args.prompt = (char *)Pstring(prompt); |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
743 else |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
744 hook_args.prompt = NULL; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
745 hook_args.selectcur_hit = 0; |
|
2412
75ae104f7e6c
ported to MPW, moved main() here
Guido van Rossum <guido@python.org>
parents:
2403
diff
changeset
|
746 CustomGetFile((FileFilterYDUPP)0, 1, list, &reply, GETDIR_ID, where, myhook_upp, |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
747 NULL, NULL, NULL, (void *)&hook_args); |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
748 |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
749 reply.sfFile.name[0] = 0; |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
750 if( FSMakeFSSpec(reply.sfFile.vRefNum, reply.sfFile.parID, reply.sfFile.name, dirfss) ) |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
751 return 0; |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
752 return hook_args.selectcur_hit; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
753 } |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
754 |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
755 /* |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
756 ** Slightly extended StandardGetFile: accepts a prompt */ |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
757 void PyMac_PromptGetFile(short numTypes, ConstSFTypeListPtr typeList, |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
758 StandardFileReply *reply, char *prompt) |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
759 { |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
760 static Point where = {-1, -1}; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
761 struct hook_args hook_args; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
762 |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
763 if ( !upp_inited ) { |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
764 myhook_upp = NewDlgHookYDProc(myhook_proc); |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
765 upp_inited = 1; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
766 } |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
767 if ( prompt && *prompt ) |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
768 hook_args.prompt = (char *)Pstring(prompt); |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
769 else |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
770 hook_args.prompt = NULL; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
771 hook_args.selectcur_hit = 0; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
772 CustomGetFile((FileFilterYDUPP)0, numTypes, typeList, reply, GETFILEPROMPT_ID, where, |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
773 myhook_upp, NULL, NULL, NULL, (void *)&hook_args); |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
774 } |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
775 |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
776 /* Convert a 4-char string object argument to an OSType value */ |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
777 int |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
778 PyMac_GetOSType(PyObject *v, OSType *pr) |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
779 { |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
780 if (!PyString_Check(v) || PyString_Size(v) != 4) { |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
781 PyErr_SetString(PyExc_TypeError, |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
782 "OSType arg must be string of 4 chars"); |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
783 return 0; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
784 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
785 memcpy((char *)pr, PyString_AsString(v), 4); |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
786 return 1; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
787 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
788 |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
789 /* Convert an OSType value to a 4-char string object */ |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
790 PyObject * |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
791 PyMac_BuildOSType(OSType t) |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
792 { |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
793 return PyString_FromStringAndSize((char *)&t, 4); |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
794 } |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
795 |
|
3914
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
796 /* Convert an NumVersion value to a 4-element tuple */ |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
797 PyObject * |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
798 PyMac_BuildNumVersion(NumVersion t) |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
799 { |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
800 return Py_BuildValue("(hhhh)", t.majorRev, t.minorAndBugRev, t.stage, t.nonRelRev); |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
801 } |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
802 |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
803 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
804 /* Convert a Python string object to a Str255 */ |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
805 int |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
806 PyMac_GetStr255(PyObject *v, Str255 pbuf) |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
807 { |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
808 int len; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
809 if (!PyString_Check(v) || (len = PyString_Size(v)) > 255) { |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
810 PyErr_SetString(PyExc_TypeError, |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
811 "Str255 arg must be string of at most 255 chars"); |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
812 return 0; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
813 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
814 pbuf[0] = len; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
815 memcpy((char *)(pbuf+1), PyString_AsString(v), len); |
| 2035 | 816 return 1; |
| 817 } | |
| 818 | |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
819 /* Convert a Str255 to a Python string object */ |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
820 PyObject * |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
821 PyMac_BuildStr255(Str255 s) |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
822 { |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
823 return PyString_FromStringAndSize((char *)&s[1], (int)s[0]); |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
824 } |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
825 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
826 |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
827 /* |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
828 ** Convert a Python object to an FSSpec. |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
829 ** The object may either be a full pathname or a triple |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
830 ** (vrefnum, dirid, path). |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
831 ** NOTE: This routine will fail on pre-sys7 machines. |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
832 ** The caller is responsible for not calling this routine |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
833 ** in those cases (which is fine, since everyone calling |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
834 ** this is probably sys7 dependent anyway). |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
835 */ |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
836 int |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
837 PyMac_GetFSSpec(PyObject *v, FSSpec *fs) |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
838 { |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
839 Str255 path; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
840 short refnum; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
841 long parid; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
842 OSErr err; |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
843 FSSpec *fs2; |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
844 |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
845 /* first check whether it already is an FSSpec */ |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
846 fs2 = mfs_GetFSSpecFSSpec(v); |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
847 if ( fs2 ) { |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
848 (void)FSMakeFSSpec(fs2->vRefNum, fs2->parID, fs2->name, fs); |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
849 return 1; |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
850 } |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
851 if ( PyString_Check(v) ) { |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
852 /* It's a pathname */ |
|
2209
4053d4cb50e0
renamed Get routines to PyMac_Get; added macfs to config.c
Guido van Rossum <guido@python.org>
parents:
2183
diff
changeset
|
853 if( !PyArg_Parse(v, "O&", PyMac_GetStr255, &path) ) |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
854 return 0; |
|
3433
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
855 refnum = 0; /* XXXX Should get CurWD here?? */ |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
856 parid = 0; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
857 } else { |
|
2209
4053d4cb50e0
renamed Get routines to PyMac_Get; added macfs to config.c
Guido van Rossum <guido@python.org>
parents:
2183
diff
changeset
|
858 if( !PyArg_Parse(v, "(hlO&); FSSpec should be fullpath or (vrefnum,dirid,path)", |
|
4053d4cb50e0
renamed Get routines to PyMac_Get; added macfs to config.c
Guido van Rossum <guido@python.org>
parents:
2183
diff
changeset
|
859 &refnum, &parid, PyMac_GetStr255, &path)) { |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
860 return 0; |
|
2209
4053d4cb50e0
renamed Get routines to PyMac_Get; added macfs to config.c
Guido van Rossum <guido@python.org>
parents:
2183
diff
changeset
|
861 } |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
862 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
863 err = FSMakeFSSpec(refnum, parid, path, fs); |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
864 if ( err && err != fnfErr ) { |
|
2209
4053d4cb50e0
renamed Get routines to PyMac_Get; added macfs to config.c
Guido van Rossum <guido@python.org>
parents:
2183
diff
changeset
|
865 PyErr_Mac(PyExc_ValueError, err); |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
866 return 0; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
867 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
868 return 1; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
869 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
870 |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
871 |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
872 /* Convert a Python object to a Rect. |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
873 The object must be a (left, top, right, bottom) tuple. |
|
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
874 (This differs from the order in the struct but is consistent with |
|
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
875 the arguments to SetRect(), and also with STDWIN). */ |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
876 int |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
877 PyMac_GetRect(PyObject *v, Rect *r) |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
878 { |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
879 return PyArg_Parse(v, "(hhhh)", &r->left, &r->top, &r->right, &r->bottom); |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
880 } |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
881 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
882 /* Convert a Rect to a Python object */ |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
883 PyObject * |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
884 PyMac_BuildRect(Rect *r) |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
885 { |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
886 return Py_BuildValue("(hhhh)", r->left, r->top, r->right, r->bottom); |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
887 } |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
888 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
889 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
890 /* Convert a Python object to a Point. |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
891 The object must be a (h, v) tuple. |
|
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
892 (This differs from the order in the struct but is consistent with |
|
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
893 the arguments to SetPoint(), and also with STDWIN). */ |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
894 int |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
895 PyMac_GetPoint(PyObject *v, Point *p) |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
896 { |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
897 return PyArg_Parse(v, "(hh)", &p->h, &p->v); |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
898 } |
|
2224
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
899 |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
900 /* Convert a Point to a Python object */ |
|
2224
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
901 PyObject * |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
902 PyMac_BuildPoint(Point p) |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
903 { |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
904 return Py_BuildValue("(hh)", p.h, p.v); |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
905 } |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
906 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
907 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
908 /* Convert a Python object to an EventRecord. |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
909 The object must be a (what, message, when, (v, h), modifiers) tuple. */ |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
910 int |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
911 PyMac_GetEventRecord(PyObject *v, EventRecord *e) |
|
2224
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
912 { |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
913 return PyArg_Parse(v, "(hll(hh)h)", |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
914 &e->what, |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
915 &e->message, |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
916 &e->when, |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
917 &e->where.h, |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
918 &e->where.v, |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
919 &e->modifiers); |
|
2224
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
920 } |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
921 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
922 /* Convert a Rect to an EventRecord object */ |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
923 PyObject * |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
924 PyMac_BuildEventRecord(EventRecord *e) |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
925 { |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
926 return Py_BuildValue("(hll(hh)h)", |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
927 e->what, |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
928 e->message, |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
929 e->when, |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
930 e->where.h, |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
931 e->where.v, |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
932 e->modifiers); |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
933 } |
|
3278
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
934 |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
935 /* Convert Python object to Fixed */ |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
936 int |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
937 PyMac_GetFixed(PyObject *v, Fixed *f) |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
938 { |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
939 double d; |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
940 |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
941 if( !PyArg_Parse(v, "d", &d)) |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
942 return 0; |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
943 *f = (Fixed)(d * 0x10000); |
|
3655
f89fa7e95b84
PyMac_GetFixed() didn't return 1 on success
Jack Jansen <jack.jansen@cwi.nl>
parents:
3478
diff
changeset
|
944 return 1; |
|
3278
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
945 } |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
946 |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
947 /* Convert a Point to a Python object */ |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
948 PyObject * |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
949 PyMac_BuildFixed(Fixed f) |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
950 { |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
951 double d; |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
952 |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
953 d = f; |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
954 d = d / 0x10000; |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
955 return Py_BuildValue("d", d); |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
956 } |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
957 |
|
8104
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
958 /* Convert wide to/from Python int or (hi, lo) tuple. XXXX Should use Python longs */ |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
959 int |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
960 PyMac_Getwide(PyObject *v, wide *rv) |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
961 { |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
962 if (PyInt_Check(v)) { |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
963 rv->hi = 0; |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
964 rv->lo = PyInt_AsLong(v); |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
965 if( rv->lo & 0x80000000 ) |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
966 rv->hi = -1; |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
967 return 1; |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
968 } |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
969 return PyArg_Parse(v, "(ll)", &rv->hi, &rv->lo); |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
970 } |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
971 |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
972 |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
973 PyObject * |
|
8113
e2d33c0732bf
Incorrect argument for PyMacBuildwide()
Jack Jansen <jack.jansen@cwi.nl>
parents:
8104
diff
changeset
|
974 PyMac_Buildwide(wide *w) |
|
8104
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
975 { |
|
8113
e2d33c0732bf
Incorrect argument for PyMacBuildwide()
Jack Jansen <jack.jansen@cwi.nl>
parents:
8104
diff
changeset
|
976 if ( (w->hi == 0 && (w->lo & 0x80000000) == 0) || |
|
e2d33c0732bf
Incorrect argument for PyMacBuildwide()
Jack Jansen <jack.jansen@cwi.nl>
parents:
8104
diff
changeset
|
977 (w->hi == -1 && (w->lo & 0x80000000) ) ) |
|
e2d33c0732bf
Incorrect argument for PyMacBuildwide()
Jack Jansen <jack.jansen@cwi.nl>
parents:
8104
diff
changeset
|
978 return PyInt_FromLong(w->lo); |
|
e2d33c0732bf
Incorrect argument for PyMacBuildwide()
Jack Jansen <jack.jansen@cwi.nl>
parents:
8104
diff
changeset
|
979 return Py_BuildValue("(ll)", w->hi, w->lo); |
|
8104
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
980 } |
