Mercurial > cpython-lru_cache-weakref
annotate Mac/Modules/macosmodule.c @ 25838:8540887bcec6 2.2
Backport of 2.183:
Fix memory leak in add_subclass() found by NealN with valgrind.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 18 Oct 2002 13:42:21 +0000 |
| parents | 91dd223829c6 |
| children | 9563c9664a0b |
| rev | line source |
|---|---|
|
1892
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /*********************************************************** |
|
5079
d6b292a33cfe
Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents:
4524
diff
changeset
|
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam, |
| 2091 | 3 The Netherlands. |
|
1892
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 All Rights Reserved |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 Centrum or CWI not be used in advertising or publicity pertaining to |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 distribution of the software without specific, written prior permission. |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 ******************************************************************/ |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 /* Macintosh OS-specific interface */ |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 #include "Python.h" |
|
2033
e43a1942e588
- Use PyErr_Mac for nicer exceptions
Jack Jansen <jack.jansen@cwi.nl>
parents:
1916
diff
changeset
|
28 #include "macglue.h" |
|
15193
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
29 #include "pythonresources.h" |
|
1892
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 |
|
17864
be969e717b91
Include Carbon/Carbon.h in stead of universal headers, if appropriate.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
31 #ifdef WITHOUT_FRAMEWORKS |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
32 #include <Windows.h> |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
33 #include <Files.h> |
|
4342
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
34 #include <LowMem.h> |
|
7436
d1465b5c0a08
Fixed double-dispose of splash() dialog
Jack Jansen <jack.jansen@cwi.nl>
parents:
6330
diff
changeset
|
35 #include <Sound.h> |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
36 #include <Events.h> |
|
17864
be969e717b91
Include Carbon/Carbon.h in stead of universal headers, if appropriate.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
37 #else |
|
be969e717b91
Include Carbon/Carbon.h in stead of universal headers, if appropriate.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
38 #include <Carbon/Carbon.h> |
|
be969e717b91
Include Carbon/Carbon.h in stead of universal headers, if appropriate.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
39 #endif |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
40 |
|
1892
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 static PyObject *MacOS_Error; /* Exception MacOS.Error */ |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 |
|
19841
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
43 #ifdef TARGET_API_MAC_OSX |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
44 #define PATHNAMELEN 1024 |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
45 #else |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
46 #define PATHNAMELEN 256 |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
47 #endif |
|
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
48 |
|
2418
22b1ab0e6473
change SC ifdef to MPW
Guido van Rossum <guido@python.org>
parents:
2401
diff
changeset
|
49 #ifdef MPW |
| 2383 | 50 #define bufferIsSmall -607 /*error returns from Post and Accept */ |
| 51 #endif | |
| 52 | |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
53 /* ----------------------------------------------------- */ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
54 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
55 /* Declarations for objects of type Resource fork */ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
56 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
57 typedef struct { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
58 PyObject_HEAD |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
59 short fRefNum; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
60 int isclosed; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
61 } rfobject; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
62 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
63 staticforward PyTypeObject Rftype; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
64 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
65 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
66 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
67 /* ---------------------------------------------------------------- */ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
68 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
69 static void |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
70 do_close(rfobject *self) |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
71 { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
72 if (self->isclosed ) return; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
73 (void)FSClose(self->fRefNum); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
74 self->isclosed = 1; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
75 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
76 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
77 static char rf_read__doc__[] = |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
78 "Read data from resource fork" |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
79 ; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
80 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
81 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
82 rf_read(rfobject *self, PyObject *args) |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
83 { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
84 long n; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
85 PyObject *v; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
86 OSErr err; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
87 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
88 if (self->isclosed) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
89 PyErr_SetString(PyExc_ValueError, "Operation on closed file"); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
90 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
91 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
92 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
93 if (!PyArg_ParseTuple(args, "l", &n)) |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
94 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
95 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
96 v = PyString_FromStringAndSize((char *)NULL, n); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
97 if (v == NULL) |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
98 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
99 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
100 err = FSRead(self->fRefNum, &n, PyString_AsString(v)); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
101 if (err && err != eofErr) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
102 PyMac_Error(err); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
103 Py_DECREF(v); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
104 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
105 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
106 _PyString_Resize(&v, n); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
107 return v; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
108 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
109 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
110 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
111 static char rf_write__doc__[] = |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
112 "Write to resource fork" |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
113 ; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
114 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
115 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
116 rf_write(rfobject *self, PyObject *args) |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
117 { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
118 char *buffer; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
119 long size; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
120 OSErr err; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
121 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
122 if (self->isclosed) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
123 PyErr_SetString(PyExc_ValueError, "Operation on closed file"); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
124 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
125 } |
|
5429
ac235c9e6881
- Changed the m# format for PyArg_ParseTuple back to s#
Jack Jansen <jack.jansen@cwi.nl>
parents:
5258
diff
changeset
|
126 if (!PyArg_ParseTuple(args, "s#", &buffer, &size)) |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
127 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
128 err = FSWrite(self->fRefNum, &size, buffer); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
129 if (err) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
130 PyMac_Error(err); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
131 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
132 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
133 Py_INCREF(Py_None); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
134 return Py_None; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
135 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
136 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
137 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
138 static char rf_seek__doc__[] = |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
139 "Set file position" |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
140 ; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
141 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
142 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
143 rf_seek(rfobject *self, PyObject *args) |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
144 { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
145 long amount, pos; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
146 int whence = SEEK_SET; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
147 long eof; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
148 OSErr err; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
149 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
150 if (self->isclosed) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
151 PyErr_SetString(PyExc_ValueError, "Operation on closed file"); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
152 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
153 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
154 if (!PyArg_ParseTuple(args, "l|i", &amount, &whence)) |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
155 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
156 |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
157 if ((err = GetEOF(self->fRefNum, &eof))) |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
158 goto ioerr; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
159 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
160 switch (whence) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
161 case SEEK_CUR: |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
162 if ((err = GetFPos(self->fRefNum, &pos))) |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
163 goto ioerr; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
164 break; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
165 case SEEK_END: |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
166 pos = eof; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
167 break; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
168 case SEEK_SET: |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
169 pos = 0; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
170 break; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
171 default: |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
172 PyErr_BadArgument(); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
173 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
174 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
175 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
176 pos += amount; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
177 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
178 /* Don't bother implementing seek past EOF */ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
179 if (pos > eof || pos < 0) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
180 PyErr_BadArgument(); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
181 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
182 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
183 |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
184 if ((err = SetFPos(self->fRefNum, fsFromStart, pos)) ) { |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
185 ioerr: |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
186 PyMac_Error(err); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
187 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
188 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
189 Py_INCREF(Py_None); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
190 return Py_None; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
191 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
192 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
193 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
194 static char rf_tell__doc__[] = |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
195 "Get file position" |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
196 ; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
197 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
198 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
199 rf_tell(rfobject *self, PyObject *args) |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
200 { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
201 long where; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
202 OSErr err; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
203 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
204 if (self->isclosed) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
205 PyErr_SetString(PyExc_ValueError, "Operation on closed file"); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
206 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
207 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
208 if (!PyArg_ParseTuple(args, "")) |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
209 return NULL; |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
210 if ((err = GetFPos(self->fRefNum, &where)) ) { |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
211 PyMac_Error(err); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
212 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
213 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
214 return PyInt_FromLong(where); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
215 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
216 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
217 static char rf_close__doc__[] = |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
218 "Close resource fork" |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
219 ; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
220 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
221 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
222 rf_close(rfobject *self, PyObject *args) |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
223 { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
224 if (!PyArg_ParseTuple(args, "")) |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
225 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
226 do_close(self); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
227 Py_INCREF(Py_None); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
228 return Py_None; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
229 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
230 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
231 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
232 static struct PyMethodDef rf_methods[] = { |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
233 {"read", (PyCFunction)rf_read, 1, rf_read__doc__}, |
|
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
234 {"write", (PyCFunction)rf_write, 1, rf_write__doc__}, |
|
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
235 {"seek", (PyCFunction)rf_seek, 1, rf_seek__doc__}, |
|
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
236 {"tell", (PyCFunction)rf_tell, 1, rf_tell__doc__}, |
|
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
237 {"close", (PyCFunction)rf_close, 1, rf_close__doc__}, |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
238 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
239 {NULL, NULL} /* sentinel */ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
240 }; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
241 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
242 /* ---------- */ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
243 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
244 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
245 static rfobject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
246 newrfobject(void) |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
247 { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
248 rfobject *self; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
249 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
250 self = PyObject_NEW(rfobject, &Rftype); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
251 if (self == NULL) |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
252 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
253 self->isclosed = 1; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
254 return self; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
255 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
256 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
257 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
258 static void |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
259 rf_dealloc(rfobject *self) |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
260 { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
261 do_close(self); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
262 PyMem_DEL(self); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
263 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
264 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
265 static PyObject * |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
266 rf_getattr(rfobject *self, char *name) |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
267 { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
268 return Py_FindMethod(rf_methods, (PyObject *)self, name); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
269 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
270 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
271 static char Rftype__doc__[] = |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
272 "Resource fork file object" |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
273 ; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
274 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
275 static PyTypeObject Rftype = { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
276 PyObject_HEAD_INIT(&PyType_Type) |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
277 0, /*ob_size*/ |
|
21313
91dd223829c6
Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents:
19841
diff
changeset
|
278 "MacOS.ResourceFork", /*tp_name*/ |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
279 sizeof(rfobject), /*tp_basicsize*/ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
280 0, /*tp_itemsize*/ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
281 /* methods */ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
282 (destructor)rf_dealloc, /*tp_dealloc*/ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
283 (printfunc)0, /*tp_print*/ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
284 (getattrfunc)rf_getattr, /*tp_getattr*/ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
285 (setattrfunc)0, /*tp_setattr*/ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
286 (cmpfunc)0, /*tp_compare*/ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
287 (reprfunc)0, /*tp_repr*/ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
288 0, /*tp_as_number*/ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
289 0, /*tp_as_sequence*/ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
290 0, /*tp_as_mapping*/ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
291 (hashfunc)0, /*tp_hash*/ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
292 (ternaryfunc)0, /*tp_call*/ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
293 (reprfunc)0, /*tp_str*/ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
294 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
295 /* Space for future expansion */ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
296 0L,0L,0L,0L, |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
297 Rftype__doc__ /* Documentation string */ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
298 }; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
299 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
300 /* End of code for Resource fork objects */ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
301 /* -------------------------------------------------------- */ |
|
1892
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
302 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
303 /*----------------------------------------------------------------------*/ |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
304 /* Miscellaneous File System Operations */ |
|
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
305 |
| 5713 | 306 static char getcrtp_doc[] = "Obsolete, use macfs module"; |
| 307 | |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
308 static PyObject * |
|
2227
e53d019e7d47
Got rid of {Get,Set}FileType in favor of {Get,Set}CreatorAndType --
Guido van Rossum <guido@python.org>
parents:
2221
diff
changeset
|
309 MacOS_GetCreatorAndType(PyObject *self, PyObject *args) |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
310 { |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
311 FSSpec fss; |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
312 FInfo info; |
|
2227
e53d019e7d47
Got rid of {Get,Set}FileType in favor of {Get,Set}CreatorAndType --
Guido van Rossum <guido@python.org>
parents:
2221
diff
changeset
|
313 PyObject *creator, *type, *res; |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
314 OSErr err; |
|
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
315 |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
316 if (!PyArg_ParseTuple(args, "O&", PyMac_GetFSSpec, &fss)) |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
317 return NULL; |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
318 if ((err = FSpGetFInfo(&fss, &info)) != noErr) |
|
2227
e53d019e7d47
Got rid of {Get,Set}FileType in favor of {Get,Set}CreatorAndType --
Guido van Rossum <guido@python.org>
parents:
2221
diff
changeset
|
319 return PyErr_Mac(MacOS_Error, err); |
|
e53d019e7d47
Got rid of {Get,Set}FileType in favor of {Get,Set}CreatorAndType --
Guido van Rossum <guido@python.org>
parents:
2221
diff
changeset
|
320 creator = PyString_FromStringAndSize((char *)&info.fdCreator, 4); |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
321 type = PyString_FromStringAndSize((char *)&info.fdType, 4); |
|
2227
e53d019e7d47
Got rid of {Get,Set}FileType in favor of {Get,Set}CreatorAndType --
Guido van Rossum <guido@python.org>
parents:
2221
diff
changeset
|
322 res = Py_BuildValue("OO", creator, type); |
|
e53d019e7d47
Got rid of {Get,Set}FileType in favor of {Get,Set}CreatorAndType --
Guido van Rossum <guido@python.org>
parents:
2221
diff
changeset
|
323 Py_DECREF(creator); |
| 2136 | 324 Py_DECREF(type); |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
325 return res; |
|
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
326 } |
|
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
327 |
| 5713 | 328 static char setcrtp_doc[] = "Obsolete, use macfs module"; |
| 329 | |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
330 static PyObject * |
|
2227
e53d019e7d47
Got rid of {Get,Set}FileType in favor of {Get,Set}CreatorAndType --
Guido van Rossum <guido@python.org>
parents:
2221
diff
changeset
|
331 MacOS_SetCreatorAndType(PyObject *self, PyObject *args) |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
332 { |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
333 FSSpec fss; |
|
2227
e53d019e7d47
Got rid of {Get,Set}FileType in favor of {Get,Set}CreatorAndType --
Guido van Rossum <guido@python.org>
parents:
2221
diff
changeset
|
334 ResType creator, type; |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
335 FInfo info; |
|
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
336 OSErr err; |
|
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
337 |
|
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
338 if (!PyArg_ParseTuple(args, "O&O&O&", |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
339 PyMac_GetFSSpec, &fss, PyMac_GetOSType, &creator, PyMac_GetOSType, &type)) |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
340 return NULL; |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
341 if ((err = FSpGetFInfo(&fss, &info)) != noErr) |
|
2227
e53d019e7d47
Got rid of {Get,Set}FileType in favor of {Get,Set}CreatorAndType --
Guido van Rossum <guido@python.org>
parents:
2221
diff
changeset
|
342 return PyErr_Mac(MacOS_Error, err); |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
343 info.fdCreator = creator; |
|
2227
e53d019e7d47
Got rid of {Get,Set}FileType in favor of {Get,Set}CreatorAndType --
Guido van Rossum <guido@python.org>
parents:
2221
diff
changeset
|
344 info.fdType = type; |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
345 if ((err = FSpSetFInfo(&fss, &info)) != noErr) |
|
2227
e53d019e7d47
Got rid of {Get,Set}FileType in favor of {Get,Set}CreatorAndType --
Guido van Rossum <guido@python.org>
parents:
2221
diff
changeset
|
346 return PyErr_Mac(MacOS_Error, err); |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
347 Py_INCREF(Py_None); |
|
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
348 return Py_None; |
|
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
349 } |
|
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
350 |
|
17864
be969e717b91
Include Carbon/Carbon.h in stead of universal headers, if appropriate.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17813
diff
changeset
|
351 #if TARGET_API_MAC_OS8 |
|
2092
b03b43bee1ab
Used new getargs interface; added {Get,Set}FileInfo.
Guido van Rossum <guido@python.org>
parents:
2091
diff
changeset
|
352 /*----------------------------------------------------------------------*/ |
|
2184
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
353 /* STDWIN High Level Event interface */ |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
354 |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
355 #include <EPPC.h> |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
356 #include <Events.h> |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
357 |
| 5713 | 358 static char accepthle_doc[] = "Get arguments of pending high-level event"; |
| 359 | |
|
2184
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
360 static PyObject * |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
361 MacOS_AcceptHighLevelEvent(self, args) |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
362 PyObject *self; |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
363 PyObject *args; |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
364 { |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
365 TargetID sender; |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
366 unsigned long refcon; |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
367 Ptr buf; |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
368 unsigned long len; |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
369 OSErr err; |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
370 PyObject *res; |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
371 |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
372 buf = NULL; |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
373 len = 0; |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
374 err = AcceptHighLevelEvent(&sender, &refcon, buf, &len); |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
375 if (err == bufferIsSmall) { |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
376 buf = malloc(len); |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
377 if (buf == NULL) |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
378 return PyErr_NoMemory(); |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
379 err = AcceptHighLevelEvent(&sender, &refcon, buf, &len); |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
380 if (err != noErr) { |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
381 free(buf); |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
382 return PyErr_Mac(MacOS_Error, (int)err); |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
383 } |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
384 } |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
385 else if (err != noErr) |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
386 return PyErr_Mac(MacOS_Error, (int)err); |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
387 res = Py_BuildValue("s#ls#", |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
388 (char *)&sender, (int)(sizeof sender), refcon, (char *)buf, (int)len); |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
389 free(buf); |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
390 return res; |
|
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
391 } |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
392 #endif |
|
17865
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
393 |
|
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
394 #if !TARGET_API_MAC_OSX |
| 5713 | 395 static char schedparams_doc[] = "Set/return mainloop interrupt check flag, etc"; |
| 396 | |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2232
diff
changeset
|
397 /* |
| 5713 | 398 ** Set scheduler parameters |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2232
diff
changeset
|
399 */ |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2232
diff
changeset
|
400 static PyObject * |
| 5713 | 401 MacOS_SchedParams(PyObject *self, PyObject *args) |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2232
diff
changeset
|
402 { |
| 5713 | 403 PyMacSchedParams old, new; |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2232
diff
changeset
|
404 |
| 5713 | 405 PyMac_GetSchedParams(&old); |
| 406 new = old; | |
| 407 if (!PyArg_ParseTuple(args, "|iiidd", &new.check_interrupt, &new.process_events, | |
| 408 &new.besocial, &new.check_interval, &new.bg_yield)) | |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2232
diff
changeset
|
409 return NULL; |
| 5713 | 410 PyMac_SetSchedParams(&new); |
| 411 return Py_BuildValue("iiidd", old.check_interrupt, old.process_events, | |
| 412 old.besocial, old.check_interval, old.bg_yield); | |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2232
diff
changeset
|
413 } |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2232
diff
changeset
|
414 |
| 5713 | 415 static char appswitch_doc[] = "Obsolete, use SchedParams"; |
| 416 | |
| 417 /* Obsolete, for backward compatability */ | |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
418 static PyObject * |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
419 MacOS_EnableAppswitch(PyObject *self, PyObject *args) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
420 { |
| 5713 | 421 int new, old; |
| 422 PyMacSchedParams schp; | |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
423 |
|
2429
efb0685a6c91
return old value of PyMac_DoYieldEnabled; -1 means do not even check for interrupts
Guido van Rossum <guido@python.org>
parents:
2418
diff
changeset
|
424 if (!PyArg_ParseTuple(args, "i", &new)) |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
425 return NULL; |
| 5713 | 426 PyMac_GetSchedParams(&schp); |
| 427 if ( schp.process_events ) | |
| 428 old = 1; | |
| 429 else if ( schp.check_interrupt ) | |
| 6279 | 430 old = 0; |
| 5713 | 431 else |
| 6279 | 432 old = -1; |
| 5713 | 433 if ( new > 0 ) { |
| 434 schp.process_events = mDownMask|keyDownMask|osMask; | |
| 435 schp.check_interrupt = 1; | |
| 6279 | 436 } else if ( new == 0 ) { |
| 5713 | 437 schp.process_events = 0; |
| 438 schp.check_interrupt = 1; | |
| 439 } else { | |
| 440 schp.process_events = 0; | |
| 441 schp.check_interrupt = 0; | |
| 442 } | |
| 443 PyMac_SetSchedParams(&schp); | |
|
2429
efb0685a6c91
return old value of PyMac_DoYieldEnabled; -1 means do not even check for interrupts
Guido van Rossum <guido@python.org>
parents:
2418
diff
changeset
|
444 return Py_BuildValue("i", old); |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
445 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
446 |
| 5746 | 447 static char setevh_doc[] = "Set python event handler to be called in mainloop"; |
| 448 | |
| 449 static PyObject * | |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
450 MacOS_SetEventHandler(PyObject *self, PyObject *args) |
| 5746 | 451 { |
| 452 PyObject *evh = NULL; | |
| 453 | |
| 454 if (!PyArg_ParseTuple(args, "|O", &evh)) | |
| 455 return NULL; | |
| 456 if (evh == Py_None) | |
| 457 evh = NULL; | |
| 458 if ( evh && !PyCallable_Check(evh) ) { | |
| 459 PyErr_SetString(PyExc_ValueError, "SetEventHandler argument must be callable"); | |
| 460 return NULL; | |
| 461 } | |
| 462 if ( !PyMac_SetEventHandler(evh) ) | |
| 463 return NULL; | |
| 464 Py_INCREF(Py_None); | |
| 465 return Py_None; | |
| 466 } | |
| 467 | |
| 5713 | 468 static char handleev_doc[] = "Pass event to other interested parties like sioux"; |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
469 |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
470 static PyObject * |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
471 MacOS_HandleEvent(PyObject *self, PyObject *args) |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
472 { |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
473 EventRecord ev; |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
474 |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
475 if (!PyArg_ParseTuple(args, "O&", PyMac_GetEventRecord, &ev)) |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
476 return NULL; |
| 5746 | 477 PyMac_HandleEventIntern(&ev); |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
478 Py_INCREF(Py_None); |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
479 return Py_None; |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
480 } |
|
17865
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
481 #endif /* !TARGET_API_MAC_OSX */ |
|
2276
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
482 |
| 5713 | 483 static char geterr_doc[] = "Convert OSErr number to string"; |
| 484 | |
|
2831
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
485 static PyObject * |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
486 MacOS_GetErrorString(PyObject *self, PyObject *args) |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
487 { |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
488 int errn; |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
489 |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
490 if (!PyArg_ParseTuple(args, "i", &errn)) |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
491 return NULL; |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
492 return Py_BuildValue("s", PyMac_StrError(errn)); |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
493 } |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
494 |
|
3567
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
495 static char splash_doc[] = "Open a splash-screen dialog by resource-id (0=close)"; |
|
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
496 |
|
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
497 static PyObject * |
|
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
498 MacOS_splash(PyObject *self, PyObject *args) |
|
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
499 { |
|
4309
ecbeb445f62e
Fixed macos.splash to actually *draw* the splash box:-)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3567
diff
changeset
|
500 int resid = -1; |
|
5488
2e89c55d9a29
Don't free the MacOS_Splash() dialog twice...
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
501 static DialogPtr curdialog = NULL; |
| 6279 | 502 DialogPtr olddialog; |
|
4328
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
503 WindowRef theWindow; |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
504 CGrafPtr thePort; |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
505 #if 0 |
|
4328
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
506 short xpos, ypos, width, height, swidth, sheight; |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
507 #endif |
|
3567
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
508 |
|
4309
ecbeb445f62e
Fixed macos.splash to actually *draw* the splash box:-)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3567
diff
changeset
|
509 if (!PyArg_ParseTuple(args, "|i", &resid)) |
|
3567
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
510 return NULL; |
| 6279 | 511 olddialog = curdialog; |
|
7436
d1465b5c0a08
Fixed double-dispose of splash() dialog
Jack Jansen <jack.jansen@cwi.nl>
parents:
6330
diff
changeset
|
512 curdialog = NULL; |
|
3567
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
513 |
|
4309
ecbeb445f62e
Fixed macos.splash to actually *draw* the splash box:-)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3567
diff
changeset
|
514 if ( resid != -1 ) { |
|
ecbeb445f62e
Fixed macos.splash to actually *draw* the splash box:-)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3567
diff
changeset
|
515 curdialog = GetNewDialog(resid, NULL, (WindowPtr)-1); |
|
4328
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
516 if ( curdialog ) { |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
517 theWindow = GetDialogWindow(curdialog); |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
518 thePort = GetWindowPort(theWindow); |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
519 #if 0 |
|
4328
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
520 width = thePort->portRect.right - thePort->portRect.left; |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
521 height = thePort->portRect.bottom - thePort->portRect.top; |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
522 swidth = qd.screenBits.bounds.right - qd.screenBits.bounds.left; |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
523 sheight = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top - LMGetMBarHeight(); |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
524 xpos = (swidth-width)/2; |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
525 ypos = (sheight-height)/5 + LMGetMBarHeight(); |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
526 MoveWindow(theWindow, xpos, ypos, 0); |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
527 ShowWindow(theWindow); |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
528 #endif |
|
4309
ecbeb445f62e
Fixed macos.splash to actually *draw* the splash box:-)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3567
diff
changeset
|
529 DrawDialog(curdialog); |
|
4328
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
530 } |
|
4309
ecbeb445f62e
Fixed macos.splash to actually *draw* the splash box:-)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3567
diff
changeset
|
531 } |
| 6279 | 532 if (olddialog) |
| 533 DisposeDialog(olddialog); | |
|
3567
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
534 Py_INCREF(Py_None); |
|
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
535 return Py_None; |
|
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
536 } |
|
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
537 |
|
4342
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
538 static char DebugStr_doc[] = "Switch to low-level debugger with a message"; |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
539 |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
540 static PyObject * |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
541 MacOS_DebugStr(PyObject *self, PyObject *args) |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
542 { |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
543 Str255 message; |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
544 PyObject *object = 0; |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
545 |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
546 if (!PyArg_ParseTuple(args, "O&|O", PyMac_GetStr255, message, &object)) |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
547 return NULL; |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
548 DebugStr(message); |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
549 Py_INCREF(Py_None); |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
550 return Py_None; |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
551 } |
|
3567
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
552 |
| 6279 | 553 static char SysBeep_doc[] = "BEEEEEP!!!"; |
| 554 | |
| 555 static PyObject * | |
| 556 MacOS_SysBeep(PyObject *self, PyObject *args) | |
| 557 { | |
| 558 int duration = 6; | |
| 559 | |
| 560 if (!PyArg_ParseTuple(args, "|i", &duration)) | |
| 561 return NULL; | |
| 562 SysBeep(duration); | |
| 563 Py_INCREF(Py_None); | |
| 564 return Py_None; | |
| 565 } | |
| 566 | |
|
6212
5088ec5a12a6
Added GetTicks() here, so profiling can use a decent timer
Jack Jansen <jack.jansen@cwi.nl>
parents:
5746
diff
changeset
|
567 static char GetTicks_doc[] = "Return number of ticks since bootup"; |
|
5088ec5a12a6
Added GetTicks() here, so profiling can use a decent timer
Jack Jansen <jack.jansen@cwi.nl>
parents:
5746
diff
changeset
|
568 |
|
5088ec5a12a6
Added GetTicks() here, so profiling can use a decent timer
Jack Jansen <jack.jansen@cwi.nl>
parents:
5746
diff
changeset
|
569 static PyObject * |
|
5088ec5a12a6
Added GetTicks() here, so profiling can use a decent timer
Jack Jansen <jack.jansen@cwi.nl>
parents:
5746
diff
changeset
|
570 MacOS_GetTicks(PyObject *self, PyObject *args) |
|
5088ec5a12a6
Added GetTicks() here, so profiling can use a decent timer
Jack Jansen <jack.jansen@cwi.nl>
parents:
5746
diff
changeset
|
571 { |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
572 return Py_BuildValue("i", (int)TickCount()); |
|
6212
5088ec5a12a6
Added GetTicks() here, so profiling can use a decent timer
Jack Jansen <jack.jansen@cwi.nl>
parents:
5746
diff
changeset
|
573 } |
|
5088ec5a12a6
Added GetTicks() here, so profiling can use a decent timer
Jack Jansen <jack.jansen@cwi.nl>
parents:
5746
diff
changeset
|
574 |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
575 static char openrf_doc[] = "Open resource fork of a file"; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
576 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
577 static PyObject * |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
578 MacOS_openrf(PyObject *self, PyObject *args) |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
579 { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
580 OSErr err; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
581 char *mode = "r"; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
582 FSSpec fss; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
583 SignedByte permission = 1; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
584 rfobject *fp; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
585 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
586 if (!PyArg_ParseTuple(args, "O&|s", PyMac_GetFSSpec, &fss, &mode)) |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
587 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
588 while (*mode) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
589 switch (*mode++) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
590 case '*': break; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
591 case 'r': permission = 1; break; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
592 case 'w': permission = 2; break; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
593 case 'b': break; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
594 default: |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
595 PyErr_BadArgument(); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
596 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
597 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
598 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
599 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
600 if ( (fp = newrfobject()) == NULL ) |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
601 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
602 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
603 err = HOpenRF(fss.vRefNum, fss.parID, fss.name, permission, &fp->fRefNum); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
604 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
605 if ( err == fnfErr ) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
606 /* In stead of doing complicated things here to get creator/type |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
607 ** correct we let the standard i/o library handle it |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
608 */ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
609 FILE *tfp; |
|
19841
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
610 char pathname[PATHNAMELEN]; |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
611 |
|
19841
d8dd75e3b304
Replaced PyMac_FullPath by PyMac_FullPathname, which has an extra 'length'
Jack Jansen <jack.jansen@cwi.nl>
parents:
19066
diff
changeset
|
612 if ( err=PyMac_GetFullPathname(&fss, pathname, PATHNAMELEN) ) { |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
613 PyMac_Error(err); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
614 Py_DECREF(fp); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
615 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
616 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
617 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
618 if ( (tfp = fopen(pathname, "w")) == NULL ) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
619 PyMac_Error(fnfErr); /* What else... */ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
620 Py_DECREF(fp); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
621 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
622 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
623 fclose(tfp); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
624 err = HOpenRF(fss.vRefNum, fss.parID, fss.name, permission, &fp->fRefNum); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
625 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
626 if ( err ) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
627 Py_DECREF(fp); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
628 PyMac_Error(err); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
629 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
630 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
631 fp->isclosed = 0; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
632 return (PyObject *)fp; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
633 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
634 |
|
17865
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
635 #if !TARGET_API_MAC_OSX |
|
11824
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
636 static char FreeMem_doc[] = "Return the total amount of free space in the heap"; |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
637 |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
638 static PyObject * |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
639 MacOS_FreeMem(PyObject *self, PyObject *args) |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
640 { |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
641 long rv; |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
642 |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
643 if (!PyArg_ParseTuple(args, "")) |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
644 return NULL; |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
645 rv = FreeMem(); |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
646 return Py_BuildValue("l", rv); |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
647 } |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
648 |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
649 static char MaxBlock_doc[] = "Return the largest contiguous block of free space in the heap"; |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
650 |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
651 static PyObject * |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
652 MacOS_MaxBlock(PyObject *self, PyObject *args) |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
653 { |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
654 long rv; |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
655 |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
656 if (!PyArg_ParseTuple(args, "")) |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
657 return NULL; |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
658 rv = MaxBlock(); |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
659 return Py_BuildValue("l", rv); |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
660 } |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
661 |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
662 static char CompactMem_doc[] = "(wanted size)->actual largest block after compacting"; |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
663 |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
664 static PyObject * |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
665 MacOS_CompactMem(PyObject *self, PyObject *args) |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
666 { |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
667 long value; |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
668 long rv; |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
669 |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
670 if (!PyArg_ParseTuple(args, "l", &value)) |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
671 return NULL; |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
672 rv = CompactMem(value); |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
673 return Py_BuildValue("l", rv); |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
674 } |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
675 |
|
15193
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
676 static char KeepConsole_doc[] = "(flag) Keep console open 0:never, 1:on output 2:on error, 3:always"; |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
677 |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
678 static PyObject * |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
679 MacOS_KeepConsole(PyObject *self, PyObject *args) |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
680 { |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
681 int value; |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
682 |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
683 if (!PyArg_ParseTuple(args, "i", &value)) |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
684 return NULL; |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
685 PyMac_options.keep_console = value; |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
686 Py_INCREF(Py_None); |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
687 return Py_None; |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
688 } |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
689 |
|
15280
a5ca54969a3f
Added PyMac_OutputSeen(), which acknowledges all current output in the stdio window, i.e. it acts like input has been read insofar as the keep-console-open option is interested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15193
diff
changeset
|
690 static char OutputSeen_doc[] = "Call to reset the 'unseen output' flag for the keep-console-open option"; |
|
a5ca54969a3f
Added PyMac_OutputSeen(), which acknowledges all current output in the stdio window, i.e. it acts like input has been read insofar as the keep-console-open option is interested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15193
diff
changeset
|
691 |
|
a5ca54969a3f
Added PyMac_OutputSeen(), which acknowledges all current output in the stdio window, i.e. it acts like input has been read insofar as the keep-console-open option is interested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15193
diff
changeset
|
692 static PyObject * |
|
a5ca54969a3f
Added PyMac_OutputSeen(), which acknowledges all current output in the stdio window, i.e. it acts like input has been read insofar as the keep-console-open option is interested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15193
diff
changeset
|
693 MacOS_OutputSeen(PyObject *self, PyObject *args) |
|
a5ca54969a3f
Added PyMac_OutputSeen(), which acknowledges all current output in the stdio window, i.e. it acts like input has been read insofar as the keep-console-open option is interested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15193
diff
changeset
|
694 { |
|
a5ca54969a3f
Added PyMac_OutputSeen(), which acknowledges all current output in the stdio window, i.e. it acts like input has been read insofar as the keep-console-open option is interested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15193
diff
changeset
|
695 if (!PyArg_ParseTuple(args, "")) |
|
a5ca54969a3f
Added PyMac_OutputSeen(), which acknowledges all current output in the stdio window, i.e. it acts like input has been read insofar as the keep-console-open option is interested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15193
diff
changeset
|
696 return NULL; |
|
a5ca54969a3f
Added PyMac_OutputSeen(), which acknowledges all current output in the stdio window, i.e. it acts like input has been read insofar as the keep-console-open option is interested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15193
diff
changeset
|
697 PyMac_OutputSeen(); |
|
a5ca54969a3f
Added PyMac_OutputSeen(), which acknowledges all current output in the stdio window, i.e. it acts like input has been read insofar as the keep-console-open option is interested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15193
diff
changeset
|
698 Py_INCREF(Py_None); |
|
a5ca54969a3f
Added PyMac_OutputSeen(), which acknowledges all current output in the stdio window, i.e. it acts like input has been read insofar as the keep-console-open option is interested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15193
diff
changeset
|
699 return Py_None; |
|
a5ca54969a3f
Added PyMac_OutputSeen(), which acknowledges all current output in the stdio window, i.e. it acts like input has been read insofar as the keep-console-open option is interested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15193
diff
changeset
|
700 } |
|
17865
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
701 #endif /* !TARGET_API_MAC_OSX */ |
|
15280
a5ca54969a3f
Added PyMac_OutputSeen(), which acknowledges all current output in the stdio window, i.e. it acts like input has been read insofar as the keep-console-open option is interested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15193
diff
changeset
|
702 |
|
1892
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
703 static PyMethodDef MacOS_Methods[] = { |
|
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:
16183
diff
changeset
|
704 #if TARGET_API_MAC_OS8 |
| 5713 | 705 {"AcceptHighLevelEvent", MacOS_AcceptHighLevelEvent, 1, accepthle_doc}, |
|
12836
3fe304050434
Made the core toolbox modules carbon-compatible using the new greylist feature of bgen: non-carbon methods are still included in non-carbon MacPython. The issue of backward compatibility of Python code is still open.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11824
diff
changeset
|
706 #endif |
| 5713 | 707 {"GetCreatorAndType", MacOS_GetCreatorAndType, 1, getcrtp_doc}, |
| 708 {"SetCreatorAndType", MacOS_SetCreatorAndType, 1, setcrtp_doc}, | |
|
17865
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
709 #if !TARGET_API_MAC_OSX |
| 5713 | 710 {"SchedParams", MacOS_SchedParams, 1, schedparams_doc}, |
| 711 {"EnableAppswitch", MacOS_EnableAppswitch, 1, appswitch_doc}, | |
| 5746 | 712 {"SetEventHandler", MacOS_SetEventHandler, 1, setevh_doc}, |
| 5713 | 713 {"HandleEvent", MacOS_HandleEvent, 1, handleev_doc}, |
|
17865
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
714 #endif |
| 5713 | 715 {"GetErrorString", MacOS_GetErrorString, 1, geterr_doc}, |
| 716 {"openrf", MacOS_openrf, 1, openrf_doc}, | |
| 717 {"splash", MacOS_splash, 1, splash_doc}, | |
| 718 {"DebugStr", MacOS_DebugStr, 1, DebugStr_doc}, | |
|
6212
5088ec5a12a6
Added GetTicks() here, so profiling can use a decent timer
Jack Jansen <jack.jansen@cwi.nl>
parents:
5746
diff
changeset
|
719 {"GetTicks", MacOS_GetTicks, 1, GetTicks_doc}, |
| 6279 | 720 {"SysBeep", MacOS_SysBeep, 1, SysBeep_doc}, |
|
17865
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
721 #if !TARGET_API_MAC_OSX |
|
11824
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
722 {"FreeMem", MacOS_FreeMem, 1, FreeMem_doc}, |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
723 {"MaxBlock", MacOS_MaxBlock, 1, MaxBlock_doc}, |
|
7c255e7a21c2
Added FreeMem, MaxBlock and CompactMem calls. The values returned by these are lower bounds in the Python case (as malloc doesn't return memory to the heap) but they can be used to decide when to give low-memory warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
11529
diff
changeset
|
724 {"CompactMem", MacOS_CompactMem, 1, CompactMem_doc}, |
|
15193
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
725 {"KeepConsole", MacOS_KeepConsole, 1, KeepConsole_doc}, |
|
15280
a5ca54969a3f
Added PyMac_OutputSeen(), which acknowledges all current output in the stdio window, i.e. it acts like input has been read insofar as the keep-console-open option is interested.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15193
diff
changeset
|
726 {"OutputSeen", MacOS_OutputSeen, 1, OutputSeen_doc}, |
|
17865
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
727 #endif |
|
2184
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
728 {NULL, NULL} /* Sentinel */ |
|
1892
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
729 }; |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
730 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
731 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
732 void |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
733 initMacOS(void) |
|
1892
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
734 { |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
735 PyObject *m, *d; |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
736 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
737 m = Py_InitModule("MacOS", MacOS_Methods); |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
738 d = PyModule_GetDict(m); |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
739 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
740 /* Initialize MacOS.Error exception */ |
|
2232
8d5e36b37a41
Got rid of the Resource and Sound interfaces, in favor of the ones
Guido van Rossum <guido@python.org>
parents:
2229
diff
changeset
|
741 MacOS_Error = PyMac_GetOSErrException(); |
|
1916
e125f5021e67
config.c: add MacOS module
Guido van Rossum <guido@python.org>
parents:
1896
diff
changeset
|
742 if (MacOS_Error == NULL || PyDict_SetItemString(d, "Error", MacOS_Error) != 0) |
|
14465
e13df4e9076f
Got rid of Py_FatalError calls.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
743 return; |
|
6330
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
6279
diff
changeset
|
744 Rftype.ob_type = &PyType_Type; |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
6279
diff
changeset
|
745 Py_INCREF(&Rftype); |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
6279
diff
changeset
|
746 if (PyDict_SetItemString(d, "ResourceForkType", (PyObject *)&Rftype) != 0) |
|
14465
e13df4e9076f
Got rid of Py_FatalError calls.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
747 return; |
|
5258
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
748 /* |
|
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
749 ** This is a hack: the following constant added to the id() of a string |
|
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
750 ** object gives you the address of the data. Unfortunately, it is needed for |
|
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
751 ** some of the image and sound processing interfaces on the mac:-( |
|
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
752 */ |
|
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
753 { |
|
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
754 PyStringObject *p = 0; |
|
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
755 long off = (long)&(p->ob_sval[0]); |
|
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
756 |
|
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
757 if( PyDict_SetItemString(d, "string_id_to_buffer", Py_BuildValue("i", off)) != 0) |
|
14465
e13df4e9076f
Got rid of Py_FatalError calls.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
758 return; |
|
5258
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
759 } |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
760 #if !TARGET_API_MAC_OSX |
|
11529
f83b74273da2
First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents:
9332
diff
changeset
|
761 if (PyDict_SetItemString(d, "AppearanceCompliant", |
|
f83b74273da2
First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents:
9332
diff
changeset
|
762 Py_BuildValue("i", PyMac_AppearanceCompliant)) != 0) |
|
14465
e13df4e9076f
Got rid of Py_FatalError calls.
Jack Jansen <jack.jansen@cwi.nl>
parents:
13608
diff
changeset
|
763 return; |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
764 #endif |
|
17865
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
765 #if TARGET_API_MAC_OSX |
|
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
766 #define PY_RUNTIMEMODEL "macho" |
|
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:
16183
diff
changeset
|
767 #elif TARGET_API_MAC_OS8 |
|
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:
16183
diff
changeset
|
768 #define PY_RUNTIMEMODEL "ppc" |
|
17865
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
769 #elif TARGET_API_MAC_CARBON |
|
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
770 #define PY_RUNTIMEMODEL "carbon" |
|
16183
a130d5f7e58a
Added an attribute runtimemodel, which is either "ppc" or "carbon" and is the runtime model of the current interpreter. Will have to ad another value later for real MacOSX MachO, I guess.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15280
diff
changeset
|
771 #else |
|
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:
16183
diff
changeset
|
772 #error "None of the TARGET_API_MAC_XXX I know about is set" |
|
16183
a130d5f7e58a
Added an attribute runtimemodel, which is either "ppc" or "carbon" and is the runtime model of the current interpreter. Will have to ad another value later for real MacOSX MachO, I guess.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15280
diff
changeset
|
773 #endif |
|
a130d5f7e58a
Added an attribute runtimemodel, which is either "ppc" or "carbon" and is the runtime model of the current interpreter. Will have to ad another value later for real MacOSX MachO, I guess.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15280
diff
changeset
|
774 if (PyDict_SetItemString(d, "runtimemodel", |
|
a130d5f7e58a
Added an attribute runtimemodel, which is either "ppc" or "carbon" and is the runtime model of the current interpreter. Will have to ad another value later for real MacOSX MachO, I guess.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15280
diff
changeset
|
775 Py_BuildValue("s", PY_RUNTIMEMODEL)) != 0) |
|
a130d5f7e58a
Added an attribute runtimemodel, which is either "ppc" or "carbon" and is the runtime model of the current interpreter. Will have to ad another value later for real MacOSX MachO, I guess.
Jack Jansen <jack.jansen@cwi.nl>
parents:
15280
diff
changeset
|
776 return; |
|
1892
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
777 } |
|
2429
efb0685a6c91
return old value of PyMac_DoYieldEnabled; -1 means do not even check for interrupts
Guido van Rossum <guido@python.org>
parents:
2418
diff
changeset
|
778 |
