diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1999-12-23 14:32:06 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1999-12-23 14:32:06 (GMT) |
commit | a1a0fef2ea9ece5b16f9e6c37800778c64844e69 (patch) | |
tree | 6af31ec1186b5ebe0aed89f5c4159445fff61381 /Mac/Modules/ctl | |
parent | 7b912120caa517ef4fa65eefc26e63f3dea8009a (diff) | |
download | cpython-a1a0fef2ea9ece5b16f9e6c37800778c64844e69.zip cpython-a1a0fef2ea9ece5b16f9e6c37800778c64844e69.tar.gz cpython-a1a0fef2ea9ece5b16f9e6c37800778c64844e69.tar.bz2 |
Unified handle-conversion scheme to
handle = Ctl.as_Resource(ctl)
ctl = Ctl.as_Control(handle)
and similarly for List, Menu, TE. The old handle.as_Control() methods are
still there for backward compatability.
Diffstat (limited to 'Mac/Modules/ctl')
-rw-r--r-- | Mac/Modules/ctl/Ctlmodule.c | 13 | ||||
-rw-r--r-- | Mac/Modules/ctl/ctledit.py | 8 | ||||
-rw-r--r-- | Mac/Modules/ctl/ctlsupport.py | 1 |
3 files changed, 11 insertions, 11 deletions
diff --git a/Mac/Modules/ctl/Ctlmodule.c b/Mac/Modules/ctl/Ctlmodule.c index d1deee8..3648a55 100644 --- a/Mac/Modules/ctl/Ctlmodule.c +++ b/Mac/Modules/ctl/Ctlmodule.c @@ -45,6 +45,7 @@ extern PyObject *WinObj_WhichWindow(WindowPtr); #include <Controls.h> #define as_Control(h) ((ControlHandle)h) +#define as_Resource(ctl) ((Handle)ctl) #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */ @@ -1008,9 +1009,13 @@ static PyObject *CtlObj_as_Resource(_self, _args) PyObject *_args; { PyObject *_res = NULL; - - return ResObj_New((Handle)_self->ob_itself); - + Handle _rv; + if (!PyArg_ParseTuple(_args, "")) + return NULL; + _rv = as_Resource(_self->ob_itself); + _res = Py_BuildValue("O&", + ResObj_New, _rv); + return _res; } static PyObject *CtlObj_DisposeControl(_self, _args) @@ -1400,7 +1405,7 @@ static PyMethodDef CtlObj_methods[] = { {"GetControlDataSize", (PyCFunction)CtlObj_GetControlDataSize, 1, "(ControlPartCode inPart, ResType inTagName) -> (Size outMaxSize)"}, {"as_Resource", (PyCFunction)CtlObj_as_Resource, 1, - "Return this Control as a Resource"}, + "() -> (Handle _rv)"}, {"DisposeControl", (PyCFunction)CtlObj_DisposeControl, 1, "() -> None"}, {"TrackControl", (PyCFunction)CtlObj_TrackControl, 1, diff --git a/Mac/Modules/ctl/ctledit.py b/Mac/Modules/ctl/ctledit.py index 97534e2..ea433e5 100644 --- a/Mac/Modules/ctl/ctledit.py +++ b/Mac/Modules/ctl/ctledit.py @@ -2,13 +2,7 @@ f = Function(ControlHandle, 'as_Control', (Handle, 'h', InMode)) functions.append(f) -as_resource_body = """ -return ResObj_New((Handle)_self->ob_itself); -""" - -f = ManualGenerator("as_Resource", as_resource_body) -f.docstring = lambda : "Return this Control as a Resource" - +f = Method(Handle, 'as_Resource', (ControlHandle, 'ctl', InMode)) methods.append(f) DisposeControl_body = """ diff --git a/Mac/Modules/ctl/ctlsupport.py b/Mac/Modules/ctl/ctlsupport.py index 4a4620f..8ac9d5c 100644 --- a/Mac/Modules/ctl/ctlsupport.py +++ b/Mac/Modules/ctl/ctlsupport.py @@ -45,6 +45,7 @@ includestuff = includestuff + """ #include <%s>""" % MACHEADERFILE + """ #define as_Control(h) ((ControlHandle)h) +#define as_Resource(ctl) ((Handle)ctl) #define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */ |