annotate Mac/Python/macglue.c @ 25135:0f0016632be4 legacy-trunk

_formatparam(), set_param(): RFC 2231 encoding support by Oleg Broytmann in SF patch #600096. Specifically, the former function now encodes the triplets, while the latter adds optional charset and language arguments.
author Barry Warsaw <barry@python.org>
date Fri, 06 Sep 2002 03:55:04 +0000
parents e8a263db1be0
children 74d1ad61f843
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
24
4024
53d511c0029f Fixed command-. handling
Jack Jansen <jack.jansen@cwi.nl>
parents: 4018
diff changeset
25
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
26 #include "Python.h"
2337
71e60871c681 ported to Think C
Guido van Rossum <guido@python.org>
parents: 2333
diff changeset
27
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
28 #include "macglue.h"
2350
a2054933775b Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2337
diff changeset
29 #include "marshal.h"
a2054933775b Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2337
diff changeset
30 #include "import.h"
5737
d0c6b49d7101 Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
31 #include "importdl.h"
17862
97ece9321c53 Merged mactoolboxglue.c into macglue.c. A later step will be to separate out
Jack Jansen <jack.jansen@cwi.nl>
parents: 17814
diff changeset
32 #include "pymactoolbox.h"
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
33
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
34 #include "pythonresources.h"
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
35
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
36 #ifdef WITHOUT_FRAMEWORKS
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
37 #include <OSUtils.h> /* for Set(Current)A5 */
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
38 #include <Files.h>
2312
40aec48cd1e2 Added PyMac_GetPythonDir routine which obtains python home directory
Jack Jansen <jack.jansen@cwi.nl>
parents: 2276
diff changeset
39 #include <StandardFile.h>
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
40 #include <Resources.h>
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
41 #include <Memory.h>
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
42 #include <Windows.h>
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
43 #include <Traps.h>
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
44 #include <Processes.h>
2382
6450d8828d2b added applet initialization;
Guido van Rossum <guido@python.org>
parents: 2350
diff changeset
45 #include <Fonts.h>
6450d8828d2b added applet initialization;
Guido van Rossum <guido@python.org>
parents: 2350
diff changeset
46 #include <Menus.h>
2747
e41669a1dea0 Added code to obtain sys.path from a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2668
diff changeset
47 #include <TextUtils.h>
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
48 #include <LowMem.h>
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
49 #include <Events.h>
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
50 #else
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
51 #include <Carbon/Carbon.h>
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
52 #endif
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
53
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
54 #if !TARGET_API_MAC_OS8
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
55 /* Unfortunately this call is probably slower... */
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
56 #define LMGetTicks() TickCount()
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
57 #endif
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
58
2443
2dcf7538347a Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents: 2429
diff changeset
59 #ifdef __MWERKS__
2dcf7538347a Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents: 2429
diff changeset
60 #include <SIOUX.h>
13547
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
61 extern void SIOUXSetupMenus(void);
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
62 extern void SIOUXDoAboutBox(void);
2443
2dcf7538347a Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents: 2429
diff changeset
63 #endif
13547
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
64 #ifdef USE_GUSI
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
65 /* Functions we redefine because they're in obscure libraries */
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
66 extern void SpinCursor(short x);
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
67 extern void RotateCursor(short x);
24012
e8a263db1be0 Changed some prototypes to match the exact definition in some faraway Apple
Jack Jansen <jack.jansen@cwi.nl>
parents: 22958
diff changeset
68 extern pascal unsigned char * PLstrcpy(unsigned char *, const unsigned char *);
e8a263db1be0 Changed some prototypes to match the exact definition in some faraway Apple
Jack Jansen <jack.jansen@cwi.nl>
parents: 22958
diff changeset
69 extern pascal short PLstrcmp(const unsigned char *, const unsigned char *);
e8a263db1be0 Changed some prototypes to match the exact definition in some faraway Apple
Jack Jansen <jack.jansen@cwi.nl>
parents: 22958
diff changeset
70 extern pascal char *PLstrrchr(const unsigned char *, short);
13547
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
71
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
72 #endif
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
73
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
74 /* 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
75 #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
76
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
77 #include <signal.h>
2350
a2054933775b Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2337
diff changeset
78 #include <stdio.h>
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
79
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
80 /*
3914
524cf501c851 - Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents: 3786
diff changeset
81 ** 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
82 ** raise a MemoryError.
524cf501c851 - Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents: 3786
diff changeset
83 */
524cf501c851 - Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents: 3786
diff changeset
84 #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
85 #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
86 #endif
524cf501c851 - Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents: 3786
diff changeset
87
16437
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
88 #if TARGET_API_MAC_CARBON
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
89 /*
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
90 ** On MacOSX StackSpace() lies: it gives the distance from heap end to stack pointer,
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
91 ** but the stack cannot grow that far due to rlimit values. We cannot get at this value
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
92 ** from Carbon, so we set a maximum to the stack here that is based on the default
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
93 ** stack limit of 512K.
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
94 */
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
95 #define MAXIMUM_STACK_SIZE (256*1024)
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
96 #endif
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
97
3914
524cf501c851 - Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents: 3786
diff changeset
98 /*
2443
2dcf7538347a Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents: 2429
diff changeset
99 ** 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
100 ** 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
101 ** 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
102 ** 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
103 */
6162
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
104 #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
105
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
106 #include <signal.h>
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
107
2224
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
108 /* 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
109 ** with the python errors.h. */
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
110 #define fnfErr -43
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
111
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
112 /* Interrupt code variables: */
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
113 static int interrupted; /* Set to true when cmd-. seen */
13542
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12855
diff changeset
114 static RETSIGTYPE intcatcher(int);
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
115
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
116 #if !TARGET_API_MAC_OSX
13542
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12855
diff changeset
117 static int PyMac_Yield(void);
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
118 #endif
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
119
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
120 /*
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
121 ** 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
122 ** 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
123 ** from pyMac_SchedParamStruct.
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
124 */
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
125
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
126 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
127 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
128 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
129 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
130 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
131 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
132 /* 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
133 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
134 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
135 };
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
136
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
137 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
138 { 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
139
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
140 /*
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
141 ** Workaround for sioux/gusi combo: set when we are exiting
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
142 */
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
143 int PyMac_ConsoleIsDead;
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
144
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
145 /*
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
146 ** 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
147 */
16647
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
148 static MenuBarHandle sioux_mbar;
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
149
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
150 /*
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
151 ** 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
152 */
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
153 struct hook_args {
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
154 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
155 char *prompt; /* The prompt */
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
156 };
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
157 #if !TARGET_API_MAC_OS8
12833
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
158 /* The StandardFile hooks don't exist in Carbon. This breaks GetDirectory,
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
159 ** but the macfsn code will replace it by a NavServices version anyway.
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
160 */
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
161 #define myhook_upp NULL
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
162 #else
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
163 static DlgHookYDUPP myhook_upp;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
164 static int upp_inited = 0;
12833
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
165 #endif
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
166
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
167 /*
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
168 ** 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
169 */
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
170 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
171
17866
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
172 /* Given an FSSpec, return the FSSpec of the parent folder */
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
173
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
174 static OSErr
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
175 get_folder_parent (FSSpec * fss, FSSpec * parent)
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
176 {
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
177 CInfoPBRec rec;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
178 short err;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
179
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
180 * parent = * fss;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
181 rec.hFileInfo.ioNamePtr = parent->name;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
182 rec.hFileInfo.ioVRefNum = parent->vRefNum;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
183 rec.hFileInfo.ioDirID = parent->parID;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
184 rec.hFileInfo.ioFDirIndex = -1;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
185 rec.hFileInfo.ioFVersNum = 0;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
186 if (err = PBGetCatInfoSync (& rec))
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
187 return err;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
188 parent->parID = rec.dirInfo.ioDrParID;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
189 /* parent->name[0] = 0; */
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
190 return 0;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
191 }
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
192
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
193 /* Given an FSSpec return a full, colon-separated pathname */
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
194
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
195 OSErr
19850
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
196 PyMac_GetFullPathname (FSSpec *fss, char *buf, int length)
17866
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
197 {
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
198 short err;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
199 FSSpec fss_parent, fss_current;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
200 char tmpbuf[1024];
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
201 int plen;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
202
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
203 fss_current = *fss;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
204 plen = fss_current.name[0];
19850
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
205 if ( plen+2 > length ) {
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
206 *buf = 0;
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
207 return errFSNameTooLong;
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
208 }
17866
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
209 memcpy(buf, &fss_current.name[1], plen);
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
210 buf[plen] = 0;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
211 /* Special case for disk names */
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
212 if ( fss_current.parID <= 1 ) {
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
213 buf[plen++] = ':';
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
214 buf[plen] = 0;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
215 return 0;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
216 }
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
217 while (fss_current.parID > 1) {
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
218 /* Get parent folder name */
19850
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
219 if (err = get_folder_parent(&fss_current, &fss_parent)) {
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
220 *buf = 0;
17866
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
221 return err;
19850
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
222 }
17866
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
223 fss_current = fss_parent;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
224 /* Prepend path component just found to buf */
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
225 plen = fss_current.name[0];
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
226 if (strlen(buf) + plen + 1 > 1024) {
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
227 /* Oops... Not enough space (shouldn't happen) */
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
228 *buf = 0;
19850
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
229 return errFSNameTooLong;
17866
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
230 }
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
231 memcpy(tmpbuf, &fss_current.name[1], plen);
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
232 tmpbuf[plen] = ':';
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
233 strcpy(&tmpbuf[plen+1], buf);
19850
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
234 if ( strlen(tmpbuf) > length ) {
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
235 *buf = 0;
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
236 return errFSNameTooLong;
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
237 }
17866
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
238 strcpy(buf, tmpbuf);
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
239 }
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
240 return 0;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
241 }
13701
c68003efb796 Added PyMac_getscript() which returns the pythonic name of the current script. Not ideal and not complete, but good enough for the time being. Idea and most of the code by Fredrik Lund.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
242
4013
aa9548885b3f Dummy SpinCursor() if __CFM68K__ is defined
Jack Jansen <jack.jansen@cwi.nl>
parents: 3914
diff changeset
243
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11676
diff changeset
244 #ifdef USE_GUSI
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4215
diff changeset
245 /*
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4215
diff changeset
246 ** 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
247 ** provide a dummy here.
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4215
diff changeset
248 */
4018
Jack Jansen <jack.jansen@cwi.nl>
parents: 4013
diff changeset
249 void SpinCursor(short x) { /* Dummy */ }
7438
cd11690cb14b - Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents: 6461
diff changeset
250 void RotateCursor(short x) { /* Dummy */ }
4018
Jack Jansen <jack.jansen@cwi.nl>
parents: 4013
diff changeset
251
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
252
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
253 /* Called at exit() time thru atexit(), to stop event processing */
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
254 void
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
255 PyMac_StopGUSISpin() {
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
256 PyMac_ConsoleIsDead = 1;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
257 }
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
258
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
259 #if TARGET_API_MAC_OS8
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
260 /*
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
261 ** Replacement routines for the PLstr... functions so we don't need
15825
4328ffe647bf Disabled a few other routines that are available in CarbonLib.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15786
diff changeset
262 ** StdCLib.
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
263 */
11548
c042e4140f1e Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents: 11529
diff changeset
264 pascal void
13547
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
265 PLstrcpy(unsigned char *to, unsigned char *fr)
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
266 {
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
267 memcpy(to, fr, fr[0]+1);
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
268 }
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
269
11548
c042e4140f1e Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents: 11529
diff changeset
270 pascal int
13547
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
271 PLstrcmp(unsigned char *s1, unsigned char *s2)
5617
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 int res;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
274 int l = s1[0] < s2[0] ? s1[0] : s2[0];
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
275
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
276 res = memcmp(s1+1, s2+1, l);
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
277 if ( res != 0 )
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
278 return res;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
279
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
280 if ( s1[0] < s2[0] )
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
281 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
282 else if ( s1[0] > s2[0] )
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
283 return 1;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
284 else
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
285 return 0;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
286 }
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
287
11548
c042e4140f1e Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents: 11529
diff changeset
288 pascal unsigned char *
13547
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
289 PLstrrchr(unsigned char *str, unsigned char chr)
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
290 {
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
291 unsigned char *ptr = 0;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
292 unsigned char *p;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
293
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
294 for(p=str+1; p<str+str[0]; p++)
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
295 if ( *p == chr )
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
296 ptr = p;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
297 return ptr;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
298 }
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
299
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
300 #endif /* TARGET_API_MAC_OS8 */
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
301 #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
302
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
303
2176
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
304 /* 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
305 unsigned char *
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
306 Pstring(char *str)
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
307 {
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
308 static Str255 buf;
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
309 int len;
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
310
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
311 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
312 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
313 len = 255;
2176
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
314 buf[0] = (unsigned char)len;
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
315 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
316 return buf;
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
317 }
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
318
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
319 #if TARGET_API_MAC_OS8
21560
ab92eaa140ef Merging changes from release22-branch.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21329
diff changeset
320 Point
ab92eaa140ef Merging changes from release22-branch.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21329
diff changeset
321 LMGetMouse(void)
ab92eaa140ef Merging changes from release22-branch.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21329
diff changeset
322 {
ab92eaa140ef Merging changes from release22-branch.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21329
diff changeset
323 return LMGetMouseLocation();
ab92eaa140ef Merging changes from release22-branch.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21329
diff changeset
324 }
ab92eaa140ef Merging changes from release22-branch.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21329
diff changeset
325
ab92eaa140ef Merging changes from release22-branch.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21329
diff changeset
326 long LMGetExpandMem(void)
ab92eaa140ef Merging changes from release22-branch.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21329
diff changeset
327 {
ab92eaa140ef Merging changes from release22-branch.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21329
diff changeset
328 return 0;
ab92eaa140ef Merging changes from release22-branch.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21329
diff changeset
329 }
ab92eaa140ef Merging changes from release22-branch.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21329
diff changeset
330
15529
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
331 void
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
332 c2pstrcpy(unsigned char *dst, const char *src)
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
333 {
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
334 int len;
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
335
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
336 len = strlen(src);
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
337 if ( len > 255 ) len = 255;
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
338 strncpy((char *)dst+1, src, len);
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
339 dst[0] = len;
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
340 }
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
341 #endif /* TARGET_API_MAC_OS8 */
15529
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
342
3786
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
343 #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
344 /* 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
345 int
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
346 PyOS_CheckStack()
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
347 {
14197
2787e93817c6 Cheaper implementation of PyOS_CheckStack: only call StackSpace once and keep a sentinel in a static variable.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13701
diff changeset
348 char here;
2787e93817c6 Cheaper implementation of PyOS_CheckStack: only call StackSpace once and keep a sentinel in a static variable.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13701
diff changeset
349 static char *sentinel = 0;
14476
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
350 static PyThreadState *thread_for_sentinel = 0;
3786
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
351
16437
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
352 if ( sentinel == 0 ) {
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
353 unsigned long stackspace = StackSpace();
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
354
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
355 #ifdef MAXIMUM_STACK_SIZE
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
356 /* See the comment at the definition */
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
357 if ( stackspace > MAXIMUM_STACK_SIZE )
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
358 stackspace = MAXIMUM_STACK_SIZE;
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
359 #endif
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
360 sentinel = &here - stackspace + MINIMUM_STACK_SIZE;
14197
2787e93817c6 Cheaper implementation of PyOS_CheckStack: only call StackSpace once and keep a sentinel in a static variable.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13701
diff changeset
361 }
14476
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
362 if ( thread_for_sentinel == 0 ) {
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
363 thread_for_sentinel = PyThreadState_Get();
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
364 }
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
365 if ( &here < sentinel ) {
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
366 if (thread_for_sentinel == PyThreadState_Get()) {
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
367 return -1;
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
368 }
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
369 }
3786
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
370 return 0;
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
371 }
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
372 #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
373
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
374 #if !TARGET_API_MAC_OSX
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
375 /* 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
376 static RETSIGTYPE
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
377 intcatcher(sig)
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
378 int sig;
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 interrupted = 1;
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
381 signal(SIGINT, intcatcher);
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
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
384 void
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
385 PyOS_InitInterrupts()
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
386 {
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
387 if (signal(SIGINT, SIG_IGN) != SIG_IGN)
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
388 signal(SIGINT, intcatcher);
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
389 }
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
390
5962
23e014839ab0 Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents: 5744
diff changeset
391 void
23e014839ab0 Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents: 5744
diff changeset
392 PyOS_FiniInterrupts()
23e014839ab0 Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents: 5744
diff changeset
393 {
23e014839ab0 Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents: 5744
diff changeset
394 }
23e014839ab0 Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents: 5744
diff changeset
395
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
396 /* Check whether we are in the foreground */
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
397 static int
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
398 PyMac_InForeground(void)
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
399 {
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
400 static ProcessSerialNumber ours;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
401 static inited;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
402 ProcessSerialNumber curfg;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
403 Boolean eq;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
404
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
405 if ( inited == 0 ) {
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
406 (void)GetCurrentProcess(&ours);
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
407 inited = 1;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
408 }
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
409 if ( GetFrontProcess(&curfg) < 0 )
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
410 eq = 1;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
411 else if ( SameProcess(&ours, &curfg, &eq) < 0 )
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
412 eq = 1;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
413 return (int)eq;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
414 }
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
415
2262
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 ** 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
418 */
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
419 static void
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
420 scan_event_queue(force)
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
421 int force;
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
422 {
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
423 #if !TARGET_API_MAC_OS8
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
424 if ( interrupted || (!schedparams.check_interrupt && !force) )
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
425 return;
15839
3b643653e078 Fixed Carbon command-dot handling. There is still a problem, though, and you may have to hit it repeatedly.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15825
diff changeset
426 if ( CheckEventQueueForUserCancel() )
3b643653e078 Fixed Carbon command-dot handling. There is still a problem, though, and you may have to hit it repeatedly.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15825
diff changeset
427 interrupted = 1;
12833
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
428 #else
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
429 register EvQElPtr q;
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
430
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
431 if ( interrupted || (!schedparams.check_interrupt && !force) || !PyMac_InForeground() )
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
432 return;
7438
cd11690cb14b - Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents: 6461
diff changeset
433 q = (EvQElPtr) LMGetEventQueue()->qHead;
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
434
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
435 for (; q; q = (EvQElPtr)q->qLink) {
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
436 if (q->evtQWhat == keyDown &&
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
437 (char)q->evtQMessage == '.' &&
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
438 (q->evtQModifiers & cmdKey) != 0) {
21113
ed3dce17fc79 Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents: 20949
diff changeset
439 FlushEvents(keyDownMask, 0);
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
440 interrupted = 1;
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
441 break;
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
442 }
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
443 }
12833
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
444 #endif
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
445 }
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
446
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
447 int
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
448 PyErr_CheckSignals()
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
449 {
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
450 if (schedparams.enabled) {
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
451 if ( interrupted || (unsigned long)LMGetTicks() > schedparams.next_check ) {
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
452 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
453 if (interrupted) {
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
454 interrupted = 0;
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
455 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
456 return -1;
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
457 }
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
458 if ( PyMac_Yield() < 0)
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
459 return -1;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
460 schedparams.next_check = (unsigned long)LMGetTicks()
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
461 + schedparams.check_interval;
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
462 }
2262
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 return 0;
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
465 }
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
466
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
467 int
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
468 PyOS_InterruptOccurred()
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
469 {
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
470 scan_event_queue(0);
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
471 if ( !interrupted )
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
472 return 0;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
473 interrupted = 0;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
474 return 1;
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
475 }
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
476 #endif
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
477
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
478 int
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
479 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
480 {
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
481 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
482 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
483 return 0;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
484 }
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
485 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
486 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
487 if ( evh )
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
488 Py_INCREF(evh);
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
489 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
490 return 1;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
491 }
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
492
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
493 /*
2276
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
494 ** 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
495 ** 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
496 */
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
497 void
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
498 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
499 EventRecord *evp;
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
500 {
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
501 #if TARGET_API_MAC_OS8
6162
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
502 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
503 WindowPtr wp;
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
504
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
505 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
506 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
507 return;
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
508 }
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
509 }
12833
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
510 #endif
2276
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
511 #ifdef __MWERKS__
3248
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
512 {
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
513 int siouxdidit;
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
514
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
515 /* If SIOUX wants it we're done */
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
516 siouxdidit = SIOUXHandleOneEvent(evp);
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
517 if ( siouxdidit )
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
518 return;
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
519 }
2276
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
520 #else
6162
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
521 /* 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
522 #endif /* !__MWERKS__ */
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
523 }
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
524
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
525 /*
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
526 ** 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
527 ** event handler.
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
528 */
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
529 int
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
530 PyMac_HandleEvent(evp)
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
531 EventRecord *evp;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
532 {
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
533 PyObject *rv;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
534
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
535 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
536 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
537 PyMac_BuildEventRecord, evp);
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
538 if ( rv )
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
539 Py_DECREF(rv);
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
540 else
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
541 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
542 } else {
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
543 PyMac_HandleEventIntern(evp);
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
544 }
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
545 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
546 }
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
547
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
548 #if !TARGET_API_MAC_OSX
2276
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
549 /*
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
550 ** 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
551 */
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11676
diff changeset
552 int
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
553 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
554 {
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
555 EventRecord ev;
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
556 int gotone;
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
557 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
558 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
559
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
560 in_here++;
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
561
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
562 /*
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
563 ** 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
564 ** - process events
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
565 ** - 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
566 ** - do neither
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
567 */
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
568 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
569 (python_event_handler && !maycallpython) ) {
17629
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
570 if ( maxsleep >= 0 ) {
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
571 #if TARGET_API_MAC_OS8
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
572 SystemTask();
17629
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
573 #else
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
574 int xxx = 0;
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
575 #endif
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
576 }
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
577 } else {
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
578 latest_time_ready = LMGetTicks() + maxsleep;
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11676
diff changeset
579 do {
6162
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
580 /* 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
581 ** 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
582 ** 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
583 ** again.
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
584 **/
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
585 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
586 /* 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
587 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
588 break;
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
589 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
590 in_here--;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
591 return -1;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
592 }
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
593 maxsleep = latest_time_ready - LMGetTicks();
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11676
diff changeset
594 } while ( maxsleep > 0 );
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
595 }
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
596 in_here--;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
597 return 0;
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
598 }
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
599
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
600 /*
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
601 ** 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
602 */
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
603 int
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
604 PyMac_Yield() {
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
605 unsigned long maxsleep;
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
606
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
607 if( PyMac_InForeground() )
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
608 maxsleep = 0;
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
609 else
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
610 maxsleep = schedparams.bg_yield;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
611
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
612 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
613 }
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
614
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
615 /*
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
616 ** Return current scheduler parameters
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 void
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
619 PyMac_GetSchedParams(PyMacSchedParams *sp)
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
620 {
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
621 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
622 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
623 sp->besocial = schedparams.besocial;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
624 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
625 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
626 }
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
627
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
628 /*
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
629 ** Set current scheduler parameters
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
630 */
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
631 void
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
632 PyMac_SetSchedParams(PyMacSchedParams *sp)
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
633 {
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
634 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
635 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
636 schedparams.besocial = sp->besocial;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
637 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
638 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
639 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
640 schedparams.besocial )
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
641 schedparams.enabled = 1;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
642 else
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
643 schedparams.enabled = 0;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
644 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
645 }
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
646
2350
a2054933775b Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2337
diff changeset
647 /*
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
648 ** 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
649 */
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
650 void
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
651 PyMac_InitMenuBar()
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
652 {
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
653 MenuHandle applemenu;
21329
848f6988829f The new menu initialization code would also add the SIOUX menus if a (frozen) Python program had installed its own menubar previously. We now guard against this, with a bit of a hack: FrameWork uses the same Menu ID as Sioux, and the init code checks that the text in the menu is "About SIOUX" before replacing it.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21113
diff changeset
654 Str255 about_text;
848f6988829f The new menu initialization code would also add the SIOUX menus if a (frozen) Python program had installed its own menubar previously. We now guard against this, with a bit of a hack: FrameWork uses the same Menu ID as Sioux, and the init code checks that the text in the menu is "About SIOUX" before replacing it.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21113
diff changeset
655 static unsigned char about_sioux[] = "\pAbout SIOUX";
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
656
17629
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
657 if ( sioux_mbar ) return;
21113
ed3dce17fc79 Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents: 20949
diff changeset
658 if ( (sioux_mbar=GetMenuBar()) == NULL || GetMenuHandle(SIOUX_APPLEID) == NULL) {
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
659 /* 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
660 SIOUXSetupMenus();
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
661 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
662 return;
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
663 }
5270
de9d0c5249b0 Changed the few old routine names still used to the new ones
Jack Jansen <jack.jansen@cwi.nl>
parents: 5153
diff changeset
664 if ( (applemenu=GetMenuHandle(SIOUX_APPLEID)) == NULL ) return;
21329
848f6988829f The new menu initialization code would also add the SIOUX menus if a (frozen) Python program had installed its own menubar previously. We now guard against this, with a bit of a hack: FrameWork uses the same Menu ID as Sioux, and the init code checks that the text in the menu is "About SIOUX" before replacing it.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21113
diff changeset
665 GetMenuItemText(applemenu, 1, about_text);
848f6988829f The new menu initialization code would also add the SIOUX menus if a (frozen) Python program had installed its own menubar previously. We now guard against this, with a bit of a hack: FrameWork uses the same Menu ID as Sioux, and the init code checks that the text in the menu is "About SIOUX" before replacing it.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21113
diff changeset
666 if ( about_text[0] == about_sioux[0] &&
848f6988829f The new menu initialization code would also add the SIOUX menus if a (frozen) Python program had installed its own menubar previously. We now guard against this, with a bit of a hack: FrameWork uses the same Menu ID as Sioux, and the init code checks that the text in the menu is "About SIOUX" before replacing it.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21113
diff changeset
667 strncmp((char *)(about_text+1), (char *)(about_sioux+1), about_text[0]) == 0 )
848f6988829f The new menu initialization code would also add the SIOUX menus if a (frozen) Python program had installed its own menubar previously. We now guard against this, with a bit of a hack: FrameWork uses the same Menu ID as Sioux, and the init code checks that the text in the menu is "About SIOUX" before replacing it.
Jack Jansen <jack.jansen@cwi.nl>
parents: 21113
diff changeset
668 SetMenuItemText(applemenu, 1, "\pAbout Python...");
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
669 }
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
670
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
671 /*
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
672 ** 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
673 */
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
674 void
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
675 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
676 {
16647
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
677 MenuBarHandle curmenubar;
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
678
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
679 curmenubar = GetMenuBar();
5737
d0c6b49d7101 Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
680 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
681 SetMenuBar(sioux_mbar);
5737
d0c6b49d7101 Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
682 DrawMenuBar();
16647
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
683 } else {
7438
cd11690cb14b - Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents: 6461
diff changeset
684 PyMac_InitMenuBar();
16647
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
685 DrawMenuBar();
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
686 }
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
687 }
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
688
17629
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
689 void
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
690 PyMac_RaiseConsoleWindow()
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
691 {
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
692 /* Note: this is a hack. SIOUXTextWindow is SIOUX's internal structure
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
693 ** and we happen to know that the first entry is the window pointer.
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
694 */
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
695 extern WindowRef *SIOUXTextWindow;
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
696
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
697 if ( SIOUXTextWindow == NULL || *SIOUXTextWindow == NULL )
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
698 return;
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
699 if ( FrontWindow() != *SIOUXTextWindow )
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
700 BringToFront(*SIOUXTextWindow);
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
701 }
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
702
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
703 /*
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
704 ** 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
705 */
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
706
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
707 #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
708
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
709 void
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
710 SIOUXDoAboutBox(void)
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
711 {
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
712 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
713 WindowPtr theWindow;
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
714 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
715 short fontID;
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
716
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
717 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
718 return;
4325
12c3865aeaa0 Changed default background yield time to 1 tick
Jack Jansen <jack.jansen@cwi.nl>
parents: 4238
diff changeset
719 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
720 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
721 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
722 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
723 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
724 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
725 TextSize(9);
19393
0f873d06ac13 PATCHLEVEL is outdated, use PY_VERSION.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19064
diff changeset
726 ParamText(Pstring(PY_VERSION), "\p", "\p", "\p");
4325
12c3865aeaa0 Changed default background yield time to 1 tick
Jack Jansen <jack.jansen@cwi.nl>
parents: 4238
diff changeset
727 ShowWindow(theWindow);
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
728 ModalDialog(NULL, &item);
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
729 DisposeDialog(theDialog);
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
730 }
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
731
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
732 #endif /* !TARGET_API_MAC_OSX */
5737
d0c6b49d7101 Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
733
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
734 #if TARGET_API_MAC_OS8
5737
d0c6b49d7101 Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
735 /*
2403
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
736 ** 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
737 */
2412
75ae104f7e6c ported to MPW, moved main() here
Guido van Rossum <guido@python.org>
parents: 2403
diff changeset
738 static pascal short
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
739 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
740 {
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
741 if ( item == sfHookFirstCall && dataptr->prompt) {
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
742 Handle prompth;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
743 short type;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
744 Rect rect;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
745
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
746 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
747 if ( prompth )
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
748 SetDialogItemText(prompth, (unsigned char *)dataptr->prompt);
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
749 } else
2403
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
750 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
751 item = sfItemCancelButton;
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
752 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
753 }
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
754 return item;
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
755 }
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
756
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 ** 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
759 ** 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
760 */
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
761 int
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
762 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
763 FSSpec *dirfss;
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
764 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
765 {
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
766 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
767 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
768 StandardFileReply reply;
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
769 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
770
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
771 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
772 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
773 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
774 }
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
775 if ( prompt && *prompt )
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
776 hook_args.prompt = (char *)Pstring(prompt);
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
777 else
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
778 hook_args.prompt = NULL;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
779 hook_args.selectcur_hit = 0;
2412
75ae104f7e6c ported to MPW, moved main() here
Guido van Rossum <guido@python.org>
parents: 2403
diff changeset
780 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
781 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
782
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
783 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
784 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
785 return 0;
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
786 return hook_args.selectcur_hit;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
787 }
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
788
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
789 /*
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
790 ** Slightly extended StandardGetFile: accepts a prompt */
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
791 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
792 StandardFileReply *reply, char *prompt)
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
793 {
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
794 static Point where = {-1, -1};
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
795 struct hook_args hook_args;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
796
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
797 if ( !upp_inited ) {
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
798 myhook_upp = NewDlgHookYDProc(myhook_proc);
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
799 upp_inited = 1;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
800 }
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
801 if ( prompt && *prompt )
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
802 hook_args.prompt = (char *)Pstring(prompt);
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
803 else
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
804 hook_args.prompt = NULL;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
805 hook_args.selectcur_hit = 0;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
806 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
807 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
808 }
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
809 #endif /* TARGET_API_MAC_OS8 */
2176
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
810
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
811