Mercurial > cpython-lru_cache-weakref
annotate Mac/Python/macglue.c @ 12357:5b59ea41db4e legacy-trunk
Install the docs (with fewer rules).
Add descriptions for the system variables.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Mon, 10 Apr 2000 19:36:27 +0000 |
| parents | 51c0c3b6d919 |
| children | 41c0c60dcaf5 |
| 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 |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
65 #ifdef USE_GUSI1 |
|
3431
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 */ |
| 4197 | 67 #include <GUSI.h> |
|
3431
26bec9e22e5d
Added code to make fsspecs work for gusi-python
Jack Jansen <jack.jansen@cwi.nl>
parents:
3278
diff
changeset
|
68 #endif |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
69 #include <LowMem.h> |
|
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(); |
|
11548
c042e4140f1e
Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
105 extern PyObject *newmfssobject Py_PROTO((FSSpec *)); |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
106 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
107 /* Interrupt code variables: */ |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
108 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
|
109 static RETSIGTYPE intcatcher Py_PROTO((int)); |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
110 |
|
5744
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 |
|
11529
f83b74273da2
First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents:
8790
diff
changeset
|
158 /* |
|
f83b74273da2
First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents:
8790
diff
changeset
|
159 ** Set to true if we're appearance-compliant |
|
f83b74273da2
First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents:
8790
diff
changeset
|
160 */ |
|
f83b74273da2
First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents:
8790
diff
changeset
|
161 int PyMac_AppearanceCompliant; |
|
f83b74273da2
First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents:
8790
diff
changeset
|
162 |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
163 #ifdef USE_GUSI1 |
|
3433
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
164 /* |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
165 ** 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
|
166 ** 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
|
167 ** 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
|
168 */ |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
169 void |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
170 PyMac_FixGUSIcd() |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
171 { |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
172 WDPBRec pb; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
173 FSSpec curdirfss; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
174 |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
175 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
|
176 return; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
177 |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
178 /* 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
|
179 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
|
180 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
|
181 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
|
182 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
|
183 return; |
|
578ca302a598
Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents:
3431
diff
changeset
|
184 } |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
185 #endif |
|
4013
aa9548885b3f
Dummy SpinCursor() if __CFM68K__ is defined
Jack Jansen <jack.jansen@cwi.nl>
parents:
3914
diff
changeset
|
186 |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
187 #ifdef USE_GUSI |
|
4238
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4215
diff
changeset
|
188 /* |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4215
diff
changeset
|
189 ** 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
|
190 ** provide a dummy here. |
|
6c86d9136c09
- Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents:
4215
diff
changeset
|
191 */ |
| 4018 | 192 void SpinCursor(short x) { /* Dummy */ } |
|
7438
cd11690cb14b
- Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents:
6461
diff
changeset
|
193 void RotateCursor(short x) { /* Dummy */ } |
| 4018 | 194 |
| 4197 | 195 /* |
| 196 ** Replacement GUSI Spin function | |
| 197 */ | |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
198 #ifdef USE_GUSI1 |
| 4197 | 199 static int |
| 200 PyMac_GUSISpin(spin_msg msg, long arg) | |
| 201 { | |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
202 static Boolean inForeground = true; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
203 int maxsleep = 6; /* 6 ticks is "normal" sleeptime */ |
| 4197 | 204 |
| 205 if (PyMac_ConsoleIsDead) return 0; | |
| 206 #if 0 | |
| 207 if (inForeground) | |
| 208 SpinCursor(msg == SP_AUTO_SPIN ? short(arg) : 1); | |
| 209 #endif | |
| 210 | |
| 211 if (interrupted) return -1; | |
| 212 | |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
213 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
|
214 maxsleep = 0; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
215 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
|
216 maxsleep = arg; |
| 4197 | 217 |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
218 PyMac_DoYield(maxsleep, 0); /* XXXX or is it safe to call python here? */ |
| 4197 | 219 |
| 220 return 0; | |
| 221 } | |
| 222 | |
| 223 void | |
| 224 PyMac_SetGUSISpin() { | |
| 225 GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin); | |
| 226 } | |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
227 #endif |
| 4197 | 228 |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
229 /* Called at exit() time thru atexit(), to stop event processing */ |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
230 void |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
231 PyMac_StopGUSISpin() { |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
232 PyMac_ConsoleIsDead = 1; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
233 } |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
234 |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
235 /* |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
236 ** 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
|
237 ** StdCLib. Moreover, that implementation is broken under cfm68k... |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
238 */ |
|
11548
c042e4140f1e
Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
239 pascal void |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
240 PLstrcpy(to, fr) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
241 unsigned char *to, *fr; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
242 { |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
243 memcpy(to, fr, fr[0]+1); |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
244 } |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
245 |
|
11548
c042e4140f1e
Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
246 pascal int |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
247 PLstrcmp(s1, s2) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
248 unsigned char *s1, *s2; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
249 { |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
250 int res; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
251 int l = s1[0] < s2[0] ? s1[0] : s2[0]; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
252 |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
253 res = memcmp(s1+1, s2+1, l); |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
254 if ( res != 0 ) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
255 return res; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
256 |
|
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
|
257 if ( s1[0] < s2[0] ) |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
258 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
|
259 else if ( s1[0] > s2[0] ) |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
260 return 1; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
261 else |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
262 return 0; |
|
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 |
|
11548
c042e4140f1e
Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
265 pascal unsigned char * |
|
5617
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
266 PLstrrchr(str, chr) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
267 unsigned char *str; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
268 unsigned char chr; |
|
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 unsigned char *ptr = 0; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
271 unsigned char *p; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
272 |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
273 for(p=str+1; p<str+str[0]; p++) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
274 if ( *p == chr ) |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
275 ptr = p; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
276 return ptr; |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
277 } |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
278 |
|
70855574516b
- Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents:
5270
diff
changeset
|
279 #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
|
280 |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
281 |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
282 /* 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
|
283 unsigned char * |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
284 Pstring(char *str) |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
285 { |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
286 static Str255 buf; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
287 int len; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
288 |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
289 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
|
290 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
|
291 len = 255; |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
292 buf[0] = (unsigned char)len; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
293 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
|
294 return buf; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
295 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
296 |
|
2382
6450d8828d2b
added applet initialization;
Guido van Rossum <guido@python.org>
parents:
2350
diff
changeset
|
297 /* Like strerror() but for Mac OS error numbers */ |
|
6450d8828d2b
added applet initialization;
Guido van Rossum <guido@python.org>
parents:
2350
diff
changeset
|
298 char *PyMac_StrError(int err) |
| 2035 | 299 { |
| 300 static char buf[256]; | |
| 301 Handle h; | |
| 302 char *str; | |
| 303 | |
| 304 h = GetResource('Estr', err); | |
| 305 if ( h ) { | |
| 306 HLock(h); | |
| 307 str = (char *)*h; | |
| 308 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
|
309 buf[(unsigned char)str[0]] = '\0'; |
| 2035 | 310 HUnlock(h); |
| 311 ReleaseResource(h); | |
| 312 } else { | |
| 313 sprintf(buf, "Mac OS error code %d", err); | |
| 314 } | |
| 315 return buf; | |
| 316 } | |
| 317 | |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
318 /* 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
|
319 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
|
320 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
321 /* 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
|
322 PyObject * |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
323 PyMac_GetOSErrException() |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
324 { |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
325 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
|
326 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
|
327 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
|
328 } |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
329 |
| 2035 | 330 /* Set a MAC-specific error from errno, and return NULL; return None if no error */ |
| 331 PyObject * | |
| 2136 | 332 PyErr_Mac(PyObject *eobj, int err) |
| 2035 | 333 { |
| 334 char *msg; | |
| 335 PyObject *v; | |
| 336 | |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
337 if (err == 0 && !PyErr_Occurred()) { |
| 2035 | 338 Py_INCREF(Py_None); |
| 339 return Py_None; | |
| 340 } | |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
341 if (err == -1 && PyErr_Occurred()) |
|
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
342 return NULL; |
|
2382
6450d8828d2b
added applet initialization;
Guido van Rossum <guido@python.org>
parents:
2350
diff
changeset
|
343 msg = PyMac_StrError(err); |
| 2035 | 344 v = Py_BuildValue("(is)", err, msg); |
| 345 PyErr_SetObject(eobj, v); | |
| 346 Py_DECREF(v); | |
| 347 return NULL; | |
| 348 } | |
| 349 | |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
350 /* 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
|
351 PyObject * |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
352 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
|
353 { |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
354 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
|
355 } |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
356 |
|
3786
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
357 #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
|
358 /* 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
|
359 int |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
360 PyOS_CheckStack() |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
361 { |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
362 long left; |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
363 |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
364 left = StackSpace(); |
|
3914
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
365 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
|
366 return -1; |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
367 return 0; |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
368 } |
|
718c8af7be2a
Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents:
3655
diff
changeset
|
369 #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
|
370 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
371 /* 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
|
372 static RETSIGTYPE |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
373 intcatcher(sig) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
374 int sig; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
375 { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
376 interrupted = 1; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
377 signal(SIGINT, intcatcher); |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
378 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
379 |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
380 void |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
381 PyOS_InitInterrupts() |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
382 { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
383 if (signal(SIGINT, SIG_IGN) != SIG_IGN) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
384 signal(SIGINT, intcatcher); |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
385 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
386 |
|
5962
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
387 void |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
388 PyOS_FiniInterrupts() |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
389 { |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
390 } |
|
23e014839ab0
Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents:
5744
diff
changeset
|
391 |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
392 /* |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
393 ** 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
|
394 ** 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
|
395 ** 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
|
396 ** 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
|
397 ** interrupt a runaway python program. |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
398 */ |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
399 static void |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
400 scan_event_queue(flush) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
401 int flush; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
402 { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
403 register EvQElPtr q; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
404 |
|
7438
cd11690cb14b
- Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents:
6461
diff
changeset
|
405 q = (EvQElPtr) LMGetEventQueue()->qHead; |
|
2262
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 for (; q; q = (EvQElPtr)q->qLink) { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
408 if (q->evtQWhat == keyDown && |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
409 (char)q->evtQMessage == '.' && |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
410 (q->evtQModifiers & cmdKey) != 0) { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
411 if ( flush ) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
412 FlushEvents(keyDownMask, 0); |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
413 interrupted = 1; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
414 break; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
415 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
416 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
417 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
418 |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
419 int |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
420 PyErr_CheckSignals() |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
421 { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
422 if (schedparams.enabled) { |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
423 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
|
424 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
|
425 return -1; |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
426 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
|
427 + schedparams.check_interval; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
428 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
|
429 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
|
430 interrupted = 0; |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
431 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
|
432 return -1; |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
433 } |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
434 } |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
435 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
436 return 0; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
437 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
438 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
439 int |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
440 PyOS_InterruptOccurred() |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
441 { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
442 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
|
443 return interrupted; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
444 } |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
445 /* Check whether we are in the foreground */ |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
446 int |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
447 PyMac_InForeground() |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
448 { |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
449 static ProcessSerialNumber ours; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
450 static inited; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
451 ProcessSerialNumber curfg; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
452 Boolean eq; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
453 |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
454 if ( inited == 0 ) { |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
455 (void)GetCurrentProcess(&ours); |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
456 inited = 1; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
457 } |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
458 if ( GetFrontProcess(&curfg) < 0 ) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
459 eq = 1; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
460 else if ( SameProcess(&ours, &curfg, &eq) < 0 ) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
461 eq = 1; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
462 return (int)eq; |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
463 |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
464 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
465 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
466 int |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
467 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
|
468 { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
469 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
|
470 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
|
471 return 0; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
472 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
473 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
|
474 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
|
475 if ( evh ) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
476 Py_INCREF(evh); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
477 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
|
478 return 1; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
479 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
480 |
| 2035 | 481 /* |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
482 ** 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
|
483 ** 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
|
484 */ |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
485 void |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
486 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
|
487 EventRecord *evp; |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
488 { |
|
6162
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
489 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
|
490 WindowPtr wp; |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
491 |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
492 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
|
493 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
|
494 return; |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
495 } |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
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 #ifdef __MWERKS__ |
|
3248
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
498 { |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
499 int siouxdidit; |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
500 |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
501 /* If SIOUX wants it we're done */ |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
502 siouxdidit = SIOUXHandleOneEvent(evp); |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
503 if ( siouxdidit ) |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
504 return; |
|
5e101ead1e69
Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents:
3052
diff
changeset
|
505 } |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
506 #else |
|
6162
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
507 /* 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
|
508 #endif /* !__MWERKS__ */ |
|
5744
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 |
|
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 ** 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
|
513 ** event handler. |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
514 */ |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
515 int |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
516 PyMac_HandleEvent(evp) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
517 EventRecord *evp; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
518 { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
519 PyObject *rv; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
520 |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
521 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
|
522 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
|
523 PyMac_BuildEventRecord, evp); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
524 if ( rv ) |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
525 Py_DECREF(rv); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
526 else |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
527 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
|
528 } else { |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
529 PyMac_HandleEventIntern(evp); |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
530 } |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
531 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
|
532 } |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
533 |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2265
diff
changeset
|
534 /* |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
535 ** 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
|
536 */ |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
537 int |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
538 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
|
539 { |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
540 EventRecord ev; |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
541 int gotone; |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
542 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
|
543 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
|
544 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
545 in_here++; |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
546 /* |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
547 ** 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
|
548 ** 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
|
549 ** moment in the mainloop. |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
550 */ |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
551 if (schedparams.check_interrupt) |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
552 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
|
553 |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
554 /* 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
|
555 |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
556 /* |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
557 ** 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
|
558 ** - process events |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
559 ** - 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
|
560 ** - do neither |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
561 */ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
562 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
|
563 (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
|
564 if ( maxsleep >= 0 ) { |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
565 SystemTask(); |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
566 } |
| 4197 | 567 } else { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
568 latest_time_ready = LMGetTicks() + maxsleep; |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
569 do { |
|
6162
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
570 /* 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
|
571 ** 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
|
572 ** 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
|
573 ** again. |
|
9183a3c6b85f
Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents:
5962
diff
changeset
|
574 **/ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
575 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
|
576 /* 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
|
577 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
|
578 break; |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
579 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
|
580 in_here--; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
581 return -1; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
582 } |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
583 maxsleep = latest_time_ready - LMGetTicks(); |
|
12281
51c0c3b6d919
Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11676
diff
changeset
|
584 } while ( maxsleep > 0 ); |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
585 } |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
586 in_here--; |
|
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
587 return 0; |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
588 } |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
589 |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
590 /* |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
591 ** 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
|
592 */ |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
593 int |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
594 PyMac_Yield() { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
595 unsigned long maxsleep; |
|
2251
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 if( PyMac_InForeground() ) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
598 maxsleep = 0; |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2255
diff
changeset
|
599 else |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
600 maxsleep = schedparams.bg_yield; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
601 |
|
5744
ea8a0b090908
Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents:
5737
diff
changeset
|
602 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
|
603 } |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
604 |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
605 /* |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
606 ** Return current scheduler parameters |
|
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 void |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
609 PyMac_GetSchedParams(PyMacSchedParams *sp) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
610 { |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
611 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
|
612 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
|
613 sp->besocial = schedparams.besocial; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
614 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
|
615 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
|
616 } |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
617 |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
618 /* |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
619 ** Set current scheduler parameters |
| 2035 | 620 */ |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
621 void |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
622 PyMac_SetSchedParams(PyMacSchedParams *sp) |
| 2035 | 623 { |
|
5711
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
624 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
|
625 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
|
626 schedparams.besocial = sp->besocial; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
627 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
|
628 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
|
629 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
|
630 schedparams.besocial ) |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
631 schedparams.enabled = 1; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
632 else |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
633 schedparams.enabled = 0; |
|
fb170ce82951
Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents:
5617
diff
changeset
|
634 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
|
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 |
|
2350
a2054933775b
Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2337
diff
changeset
|
637 /* |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
638 ** 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
|
639 */ |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
640 void |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
641 PyMac_InitMenuBar() |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
642 { |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
643 MenuHandle applemenu; |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
644 |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
645 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
|
646 /* 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
|
647 SIOUXSetupMenus(); |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
648 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
|
649 return; |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
650 } |
|
5270
de9d0c5249b0
Changed the few old routine names still used to the new ones
Jack Jansen <jack.jansen@cwi.nl>
parents:
5153
diff
changeset
|
651 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
|
652 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
|
653 } |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
654 |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
655 /* |
|
5732
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
656 ** 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
|
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 void |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
659 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
|
660 { |
|
5737
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
661 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
|
662 SetMenuBar(sioux_mbar); |
|
5737
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
663 DrawMenuBar(); |
|
7438
cd11690cb14b
- Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents:
6461
diff
changeset
|
664 } else |
|
cd11690cb14b
- Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents:
6461
diff
changeset
|
665 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
|
666 } |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
667 |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
668 |
|
f027dd0a85e4
- Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents:
5711
diff
changeset
|
669 /* |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
670 ** 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
|
671 */ |
|
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 |
|
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
|
673 #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
|
674 |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
675 void |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
676 SIOUXDoAboutBox(void) |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
677 { |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
678 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
|
679 WindowPtr theWindow; |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
680 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
|
681 short fontID; |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
682 |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
683 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
|
684 return; |
|
4325
12c3865aeaa0
Changed default background yield time to 1 tick
Jack Jansen <jack.jansen@cwi.nl>
parents:
4238
diff
changeset
|
685 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
|
686 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
|
687 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
|
688 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
|
689 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
|
690 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
|
691 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
|
692 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
|
693 ShowWindow(theWindow); |
|
4215
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
694 ModalDialog(NULL, &item); |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
695 DisposeDialog(theDialog); |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
696 } |
|
0410ed3808ee
Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents:
4204
diff
changeset
|
697 |
|
5737
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
698 #if 0 |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
699 int |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
700 PyMac_FileExists(char *name) |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
701 { |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
702 FSSpec fss; |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
703 |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
704 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
|
705 return 1; |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
706 return 0; |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
707 } |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
708 #endif |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
709 |
|
d0c6b49d7101
Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents:
5732
diff
changeset
|
710 /* |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
711 ** 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
|
712 */ |
|
2412
75ae104f7e6c
ported to MPW, moved main() here
Guido van Rossum <guido@python.org>
parents:
2403
diff
changeset
|
713 static pascal short |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
714 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
|
715 { |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
716 if ( item == sfHookFirstCall && dataptr->prompt) { |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
717 Handle prompth; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
718 short type; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
719 Rect rect; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
720 |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
721 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
|
722 if ( prompth ) |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
723 SetDialogItemText(prompth, (unsigned char *)dataptr->prompt); |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
724 } else |
|
2403
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
725 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
|
726 item = sfItemCancelButton; |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
727 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
|
728 } |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
729 return item; |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
730 } |
|
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 /* |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
733 ** 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
|
734 ** 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
|
735 */ |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
736 int |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
737 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
|
738 FSSpec *dirfss; |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
739 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
|
740 { |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
741 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
|
742 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
|
743 StandardFileReply reply; |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
744 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
|
745 |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
746 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
|
747 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
|
748 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
|
749 } |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
750 if ( prompt && *prompt ) |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
751 hook_args.prompt = (char *)Pstring(prompt); |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
752 else |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
753 hook_args.prompt = NULL; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
754 hook_args.selectcur_hit = 0; |
|
2412
75ae104f7e6c
ported to MPW, moved main() here
Guido van Rossum <guido@python.org>
parents:
2403
diff
changeset
|
755 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
|
756 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
|
757 |
|
72c715c004c8
- Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents:
2394
diff
changeset
|
758 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
|
759 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
|
760 return 0; |
|
2988
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
761 return hook_args.selectcur_hit; |
|
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 |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
764 /* |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
765 ** Slightly extended StandardGetFile: accepts a prompt */ |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
766 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
|
767 StandardFileReply *reply, char *prompt) |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
768 { |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
769 static Point where = {-1, -1}; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
770 struct hook_args hook_args; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
771 |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
772 if ( !upp_inited ) { |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
773 myhook_upp = NewDlgHookYDProc(myhook_proc); |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
774 upp_inited = 1; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
775 } |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
776 if ( prompt && *prompt ) |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
777 hook_args.prompt = (char *)Pstring(prompt); |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
778 else |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
779 hook_args.prompt = NULL; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
780 hook_args.selectcur_hit = 0; |
|
2fe9d0371ecd
Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents:
2913
diff
changeset
|
781 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
|
782 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
|
783 } |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
784 |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
785 /* 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
|
786 int |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
787 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
|
788 { |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
789 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
|
790 PyErr_SetString(PyExc_TypeError, |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
791 "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
|
792 return 0; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
793 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
794 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
|
795 return 1; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
796 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
797 |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
798 /* 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
|
799 PyObject * |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
800 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
|
801 { |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
802 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
|
803 } |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
804 |
|
3914
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
805 /* 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
|
806 PyObject * |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
807 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
|
808 { |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
809 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
|
810 } |
|
524cf501c851
- Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents:
3786
diff
changeset
|
811 |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
812 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
813 /* 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
|
814 int |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
815 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
|
816 { |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
817 int len; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
818 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
|
819 PyErr_SetString(PyExc_TypeError, |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
820 "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
|
821 return 0; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
822 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
823 pbuf[0] = len; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
824 memcpy((char *)(pbuf+1), PyString_AsString(v), len); |
| 2035 | 825 return 1; |
| 826 } | |
| 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 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
|
829 PyObject * |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
830 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
|
831 { |
|
11591
1131bfa1ad99
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11548
diff
changeset
|
832 if ( s == NULL ) { |
|
1131bfa1ad99
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11548
diff
changeset
|
833 PyErr_SetString(PyExc_SystemError, "Str255 pointer is NULL"); |
|
1131bfa1ad99
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11548
diff
changeset
|
834 return NULL; |
|
1131bfa1ad99
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11548
diff
changeset
|
835 } |
|
1131bfa1ad99
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11548
diff
changeset
|
836 return PyString_FromStringAndSize((char *)&s[1], (int)s[0]); |
|
1131bfa1ad99
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11548
diff
changeset
|
837 } |
|
1131bfa1ad99
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11548
diff
changeset
|
838 |
|
1131bfa1ad99
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11548
diff
changeset
|
839 PyObject * |
|
1131bfa1ad99
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11548
diff
changeset
|
840 PyMac_BuildOptStr255(Str255 s) |
|
1131bfa1ad99
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11548
diff
changeset
|
841 { |
|
1131bfa1ad99
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11548
diff
changeset
|
842 if ( s == NULL ) { |
|
1131bfa1ad99
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11548
diff
changeset
|
843 Py_INCREF(Py_None); |
|
1131bfa1ad99
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11548
diff
changeset
|
844 return Py_None; |
|
1131bfa1ad99
Added PyMac_BuildOptStr255, which returns None on a null pointer.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11548
diff
changeset
|
845 } |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
846 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
|
847 } |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
848 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
849 |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
850 /* |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
851 ** 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
|
852 ** 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
|
853 ** (vrefnum, dirid, path). |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
854 ** 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
|
855 ** 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
|
856 ** 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
|
857 ** 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
|
858 */ |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
859 int |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
860 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
|
861 { |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
862 Str255 path; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
863 short refnum; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
864 long parid; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
865 OSErr err; |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
866 FSSpec *fs2; |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
867 |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
868 /* 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
|
869 fs2 = mfs_GetFSSpecFSSpec(v); |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
870 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
|
871 (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
|
872 return 1; |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2231
diff
changeset
|
873 } |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
874 if ( PyString_Check(v) ) { |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
875 /* 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
|
876 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
|
877 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
|
878 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
|
879 parid = 0; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
880 } else { |
|
2209
4053d4cb50e0
renamed Get routines to PyMac_Get; added macfs to config.c
Guido van Rossum <guido@python.org>
parents:
2183
diff
changeset
|
881 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
|
882 &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
|
883 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
|
884 } |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
885 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
886 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
|
887 if ( err && err != fnfErr ) { |
|
11676
489483b65b3a
If there's an error in an fsspec argument raise MacOS.Error, not ValueError.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11591
diff
changeset
|
888 PyMac_Error(err); |
|
2176
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
889 return 0; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
890 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
891 return 1; |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
892 } |
|
1e9e74944bb5
- Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents:
2136
diff
changeset
|
893 |
|
11548
c042e4140f1e
Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
894 /* Convert FSSpec to PyObject */ |
|
c042e4140f1e
Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
895 PyObject *PyMac_BuildFSSpec(FSSpec *v) |
|
c042e4140f1e
Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
896 { |
|
c042e4140f1e
Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
897 return newmfssobject(v); |
|
c042e4140f1e
Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
898 } |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
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 Python object to a Rect. |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
901 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
|
902 (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
|
903 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
|
904 int |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
905 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
|
906 { |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
907 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
|
908 } |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
909 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
910 /* Convert a Rect to a Python object */ |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
911 PyObject * |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
912 PyMac_BuildRect(Rect *r) |
|
2183
62bdded5f00a
modernized/rationalized, added PyMac_BuildOSType
Guido van Rossum <guido@python.org>
parents:
2176
diff
changeset
|
913 { |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
914 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
|
915 } |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
916 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
917 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
918 /* 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
|
919 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
|
920 (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
|
921 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
|
922 int |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
923 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
|
924 { |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
925 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
|
926 } |
|
2224
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
927 |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
928 /* Convert a Point to a Python object */ |
|
2224
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
929 PyObject * |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
930 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
|
931 { |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
932 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
|
933 } |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
934 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
935 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
936 /* 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
|
937 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
|
938 int |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
939 PyMac_GetEventRecord(PyObject *v, EventRecord *e) |
|
2224
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
940 { |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
941 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
|
942 &e->what, |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
943 &e->message, |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
944 &e->when, |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
945 &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
|
946 &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
|
947 &e->modifiers); |
|
2224
32435d33f34a
cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents:
2209
diff
changeset
|
948 } |
|
2231
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
949 |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
950 /* 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
|
951 PyObject * |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
952 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
|
953 { |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
954 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
|
955 e->what, |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
956 e->message, |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
957 e->when, |
|
2255
382edef2d6d7
reverse h/v in Point and Rect
Guido van Rossum <guido@python.org>
parents:
2251
diff
changeset
|
958 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
|
959 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
|
960 e->modifiers); |
|
1e8b347a056c
Some layout changes; added EventRecord Get/Build functions (as a tuple).
Guido van Rossum <guido@python.org>
parents:
2224
diff
changeset
|
961 } |
|
3278
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
962 |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
963 /* Convert Python object to Fixed */ |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
964 int |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
965 PyMac_GetFixed(PyObject *v, Fixed *f) |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
966 { |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
967 double d; |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
968 |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
969 if( !PyArg_Parse(v, "d", &d)) |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
970 return 0; |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
971 *f = (Fixed)(d * 0x10000); |
|
3655
f89fa7e95b84
PyMac_GetFixed() didn't return 1 on success
Jack Jansen <jack.jansen@cwi.nl>
parents:
3478
diff
changeset
|
972 return 1; |
|
3278
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
973 } |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
974 |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
975 /* Convert a Point to a Python object */ |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
976 PyObject * |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
977 PyMac_BuildFixed(Fixed f) |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
978 { |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
979 double d; |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
980 |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
981 d = f; |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
982 d = d / 0x10000; |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
983 return Py_BuildValue("d", d); |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
984 } |
|
43c5e7a3fc1f
Added converters for Fixed
Jack Jansen <jack.jansen@cwi.nl>
parents:
3248
diff
changeset
|
985 |
|
8104
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
986 /* 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
|
987 int |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
988 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
|
989 { |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
990 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
|
991 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
|
992 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
|
993 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
|
994 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
|
995 return 1; |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
996 } |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
997 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
|
998 } |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
999 |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
1000 |
|
93348e5a85a2
Added PyMac_{Get,Build}wide. These should support python longints at
Jack Jansen <jack.jansen@cwi.nl>
parents:
7438
diff
changeset
|
1001 PyObject * |
|
8113
e2d33c0732bf
Incorrect argument for PyMacBuildwide()
Jack Jansen <jack.jansen@cwi.nl>
parents:
8104
diff
changeset
|
1002 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
|
1003 { |
|
8113
e2d33c0732bf
Incorrect argument for PyMacBuildwide()
Jack Jansen <jack.jansen@cwi.nl>
parents:
8104
diff
changeset
|
1004 if ( (w->hi == 0 && (w->lo & 0x80000000) == 0) || |
|
e2d33c0732bf
Incorrect argument for PyMacBuildwide()
Jack Jansen <jack.jansen@cwi.nl>
parents:
8104
diff
changeset
|
1005 (w->hi == -1 && (w->lo & 0x80000000) ) ) |
|
e2d33c0732bf
Incorrect argument for PyMacBuildwide()
Jack Jansen <jack.jansen@cwi.nl>
parents:
8104
diff
changeset
|
1006 return PyInt_FromLong(w->lo); |
|
e2d33c0732bf
Incorrect argument for PyMacBuildwide()
Jack Jansen <jack.jansen@cwi.nl>
parents:
8104
diff
changeset
|
1007 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
|
1008 } |
