mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
Got rid of {Get,Set}FileType in favor of {Get,Set}CreatorAndType --
the former had their arguments reversed compared to all Apple's routines (e.g. FSpOpenResFile()). Also fixed the SoundMgr UserRoutine (Jack fixed it but put the fix between #ifdef __MWERKS__ ... #endif :-( ). NB eventually this module should disappear in favor of separate modules per manager (e.g. Resources, Sound, Files, ...).
This commit is contained in:
parent
c02311ba53
commit
b7e79e5f94
1 changed files with 19 additions and 37 deletions
|
|
@ -71,7 +71,6 @@ Rsrc_FromHandle(Handle h)
|
||||||
static void
|
static void
|
||||||
Rsrc_Dealloc(RsrcObject *r)
|
Rsrc_Dealloc(RsrcObject *r)
|
||||||
{
|
{
|
||||||
/* XXXX Note by Jack: shouldn't we ReleaseResource here? */
|
|
||||||
PyMem_DEL(r);
|
PyMem_DEL(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,8 +119,8 @@ Rsrc_AsString(RsrcObject *r, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef Rsrc_Methods[] = {
|
static PyMethodDef Rsrc_Methods[] = {
|
||||||
{"GetResInfo", (PyCFunction)Rsrc_GetResInfo, 1},
|
{"GetResInfo", (PyCFunction)Rsrc_GetResInfo, 1},
|
||||||
{"AsString", (PyCFunction)Rsrc_AsString, 1},
|
{"AsString", (PyCFunction)Rsrc_AsString, 1},
|
||||||
{"AsBytes", (PyCFunction)Rsrc_AsBytes, 1},
|
{"AsBytes", (PyCFunction)Rsrc_AsBytes, 1},
|
||||||
{NULL, NULL} /* Sentinel */
|
{NULL, NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
@ -179,51 +178,42 @@ MacOS_GetNamedResource(PyObject *self, PyObject *args)
|
||||||
/* Miscellaneous File System Operations */
|
/* Miscellaneous File System Operations */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
MacOS_GetFileType(PyObject *self, PyObject *args)
|
MacOS_GetCreatorAndType(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
Str255 name;
|
Str255 name;
|
||||||
FInfo info;
|
FInfo info;
|
||||||
PyObject *type, *creator, *res;
|
PyObject *creator, *type, *res;
|
||||||
OSErr err;
|
OSErr err;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, &name))
|
if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, &name))
|
||||||
return NULL;
|
return NULL;
|
||||||
if ((err = GetFInfo(name, 0, &info)) != noErr) {
|
if ((err = GetFInfo(name, 0, &info)) != noErr)
|
||||||
errno = err;
|
return PyErr_Mac(MacOS_Error, err);
|
||||||
PyErr_SetFromErrno(MacOS_Error);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
type = PyString_FromStringAndSize((char *)&info.fdType, 4);
|
|
||||||
creator = PyString_FromStringAndSize((char *)&info.fdCreator, 4);
|
creator = PyString_FromStringAndSize((char *)&info.fdCreator, 4);
|
||||||
res = Py_BuildValue("OO", type, creator);
|
type = PyString_FromStringAndSize((char *)&info.fdType, 4);
|
||||||
Py_DECREF(type);
|
res = Py_BuildValue("OO", creator, type);
|
||||||
Py_DECREF(creator);
|
Py_DECREF(creator);
|
||||||
|
Py_DECREF(type);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
MacOS_SetFileType(PyObject *self, PyObject *args)
|
MacOS_SetCreatorAndType(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
Str255 name;
|
Str255 name;
|
||||||
ResType type, creator;
|
ResType creator, type;
|
||||||
FInfo info;
|
FInfo info;
|
||||||
OSErr err;
|
OSErr err;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O&O&O&",
|
if (!PyArg_ParseTuple(args, "O&O&O&",
|
||||||
PyMac_GetStr255, &name, PyMac_GetOSType, &type, PyMac_GetOSType, &creator))
|
PyMac_GetStr255, &name, PyMac_GetOSType, &creator, PyMac_GetOSType, &type))
|
||||||
return NULL;
|
return NULL;
|
||||||
if ((err = GetFInfo(name, 0, &info)) != noErr) {
|
if ((err = GetFInfo(name, 0, &info)) != noErr)
|
||||||
errno = err;
|
return PyErr_Mac(MacOS_Error, err);
|
||||||
PyErr_SetFromErrno(MacOS_Error);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
info.fdType = type;
|
|
||||||
info.fdCreator = creator;
|
info.fdCreator = creator;
|
||||||
if ((err = SetFInfo(name, 0, &info)) != noErr) {
|
info.fdType = type;
|
||||||
errno = err;
|
if ((err = SetFInfo(name, 0, &info)) != noErr)
|
||||||
PyErr_SetFromErrno(MacOS_Error);
|
return PyErr_Mac(MacOS_Error, err);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
@ -411,19 +401,11 @@ MySafeCallback(arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
static pascal void
|
static pascal void
|
||||||
#ifdef __MWERKS__
|
|
||||||
MyUserRoutine(SndChannelPtr chan, SndCommand *cmd)
|
MyUserRoutine(SndChannelPtr chan, SndCommand *cmd)
|
||||||
#else
|
|
||||||
MyUserRoutine(SndChannelPtr chan, SndCommand cmd)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
cbinfo *p = (cbinfo *)chan->userInfo;
|
cbinfo *p = (cbinfo *)chan->userInfo;
|
||||||
long A5 = SetA5(p->A5);
|
long A5 = SetA5(p->A5);
|
||||||
#ifdef __MWERKS__
|
|
||||||
p->cmd = *cmd;
|
p->cmd = *cmd;
|
||||||
#else
|
|
||||||
p->cmd = cmd;
|
|
||||||
#endif
|
|
||||||
Py_AddPendingCall(MySafeCallback, (void *)p);
|
Py_AddPendingCall(MySafeCallback, (void *)p);
|
||||||
SetA5(A5);
|
SetA5(A5);
|
||||||
}
|
}
|
||||||
|
|
@ -589,8 +571,8 @@ static PyMethodDef MacOS_Methods[] = {
|
||||||
{"AcceptHighLevelEvent", MacOS_AcceptHighLevelEvent, 1},
|
{"AcceptHighLevelEvent", MacOS_AcceptHighLevelEvent, 1},
|
||||||
{"GetResource", MacOS_GetResource, 1},
|
{"GetResource", MacOS_GetResource, 1},
|
||||||
{"GetNamedResource", MacOS_GetNamedResource, 1},
|
{"GetNamedResource", MacOS_GetNamedResource, 1},
|
||||||
{"GetFileType", MacOS_GetFileType, 1},
|
{"GetCreatorAndType", MacOS_GetCreatorAndType, 1},
|
||||||
{"SetFileType", MacOS_SetFileType, 1},
|
{"SetCreatorAndType", MacOS_SetCreatorAndType, 1},
|
||||||
{"SndNewChannel", MacOS_SndNewChannel, 1},
|
{"SndNewChannel", MacOS_SndNewChannel, 1},
|
||||||
{"SndPlay", MacOS_SndPlay, 1},
|
{"SndPlay", MacOS_SndPlay, 1},
|
||||||
{"SndControl", MacOS_SndControl, 1},
|
{"SndControl", MacOS_SndControl, 1},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue