summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/dlg/_Dlgmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Mac/Modules/dlg/_Dlgmodule.c')
-rw-r--r--Mac/Modules/dlg/_Dlgmodule.c233
1 files changed, 117 insertions, 116 deletions
diff --git a/Mac/Modules/dlg/_Dlgmodule.c b/Mac/Modules/dlg/_Dlgmodule.c
index 19ae1e9..64ddac8 100644
--- a/Mac/Modules/dlg/_Dlgmodule.c
+++ b/Mac/Modules/dlg/_Dlgmodule.c
@@ -34,55 +34,55 @@ static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
EventRecord *event,
short *itemHit)
{
- Boolean rv;
- PyObject *args, *res;
- PyObject *callback = Dlg_FilterProc_callback;
- if (callback == NULL)
- return 0; /* Default behavior */
- Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
- args = Py_BuildValue("O&O&", DlgObj_WhichDialog, dialog, PyMac_BuildEventRecord, event);
- if (args == NULL)
- res = NULL;
- else {
- res = PyEval_CallObject(callback, args);
- Py_DECREF(args);
- }
- if (res == NULL) {
- PySys_WriteStderr("Exception in Dialog Filter\n");
- PyErr_Print();
- *itemHit = -1; /* Fake return item */
- return 1; /* We handled it */
- }
- else {
- Dlg_FilterProc_callback = callback;
- if (PyInt_Check(res)) {
- *itemHit = PyInt_AsLong(res);
- rv = 1;
- }
- else
- rv = PyObject_IsTrue(res);
- }
- Py_DECREF(res);
- return rv;
+ Boolean rv;
+ PyObject *args, *res;
+ PyObject *callback = Dlg_FilterProc_callback;
+ if (callback == NULL)
+ return 0; /* Default behavior */
+ Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
+ args = Py_BuildValue("O&O&", DlgObj_WhichDialog, dialog, PyMac_BuildEventRecord, event);
+ if (args == NULL)
+ res = NULL;
+ else {
+ res = PyEval_CallObject(callback, args);
+ Py_DECREF(args);
+ }
+ if (res == NULL) {
+ PySys_WriteStderr("Exception in Dialog Filter\n");
+ PyErr_Print();
+ *itemHit = -1; /* Fake return item */
+ return 1; /* We handled it */
+ }
+ else {
+ Dlg_FilterProc_callback = callback;
+ if (PyInt_Check(res)) {
+ *itemHit = PyInt_AsLong(res);
+ rv = 1;
+ }
+ else
+ rv = PyObject_IsTrue(res);
+ }
+ Py_DECREF(res);
+ return rv;
}
static ModalFilterUPP
Dlg_PassFilterProc(PyObject *callback)
{
- PyObject *tmp = Dlg_FilterProc_callback;
- static ModalFilterUPP UnivFilterUpp = NULL;
-
- Dlg_FilterProc_callback = NULL;
- if (callback == Py_None) {
- Py_XDECREF(tmp);
- return NULL;
- }
- Py_INCREF(callback);
- Dlg_FilterProc_callback = callback;
- Py_XDECREF(tmp);
- if ( UnivFilterUpp == NULL )
- UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc);
- return UnivFilterUpp;
+ PyObject *tmp = Dlg_FilterProc_callback;
+ static ModalFilterUPP UnivFilterUpp = NULL;
+
+ Dlg_FilterProc_callback = NULL;
+ if (callback == Py_None) {
+ Py_XDECREF(tmp);
+ return NULL;
+ }
+ Py_INCREF(callback);
+ Dlg_FilterProc_callback = callback;
+ Py_XDECREF(tmp);
+ if ( UnivFilterUpp == NULL )
+ UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc);
+ return UnivFilterUpp;
}
static PyObject *Dlg_UserItemProc_callback = NULL;
@@ -90,24 +90,24 @@ static PyObject *Dlg_UserItemProc_callback = NULL;
static pascal void Dlg_UnivUserItemProc(DialogPtr dialog,
short item)
{
- PyObject *args, *res;
-
- if (Dlg_UserItemProc_callback == NULL)
- return; /* Default behavior */
- Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
- args = Py_BuildValue("O&h", DlgObj_WhichDialog, dialog, item);
- if (args == NULL)
- res = NULL;
- else {
- res = PyEval_CallObject(Dlg_UserItemProc_callback, args);
- Py_DECREF(args);
- }
- if (res == NULL) {
- PySys_WriteStderr("Exception in Dialog UserItem proc\n");
- PyErr_Print();
- }
- Py_XDECREF(res);
- return;
+ PyObject *args, *res;
+
+ if (Dlg_UserItemProc_callback == NULL)
+ return; /* Default behavior */
+ Dlg_FilterProc_callback = NULL; /* We'll restore it when call successful */
+ args = Py_BuildValue("O&h", DlgObj_WhichDialog, dialog, item);
+ if (args == NULL)
+ res = NULL;
+ else {
+ res = PyEval_CallObject(Dlg_UserItemProc_callback, args);
+ Py_DECREF(args);
+ }
+ if (res == NULL) {
+ PySys_WriteStderr("Exception in Dialog UserItem proc\n");
+ PyErr_Print();
+ }
+ Py_XDECREF(res);
+ return;
}
#if 0
@@ -146,6 +146,7 @@ PyObject *DlgObj_New(DialogPtr itself)
SetWRefCon(GetDialogWindow(itself), (long)it);
return (PyObject *)it;
}
+
int DlgObj_Convert(PyObject *v, DialogPtr *p_itself)
{
if (v == Py_None) { *p_itself = NULL; return 1; }
@@ -958,16 +959,16 @@ static int DlgObj_hash(DialogObject *self)
#define DlgObj_tp_alloc PyType_GenericAlloc
-static PyObject *DlgObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+static PyObject *DlgObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
{
- PyObject *self;
+ PyObject *_self;
DialogPtr itself;
char *kw[] = {"itself", 0};
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, DlgObj_Convert, &itself)) return NULL;
- if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
- ((DialogObject *)self)->ob_itself = itself;
- return self;
+ if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, DlgObj_Convert, &itself)) return NULL;
+ if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
+ ((DialogObject *)_self)->ob_itself = itself;
+ return _self;
}
#define DlgObj_tp_free PyObject_Del
@@ -1452,28 +1453,28 @@ static PyObject *Dlg_SetUserItemHandler(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
- PyObject *new = NULL;
-
-
- if (!PyArg_ParseTuple(_args, "|O", &new))
- return NULL;
-
- if (Dlg_UserItemProc_callback && new && new != Py_None) {
- PyErr_SetString(Dlg_Error, "Another UserItemProc is already installed");
- return NULL;
- }
-
- if (new == NULL || new == Py_None) {
- new = NULL;
- _res = Py_None;
- Py_INCREF(Py_None);
- } else {
- Py_INCREF(new);
- _res = Py_BuildValue("O&", ResObj_New, (Handle)NewUserItemUPP(Dlg_UnivUserItemProc));
- }
-
- Dlg_UserItemProc_callback = new;
- return _res;
+ PyObject *new = NULL;
+
+
+ if (!PyArg_ParseTuple(_args, "|O", &new))
+ return NULL;
+
+ if (Dlg_UserItemProc_callback && new && new != Py_None) {
+ PyErr_SetString(Dlg_Error, "Another UserItemProc is already installed");
+ return NULL;
+ }
+
+ if (new == NULL || new == Py_None) {
+ new = NULL;
+ _res = Py_None;
+ Py_INCREF(Py_None);
+ } else {
+ Py_INCREF(new);
+ _res = Py_BuildValue("O&", ResObj_New, (Handle)NewUserItemUPP(Dlg_UnivUserItemProc));
+ }
+
+ Dlg_UserItemProc_callback = new;
+ return _res;
}
@@ -1528,9 +1529,9 @@ static PyMethodDef Dlg_methods[] = {
WindowPtr
DlgObj_ConvertToWindow(PyObject *self)
{
- if ( DlgObj_Check(self) )
- return GetDialogWindow(((DialogObject *)self)->ob_itself);
- return NULL;
+ if ( DlgObj_Check(self) )
+ return GetDialogWindow(((DialogObject *)self)->ob_itself);
+ return NULL;
}
#endif
/* Return the object corresponding to the dialog, or None */
@@ -1538,29 +1539,29 @@ DlgObj_ConvertToWindow(PyObject *self)
PyObject *
DlgObj_WhichDialog(DialogPtr d)
{
- PyObject *it;
-
- if (d == NULL) {
- it = Py_None;
- Py_INCREF(it);
- } else {
- WindowPtr w = GetDialogWindow(d);
-
- it = (PyObject *) GetWRefCon(w);
- if (it == NULL || ((DialogObject *)it)->ob_itself != d || !DlgObj_Check(it)) {
+ PyObject *it;
+
+ if (d == NULL) {
+ it = Py_None;
+ Py_INCREF(it);
+ } else {
+ WindowPtr w = GetDialogWindow(d);
+
+ it = (PyObject *) GetWRefCon(w);
+ if (it == NULL || ((DialogObject *)it)->ob_itself != d || !DlgObj_Check(it)) {
#if 0
- /* Should do this, but we don't have an ob_freeit for dialogs yet. */
- it = WinObj_New(w);
- ((WindowObject *)it)->ob_freeit = NULL;
+ /* Should do this, but we don't have an ob_freeit for dialogs yet. */
+ it = WinObj_New(w);
+ ((WindowObject *)it)->ob_freeit = NULL;
#else
- it = Py_None;
- Py_INCREF(it);
+ it = Py_None;
+ Py_INCREF(it);
#endif
- } else {
- Py_INCREF(it);
- }
- }
- return it;
+ } else {
+ Py_INCREF(it);
+ }
+ }
+ return it;
}
@@ -1571,9 +1572,9 @@ void init_Dlg(void)
- PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_New);
- PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_WhichDialog);
- PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DialogPtr, DlgObj_Convert);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(DialogPtr, DlgObj_WhichDialog);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(DialogPtr, DlgObj_Convert);
m = Py_InitModule("_Dlg", Dlg_methods);