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.
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 @@
#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 @@
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 @@
{"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 @@
(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 @@
#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" */