diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2004-07-15 13:42:06 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2004-07-15 13:42:06 (GMT) |
commit | 3bfc28c12f3627470d9e4d1ff18c76cfce54cc02 (patch) | |
tree | 9e961c1ac3712769ea07d3715754086d8ecd2d2d /Mac | |
parent | 59f072ad7c7b56a1e803a74ba59d869b838c256f (diff) | |
download | cpython-3bfc28c12f3627470d9e4d1ff18c76cfce54cc02.zip cpython-3bfc28c12f3627470d9e4d1ff18c76cfce54cc02.tar.gz cpython-3bfc28c12f3627470d9e4d1ff18c76cfce54cc02.tar.bz2 |
Make CF module PEP253 based (finally).
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/Modules/cf/_CFmodule.c | 731 | ||||
-rw-r--r-- | Mac/Modules/cf/cfsupport.py | 48 |
2 files changed, 669 insertions, 110 deletions
diff --git a/Mac/Modules/cf/_CFmodule.c b/Mac/Modules/cf/_CFmodule.c index 250e7ac..1f44a8e 100644 --- a/Mac/Modules/cf/_CFmodule.c +++ b/Mac/Modules/cf/_CFmodule.c @@ -159,7 +159,7 @@ static void CFTypeRefObj_dealloc(CFTypeRefObject *self) { self->ob_freeit((CFTypeRef)self->ob_itself); } - PyObject_Free((PyObject *)self); + self->ob_type->tp_free((PyObject *)self); } static PyObject *CFTypeRefObj_CFGetTypeID(CFTypeRefObject *_self, PyObject *_args) @@ -375,14 +375,8 @@ static PyMethodDef CFTypeRefObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain CFTypeRefObj_chain = { CFTypeRefObj_methods, NULL }; +#define CFTypeRefObj_getsetlist NULL -static PyObject *CFTypeRefObj_getattr(CFTypeRefObject *self, char *name) -{ - return Py_FindMethodInChain(&CFTypeRefObj_chain, (PyObject *)self, name); -} - -#define CFTypeRefObj_setattr NULL static int CFTypeRefObj_compare(CFTypeRefObject *self, CFTypeRefObject *other) { @@ -404,6 +398,32 @@ static int CFTypeRefObj_hash(CFTypeRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } +static int CFTypeRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + CFTypeRef itself; + char *kw[] = {"itself", 0}; + + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + { + ((CFTypeRefObject *)self)->ob_itself = itself; + return 0; + } + return -1; +} + +#define CFTypeRefObj_tp_alloc PyType_GenericAlloc + +static PyObject *CFTypeRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((CFTypeRefObject *)self)->ob_itself = NULL; + ((CFTypeRefObject *)self)->ob_freeit = CFRelease; + return self; +} + +#define CFTypeRefObj_tp_free PyObject_Del + PyTypeObject CFTypeRef_Type = { PyObject_HEAD_INIT(NULL) @@ -414,14 +434,39 @@ PyTypeObject CFTypeRef_Type = { /* methods */ (destructor) CFTypeRefObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) CFTypeRefObj_getattr, /*tp_getattr*/ - (setattrfunc) CFTypeRefObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) CFTypeRefObj_compare, /*tp_compare*/ (reprfunc) CFTypeRefObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) CFTypeRefObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 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*/ + CFTypeRefObj_methods, /* tp_methods */ + 0, /*tp_members*/ + CFTypeRefObj_getsetlist, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + CFTypeRefObj_tp_init, /* tp_init */ + CFTypeRefObj_tp_alloc, /* tp_alloc */ + CFTypeRefObj_tp_new, /* tp_new */ + CFTypeRefObj_tp_free, /* tp_free */ }; /* ------------------- End object type CFTypeRef -------------------- */ @@ -449,6 +494,7 @@ PyObject *CFArrayRefObj_New(CFArrayRef itself) } it = PyObject_NEW(CFArrayRefObject, &CFArrayRef_Type); if (it == NULL) return NULL; + /* XXXX Should we tp_init or tp_new our basetype? */ it->ob_itself = itself; it->ob_freeit = CFRelease; return (PyObject *)it; @@ -474,7 +520,7 @@ static void CFArrayRefObj_dealloc(CFArrayRefObject *self) { self->ob_freeit((CFTypeRef)self->ob_itself); } - PyObject_Free((PyObject *)self); + self->ob_type->tp_base->tp_dealloc((PyObject *)self); } static PyObject *CFArrayRefObj_CFArrayCreateCopy(CFArrayRefObject *_self, PyObject *_args) @@ -531,14 +577,8 @@ static PyMethodDef CFArrayRefObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain CFArrayRefObj_chain = { CFArrayRefObj_methods, &CFTypeRefObj_chain }; - -static PyObject *CFArrayRefObj_getattr(CFArrayRefObject *self, char *name) -{ - return Py_FindMethodInChain(&CFArrayRefObj_chain, (PyObject *)self, name); -} +#define CFArrayRefObj_getsetlist NULL -#define CFArrayRefObj_setattr NULL static int CFArrayRefObj_compare(CFArrayRefObject *self, CFArrayRefObject *other) { @@ -560,6 +600,39 @@ static int CFArrayRefObj_hash(CFArrayRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } +static int CFArrayRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + CFArrayRef itself; + char *kw[] = {"itself", 0}; + + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFArrayRefObj_Convert, &itself)) + { + ((CFArrayRefObject *)self)->ob_itself = itself; + return 0; + } + + /* Any CFTypeRef descendent is allowed as initializer too */ + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + { + ((CFArrayRefObject *)self)->ob_itself = itself; + return 0; + } + return -1; +} + +#define CFArrayRefObj_tp_alloc PyType_GenericAlloc + +static PyObject *CFArrayRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((CFArrayRefObject *)self)->ob_itself = NULL; + ((CFArrayRefObject *)self)->ob_freeit = CFRelease; + return self; +} + +#define CFArrayRefObj_tp_free PyObject_Del + PyTypeObject CFArrayRef_Type = { PyObject_HEAD_INIT(NULL) @@ -570,14 +643,39 @@ PyTypeObject CFArrayRef_Type = { /* methods */ (destructor) CFArrayRefObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) CFArrayRefObj_getattr, /*tp_getattr*/ - (setattrfunc) CFArrayRefObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) CFArrayRefObj_compare, /*tp_compare*/ (reprfunc) CFArrayRefObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) CFArrayRefObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 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*/ + CFArrayRefObj_methods, /* tp_methods */ + 0, /*tp_members*/ + CFArrayRefObj_getsetlist, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + CFArrayRefObj_tp_init, /* tp_init */ + CFArrayRefObj_tp_alloc, /* tp_alloc */ + CFArrayRefObj_tp_new, /* tp_new */ + CFArrayRefObj_tp_free, /* tp_free */ }; /* ------------------- End object type CFArrayRef ------------------- */ @@ -605,6 +703,7 @@ PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef itself) } it = PyObject_NEW(CFMutableArrayRefObject, &CFMutableArrayRef_Type); if (it == NULL) return NULL; + /* XXXX Should we tp_init or tp_new our basetype? */ it->ob_itself = itself; it->ob_freeit = CFRelease; return (PyObject *)it; @@ -630,7 +729,7 @@ static void CFMutableArrayRefObj_dealloc(CFMutableArrayRefObject *self) { self->ob_freeit((CFTypeRef)self->ob_itself); } - PyObject_Free((PyObject *)self); + self->ob_type->tp_base->tp_dealloc((PyObject *)self); } static PyObject *CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRefObject *_self, PyObject *_args) @@ -716,14 +815,8 @@ static PyMethodDef CFMutableArrayRefObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain CFMutableArrayRefObj_chain = { CFMutableArrayRefObj_methods, &CFArrayRefObj_chain }; +#define CFMutableArrayRefObj_getsetlist NULL -static PyObject *CFMutableArrayRefObj_getattr(CFMutableArrayRefObject *self, char *name) -{ - return Py_FindMethodInChain(&CFMutableArrayRefObj_chain, (PyObject *)self, name); -} - -#define CFMutableArrayRefObj_setattr NULL static int CFMutableArrayRefObj_compare(CFMutableArrayRefObject *self, CFMutableArrayRefObject *other) { @@ -745,6 +838,39 @@ static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } +static int CFMutableArrayRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + CFMutableArrayRef itself; + char *kw[] = {"itself", 0}; + + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFMutableArrayRefObj_Convert, &itself)) + { + ((CFMutableArrayRefObject *)self)->ob_itself = itself; + return 0; + } + + /* Any CFTypeRef descendent is allowed as initializer too */ + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + { + ((CFMutableArrayRefObject *)self)->ob_itself = itself; + return 0; + } + return -1; +} + +#define CFMutableArrayRefObj_tp_alloc PyType_GenericAlloc + +static PyObject *CFMutableArrayRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((CFMutableArrayRefObject *)self)->ob_itself = NULL; + ((CFMutableArrayRefObject *)self)->ob_freeit = CFRelease; + return self; +} + +#define CFMutableArrayRefObj_tp_free PyObject_Del + PyTypeObject CFMutableArrayRef_Type = { PyObject_HEAD_INIT(NULL) @@ -755,14 +881,39 @@ PyTypeObject CFMutableArrayRef_Type = { /* methods */ (destructor) CFMutableArrayRefObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) CFMutableArrayRefObj_getattr, /*tp_getattr*/ - (setattrfunc) CFMutableArrayRefObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) CFMutableArrayRefObj_compare, /*tp_compare*/ (reprfunc) CFMutableArrayRefObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) CFMutableArrayRefObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 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*/ + CFMutableArrayRefObj_methods, /* tp_methods */ + 0, /*tp_members*/ + CFMutableArrayRefObj_getsetlist, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + CFMutableArrayRefObj_tp_init, /* tp_init */ + CFMutableArrayRefObj_tp_alloc, /* tp_alloc */ + CFMutableArrayRefObj_tp_new, /* tp_new */ + CFMutableArrayRefObj_tp_free, /* tp_free */ }; /* --------------- End object type CFMutableArrayRef ---------------- */ @@ -790,6 +941,7 @@ PyObject *CFDictionaryRefObj_New(CFDictionaryRef itself) } it = PyObject_NEW(CFDictionaryRefObject, &CFDictionaryRef_Type); if (it == NULL) return NULL; + /* XXXX Should we tp_init or tp_new our basetype? */ it->ob_itself = itself; it->ob_freeit = CFRelease; return (PyObject *)it; @@ -815,7 +967,7 @@ static void CFDictionaryRefObj_dealloc(CFDictionaryRefObject *self) { self->ob_freeit((CFTypeRef)self->ob_itself); } - PyObject_Free((PyObject *)self); + self->ob_type->tp_base->tp_dealloc((PyObject *)self); } static PyObject *CFDictionaryRefObj_CFDictionaryCreateCopy(CFDictionaryRefObject *_self, PyObject *_args) @@ -854,14 +1006,8 @@ static PyMethodDef CFDictionaryRefObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain CFDictionaryRefObj_chain = { CFDictionaryRefObj_methods, &CFTypeRefObj_chain }; +#define CFDictionaryRefObj_getsetlist NULL -static PyObject *CFDictionaryRefObj_getattr(CFDictionaryRefObject *self, char *name) -{ - return Py_FindMethodInChain(&CFDictionaryRefObj_chain, (PyObject *)self, name); -} - -#define CFDictionaryRefObj_setattr NULL static int CFDictionaryRefObj_compare(CFDictionaryRefObject *self, CFDictionaryRefObject *other) { @@ -883,6 +1029,39 @@ static int CFDictionaryRefObj_hash(CFDictionaryRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } +static int CFDictionaryRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + CFDictionaryRef itself; + char *kw[] = {"itself", 0}; + + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFDictionaryRefObj_Convert, &itself)) + { + ((CFDictionaryRefObject *)self)->ob_itself = itself; + return 0; + } + + /* Any CFTypeRef descendent is allowed as initializer too */ + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + { + ((CFDictionaryRefObject *)self)->ob_itself = itself; + return 0; + } + return -1; +} + +#define CFDictionaryRefObj_tp_alloc PyType_GenericAlloc + +static PyObject *CFDictionaryRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((CFDictionaryRefObject *)self)->ob_itself = NULL; + ((CFDictionaryRefObject *)self)->ob_freeit = CFRelease; + return self; +} + +#define CFDictionaryRefObj_tp_free PyObject_Del + PyTypeObject CFDictionaryRef_Type = { PyObject_HEAD_INIT(NULL) @@ -893,14 +1072,39 @@ PyTypeObject CFDictionaryRef_Type = { /* methods */ (destructor) CFDictionaryRefObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) CFDictionaryRefObj_getattr, /*tp_getattr*/ - (setattrfunc) CFDictionaryRefObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) CFDictionaryRefObj_compare, /*tp_compare*/ (reprfunc) CFDictionaryRefObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) CFDictionaryRefObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 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*/ + CFDictionaryRefObj_methods, /* tp_methods */ + 0, /*tp_members*/ + CFDictionaryRefObj_getsetlist, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + CFDictionaryRefObj_tp_init, /* tp_init */ + CFDictionaryRefObj_tp_alloc, /* tp_alloc */ + CFDictionaryRefObj_tp_new, /* tp_new */ + CFDictionaryRefObj_tp_free, /* tp_free */ }; /* ---------------- End object type CFDictionaryRef ----------------- */ @@ -928,6 +1132,7 @@ PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef itself) } it = PyObject_NEW(CFMutableDictionaryRefObject, &CFMutableDictionaryRef_Type); if (it == NULL) return NULL; + /* XXXX Should we tp_init or tp_new our basetype? */ it->ob_itself = itself; it->ob_freeit = CFRelease; return (PyObject *)it; @@ -953,7 +1158,7 @@ static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject *self { self->ob_freeit((CFTypeRef)self->ob_itself); } - PyObject_Free((PyObject *)self); + self->ob_type->tp_base->tp_dealloc((PyObject *)self); } static PyObject *CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject *_self, PyObject *_args) @@ -976,14 +1181,8 @@ static PyMethodDef CFMutableDictionaryRefObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain CFMutableDictionaryRefObj_chain = { CFMutableDictionaryRefObj_methods, &CFDictionaryRefObj_chain }; - -static PyObject *CFMutableDictionaryRefObj_getattr(CFMutableDictionaryRefObject *self, char *name) -{ - return Py_FindMethodInChain(&CFMutableDictionaryRefObj_chain, (PyObject *)self, name); -} +#define CFMutableDictionaryRefObj_getsetlist NULL -#define CFMutableDictionaryRefObj_setattr NULL static int CFMutableDictionaryRefObj_compare(CFMutableDictionaryRefObject *self, CFMutableDictionaryRefObject *other) { @@ -1005,6 +1204,39 @@ static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } +static int CFMutableDictionaryRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + CFMutableDictionaryRef itself; + char *kw[] = {"itself", 0}; + + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFMutableDictionaryRefObj_Convert, &itself)) + { + ((CFMutableDictionaryRefObject *)self)->ob_itself = itself; + return 0; + } + + /* Any CFTypeRef descendent is allowed as initializer too */ + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + { + ((CFMutableDictionaryRefObject *)self)->ob_itself = itself; + return 0; + } + return -1; +} + +#define CFMutableDictionaryRefObj_tp_alloc PyType_GenericAlloc + +static PyObject *CFMutableDictionaryRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((CFMutableDictionaryRefObject *)self)->ob_itself = NULL; + ((CFMutableDictionaryRefObject *)self)->ob_freeit = CFRelease; + return self; +} + +#define CFMutableDictionaryRefObj_tp_free PyObject_Del + PyTypeObject CFMutableDictionaryRef_Type = { PyObject_HEAD_INIT(NULL) @@ -1015,14 +1247,39 @@ PyTypeObject CFMutableDictionaryRef_Type = { /* methods */ (destructor) CFMutableDictionaryRefObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) CFMutableDictionaryRefObj_getattr, /*tp_getattr*/ - (setattrfunc) CFMutableDictionaryRefObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) CFMutableDictionaryRefObj_compare, /*tp_compare*/ (reprfunc) CFMutableDictionaryRefObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) CFMutableDictionaryRefObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 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*/ + CFMutableDictionaryRefObj_methods, /* tp_methods */ + 0, /*tp_members*/ + CFMutableDictionaryRefObj_getsetlist, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + CFMutableDictionaryRefObj_tp_init, /* tp_init */ + CFMutableDictionaryRefObj_tp_alloc, /* tp_alloc */ + CFMutableDictionaryRefObj_tp_new, /* tp_new */ + CFMutableDictionaryRefObj_tp_free, /* tp_free */ }; /* ------------- End object type CFMutableDictionaryRef ------------- */ @@ -1050,6 +1307,7 @@ PyObject *CFDataRefObj_New(CFDataRef itself) } it = PyObject_NEW(CFDataRefObject, &CFDataRef_Type); if (it == NULL) return NULL; + /* XXXX Should we tp_init or tp_new our basetype? */ it->ob_itself = itself; it->ob_freeit = CFRelease; return (PyObject *)it; @@ -1081,7 +1339,7 @@ static void CFDataRefObj_dealloc(CFDataRefObject *self) { self->ob_freeit((CFTypeRef)self->ob_itself); } - PyObject_Free((PyObject *)self); + self->ob_type->tp_base->tp_dealloc((PyObject *)self); } static PyObject *CFDataRefObj_CFDataCreateCopy(CFDataRefObject *_self, PyObject *_args) @@ -1152,14 +1410,8 @@ static PyMethodDef CFDataRefObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain CFDataRefObj_chain = { CFDataRefObj_methods, &CFTypeRefObj_chain }; - -static PyObject *CFDataRefObj_getattr(CFDataRefObject *self, char *name) -{ - return Py_FindMethodInChain(&CFDataRefObj_chain, (PyObject *)self, name); -} +#define CFDataRefObj_getsetlist NULL -#define CFDataRefObj_setattr NULL static int CFDataRefObj_compare(CFDataRefObject *self, CFDataRefObject *other) { @@ -1181,6 +1433,39 @@ static int CFDataRefObj_hash(CFDataRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } +static int CFDataRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + CFDataRef itself; + char *kw[] = {"itself", 0}; + + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFDataRefObj_Convert, &itself)) + { + ((CFDataRefObject *)self)->ob_itself = itself; + return 0; + } + + /* Any CFTypeRef descendent is allowed as initializer too */ + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + { + ((CFDataRefObject *)self)->ob_itself = itself; + return 0; + } + return -1; +} + +#define CFDataRefObj_tp_alloc PyType_GenericAlloc + +static PyObject *CFDataRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((CFDataRefObject *)self)->ob_itself = NULL; + ((CFDataRefObject *)self)->ob_freeit = CFRelease; + return self; +} + +#define CFDataRefObj_tp_free PyObject_Del + PyTypeObject CFDataRef_Type = { PyObject_HEAD_INIT(NULL) @@ -1191,14 +1476,39 @@ PyTypeObject CFDataRef_Type = { /* methods */ (destructor) CFDataRefObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) CFDataRefObj_getattr, /*tp_getattr*/ - (setattrfunc) CFDataRefObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) CFDataRefObj_compare, /*tp_compare*/ (reprfunc) CFDataRefObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) CFDataRefObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 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*/ + CFDataRefObj_methods, /* tp_methods */ + 0, /*tp_members*/ + CFDataRefObj_getsetlist, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + CFDataRefObj_tp_init, /* tp_init */ + CFDataRefObj_tp_alloc, /* tp_alloc */ + CFDataRefObj_tp_new, /* tp_new */ + CFDataRefObj_tp_free, /* tp_free */ }; /* ------------------- End object type CFDataRef -------------------- */ @@ -1226,6 +1536,7 @@ PyObject *CFMutableDataRefObj_New(CFMutableDataRef itself) } it = PyObject_NEW(CFMutableDataRefObject, &CFMutableDataRef_Type); if (it == NULL) return NULL; + /* XXXX Should we tp_init or tp_new our basetype? */ it->ob_itself = itself; it->ob_freeit = CFRelease; return (PyObject *)it; @@ -1251,7 +1562,7 @@ static void CFMutableDataRefObj_dealloc(CFMutableDataRefObject *self) { self->ob_freeit((CFTypeRef)self->ob_itself); } - PyObject_Free((PyObject *)self); + self->ob_type->tp_base->tp_dealloc((PyObject *)self); } static PyObject *CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject *_self, PyObject *_args) @@ -1362,14 +1673,8 @@ static PyMethodDef CFMutableDataRefObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain CFMutableDataRefObj_chain = { CFMutableDataRefObj_methods, &CFDataRefObj_chain }; - -static PyObject *CFMutableDataRefObj_getattr(CFMutableDataRefObject *self, char *name) -{ - return Py_FindMethodInChain(&CFMutableDataRefObj_chain, (PyObject *)self, name); -} +#define CFMutableDataRefObj_getsetlist NULL -#define CFMutableDataRefObj_setattr NULL static int CFMutableDataRefObj_compare(CFMutableDataRefObject *self, CFMutableDataRefObject *other) { @@ -1391,6 +1696,39 @@ static int CFMutableDataRefObj_hash(CFMutableDataRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } +static int CFMutableDataRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + CFMutableDataRef itself; + char *kw[] = {"itself", 0}; + + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFMutableDataRefObj_Convert, &itself)) + { + ((CFMutableDataRefObject *)self)->ob_itself = itself; + return 0; + } + + /* Any CFTypeRef descendent is allowed as initializer too */ + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + { + ((CFMutableDataRefObject *)self)->ob_itself = itself; + return 0; + } + return -1; +} + +#define CFMutableDataRefObj_tp_alloc PyType_GenericAlloc + +static PyObject *CFMutableDataRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((CFMutableDataRefObject *)self)->ob_itself = NULL; + ((CFMutableDataRefObject *)self)->ob_freeit = CFRelease; + return self; +} + +#define CFMutableDataRefObj_tp_free PyObject_Del + PyTypeObject CFMutableDataRef_Type = { PyObject_HEAD_INIT(NULL) @@ -1401,14 +1739,39 @@ PyTypeObject CFMutableDataRef_Type = { /* methods */ (destructor) CFMutableDataRefObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) CFMutableDataRefObj_getattr, /*tp_getattr*/ - (setattrfunc) CFMutableDataRefObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) CFMutableDataRefObj_compare, /*tp_compare*/ (reprfunc) CFMutableDataRefObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) CFMutableDataRefObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 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*/ + CFMutableDataRefObj_methods, /* tp_methods */ + 0, /*tp_members*/ + CFMutableDataRefObj_getsetlist, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + CFMutableDataRefObj_tp_init, /* tp_init */ + CFMutableDataRefObj_tp_alloc, /* tp_alloc */ + CFMutableDataRefObj_tp_new, /* tp_new */ + CFMutableDataRefObj_tp_free, /* tp_free */ }; /* ---------------- End object type CFMutableDataRef ---------------- */ @@ -1436,6 +1799,7 @@ PyObject *CFStringRefObj_New(CFStringRef itself) } it = PyObject_NEW(CFStringRefObject, &CFStringRef_Type); if (it == NULL) return NULL; + /* XXXX Should we tp_init or tp_new our basetype? */ it->ob_itself = itself; it->ob_freeit = CFRelease; return (PyObject *)it; @@ -1476,7 +1840,7 @@ static void CFStringRefObj_dealloc(CFStringRefObject *self) { self->ob_freeit((CFTypeRef)self->ob_itself); } - PyObject_Free((PyObject *)self); + self->ob_type->tp_base->tp_dealloc((PyObject *)self); } static PyObject *CFStringRefObj_CFStringCreateWithSubstring(CFStringRefObject *_self, PyObject *_args) @@ -2049,14 +2413,8 @@ static PyMethodDef CFStringRefObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain CFStringRefObj_chain = { CFStringRefObj_methods, &CFTypeRefObj_chain }; +#define CFStringRefObj_getsetlist NULL -static PyObject *CFStringRefObj_getattr(CFStringRefObject *self, char *name) -{ - return Py_FindMethodInChain(&CFStringRefObj_chain, (PyObject *)self, name); -} - -#define CFStringRefObj_setattr NULL static int CFStringRefObj_compare(CFStringRefObject *self, CFStringRefObject *other) { @@ -2078,6 +2436,39 @@ static int CFStringRefObj_hash(CFStringRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } +static int CFStringRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + CFStringRef itself; + char *kw[] = {"itself", 0}; + + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFStringRefObj_Convert, &itself)) + { + ((CFStringRefObject *)self)->ob_itself = itself; + return 0; + } + + /* Any CFTypeRef descendent is allowed as initializer too */ + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + { + ((CFStringRefObject *)self)->ob_itself = itself; + return 0; + } + return -1; +} + +#define CFStringRefObj_tp_alloc PyType_GenericAlloc + +static PyObject *CFStringRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((CFStringRefObject *)self)->ob_itself = NULL; + ((CFStringRefObject *)self)->ob_freeit = CFRelease; + return self; +} + +#define CFStringRefObj_tp_free PyObject_Del + PyTypeObject CFStringRef_Type = { PyObject_HEAD_INIT(NULL) @@ -2088,14 +2479,39 @@ PyTypeObject CFStringRef_Type = { /* methods */ (destructor) CFStringRefObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) CFStringRefObj_getattr, /*tp_getattr*/ - (setattrfunc) CFStringRefObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) CFStringRefObj_compare, /*tp_compare*/ (reprfunc) CFStringRefObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) CFStringRefObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 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*/ + CFStringRefObj_methods, /* tp_methods */ + 0, /*tp_members*/ + CFStringRefObj_getsetlist, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + CFStringRefObj_tp_init, /* tp_init */ + CFStringRefObj_tp_alloc, /* tp_alloc */ + CFStringRefObj_tp_new, /* tp_new */ + CFStringRefObj_tp_free, /* tp_free */ }; /* ------------------ End object type CFStringRef ------------------- */ @@ -2123,6 +2539,7 @@ PyObject *CFMutableStringRefObj_New(CFMutableStringRef itself) } it = PyObject_NEW(CFMutableStringRefObject, &CFMutableStringRef_Type); if (it == NULL) return NULL; + /* XXXX Should we tp_init or tp_new our basetype? */ it->ob_itself = itself; it->ob_freeit = CFRelease; return (PyObject *)it; @@ -2148,7 +2565,7 @@ static void CFMutableStringRefObj_dealloc(CFMutableStringRefObject *self) { self->ob_freeit((CFTypeRef)self->ob_itself); } - PyObject_Free((PyObject *)self); + self->ob_type->tp_base->tp_dealloc((PyObject *)self); } static PyObject *CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject *_self, PyObject *_args) @@ -2382,14 +2799,8 @@ static PyMethodDef CFMutableStringRefObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain CFMutableStringRefObj_chain = { CFMutableStringRefObj_methods, &CFStringRefObj_chain }; - -static PyObject *CFMutableStringRefObj_getattr(CFMutableStringRefObject *self, char *name) -{ - return Py_FindMethodInChain(&CFMutableStringRefObj_chain, (PyObject *)self, name); -} +#define CFMutableStringRefObj_getsetlist NULL -#define CFMutableStringRefObj_setattr NULL static int CFMutableStringRefObj_compare(CFMutableStringRefObject *self, CFMutableStringRefObject *other) { @@ -2411,6 +2822,39 @@ static int CFMutableStringRefObj_hash(CFMutableStringRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } +static int CFMutableStringRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + CFMutableStringRef itself; + char *kw[] = {"itself", 0}; + + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFMutableStringRefObj_Convert, &itself)) + { + ((CFMutableStringRefObject *)self)->ob_itself = itself; + return 0; + } + + /* Any CFTypeRef descendent is allowed as initializer too */ + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + { + ((CFMutableStringRefObject *)self)->ob_itself = itself; + return 0; + } + return -1; +} + +#define CFMutableStringRefObj_tp_alloc PyType_GenericAlloc + +static PyObject *CFMutableStringRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((CFMutableStringRefObject *)self)->ob_itself = NULL; + ((CFMutableStringRefObject *)self)->ob_freeit = CFRelease; + return self; +} + +#define CFMutableStringRefObj_tp_free PyObject_Del + PyTypeObject CFMutableStringRef_Type = { PyObject_HEAD_INIT(NULL) @@ -2421,14 +2865,39 @@ PyTypeObject CFMutableStringRef_Type = { /* methods */ (destructor) CFMutableStringRefObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) CFMutableStringRefObj_getattr, /*tp_getattr*/ - (setattrfunc) CFMutableStringRefObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) CFMutableStringRefObj_compare, /*tp_compare*/ (reprfunc) CFMutableStringRefObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) CFMutableStringRefObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 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*/ + CFMutableStringRefObj_methods, /* tp_methods */ + 0, /*tp_members*/ + CFMutableStringRefObj_getsetlist, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + CFMutableStringRefObj_tp_init, /* tp_init */ + CFMutableStringRefObj_tp_alloc, /* tp_alloc */ + CFMutableStringRefObj_tp_new, /* tp_new */ + CFMutableStringRefObj_tp_free, /* tp_free */ }; /* --------------- End object type CFMutableStringRef --------------- */ @@ -2456,6 +2925,7 @@ PyObject *CFURLRefObj_New(CFURLRef itself) } it = PyObject_NEW(CFURLRefObject, &CFURLRef_Type); if (it == NULL) return NULL; + /* XXXX Should we tp_init or tp_new our basetype? */ it->ob_itself = itself; it->ob_freeit = CFRelease; return (PyObject *)it; @@ -2481,7 +2951,7 @@ static void CFURLRefObj_dealloc(CFURLRefObject *self) { self->ob_freeit((CFTypeRef)self->ob_itself); } - PyObject_Free((PyObject *)self); + self->ob_type->tp_base->tp_dealloc((PyObject *)self); } static PyObject *CFURLRefObj_CFURLCreateData(CFURLRefObject *_self, PyObject *_args) @@ -2979,14 +3449,8 @@ static PyMethodDef CFURLRefObj_methods[] = { {NULL, NULL, 0} }; -PyMethodChain CFURLRefObj_chain = { CFURLRefObj_methods, &CFTypeRefObj_chain }; - -static PyObject *CFURLRefObj_getattr(CFURLRefObject *self, char *name) -{ - return Py_FindMethodInChain(&CFURLRefObj_chain, (PyObject *)self, name); -} +#define CFURLRefObj_getsetlist NULL -#define CFURLRefObj_setattr NULL static int CFURLRefObj_compare(CFURLRefObject *self, CFURLRefObject *other) { @@ -3008,6 +3472,39 @@ static int CFURLRefObj_hash(CFURLRefObject *self) /* XXXX Or should we use CFHash?? */ return (int)self->ob_itself; } +static int CFURLRefObj_tp_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + CFURLRef itself; + char *kw[] = {"itself", 0}; + + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFURLRefObj_Convert, &itself)) + { + ((CFURLRefObject *)self)->ob_itself = itself; + return 0; + } + + /* Any CFTypeRef descendent is allowed as initializer too */ + if (PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) + { + ((CFURLRefObject *)self)->ob_itself = itself; + return 0; + } + return -1; +} + +#define CFURLRefObj_tp_alloc PyType_GenericAlloc + +static PyObject *CFURLRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((CFURLRefObject *)self)->ob_itself = NULL; + ((CFURLRefObject *)self)->ob_freeit = CFRelease; + return self; +} + +#define CFURLRefObj_tp_free PyObject_Del + PyTypeObject CFURLRef_Type = { PyObject_HEAD_INIT(NULL) @@ -3018,14 +3515,39 @@ PyTypeObject CFURLRef_Type = { /* methods */ (destructor) CFURLRefObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc) CFURLRefObj_getattr, /*tp_getattr*/ - (setattrfunc) CFURLRefObj_setattr, /*tp_setattr*/ + (getattrfunc)0, /*tp_getattr*/ + (setattrfunc)0, /*tp_setattr*/ (cmpfunc) CFURLRefObj_compare, /*tp_compare*/ (reprfunc) CFURLRefObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) CFURLRefObj_hash, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + PyObject_GenericGetAttr, /*tp_getattro*/ + PyObject_GenericSetAttr, /*tp_setattro */ + 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*/ + CFURLRefObj_methods, /* tp_methods */ + 0, /*tp_members*/ + CFURLRefObj_getsetlist, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + CFURLRefObj_tp_init, /* tp_init */ + CFURLRefObj_tp_alloc, /* tp_alloc */ + CFURLRefObj_tp_new, /* tp_new */ + CFURLRefObj_tp_free, /* tp_free */ }; /* -------------------- End object type CFURLRef -------------------- */ @@ -4365,6 +4887,7 @@ void init_CF(void) Py_INCREF(&CFTypeRef_Type); PyModule_AddObject(m, "CFTypeRefType", (PyObject *)&CFTypeRef_Type); CFArrayRef_Type.ob_type = &PyType_Type; + CFArrayRef_Type.tp_base = &CFTypeRef_Type; if (PyType_Ready(&CFArrayRef_Type) < 0) return; Py_INCREF(&CFArrayRef_Type); PyModule_AddObject(m, "CFArrayRef", (PyObject *)&CFArrayRef_Type); @@ -4372,6 +4895,7 @@ void init_CF(void) Py_INCREF(&CFArrayRef_Type); PyModule_AddObject(m, "CFArrayRefType", (PyObject *)&CFArrayRef_Type); CFMutableArrayRef_Type.ob_type = &PyType_Type; + CFMutableArrayRef_Type.tp_base = &CFArrayRef_Type; if (PyType_Ready(&CFMutableArrayRef_Type) < 0) return; Py_INCREF(&CFMutableArrayRef_Type); PyModule_AddObject(m, "CFMutableArrayRef", (PyObject *)&CFMutableArrayRef_Type); @@ -4379,6 +4903,7 @@ void init_CF(void) Py_INCREF(&CFMutableArrayRef_Type); PyModule_AddObject(m, "CFMutableArrayRefType", (PyObject *)&CFMutableArrayRef_Type); CFDictionaryRef_Type.ob_type = &PyType_Type; + CFDictionaryRef_Type.tp_base = &CFTypeRef_Type; if (PyType_Ready(&CFDictionaryRef_Type) < 0) return; Py_INCREF(&CFDictionaryRef_Type); PyModule_AddObject(m, "CFDictionaryRef", (PyObject *)&CFDictionaryRef_Type); @@ -4386,6 +4911,7 @@ void init_CF(void) Py_INCREF(&CFDictionaryRef_Type); PyModule_AddObject(m, "CFDictionaryRefType", (PyObject *)&CFDictionaryRef_Type); CFMutableDictionaryRef_Type.ob_type = &PyType_Type; + CFMutableDictionaryRef_Type.tp_base = &CFDictionaryRef_Type; if (PyType_Ready(&CFMutableDictionaryRef_Type) < 0) return; Py_INCREF(&CFMutableDictionaryRef_Type); PyModule_AddObject(m, "CFMutableDictionaryRef", (PyObject *)&CFMutableDictionaryRef_Type); @@ -4393,6 +4919,7 @@ void init_CF(void) Py_INCREF(&CFMutableDictionaryRef_Type); PyModule_AddObject(m, "CFMutableDictionaryRefType", (PyObject *)&CFMutableDictionaryRef_Type); CFDataRef_Type.ob_type = &PyType_Type; + CFDataRef_Type.tp_base = &CFTypeRef_Type; if (PyType_Ready(&CFDataRef_Type) < 0) return; Py_INCREF(&CFDataRef_Type); PyModule_AddObject(m, "CFDataRef", (PyObject *)&CFDataRef_Type); @@ -4400,6 +4927,7 @@ void init_CF(void) Py_INCREF(&CFDataRef_Type); PyModule_AddObject(m, "CFDataRefType", (PyObject *)&CFDataRef_Type); CFMutableDataRef_Type.ob_type = &PyType_Type; + CFMutableDataRef_Type.tp_base = &CFDataRef_Type; if (PyType_Ready(&CFMutableDataRef_Type) < 0) return; Py_INCREF(&CFMutableDataRef_Type); PyModule_AddObject(m, "CFMutableDataRef", (PyObject *)&CFMutableDataRef_Type); @@ -4407,6 +4935,7 @@ void init_CF(void) Py_INCREF(&CFMutableDataRef_Type); PyModule_AddObject(m, "CFMutableDataRefType", (PyObject *)&CFMutableDataRef_Type); CFStringRef_Type.ob_type = &PyType_Type; + CFStringRef_Type.tp_base = &CFTypeRef_Type; if (PyType_Ready(&CFStringRef_Type) < 0) return; Py_INCREF(&CFStringRef_Type); PyModule_AddObject(m, "CFStringRef", (PyObject *)&CFStringRef_Type); @@ -4414,6 +4943,7 @@ void init_CF(void) Py_INCREF(&CFStringRef_Type); PyModule_AddObject(m, "CFStringRefType", (PyObject *)&CFStringRef_Type); CFMutableStringRef_Type.ob_type = &PyType_Type; + CFMutableStringRef_Type.tp_base = &CFStringRef_Type; if (PyType_Ready(&CFMutableStringRef_Type) < 0) return; Py_INCREF(&CFMutableStringRef_Type); PyModule_AddObject(m, "CFMutableStringRef", (PyObject *)&CFMutableStringRef_Type); @@ -4421,6 +4951,7 @@ void init_CF(void) Py_INCREF(&CFMutableStringRef_Type); PyModule_AddObject(m, "CFMutableStringRefType", (PyObject *)&CFMutableStringRef_Type); CFURLRef_Type.ob_type = &PyType_Type; + CFURLRef_Type.tp_base = &CFTypeRef_Type; if (PyType_Ready(&CFURLRef_Type) < 0) return; Py_INCREF(&CFURLRef_Type); PyModule_AddObject(m, "CFURLRef", (PyObject *)&CFURLRef_Type); diff --git a/Mac/Modules/cf/cfsupport.py b/Mac/Modules/cf/cfsupport.py index e68ae03..c244c72 100644 --- a/Mac/Modules/cf/cfsupport.py +++ b/Mac/Modules/cf/cfsupport.py @@ -250,7 +250,7 @@ OptionalCFURLRef = OpaqueByValueType("CFURLRef", "OptionalCFURLRefObj") # Our (opaque) objects -class MyGlobalObjectDefinition(GlobalObjectDefinition): +class MyGlobalObjectDefinition(PEP253Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output('if (itself == NULL)') OutLbrace() @@ -302,11 +302,39 @@ class MyGlobalObjectDefinition(GlobalObjectDefinition): Output("return PyString_FromString(buf);") OutRbrace() + def output_tp_newBody(self): + Output("PyObject *self;") + Output + Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;") + Output("((%s *)self)->ob_itself = NULL;", self.objecttype) + Output("((%s *)self)->ob_freeit = CFRelease;", self.objecttype) + Output("return self;") + + def output_tp_initBody(self): + Output("%s itself;", self.itselftype) + Output("char *kw[] = {\"itself\", 0};") + Output() + Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, %s_Convert, &itself))", + self.prefix) + OutLbrace() + Output("((%s *)self)->ob_itself = itself;", self.objecttype) + Output("return 0;") + OutRbrace() + if self.prefix != 'CFTypeRefObj': + Output() + Output("/* Any CFTypeRef descendent is allowed as initializer too */") + Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, CFTypeRefObj_Convert, &itself))") + OutLbrace() + Output("((%s *)self)->ob_itself = itself;", self.objecttype) + Output("return 0;") + OutRbrace() + Output("return -1;") + class CFTypeRefObjectDefinition(MyGlobalObjectDefinition): pass class CFArrayRefObjectDefinition(MyGlobalObjectDefinition): - basechain = "&CFTypeRefObj_chain" + basetype = "CFTypeRef_Type" def outputRepr(self): Output() @@ -318,7 +346,7 @@ class CFArrayRefObjectDefinition(MyGlobalObjectDefinition): OutRbrace() class CFMutableArrayRefObjectDefinition(MyGlobalObjectDefinition): - basechain = "&CFArrayRefObj_chain" + basetype = "CFArrayRef_Type" def outputRepr(self): Output() @@ -330,7 +358,7 @@ class CFMutableArrayRefObjectDefinition(MyGlobalObjectDefinition): OutRbrace() class CFDictionaryRefObjectDefinition(MyGlobalObjectDefinition): - basechain = "&CFTypeRefObj_chain" + basetype = "CFTypeRef_Type" def outputRepr(self): Output() @@ -342,7 +370,7 @@ class CFDictionaryRefObjectDefinition(MyGlobalObjectDefinition): OutRbrace() class CFMutableDictionaryRefObjectDefinition(MyGlobalObjectDefinition): - basechain = "&CFDictionaryRefObj_chain" + basetype = "CFDictionaryRef_Type" def outputRepr(self): Output() @@ -354,7 +382,7 @@ class CFMutableDictionaryRefObjectDefinition(MyGlobalObjectDefinition): OutRbrace() class CFDataRefObjectDefinition(MyGlobalObjectDefinition): - basechain = "&CFTypeRefObj_chain" + basetype = "CFTypeRef_Type" def outputCheckConvertArg(self): Out(""" @@ -378,7 +406,7 @@ class CFDataRefObjectDefinition(MyGlobalObjectDefinition): OutRbrace() class CFMutableDataRefObjectDefinition(MyGlobalObjectDefinition): - basechain = "&CFDataRefObj_chain" + basetype = "CFDataRef_Type" def outputRepr(self): Output() @@ -390,7 +418,7 @@ class CFMutableDataRefObjectDefinition(MyGlobalObjectDefinition): OutRbrace() class CFStringRefObjectDefinition(MyGlobalObjectDefinition): - basechain = "&CFTypeRefObj_chain" + basetype = "CFTypeRef_Type" def outputCheckConvertArg(self): Out(""" @@ -423,7 +451,7 @@ class CFStringRefObjectDefinition(MyGlobalObjectDefinition): OutRbrace() class CFMutableStringRefObjectDefinition(CFStringRefObjectDefinition): - basechain = "&CFStringRefObj_chain" + basetype = "CFStringRef_Type" def outputCheckConvertArg(self): # Mutable, don't allow Python strings @@ -439,7 +467,7 @@ class CFMutableStringRefObjectDefinition(CFStringRefObjectDefinition): OutRbrace() class CFURLRefObjectDefinition(MyGlobalObjectDefinition): - basechain = "&CFTypeRefObj_chain" + basetype = "CFTypeRef_Type" def outputRepr(self): Output() |