diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2000-08-25 22:17:51 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2000-08-25 22:17:51 (GMT) |
commit | 0aee0e61f8e7b1b112500aa3ae1edb7bcb5e28b1 (patch) | |
tree | f59c9850a71fc18f23fc52df4cbb8d7ac145eb34 /Mac/Modules/win/winsupport.py | |
parent | 0c1836f13bc3587f3a7bd74073cef63ef9a17b4c (diff) | |
download | cpython-0aee0e61f8e7b1b112500aa3ae1edb7bcb5e28b1.zip cpython-0aee0e61f8e7b1b112500aa3ae1edb7bcb5e28b1.tar.gz cpython-0aee0e61f8e7b1b112500aa3ae1edb7bcb5e28b1.tar.bz2 |
Window objects now also have an AutoDispose funcpointer (set for our windows, cleared for foreign windows). Needed mainly for Carbon (where we don't know about the windows belonging to our dialogs).
Fixed a few calls that return an ExistingWindow.
Diffstat (limited to 'Mac/Modules/win/winsupport.py')
-rw-r--r-- | Mac/Modules/win/winsupport.py | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/Mac/Modules/win/winsupport.py b/Mac/Modules/win/winsupport.py index bfc5f27..65d70d0 100644 --- a/Mac/Modules/win/winsupport.py +++ b/Mac/Modules/win/winsupport.py @@ -49,6 +49,12 @@ PropertyTag = OSTypeType("PropertyTag") includestuff = includestuff + """ #include <%s>""" % MACHEADERFILE + """ +/* Function to dispose a window, with a "normal" calling sequence */ +static void +PyMac_AutoDisposeWindow(WindowPtr w) +{ + DisposeWindow(w); +} """ finalstuff = finalstuff + """ @@ -60,15 +66,18 @@ WinObj_WhichWindow(w) { PyObject *it; - /* XXX What if we find a stdwin window or a window belonging - to some other package? */ - if (w == NULL) - it = NULL; - else - it = (PyObject *) GetWRefCon(w); - if (it == NULL || ((WindowObject *)it)->ob_itself != w) + if (w == NULL) { it = Py_None; - Py_INCREF(it); + Py_INCREF(it); + } else { + it = (PyObject *) GetWRefCon(w); + if (it == NULL || ((WindowObject *)it)->ob_itself != w) { + it = WinObj_New(w); + ((WindowObject *)it)->ob_freeit = NULL; + } else { + Py_INCREF(it); + } + } return it; } """ @@ -76,22 +85,31 @@ WinObj_WhichWindow(w) class MyObjectDefinition(GlobalObjectDefinition): def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") + def outputStructMembers(self): + GlobalObjectDefinition.outputStructMembers(self) + Output("void (*ob_freeit)(%s ptr);", self.itselftype) def outputInitStructMembers(self): GlobalObjectDefinition.outputInitStructMembers(self) Output("SetWRefCon(itself, (long)it);") + Output("it->ob_freeit = PyMac_AutoDisposeWindow;") def outputCheckConvertArg(self): - Output("#if !TARGET_API_MAC_CARBON") OutLbrace("if (DlgObj_Check(v))") - Output("*p_itself = ((WindowObject *)v)->ob_itself;") + Output("*p_itself = DlgObj_ConvertToWindow(v);") Output("return 1;") OutRbrace() - Output("#endif") Out(""" if (v == Py_None) { *p_itself = NULL; return 1; } if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; } """) - def outputFreeIt(self, itselfname): - Output("DisposeWindow(%s);", itselfname) + def outputCleanupStructMembers(self): + Output("if (self->ob_itself) SetWRefCon(self->ob_itself, 0);") + Output("if (self->ob_freeit && self->ob_itself)") + OutLbrace() + Output("self->ob_freeit(self->ob_itself);") + OutRbrace() + Output("self->ob_itself = NULL;") +## def outputFreeIt(self, itselfname): +## Output("DisposeWindow(%s);", itselfname) # From here on it's basically all boiler plate... # Create the generator groups and link them |