summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-01-18 23:57:26 (GMT)
committerGuido van Rossum <guido@python.org>1995-01-18 23:57:26 (GMT)
commit8f69179f973b1eb4c29914d73a275a2488132a08 (patch)
tree7c2e6868abaac2ff8e516ebc58446f0102389224 /Mac
parent8d6c180c8d32d5c3126a1d9a30512cdb69343c64 (diff)
downloadcpython-8f69179f973b1eb4c29914d73a275a2488132a08.zip
cpython-8f69179f973b1eb4c29914d73a275a2488132a08.tar.gz
cpython-8f69179f973b1eb4c29914d73a275a2488132a08.tar.bz2
modernized/rationalized, added PyMac_BuildOSType
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Include/macglue.h18
-rw-r--r--Mac/Python/macglue.c17
2 files changed, 24 insertions, 11 deletions
diff --git a/Mac/Include/macglue.h b/Mac/Include/macglue.h
index 7c074d3..89d10d1 100644
--- a/Mac/Include/macglue.h
+++ b/Mac/Include/macglue.h
@@ -2,11 +2,15 @@
#include <Types.h>
#include <Resources.h>
-char *macstrerror PROTO((int)); /* strerror with mac errors */
-object *PyErr_Mac PROTO((object *, int)); /* Exception with a mac error */
-int PyMac_Idle PROTO((void)); /* Idle routine */
-int GetOSType PROTO((object *, ResType *)); /* argument parser for OSType */
-int GetStr255 PROTO((object *, Str255)); /* argument parser for Str255 */
-int GetFSSpec PROTO((object *, FSSpec *)); /* argument parser for FSSpec */
-object *PyMac_BuildFSSpec PROTO((FSSpec *)); /* Convert FSSpec to python object */
+char *macstrerror Py_PROTO((int)); /* strerror with mac errors */
+PyObject *PyErr_Mac Py_PROTO((PyObject *, int)); /* Exception with a mac error */
+int PyMac_Idle Py_PROTO((void)); /* Idle routine */
+int PyMac_GetOSType Py_PROTO((PyObject *, ResType *)); /* argument parser for OSType */
+int PyMac_GetStr255 Py_PROTO((PyObject *, Str255)); /* argument parser for Str255 */
+int PyMac_GetFSSpec Py_PROTO((PyObject *, FSSpec *)); /* argument parser for FSSpec */
+PyObject *PyMac_BuildFSSpec Py_PROTO((FSSpec *)); /* Convert FSSpec to PyObject */
+PyObject *PyMac_BuildOSType Py_PROTO((OSType)); /* Convert OSType to PyObject */
+#define GetOSType PyMac_GetOSType
+#define GetStr255 PyMac_GetStr255
+#define GetFSSpec PyMac_GetFSSpec
diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c
index 76e96a8..741e985 100644
--- a/Mac/Python/macglue.c
+++ b/Mac/Python/macglue.c
@@ -63,10 +63,12 @@ PyErr_Mac(PyObject *eobj, int err)
char *msg;
PyObject *v;
- if (err == 0) {
+ if (err == 0 && !PyErr_Occurred()) {
Py_INCREF(Py_None);
return Py_None;
}
+ if (err == -1 && PyErr_Occurred())
+ return NULL;
msg = macstrerror(err);
v = Py_BuildValue("(is)", err, msg);
PyErr_SetObject(eobj, v);
@@ -102,7 +104,7 @@ PyMac_Idle()
/* Convert a ResType argument */
int
-GetOSType(PyObject *v, ResType *pr)
+PyMac_GetOSType(PyObject *v, ResType *pr)
{
if (!PyString_Check(v) || PyString_Size(v) != 4) {
PyErr_SetString(PyExc_TypeError,
@@ -115,7 +117,7 @@ GetOSType(PyObject *v, ResType *pr)
/* Convert a Str255 argument */
int
-GetStr255(PyObject *v, Str255 pbuf)
+PyMac_GetStr255(PyObject *v, Str255 pbuf)
{
int len;
if (!PyString_Check(v) || (len = PyString_Size(v)) > 255) {
@@ -136,7 +138,7 @@ GetStr255(PyObject *v, Str255 pbuf)
** this is probably sys7 dependent anyway).
*/
int
-GetFSSpec(PyObject *v, FSSpec *fs)
+PyMac_GetFSSpec(PyObject *v, FSSpec *fs)
{
Str255 path;
short refnum;
@@ -172,3 +174,10 @@ PyMac_BuildFSSpec(FSSpec *fs)
{
return Py_BuildValue("(iis#)", fs->vRefNum, fs->parID, &fs->name[1], fs->name[0]);
}
+
+/* Convert an OSType value to a 4-char string object */
+PyObject *
+PyMac_BuildOSType(OSType t)
+{
+ return PyString_FromStringAndSize((char *)&t, 4);
+}