Mercurial > cpython-lru_cache-weakref
annotate Mac/Modules/macosmodule.c @ 27998:e27f58a50737 legacy-trunk
SF bug #690377: Dud footnote reference in distutils docs
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 21 Feb 2003 02:47:09 +0000 |
| parents | aef3a03a79f1 |
| children | 7aa2163889ac |
| 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 |
|
24280
1598a1e473e2
staticforward bites the dust.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23510
diff
changeset
|
63 static PyTypeObject Rftype; |
|
3425
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); |
|
23510
82309c7325ef
Replaced lots of PyMem_DEL() calls with PyObject_DEL().
Jack Jansen <jack.jansen@cwi.nl>
parents:
22963
diff
changeset
|
262 PyObject_DEL(self); |
|
3425
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 |
|
17865
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
351 #if !TARGET_API_MAC_OSX |
| 5713 | 352 static char schedparams_doc[] = "Set/return mainloop interrupt check flag, etc"; |
| 353 | |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2232
diff
changeset
|
354 /* |
| 5713 | 355 ** Set scheduler parameters |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2232
diff
changeset
|
356 */ |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2232
diff
changeset
|
357 static PyObject * |
| 5713 | 358 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
|
359 { |
| 5713 | 360 PyMacSchedParams old, new; |
|
2251
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2232
diff
changeset
|
361 |
| 5713 | 362 PyMac_GetSchedParams(&old); |
| 363 new = old; | |
| 364 if (!PyArg_ParseTuple(args, "|iiidd", &new.check_interrupt, &new.process_events, | |
| 365 &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
|
366 return NULL; |
| 5713 | 367 PyMac_SetSchedParams(&new); |
| 368 return Py_BuildValue("iiidd", old.check_interrupt, old.process_events, | |
| 369 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
|
370 } |
|
e0a3242d5ae7
Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents:
2232
diff
changeset
|
371 |
| 5713 | 372 static char appswitch_doc[] = "Obsolete, use SchedParams"; |
| 373 | |
| 374 /* Obsolete, for backward compatability */ | |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
375 static PyObject * |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
376 MacOS_EnableAppswitch(PyObject *self, PyObject *args) |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
377 { |
| 5713 | 378 int new, old; |
| 379 PyMacSchedParams schp; | |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
380 |
|
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
|
381 if (!PyArg_ParseTuple(args, "i", &new)) |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
382 return NULL; |
| 5713 | 383 PyMac_GetSchedParams(&schp); |
| 384 if ( schp.process_events ) | |
| 385 old = 1; | |
| 386 else if ( schp.check_interrupt ) | |
| 6279 | 387 old = 0; |
| 5713 | 388 else |
| 6279 | 389 old = -1; |
| 5713 | 390 if ( new > 0 ) { |
| 391 schp.process_events = mDownMask|keyDownMask|osMask; | |
| 392 schp.check_interrupt = 1; | |
| 6279 | 393 } else if ( new == 0 ) { |
| 5713 | 394 schp.process_events = 0; |
| 395 schp.check_interrupt = 1; | |
| 396 } else { | |
| 397 schp.process_events = 0; | |
| 398 schp.check_interrupt = 0; | |
| 399 } | |
| 400 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
|
401 return Py_BuildValue("i", old); |
|
2262
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
402 } |
|
03bd79432f06
- Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents:
2251
diff
changeset
|
403 |
| 5746 | 404 static char setevh_doc[] = "Set python event handler to be called in mainloop"; |
| 405 | |
| 406 static PyObject * | |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
407 MacOS_SetEventHandler(PyObject *self, PyObject *args) |
| 5746 | 408 { |
| 409 PyObject *evh = NULL; | |
| 410 | |
| 411 if (!PyArg_ParseTuple(args, "|O", &evh)) | |
| 412 return NULL; | |
| 413 if (evh == Py_None) | |
| 414 evh = NULL; | |
| 415 if ( evh && !PyCallable_Check(evh) ) { | |
| 416 PyErr_SetString(PyExc_ValueError, "SetEventHandler argument must be callable"); | |
| 417 return NULL; | |
| 418 } | |
| 419 if ( !PyMac_SetEventHandler(evh) ) | |
| 420 return NULL; | |
| 421 Py_INCREF(Py_None); | |
| 422 return Py_None; | |
| 423 } | |
| 424 | |
| 5713 | 425 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
|
426 |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
427 static PyObject * |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
428 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
|
429 { |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
430 EventRecord ev; |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
431 |
|
66d6d13df4f8
Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents:
2262
diff
changeset
|
432 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
|
433 return NULL; |
| 5746 | 434 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
|
435 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
|
436 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
|
437 } |
|
17865
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
438 #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
|
439 |
| 5713 | 440 static char geterr_doc[] = "Convert OSErr number to string"; |
| 441 | |
|
2831
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
442 static PyObject * |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
443 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
|
444 { |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
445 int errn; |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
446 |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
447 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
|
448 return NULL; |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
449 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
|
450 } |
|
eedd6c1f3ae7
Added GetErrorString method (convert OSErr number to string)
Jack Jansen <jack.jansen@cwi.nl>
parents:
2429
diff
changeset
|
451 |
|
3567
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
452 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
|
453 |
|
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
454 static PyObject * |
|
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
455 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
|
456 { |
|
4309
ecbeb445f62e
Fixed macos.splash to actually *draw* the splash box:-)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3567
diff
changeset
|
457 int resid = -1; |
|
5488
2e89c55d9a29
Don't free the MacOS_Splash() dialog twice...
Jack Jansen <jack.jansen@cwi.nl>
parents:
5429
diff
changeset
|
458 static DialogPtr curdialog = NULL; |
| 6279 | 459 DialogPtr olddialog; |
|
4328
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
460 WindowRef theWindow; |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
461 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
|
462 #if 0 |
|
4328
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
463 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
|
464 #endif |
|
3567
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
465 |
|
4309
ecbeb445f62e
Fixed macos.splash to actually *draw* the splash box:-)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3567
diff
changeset
|
466 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
|
467 return NULL; |
| 6279 | 468 olddialog = curdialog; |
|
7436
d1465b5c0a08
Fixed double-dispose of splash() dialog
Jack Jansen <jack.jansen@cwi.nl>
parents:
6330
diff
changeset
|
469 curdialog = NULL; |
|
3567
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
470 |
|
4309
ecbeb445f62e
Fixed macos.splash to actually *draw* the splash box:-)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3567
diff
changeset
|
471 if ( resid != -1 ) { |
|
ecbeb445f62e
Fixed macos.splash to actually *draw* the splash box:-)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3567
diff
changeset
|
472 curdialog = GetNewDialog(resid, NULL, (WindowPtr)-1); |
|
4328
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
473 if ( curdialog ) { |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
474 theWindow = GetDialogWindow(curdialog); |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
475 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
|
476 #if 0 |
|
4328
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
477 width = thePort->portRect.right - thePort->portRect.left; |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
478 height = thePort->portRect.bottom - thePort->portRect.top; |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
479 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
|
480 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
|
481 xpos = (swidth-width)/2; |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
482 ypos = (sheight-height)/5 + LMGetMBarHeight(); |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
483 MoveWindow(theWindow, xpos, ypos, 0); |
|
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
484 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
|
485 #endif |
|
4309
ecbeb445f62e
Fixed macos.splash to actually *draw* the splash box:-)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3567
diff
changeset
|
486 DrawDialog(curdialog); |
|
4328
b03ab35d52df
Added dialog-centering code to splash()
Jack Jansen <jack.jansen@cwi.nl>
parents:
4309
diff
changeset
|
487 } |
|
4309
ecbeb445f62e
Fixed macos.splash to actually *draw* the splash box:-)
Jack Jansen <jack.jansen@cwi.nl>
parents:
3567
diff
changeset
|
488 } |
| 6279 | 489 if (olddialog) |
| 490 DisposeDialog(olddialog); | |
|
3567
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
491 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
|
492 return Py_None; |
|
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
493 } |
|
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
494 |
|
4342
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
495 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
|
496 |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
497 static PyObject * |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
498 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
|
499 { |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
500 Str255 message; |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
501 PyObject *object = 0; |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
502 |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
503 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
|
504 return NULL; |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
505 DebugStr(message); |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
506 Py_INCREF(Py_None); |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
507 return Py_None; |
|
897297abe5b4
Added DebugStr method to drop into low-level debugger
Jack Jansen <jack.jansen@cwi.nl>
parents:
4328
diff
changeset
|
508 } |
|
3567
6f715bff17e4
Added splash method (to quickly display splash screen without first
Jack Jansen <jack.jansen@cwi.nl>
parents:
3430
diff
changeset
|
509 |
| 6279 | 510 static char SysBeep_doc[] = "BEEEEEP!!!"; |
| 511 | |
| 512 static PyObject * | |
| 513 MacOS_SysBeep(PyObject *self, PyObject *args) | |
| 514 { | |
| 515 int duration = 6; | |
| 516 | |
| 517 if (!PyArg_ParseTuple(args, "|i", &duration)) | |
| 518 return NULL; | |
| 519 SysBeep(duration); | |
| 520 Py_INCREF(Py_None); | |
| 521 return Py_None; | |
| 522 } | |
| 523 | |
|
6212
5088ec5a12a6
Added GetTicks() here, so profiling can use a decent timer
Jack Jansen <jack.jansen@cwi.nl>
parents:
5746
diff
changeset
|
524 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
|
525 |
|
5088ec5a12a6
Added GetTicks() here, so profiling can use a decent timer
Jack Jansen <jack.jansen@cwi.nl>
parents:
5746
diff
changeset
|
526 static PyObject * |
|
5088ec5a12a6
Added GetTicks() here, so profiling can use a decent timer
Jack Jansen <jack.jansen@cwi.nl>
parents:
5746
diff
changeset
|
527 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
|
528 { |
|
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
|
529 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
|
530 } |
|
5088ec5a12a6
Added GetTicks() here, so profiling can use a decent timer
Jack Jansen <jack.jansen@cwi.nl>
parents:
5746
diff
changeset
|
531 |
|
3425
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
532 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
|
533 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
534 static PyObject * |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
535 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
|
536 { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
537 OSErr err; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
538 char *mode = "r"; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
539 FSSpec fss; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
540 SignedByte permission = 1; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
541 rfobject *fp; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
542 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
543 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
|
544 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
545 while (*mode) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
546 switch (*mode++) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
547 case '*': break; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
548 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
|
549 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
|
550 case 'b': break; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
551 default: |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
552 PyErr_BadArgument(); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
553 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
554 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
555 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
556 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
557 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
|
558 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
559 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
560 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
|
561 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
562 if ( err == fnfErr ) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
563 /* 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
|
564 ** 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
|
565 */ |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
566 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
|
567 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
|
568 |
|
26769
aef3a03a79f1
- Various tweaks to shut up compiler warnings.
Jack Jansen <jack.jansen@cwi.nl>
parents:
26610
diff
changeset
|
569 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
|
570 PyMac_Error(err); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
571 Py_DECREF(fp); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
572 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
573 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
574 |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
575 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
|
576 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
|
577 Py_DECREF(fp); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
578 return NULL; |
|
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 fclose(tfp); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
581 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
|
582 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
583 if ( err ) { |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
584 Py_DECREF(fp); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
585 PyMac_Error(err); |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
586 return NULL; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
587 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
588 fp->isclosed = 0; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
589 return (PyObject *)fp; |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
590 } |
|
23254daa247b
Added openrf method, which opens resource fork. The resulting object
Jack Jansen <jack.jansen@cwi.nl>
parents:
2831
diff
changeset
|
591 |
|
17865
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
592 #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
|
593 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
|
594 |
|
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
|
595 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
|
596 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
|
597 { |
|
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
|
598 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
|
599 |
|
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
|
600 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
|
601 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
|
602 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
|
603 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
|
604 } |
|
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
|
605 |
|
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
|
606 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
|
607 |
|
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
|
608 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
|
609 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
|
610 { |
|
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
|
611 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
|
612 |
|
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
|
613 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
|
614 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
|
615 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
|
616 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
|
617 } |
|
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
|
618 |
|
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
|
619 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
|
620 |
|
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
|
621 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
|
622 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
|
623 { |
|
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
|
624 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
|
625 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
|
626 |
|
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
|
627 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
|
628 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
|
629 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
|
630 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
|
631 } |
|
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
|
632 |
|
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
|
633 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
|
634 |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
635 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
|
636 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
|
637 { |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
638 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
|
639 |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
640 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
|
641 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
|
642 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
|
643 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
|
644 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
|
645 } |
|
e3d8365ea231
Added a method KeepConsole so programs can override the Keep console open option.
Jack Jansen <jack.jansen@cwi.nl>
parents:
14465
diff
changeset
|
646 |
|
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
|
647 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
|
648 |
|
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
|
649 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
|
650 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
|
651 { |
|
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
|
652 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
|
653 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
|
654 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
|
655 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
|
656 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
|
657 } |
|
17865
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
658 #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
|
659 |
|
1892
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
660 static PyMethodDef MacOS_Methods[] = { |
| 5713 | 661 {"GetCreatorAndType", MacOS_GetCreatorAndType, 1, getcrtp_doc}, |
| 662 {"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
|
663 #if !TARGET_API_MAC_OSX |
| 5713 | 664 {"SchedParams", MacOS_SchedParams, 1, schedparams_doc}, |
| 665 {"EnableAppswitch", MacOS_EnableAppswitch, 1, appswitch_doc}, | |
| 5746 | 666 {"SetEventHandler", MacOS_SetEventHandler, 1, setevh_doc}, |
| 5713 | 667 {"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
|
668 #endif |
| 5713 | 669 {"GetErrorString", MacOS_GetErrorString, 1, geterr_doc}, |
| 670 {"openrf", MacOS_openrf, 1, openrf_doc}, | |
| 671 {"splash", MacOS_splash, 1, splash_doc}, | |
| 672 {"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
|
673 {"GetTicks", MacOS_GetTicks, 1, GetTicks_doc}, |
| 6279 | 674 {"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
|
675 #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
|
676 {"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
|
677 {"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
|
678 {"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
|
679 {"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
|
680 {"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
|
681 #endif |
|
2184
87f4d6d2e9c8
added high level event interface (requires stdwin patch)
Guido van Rossum <guido@python.org>
parents:
2175
diff
changeset
|
682 {NULL, NULL} /* Sentinel */ |
|
1892
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
683 }; |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
684 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
685 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
686 void |
|
19066
a1b4f3a1ee07
- Don't return mac-style pathnames in unix-Python.
Jack Jansen <jack.jansen@cwi.nl>
parents:
17865
diff
changeset
|
687 initMacOS(void) |
|
1892
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
688 { |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
689 PyObject *m, *d; |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
690 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
691 m = Py_InitModule("MacOS", MacOS_Methods); |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
692 d = PyModule_GetDict(m); |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
693 |
|
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
694 /* 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
|
695 MacOS_Error = PyMac_GetOSErrException(); |
|
1916
e125f5021e67
config.c: add MacOS module
Guido van Rossum <guido@python.org>
parents:
1896
diff
changeset
|
696 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
|
697 return; |
|
6330
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
6279
diff
changeset
|
698 Rftype.ob_type = &PyType_Type; |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
6279
diff
changeset
|
699 Py_INCREF(&Rftype); |
|
172c7febd755
Export type objects to Python
Jack Jansen <jack.jansen@cwi.nl>
parents:
6279
diff
changeset
|
700 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
|
701 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
|
702 /* |
|
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
703 ** 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
|
704 ** 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
|
705 ** 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
|
706 */ |
|
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
707 { |
|
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
708 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
|
709 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
|
710 |
|
40d2fd472284
Added an attribute string_id_to_buffer, which gives the offset you
Jack Jansen <jack.jansen@cwi.nl>
parents:
5152
diff
changeset
|
711 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
|
712 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
|
713 } |
|
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 #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
|
715 #define PY_RUNTIMEMODEL "macho" |
|
fde5508e82de
Ifdeffed a few more sections. All functionality that is relevant on MacOSX
Jack Jansen <jack.jansen@cwi.nl>
parents:
17864
diff
changeset
|
716 #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
|
717 #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
|
718 #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
|
719 #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
|
720 #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
|
721 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
|
722 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
|
723 return; |
|
1892
eec0dc5aba60
gestaltmodule.c: interface to Gestalt Manager.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
724 } |
|
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
|
725 |
