PageRenderTime 326ms CodeModel.GetById 121ms app.highlight 144ms RepoModel.GetById 37ms app.codeStats 2ms

/Mac/Modules/cf/_CFmodule.c

http://unladen-swallow.googlecode.com/
C | 4996 lines | 4442 code | 456 blank | 98 comment | 373 complexity | 0a8f460a90537f888b4ce7c8d25b1b2c MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1
   2/* =========================== Module _CF =========================== */
   3
   4#include "Python.h"
   5
   6
   7
   8#include "pymactoolbox.h"
   9
  10/* Macro to test whether a weak-loaded CFM function exists */
  11#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL )  {\
  12        PyErr_SetString(PyExc_NotImplementedError, \
  13        "Not available in this shared library/OS version"); \
  14        return NULL; \
  15    }} while(0)
  16
  17
  18#include <CoreServices/CoreServices.h>
  19
  20#include "pycfbridge.h"
  21
  22#ifdef USE_TOOLBOX_OBJECT_GLUE
  23extern PyObject *_CFObj_New(CFTypeRef);
  24extern int _CFObj_Convert(PyObject *, CFTypeRef *);
  25#define CFObj_New _CFObj_New
  26#define CFObj_Convert _CFObj_Convert
  27
  28extern PyObject *_CFTypeRefObj_New(CFTypeRef);
  29extern int _CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
  30#define CFTypeRefObj_New _CFTypeRefObj_New
  31#define CFTypeRefObj_Convert _CFTypeRefObj_Convert
  32
  33extern PyObject *_CFStringRefObj_New(CFStringRef);
  34extern int _CFStringRefObj_Convert(PyObject *, CFStringRef *);
  35#define CFStringRefObj_New _CFStringRefObj_New
  36#define CFStringRefObj_Convert _CFStringRefObj_Convert
  37
  38extern PyObject *_CFMutableStringRefObj_New(CFMutableStringRef);
  39extern int _CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *);
  40#define CFMutableStringRefObj_New _CFMutableStringRefObj_New
  41#define CFMutableStringRefObj_Convert _CFMutableStringRefObj_Convert
  42
  43extern PyObject *_CFArrayRefObj_New(CFArrayRef);
  44extern int _CFArrayRefObj_Convert(PyObject *, CFArrayRef *);
  45#define CFArrayRefObj_New _CFArrayRefObj_New
  46#define CFArrayRefObj_Convert _CFArrayRefObj_Convert
  47
  48extern PyObject *_CFMutableArrayRefObj_New(CFMutableArrayRef);
  49extern int _CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *);
  50#define CFMutableArrayRefObj_New _CFMutableArrayRefObj_New
  51#define CFMutableArrayRefObj_Convert _CFMutableArrayRefObj_Convert
  52
  53extern PyObject *_CFDataRefObj_New(CFDataRef);
  54extern int _CFDataRefObj_Convert(PyObject *, CFDataRef *);
  55#define CFDataRefObj_New _CFDataRefObj_New
  56#define CFDataRefObj_Convert _CFDataRefObj_Convert
  57
  58extern PyObject *_CFMutableDataRefObj_New(CFMutableDataRef);
  59extern int _CFMutableDataRefObj_Convert(PyObject *, CFMutableDataRef *);
  60#define CFMutableDataRefObj_New _CFMutableDataRefObj_New
  61#define CFMutableDataRefObj_Convert _CFMutableDataRefObj_Convert
  62
  63extern PyObject *_CFDictionaryRefObj_New(CFDictionaryRef);
  64extern int _CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *);
  65#define CFDictionaryRefObj_New _CFDictionaryRefObj_New
  66#define CFDictionaryRefObj_Convert _CFDictionaryRefObj_Convert
  67
  68extern PyObject *_CFMutableDictionaryRefObj_New(CFMutableDictionaryRef);
  69extern int _CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *);
  70#define CFMutableDictionaryRefObj_New _CFMutableDictionaryRefObj_New
  71#define CFMutableDictionaryRefObj_Convert _CFMutableDictionaryRefObj_Convert
  72
  73extern PyObject *_CFURLRefObj_New(CFURLRef);
  74extern int _CFURLRefObj_Convert(PyObject *, CFURLRef *);
  75extern int _OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *);
  76#define CFURLRefObj_New _CFURLRefObj_New
  77#define CFURLRefObj_Convert _CFURLRefObj_Convert
  78#define OptionalCFURLRefObj_Convert _OptionalCFURLRefObj_Convert
  79#endif
  80
  81/*
  82** Parse/generate CFRange records
  83*/
  84PyObject *CFRange_New(CFRange *itself)
  85{
  86
  87        return Py_BuildValue("ll", (long)itself->location, (long)itself->length);
  88}
  89
  90int
  91CFRange_Convert(PyObject *v, CFRange *p_itself)
  92{
  93        long location, length;
  94
  95        if( !PyArg_ParseTuple(v, "ll", &location, &length) )
  96                return 0;
  97        p_itself->location = (CFIndex)location;
  98        p_itself->length = (CFIndex)length;
  99        return 1;
 100}
 101
 102/* Optional CFURL argument or None (passed as NULL) */
 103int
 104OptionalCFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself)
 105{
 106    if ( v == Py_None ) {
 107        p_itself = NULL;
 108        return 1;
 109    }
 110    return CFURLRefObj_Convert(v, p_itself);
 111}
 112
 113static PyObject *CF_Error;
 114
 115/* --------------------- Object type CFTypeRef ---------------------- */
 116
 117PyTypeObject CFTypeRef_Type;
 118
 119#define CFTypeRefObj_Check(x) ((x)->ob_type == &CFTypeRef_Type || PyObject_TypeCheck((x), &CFTypeRef_Type))
 120
 121typedef struct CFTypeRefObject {
 122	PyObject_HEAD
 123	CFTypeRef ob_itself;
 124	void (*ob_freeit)(CFTypeRef ptr);
 125} CFTypeRefObject;
 126
 127PyObject *CFTypeRefObj_New(CFTypeRef itself)
 128{
 129	CFTypeRefObject *it;
 130	if (itself == NULL)
 131	{
 132		PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
 133		return NULL;
 134	}
 135	it = PyObject_NEW(CFTypeRefObject, &CFTypeRef_Type);
 136	if (it == NULL) return NULL;
 137	it->ob_itself = itself;
 138	it->ob_freeit = CFRelease;
 139	return (PyObject *)it;
 140}
 141
 142int CFTypeRefObj_Convert(PyObject *v, CFTypeRef *p_itself)
 143{
 144
 145	if (v == Py_None) { *p_itself = NULL; return 1; }
 146	/* Check for other CF objects here */
 147
 148	if (!CFTypeRefObj_Check(v))
 149	{
 150		PyErr_SetString(PyExc_TypeError, "CFTypeRef required");
 151		return 0;
 152	}
 153	*p_itself = ((CFTypeRefObject *)v)->ob_itself;
 154	return 1;
 155}
 156
 157static void CFTypeRefObj_dealloc(CFTypeRefObject *self)
 158{
 159	if (self->ob_freeit && self->ob_itself)
 160	{
 161		self->ob_freeit((CFTypeRef)self->ob_itself);
 162		self->ob_itself = NULL;
 163	}
 164	self->ob_type->tp_free((PyObject *)self);
 165}
 166
 167static PyObject *CFTypeRefObj_CFGetTypeID(CFTypeRefObject *_self, PyObject *_args)
 168{
 169	PyObject *_res = NULL;
 170	CFTypeID _rv;
 171#ifndef CFGetTypeID
 172	PyMac_PRECHECK(CFGetTypeID);
 173#endif
 174	if (!PyArg_ParseTuple(_args, ""))
 175		return NULL;
 176	_rv = CFGetTypeID(_self->ob_itself);
 177	_res = Py_BuildValue("l",
 178	                     _rv);
 179	return _res;
 180}
 181
 182static PyObject *CFTypeRefObj_CFRetain(CFTypeRefObject *_self, PyObject *_args)
 183{
 184	PyObject *_res = NULL;
 185	CFTypeRef _rv;
 186#ifndef CFRetain
 187	PyMac_PRECHECK(CFRetain);
 188#endif
 189	if (!PyArg_ParseTuple(_args, ""))
 190		return NULL;
 191	_rv = CFRetain(_self->ob_itself);
 192	_res = Py_BuildValue("O&",
 193	                     CFTypeRefObj_New, _rv);
 194	return _res;
 195}
 196
 197static PyObject *CFTypeRefObj_CFRelease(CFTypeRefObject *_self, PyObject *_args)
 198{
 199	PyObject *_res = NULL;
 200#ifndef CFRelease
 201	PyMac_PRECHECK(CFRelease);
 202#endif
 203	if (!PyArg_ParseTuple(_args, ""))
 204		return NULL;
 205	CFRelease(_self->ob_itself);
 206	Py_INCREF(Py_None);
 207	_res = Py_None;
 208	return _res;
 209}
 210
 211static PyObject *CFTypeRefObj_CFGetRetainCount(CFTypeRefObject *_self, PyObject *_args)
 212{
 213	PyObject *_res = NULL;
 214	CFIndex _rv;
 215#ifndef CFGetRetainCount
 216	PyMac_PRECHECK(CFGetRetainCount);
 217#endif
 218	if (!PyArg_ParseTuple(_args, ""))
 219		return NULL;
 220	_rv = CFGetRetainCount(_self->ob_itself);
 221	_res = Py_BuildValue("l",
 222	                     _rv);
 223	return _res;
 224}
 225
 226static PyObject *CFTypeRefObj_CFEqual(CFTypeRefObject *_self, PyObject *_args)
 227{
 228	PyObject *_res = NULL;
 229	Boolean _rv;
 230	CFTypeRef cf2;
 231#ifndef CFEqual
 232	PyMac_PRECHECK(CFEqual);
 233#endif
 234	if (!PyArg_ParseTuple(_args, "O&",
 235	                      CFTypeRefObj_Convert, &cf2))
 236		return NULL;
 237	_rv = CFEqual(_self->ob_itself,
 238	              cf2);
 239	_res = Py_BuildValue("l",
 240	                     _rv);
 241	return _res;
 242}
 243
 244static PyObject *CFTypeRefObj_CFHash(CFTypeRefObject *_self, PyObject *_args)
 245{
 246	PyObject *_res = NULL;
 247	CFHashCode _rv;
 248#ifndef CFHash
 249	PyMac_PRECHECK(CFHash);
 250#endif
 251	if (!PyArg_ParseTuple(_args, ""))
 252		return NULL;
 253	_rv = CFHash(_self->ob_itself);
 254	_res = Py_BuildValue("l",
 255	                     _rv);
 256	return _res;
 257}
 258
 259static PyObject *CFTypeRefObj_CFCopyDescription(CFTypeRefObject *_self, PyObject *_args)
 260{
 261	PyObject *_res = NULL;
 262	CFStringRef _rv;
 263#ifndef CFCopyDescription
 264	PyMac_PRECHECK(CFCopyDescription);
 265#endif
 266	if (!PyArg_ParseTuple(_args, ""))
 267		return NULL;
 268	_rv = CFCopyDescription(_self->ob_itself);
 269	_res = Py_BuildValue("O&",
 270	                     CFStringRefObj_New, _rv);
 271	return _res;
 272}
 273
 274static PyObject *CFTypeRefObj_CFPropertyListCreateXMLData(CFTypeRefObject *_self, PyObject *_args)
 275{
 276	PyObject *_res = NULL;
 277	CFDataRef _rv;
 278	if (!PyArg_ParseTuple(_args, ""))
 279		return NULL;
 280	_rv = CFPropertyListCreateXMLData((CFAllocatorRef)NULL,
 281	                                  _self->ob_itself);
 282	_res = Py_BuildValue("O&",
 283	                     CFDataRefObj_New, _rv);
 284	return _res;
 285}
 286
 287static PyObject *CFTypeRefObj_CFPropertyListCreateDeepCopy(CFTypeRefObject *_self, PyObject *_args)
 288{
 289	PyObject *_res = NULL;
 290	CFTypeRef _rv;
 291	CFOptionFlags mutabilityOption;
 292	if (!PyArg_ParseTuple(_args, "l",
 293	                      &mutabilityOption))
 294		return NULL;
 295	_rv = CFPropertyListCreateDeepCopy((CFAllocatorRef)NULL,
 296	                                   _self->ob_itself,
 297	                                   mutabilityOption);
 298	_res = Py_BuildValue("O&",
 299	                     CFTypeRefObj_New, _rv);
 300	return _res;
 301}
 302
 303static PyObject *CFTypeRefObj_CFShow(CFTypeRefObject *_self, PyObject *_args)
 304{
 305	PyObject *_res = NULL;
 306#ifndef CFShow
 307	PyMac_PRECHECK(CFShow);
 308#endif
 309	if (!PyArg_ParseTuple(_args, ""))
 310		return NULL;
 311	CFShow(_self->ob_itself);
 312	Py_INCREF(Py_None);
 313	_res = Py_None;
 314	return _res;
 315}
 316
 317static PyObject *CFTypeRefObj_CFPropertyListCreateFromXMLData(CFTypeRefObject *_self, PyObject *_args)
 318{
 319	PyObject *_res = NULL;
 320
 321	CFTypeRef _rv;
 322	CFOptionFlags mutabilityOption;
 323	CFStringRef errorString;
 324	if (!PyArg_ParseTuple(_args, "l",
 325	                      &mutabilityOption))
 326	        return NULL;
 327	_rv = CFPropertyListCreateFromXMLData((CFAllocatorRef)NULL,
 328	                                      _self->ob_itself,
 329	                                      mutabilityOption,
 330	                                      &errorString);
 331	if (errorString)
 332	        CFRelease(errorString);
 333	if (_rv == NULL) {
 334	        PyErr_SetString(PyExc_RuntimeError, "Parse error in XML data");
 335	        return NULL;
 336	}
 337	_res = Py_BuildValue("O&",
 338	                     CFTypeRefObj_New, _rv);
 339	return _res;
 340
 341}
 342
 343static PyObject *CFTypeRefObj_toPython(CFTypeRefObject *_self, PyObject *_args)
 344{
 345	PyObject *_res = NULL;
 346
 347	_res = PyCF_CF2Python(_self->ob_itself);
 348	return _res;
 349
 350}
 351
 352static PyMethodDef CFTypeRefObj_methods[] = {
 353	{"CFGetTypeID", (PyCFunction)CFTypeRefObj_CFGetTypeID, 1,
 354	 PyDoc_STR("() -> (CFTypeID _rv)")},
 355	{"CFRetain", (PyCFunction)CFTypeRefObj_CFRetain, 1,
 356	 PyDoc_STR("() -> (CFTypeRef _rv)")},
 357	{"CFRelease", (PyCFunction)CFTypeRefObj_CFRelease, 1,
 358	 PyDoc_STR("() -> None")},
 359	{"CFGetRetainCount", (PyCFunction)CFTypeRefObj_CFGetRetainCount, 1,
 360	 PyDoc_STR("() -> (CFIndex _rv)")},
 361	{"CFEqual", (PyCFunction)CFTypeRefObj_CFEqual, 1,
 362	 PyDoc_STR("(CFTypeRef cf2) -> (Boolean _rv)")},
 363	{"CFHash", (PyCFunction)CFTypeRefObj_CFHash, 1,
 364	 PyDoc_STR("() -> (CFHashCode _rv)")},
 365	{"CFCopyDescription", (PyCFunction)CFTypeRefObj_CFCopyDescription, 1,
 366	 PyDoc_STR("() -> (CFStringRef _rv)")},
 367	{"CFPropertyListCreateXMLData", (PyCFunction)CFTypeRefObj_CFPropertyListCreateXMLData, 1,
 368	 PyDoc_STR("() -> (CFDataRef _rv)")},
 369	{"CFPropertyListCreateDeepCopy", (PyCFunction)CFTypeRefObj_CFPropertyListCreateDeepCopy, 1,
 370	 PyDoc_STR("(CFOptionFlags mutabilityOption) -> (CFTypeRef _rv)")},
 371	{"CFShow", (PyCFunction)CFTypeRefObj_CFShow, 1,
 372	 PyDoc_STR("() -> None")},
 373	{"CFPropertyListCreateFromXMLData", (PyCFunction)CFTypeRefObj_CFPropertyListCreateFromXMLData, 1,
 374	 PyDoc_STR("(CFOptionFlags mutabilityOption) -> (CFTypeRefObj)")},
 375	{"toPython", (PyCFunction)CFTypeRefObj_toPython, 1,
 376	 PyDoc_STR("() -> (python_object)")},
 377	{NULL, NULL, 0}
 378};
 379
 380#define CFTypeRefObj_getsetlist NULL
 381
 382
 383static int CFTypeRefObj_compare(CFTypeRefObject *self, CFTypeRefObject *other)
 384{
 385	/* XXXX Or should we use CFEqual?? */
 386	if ( self->ob_itself > other->ob_itself ) return 1;
 387	if ( self->ob_itself < other->ob_itself ) return -1;
 388	return 0;
 389}
 390
 391static PyObject * CFTypeRefObj_repr(CFTypeRefObject *self)
 392{
 393	char buf[100];
 394	sprintf(buf, "<CFTypeRef type-%d object at 0x%8.8x for 0x%8.8x>", (int)CFGetTypeID(self->ob_itself), (unsigned)self, (unsigned)self->ob_itself);
 395	return PyString_FromString(buf);
 396}
 397
 398static int CFTypeRefObj_hash(CFTypeRefObject *self)
 399{
 400	/* XXXX Or should we use CFHash?? */
 401	return (int)self->ob_itself;
 402}
 403static int CFTypeRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
 404{
 405	CFTypeRef itself;
 406	char *kw[] = {"itself", 0};
 407
 408	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself))
 409	{
 410		((CFTypeRefObject *)_self)->ob_itself = itself;
 411		return 0;
 412	}
 413	return -1;
 414}
 415
 416#define CFTypeRefObj_tp_alloc PyType_GenericAlloc
 417
 418static PyObject *CFTypeRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
 419{
 420	PyObject *self;
 421	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
 422	((CFTypeRefObject *)self)->ob_itself = NULL;
 423	((CFTypeRefObject *)self)->ob_freeit = CFRelease;
 424	return self;
 425}
 426
 427#define CFTypeRefObj_tp_free PyObject_Del
 428
 429
 430PyTypeObject CFTypeRef_Type = {
 431	PyObject_HEAD_INIT(NULL)
 432	0, /*ob_size*/
 433	"_CF.CFTypeRef", /*tp_name*/
 434	sizeof(CFTypeRefObject), /*tp_basicsize*/
 435	0, /*tp_itemsize*/
 436	/* methods */
 437	(destructor) CFTypeRefObj_dealloc, /*tp_dealloc*/
 438	0, /*tp_print*/
 439	(getattrfunc)0, /*tp_getattr*/
 440	(setattrfunc)0, /*tp_setattr*/
 441	(cmpfunc) CFTypeRefObj_compare, /*tp_compare*/
 442	(reprfunc) CFTypeRefObj_repr, /*tp_repr*/
 443	(PyNumberMethods *)0, /* tp_as_number */
 444	(PySequenceMethods *)0, /* tp_as_sequence */
 445	(PyMappingMethods *)0, /* tp_as_mapping */
 446	(hashfunc) CFTypeRefObj_hash, /*tp_hash*/
 447	0, /*tp_call*/
 448	0, /*tp_str*/
 449	PyObject_GenericGetAttr, /*tp_getattro*/
 450	PyObject_GenericSetAttr, /*tp_setattro */
 451	0, /*tp_as_buffer*/
 452	Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
 453	0, /*tp_doc*/
 454	0, /*tp_traverse*/
 455	0, /*tp_clear*/
 456	0, /*tp_richcompare*/
 457	0, /*tp_weaklistoffset*/
 458	0, /*tp_iter*/
 459	0, /*tp_iternext*/
 460	CFTypeRefObj_methods, /* tp_methods */
 461	0, /*tp_members*/
 462	CFTypeRefObj_getsetlist, /*tp_getset*/
 463	0, /*tp_base*/
 464	0, /*tp_dict*/
 465	0, /*tp_descr_get*/
 466	0, /*tp_descr_set*/
 467	0, /*tp_dictoffset*/
 468	CFTypeRefObj_tp_init, /* tp_init */
 469	CFTypeRefObj_tp_alloc, /* tp_alloc */
 470	CFTypeRefObj_tp_new, /* tp_new */
 471	CFTypeRefObj_tp_free, /* tp_free */
 472};
 473
 474/* ------------------- End object type CFTypeRef -------------------- */
 475
 476
 477/* --------------------- Object type CFArrayRef --------------------- */
 478
 479PyTypeObject CFArrayRef_Type;
 480
 481#define CFArrayRefObj_Check(x) ((x)->ob_type == &CFArrayRef_Type || PyObject_TypeCheck((x), &CFArrayRef_Type))
 482
 483typedef struct CFArrayRefObject {
 484	PyObject_HEAD
 485	CFArrayRef ob_itself;
 486	void (*ob_freeit)(CFTypeRef ptr);
 487} CFArrayRefObject;
 488
 489PyObject *CFArrayRefObj_New(CFArrayRef itself)
 490{
 491	CFArrayRefObject *it;
 492	if (itself == NULL)
 493	{
 494		PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
 495		return NULL;
 496	}
 497	it = PyObject_NEW(CFArrayRefObject, &CFArrayRef_Type);
 498	if (it == NULL) return NULL;
 499	/* XXXX Should we tp_init or tp_new our basetype? */
 500	it->ob_itself = itself;
 501	it->ob_freeit = CFRelease;
 502	return (PyObject *)it;
 503}
 504
 505int CFArrayRefObj_Convert(PyObject *v, CFArrayRef *p_itself)
 506{
 507
 508	if (v == Py_None) { *p_itself = NULL; return 1; }
 509	/* Check for other CF objects here */
 510
 511	if (!CFArrayRefObj_Check(v))
 512	{
 513		PyErr_SetString(PyExc_TypeError, "CFArrayRef required");
 514		return 0;
 515	}
 516	*p_itself = ((CFArrayRefObject *)v)->ob_itself;
 517	return 1;
 518}
 519
 520static void CFArrayRefObj_dealloc(CFArrayRefObject *self)
 521{
 522	if (self->ob_freeit && self->ob_itself)
 523	{
 524		self->ob_freeit((CFTypeRef)self->ob_itself);
 525		self->ob_itself = NULL;
 526	}
 527	CFTypeRef_Type.tp_dealloc((PyObject *)self);
 528}
 529
 530static PyObject *CFArrayRefObj_CFArrayCreateCopy(CFArrayRefObject *_self, PyObject *_args)
 531{
 532	PyObject *_res = NULL;
 533	CFArrayRef _rv;
 534	if (!PyArg_ParseTuple(_args, ""))
 535		return NULL;
 536	_rv = CFArrayCreateCopy((CFAllocatorRef)NULL,
 537	                        _self->ob_itself);
 538	_res = Py_BuildValue("O&",
 539	                     CFArrayRefObj_New, _rv);
 540	return _res;
 541}
 542
 543static PyObject *CFArrayRefObj_CFArrayGetCount(CFArrayRefObject *_self, PyObject *_args)
 544{
 545	PyObject *_res = NULL;
 546	CFIndex _rv;
 547#ifndef CFArrayGetCount
 548	PyMac_PRECHECK(CFArrayGetCount);
 549#endif
 550	if (!PyArg_ParseTuple(_args, ""))
 551		return NULL;
 552	_rv = CFArrayGetCount(_self->ob_itself);
 553	_res = Py_BuildValue("l",
 554	                     _rv);
 555	return _res;
 556}
 557
 558static PyObject *CFArrayRefObj_CFStringCreateByCombiningStrings(CFArrayRefObject *_self, PyObject *_args)
 559{
 560	PyObject *_res = NULL;
 561	CFStringRef _rv;
 562	CFStringRef separatorString;
 563	if (!PyArg_ParseTuple(_args, "O&",
 564	                      CFStringRefObj_Convert, &separatorString))
 565		return NULL;
 566	_rv = CFStringCreateByCombiningStrings((CFAllocatorRef)NULL,
 567	                                       _self->ob_itself,
 568	                                       separatorString);
 569	_res = Py_BuildValue("O&",
 570	                     CFStringRefObj_New, _rv);
 571	return _res;
 572}
 573
 574static PyMethodDef CFArrayRefObj_methods[] = {
 575	{"CFArrayCreateCopy", (PyCFunction)CFArrayRefObj_CFArrayCreateCopy, 1,
 576	 PyDoc_STR("() -> (CFArrayRef _rv)")},
 577	{"CFArrayGetCount", (PyCFunction)CFArrayRefObj_CFArrayGetCount, 1,
 578	 PyDoc_STR("() -> (CFIndex _rv)")},
 579	{"CFStringCreateByCombiningStrings", (PyCFunction)CFArrayRefObj_CFStringCreateByCombiningStrings, 1,
 580	 PyDoc_STR("(CFStringRef separatorString) -> (CFStringRef _rv)")},
 581	{NULL, NULL, 0}
 582};
 583
 584#define CFArrayRefObj_getsetlist NULL
 585
 586
 587static int CFArrayRefObj_compare(CFArrayRefObject *self, CFArrayRefObject *other)
 588{
 589	/* XXXX Or should we use CFEqual?? */
 590	if ( self->ob_itself > other->ob_itself ) return 1;
 591	if ( self->ob_itself < other->ob_itself ) return -1;
 592	return 0;
 593}
 594
 595static PyObject * CFArrayRefObj_repr(CFArrayRefObject *self)
 596{
 597	char buf[100];
 598	sprintf(buf, "<CFArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
 599	return PyString_FromString(buf);
 600}
 601
 602static int CFArrayRefObj_hash(CFArrayRefObject *self)
 603{
 604	/* XXXX Or should we use CFHash?? */
 605	return (int)self->ob_itself;
 606}
 607static int CFArrayRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
 608{
 609	CFArrayRef itself;
 610	char *kw[] = {"itself", 0};
 611
 612	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFArrayRefObj_Convert, &itself))
 613	{
 614		((CFArrayRefObject *)_self)->ob_itself = itself;
 615		return 0;
 616	}
 617
 618	/* Any CFTypeRef descendent is allowed as initializer too */
 619	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself))
 620	{
 621		((CFArrayRefObject *)_self)->ob_itself = itself;
 622		return 0;
 623	}
 624	return -1;
 625}
 626
 627#define CFArrayRefObj_tp_alloc PyType_GenericAlloc
 628
 629static PyObject *CFArrayRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
 630{
 631	PyObject *self;
 632	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
 633	((CFArrayRefObject *)self)->ob_itself = NULL;
 634	((CFArrayRefObject *)self)->ob_freeit = CFRelease;
 635	return self;
 636}
 637
 638#define CFArrayRefObj_tp_free PyObject_Del
 639
 640
 641PyTypeObject CFArrayRef_Type = {
 642	PyObject_HEAD_INIT(NULL)
 643	0, /*ob_size*/
 644	"_CF.CFArrayRef", /*tp_name*/
 645	sizeof(CFArrayRefObject), /*tp_basicsize*/
 646	0, /*tp_itemsize*/
 647	/* methods */
 648	(destructor) CFArrayRefObj_dealloc, /*tp_dealloc*/
 649	0, /*tp_print*/
 650	(getattrfunc)0, /*tp_getattr*/
 651	(setattrfunc)0, /*tp_setattr*/
 652	(cmpfunc) CFArrayRefObj_compare, /*tp_compare*/
 653	(reprfunc) CFArrayRefObj_repr, /*tp_repr*/
 654	(PyNumberMethods *)0, /* tp_as_number */
 655	(PySequenceMethods *)0, /* tp_as_sequence */
 656	(PyMappingMethods *)0, /* tp_as_mapping */
 657	(hashfunc) CFArrayRefObj_hash, /*tp_hash*/
 658	0, /*tp_call*/
 659	0, /*tp_str*/
 660	PyObject_GenericGetAttr, /*tp_getattro*/
 661	PyObject_GenericSetAttr, /*tp_setattro */
 662	0, /*tp_as_buffer*/
 663	Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
 664	0, /*tp_doc*/
 665	0, /*tp_traverse*/
 666	0, /*tp_clear*/
 667	0, /*tp_richcompare*/
 668	0, /*tp_weaklistoffset*/
 669	0, /*tp_iter*/
 670	0, /*tp_iternext*/
 671	CFArrayRefObj_methods, /* tp_methods */
 672	0, /*tp_members*/
 673	CFArrayRefObj_getsetlist, /*tp_getset*/
 674	0, /*tp_base*/
 675	0, /*tp_dict*/
 676	0, /*tp_descr_get*/
 677	0, /*tp_descr_set*/
 678	0, /*tp_dictoffset*/
 679	CFArrayRefObj_tp_init, /* tp_init */
 680	CFArrayRefObj_tp_alloc, /* tp_alloc */
 681	CFArrayRefObj_tp_new, /* tp_new */
 682	CFArrayRefObj_tp_free, /* tp_free */
 683};
 684
 685/* ------------------- End object type CFArrayRef ------------------- */
 686
 687
 688/* ----------------- Object type CFMutableArrayRef ------------------ */
 689
 690PyTypeObject CFMutableArrayRef_Type;
 691
 692#define CFMutableArrayRefObj_Check(x) ((x)->ob_type == &CFMutableArrayRef_Type || PyObject_TypeCheck((x), &CFMutableArrayRef_Type))
 693
 694typedef struct CFMutableArrayRefObject {
 695	PyObject_HEAD
 696	CFMutableArrayRef ob_itself;
 697	void (*ob_freeit)(CFTypeRef ptr);
 698} CFMutableArrayRefObject;
 699
 700PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef itself)
 701{
 702	CFMutableArrayRefObject *it;
 703	if (itself == NULL)
 704	{
 705		PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
 706		return NULL;
 707	}
 708	it = PyObject_NEW(CFMutableArrayRefObject, &CFMutableArrayRef_Type);
 709	if (it == NULL) return NULL;
 710	/* XXXX Should we tp_init or tp_new our basetype? */
 711	it->ob_itself = itself;
 712	it->ob_freeit = CFRelease;
 713	return (PyObject *)it;
 714}
 715
 716int CFMutableArrayRefObj_Convert(PyObject *v, CFMutableArrayRef *p_itself)
 717{
 718
 719	if (v == Py_None) { *p_itself = NULL; return 1; }
 720	/* Check for other CF objects here */
 721
 722	if (!CFMutableArrayRefObj_Check(v))
 723	{
 724		PyErr_SetString(PyExc_TypeError, "CFMutableArrayRef required");
 725		return 0;
 726	}
 727	*p_itself = ((CFMutableArrayRefObject *)v)->ob_itself;
 728	return 1;
 729}
 730
 731static void CFMutableArrayRefObj_dealloc(CFMutableArrayRefObject *self)
 732{
 733	if (self->ob_freeit && self->ob_itself)
 734	{
 735		self->ob_freeit((CFTypeRef)self->ob_itself);
 736		self->ob_itself = NULL;
 737	}
 738	CFArrayRef_Type.tp_dealloc((PyObject *)self);
 739}
 740
 741static PyObject *CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRefObject *_self, PyObject *_args)
 742{
 743	PyObject *_res = NULL;
 744	CFIndex idx;
 745#ifndef CFArrayRemoveValueAtIndex
 746	PyMac_PRECHECK(CFArrayRemoveValueAtIndex);
 747#endif
 748	if (!PyArg_ParseTuple(_args, "l",
 749	                      &idx))
 750		return NULL;
 751	CFArrayRemoveValueAtIndex(_self->ob_itself,
 752	                          idx);
 753	Py_INCREF(Py_None);
 754	_res = Py_None;
 755	return _res;
 756}
 757
 758static PyObject *CFMutableArrayRefObj_CFArrayRemoveAllValues(CFMutableArrayRefObject *_self, PyObject *_args)
 759{
 760	PyObject *_res = NULL;
 761#ifndef CFArrayRemoveAllValues
 762	PyMac_PRECHECK(CFArrayRemoveAllValues);
 763#endif
 764	if (!PyArg_ParseTuple(_args, ""))
 765		return NULL;
 766	CFArrayRemoveAllValues(_self->ob_itself);
 767	Py_INCREF(Py_None);
 768	_res = Py_None;
 769	return _res;
 770}
 771
 772static PyObject *CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices(CFMutableArrayRefObject *_self, PyObject *_args)
 773{
 774	PyObject *_res = NULL;
 775	CFIndex idx1;
 776	CFIndex idx2;
 777#ifndef CFArrayExchangeValuesAtIndices
 778	PyMac_PRECHECK(CFArrayExchangeValuesAtIndices);
 779#endif
 780	if (!PyArg_ParseTuple(_args, "ll",
 781	                      &idx1,
 782	                      &idx2))
 783		return NULL;
 784	CFArrayExchangeValuesAtIndices(_self->ob_itself,
 785	                               idx1,
 786	                               idx2);
 787	Py_INCREF(Py_None);
 788	_res = Py_None;
 789	return _res;
 790}
 791
 792static PyObject *CFMutableArrayRefObj_CFArrayAppendArray(CFMutableArrayRefObject *_self, PyObject *_args)
 793{
 794	PyObject *_res = NULL;
 795	CFArrayRef otherArray;
 796	CFRange otherRange;
 797#ifndef CFArrayAppendArray
 798	PyMac_PRECHECK(CFArrayAppendArray);
 799#endif
 800	if (!PyArg_ParseTuple(_args, "O&O&",
 801	                      CFArrayRefObj_Convert, &otherArray,
 802	                      CFRange_Convert, &otherRange))
 803		return NULL;
 804	CFArrayAppendArray(_self->ob_itself,
 805	                   otherArray,
 806	                   otherRange);
 807	Py_INCREF(Py_None);
 808	_res = Py_None;
 809	return _res;
 810}
 811
 812static PyMethodDef CFMutableArrayRefObj_methods[] = {
 813	{"CFArrayRemoveValueAtIndex", (PyCFunction)CFMutableArrayRefObj_CFArrayRemoveValueAtIndex, 1,
 814	 PyDoc_STR("(CFIndex idx) -> None")},
 815	{"CFArrayRemoveAllValues", (PyCFunction)CFMutableArrayRefObj_CFArrayRemoveAllValues, 1,
 816	 PyDoc_STR("() -> None")},
 817	{"CFArrayExchangeValuesAtIndices", (PyCFunction)CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices, 1,
 818	 PyDoc_STR("(CFIndex idx1, CFIndex idx2) -> None")},
 819	{"CFArrayAppendArray", (PyCFunction)CFMutableArrayRefObj_CFArrayAppendArray, 1,
 820	 PyDoc_STR("(CFArrayRef otherArray, CFRange otherRange) -> None")},
 821	{NULL, NULL, 0}
 822};
 823
 824#define CFMutableArrayRefObj_getsetlist NULL
 825
 826
 827static int CFMutableArrayRefObj_compare(CFMutableArrayRefObject *self, CFMutableArrayRefObject *other)
 828{
 829	/* XXXX Or should we use CFEqual?? */
 830	if ( self->ob_itself > other->ob_itself ) return 1;
 831	if ( self->ob_itself < other->ob_itself ) return -1;
 832	return 0;
 833}
 834
 835static PyObject * CFMutableArrayRefObj_repr(CFMutableArrayRefObject *self)
 836{
 837	char buf[100];
 838	sprintf(buf, "<CFMutableArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
 839	return PyString_FromString(buf);
 840}
 841
 842static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject *self)
 843{
 844	/* XXXX Or should we use CFHash?? */
 845	return (int)self->ob_itself;
 846}
 847static int CFMutableArrayRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
 848{
 849	CFMutableArrayRef itself;
 850	char *kw[] = {"itself", 0};
 851
 852	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFMutableArrayRefObj_Convert, &itself))
 853	{
 854		((CFMutableArrayRefObject *)_self)->ob_itself = itself;
 855		return 0;
 856	}
 857
 858	/* Any CFTypeRef descendent is allowed as initializer too */
 859	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself))
 860	{
 861		((CFMutableArrayRefObject *)_self)->ob_itself = itself;
 862		return 0;
 863	}
 864	return -1;
 865}
 866
 867#define CFMutableArrayRefObj_tp_alloc PyType_GenericAlloc
 868
 869static PyObject *CFMutableArrayRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
 870{
 871	PyObject *self;
 872	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
 873	((CFMutableArrayRefObject *)self)->ob_itself = NULL;
 874	((CFMutableArrayRefObject *)self)->ob_freeit = CFRelease;
 875	return self;
 876}
 877
 878#define CFMutableArrayRefObj_tp_free PyObject_Del
 879
 880
 881PyTypeObject CFMutableArrayRef_Type = {
 882	PyObject_HEAD_INIT(NULL)
 883	0, /*ob_size*/
 884	"_CF.CFMutableArrayRef", /*tp_name*/
 885	sizeof(CFMutableArrayRefObject), /*tp_basicsize*/
 886	0, /*tp_itemsize*/
 887	/* methods */
 888	(destructor) CFMutableArrayRefObj_dealloc, /*tp_dealloc*/
 889	0, /*tp_print*/
 890	(getattrfunc)0, /*tp_getattr*/
 891	(setattrfunc)0, /*tp_setattr*/
 892	(cmpfunc) CFMutableArrayRefObj_compare, /*tp_compare*/
 893	(reprfunc) CFMutableArrayRefObj_repr, /*tp_repr*/
 894	(PyNumberMethods *)0, /* tp_as_number */
 895	(PySequenceMethods *)0, /* tp_as_sequence */
 896	(PyMappingMethods *)0, /* tp_as_mapping */
 897	(hashfunc) CFMutableArrayRefObj_hash, /*tp_hash*/
 898	0, /*tp_call*/
 899	0, /*tp_str*/
 900	PyObject_GenericGetAttr, /*tp_getattro*/
 901	PyObject_GenericSetAttr, /*tp_setattro */
 902	0, /*tp_as_buffer*/
 903	Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
 904	0, /*tp_doc*/
 905	0, /*tp_traverse*/
 906	0, /*tp_clear*/
 907	0, /*tp_richcompare*/
 908	0, /*tp_weaklistoffset*/
 909	0, /*tp_iter*/
 910	0, /*tp_iternext*/
 911	CFMutableArrayRefObj_methods, /* tp_methods */
 912	0, /*tp_members*/
 913	CFMutableArrayRefObj_getsetlist, /*tp_getset*/
 914	0, /*tp_base*/
 915	0, /*tp_dict*/
 916	0, /*tp_descr_get*/
 917	0, /*tp_descr_set*/
 918	0, /*tp_dictoffset*/
 919	CFMutableArrayRefObj_tp_init, /* tp_init */
 920	CFMutableArrayRefObj_tp_alloc, /* tp_alloc */
 921	CFMutableArrayRefObj_tp_new, /* tp_new */
 922	CFMutableArrayRefObj_tp_free, /* tp_free */
 923};
 924
 925/* --------------- End object type CFMutableArrayRef ---------------- */
 926
 927
 928/* ------------------ Object type CFDictionaryRef ------------------- */
 929
 930PyTypeObject CFDictionaryRef_Type;
 931
 932#define CFDictionaryRefObj_Check(x) ((x)->ob_type == &CFDictionaryRef_Type || PyObject_TypeCheck((x), &CFDictionaryRef_Type))
 933
 934typedef struct CFDictionaryRefObject {
 935	PyObject_HEAD
 936	CFDictionaryRef ob_itself;
 937	void (*ob_freeit)(CFTypeRef ptr);
 938} CFDictionaryRefObject;
 939
 940PyObject *CFDictionaryRefObj_New(CFDictionaryRef itself)
 941{
 942	CFDictionaryRefObject *it;
 943	if (itself == NULL)
 944	{
 945		PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
 946		return NULL;
 947	}
 948	it = PyObject_NEW(CFDictionaryRefObject, &CFDictionaryRef_Type);
 949	if (it == NULL) return NULL;
 950	/* XXXX Should we tp_init or tp_new our basetype? */
 951	it->ob_itself = itself;
 952	it->ob_freeit = CFRelease;
 953	return (PyObject *)it;
 954}
 955
 956int CFDictionaryRefObj_Convert(PyObject *v, CFDictionaryRef *p_itself)
 957{
 958
 959	if (v == Py_None) { *p_itself = NULL; return 1; }
 960	/* Check for other CF objects here */
 961
 962	if (!CFDictionaryRefObj_Check(v))
 963	{
 964		PyErr_SetString(PyExc_TypeError, "CFDictionaryRef required");
 965		return 0;
 966	}
 967	*p_itself = ((CFDictionaryRefObject *)v)->ob_itself;
 968	return 1;
 969}
 970
 971static void CFDictionaryRefObj_dealloc(CFDictionaryRefObject *self)
 972{
 973	if (self->ob_freeit && self->ob_itself)
 974	{
 975		self->ob_freeit((CFTypeRef)self->ob_itself);
 976		self->ob_itself = NULL;
 977	}
 978	CFTypeRef_Type.tp_dealloc((PyObject *)self);
 979}
 980
 981static PyObject *CFDictionaryRefObj_CFDictionaryCreateCopy(CFDictionaryRefObject *_self, PyObject *_args)
 982{
 983	PyObject *_res = NULL;
 984	CFDictionaryRef _rv;
 985	if (!PyArg_ParseTuple(_args, ""))
 986		return NULL;
 987	_rv = CFDictionaryCreateCopy((CFAllocatorRef)NULL,
 988	                             _self->ob_itself);
 989	_res = Py_BuildValue("O&",
 990	                     CFDictionaryRefObj_New, _rv);
 991	return _res;
 992}
 993
 994static PyObject *CFDictionaryRefObj_CFDictionaryGetCount(CFDictionaryRefObject *_self, PyObject *_args)
 995{
 996	PyObject *_res = NULL;
 997	CFIndex _rv;
 998#ifndef CFDictionaryGetCount
 999	PyMac_PRECHECK(CFDictionaryGetCount);
1000#endif
1001	if (!PyArg_ParseTuple(_args, ""))
1002		return NULL;
1003	_rv = CFDictionaryGetCount(_self->ob_itself);
1004	_res = Py_BuildValue("l",
1005	                     _rv);
1006	return _res;
1007}
1008
1009static PyMethodDef CFDictionaryRefObj_methods[] = {
1010	{"CFDictionaryCreateCopy", (PyCFunction)CFDictionaryRefObj_CFDictionaryCreateCopy, 1,
1011	 PyDoc_STR("() -> (CFDictionaryRef _rv)")},
1012	{"CFDictionaryGetCount", (PyCFunction)CFDictionaryRefObj_CFDictionaryGetCount, 1,
1013	 PyDoc_STR("() -> (CFIndex _rv)")},
1014	{NULL, NULL, 0}
1015};
1016
1017#define CFDictionaryRefObj_getsetlist NULL
1018
1019
1020static int CFDictionaryRefObj_compare(CFDictionaryRefObject *self, CFDictionaryRefObject *other)
1021{
1022	/* XXXX Or should we use CFEqual?? */
1023	if ( self->ob_itself > other->ob_itself ) return 1;
1024	if ( self->ob_itself < other->ob_itself ) return -1;
1025	return 0;
1026}
1027
1028static PyObject * CFDictionaryRefObj_repr(CFDictionaryRefObject *self)
1029{
1030	char buf[100];
1031	sprintf(buf, "<CFDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
1032	return PyString_FromString(buf);
1033}
1034
1035static int CFDictionaryRefObj_hash(CFDictionaryRefObject *self)
1036{
1037	/* XXXX Or should we use CFHash?? */
1038	return (int)self->ob_itself;
1039}
1040static int CFDictionaryRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
1041{
1042	CFDictionaryRef itself;
1043	char *kw[] = {"itself", 0};
1044
1045	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFDictionaryRefObj_Convert, &itself))
1046	{
1047		((CFDictionaryRefObject *)_self)->ob_itself = itself;
1048		return 0;
1049	}
1050
1051	/* Any CFTypeRef descendent is allowed as initializer too */
1052	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself))
1053	{
1054		((CFDictionaryRefObject *)_self)->ob_itself = itself;
1055		return 0;
1056	}
1057	return -1;
1058}
1059
1060#define CFDictionaryRefObj_tp_alloc PyType_GenericAlloc
1061
1062static PyObject *CFDictionaryRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
1063{
1064	PyObject *self;
1065	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
1066	((CFDictionaryRefObject *)self)->ob_itself = NULL;
1067	((CFDictionaryRefObject *)self)->ob_freeit = CFRelease;
1068	return self;
1069}
1070
1071#define CFDictionaryRefObj_tp_free PyObject_Del
1072
1073
1074PyTypeObject CFDictionaryRef_Type = {
1075	PyObject_HEAD_INIT(NULL)
1076	0, /*ob_size*/
1077	"_CF.CFDictionaryRef", /*tp_name*/
1078	sizeof(CFDictionaryRefObject), /*tp_basicsize*/
1079	0, /*tp_itemsize*/
1080	/* methods */
1081	(destructor) CFDictionaryRefObj_dealloc, /*tp_dealloc*/
1082	0, /*tp_print*/
1083	(getattrfunc)0, /*tp_getattr*/
1084	(setattrfunc)0, /*tp_setattr*/
1085	(cmpfunc) CFDictionaryRefObj_compare, /*tp_compare*/
1086	(reprfunc) CFDictionaryRefObj_repr, /*tp_repr*/
1087	(PyNumberMethods *)0, /* tp_as_number */
1088	(PySequenceMethods *)0, /* tp_as_sequence */
1089	(PyMappingMethods *)0, /* tp_as_mapping */
1090	(hashfunc) CFDictionaryRefObj_hash, /*tp_hash*/
1091	0, /*tp_call*/
1092	0, /*tp_str*/
1093	PyObject_GenericGetAttr, /*tp_getattro*/
1094	PyObject_GenericSetAttr, /*tp_setattro */
1095	0, /*tp_as_buffer*/
1096	Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
1097	0, /*tp_doc*/
1098	0, /*tp_traverse*/
1099	0, /*tp_clear*/
1100	0, /*tp_richcompare*/
1101	0, /*tp_weaklistoffset*/
1102	0, /*tp_iter*/
1103	0, /*tp_iternext*/
1104	CFDictionaryRefObj_methods, /* tp_methods */
1105	0, /*tp_members*/
1106	CFDictionaryRefObj_getsetlist, /*tp_getset*/
1107	0, /*tp_base*/
1108	0, /*tp_dict*/
1109	0, /*tp_descr_get*/
1110	0, /*tp_descr_set*/
1111	0, /*tp_dictoffset*/
1112	CFDictionaryRefObj_tp_init, /* tp_init */
1113	CFDictionaryRefObj_tp_alloc, /* tp_alloc */
1114	CFDictionaryRefObj_tp_new, /* tp_new */
1115	CFDictionaryRefObj_tp_free, /* tp_free */
1116};
1117
1118/* ---------------- End object type CFDictionaryRef ----------------- */
1119
1120
1121/* --------------- Object type CFMutableDictionaryRef --------------- */
1122
1123PyTypeObject CFMutableDictionaryRef_Type;
1124
1125#define CFMutableDictionaryRefObj_Check(x) ((x)->ob_type == &CFMutableDictionaryRef_Type || PyObject_TypeCheck((x), &CFMutableDictionaryRef_Type))
1126
1127typedef struct CFMutableDictionaryRefObject {
1128	PyObject_HEAD
1129	CFMutableDictionaryRef ob_itself;
1130	void (*ob_freeit)(CFTypeRef ptr);
1131} CFMutableDictionaryRefObject;
1132
1133PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef itself)
1134{
1135	CFMutableDictionaryRefObject *it;
1136	if (itself == NULL)
1137	{
1138		PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
1139		return NULL;
1140	}
1141	it = PyObject_NEW(CFMutableDictionaryRefObject, &CFMutableDictionaryRef_Type);
1142	if (it == NULL) return NULL;
1143	/* XXXX Should we tp_init or tp_new our basetype? */
1144	it->ob_itself = itself;
1145	it->ob_freeit = CFRelease;
1146	return (PyObject *)it;
1147}
1148
1149int CFMutableDictionaryRefObj_Convert(PyObject *v, CFMutableDictionaryRef *p_itself)
1150{
1151
1152	if (v == Py_None) { *p_itself = NULL; return 1; }
1153	/* Check for other CF objects here */
1154
1155	if (!CFMutableDictionaryRefObj_Check(v))
1156	{
1157		PyErr_SetString(PyExc_TypeError, "CFMutableDictionaryRef required");
1158		return 0;
1159	}
1160	*p_itself = ((CFMutableDictionaryRefObject *)v)->ob_itself;
1161	return 1;
1162}
1163
1164static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject *self)
1165{
1166	if (self->ob_freeit && self->ob_itself)
1167	{
1168		self->ob_freeit((CFTypeRef)self->ob_itself);
1169		self->ob_itself = NULL;
1170	}
1171	CFDictionaryRef_Type.tp_dealloc((PyObject *)self);
1172}
1173
1174static PyObject *CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject *_self, PyObject *_args)
1175{
1176	PyObject *_res = NULL;
1177#ifndef CFDictionaryRemoveAllValues
1178	PyMac_PRECHECK(CFDictionaryRemoveAllValues);
1179#endif
1180	if (!PyArg_ParseTuple(_args, ""))
1181		return NULL;
1182	CFDictionaryRemoveAllValues(_self->ob_itself);
1183	Py_INCREF(Py_None);
1184	_res = Py_None;
1185	return _res;
1186}
1187
1188static PyMethodDef CFMutableDictionaryRefObj_methods[] = {
1189	{"CFDictionaryRemoveAllValues", (PyCFunction)CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues, 1,
1190	 PyDoc_STR("() -> None")},
1191	{NULL, NULL, 0}
1192};
1193
1194#define CFMutableDictionaryRefObj_getsetlist NULL
1195
1196
1197static int CFMutableDictionaryRefObj_compare(CFMutableDictionaryRefObject *self, CFMutableDictionaryRefObject *other)
1198{
1199	/* XXXX Or should we use CFEqual?? */
1200	if ( self->ob_itself > other->ob_itself ) return 1;
1201	if ( self->ob_itself < other->ob_itself ) return -1;
1202	return 0;
1203}
1204
1205static PyObject * CFMutableDictionaryRefObj_repr(CFMutableDictionaryRefObject *self)
1206{
1207	char buf[100];
1208	sprintf(buf, "<CFMutableDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
1209	return PyString_FromString(buf);
1210}
1211
1212static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject *self)
1213{
1214	/* XXXX Or should we use CFHash?? */
1215	return (int)self->ob_itself;
1216}
1217static int CFMutableDictionaryRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
1218{
1219	CFMutableDictionaryRef itself;
1220	char *kw[] = {"itself", 0};
1221
1222	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFMutableDictionaryRefObj_Convert, &itself))
1223	{
1224		((CFMutableDictionaryRefObject *)_self)->ob_itself = itself;
1225		return 0;
1226	}
1227
1228	/* Any CFTypeRef descendent is allowed as initializer too */
1229	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself))
1230	{
1231		((CFMutableDictionaryRefObject *)_self)->ob_itself = itself;
1232		return 0;
1233	}
1234	return -1;
1235}
1236
1237#define CFMutableDictionaryRefObj_tp_alloc PyType_GenericAlloc
1238
1239static PyObject *CFMutableDictionaryRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
1240{
1241	PyObject *self;
1242	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
1243	((CFMutableDictionaryRefObject *)self)->ob_itself = NULL;
1244	((CFMutableDictionaryRefObject *)self)->ob_freeit = CFRelease;
1245	return self;
1246}
1247
1248#define CFMutableDictionaryRefObj_tp_free PyObject_Del
1249
1250
1251PyTypeObject CFMutableDictionaryRef_Type = {
1252	PyObject_HEAD_INIT(NULL)
1253	0, /*ob_size*/
1254	"_CF.CFMutableDictionaryRef", /*tp_name*/
1255	sizeof(CFMutableDictionaryRefObject), /*tp_basicsize*/
1256	0, /*tp_itemsize*/
1257	/* methods */
1258	(destructor) CFMutableDictionaryRefObj_dealloc, /*tp_dealloc*/
1259	0, /*tp_print*/
1260	(getattrfunc)0, /*tp_getattr*/
1261	(setattrfunc)0, /*tp_setattr*/
1262	(cmpfunc) CFMutableDictionaryRefObj_compare, /*tp_compare*/
1263	(reprfunc) CFMutableDictionaryRefObj_repr, /*tp_repr*/
1264	(PyNumberMethods *)0, /* tp_as_number */
1265	(PySequenceMethods *)0, /* tp_as_sequence */
1266	(PyMappingMethods *)0, /* tp_as_mapping */
1267	(hashfunc) CFMutableDictionaryRefObj_hash, /*tp_hash*/
1268	0, /*tp_call*/
1269	0, /*tp_str*/
1270	PyObject_GenericGetAttr, /*tp_getattro*/
1271	PyObject_GenericSetAttr, /*tp_setattro */
1272	0, /*tp_as_buffer*/
1273	Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
1274	0, /*tp_doc*/
1275	0, /*tp_traverse*/
1276	0, /*tp_clear*/
1277	0, /*tp_richcompare*/
1278	0, /*tp_weaklistoffset*/
1279	0, /*tp_iter*/
1280	0, /*tp_iternext*/
1281	CFMutableDictionaryRefObj_methods, /* tp_methods */
1282	0, /*tp_members*/
1283	CFMutableDictionaryRefObj_getsetlist, /*tp_getset*/
1284	0, /*tp_base*/
1285	0, /*tp_dict*/
1286	0, /*tp_descr_get*/
1287	0, /*tp_descr_set*/
1288	0, /*tp_dictoffset*/
1289	CFMutableDictionaryRefObj_tp_init, /* tp_init */
1290	CFMutableDictionaryRefObj_tp_alloc, /* tp_alloc */
1291	CFMutableDictionaryRefObj_tp_new, /* tp_new */
1292	CFMutableDictionaryRefObj_tp_free, /* tp_free */
1293};
1294
1295/* ------------- End object type CFMutableDictionaryRef ------------- */
1296
1297
1298/* --------------------- Object type CFDataRef ---------------------- */
1299
1300PyTypeObject CFDataRef_Type;
1301
1302#define CFDataRefObj_Check(x) ((x)->ob_type == &CFDataRef_Type || PyObject_TypeCheck((x), &CFDataRef_Type))
1303
1304typedef struct CFDataRefObject {
1305	PyObject_HEAD
1306	CFDataRef ob_itself;
1307	void (*ob_freeit)(CFTypeRef ptr);
1308} CFDataRefObject;
1309
1310PyObject *CFDataRefObj_New(CFDataRef itself)
1311{
1312	CFDataRefObject *it;
1313	if (itself == NULL)
1314	{
1315		PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
1316		return NULL;
1317	}
1318	it = PyObject_NEW(CFDataRefObject, &CFDataRef_Type);
1319	if (it == NULL) return NULL;
1320	/* XXXX Should we tp_init or tp_new our basetype? */
1321	it->ob_itself = itself;
1322	it->ob_freeit = CFRelease;
1323	return (PyObject *)it;
1324}
1325
1326int CFDataRefObj_Convert(PyObject *v, CFDataRef *p_itself)
1327{
1328
1329	if (v == Py_None) { *p_itself = NULL; return 1; }
1330	if (PyString_Check(v)) {
1331	    char *cStr;
1332	    Py_ssize_t cLen;
1333	    if( PyString_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0;
1334	    *p_itself = CFDataCreate((CFAllocatorRef)NULL, (unsigned char *)cStr, cLen);
1335	    return 1;
1336	}
1337
1338	if (!CFDataRefObj_Check(v))
1339	{
1340		PyErr_SetString(PyExc_TypeError, "CFDataRef required");
1341		return 0;
1342	}
1343	*p_itself = ((CFDataRefObject *)v)->ob_itself;
1344	return 1;
1345}
1346
1347static void CFDataRefObj_dealloc(CFDataRefObject *self)
1348{
1349	if (self->ob_freeit && self->ob_itself)
1350	{
1351		self->ob_freeit((CFTypeRef)self->ob_itself);
1352		self->ob_itself = NULL;
1353	}
1354	CFTypeRef_Type.tp_dealloc((PyObject *)self);
1355}
1356
1357static PyObject *CFDataRefObj_CFDataCreateCopy(CFDataRefObject *_self, PyObject *_args)
1358{
1359	PyObject *_res = NULL;
1360	CFDataRef _rv;
1361	if (!PyArg_ParseTuple(_args, ""))
1362		return NULL;
1363	_rv = CFDataCreateCopy((CFAllocatorRef)NULL,
1364	                       _self->ob_itself);
1365	_res = Py_BuildValue("O&",
1366	                     CFDataRefObj_New, _rv);
1367	return _res;
1368}
1369
1370static PyObject *CFDataRefObj_CFDataGetLength(CFDataRefObject *_self, PyObject *_args)
1371{
1372	PyObject *_res = NULL;
1373	CFIndex _rv;
1374#ifndef CFDataGetLength
1375	PyMac_PRECHECK(CFDataGetLength);
1376#endif
1377	if (!PyArg_ParseTuple(_args, ""))
1378		return NULL;
1379	_rv = CFDataGetLength(_self->ob_itself);
1380	_res = Py_BuildValue("l",
1381	                     _rv);
1382	return _res;
1383}
1384
1385static PyObject *CFDataRefObj_CFStringCreateFromExternalRepresentation(CFDataRefObject *_self, PyObject *_args)
1386{
1387	PyObject *_res = NULL;
1388	CFStringRef _rv;
1389	CFStringEncoding encoding;
1390	if (!PyArg_ParseTuple(_args, "l",
1391	                      &encoding))
1392		return NULL;
1393	_rv = CFStringCreateFromExternalRepresentation((CFAllocatorRef)NULL,
1394	                                               _self->ob_itself,
1395	                                               encoding);
1396	_res = Py_BuildValue("O&",
1397	                     CFStringRefObj_New, _rv);
1398	return _res;
1399}
1400
1401static PyObject *CFDataRefObj_CFDataGetData(CFDataRefObject *_self, PyObject *_args)
1402{
1403	PyObject *_res = NULL;
1404
1405	int size = CFDataGetLength(_self->ob_itself);
1406	char *data = (char *)CFDataGetBytePtr(_self->ob_itself);
1407
1408	_res = (PyObject *)PyString_FromStringAndSize(data, size);
1409	return _res;
1410
1411}
1412
1413static PyMethodDef CFDataRefObj_methods[] = {
1414	{"CFDataCreateCopy", (PyCFunction)CFDataRefObj_CFDataCreateCopy, 1,
1415	 PyDoc_STR("() -> (CFDataRef _rv)")},
1416	{"CFDataGetLength", (PyCFunction)CFDataRefObj_CFDataGetLength, 1,
1417	 PyDoc_STR("() -> (CFIndex _rv)")},
1418	{"CFStringCreateFromExternalRepresentation", (PyCFunction)CFDataRefObj_CFStringCreateFromExternalRepresentation, 1,
1419	 PyDoc_STR("(CFStringEncoding encoding) -> (CFStringRef _rv)")},
1420	{"CFDataGetData", (PyCFunction)CFDataRefObj_CFDataGetData, 1,
1421	 PyDoc_STR("() -> (string _rv)")},
1422	{NULL, NULL, 0}
1423};
1424
1425#define CFDataRefObj_getsetlist NULL
1426
1427
1428static int CFDataRefObj_compare(CFDataRefObject *self, CFDataRefObject *other)
1429{
1430	/* XXXX Or should we use CFEqual?? */
1431	if ( self->ob_itself > other->ob_itself ) return 1;
1432	if ( self->ob_itself < other->ob_itself ) return -1;
1433	return 0;
1434}
1435
1436static PyObject * CFDataRefObj_repr(CFDataRefObject *self)
1437{
1438	char buf[100];
1439	sprintf(buf, "<CFDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
1440	return PyString_FromString(buf);
1441}
1442
1443static int CFDataRefObj_hash(CFDataRefObject *self)
1444{
1445	/* XXXX Or should we use CFHash?? */
1446	return (int)self->ob_itself;
1447}
1448static int CFDataRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
1449{
1450	CFDataRef itself;
1451	char *kw[] = {"itself", 0};
1452
1453	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFDataRefObj_Convert, &itself))
1454	{
1455		((CFDataRefObject *)_self)->ob_itself = itself;
1456		return 0;
1457	}
1458
1459	/* Any CFTypeRef descendent is allowed as initializer too */
1460	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself))
1461	{
1462		((CFDataRefObject *)_self)->ob_itself = itself;
1463		return 0;
1464	}
1465	return -1;
1466}
1467
1468#define CFDataRefObj_tp_alloc PyType_GenericAlloc
1469
1470static PyObject *CFDataRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
1471{
1472	PyObject *self;
1473	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
1474	((CFDataRefObject *)self)->ob_itself = NULL;
1475	((CFDataRefObject *)self)->ob_freeit = CFRelease;
1476	return self;
1477}
1478
1479#define CFDataRefObj_tp_free PyObject_Del
1480
1481
1482PyTypeObject CFDataRef_Type = {
1483	PyObject_HEAD_INIT(NULL)
1484	0, /*ob_size*/
1485	"_CF.CFDataRef", /*tp_name*/
1486	sizeof(CFDataRefObject), /*tp_basicsize*/
1487	0, /*tp_itemsize*/
1488	/* methods */
1489	(destructor) CFDataRefObj_dealloc, /*tp_dealloc*/
1490	0, /*tp_print*/
1491	(getattrfunc)0, /*tp_getattr*/
1492	(setattrfunc)0, /*tp_setattr*/
1493	(cmpfunc) CFDataRefObj_compare, /*tp_compare*/
1494	(reprfunc) CFDataRefObj_repr, /*tp_repr*/
1495	(PyNumberMethods *)0, /* tp_as_number */
1496	(PySequenceMethods *)0, /* tp_as_sequence */
1497	(PyMappingMethods *)0, /* tp_as_mapping */
1498	(hashfunc) CFDataRefObj_hash, /*tp_hash*/
1499	0, /*tp_call*/
1500	0, /*tp_str*/
1501	PyObject_GenericGetAttr, /*tp_getattro*/
1502	PyObject_GenericSetAttr, /*tp_setattro */
1503	0, /*tp_as_buffer*/
1504	Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
1505	0, /*tp_doc*/
1506	0, /*tp_traverse*/
1507	0, /*tp_clear*/
1508	0, /*tp_richcompare*/
1509	0, /*tp_weaklistoffset*/
1510	0, /*tp_iter*/
1511	0, /*tp_iternext*/
1512	CFDataRefObj_methods, /* tp_methods */
1513	0, /*tp_members*/
1514	CFDataRefObj_getsetlist, /*tp_getset*/
1515	0, /*tp_base*/
1516	0, /*tp_dict*/
1517	0, /*tp_descr_get*/
1518	0, /*tp_descr_set*/
1519	0, /*tp_dictoffset*/
1520	CFDataRefObj_tp_init, /* tp_init */
1521	CFDataRefObj_tp_alloc, /* tp_alloc */
1522	CFDataRefObj_tp_new, /* tp_new */
1523	CFDataRefObj_tp_free, /* tp_free */
1524};
1525
1526/* ------------------- End object type CFDataRef -------------------- */
1527
1528
1529/* ------------------ Object type CFMutableDataRef ------------------ */
1530
1531PyTypeObject CFMutableDataRef_Type;
1532
1533#define CFMutableDataRefObj_Check(x) ((x)->ob_type == &CFMutableDataRef_Type || PyObject_TypeCheck((x), &CFMutableDataRef_Type))
1534
1535typedef struct CFMutableDataRefObject {
1536	PyObject_HEAD
1537	CFMutableDataRef ob_itself;
1538	void (*ob_freeit)(CFTypeRef ptr);
1539} CFMutableDataRefObject;
1540
1541PyObject *CFMutableDataRefObj_New(CFMutableDataRef itself)
1542{
1543	CFMutableDataRefObject *it;
1544	if (itself == NULL)
1545	{
1546		PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
1547		return NULL;
1548	}
1549	it = PyObject_NEW(CFMutableDataRefObject, &CFMutableDataRef_Type);
1550	if (it == NULL) return NULL;
1551	/* XXXX Should we tp_init or tp_new our basetype? */
1552	it->ob_itself = itself;
1553	it->ob_freeit = CFRelease;
1554	return (PyObject *)it;
1555}
1556
1557int CFMutableDataRefObj_Convert(PyObject *v, CFMutableDataRef *p_itself)
1558{
1559
1560	if (v == Py_None) { *p_itself = NULL; return 1; }
1561	/* Check for other CF objects here */
1562
1563	if (!CFMutableDataRefObj_Check(v))
1564	{
1565		PyErr_SetString(PyExc_TypeError, "CFMutableDataRef required");
1566		return 0;
1567	}
1568	*p_itself = ((CFMutableDataRefObject *)v)->ob_itself;
1569	return 1;
1570}
1571
1572static void CFMutableDataRefObj_dealloc(CFMutableDataRefObject *self)
1573{
1574	if (self->ob_freeit && self->ob_itself)
1575	{
1576		self->ob_freeit((CFTypeRef)self->ob_itself);
1577		self->ob_itself = NULL;
1578	}
1579	CFDataRef_Type.tp_dealloc((PyObject *)self);
1580}
1581
1582static PyObject *CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject *_self, PyObject *_args)
1583{
1584	PyObject *_res = NULL;
1585	CFIndex length;
1586#ifndef CFDataSetLength
1587	PyMac_PRECHECK(CFDataSetLength);
1588#endif
1589	if (!PyArg_ParseTuple(_args, "l",
1590	                      &length))
1591		return NULL;
1592	CFDataSetLength(_self->ob_itself,
1593	                length);
1594	Py_INCREF(Py_None);
1595	_res = Py_None;
1596	return _res;
1597}
1598
1599static PyObject *CFMutableDataRefObj_CFDataIncreaseLength(CFMutableDataRefObject *_self, PyObject *_args)
1600{
1601	PyObject *_res = NULL;
1602	CFIndex extraLength;
1603#ifndef CFDataIncreaseLength
1604	PyMac_PRECHECK(CFDataIncreaseLength);
1605#endif
1606	if (!PyArg_ParseTuple(_args, "l",
1607	                      &extraLength))
1608		return NULL;
1609	CFDataIncreaseLength(_self->ob_itself,
1610	                     extraLength);
1611	Py_INCREF(Py_None);
1612	_res = Py_None;
1613	return _res;
1614}
1615
1616static PyObject *CFMutableDataRefObj_CFDataAppendBytes(CFMutableDataRefObject *_self, PyObject *_args)
1617{
1618	PyObject *_res = NULL;
1619	unsigned char *bytes__in__;
1620	long bytes__len__;
1621	int bytes__in_len__;
1622#ifndef CFDataAppendBytes
1623	PyMac_PRECHECK(CFDataAppendBytes);
1624#endif
1625	if (!PyArg_ParseTuple(_args, "s#",
1626	                      &bytes__in__, &bytes__in_len__))
1627		return NULL;
1628	bytes__len__ = bytes__in_len__;
1629	CFDataAppendBytes(_self->ob_itself,
1630	                  bytes__in__, bytes__len__);
1631	Py_INCREF(Py_None);
1632	_res = Py_None;
1633	return _res;
1634}
1635
1636static PyObject *CFMutableDataRefObj_CFDataReplaceBytes(CFMutableDataRefObject *_self, PyObject *_args)
1637{
1638	PyObject *_res = NULL;
1639	CFRange range;
1640	unsigned char *newBytes__in__;
1641	long newBytes__len__;
1642	int newBytes__in_len__;
1643#ifndef CFDataReplaceBytes
1644	PyMac_PRECHECK(CFDataReplaceBytes);
1645#endif
1646	if (!PyArg_ParseTuple(_args, "O&s#",
1647	                      CFRange_Convert, &range,
1648	                      &newBytes__in__, &newBytes__in_len__))
1649		return NULL;
1650	newBytes__len__ = newBytes__in_len__;
1651	CFDataReplaceBytes(_self->ob_itself,
1652	                   range,
1653	                   newBytes__in__, newBytes__len__);
1654	Py_INCREF(Py_None);
1655	_res = Py_None;
1656	return _res;
1657}
1658
1659static PyObject *CFMutableDataRefObj_CFDataDeleteBytes(CFMutableDataRefObject *_self, PyObject *_args)
1660{
1661	PyObject *_res = NULL;
1662	CFRange range;
1663#ifndef CFDataDeleteBytes
1664	PyMac_PRECHECK(CFDataDeleteBytes);
1665#endif
1666	if (!PyArg_ParseTuple(_args, "O&",
1667	                      CFRange_Convert, &range))
1668		return NULL;
1669	CFDataDeleteBytes(_self->ob_itself,
1670	                  range);
1671	Py_INCREF(Py_None);
1672	_res = Py_None;
1673	return _res;
1674}
1675
1676static PyMethodDef CFMutableDataRefObj_methods[] = {
1677	{"CFDataSetLength", (PyCFunction)CFMutableDataRefObj_CFDataSetLength, 1,
1678	 PyDoc_STR("(CFIndex length) -> None")},
1679	{"CFDataIncreaseLength", (PyCFunction)CFMutableDataRefObj_CFDataIncreaseLength, 1,
1680	 PyDoc_STR("(CFIndex extraLength) -> None")},
1681	{"CFDataAppendBytes", (PyCFunction)CFMutableDataRefObj_CFDataAppendBytes, 1,
1682	 PyDoc_STR("(Buffer bytes) -> None")},
1683	{"CFDataReplaceBytes", (PyCFunction)CFMutableDataRefObj_CFDataReplaceBytes, 1,
1684	 PyDoc_STR("(CFRange range, Buffer newBytes) -> None")},
1685	{"CFDataDeleteBytes", (PyCFunction)CFMutableDataRefObj_CFDataDeleteBytes, 1,
1686	 PyDoc_STR("(CFRange range) -> None")},
1687	{NULL, NULL, 0}
1688};
1689
1690#define CFMutableDataRefObj_getsetlist NULL
1691
1692
1693static int CFMutableDataRefObj_compare(CFMutableDataRefObject *self, CFMutableDataRefObject *other)
1694{
1695	/* XXXX Or should we use CFEqual?? */
1696	if ( self->ob_itself > other->ob_itself ) return 1;
1697	if ( self->ob_itself < other->ob_itself ) return -1;
1698	return 0;
1699}
1700
1701static PyObject * CFMutableDataRefObj_repr(CFMutableDataRefObject *self)
1702{
1703	char buf[100];
1704	sprintf(buf, "<CFMutableDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
1705	return PyString_FromString(buf);
1706}
1707
1708static int CFMutableDataRefObj_hash(CFMutableDataRefObject *self)
1709{
1710	/* XXXX Or should we use CFHash?? */
1711	return (int)self->ob_itself;
1712}
1713static int CFMutableDataRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
1714{
1715	CFMutableDataRef itself;
1716	char *kw[] = {"itself", 0};
1717
1718	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFMutableDataRefObj_Convert, &itself))
1719	{
1720		((CFMutableDataRefObject *)_self)->ob_itself = itself;
1721		return 0;
1722	}
1723
1724	/* Any CFTypeRef descendent is allowed as initializer too */
1725	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFType

Large files files are truncated, but you can click here to view the full file