| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | /***********************************************************
 | 
					
						
							| 
									
										
										
										
											1995-01-08 14:33:34 +00:00
										 |  |  | Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, | 
					
						
							|  |  |  | The Netherlands. | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |                         All Rights Reserved | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Permission to use, copy, modify, and distribute this software and its  | 
					
						
							|  |  |  | documentation for any purpose and without fee is hereby granted,  | 
					
						
							|  |  |  | provided that the above copyright notice appear in all copies and that | 
					
						
							|  |  |  | both that copyright notice and this permission notice appear in  | 
					
						
							|  |  |  | supporting documentation, and that the names of Stichting Mathematisch | 
					
						
							|  |  |  | Centrum or CWI not be used in advertising or publicity pertaining to | 
					
						
							|  |  |  | distribution of the software without specific, written prior permission. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO | 
					
						
							|  |  |  | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | 
					
						
							|  |  |  | FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE | 
					
						
							|  |  |  | FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 
					
						
							|  |  |  | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 
					
						
							|  |  |  | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | 
					
						
							|  |  |  | OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ******************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Macintosh OS-specific interface */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Python.h"
 | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | #include "macglue.h"
 | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <errno.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | #include <OSUtils.h> /* for Set(Current)A5 */
 | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | #include <Resources.h>
 | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | #include <Memory.h>
 | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | #include <Sound.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | #ifndef __MWERKS__
 | 
					
						
							|  |  |  | #define SndCallBackUPP ProcPtr
 | 
					
						
							|  |  |  | #define NewSndCallBackProc(x) (x)
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | /*----------------------------------------------------------------------*/ | 
					
						
							|  |  |  | /* General tools */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *MacOS_Error; /* Exception MacOS.Error */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*----------------------------------------------------------------------*/ | 
					
						
							|  |  |  | /* Resource objects */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							| 
									
										
										
										
											1995-01-12 12:37:24 +00:00
										 |  |  | 	PyObject_HEAD | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	Handle h; | 
					
						
							|  |  |  | } RsrcObject; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | staticforward PyTypeObject RsrcType; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | #define Rsrc_Check(r) ((r)->ob_type == &RsrcType)
 | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static RsrcObject * | 
					
						
							|  |  |  | Rsrc_FromHandle(Handle h) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	RsrcObject *r; | 
					
						
							|  |  |  | 	if (h == NULL) | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | 		return (RsrcObject *)PyErr_Mac(MacOS_Error, (int)ResError()); | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	r = PyObject_NEW(RsrcObject, &RsrcType); | 
					
						
							|  |  |  | 	if (r != NULL) | 
					
						
							|  |  |  | 		r->h = h; | 
					
						
							|  |  |  | 	return r; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | Rsrc_Dealloc(RsrcObject *r) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | 	/* XXXX Note by Jack: shouldn't we ReleaseResource here? */ | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	PyMem_DEL(r); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | Rsrc_GetResInfo(RsrcObject *r, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	short id; | 
					
						
							|  |  |  | 	ResType type; | 
					
						
							|  |  |  | 	Str255 name; | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(args, "")) | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 		return NULL; | 
					
						
							|  |  |  | 	GetResInfo(r->h, &id, &type, name); | 
					
						
							|  |  |  | 	return Py_BuildValue("(is#s#)", | 
					
						
							|  |  |  | 		(int)id, (char *)&type, 4, name+1, (int)name[0]); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | static PyObject * | 
					
						
							|  |  |  | Rsrc_AsBytes(RsrcObject *r, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	long len; | 
					
						
							|  |  |  | 	PyObject *rv; | 
					
						
							|  |  |  | 	char *cp; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(args, "l", &len)) | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | 		return NULL; | 
					
						
							|  |  |  | 	HLock(r->h); | 
					
						
							|  |  |  | 	cp = (char *)*r->h; | 
					
						
							|  |  |  | 	rv = PyString_FromStringAndSize(cp, len); | 
					
						
							|  |  |  | 	HUnlock(r->h); | 
					
						
							|  |  |  | 	return rv; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | Rsrc_AsString(RsrcObject *r, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *rv; | 
					
						
							|  |  |  | 	unsigned char *cp; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(args, "")) | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | 		return NULL; | 
					
						
							|  |  |  | 	HLock(r->h); | 
					
						
							|  |  |  | 	cp = (unsigned char *)*r->h; | 
					
						
							|  |  |  | 	rv = PyString_FromStringAndSize((char *)cp+1, cp[0]); | 
					
						
							|  |  |  | 	HUnlock(r->h); | 
					
						
							|  |  |  | 	return rv; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | static PyMethodDef Rsrc_Methods[] = { | 
					
						
							|  |  |  | 	{"GetResInfo",	(PyCFunction)Rsrc_GetResInfo, 1}, | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | 	{"AsString",	(PyCFunction)Rsrc_AsString, 1}, | 
					
						
							|  |  |  | 	{"AsBytes",		(PyCFunction)Rsrc_AsBytes, 1}, | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	{NULL,			NULL}		 /* Sentinel */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | Rsrc_GetAttr(PyObject *r, char *name) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return Py_FindMethod(Rsrc_Methods, r, name); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyTypeObject RsrcType = { | 
					
						
							|  |  |  | 	PyObject_HEAD_INIT(&PyType_Type) | 
					
						
							|  |  |  | 	0, | 
					
						
							|  |  |  | 	"Resource",			/*tp_name*/ | 
					
						
							|  |  |  | 	sizeof(RsrcObject),	/*tp_basicsize*/ | 
					
						
							|  |  |  | 	0,			/*tp_itemsize*/ | 
					
						
							|  |  |  | 	/* methods */ | 
					
						
							|  |  |  | 	(destructor)Rsrc_Dealloc, /*tp_dealloc*/ | 
					
						
							|  |  |  | 	0,			/*tp_print*/ | 
					
						
							|  |  |  | 	(getattrfunc)Rsrc_GetAttr, /*tp_getattr*/ | 
					
						
							|  |  |  | 	0,			/*tp_setattr*/ | 
					
						
							|  |  |  | 	0,			/*tp_compare*/ | 
					
						
							|  |  |  | 	0,			/*tp_repr*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_number*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_sequence*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_mapping*/ | 
					
						
							|  |  |  | 	0,			/*tp_hash*/ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | MacOS_GetResource(PyObject *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	ResType rt; | 
					
						
							|  |  |  | 	int id; | 
					
						
							|  |  |  | 	Handle h; | 
					
						
							| 
									
										
										
										
											1995-01-21 13:46:04 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(args, "O&i", PyMac_GetOSType, &rt, &id)) | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 		return NULL; | 
					
						
							|  |  |  | 	h = GetResource(rt, id); | 
					
						
							|  |  |  | 	return (PyObject *)Rsrc_FromHandle(h); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | MacOS_GetNamedResource(PyObject *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	ResType rt; | 
					
						
							|  |  |  | 	Str255 name; | 
					
						
							|  |  |  | 	Handle h; | 
					
						
							| 
									
										
										
										
											1995-01-21 13:46:04 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(args, "O&O&", PyMac_GetOSType, &rt, PyMac_GetStr255, &name)) | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 		return NULL; | 
					
						
							|  |  |  | 	h = GetNamedResource(rt, name); | 
					
						
							|  |  |  | 	return (PyObject *)Rsrc_FromHandle(h); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | /*----------------------------------------------------------------------*/ | 
					
						
							|  |  |  | /* Miscellaneous File System Operations */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | MacOS_GetFileType(PyObject *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Str255 name; | 
					
						
							|  |  |  | 	FInfo info; | 
					
						
							|  |  |  | 	PyObject *type, *creator, *res; | 
					
						
							|  |  |  | 	OSErr err; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											1995-01-21 13:46:04 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(args, "O&", PyMac_GetStr255, &name)) | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err = GetFInfo(name, 0, &info)) != noErr) { | 
					
						
							|  |  |  | 		errno = err; | 
					
						
							|  |  |  | 		PyErr_SetFromErrno(MacOS_Error); | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	type = PyString_FromStringAndSize((char *)&info.fdType, 4); | 
					
						
							|  |  |  | 	creator = PyString_FromStringAndSize((char *)&info.fdCreator, 4); | 
					
						
							|  |  |  | 	res = Py_BuildValue("OO", type, creator); | 
					
						
							| 
									
										
										
										
											1995-01-12 12:37:24 +00:00
										 |  |  | 	Py_DECREF(type); | 
					
						
							|  |  |  | 	Py_DECREF(creator); | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 	return res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | MacOS_SetFileType(PyObject *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Str255 name; | 
					
						
							|  |  |  | 	ResType type, creator; | 
					
						
							|  |  |  | 	FInfo info; | 
					
						
							|  |  |  | 	OSErr err; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "O&O&O&", | 
					
						
							| 
									
										
										
										
											1995-01-21 13:46:04 +00:00
										 |  |  | 			PyMac_GetStr255, &name, PyMac_GetOSType, &type, PyMac_GetOSType, &creator)) | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if ((err = GetFInfo(name, 0, &info)) != noErr) { | 
					
						
							|  |  |  | 		errno = err; | 
					
						
							|  |  |  | 		PyErr_SetFromErrno(MacOS_Error); | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	info.fdType = type; | 
					
						
							|  |  |  | 	info.fdCreator = creator; | 
					
						
							|  |  |  | 	if ((err = SetFInfo(name, 0, &info)) != noErr) { | 
					
						
							|  |  |  | 		errno = err; | 
					
						
							| 
									
										
										
										
											1995-01-12 12:37:24 +00:00
										 |  |  | 		PyErr_SetFromErrno(MacOS_Error); | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 		return NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | /*----------------------------------------------------------------------*/ | 
					
						
							|  |  |  | /* SoundChannel objects */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | /* Convert a SndCommand argument */ | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | static int | 
					
						
							|  |  |  | GetSndCommand(PyObject *v, SndCommand *pc) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int len; | 
					
						
							|  |  |  | 	pc->param1 = 0; | 
					
						
							|  |  |  | 	pc->param2 = 0; | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 	if (PyTuple_Check(v)) { | 
					
						
							|  |  |  | 		if (PyArg_ParseTuple(v, "h|hl", &pc->cmd, &pc->param1, &pc->param2)) | 
					
						
							|  |  |  | 			return 1; | 
					
						
							|  |  |  | 		PyErr_Clear(); | 
					
						
							|  |  |  | 		return PyArg_ParseTuple(v, "hhs#", &pc->cmd, &pc->param1, &pc->param2, &len); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return PyArg_Parse(v, "h", &pc->cmd); | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							| 
									
										
										
										
											1995-01-12 12:37:24 +00:00
										 |  |  | 	PyObject_HEAD | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	SndChannelPtr chan; | 
					
						
							|  |  |  | } SndChObject; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | staticforward PyTypeObject SndChType; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | #define SndCh_Check(s) ((s)->ob_type == &SndChType)
 | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static SndChObject * | 
					
						
							|  |  |  | SndCh_FromSndChannelPtr(SndChannelPtr chan) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	SndChObject *s = PyObject_NEW(SndChObject, &SndChType); | 
					
						
							|  |  |  | 	if (s != NULL) | 
					
						
							|  |  |  | 		s->chan = chan; | 
					
						
							|  |  |  | 	return s; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | SndCh_Cleanup(SndChObject *s, int quitNow) | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | 	SndChannelPtr chan = s->chan; | 
					
						
							|  |  |  | 	if (chan != NULL) { | 
					
						
							|  |  |  | 		void *userInfo = (void *)chan->userInfo; | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 		s->chan = NULL; | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | 		SndDisposeChannel(chan, quitNow); | 
					
						
							|  |  |  | 		if (userInfo != 0) | 
					
						
							| 
									
										
										
										
											1995-01-12 12:37:24 +00:00
										 |  |  | 			PyMem_DEL(userInfo); | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | SndCh_Dealloc(SndChObject *s) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	SndCh_Cleanup(s, 1); | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	PyMem_DEL(s); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | SndCh_DisposeChannel(SndChObject *s, PyObject *args) | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | 	int quitNow = 1; | 
					
						
							|  |  |  | 	if (PyTuple_Size(args) > 0) { | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 		if (!PyArg_ParseTuple(args, "i", &quitNow)) | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 			return NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | 	SndCh_Cleanup(s, quitNow); | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | static int | 
					
						
							|  |  |  | SndCh_OK(SndChObject *s) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (s->chan == NULL) { | 
					
						
							|  |  |  | 		PyErr_SetString(MacOS_Error, "channel is closed"); | 
					
						
							|  |  |  | 		return 0; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return 1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | static PyObject * | 
					
						
							|  |  |  | SndCh_SndPlay(SndChObject *s, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	RsrcObject *r; | 
					
						
							|  |  |  | 	int async = 0; | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(args, "O!|i", RsrcType, &r, &async)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | 	if (!SndCh_OK(s)) | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											1995-01-22 16:52:02 +00:00
										 |  |  | 	SndPlay(s->chan, (SndListHandle)r->h, async); | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	Py_INCREF(Py_None); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | SndCh_SndDoCommand(SndChObject *s, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	SndCommand c; | 
					
						
							|  |  |  | 	int noWait = 0; | 
					
						
							|  |  |  | 	OSErr err; | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(args, "O&|i", GetSndCommand, &c, &noWait)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | 	if (!SndCh_OK(s)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	err = SndDoCommand(s->chan, &c, noWait); | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | 	return PyErr_Mac(MacOS_Error, (int)err); | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | SndCh_SndDoImmediate(SndChObject *s, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	SndCommand c; | 
					
						
							|  |  |  | 	OSErr err; | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(args, "O&", GetSndCommand, &c)) | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 		return 0; | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | 	if (!SndCh_OK(s)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	err = SndDoImmediate(s->chan, &c); | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | 	return PyErr_Mac(MacOS_Error, (int)err); | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyMethodDef SndCh_Methods[] = { | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | 	{"close",				(PyCFunction)SndCh_DisposeChannel, 1}, | 
					
						
							|  |  |  | 	{"SndDisposeChannel",	(PyCFunction)SndCh_DisposeChannel, 1}, | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	{"SndPlay",				(PyCFunction)SndCh_SndPlay, 1}, | 
					
						
							|  |  |  | 	{"SndDoCommand",		(PyCFunction)SndCh_SndDoCommand, 1}, | 
					
						
							|  |  |  | 	{"SndDoImmediate",		(PyCFunction)SndCh_SndDoImmediate, 1}, | 
					
						
							|  |  |  | 	{NULL,					NULL}		 /* Sentinel */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | SndCh_GetAttr(PyObject *s, char *name) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return Py_FindMethod(SndCh_Methods, s, name); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyTypeObject SndChType = { | 
					
						
							|  |  |  | 	PyObject_HEAD_INIT(&PyType_Type) | 
					
						
							|  |  |  | 	0, | 
					
						
							|  |  |  | 	"SoundChannel",			/*tp_name*/ | 
					
						
							|  |  |  | 	sizeof(SndChObject),	/*tp_basicsize*/ | 
					
						
							|  |  |  | 	0,			/*tp_itemsize*/ | 
					
						
							|  |  |  | 	/* methods */ | 
					
						
							|  |  |  | 	(destructor)SndCh_Dealloc, /*tp_dealloc*/ | 
					
						
							|  |  |  | 	0,			/*tp_print*/ | 
					
						
							|  |  |  | 	(getattrfunc)SndCh_GetAttr, /*tp_getattr*/ | 
					
						
							|  |  |  | 	0,			/*tp_setattr*/ | 
					
						
							|  |  |  | 	0,			/*tp_compare*/ | 
					
						
							|  |  |  | 	0,			/*tp_repr*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_number*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_sequence*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_mapping*/ | 
					
						
							|  |  |  | 	0,			/*tp_hash*/ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*----------------------------------------------------------------------*/ | 
					
						
							|  |  |  | /* Module */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | typedef struct { | 
					
						
							|  |  |  | 	long A5; | 
					
						
							|  |  |  | 	PyObject *callback; | 
					
						
							|  |  |  | 	PyObject *channel; | 
					
						
							|  |  |  | 	SndCommand cmd; | 
					
						
							|  |  |  | } cbinfo; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int | 
					
						
							|  |  |  | MySafeCallback(arg) | 
					
						
							|  |  |  | 	void *arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	cbinfo *p = (cbinfo *)arg; | 
					
						
							|  |  |  | 	PyObject *args; | 
					
						
							|  |  |  | 	PyObject *res; | 
					
						
							|  |  |  | 	args = Py_BuildValue("(O(hhl))", | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | 						 p->channel, p->cmd.cmd, p->cmd.param1, p->cmd.param2); | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | 	res = PyEval_CallObject(p->callback, args); | 
					
						
							|  |  |  | 	Py_DECREF(args); | 
					
						
							|  |  |  | 	if (res == NULL) | 
					
						
							|  |  |  | 		return -1; | 
					
						
							| 
									
										
										
										
											1995-01-12 12:37:24 +00:00
										 |  |  | 	Py_DECREF(res); | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static pascal void | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | #ifdef __MWERKS__
 | 
					
						
							|  |  |  | MyUserRoutine(SndChannelPtr chan, SndCommand *cmd) | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | MyUserRoutine(SndChannelPtr chan, SndCommand cmd) | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	cbinfo *p = (cbinfo *)chan->userInfo; | 
					
						
							|  |  |  | 	long A5 = SetA5(p->A5); | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | #ifdef __MWERKS__
 | 
					
						
							|  |  |  | 	p->cmd = *cmd; | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | 	p->cmd = cmd; | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | 	Py_AddPendingCall(MySafeCallback, (void *)p); | 
					
						
							|  |  |  | 	SetA5(A5); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | static PyObject * | 
					
						
							|  |  |  | MacOS_SndNewChannel(PyObject *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	SndChannelPtr chan; | 
					
						
							|  |  |  | 	short synth; | 
					
						
							|  |  |  | 	long init = 0; | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | 	PyObject *callback = NULL; | 
					
						
							|  |  |  | 	cbinfo *p = NULL; | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | 	SndCallBackUPP userroutine = 0; | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	OSErr err; | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | 	PyObject *res; | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(args, "h|lO", &synth, &init, &callback)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | 	if (callback != NULL) { | 
					
						
							| 
									
										
										
										
											1995-01-12 12:37:24 +00:00
										 |  |  | 		p = PyMem_NEW(cbinfo, 1); | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | 		if (p == NULL) | 
					
						
							|  |  |  | 			return PyErr_NoMemory(); | 
					
						
							|  |  |  | 		p->A5 = SetCurrentA5(); | 
					
						
							|  |  |  | 		p->callback = callback; | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | 		userroutine = NewSndCallBackProc(MyUserRoutine); | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	chan = NULL; | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | 	err = SndNewChannel(&chan, synth, init, userroutine); | 
					
						
							|  |  |  | 	if (err) { | 
					
						
							|  |  |  | 		if (p) | 
					
						
							| 
									
										
										
										
											1995-01-12 12:37:24 +00:00
										 |  |  | 			PyMem_DEL(p); | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | 		return PyErr_Mac(MacOS_Error, (int)err); | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	res = (PyObject *)SndCh_FromSndChannelPtr(chan); | 
					
						
							|  |  |  | 	if (res == NULL) { | 
					
						
							|  |  |  | 		SndDisposeChannel(chan, 1); | 
					
						
							| 
									
										
										
										
											1995-01-12 12:37:24 +00:00
										 |  |  | 		PyMem_DEL(p); | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | 	else { | 
					
						
							|  |  |  | 		chan->userInfo = (long)p; | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | 		p->channel = res; | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											1994-09-16 12:48:59 +00:00
										 |  |  | 	return res; | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | MacOS_SndPlay(PyObject *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	RsrcObject *r; | 
					
						
							|  |  |  | 	OSErr err; | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(args, "O!", &RsrcType, &r)) | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											1995-01-22 16:52:02 +00:00
										 |  |  | 	err = SndPlay((SndChannelPtr)NULL, (SndListHandle)r->h, 0); | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | 	return PyErr_Mac(MacOS_Error, (int)err); | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | MacOS_SndControl(PyObject *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int id; | 
					
						
							|  |  |  | 	SndCommand c; | 
					
						
							|  |  |  | 	OSErr err; | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 	if (!PyArg_ParseTuple(args, "iO&", &id, GetSndCommand, &c)) | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 		return NULL; | 
					
						
							|  |  |  | 	err = SndControl(id, &c); | 
					
						
							|  |  |  | 	if (err) | 
					
						
							| 
									
										
										
										
											1994-12-14 14:02:24 +00:00
										 |  |  | 		return PyErr_Mac(MacOS_Error, (int)err); | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	return Py_BuildValue("(hhl)", c.cmd, c.param1, c.param2); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-01-18 23:58:07 +00:00
										 |  |  | /*----------------------------------------------------------------------*/ | 
					
						
							|  |  |  | /* STDWIN High Level Event interface */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <EPPC.h>
 | 
					
						
							|  |  |  | #include <Events.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef USE_STDWIN
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern void (*_w_high_level_event_proc)(EventRecord *); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *MacOS_HighLevelEventHandler = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | MacOS_HighLevelEventProc(EventRecord *erp) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (MacOS_HighLevelEventHandler != NULL) { | 
					
						
							|  |  |  | 		PyObject *args = Py_BuildValue("(s#)", (char *)erp, (int)sizeof(*erp)); | 
					
						
							|  |  |  | 		PyObject *res; | 
					
						
							|  |  |  | 		if (args == NULL) | 
					
						
							|  |  |  | 			res = NULL; | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			res = PyEval_CallObject(MacOS_HighLevelEventHandler, args); | 
					
						
							|  |  |  | 			Py_DECREF(args); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (res == NULL) { | 
					
						
							|  |  |  | 			fprintf(stderr, "Exception in MacOS_HighLevelEventProc:\n"); | 
					
						
							|  |  |  | 			PyErr_Print(); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			Py_DECREF(res); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | MacOS_SetHighLevelEventHandler(self, args) | 
					
						
							|  |  |  | 	PyObject *self; | 
					
						
							|  |  |  | 	PyObject *args; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *previous = MacOS_HighLevelEventHandler; | 
					
						
							|  |  |  | 	PyObject *next = NULL; | 
					
						
							|  |  |  | 	if (!PyArg_ParseTuple(args, "|O", &next)) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	if (next == Py_None) | 
					
						
							|  |  |  | 		next = NULL; | 
					
						
							|  |  |  | 	Py_INCREF(next); | 
					
						
							|  |  |  | 	MacOS_HighLevelEventHandler = next; | 
					
						
							|  |  |  | 	if (next == NULL) | 
					
						
							|  |  |  | 		_w_high_level_event_proc = NULL; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		_w_high_level_event_proc = MacOS_HighLevelEventProc; | 
					
						
							|  |  |  | 	if (previous == NULL) { | 
					
						
							|  |  |  | 		Py_INCREF(Py_None); | 
					
						
							|  |  |  | 		previous = Py_None; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return previous; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* USE_STDWIN */
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | MacOS_AcceptHighLevelEvent(self, args) | 
					
						
							|  |  |  | 	PyObject *self; | 
					
						
							|  |  |  | 	PyObject *args; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	TargetID sender; | 
					
						
							|  |  |  | 	unsigned long refcon; | 
					
						
							|  |  |  | 	Ptr buf; | 
					
						
							|  |  |  | 	unsigned long len; | 
					
						
							|  |  |  | 	OSErr err; | 
					
						
							|  |  |  | 	PyObject *res; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	buf = NULL; | 
					
						
							|  |  |  | 	len = 0; | 
					
						
							|  |  |  | 	err = AcceptHighLevelEvent(&sender, &refcon, buf, &len); | 
					
						
							|  |  |  | 	if (err == bufferIsSmall) { | 
					
						
							|  |  |  | 		buf = malloc(len); | 
					
						
							|  |  |  | 		if (buf == NULL) | 
					
						
							|  |  |  | 			return PyErr_NoMemory(); | 
					
						
							|  |  |  | 		err = AcceptHighLevelEvent(&sender, &refcon, buf, &len); | 
					
						
							|  |  |  | 		if (err != noErr) { | 
					
						
							|  |  |  | 			free(buf); | 
					
						
							|  |  |  | 			return PyErr_Mac(MacOS_Error, (int)err); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else if (err != noErr) | 
					
						
							|  |  |  | 		return PyErr_Mac(MacOS_Error, (int)err); | 
					
						
							|  |  |  | 	res = Py_BuildValue("s#ls#", | 
					
						
							|  |  |  | 		(char *)&sender, (int)(sizeof sender), refcon, (char *)buf, (int)len); | 
					
						
							|  |  |  | 	free(buf); | 
					
						
							|  |  |  | 	return res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | static PyMethodDef MacOS_Methods[] = { | 
					
						
							| 
									
										
										
										
											1995-01-18 23:58:07 +00:00
										 |  |  | 	{"AcceptHighLevelEvent",	MacOS_AcceptHighLevelEvent, 1}, | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	{"GetResource",			MacOS_GetResource, 1}, | 
					
						
							| 
									
										
										
										
											1995-01-18 23:58:07 +00:00
										 |  |  | 	{"GetNamedResource",		MacOS_GetNamedResource, 1}, | 
					
						
							| 
									
										
										
										
											1995-01-09 13:20:04 +00:00
										 |  |  | 	{"GetFileType",			MacOS_GetFileType, 1}, | 
					
						
							|  |  |  | 	{"SetFileType",			MacOS_SetFileType, 1}, | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	{"SndNewChannel",		MacOS_SndNewChannel, 1}, | 
					
						
							| 
									
										
										
										
											1995-01-18 23:58:07 +00:00
										 |  |  | 	{"SndPlay",			MacOS_SndPlay, 1}, | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 	{"SndControl",			MacOS_SndControl, 1}, | 
					
						
							| 
									
										
										
										
											1995-01-18 23:58:07 +00:00
										 |  |  | #ifdef USE_STDWIN
 | 
					
						
							|  |  |  | 	{"SetHighLevelEventHandler",	MacOS_SetHighLevelEventHandler, 1}, | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 	{NULL,				NULL}		 /* Sentinel */ | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void | 
					
						
							|  |  |  | MacOS_Init() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *m, *d; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	m = Py_InitModule("MacOS", MacOS_Methods); | 
					
						
							|  |  |  | 	d = PyModule_GetDict(m); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* Initialize MacOS.Error exception */ | 
					
						
							|  |  |  | 	MacOS_Error = PyString_FromString("MacOS.Error"); | 
					
						
							| 
									
										
										
										
											1994-09-29 10:02:56 +00:00
										 |  |  | 	if (MacOS_Error == NULL || PyDict_SetItemString(d, "Error", MacOS_Error) != 0) | 
					
						
							| 
									
										
										
										
											1994-09-16 10:54:21 +00:00
										 |  |  | 		Py_FatalError("can't define MacOS.Error"); | 
					
						
							|  |  |  | } |