summaryrefslogtreecommitdiff
path: root/Mac/Modules/ctl
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2002-12-03 23:40:22 +0000
committerJack Jansen <jack.jansen@cwi.nl>2002-12-03 23:40:22 +0000
commit96cebde909bbb8034af576d8f31f465bbad90374 (patch)
tree305f0e665ac5676a19485cf662920a7db5c19eee /Mac/Modules/ctl
parent99899b92b86ee69f0b46b708a465f445059dc793 (diff)
downloadcpython-git-96cebde909bbb8034af576d8f31f465bbad90374.tar.gz
Added PEP253 support to most Carbon modules. This isn't complete yet:
some of the more compilcated cases (CF, Res) haven't been done yet. Also, various types should inherit from each other (anything with an as_Resource method should be a Resource subtype, the CF types should become one family).
Diffstat (limited to 'Mac/Modules/ctl')
-rw-r--r--Mac/Modules/ctl/_Ctlmodule.c55
-rw-r--r--Mac/Modules/ctl/ctlsupport.py2
2 files changed, 43 insertions, 14 deletions
diff --git a/Mac/Modules/ctl/_Ctlmodule.c b/Mac/Modules/ctl/_Ctlmodule.c
index aa0af9e0fb..9c1e04196a 100644
--- a/Mac/Modules/ctl/_Ctlmodule.c
+++ b/Mac/Modules/ctl/_Ctlmodule.c
@@ -4545,6 +4545,7 @@ static PyMethodDef CtlObj_methods[] = {
#define CtlObj_getsetlist NULL
+
static int CtlObj_compare(ControlObject *self, ControlObject *other)
{
unsigned long v, w;
@@ -4570,6 +4571,24 @@ static long CtlObj_hash(ControlObject *self)
{
return (long)self->ob_itself;
}
+#define CtlObj_tp_init 0
+
+#define CtlObj_tp_alloc PyType_GenericAlloc
+
+static PyObject *CtlObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ PyObject *self;
+ ControlHandle itself;
+ char *kw[] = {"itself", 0};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CtlObj_Convert, &itself)) return NULL;
+ if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
+ ((ControlObject *)self)->ob_itself = itself;
+ return self;
+}
+
+#define CtlObj_tp_free PyObject_Del
+
PyTypeObject Control_Type = {
PyObject_HEAD_INIT(NULL)
@@ -4592,19 +4611,27 @@ PyTypeObject Control_Type = {
0, /*tp_str*/
PyObject_GenericGetAttr, /*tp_getattro*/
PyObject_GenericSetAttr, /*tp_setattro */
- 0, /*outputHook_tp_as_buffer*/
- 0, /*outputHook_tp_flags*/
- 0, /*outputHook_tp_doc*/
- 0, /*outputHook_tp_traverse*/
- 0, /*outputHook_tp_clear*/
- 0, /*outputHook_tp_richcompare*/
- 0, /*outputHook_tp_weaklistoffset*/
- 0, /*outputHook_tp_iter*/
- 0, /*outputHook_tp_iternext*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
CtlObj_methods, /* tp_methods */
- 0, /*outputHook_tp_members*/
+ 0, /*tp_members*/
CtlObj_getsetlist, /*tp_getset*/
- 0, /*outputHook_tp_base*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ CtlObj_tp_init, /* tp_init */
+ CtlObj_tp_alloc, /* tp_alloc */
+ CtlObj_tp_new, /* tp_new */
+ CtlObj_tp_free, /* tp_free */
};
/* -------------------- End object type Control --------------------- */
@@ -6714,8 +6741,10 @@ void init_Ctl(void)
return;
Control_Type.ob_type = &PyType_Type;
Py_INCREF(&Control_Type);
- if (PyDict_SetItemString(d, "ControlType", (PyObject *)&Control_Type) != 0)
- Py_FatalError("can't initialize ControlType");
+ PyModule_AddObject(m, "Control", (PyObject *)&Control_Type);
+ /* Backward-compatible name */
+ Py_INCREF(&Control_Type);
+ PyModule_AddObject(m, "ControlType", (PyObject *)&Control_Type);
}
/* ======================== End module _Ctl ========================= */
diff --git a/Mac/Modules/ctl/ctlsupport.py b/Mac/Modules/ctl/ctlsupport.py
index 6053f9316c..2fa575773f 100644
--- a/Mac/Modules/ctl/ctlsupport.py
+++ b/Mac/Modules/ctl/ctlsupport.py
@@ -490,7 +490,7 @@ PyMac_INIT_TOOLBOX_OBJECT_NEW(ControlHandle, CtlObj_New);
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ControlHandle, CtlObj_Convert);
"""
-class MyObjectDefinition(PEP252Mixin, ObjectIdentityMixin, GlobalObjectDefinition):
+class MyObjectDefinition(PEP253Mixin, ObjectIdentityMixin, GlobalObjectDefinition):
def outputStructMembers(self):
GlobalObjectDefinition.outputStructMembers(self)
Output("PyObject *ob_callbackdict;")