symbian-qemu-0.9.1-12/python-2.6.1/Mac/Modules/cf/_CFmodule.c
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     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
       
    23 extern PyObject *_CFObj_New(CFTypeRef);
       
    24 extern int _CFObj_Convert(PyObject *, CFTypeRef *);
       
    25 #define CFObj_New _CFObj_New
       
    26 #define CFObj_Convert _CFObj_Convert
       
    27 
       
    28 extern PyObject *_CFTypeRefObj_New(CFTypeRef);
       
    29 extern int _CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
       
    30 #define CFTypeRefObj_New _CFTypeRefObj_New
       
    31 #define CFTypeRefObj_Convert _CFTypeRefObj_Convert
       
    32 
       
    33 extern PyObject *_CFStringRefObj_New(CFStringRef);
       
    34 extern int _CFStringRefObj_Convert(PyObject *, CFStringRef *);
       
    35 #define CFStringRefObj_New _CFStringRefObj_New
       
    36 #define CFStringRefObj_Convert _CFStringRefObj_Convert
       
    37 
       
    38 extern PyObject *_CFMutableStringRefObj_New(CFMutableStringRef);
       
    39 extern int _CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *);
       
    40 #define CFMutableStringRefObj_New _CFMutableStringRefObj_New
       
    41 #define CFMutableStringRefObj_Convert _CFMutableStringRefObj_Convert
       
    42 
       
    43 extern PyObject *_CFArrayRefObj_New(CFArrayRef);
       
    44 extern int _CFArrayRefObj_Convert(PyObject *, CFArrayRef *);
       
    45 #define CFArrayRefObj_New _CFArrayRefObj_New
       
    46 #define CFArrayRefObj_Convert _CFArrayRefObj_Convert
       
    47 
       
    48 extern PyObject *_CFMutableArrayRefObj_New(CFMutableArrayRef);
       
    49 extern int _CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *);
       
    50 #define CFMutableArrayRefObj_New _CFMutableArrayRefObj_New
       
    51 #define CFMutableArrayRefObj_Convert _CFMutableArrayRefObj_Convert
       
    52 
       
    53 extern PyObject *_CFDataRefObj_New(CFDataRef);
       
    54 extern int _CFDataRefObj_Convert(PyObject *, CFDataRef *);
       
    55 #define CFDataRefObj_New _CFDataRefObj_New
       
    56 #define CFDataRefObj_Convert _CFDataRefObj_Convert
       
    57 
       
    58 extern PyObject *_CFMutableDataRefObj_New(CFMutableDataRef);
       
    59 extern int _CFMutableDataRefObj_Convert(PyObject *, CFMutableDataRef *);
       
    60 #define CFMutableDataRefObj_New _CFMutableDataRefObj_New
       
    61 #define CFMutableDataRefObj_Convert _CFMutableDataRefObj_Convert
       
    62 
       
    63 extern PyObject *_CFDictionaryRefObj_New(CFDictionaryRef);
       
    64 extern int _CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *);
       
    65 #define CFDictionaryRefObj_New _CFDictionaryRefObj_New
       
    66 #define CFDictionaryRefObj_Convert _CFDictionaryRefObj_Convert
       
    67 
       
    68 extern PyObject *_CFMutableDictionaryRefObj_New(CFMutableDictionaryRef);
       
    69 extern int _CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *);
       
    70 #define CFMutableDictionaryRefObj_New _CFMutableDictionaryRefObj_New
       
    71 #define CFMutableDictionaryRefObj_Convert _CFMutableDictionaryRefObj_Convert
       
    72 
       
    73 extern PyObject *_CFURLRefObj_New(CFURLRef);
       
    74 extern int _CFURLRefObj_Convert(PyObject *, CFURLRef *);
       
    75 extern 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 */
       
    84 PyObject *CFRange_New(CFRange *itself)
       
    85 {
       
    86 
       
    87         return Py_BuildValue("ll", (long)itself->location, (long)itself->length);
       
    88 }
       
    89 
       
    90 int
       
    91 CFRange_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) */
       
   103 int
       
   104 OptionalCFURLRefObj_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 
       
   113 static PyObject *CF_Error;
       
   114 
       
   115 /* --------------------- Object type CFTypeRef ---------------------- */
       
   116 
       
   117 PyTypeObject CFTypeRef_Type;
       
   118 
       
   119 #define CFTypeRefObj_Check(x) ((x)->ob_type == &CFTypeRef_Type || PyObject_TypeCheck((x), &CFTypeRef_Type))
       
   120 
       
   121 typedef struct CFTypeRefObject {
       
   122 	PyObject_HEAD
       
   123 	CFTypeRef ob_itself;
       
   124 	void (*ob_freeit)(CFTypeRef ptr);
       
   125 } CFTypeRefObject;
       
   126 
       
   127 PyObject *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 
       
   142 int 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 
       
   157 static 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 
       
   167 static 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 
       
   182 static 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 
       
   197 static 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 
       
   211 static 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 
       
   226 static 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 
       
   244 static 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 
       
   259 static 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 
       
   274 static 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 
       
   287 static 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 
       
   303 static 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 
       
   317 static 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 
       
   343 static 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 
       
   352 static 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 
       
   383 static 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 
       
   391 static 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 
       
   398 static int CFTypeRefObj_hash(CFTypeRefObject *self)
       
   399 {
       
   400 	/* XXXX Or should we use CFHash?? */
       
   401 	return (int)self->ob_itself;
       
   402 }
       
   403 static 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 
       
   418 static 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 
       
   430 PyTypeObject 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 
       
   479 PyTypeObject CFArrayRef_Type;
       
   480 
       
   481 #define CFArrayRefObj_Check(x) ((x)->ob_type == &CFArrayRef_Type || PyObject_TypeCheck((x), &CFArrayRef_Type))
       
   482 
       
   483 typedef struct CFArrayRefObject {
       
   484 	PyObject_HEAD
       
   485 	CFArrayRef ob_itself;
       
   486 	void (*ob_freeit)(CFTypeRef ptr);
       
   487 } CFArrayRefObject;
       
   488 
       
   489 PyObject *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 
       
   505 int 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 
       
   520 static 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 
       
   530 static 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 
       
   543 static 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 
       
   558 static 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 
       
   574 static 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 
       
   587 static 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 
       
   595 static 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 
       
   602 static int CFArrayRefObj_hash(CFArrayRefObject *self)
       
   603 {
       
   604 	/* XXXX Or should we use CFHash?? */
       
   605 	return (int)self->ob_itself;
       
   606 }
       
   607 static 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 
       
   629 static 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 
       
   641 PyTypeObject 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 
       
   690 PyTypeObject CFMutableArrayRef_Type;
       
   691 
       
   692 #define CFMutableArrayRefObj_Check(x) ((x)->ob_type == &CFMutableArrayRef_Type || PyObject_TypeCheck((x), &CFMutableArrayRef_Type))
       
   693 
       
   694 typedef struct CFMutableArrayRefObject {
       
   695 	PyObject_HEAD
       
   696 	CFMutableArrayRef ob_itself;
       
   697 	void (*ob_freeit)(CFTypeRef ptr);
       
   698 } CFMutableArrayRefObject;
       
   699 
       
   700 PyObject *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 
       
   716 int 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 
       
   731 static 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 
       
   741 static 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 
       
   758 static 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 
       
   772 static 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 
       
   792 static 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 
       
   812 static 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 
       
   827 static 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 
       
   835 static 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 
       
   842 static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject *self)
       
   843 {
       
   844 	/* XXXX Or should we use CFHash?? */
       
   845 	return (int)self->ob_itself;
       
   846 }
       
   847 static 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 
       
   869 static 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 
       
   881 PyTypeObject 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 
       
   930 PyTypeObject CFDictionaryRef_Type;
       
   931 
       
   932 #define CFDictionaryRefObj_Check(x) ((x)->ob_type == &CFDictionaryRef_Type || PyObject_TypeCheck((x), &CFDictionaryRef_Type))
       
   933 
       
   934 typedef struct CFDictionaryRefObject {
       
   935 	PyObject_HEAD
       
   936 	CFDictionaryRef ob_itself;
       
   937 	void (*ob_freeit)(CFTypeRef ptr);
       
   938 } CFDictionaryRefObject;
       
   939 
       
   940 PyObject *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 
       
   956 int 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 
       
   971 static 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 
       
   981 static 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 
       
   994 static 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 
       
  1009 static 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 
       
  1020 static 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 
       
  1028 static 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 
       
  1035 static int CFDictionaryRefObj_hash(CFDictionaryRefObject *self)
       
  1036 {
       
  1037 	/* XXXX Or should we use CFHash?? */
       
  1038 	return (int)self->ob_itself;
       
  1039 }
       
  1040 static 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 
       
  1062 static 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 
       
  1074 PyTypeObject 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 
       
  1123 PyTypeObject CFMutableDictionaryRef_Type;
       
  1124 
       
  1125 #define CFMutableDictionaryRefObj_Check(x) ((x)->ob_type == &CFMutableDictionaryRef_Type || PyObject_TypeCheck((x), &CFMutableDictionaryRef_Type))
       
  1126 
       
  1127 typedef struct CFMutableDictionaryRefObject {
       
  1128 	PyObject_HEAD
       
  1129 	CFMutableDictionaryRef ob_itself;
       
  1130 	void (*ob_freeit)(CFTypeRef ptr);
       
  1131 } CFMutableDictionaryRefObject;
       
  1132 
       
  1133 PyObject *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 
       
  1149 int 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 
       
  1164 static 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 
       
  1174 static 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 
       
  1188 static 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 
       
  1197 static 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 
       
  1205 static 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 
       
  1212 static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject *self)
       
  1213 {
       
  1214 	/* XXXX Or should we use CFHash?? */
       
  1215 	return (int)self->ob_itself;
       
  1216 }
       
  1217 static 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 
       
  1239 static 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 
       
  1251 PyTypeObject 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 
       
  1300 PyTypeObject CFDataRef_Type;
       
  1301 
       
  1302 #define CFDataRefObj_Check(x) ((x)->ob_type == &CFDataRef_Type || PyObject_TypeCheck((x), &CFDataRef_Type))
       
  1303 
       
  1304 typedef struct CFDataRefObject {
       
  1305 	PyObject_HEAD
       
  1306 	CFDataRef ob_itself;
       
  1307 	void (*ob_freeit)(CFTypeRef ptr);
       
  1308 } CFDataRefObject;
       
  1309 
       
  1310 PyObject *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 
       
  1326 int 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 
       
  1347 static 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 
       
  1357 static 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 
       
  1370 static 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 
       
  1385 static 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 
       
  1401 static 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 
       
  1413 static 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 
       
  1428 static 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 
       
  1436 static 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 
       
  1443 static int CFDataRefObj_hash(CFDataRefObject *self)
       
  1444 {
       
  1445 	/* XXXX Or should we use CFHash?? */
       
  1446 	return (int)self->ob_itself;
       
  1447 }
       
  1448 static 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 
       
  1470 static 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 
       
  1482 PyTypeObject 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 
       
  1531 PyTypeObject CFMutableDataRef_Type;
       
  1532 
       
  1533 #define CFMutableDataRefObj_Check(x) ((x)->ob_type == &CFMutableDataRef_Type || PyObject_TypeCheck((x), &CFMutableDataRef_Type))
       
  1534 
       
  1535 typedef struct CFMutableDataRefObject {
       
  1536 	PyObject_HEAD
       
  1537 	CFMutableDataRef ob_itself;
       
  1538 	void (*ob_freeit)(CFTypeRef ptr);
       
  1539 } CFMutableDataRefObject;
       
  1540 
       
  1541 PyObject *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 
       
  1557 int 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 
       
  1572 static 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 
       
  1582 static 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 
       
  1599 static 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 
       
  1616 static 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 
       
  1636 static 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 
       
  1659 static 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 
       
  1676 static 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 
       
  1693 static 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 
       
  1701 static 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 
       
  1708 static int CFMutableDataRefObj_hash(CFMutableDataRefObject *self)
       
  1709 {
       
  1710 	/* XXXX Or should we use CFHash?? */
       
  1711 	return (int)self->ob_itself;
       
  1712 }
       
  1713 static 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, CFTypeRefObj_Convert, &itself))
       
  1726 	{
       
  1727 		((CFMutableDataRefObject *)_self)->ob_itself = itself;
       
  1728 		return 0;
       
  1729 	}
       
  1730 	return -1;
       
  1731 }
       
  1732 
       
  1733 #define CFMutableDataRefObj_tp_alloc PyType_GenericAlloc
       
  1734 
       
  1735 static PyObject *CFMutableDataRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
       
  1736 {
       
  1737 	PyObject *self;
       
  1738 	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
       
  1739 	((CFMutableDataRefObject *)self)->ob_itself = NULL;
       
  1740 	((CFMutableDataRefObject *)self)->ob_freeit = CFRelease;
       
  1741 	return self;
       
  1742 }
       
  1743 
       
  1744 #define CFMutableDataRefObj_tp_free PyObject_Del
       
  1745 
       
  1746 
       
  1747 PyTypeObject CFMutableDataRef_Type = {
       
  1748 	PyObject_HEAD_INIT(NULL)
       
  1749 	0, /*ob_size*/
       
  1750 	"_CF.CFMutableDataRef", /*tp_name*/
       
  1751 	sizeof(CFMutableDataRefObject), /*tp_basicsize*/
       
  1752 	0, /*tp_itemsize*/
       
  1753 	/* methods */
       
  1754 	(destructor) CFMutableDataRefObj_dealloc, /*tp_dealloc*/
       
  1755 	0, /*tp_print*/
       
  1756 	(getattrfunc)0, /*tp_getattr*/
       
  1757 	(setattrfunc)0, /*tp_setattr*/
       
  1758 	(cmpfunc) CFMutableDataRefObj_compare, /*tp_compare*/
       
  1759 	(reprfunc) CFMutableDataRefObj_repr, /*tp_repr*/
       
  1760 	(PyNumberMethods *)0, /* tp_as_number */
       
  1761 	(PySequenceMethods *)0, /* tp_as_sequence */
       
  1762 	(PyMappingMethods *)0, /* tp_as_mapping */
       
  1763 	(hashfunc) CFMutableDataRefObj_hash, /*tp_hash*/
       
  1764 	0, /*tp_call*/
       
  1765 	0, /*tp_str*/
       
  1766 	PyObject_GenericGetAttr, /*tp_getattro*/
       
  1767 	PyObject_GenericSetAttr, /*tp_setattro */
       
  1768 	0, /*tp_as_buffer*/
       
  1769 	Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
       
  1770 	0, /*tp_doc*/
       
  1771 	0, /*tp_traverse*/
       
  1772 	0, /*tp_clear*/
       
  1773 	0, /*tp_richcompare*/
       
  1774 	0, /*tp_weaklistoffset*/
       
  1775 	0, /*tp_iter*/
       
  1776 	0, /*tp_iternext*/
       
  1777 	CFMutableDataRefObj_methods, /* tp_methods */
       
  1778 	0, /*tp_members*/
       
  1779 	CFMutableDataRefObj_getsetlist, /*tp_getset*/
       
  1780 	0, /*tp_base*/
       
  1781 	0, /*tp_dict*/
       
  1782 	0, /*tp_descr_get*/
       
  1783 	0, /*tp_descr_set*/
       
  1784 	0, /*tp_dictoffset*/
       
  1785 	CFMutableDataRefObj_tp_init, /* tp_init */
       
  1786 	CFMutableDataRefObj_tp_alloc, /* tp_alloc */
       
  1787 	CFMutableDataRefObj_tp_new, /* tp_new */
       
  1788 	CFMutableDataRefObj_tp_free, /* tp_free */
       
  1789 };
       
  1790 
       
  1791 /* ---------------- End object type CFMutableDataRef ---------------- */
       
  1792 
       
  1793 
       
  1794 /* -------------------- Object type CFStringRef --------------------- */
       
  1795 
       
  1796 PyTypeObject CFStringRef_Type;
       
  1797 
       
  1798 #define CFStringRefObj_Check(x) ((x)->ob_type == &CFStringRef_Type || PyObject_TypeCheck((x), &CFStringRef_Type))
       
  1799 
       
  1800 typedef struct CFStringRefObject {
       
  1801 	PyObject_HEAD
       
  1802 	CFStringRef ob_itself;
       
  1803 	void (*ob_freeit)(CFTypeRef ptr);
       
  1804 } CFStringRefObject;
       
  1805 
       
  1806 PyObject *CFStringRefObj_New(CFStringRef itself)
       
  1807 {
       
  1808 	CFStringRefObject *it;
       
  1809 	if (itself == NULL)
       
  1810 	{
       
  1811 		PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
       
  1812 		return NULL;
       
  1813 	}
       
  1814 	it = PyObject_NEW(CFStringRefObject, &CFStringRef_Type);
       
  1815 	if (it == NULL) return NULL;
       
  1816 	/* XXXX Should we tp_init or tp_new our basetype? */
       
  1817 	it->ob_itself = itself;
       
  1818 	it->ob_freeit = CFRelease;
       
  1819 	return (PyObject *)it;
       
  1820 }
       
  1821 
       
  1822 int CFStringRefObj_Convert(PyObject *v, CFStringRef *p_itself)
       
  1823 {
       
  1824 
       
  1825 	if (v == Py_None) { *p_itself = NULL; return 1; }
       
  1826 	if (PyString_Check(v)) {
       
  1827 	    char *cStr;
       
  1828 	    if (!PyArg_Parse(v, "es", "ascii", &cStr))
       
  1829 	        return 0;
       
  1830 	        *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII);
       
  1831 		PyMem_Free(cStr);
       
  1832 	        return 1;
       
  1833 	}
       
  1834 	if (PyUnicode_Check(v)) {
       
  1835 	        /* We use the CF types here, if Python was configured differently that will give an error */
       
  1836 	        CFIndex size = PyUnicode_GetSize(v);
       
  1837 	        UniChar *unichars = PyUnicode_AsUnicode(v);
       
  1838 	        if (!unichars) return 0;
       
  1839 	        *p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size);
       
  1840 	        return 1;
       
  1841 	}
       
  1842 
       
  1843 
       
  1844 	if (!CFStringRefObj_Check(v))
       
  1845 	{
       
  1846 		PyErr_SetString(PyExc_TypeError, "CFStringRef required");
       
  1847 		return 0;
       
  1848 	}
       
  1849 	*p_itself = ((CFStringRefObject *)v)->ob_itself;
       
  1850 	return 1;
       
  1851 }
       
  1852 
       
  1853 static void CFStringRefObj_dealloc(CFStringRefObject *self)
       
  1854 {
       
  1855 	if (self->ob_freeit && self->ob_itself)
       
  1856 	{
       
  1857 		self->ob_freeit((CFTypeRef)self->ob_itself);
       
  1858 		self->ob_itself = NULL;
       
  1859 	}
       
  1860 	CFTypeRef_Type.tp_dealloc((PyObject *)self);
       
  1861 }
       
  1862 
       
  1863 static PyObject *CFStringRefObj_CFStringCreateWithSubstring(CFStringRefObject *_self, PyObject *_args)
       
  1864 {
       
  1865 	PyObject *_res = NULL;
       
  1866 	CFStringRef _rv;
       
  1867 	CFRange range;
       
  1868 	if (!PyArg_ParseTuple(_args, "O&",
       
  1869 	                      CFRange_Convert, &range))
       
  1870 		return NULL;
       
  1871 	_rv = CFStringCreateWithSubstring((CFAllocatorRef)NULL,
       
  1872 	                                  _self->ob_itself,
       
  1873 	                                  range);
       
  1874 	_res = Py_BuildValue("O&",
       
  1875 	                     CFStringRefObj_New, _rv);
       
  1876 	return _res;
       
  1877 }
       
  1878 
       
  1879 static PyObject *CFStringRefObj_CFStringCreateCopy(CFStringRefObject *_self, PyObject *_args)
       
  1880 {
       
  1881 	PyObject *_res = NULL;
       
  1882 	CFStringRef _rv;
       
  1883 	if (!PyArg_ParseTuple(_args, ""))
       
  1884 		return NULL;
       
  1885 	_rv = CFStringCreateCopy((CFAllocatorRef)NULL,
       
  1886 	                         _self->ob_itself);
       
  1887 	_res = Py_BuildValue("O&",
       
  1888 	                     CFStringRefObj_New, _rv);
       
  1889 	return _res;
       
  1890 }
       
  1891 
       
  1892 static PyObject *CFStringRefObj_CFStringGetLength(CFStringRefObject *_self, PyObject *_args)
       
  1893 {
       
  1894 	PyObject *_res = NULL;
       
  1895 	CFIndex _rv;
       
  1896 #ifndef CFStringGetLength
       
  1897 	PyMac_PRECHECK(CFStringGetLength);
       
  1898 #endif
       
  1899 	if (!PyArg_ParseTuple(_args, ""))
       
  1900 		return NULL;
       
  1901 	_rv = CFStringGetLength(_self->ob_itself);
       
  1902 	_res = Py_BuildValue("l",
       
  1903 	                     _rv);
       
  1904 	return _res;
       
  1905 }
       
  1906 
       
  1907 static PyObject *CFStringRefObj_CFStringGetBytes(CFStringRefObject *_self, PyObject *_args)
       
  1908 {
       
  1909 	PyObject *_res = NULL;
       
  1910 	CFIndex _rv;
       
  1911 	CFRange range;
       
  1912 	CFStringEncoding encoding;
       
  1913 	UInt8 lossByte;
       
  1914 	Boolean isExternalRepresentation;
       
  1915 	UInt8 buffer;
       
  1916 	CFIndex maxBufLen;
       
  1917 	CFIndex usedBufLen;
       
  1918 #ifndef CFStringGetBytes
       
  1919 	PyMac_PRECHECK(CFStringGetBytes);
       
  1920 #endif
       
  1921 	if (!PyArg_ParseTuple(_args, "O&lbll",
       
  1922 	                      CFRange_Convert, &range,
       
  1923 	                      &encoding,
       
  1924 	                      &lossByte,
       
  1925 	                      &isExternalRepresentation,
       
  1926 	                      &maxBufLen))
       
  1927 		return NULL;
       
  1928 	_rv = CFStringGetBytes(_self->ob_itself,
       
  1929 	                       range,
       
  1930 	                       encoding,
       
  1931 	                       lossByte,
       
  1932 	                       isExternalRepresentation,
       
  1933 	                       &buffer,
       
  1934 	                       maxBufLen,
       
  1935 	                       &usedBufLen);
       
  1936 	_res = Py_BuildValue("lbl",
       
  1937 	                     _rv,
       
  1938 	                     buffer,
       
  1939 	                     usedBufLen);
       
  1940 	return _res;
       
  1941 }
       
  1942 
       
  1943 static PyObject *CFStringRefObj_CFStringCreateExternalRepresentation(CFStringRefObject *_self, PyObject *_args)
       
  1944 {
       
  1945 	PyObject *_res = NULL;
       
  1946 	CFDataRef _rv;
       
  1947 	CFStringEncoding encoding;
       
  1948 	UInt8 lossByte;
       
  1949 	if (!PyArg_ParseTuple(_args, "lb",
       
  1950 	                      &encoding,
       
  1951 	                      &lossByte))
       
  1952 		return NULL;
       
  1953 	_rv = CFStringCreateExternalRepresentation((CFAllocatorRef)NULL,
       
  1954 	                                           _self->ob_itself,
       
  1955 	                                           encoding,
       
  1956 	                                           lossByte);
       
  1957 	_res = Py_BuildValue("O&",
       
  1958 	                     CFDataRefObj_New, _rv);
       
  1959 	return _res;
       
  1960 }
       
  1961 
       
  1962 static PyObject *CFStringRefObj_CFStringGetSmallestEncoding(CFStringRefObject *_self, PyObject *_args)
       
  1963 {
       
  1964 	PyObject *_res = NULL;
       
  1965 	CFStringEncoding _rv;
       
  1966 #ifndef CFStringGetSmallestEncoding
       
  1967 	PyMac_PRECHECK(CFStringGetSmallestEncoding);
       
  1968 #endif
       
  1969 	if (!PyArg_ParseTuple(_args, ""))
       
  1970 		return NULL;
       
  1971 	_rv = CFStringGetSmallestEncoding(_self->ob_itself);
       
  1972 	_res = Py_BuildValue("l",
       
  1973 	                     _rv);
       
  1974 	return _res;
       
  1975 }
       
  1976 
       
  1977 static PyObject *CFStringRefObj_CFStringGetFastestEncoding(CFStringRefObject *_self, PyObject *_args)
       
  1978 {
       
  1979 	PyObject *_res = NULL;
       
  1980 	CFStringEncoding _rv;
       
  1981 #ifndef CFStringGetFastestEncoding
       
  1982 	PyMac_PRECHECK(CFStringGetFastestEncoding);
       
  1983 #endif
       
  1984 	if (!PyArg_ParseTuple(_args, ""))
       
  1985 		return NULL;
       
  1986 	_rv = CFStringGetFastestEncoding(_self->ob_itself);
       
  1987 	_res = Py_BuildValue("l",
       
  1988 	                     _rv);
       
  1989 	return _res;
       
  1990 }
       
  1991 
       
  1992 static PyObject *CFStringRefObj_CFStringCompareWithOptions(CFStringRefObject *_self, PyObject *_args)
       
  1993 {
       
  1994 	PyObject *_res = NULL;
       
  1995 	CFComparisonResult _rv;
       
  1996 	CFStringRef theString2;
       
  1997 	CFRange rangeToCompare;
       
  1998 	CFOptionFlags compareOptions;
       
  1999 #ifndef CFStringCompareWithOptions
       
  2000 	PyMac_PRECHECK(CFStringCompareWithOptions);
       
  2001 #endif
       
  2002 	if (!PyArg_ParseTuple(_args, "O&O&l",
       
  2003 	                      CFStringRefObj_Convert, &theString2,
       
  2004 	                      CFRange_Convert, &rangeToCompare,
       
  2005 	                      &compareOptions))
       
  2006 		return NULL;
       
  2007 	_rv = CFStringCompareWithOptions(_self->ob_itself,
       
  2008 	                                 theString2,
       
  2009 	                                 rangeToCompare,
       
  2010 	                                 compareOptions);
       
  2011 	_res = Py_BuildValue("l",
       
  2012 	                     _rv);
       
  2013 	return _res;
       
  2014 }
       
  2015 
       
  2016 static PyObject *CFStringRefObj_CFStringCompare(CFStringRefObject *_self, PyObject *_args)
       
  2017 {
       
  2018 	PyObject *_res = NULL;
       
  2019 	CFComparisonResult _rv;
       
  2020 	CFStringRef theString2;
       
  2021 	CFOptionFlags compareOptions;
       
  2022 #ifndef CFStringCompare
       
  2023 	PyMac_PRECHECK(CFStringCompare);
       
  2024 #endif
       
  2025 	if (!PyArg_ParseTuple(_args, "O&l",
       
  2026 	                      CFStringRefObj_Convert, &theString2,
       
  2027 	                      &compareOptions))
       
  2028 		return NULL;
       
  2029 	_rv = CFStringCompare(_self->ob_itself,
       
  2030 	                      theString2,
       
  2031 	                      compareOptions);
       
  2032 	_res = Py_BuildValue("l",
       
  2033 	                     _rv);
       
  2034 	return _res;
       
  2035 }
       
  2036 
       
  2037 static PyObject *CFStringRefObj_CFStringFindWithOptions(CFStringRefObject *_self, PyObject *_args)
       
  2038 {
       
  2039 	PyObject *_res = NULL;
       
  2040 	Boolean _rv;
       
  2041 	CFStringRef stringToFind;
       
  2042 	CFRange rangeToSearch;
       
  2043 	CFOptionFlags searchOptions;
       
  2044 	CFRange result;
       
  2045 #ifndef CFStringFindWithOptions
       
  2046 	PyMac_PRECHECK(CFStringFindWithOptions);
       
  2047 #endif
       
  2048 	if (!PyArg_ParseTuple(_args, "O&O&l",
       
  2049 	                      CFStringRefObj_Convert, &stringToFind,
       
  2050 	                      CFRange_Convert, &rangeToSearch,
       
  2051 	                      &searchOptions))
       
  2052 		return NULL;
       
  2053 	_rv = CFStringFindWithOptions(_self->ob_itself,
       
  2054 	                              stringToFind,
       
  2055 	                              rangeToSearch,
       
  2056 	                              searchOptions,
       
  2057 	                              &result);
       
  2058 	_res = Py_BuildValue("lO&",
       
  2059 	                     _rv,
       
  2060 	                     CFRange_New, result);
       
  2061 	return _res;
       
  2062 }
       
  2063 
       
  2064 static PyObject *CFStringRefObj_CFStringCreateArrayWithFindResults(CFStringRefObject *_self, PyObject *_args)
       
  2065 {
       
  2066 	PyObject *_res = NULL;
       
  2067 	CFArrayRef _rv;
       
  2068 	CFStringRef stringToFind;
       
  2069 	CFRange rangeToSearch;
       
  2070 	CFOptionFlags compareOptions;
       
  2071 	if (!PyArg_ParseTuple(_args, "O&O&l",
       
  2072 	                      CFStringRefObj_Convert, &stringToFind,
       
  2073 	                      CFRange_Convert, &rangeToSearch,
       
  2074 	                      &compareOptions))
       
  2075 		return NULL;
       
  2076 	_rv = CFStringCreateArrayWithFindResults((CFAllocatorRef)NULL,
       
  2077 	                                         _self->ob_itself,
       
  2078 	                                         stringToFind,
       
  2079 	                                         rangeToSearch,
       
  2080 	                                         compareOptions);
       
  2081 	_res = Py_BuildValue("O&",
       
  2082 	                     CFArrayRefObj_New, _rv);
       
  2083 	return _res;
       
  2084 }
       
  2085 
       
  2086 static PyObject *CFStringRefObj_CFStringFind(CFStringRefObject *_self, PyObject *_args)
       
  2087 {
       
  2088 	PyObject *_res = NULL;
       
  2089 	CFRange _rv;
       
  2090 	CFStringRef stringToFind;
       
  2091 	CFOptionFlags compareOptions;
       
  2092 #ifndef CFStringFind
       
  2093 	PyMac_PRECHECK(CFStringFind);
       
  2094 #endif
       
  2095 	if (!PyArg_ParseTuple(_args, "O&l",
       
  2096 	                      CFStringRefObj_Convert, &stringToFind,
       
  2097 	                      &compareOptions))
       
  2098 		return NULL;
       
  2099 	_rv = CFStringFind(_self->ob_itself,
       
  2100 	                   stringToFind,
       
  2101 	                   compareOptions);
       
  2102 	_res = Py_BuildValue("O&",
       
  2103 	                     CFRange_New, _rv);
       
  2104 	return _res;
       
  2105 }
       
  2106 
       
  2107 static PyObject *CFStringRefObj_CFStringHasPrefix(CFStringRefObject *_self, PyObject *_args)
       
  2108 {
       
  2109 	PyObject *_res = NULL;
       
  2110 	Boolean _rv;
       
  2111 	CFStringRef prefix;
       
  2112 #ifndef CFStringHasPrefix
       
  2113 	PyMac_PRECHECK(CFStringHasPrefix);
       
  2114 #endif
       
  2115 	if (!PyArg_ParseTuple(_args, "O&",
       
  2116 	                      CFStringRefObj_Convert, &prefix))
       
  2117 		return NULL;
       
  2118 	_rv = CFStringHasPrefix(_self->ob_itself,
       
  2119 	                        prefix);
       
  2120 	_res = Py_BuildValue("l",
       
  2121 	                     _rv);
       
  2122 	return _res;
       
  2123 }
       
  2124 
       
  2125 static PyObject *CFStringRefObj_CFStringHasSuffix(CFStringRefObject *_self, PyObject *_args)
       
  2126 {
       
  2127 	PyObject *_res = NULL;
       
  2128 	Boolean _rv;
       
  2129 	CFStringRef suffix;
       
  2130 #ifndef CFStringHasSuffix
       
  2131 	PyMac_PRECHECK(CFStringHasSuffix);
       
  2132 #endif
       
  2133 	if (!PyArg_ParseTuple(_args, "O&",
       
  2134 	                      CFStringRefObj_Convert, &suffix))
       
  2135 		return NULL;
       
  2136 	_rv = CFStringHasSuffix(_self->ob_itself,
       
  2137 	                        suffix);
       
  2138 	_res = Py_BuildValue("l",
       
  2139 	                     _rv);
       
  2140 	return _res;
       
  2141 }
       
  2142 
       
  2143 static PyObject *CFStringRefObj_CFStringGetLineBounds(CFStringRefObject *_self, PyObject *_args)
       
  2144 {
       
  2145 	PyObject *_res = NULL;
       
  2146 	CFRange range;
       
  2147 	CFIndex lineBeginIndex;
       
  2148 	CFIndex lineEndIndex;
       
  2149 	CFIndex contentsEndIndex;
       
  2150 #ifndef CFStringGetLineBounds
       
  2151 	PyMac_PRECHECK(CFStringGetLineBounds);
       
  2152 #endif
       
  2153 	if (!PyArg_ParseTuple(_args, "O&",
       
  2154 	                      CFRange_Convert, &range))
       
  2155 		return NULL;
       
  2156 	CFStringGetLineBounds(_self->ob_itself,
       
  2157 	                      range,
       
  2158 	                      &lineBeginIndex,
       
  2159 	                      &lineEndIndex,
       
  2160 	                      &contentsEndIndex);
       
  2161 	_res = Py_BuildValue("lll",
       
  2162 	                     lineBeginIndex,
       
  2163 	                     lineEndIndex,
       
  2164 	                     contentsEndIndex);
       
  2165 	return _res;
       
  2166 }
       
  2167 
       
  2168 static PyObject *CFStringRefObj_CFStringCreateArrayBySeparatingStrings(CFStringRefObject *_self, PyObject *_args)
       
  2169 {
       
  2170 	PyObject *_res = NULL;
       
  2171 	CFArrayRef _rv;
       
  2172 	CFStringRef separatorString;
       
  2173 	if (!PyArg_ParseTuple(_args, "O&",
       
  2174 	                      CFStringRefObj_Convert, &separatorString))
       
  2175 		return NULL;
       
  2176 	_rv = CFStringCreateArrayBySeparatingStrings((CFAllocatorRef)NULL,
       
  2177 	                                             _self->ob_itself,
       
  2178 	                                             separatorString);
       
  2179 	_res = Py_BuildValue("O&",
       
  2180 	                     CFArrayRefObj_New, _rv);
       
  2181 	return _res;
       
  2182 }
       
  2183 
       
  2184 static PyObject *CFStringRefObj_CFStringGetIntValue(CFStringRefObject *_self, PyObject *_args)
       
  2185 {
       
  2186 	PyObject *_res = NULL;
       
  2187 	SInt32 _rv;
       
  2188 #ifndef CFStringGetIntValue
       
  2189 	PyMac_PRECHECK(CFStringGetIntValue);
       
  2190 #endif
       
  2191 	if (!PyArg_ParseTuple(_args, ""))
       
  2192 		return NULL;
       
  2193 	_rv = CFStringGetIntValue(_self->ob_itself);
       
  2194 	_res = Py_BuildValue("l",
       
  2195 	                     _rv);
       
  2196 	return _res;
       
  2197 }
       
  2198 
       
  2199 static PyObject *CFStringRefObj_CFStringGetDoubleValue(CFStringRefObject *_self, PyObject *_args)
       
  2200 {
       
  2201 	PyObject *_res = NULL;
       
  2202 	double _rv;
       
  2203 #ifndef CFStringGetDoubleValue
       
  2204 	PyMac_PRECHECK(CFStringGetDoubleValue);
       
  2205 #endif
       
  2206 	if (!PyArg_ParseTuple(_args, ""))
       
  2207 		return NULL;
       
  2208 	_rv = CFStringGetDoubleValue(_self->ob_itself);
       
  2209 	_res = Py_BuildValue("d",
       
  2210 	                     _rv);
       
  2211 	return _res;
       
  2212 }
       
  2213 
       
  2214 static PyObject *CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStringRefObject *_self, PyObject *_args)
       
  2215 {
       
  2216 	PyObject *_res = NULL;
       
  2217 	CFStringEncoding _rv;
       
  2218 #ifndef CFStringConvertIANACharSetNameToEncoding
       
  2219 	PyMac_PRECHECK(CFStringConvertIANACharSetNameToEncoding);
       
  2220 #endif
       
  2221 	if (!PyArg_ParseTuple(_args, ""))
       
  2222 		return NULL;
       
  2223 	_rv = CFStringConvertIANACharSetNameToEncoding(_self->ob_itself);
       
  2224 	_res = Py_BuildValue("l",
       
  2225 	                     _rv);
       
  2226 	return _res;
       
  2227 }
       
  2228 
       
  2229 static PyObject *CFStringRefObj_CFShowStr(CFStringRefObject *_self, PyObject *_args)
       
  2230 {
       
  2231 	PyObject *_res = NULL;
       
  2232 #ifndef CFShowStr
       
  2233 	PyMac_PRECHECK(CFShowStr);
       
  2234 #endif
       
  2235 	if (!PyArg_ParseTuple(_args, ""))
       
  2236 		return NULL;
       
  2237 	CFShowStr(_self->ob_itself);
       
  2238 	Py_INCREF(Py_None);
       
  2239 	_res = Py_None;
       
  2240 	return _res;
       
  2241 }
       
  2242 
       
  2243 static PyObject *CFStringRefObj_CFURLCreateWithString(CFStringRefObject *_self, PyObject *_args)
       
  2244 {
       
  2245 	PyObject *_res = NULL;
       
  2246 	CFURLRef _rv;
       
  2247 	CFURLRef baseURL;
       
  2248 	if (!PyArg_ParseTuple(_args, "O&",
       
  2249 	                      OptionalCFURLRefObj_Convert, &baseURL))
       
  2250 		return NULL;
       
  2251 	_rv = CFURLCreateWithString((CFAllocatorRef)NULL,
       
  2252 	                            _self->ob_itself,
       
  2253 	                            baseURL);
       
  2254 	_res = Py_BuildValue("O&",
       
  2255 	                     CFURLRefObj_New, _rv);
       
  2256 	return _res;
       
  2257 }
       
  2258 
       
  2259 static PyObject *CFStringRefObj_CFURLCreateWithFileSystemPath(CFStringRefObject *_self, PyObject *_args)
       
  2260 {
       
  2261 	PyObject *_res = NULL;
       
  2262 	CFURLRef _rv;
       
  2263 	CFURLPathStyle pathStyle;
       
  2264 	Boolean isDirectory;
       
  2265 	if (!PyArg_ParseTuple(_args, "ll",
       
  2266 	                      &pathStyle,
       
  2267 	                      &isDirectory))
       
  2268 		return NULL;
       
  2269 	_rv = CFURLCreateWithFileSystemPath((CFAllocatorRef)NULL,
       
  2270 	                                    _self->ob_itself,
       
  2271 	                                    pathStyle,
       
  2272 	                                    isDirectory);
       
  2273 	_res = Py_BuildValue("O&",
       
  2274 	                     CFURLRefObj_New, _rv);
       
  2275 	return _res;
       
  2276 }
       
  2277 
       
  2278 static PyObject *CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase(CFStringRefObject *_self, PyObject *_args)
       
  2279 {
       
  2280 	PyObject *_res = NULL;
       
  2281 	CFURLRef _rv;
       
  2282 	CFURLPathStyle pathStyle;
       
  2283 	Boolean isDirectory;
       
  2284 	CFURLRef baseURL;
       
  2285 	if (!PyArg_ParseTuple(_args, "llO&",
       
  2286 	                      &pathStyle,
       
  2287 	                      &isDirectory,
       
  2288 	                      OptionalCFURLRefObj_Convert, &baseURL))
       
  2289 		return NULL;
       
  2290 	_rv = CFURLCreateWithFileSystemPathRelativeToBase((CFAllocatorRef)NULL,
       
  2291 	                                                  _self->ob_itself,
       
  2292 	                                                  pathStyle,
       
  2293 	                                                  isDirectory,
       
  2294 	                                                  baseURL);
       
  2295 	_res = Py_BuildValue("O&",
       
  2296 	                     CFURLRefObj_New, _rv);
       
  2297 	return _res;
       
  2298 }
       
  2299 
       
  2300 static PyObject *CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes(CFStringRefObject *_self, PyObject *_args)
       
  2301 {
       
  2302 	PyObject *_res = NULL;
       
  2303 	CFStringRef _rv;
       
  2304 	CFStringRef charactersToLeaveEscaped;
       
  2305 	if (!PyArg_ParseTuple(_args, "O&",
       
  2306 	                      CFStringRefObj_Convert, &charactersToLeaveEscaped))
       
  2307 		return NULL;
       
  2308 	_rv = CFURLCreateStringByReplacingPercentEscapes((CFAllocatorRef)NULL,
       
  2309 	                                                 _self->ob_itself,
       
  2310 	                                                 charactersToLeaveEscaped);
       
  2311 	_res = Py_BuildValue("O&",
       
  2312 	                     CFStringRefObj_New, _rv);
       
  2313 	return _res;
       
  2314 }
       
  2315 
       
  2316 static PyObject *CFStringRefObj_CFURLCreateStringByAddingPercentEscapes(CFStringRefObject *_self, PyObject *_args)
       
  2317 {
       
  2318 	PyObject *_res = NULL;
       
  2319 	CFStringRef _rv;
       
  2320 	CFStringRef charactersToLeaveUnescaped;
       
  2321 	CFStringRef legalURLCharactersToBeEscaped;
       
  2322 	CFStringEncoding encoding;
       
  2323 	if (!PyArg_ParseTuple(_args, "O&O&l",
       
  2324 	                      CFStringRefObj_Convert, &charactersToLeaveUnescaped,
       
  2325 	                      CFStringRefObj_Convert, &legalURLCharactersToBeEscaped,
       
  2326 	                      &encoding))
       
  2327 		return NULL;
       
  2328 	_rv = CFURLCreateStringByAddingPercentEscapes((CFAllocatorRef)NULL,
       
  2329 	                                              _self->ob_itself,
       
  2330 	                                              charactersToLeaveUnescaped,
       
  2331 	                                              legalURLCharactersToBeEscaped,
       
  2332 	                                              encoding);
       
  2333 	_res = Py_BuildValue("O&",
       
  2334 	                     CFStringRefObj_New, _rv);
       
  2335 	return _res;
       
  2336 }
       
  2337 
       
  2338 static PyObject *CFStringRefObj_CFStringGetString(CFStringRefObject *_self, PyObject *_args)
       
  2339 {
       
  2340 	PyObject *_res = NULL;
       
  2341 
       
  2342 	int size = CFStringGetLength(_self->ob_itself)+1;
       
  2343 	char *data = malloc(size);
       
  2344 
       
  2345 	if( data == NULL ) return PyErr_NoMemory();
       
  2346 	if ( CFStringGetCString(_self->ob_itself, data, size, 0) ) {
       
  2347 	        _res = (PyObject *)PyString_FromString(data);
       
  2348 	} else {
       
  2349 	        PyErr_SetString(PyExc_RuntimeError, "CFStringGetCString could not fit the string");
       
  2350 	        _res = NULL;
       
  2351 	}
       
  2352 	free(data);
       
  2353 	return _res;
       
  2354 
       
  2355 }
       
  2356 
       
  2357 static PyObject *CFStringRefObj_CFStringGetUnicode(CFStringRefObject *_self, PyObject *_args)
       
  2358 {
       
  2359 	PyObject *_res = NULL;
       
  2360 
       
  2361 	int size = CFStringGetLength(_self->ob_itself)+1;
       
  2362 	Py_UNICODE *data = malloc(size*sizeof(Py_UNICODE));
       
  2363 	CFRange range;
       
  2364 
       
  2365 	range.location = 0;
       
  2366 	range.length = size;
       
  2367 	if( data == NULL ) return PyErr_NoMemory();
       
  2368 	CFStringGetCharacters(_self->ob_itself, range, data);
       
  2369 	_res = (PyObject *)PyUnicode_FromUnicode(data, size-1);
       
  2370 	free(data);
       
  2371 	return _res;
       
  2372 
       
  2373 }
       
  2374 
       
  2375 static PyMethodDef CFStringRefObj_methods[] = {
       
  2376 	{"CFStringCreateWithSubstring", (PyCFunction)CFStringRefObj_CFStringCreateWithSubstring, 1,
       
  2377 	 PyDoc_STR("(CFRange range) -> (CFStringRef _rv)")},
       
  2378 	{"CFStringCreateCopy", (PyCFunction)CFStringRefObj_CFStringCreateCopy, 1,
       
  2379 	 PyDoc_STR("() -> (CFStringRef _rv)")},
       
  2380 	{"CFStringGetLength", (PyCFunction)CFStringRefObj_CFStringGetLength, 1,
       
  2381 	 PyDoc_STR("() -> (CFIndex _rv)")},
       
  2382 	{"CFStringGetBytes", (PyCFunction)CFStringRefObj_CFStringGetBytes, 1,
       
  2383 	 PyDoc_STR("(CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, CFIndex maxBufLen) -> (CFIndex _rv, UInt8 buffer, CFIndex usedBufLen)")},
       
  2384 	{"CFStringCreateExternalRepresentation", (PyCFunction)CFStringRefObj_CFStringCreateExternalRepresentation, 1,
       
  2385 	 PyDoc_STR("(CFStringEncoding encoding, UInt8 lossByte) -> (CFDataRef _rv)")},
       
  2386 	{"CFStringGetSmallestEncoding", (PyCFunction)CFStringRefObj_CFStringGetSmallestEncoding, 1,
       
  2387 	 PyDoc_STR("() -> (CFStringEncoding _rv)")},
       
  2388 	{"CFStringGetFastestEncoding", (PyCFunction)CFStringRefObj_CFStringGetFastestEncoding, 1,
       
  2389 	 PyDoc_STR("() -> (CFStringEncoding _rv)")},
       
  2390 	{"CFStringCompareWithOptions", (PyCFunction)CFStringRefObj_CFStringCompareWithOptions, 1,
       
  2391 	 PyDoc_STR("(CFStringRef theString2, CFRange rangeToCompare, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)")},
       
  2392 	{"CFStringCompare", (PyCFunction)CFStringRefObj_CFStringCompare, 1,
       
  2393 	 PyDoc_STR("(CFStringRef theString2, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)")},
       
  2394 	{"CFStringFindWithOptions", (PyCFunction)CFStringRefObj_CFStringFindWithOptions, 1,
       
  2395 	 PyDoc_STR("(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags searchOptions) -> (Boolean _rv, CFRange result)")},
       
  2396 	{"CFStringCreateArrayWithFindResults", (PyCFunction)CFStringRefObj_CFStringCreateArrayWithFindResults, 1,
       
  2397 	 PyDoc_STR("(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions) -> (CFArrayRef _rv)")},
       
  2398 	{"CFStringFind", (PyCFunction)CFStringRefObj_CFStringFind, 1,
       
  2399 	 PyDoc_STR("(CFStringRef stringToFind, CFOptionFlags compareOptions) -> (CFRange _rv)")},
       
  2400 	{"CFStringHasPrefix", (PyCFunction)CFStringRefObj_CFStringHasPrefix, 1,
       
  2401 	 PyDoc_STR("(CFStringRef prefix) -> (Boolean _rv)")},
       
  2402 	{"CFStringHasSuffix", (PyCFunction)CFStringRefObj_CFStringHasSuffix, 1,
       
  2403 	 PyDoc_STR("(CFStringRef suffix) -> (Boolean _rv)")},
       
  2404 	{"CFStringGetLineBounds", (PyCFunction)CFStringRefObj_CFStringGetLineBounds, 1,
       
  2405 	 PyDoc_STR("(CFRange range) -> (CFIndex lineBeginIndex, CFIndex lineEndIndex, CFIndex contentsEndIndex)")},
       
  2406 	{"CFStringCreateArrayBySeparatingStrings", (PyCFunction)CFStringRefObj_CFStringCreateArrayBySeparatingStrings, 1,
       
  2407 	 PyDoc_STR("(CFStringRef separatorString) -> (CFArrayRef _rv)")},
       
  2408 	{"CFStringGetIntValue", (PyCFunction)CFStringRefObj_CFStringGetIntValue, 1,
       
  2409 	 PyDoc_STR("() -> (SInt32 _rv)")},
       
  2410 	{"CFStringGetDoubleValue", (PyCFunction)CFStringRefObj_CFStringGetDoubleValue, 1,
       
  2411 	 PyDoc_STR("() -> (double _rv)")},
       
  2412 	{"CFStringConvertIANACharSetNameToEncoding", (PyCFunction)CFStringRefObj_CFStringConvertIANACharSetNameToEncoding, 1,
       
  2413 	 PyDoc_STR("() -> (CFStringEncoding _rv)")},
       
  2414 	{"CFShowStr", (PyCFunction)CFStringRefObj_CFShowStr, 1,
       
  2415 	 PyDoc_STR("() -> None")},
       
  2416 	{"CFURLCreateWithString", (PyCFunction)CFStringRefObj_CFURLCreateWithString, 1,
       
  2417 	 PyDoc_STR("(CFURLRef baseURL) -> (CFURLRef _rv)")},
       
  2418 	{"CFURLCreateWithFileSystemPath", (PyCFunction)CFStringRefObj_CFURLCreateWithFileSystemPath, 1,
       
  2419 	 PyDoc_STR("(CFURLPathStyle pathStyle, Boolean isDirectory) -> (CFURLRef _rv)")},
       
  2420 	{"CFURLCreateWithFileSystemPathRelativeToBase", (PyCFunction)CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase, 1,
       
  2421 	 PyDoc_STR("(CFURLPathStyle pathStyle, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)")},
       
  2422 	{"CFURLCreateStringByReplacingPercentEscapes", (PyCFunction)CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes, 1,
       
  2423 	 PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")},
       
  2424 	{"CFURLCreateStringByAddingPercentEscapes", (PyCFunction)CFStringRefObj_CFURLCreateStringByAddingPercentEscapes, 1,
       
  2425 	 PyDoc_STR("(CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding) -> (CFStringRef _rv)")},
       
  2426 	{"CFStringGetString", (PyCFunction)CFStringRefObj_CFStringGetString, 1,
       
  2427 	 PyDoc_STR("() -> (string _rv)")},
       
  2428 	{"CFStringGetUnicode", (PyCFunction)CFStringRefObj_CFStringGetUnicode, 1,
       
  2429 	 PyDoc_STR("() -> (unicode _rv)")},
       
  2430 	{NULL, NULL, 0}
       
  2431 };
       
  2432 
       
  2433 #define CFStringRefObj_getsetlist NULL
       
  2434 
       
  2435 
       
  2436 static int CFStringRefObj_compare(CFStringRefObject *self, CFStringRefObject *other)
       
  2437 {
       
  2438 	/* XXXX Or should we use CFEqual?? */
       
  2439 	if ( self->ob_itself > other->ob_itself ) return 1;
       
  2440 	if ( self->ob_itself < other->ob_itself ) return -1;
       
  2441 	return 0;
       
  2442 }
       
  2443 
       
  2444 static PyObject * CFStringRefObj_repr(CFStringRefObject *self)
       
  2445 {
       
  2446 	char buf[100];
       
  2447 	sprintf(buf, "<CFStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
       
  2448 	return PyString_FromString(buf);
       
  2449 }
       
  2450 
       
  2451 static int CFStringRefObj_hash(CFStringRefObject *self)
       
  2452 {
       
  2453 	/* XXXX Or should we use CFHash?? */
       
  2454 	return (int)self->ob_itself;
       
  2455 }
       
  2456 static int CFStringRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
       
  2457 {
       
  2458 	CFStringRef itself;
       
  2459 	char *kw[] = {"itself", 0};
       
  2460 
       
  2461 	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFStringRefObj_Convert, &itself))
       
  2462 	{
       
  2463 		((CFStringRefObject *)_self)->ob_itself = itself;
       
  2464 		return 0;
       
  2465 	}
       
  2466 
       
  2467 	/* Any CFTypeRef descendent is allowed as initializer too */
       
  2468 	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself))
       
  2469 	{
       
  2470 		((CFStringRefObject *)_self)->ob_itself = itself;
       
  2471 		return 0;
       
  2472 	}
       
  2473 	return -1;
       
  2474 }
       
  2475 
       
  2476 #define CFStringRefObj_tp_alloc PyType_GenericAlloc
       
  2477 
       
  2478 static PyObject *CFStringRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
       
  2479 {
       
  2480 	PyObject *self;
       
  2481 	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
       
  2482 	((CFStringRefObject *)self)->ob_itself = NULL;
       
  2483 	((CFStringRefObject *)self)->ob_freeit = CFRelease;
       
  2484 	return self;
       
  2485 }
       
  2486 
       
  2487 #define CFStringRefObj_tp_free PyObject_Del
       
  2488 
       
  2489 
       
  2490 PyTypeObject CFStringRef_Type = {
       
  2491 	PyObject_HEAD_INIT(NULL)
       
  2492 	0, /*ob_size*/
       
  2493 	"_CF.CFStringRef", /*tp_name*/
       
  2494 	sizeof(CFStringRefObject), /*tp_basicsize*/
       
  2495 	0, /*tp_itemsize*/
       
  2496 	/* methods */
       
  2497 	(destructor) CFStringRefObj_dealloc, /*tp_dealloc*/
       
  2498 	0, /*tp_print*/
       
  2499 	(getattrfunc)0, /*tp_getattr*/
       
  2500 	(setattrfunc)0, /*tp_setattr*/
       
  2501 	(cmpfunc) CFStringRefObj_compare, /*tp_compare*/
       
  2502 	(reprfunc) CFStringRefObj_repr, /*tp_repr*/
       
  2503 	(PyNumberMethods *)0, /* tp_as_number */
       
  2504 	(PySequenceMethods *)0, /* tp_as_sequence */
       
  2505 	(PyMappingMethods *)0, /* tp_as_mapping */
       
  2506 	(hashfunc) CFStringRefObj_hash, /*tp_hash*/
       
  2507 	0, /*tp_call*/
       
  2508 	0, /*tp_str*/
       
  2509 	PyObject_GenericGetAttr, /*tp_getattro*/
       
  2510 	PyObject_GenericSetAttr, /*tp_setattro */
       
  2511 	0, /*tp_as_buffer*/
       
  2512 	Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
       
  2513 	0, /*tp_doc*/
       
  2514 	0, /*tp_traverse*/
       
  2515 	0, /*tp_clear*/
       
  2516 	0, /*tp_richcompare*/
       
  2517 	0, /*tp_weaklistoffset*/
       
  2518 	0, /*tp_iter*/
       
  2519 	0, /*tp_iternext*/
       
  2520 	CFStringRefObj_methods, /* tp_methods */
       
  2521 	0, /*tp_members*/
       
  2522 	CFStringRefObj_getsetlist, /*tp_getset*/
       
  2523 	0, /*tp_base*/
       
  2524 	0, /*tp_dict*/
       
  2525 	0, /*tp_descr_get*/
       
  2526 	0, /*tp_descr_set*/
       
  2527 	0, /*tp_dictoffset*/
       
  2528 	CFStringRefObj_tp_init, /* tp_init */
       
  2529 	CFStringRefObj_tp_alloc, /* tp_alloc */
       
  2530 	CFStringRefObj_tp_new, /* tp_new */
       
  2531 	CFStringRefObj_tp_free, /* tp_free */
       
  2532 };
       
  2533 
       
  2534 /* ------------------ End object type CFStringRef ------------------- */
       
  2535 
       
  2536 
       
  2537 /* ----------------- Object type CFMutableStringRef ----------------- */
       
  2538 
       
  2539 PyTypeObject CFMutableStringRef_Type;
       
  2540 
       
  2541 #define CFMutableStringRefObj_Check(x) ((x)->ob_type == &CFMutableStringRef_Type || PyObject_TypeCheck((x), &CFMutableStringRef_Type))
       
  2542 
       
  2543 typedef struct CFMutableStringRefObject {
       
  2544 	PyObject_HEAD
       
  2545 	CFMutableStringRef ob_itself;
       
  2546 	void (*ob_freeit)(CFTypeRef ptr);
       
  2547 } CFMutableStringRefObject;
       
  2548 
       
  2549 PyObject *CFMutableStringRefObj_New(CFMutableStringRef itself)
       
  2550 {
       
  2551 	CFMutableStringRefObject *it;
       
  2552 	if (itself == NULL)
       
  2553 	{
       
  2554 		PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
       
  2555 		return NULL;
       
  2556 	}
       
  2557 	it = PyObject_NEW(CFMutableStringRefObject, &CFMutableStringRef_Type);
       
  2558 	if (it == NULL) return NULL;
       
  2559 	/* XXXX Should we tp_init or tp_new our basetype? */
       
  2560 	it->ob_itself = itself;
       
  2561 	it->ob_freeit = CFRelease;
       
  2562 	return (PyObject *)it;
       
  2563 }
       
  2564 
       
  2565 int CFMutableStringRefObj_Convert(PyObject *v, CFMutableStringRef *p_itself)
       
  2566 {
       
  2567 
       
  2568 	if (v == Py_None) { *p_itself = NULL; return 1; }
       
  2569 	/* Check for other CF objects here */
       
  2570 
       
  2571 	if (!CFMutableStringRefObj_Check(v))
       
  2572 	{
       
  2573 		PyErr_SetString(PyExc_TypeError, "CFMutableStringRef required");
       
  2574 		return 0;
       
  2575 	}
       
  2576 	*p_itself = ((CFMutableStringRefObject *)v)->ob_itself;
       
  2577 	return 1;
       
  2578 }
       
  2579 
       
  2580 static void CFMutableStringRefObj_dealloc(CFMutableStringRefObject *self)
       
  2581 {
       
  2582 	if (self->ob_freeit && self->ob_itself)
       
  2583 	{
       
  2584 		self->ob_freeit((CFTypeRef)self->ob_itself);
       
  2585 		self->ob_itself = NULL;
       
  2586 	}
       
  2587 	CFStringRef_Type.tp_dealloc((PyObject *)self);
       
  2588 }
       
  2589 
       
  2590 static PyObject *CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject *_self, PyObject *_args)
       
  2591 {
       
  2592 	PyObject *_res = NULL;
       
  2593 	CFStringRef appendedString;
       
  2594 #ifndef CFStringAppend
       
  2595 	PyMac_PRECHECK(CFStringAppend);
       
  2596 #endif
       
  2597 	if (!PyArg_ParseTuple(_args, "O&",
       
  2598 	                      CFStringRefObj_Convert, &appendedString))
       
  2599 		return NULL;
       
  2600 	CFStringAppend(_self->ob_itself,
       
  2601 	               appendedString);
       
  2602 	Py_INCREF(Py_None);
       
  2603 	_res = Py_None;
       
  2604 	return _res;
       
  2605 }
       
  2606 
       
  2607 static PyObject *CFMutableStringRefObj_CFStringAppendCharacters(CFMutableStringRefObject *_self, PyObject *_args)
       
  2608 {
       
  2609 	PyObject *_res = NULL;
       
  2610 	UniChar *chars__in__;
       
  2611 	UniCharCount chars__len__;
       
  2612 	int chars__in_len__;
       
  2613 #ifndef CFStringAppendCharacters
       
  2614 	PyMac_PRECHECK(CFStringAppendCharacters);
       
  2615 #endif
       
  2616 	if (!PyArg_ParseTuple(_args, "u#",
       
  2617 	                      &chars__in__, &chars__in_len__))
       
  2618 		return NULL;
       
  2619 	chars__len__ = chars__in_len__;
       
  2620 	CFStringAppendCharacters(_self->ob_itself,
       
  2621 	                         chars__in__, chars__len__);
       
  2622 	Py_INCREF(Py_None);
       
  2623 	_res = Py_None;
       
  2624 	return _res;
       
  2625 }
       
  2626 
       
  2627 static PyObject *CFMutableStringRefObj_CFStringAppendPascalString(CFMutableStringRefObject *_self, PyObject *_args)
       
  2628 {
       
  2629 	PyObject *_res = NULL;
       
  2630 	Str255 pStr;
       
  2631 	CFStringEncoding encoding;
       
  2632 #ifndef CFStringAppendPascalString
       
  2633 	PyMac_PRECHECK(CFStringAppendPascalString);
       
  2634 #endif
       
  2635 	if (!PyArg_ParseTuple(_args, "O&l",
       
  2636 	                      PyMac_GetStr255, pStr,
       
  2637 	                      &encoding))
       
  2638 		return NULL;
       
  2639 	CFStringAppendPascalString(_self->ob_itself,
       
  2640 	                           pStr,
       
  2641 	                           encoding);
       
  2642 	Py_INCREF(Py_None);
       
  2643 	_res = Py_None;
       
  2644 	return _res;
       
  2645 }
       
  2646 
       
  2647 static PyObject *CFMutableStringRefObj_CFStringAppendCString(CFMutableStringRefObject *_self, PyObject *_args)
       
  2648 {
       
  2649 	PyObject *_res = NULL;
       
  2650 	char* cStr;
       
  2651 	CFStringEncoding encoding;
       
  2652 #ifndef CFStringAppendCString
       
  2653 	PyMac_PRECHECK(CFStringAppendCString);
       
  2654 #endif
       
  2655 	if (!PyArg_ParseTuple(_args, "sl",
       
  2656 	                      &cStr,
       
  2657 	                      &encoding))
       
  2658 		return NULL;
       
  2659 	CFStringAppendCString(_self->ob_itself,
       
  2660 	                      cStr,
       
  2661 	                      encoding);
       
  2662 	Py_INCREF(Py_None);
       
  2663 	_res = Py_None;
       
  2664 	return _res;
       
  2665 }
       
  2666 
       
  2667 static PyObject *CFMutableStringRefObj_CFStringInsert(CFMutableStringRefObject *_self, PyObject *_args)
       
  2668 {
       
  2669 	PyObject *_res = NULL;
       
  2670 	CFIndex idx;
       
  2671 	CFStringRef insertedStr;
       
  2672 #ifndef CFStringInsert
       
  2673 	PyMac_PRECHECK(CFStringInsert);
       
  2674 #endif
       
  2675 	if (!PyArg_ParseTuple(_args, "lO&",
       
  2676 	                      &idx,
       
  2677 	                      CFStringRefObj_Convert, &insertedStr))
       
  2678 		return NULL;
       
  2679 	CFStringInsert(_self->ob_itself,
       
  2680 	               idx,
       
  2681 	               insertedStr);
       
  2682 	Py_INCREF(Py_None);
       
  2683 	_res = Py_None;
       
  2684 	return _res;
       
  2685 }
       
  2686 
       
  2687 static PyObject *CFMutableStringRefObj_CFStringDelete(CFMutableStringRefObject *_self, PyObject *_args)
       
  2688 {
       
  2689 	PyObject *_res = NULL;
       
  2690 	CFRange range;
       
  2691 #ifndef CFStringDelete
       
  2692 	PyMac_PRECHECK(CFStringDelete);
       
  2693 #endif
       
  2694 	if (!PyArg_ParseTuple(_args, "O&",
       
  2695 	                      CFRange_Convert, &range))
       
  2696 		return NULL;
       
  2697 	CFStringDelete(_self->ob_itself,
       
  2698 	               range);
       
  2699 	Py_INCREF(Py_None);
       
  2700 	_res = Py_None;
       
  2701 	return _res;
       
  2702 }
       
  2703 
       
  2704 static PyObject *CFMutableStringRefObj_CFStringReplace(CFMutableStringRefObject *_self, PyObject *_args)
       
  2705 {
       
  2706 	PyObject *_res = NULL;
       
  2707 	CFRange range;
       
  2708 	CFStringRef replacement;
       
  2709 #ifndef CFStringReplace
       
  2710 	PyMac_PRECHECK(CFStringReplace);
       
  2711 #endif
       
  2712 	if (!PyArg_ParseTuple(_args, "O&O&",
       
  2713 	                      CFRange_Convert, &range,
       
  2714 	                      CFStringRefObj_Convert, &replacement))
       
  2715 		return NULL;
       
  2716 	CFStringReplace(_self->ob_itself,
       
  2717 	                range,
       
  2718 	                replacement);
       
  2719 	Py_INCREF(Py_None);
       
  2720 	_res = Py_None;
       
  2721 	return _res;
       
  2722 }
       
  2723 
       
  2724 static PyObject *CFMutableStringRefObj_CFStringReplaceAll(CFMutableStringRefObject *_self, PyObject *_args)
       
  2725 {
       
  2726 	PyObject *_res = NULL;
       
  2727 	CFStringRef replacement;
       
  2728 #ifndef CFStringReplaceAll
       
  2729 	PyMac_PRECHECK(CFStringReplaceAll);
       
  2730 #endif
       
  2731 	if (!PyArg_ParseTuple(_args, "O&",
       
  2732 	                      CFStringRefObj_Convert, &replacement))
       
  2733 		return NULL;
       
  2734 	CFStringReplaceAll(_self->ob_itself,
       
  2735 	                   replacement);
       
  2736 	Py_INCREF(Py_None);
       
  2737 	_res = Py_None;
       
  2738 	return _res;
       
  2739 }
       
  2740 
       
  2741 static PyObject *CFMutableStringRefObj_CFStringPad(CFMutableStringRefObject *_self, PyObject *_args)
       
  2742 {
       
  2743 	PyObject *_res = NULL;
       
  2744 	CFStringRef padString;
       
  2745 	CFIndex length;
       
  2746 	CFIndex indexIntoPad;
       
  2747 #ifndef CFStringPad
       
  2748 	PyMac_PRECHECK(CFStringPad);
       
  2749 #endif
       
  2750 	if (!PyArg_ParseTuple(_args, "O&ll",
       
  2751 	                      CFStringRefObj_Convert, &padString,
       
  2752 	                      &length,
       
  2753 	                      &indexIntoPad))
       
  2754 		return NULL;
       
  2755 	CFStringPad(_self->ob_itself,
       
  2756 	            padString,
       
  2757 	            length,
       
  2758 	            indexIntoPad);
       
  2759 	Py_INCREF(Py_None);
       
  2760 	_res = Py_None;
       
  2761 	return _res;
       
  2762 }
       
  2763 
       
  2764 static PyObject *CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject *_self, PyObject *_args)
       
  2765 {
       
  2766 	PyObject *_res = NULL;
       
  2767 	CFStringRef trimString;
       
  2768 #ifndef CFStringTrim
       
  2769 	PyMac_PRECHECK(CFStringTrim);
       
  2770 #endif
       
  2771 	if (!PyArg_ParseTuple(_args, "O&",
       
  2772 	                      CFStringRefObj_Convert, &trimString))
       
  2773 		return NULL;
       
  2774 	CFStringTrim(_self->ob_itself,
       
  2775 	             trimString);
       
  2776 	Py_INCREF(Py_None);
       
  2777 	_res = Py_None;
       
  2778 	return _res;
       
  2779 }
       
  2780 
       
  2781 static PyObject *CFMutableStringRefObj_CFStringTrimWhitespace(CFMutableStringRefObject *_self, PyObject *_args)
       
  2782 {
       
  2783 	PyObject *_res = NULL;
       
  2784 #ifndef CFStringTrimWhitespace
       
  2785 	PyMac_PRECHECK(CFStringTrimWhitespace);
       
  2786 #endif
       
  2787 	if (!PyArg_ParseTuple(_args, ""))
       
  2788 		return NULL;
       
  2789 	CFStringTrimWhitespace(_self->ob_itself);
       
  2790 	Py_INCREF(Py_None);
       
  2791 	_res = Py_None;
       
  2792 	return _res;
       
  2793 }
       
  2794 
       
  2795 static PyMethodDef CFMutableStringRefObj_methods[] = {
       
  2796 	{"CFStringAppend", (PyCFunction)CFMutableStringRefObj_CFStringAppend, 1,
       
  2797 	 PyDoc_STR("(CFStringRef appendedString) -> None")},
       
  2798 	{"CFStringAppendCharacters", (PyCFunction)CFMutableStringRefObj_CFStringAppendCharacters, 1,
       
  2799 	 PyDoc_STR("(Buffer chars) -> None")},
       
  2800 	{"CFStringAppendPascalString", (PyCFunction)CFMutableStringRefObj_CFStringAppendPascalString, 1,
       
  2801 	 PyDoc_STR("(Str255 pStr, CFStringEncoding encoding) -> None")},
       
  2802 	{"CFStringAppendCString", (PyCFunction)CFMutableStringRefObj_CFStringAppendCString, 1,
       
  2803 	 PyDoc_STR("(char* cStr, CFStringEncoding encoding) -> None")},
       
  2804 	{"CFStringInsert", (PyCFunction)CFMutableStringRefObj_CFStringInsert, 1,
       
  2805 	 PyDoc_STR("(CFIndex idx, CFStringRef insertedStr) -> None")},
       
  2806 	{"CFStringDelete", (PyCFunction)CFMutableStringRefObj_CFStringDelete, 1,
       
  2807 	 PyDoc_STR("(CFRange range) -> None")},
       
  2808 	{"CFStringReplace", (PyCFunction)CFMutableStringRefObj_CFStringReplace, 1,
       
  2809 	 PyDoc_STR("(CFRange range, CFStringRef replacement) -> None")},
       
  2810 	{"CFStringReplaceAll", (PyCFunction)CFMutableStringRefObj_CFStringReplaceAll, 1,
       
  2811 	 PyDoc_STR("(CFStringRef replacement) -> None")},
       
  2812 	{"CFStringPad", (PyCFunction)CFMutableStringRefObj_CFStringPad, 1,
       
  2813 	 PyDoc_STR("(CFStringRef padString, CFIndex length, CFIndex indexIntoPad) -> None")},
       
  2814 	{"CFStringTrim", (PyCFunction)CFMutableStringRefObj_CFStringTrim, 1,
       
  2815 	 PyDoc_STR("(CFStringRef trimString) -> None")},
       
  2816 	{"CFStringTrimWhitespace", (PyCFunction)CFMutableStringRefObj_CFStringTrimWhitespace, 1,
       
  2817 	 PyDoc_STR("() -> None")},
       
  2818 	{NULL, NULL, 0}
       
  2819 };
       
  2820 
       
  2821 #define CFMutableStringRefObj_getsetlist NULL
       
  2822 
       
  2823 
       
  2824 static int CFMutableStringRefObj_compare(CFMutableStringRefObject *self, CFMutableStringRefObject *other)
       
  2825 {
       
  2826 	/* XXXX Or should we use CFEqual?? */
       
  2827 	if ( self->ob_itself > other->ob_itself ) return 1;
       
  2828 	if ( self->ob_itself < other->ob_itself ) return -1;
       
  2829 	return 0;
       
  2830 }
       
  2831 
       
  2832 static PyObject * CFMutableStringRefObj_repr(CFMutableStringRefObject *self)
       
  2833 {
       
  2834 	char buf[100];
       
  2835 	sprintf(buf, "<CFMutableStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
       
  2836 	return PyString_FromString(buf);
       
  2837 }
       
  2838 
       
  2839 static int CFMutableStringRefObj_hash(CFMutableStringRefObject *self)
       
  2840 {
       
  2841 	/* XXXX Or should we use CFHash?? */
       
  2842 	return (int)self->ob_itself;
       
  2843 }
       
  2844 static int CFMutableStringRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
       
  2845 {
       
  2846 	CFMutableStringRef itself;
       
  2847 	char *kw[] = {"itself", 0};
       
  2848 
       
  2849 	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFMutableStringRefObj_Convert, &itself))
       
  2850 	{
       
  2851 		((CFMutableStringRefObject *)_self)->ob_itself = itself;
       
  2852 		return 0;
       
  2853 	}
       
  2854 
       
  2855 	/* Any CFTypeRef descendent is allowed as initializer too */
       
  2856 	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself))
       
  2857 	{
       
  2858 		((CFMutableStringRefObject *)_self)->ob_itself = itself;
       
  2859 		return 0;
       
  2860 	}
       
  2861 	return -1;
       
  2862 }
       
  2863 
       
  2864 #define CFMutableStringRefObj_tp_alloc PyType_GenericAlloc
       
  2865 
       
  2866 static PyObject *CFMutableStringRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
       
  2867 {
       
  2868 	PyObject *self;
       
  2869 	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
       
  2870 	((CFMutableStringRefObject *)self)->ob_itself = NULL;
       
  2871 	((CFMutableStringRefObject *)self)->ob_freeit = CFRelease;
       
  2872 	return self;
       
  2873 }
       
  2874 
       
  2875 #define CFMutableStringRefObj_tp_free PyObject_Del
       
  2876 
       
  2877 
       
  2878 PyTypeObject CFMutableStringRef_Type = {
       
  2879 	PyObject_HEAD_INIT(NULL)
       
  2880 	0, /*ob_size*/
       
  2881 	"_CF.CFMutableStringRef", /*tp_name*/
       
  2882 	sizeof(CFMutableStringRefObject), /*tp_basicsize*/
       
  2883 	0, /*tp_itemsize*/
       
  2884 	/* methods */
       
  2885 	(destructor) CFMutableStringRefObj_dealloc, /*tp_dealloc*/
       
  2886 	0, /*tp_print*/
       
  2887 	(getattrfunc)0, /*tp_getattr*/
       
  2888 	(setattrfunc)0, /*tp_setattr*/
       
  2889 	(cmpfunc) CFMutableStringRefObj_compare, /*tp_compare*/
       
  2890 	(reprfunc) CFMutableStringRefObj_repr, /*tp_repr*/
       
  2891 	(PyNumberMethods *)0, /* tp_as_number */
       
  2892 	(PySequenceMethods *)0, /* tp_as_sequence */
       
  2893 	(PyMappingMethods *)0, /* tp_as_mapping */
       
  2894 	(hashfunc) CFMutableStringRefObj_hash, /*tp_hash*/
       
  2895 	0, /*tp_call*/
       
  2896 	0, /*tp_str*/
       
  2897 	PyObject_GenericGetAttr, /*tp_getattro*/
       
  2898 	PyObject_GenericSetAttr, /*tp_setattro */
       
  2899 	0, /*tp_as_buffer*/
       
  2900 	Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
       
  2901 	0, /*tp_doc*/
       
  2902 	0, /*tp_traverse*/
       
  2903 	0, /*tp_clear*/
       
  2904 	0, /*tp_richcompare*/
       
  2905 	0, /*tp_weaklistoffset*/
       
  2906 	0, /*tp_iter*/
       
  2907 	0, /*tp_iternext*/
       
  2908 	CFMutableStringRefObj_methods, /* tp_methods */
       
  2909 	0, /*tp_members*/
       
  2910 	CFMutableStringRefObj_getsetlist, /*tp_getset*/
       
  2911 	0, /*tp_base*/
       
  2912 	0, /*tp_dict*/
       
  2913 	0, /*tp_descr_get*/
       
  2914 	0, /*tp_descr_set*/
       
  2915 	0, /*tp_dictoffset*/
       
  2916 	CFMutableStringRefObj_tp_init, /* tp_init */
       
  2917 	CFMutableStringRefObj_tp_alloc, /* tp_alloc */
       
  2918 	CFMutableStringRefObj_tp_new, /* tp_new */
       
  2919 	CFMutableStringRefObj_tp_free, /* tp_free */
       
  2920 };
       
  2921 
       
  2922 /* --------------- End object type CFMutableStringRef --------------- */
       
  2923 
       
  2924 
       
  2925 /* ---------------------- Object type CFURLRef ---------------------- */
       
  2926 
       
  2927 PyTypeObject CFURLRef_Type;
       
  2928 
       
  2929 #define CFURLRefObj_Check(x) ((x)->ob_type == &CFURLRef_Type || PyObject_TypeCheck((x), &CFURLRef_Type))
       
  2930 
       
  2931 typedef struct CFURLRefObject {
       
  2932 	PyObject_HEAD
       
  2933 	CFURLRef ob_itself;
       
  2934 	void (*ob_freeit)(CFTypeRef ptr);
       
  2935 } CFURLRefObject;
       
  2936 
       
  2937 PyObject *CFURLRefObj_New(CFURLRef itself)
       
  2938 {
       
  2939 	CFURLRefObject *it;
       
  2940 	if (itself == NULL)
       
  2941 	{
       
  2942 		PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
       
  2943 		return NULL;
       
  2944 	}
       
  2945 	it = PyObject_NEW(CFURLRefObject, &CFURLRef_Type);
       
  2946 	if (it == NULL) return NULL;
       
  2947 	/* XXXX Should we tp_init or tp_new our basetype? */
       
  2948 	it->ob_itself = itself;
       
  2949 	it->ob_freeit = CFRelease;
       
  2950 	return (PyObject *)it;
       
  2951 }
       
  2952 
       
  2953 int CFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself)
       
  2954 {
       
  2955 
       
  2956 	if (v == Py_None) { *p_itself = NULL; return 1; }
       
  2957 	/* Check for other CF objects here */
       
  2958 
       
  2959 	if (!CFURLRefObj_Check(v))
       
  2960 	{
       
  2961 		PyErr_SetString(PyExc_TypeError, "CFURLRef required");
       
  2962 		return 0;
       
  2963 	}
       
  2964 	*p_itself = ((CFURLRefObject *)v)->ob_itself;
       
  2965 	return 1;
       
  2966 }
       
  2967 
       
  2968 static void CFURLRefObj_dealloc(CFURLRefObject *self)
       
  2969 {
       
  2970 	if (self->ob_freeit && self->ob_itself)
       
  2971 	{
       
  2972 		self->ob_freeit((CFTypeRef)self->ob_itself);
       
  2973 		self->ob_itself = NULL;
       
  2974 	}
       
  2975 	CFTypeRef_Type.tp_dealloc((PyObject *)self);
       
  2976 }
       
  2977 
       
  2978 static PyObject *CFURLRefObj_CFURLCreateData(CFURLRefObject *_self, PyObject *_args)
       
  2979 {
       
  2980 	PyObject *_res = NULL;
       
  2981 	CFDataRef _rv;
       
  2982 	CFStringEncoding encoding;
       
  2983 	Boolean escapeWhitespace;
       
  2984 	if (!PyArg_ParseTuple(_args, "ll",
       
  2985 	                      &encoding,
       
  2986 	                      &escapeWhitespace))
       
  2987 		return NULL;
       
  2988 	_rv = CFURLCreateData((CFAllocatorRef)NULL,
       
  2989 	                      _self->ob_itself,
       
  2990 	                      encoding,
       
  2991 	                      escapeWhitespace);
       
  2992 	_res = Py_BuildValue("O&",
       
  2993 	                     CFDataRefObj_New, _rv);
       
  2994 	return _res;
       
  2995 }
       
  2996 
       
  2997 static PyObject *CFURLRefObj_CFURLGetFileSystemRepresentation(CFURLRefObject *_self, PyObject *_args)
       
  2998 {
       
  2999 	PyObject *_res = NULL;
       
  3000 	Boolean _rv;
       
  3001 	Boolean resolveAgainstBase;
       
  3002 	UInt8 buffer;
       
  3003 	CFIndex maxBufLen;
       
  3004 #ifndef CFURLGetFileSystemRepresentation
       
  3005 	PyMac_PRECHECK(CFURLGetFileSystemRepresentation);
       
  3006 #endif
       
  3007 	if (!PyArg_ParseTuple(_args, "ll",
       
  3008 	                      &resolveAgainstBase,
       
  3009 	                      &maxBufLen))
       
  3010 		return NULL;
       
  3011 	_rv = CFURLGetFileSystemRepresentation(_self->ob_itself,
       
  3012 	                                       resolveAgainstBase,
       
  3013 	                                       &buffer,
       
  3014 	                                       maxBufLen);
       
  3015 	_res = Py_BuildValue("lb",
       
  3016 	                     _rv,
       
  3017 	                     buffer);
       
  3018 	return _res;
       
  3019 }
       
  3020 
       
  3021 static PyObject *CFURLRefObj_CFURLCopyAbsoluteURL(CFURLRefObject *_self, PyObject *_args)
       
  3022 {
       
  3023 	PyObject *_res = NULL;
       
  3024 	CFURLRef _rv;
       
  3025 #ifndef CFURLCopyAbsoluteURL
       
  3026 	PyMac_PRECHECK(CFURLCopyAbsoluteURL);
       
  3027 #endif
       
  3028 	if (!PyArg_ParseTuple(_args, ""))
       
  3029 		return NULL;
       
  3030 	_rv = CFURLCopyAbsoluteURL(_self->ob_itself);
       
  3031 	_res = Py_BuildValue("O&",
       
  3032 	                     CFURLRefObj_New, _rv);
       
  3033 	return _res;
       
  3034 }
       
  3035 
       
  3036 static PyObject *CFURLRefObj_CFURLGetString(CFURLRefObject *_self, PyObject *_args)
       
  3037 {
       
  3038 	PyObject *_res = NULL;
       
  3039 	CFStringRef _rv;
       
  3040 #ifndef CFURLGetString
       
  3041 	PyMac_PRECHECK(CFURLGetString);
       
  3042 #endif
       
  3043 	if (!PyArg_ParseTuple(_args, ""))
       
  3044 		return NULL;
       
  3045 	_rv = CFURLGetString(_self->ob_itself);
       
  3046 	_res = Py_BuildValue("O&",
       
  3047 	                     CFStringRefObj_New, _rv);
       
  3048 	return _res;
       
  3049 }
       
  3050 
       
  3051 static PyObject *CFURLRefObj_CFURLGetBaseURL(CFURLRefObject *_self, PyObject *_args)
       
  3052 {
       
  3053 	PyObject *_res = NULL;
       
  3054 	CFURLRef _rv;
       
  3055 #ifndef CFURLGetBaseURL
       
  3056 	PyMac_PRECHECK(CFURLGetBaseURL);
       
  3057 #endif
       
  3058 	if (!PyArg_ParseTuple(_args, ""))
       
  3059 		return NULL;
       
  3060 	_rv = CFURLGetBaseURL(_self->ob_itself);
       
  3061 	_res = Py_BuildValue("O&",
       
  3062 	                     CFURLRefObj_New, _rv);
       
  3063 	return _res;
       
  3064 }
       
  3065 
       
  3066 static PyObject *CFURLRefObj_CFURLCanBeDecomposed(CFURLRefObject *_self, PyObject *_args)
       
  3067 {
       
  3068 	PyObject *_res = NULL;
       
  3069 	Boolean _rv;
       
  3070 #ifndef CFURLCanBeDecomposed
       
  3071 	PyMac_PRECHECK(CFURLCanBeDecomposed);
       
  3072 #endif
       
  3073 	if (!PyArg_ParseTuple(_args, ""))
       
  3074 		return NULL;
       
  3075 	_rv = CFURLCanBeDecomposed(_self->ob_itself);
       
  3076 	_res = Py_BuildValue("l",
       
  3077 	                     _rv);
       
  3078 	return _res;
       
  3079 }
       
  3080 
       
  3081 static PyObject *CFURLRefObj_CFURLCopyScheme(CFURLRefObject *_self, PyObject *_args)
       
  3082 {
       
  3083 	PyObject *_res = NULL;
       
  3084 	CFStringRef _rv;
       
  3085 #ifndef CFURLCopyScheme
       
  3086 	PyMac_PRECHECK(CFURLCopyScheme);
       
  3087 #endif
       
  3088 	if (!PyArg_ParseTuple(_args, ""))
       
  3089 		return NULL;
       
  3090 	_rv = CFURLCopyScheme(_self->ob_itself);
       
  3091 	_res = Py_BuildValue("O&",
       
  3092 	                     CFStringRefObj_New, _rv);
       
  3093 	return _res;
       
  3094 }
       
  3095 
       
  3096 static PyObject *CFURLRefObj_CFURLCopyNetLocation(CFURLRefObject *_self, PyObject *_args)
       
  3097 {
       
  3098 	PyObject *_res = NULL;
       
  3099 	CFStringRef _rv;
       
  3100 #ifndef CFURLCopyNetLocation
       
  3101 	PyMac_PRECHECK(CFURLCopyNetLocation);
       
  3102 #endif
       
  3103 	if (!PyArg_ParseTuple(_args, ""))
       
  3104 		return NULL;
       
  3105 	_rv = CFURLCopyNetLocation(_self->ob_itself);
       
  3106 	_res = Py_BuildValue("O&",
       
  3107 	                     CFStringRefObj_New, _rv);
       
  3108 	return _res;
       
  3109 }
       
  3110 
       
  3111 static PyObject *CFURLRefObj_CFURLCopyPath(CFURLRefObject *_self, PyObject *_args)
       
  3112 {
       
  3113 	PyObject *_res = NULL;
       
  3114 	CFStringRef _rv;
       
  3115 #ifndef CFURLCopyPath
       
  3116 	PyMac_PRECHECK(CFURLCopyPath);
       
  3117 #endif
       
  3118 	if (!PyArg_ParseTuple(_args, ""))
       
  3119 		return NULL;
       
  3120 	_rv = CFURLCopyPath(_self->ob_itself);
       
  3121 	_res = Py_BuildValue("O&",
       
  3122 	                     CFStringRefObj_New, _rv);
       
  3123 	return _res;
       
  3124 }
       
  3125 
       
  3126 static PyObject *CFURLRefObj_CFURLCopyStrictPath(CFURLRefObject *_self, PyObject *_args)
       
  3127 {
       
  3128 	PyObject *_res = NULL;
       
  3129 	CFStringRef _rv;
       
  3130 	Boolean isAbsolute;
       
  3131 #ifndef CFURLCopyStrictPath
       
  3132 	PyMac_PRECHECK(CFURLCopyStrictPath);
       
  3133 #endif
       
  3134 	if (!PyArg_ParseTuple(_args, ""))
       
  3135 		return NULL;
       
  3136 	_rv = CFURLCopyStrictPath(_self->ob_itself,
       
  3137 	                          &isAbsolute);
       
  3138 	_res = Py_BuildValue("O&l",
       
  3139 	                     CFStringRefObj_New, _rv,
       
  3140 	                     isAbsolute);
       
  3141 	return _res;
       
  3142 }
       
  3143 
       
  3144 static PyObject *CFURLRefObj_CFURLCopyFileSystemPath(CFURLRefObject *_self, PyObject *_args)
       
  3145 {
       
  3146 	PyObject *_res = NULL;
       
  3147 	CFStringRef _rv;
       
  3148 	CFURLPathStyle pathStyle;
       
  3149 #ifndef CFURLCopyFileSystemPath
       
  3150 	PyMac_PRECHECK(CFURLCopyFileSystemPath);
       
  3151 #endif
       
  3152 	if (!PyArg_ParseTuple(_args, "l",
       
  3153 	                      &pathStyle))
       
  3154 		return NULL;
       
  3155 	_rv = CFURLCopyFileSystemPath(_self->ob_itself,
       
  3156 	                              pathStyle);
       
  3157 	_res = Py_BuildValue("O&",
       
  3158 	                     CFStringRefObj_New, _rv);
       
  3159 	return _res;
       
  3160 }
       
  3161 
       
  3162 static PyObject *CFURLRefObj_CFURLHasDirectoryPath(CFURLRefObject *_self, PyObject *_args)
       
  3163 {
       
  3164 	PyObject *_res = NULL;
       
  3165 	Boolean _rv;
       
  3166 #ifndef CFURLHasDirectoryPath
       
  3167 	PyMac_PRECHECK(CFURLHasDirectoryPath);
       
  3168 #endif
       
  3169 	if (!PyArg_ParseTuple(_args, ""))
       
  3170 		return NULL;
       
  3171 	_rv = CFURLHasDirectoryPath(_self->ob_itself);
       
  3172 	_res = Py_BuildValue("l",
       
  3173 	                     _rv);
       
  3174 	return _res;
       
  3175 }
       
  3176 
       
  3177 static PyObject *CFURLRefObj_CFURLCopyResourceSpecifier(CFURLRefObject *_self, PyObject *_args)
       
  3178 {
       
  3179 	PyObject *_res = NULL;
       
  3180 	CFStringRef _rv;
       
  3181 #ifndef CFURLCopyResourceSpecifier
       
  3182 	PyMac_PRECHECK(CFURLCopyResourceSpecifier);
       
  3183 #endif
       
  3184 	if (!PyArg_ParseTuple(_args, ""))
       
  3185 		return NULL;
       
  3186 	_rv = CFURLCopyResourceSpecifier(_self->ob_itself);
       
  3187 	_res = Py_BuildValue("O&",
       
  3188 	                     CFStringRefObj_New, _rv);
       
  3189 	return _res;
       
  3190 }
       
  3191 
       
  3192 static PyObject *CFURLRefObj_CFURLCopyHostName(CFURLRefObject *_self, PyObject *_args)
       
  3193 {
       
  3194 	PyObject *_res = NULL;
       
  3195 	CFStringRef _rv;
       
  3196 #ifndef CFURLCopyHostName
       
  3197 	PyMac_PRECHECK(CFURLCopyHostName);
       
  3198 #endif
       
  3199 	if (!PyArg_ParseTuple(_args, ""))
       
  3200 		return NULL;
       
  3201 	_rv = CFURLCopyHostName(_self->ob_itself);
       
  3202 	_res = Py_BuildValue("O&",
       
  3203 	                     CFStringRefObj_New, _rv);
       
  3204 	return _res;
       
  3205 }
       
  3206 
       
  3207 static PyObject *CFURLRefObj_CFURLGetPortNumber(CFURLRefObject *_self, PyObject *_args)
       
  3208 {
       
  3209 	PyObject *_res = NULL;
       
  3210 	SInt32 _rv;
       
  3211 #ifndef CFURLGetPortNumber
       
  3212 	PyMac_PRECHECK(CFURLGetPortNumber);
       
  3213 #endif
       
  3214 	if (!PyArg_ParseTuple(_args, ""))
       
  3215 		return NULL;
       
  3216 	_rv = CFURLGetPortNumber(_self->ob_itself);
       
  3217 	_res = Py_BuildValue("l",
       
  3218 	                     _rv);
       
  3219 	return _res;
       
  3220 }
       
  3221 
       
  3222 static PyObject *CFURLRefObj_CFURLCopyUserName(CFURLRefObject *_self, PyObject *_args)
       
  3223 {
       
  3224 	PyObject *_res = NULL;
       
  3225 	CFStringRef _rv;
       
  3226 #ifndef CFURLCopyUserName
       
  3227 	PyMac_PRECHECK(CFURLCopyUserName);
       
  3228 #endif
       
  3229 	if (!PyArg_ParseTuple(_args, ""))
       
  3230 		return NULL;
       
  3231 	_rv = CFURLCopyUserName(_self->ob_itself);
       
  3232 	_res = Py_BuildValue("O&",
       
  3233 	                     CFStringRefObj_New, _rv);
       
  3234 	return _res;
       
  3235 }
       
  3236 
       
  3237 static PyObject *CFURLRefObj_CFURLCopyPassword(CFURLRefObject *_self, PyObject *_args)
       
  3238 {
       
  3239 	PyObject *_res = NULL;
       
  3240 	CFStringRef _rv;
       
  3241 #ifndef CFURLCopyPassword
       
  3242 	PyMac_PRECHECK(CFURLCopyPassword);
       
  3243 #endif
       
  3244 	if (!PyArg_ParseTuple(_args, ""))
       
  3245 		return NULL;
       
  3246 	_rv = CFURLCopyPassword(_self->ob_itself);
       
  3247 	_res = Py_BuildValue("O&",
       
  3248 	                     CFStringRefObj_New, _rv);
       
  3249 	return _res;
       
  3250 }
       
  3251 
       
  3252 static PyObject *CFURLRefObj_CFURLCopyParameterString(CFURLRefObject *_self, PyObject *_args)
       
  3253 {
       
  3254 	PyObject *_res = NULL;
       
  3255 	CFStringRef _rv;
       
  3256 	CFStringRef charactersToLeaveEscaped;
       
  3257 #ifndef CFURLCopyParameterString
       
  3258 	PyMac_PRECHECK(CFURLCopyParameterString);
       
  3259 #endif
       
  3260 	if (!PyArg_ParseTuple(_args, "O&",
       
  3261 	                      CFStringRefObj_Convert, &charactersToLeaveEscaped))
       
  3262 		return NULL;
       
  3263 	_rv = CFURLCopyParameterString(_self->ob_itself,
       
  3264 	                               charactersToLeaveEscaped);
       
  3265 	_res = Py_BuildValue("O&",
       
  3266 	                     CFStringRefObj_New, _rv);
       
  3267 	return _res;
       
  3268 }
       
  3269 
       
  3270 static PyObject *CFURLRefObj_CFURLCopyQueryString(CFURLRefObject *_self, PyObject *_args)
       
  3271 {
       
  3272 	PyObject *_res = NULL;
       
  3273 	CFStringRef _rv;
       
  3274 	CFStringRef charactersToLeaveEscaped;
       
  3275 #ifndef CFURLCopyQueryString
       
  3276 	PyMac_PRECHECK(CFURLCopyQueryString);
       
  3277 #endif
       
  3278 	if (!PyArg_ParseTuple(_args, "O&",
       
  3279 	                      CFStringRefObj_Convert, &charactersToLeaveEscaped))
       
  3280 		return NULL;
       
  3281 	_rv = CFURLCopyQueryString(_self->ob_itself,
       
  3282 	                           charactersToLeaveEscaped);
       
  3283 	_res = Py_BuildValue("O&",
       
  3284 	                     CFStringRefObj_New, _rv);
       
  3285 	return _res;
       
  3286 }
       
  3287 
       
  3288 static PyObject *CFURLRefObj_CFURLCopyFragment(CFURLRefObject *_self, PyObject *_args)
       
  3289 {
       
  3290 	PyObject *_res = NULL;
       
  3291 	CFStringRef _rv;
       
  3292 	CFStringRef charactersToLeaveEscaped;
       
  3293 #ifndef CFURLCopyFragment
       
  3294 	PyMac_PRECHECK(CFURLCopyFragment);
       
  3295 #endif
       
  3296 	if (!PyArg_ParseTuple(_args, "O&",
       
  3297 	                      CFStringRefObj_Convert, &charactersToLeaveEscaped))
       
  3298 		return NULL;
       
  3299 	_rv = CFURLCopyFragment(_self->ob_itself,
       
  3300 	                        charactersToLeaveEscaped);
       
  3301 	_res = Py_BuildValue("O&",
       
  3302 	                     CFStringRefObj_New, _rv);
       
  3303 	return _res;
       
  3304 }
       
  3305 
       
  3306 static PyObject *CFURLRefObj_CFURLCopyLastPathComponent(CFURLRefObject *_self, PyObject *_args)
       
  3307 {
       
  3308 	PyObject *_res = NULL;
       
  3309 	CFStringRef _rv;
       
  3310 #ifndef CFURLCopyLastPathComponent
       
  3311 	PyMac_PRECHECK(CFURLCopyLastPathComponent);
       
  3312 #endif
       
  3313 	if (!PyArg_ParseTuple(_args, ""))
       
  3314 		return NULL;
       
  3315 	_rv = CFURLCopyLastPathComponent(_self->ob_itself);
       
  3316 	_res = Py_BuildValue("O&",
       
  3317 	                     CFStringRefObj_New, _rv);
       
  3318 	return _res;
       
  3319 }
       
  3320 
       
  3321 static PyObject *CFURLRefObj_CFURLCopyPathExtension(CFURLRefObject *_self, PyObject *_args)
       
  3322 {
       
  3323 	PyObject *_res = NULL;
       
  3324 	CFStringRef _rv;
       
  3325 #ifndef CFURLCopyPathExtension
       
  3326 	PyMac_PRECHECK(CFURLCopyPathExtension);
       
  3327 #endif
       
  3328 	if (!PyArg_ParseTuple(_args, ""))
       
  3329 		return NULL;
       
  3330 	_rv = CFURLCopyPathExtension(_self->ob_itself);
       
  3331 	_res = Py_BuildValue("O&",
       
  3332 	                     CFStringRefObj_New, _rv);
       
  3333 	return _res;
       
  3334 }
       
  3335 
       
  3336 static PyObject *CFURLRefObj_CFURLCreateCopyAppendingPathComponent(CFURLRefObject *_self, PyObject *_args)
       
  3337 {
       
  3338 	PyObject *_res = NULL;
       
  3339 	CFURLRef _rv;
       
  3340 	CFStringRef pathComponent;
       
  3341 	Boolean isDirectory;
       
  3342 	if (!PyArg_ParseTuple(_args, "O&l",
       
  3343 	                      CFStringRefObj_Convert, &pathComponent,
       
  3344 	                      &isDirectory))
       
  3345 		return NULL;
       
  3346 	_rv = CFURLCreateCopyAppendingPathComponent((CFAllocatorRef)NULL,
       
  3347 	                                            _self->ob_itself,
       
  3348 	                                            pathComponent,
       
  3349 	                                            isDirectory);
       
  3350 	_res = Py_BuildValue("O&",
       
  3351 	                     CFURLRefObj_New, _rv);
       
  3352 	return _res;
       
  3353 }
       
  3354 
       
  3355 static PyObject *CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent(CFURLRefObject *_self, PyObject *_args)
       
  3356 {
       
  3357 	PyObject *_res = NULL;
       
  3358 	CFURLRef _rv;
       
  3359 	if (!PyArg_ParseTuple(_args, ""))
       
  3360 		return NULL;
       
  3361 	_rv = CFURLCreateCopyDeletingLastPathComponent((CFAllocatorRef)NULL,
       
  3362 	                                               _self->ob_itself);
       
  3363 	_res = Py_BuildValue("O&",
       
  3364 	                     CFURLRefObj_New, _rv);
       
  3365 	return _res;
       
  3366 }
       
  3367 
       
  3368 static PyObject *CFURLRefObj_CFURLCreateCopyAppendingPathExtension(CFURLRefObject *_self, PyObject *_args)
       
  3369 {
       
  3370 	PyObject *_res = NULL;
       
  3371 	CFURLRef _rv;
       
  3372 	CFStringRef extension;
       
  3373 	if (!PyArg_ParseTuple(_args, "O&",
       
  3374 	                      CFStringRefObj_Convert, &extension))
       
  3375 		return NULL;
       
  3376 	_rv = CFURLCreateCopyAppendingPathExtension((CFAllocatorRef)NULL,
       
  3377 	                                            _self->ob_itself,
       
  3378 	                                            extension);
       
  3379 	_res = Py_BuildValue("O&",
       
  3380 	                     CFURLRefObj_New, _rv);
       
  3381 	return _res;
       
  3382 }
       
  3383 
       
  3384 static PyObject *CFURLRefObj_CFURLCreateCopyDeletingPathExtension(CFURLRefObject *_self, PyObject *_args)
       
  3385 {
       
  3386 	PyObject *_res = NULL;
       
  3387 	CFURLRef _rv;
       
  3388 	if (!PyArg_ParseTuple(_args, ""))
       
  3389 		return NULL;
       
  3390 	_rv = CFURLCreateCopyDeletingPathExtension((CFAllocatorRef)NULL,
       
  3391 	                                           _self->ob_itself);
       
  3392 	_res = Py_BuildValue("O&",
       
  3393 	                     CFURLRefObj_New, _rv);
       
  3394 	return _res;
       
  3395 }
       
  3396 
       
  3397 static PyObject *CFURLRefObj_CFURLGetFSRef(CFURLRefObject *_self, PyObject *_args)
       
  3398 {
       
  3399 	PyObject *_res = NULL;
       
  3400 	Boolean _rv;
       
  3401 	FSRef fsRef;
       
  3402 #ifndef CFURLGetFSRef
       
  3403 	PyMac_PRECHECK(CFURLGetFSRef);
       
  3404 #endif
       
  3405 	if (!PyArg_ParseTuple(_args, ""))
       
  3406 		return NULL;
       
  3407 	_rv = CFURLGetFSRef(_self->ob_itself,
       
  3408 	                    &fsRef);
       
  3409 	_res = Py_BuildValue("lO&",
       
  3410 	                     _rv,
       
  3411 	                     PyMac_BuildFSRef, &fsRef);
       
  3412 	return _res;
       
  3413 }
       
  3414 
       
  3415 static PyMethodDef CFURLRefObj_methods[] = {
       
  3416 	{"CFURLCreateData", (PyCFunction)CFURLRefObj_CFURLCreateData, 1,
       
  3417 	 PyDoc_STR("(CFStringEncoding encoding, Boolean escapeWhitespace) -> (CFDataRef _rv)")},
       
  3418 	{"CFURLGetFileSystemRepresentation", (PyCFunction)CFURLRefObj_CFURLGetFileSystemRepresentation, 1,
       
  3419 	 PyDoc_STR("(Boolean resolveAgainstBase, CFIndex maxBufLen) -> (Boolean _rv, UInt8 buffer)")},
       
  3420 	{"CFURLCopyAbsoluteURL", (PyCFunction)CFURLRefObj_CFURLCopyAbsoluteURL, 1,
       
  3421 	 PyDoc_STR("() -> (CFURLRef _rv)")},
       
  3422 	{"CFURLGetString", (PyCFunction)CFURLRefObj_CFURLGetString, 1,
       
  3423 	 PyDoc_STR("() -> (CFStringRef _rv)")},
       
  3424 	{"CFURLGetBaseURL", (PyCFunction)CFURLRefObj_CFURLGetBaseURL, 1,
       
  3425 	 PyDoc_STR("() -> (CFURLRef _rv)")},
       
  3426 	{"CFURLCanBeDecomposed", (PyCFunction)CFURLRefObj_CFURLCanBeDecomposed, 1,
       
  3427 	 PyDoc_STR("() -> (Boolean _rv)")},
       
  3428 	{"CFURLCopyScheme", (PyCFunction)CFURLRefObj_CFURLCopyScheme, 1,
       
  3429 	 PyDoc_STR("() -> (CFStringRef _rv)")},
       
  3430 	{"CFURLCopyNetLocation", (PyCFunction)CFURLRefObj_CFURLCopyNetLocation, 1,
       
  3431 	 PyDoc_STR("() -> (CFStringRef _rv)")},
       
  3432 	{"CFURLCopyPath", (PyCFunction)CFURLRefObj_CFURLCopyPath, 1,
       
  3433 	 PyDoc_STR("() -> (CFStringRef _rv)")},
       
  3434 	{"CFURLCopyStrictPath", (PyCFunction)CFURLRefObj_CFURLCopyStrictPath, 1,
       
  3435 	 PyDoc_STR("() -> (CFStringRef _rv, Boolean isAbsolute)")},
       
  3436 	{"CFURLCopyFileSystemPath", (PyCFunction)CFURLRefObj_CFURLCopyFileSystemPath, 1,
       
  3437 	 PyDoc_STR("(CFURLPathStyle pathStyle) -> (CFStringRef _rv)")},
       
  3438 	{"CFURLHasDirectoryPath", (PyCFunction)CFURLRefObj_CFURLHasDirectoryPath, 1,
       
  3439 	 PyDoc_STR("() -> (Boolean _rv)")},
       
  3440 	{"CFURLCopyResourceSpecifier", (PyCFunction)CFURLRefObj_CFURLCopyResourceSpecifier, 1,
       
  3441 	 PyDoc_STR("() -> (CFStringRef _rv)")},
       
  3442 	{"CFURLCopyHostName", (PyCFunction)CFURLRefObj_CFURLCopyHostName, 1,
       
  3443 	 PyDoc_STR("() -> (CFStringRef _rv)")},
       
  3444 	{"CFURLGetPortNumber", (PyCFunction)CFURLRefObj_CFURLGetPortNumber, 1,
       
  3445 	 PyDoc_STR("() -> (SInt32 _rv)")},
       
  3446 	{"CFURLCopyUserName", (PyCFunction)CFURLRefObj_CFURLCopyUserName, 1,
       
  3447 	 PyDoc_STR("() -> (CFStringRef _rv)")},
       
  3448 	{"CFURLCopyPassword", (PyCFunction)CFURLRefObj_CFURLCopyPassword, 1,
       
  3449 	 PyDoc_STR("() -> (CFStringRef _rv)")},
       
  3450 	{"CFURLCopyParameterString", (PyCFunction)CFURLRefObj_CFURLCopyParameterString, 1,
       
  3451 	 PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")},
       
  3452 	{"CFURLCopyQueryString", (PyCFunction)CFURLRefObj_CFURLCopyQueryString, 1,
       
  3453 	 PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")},
       
  3454 	{"CFURLCopyFragment", (PyCFunction)CFURLRefObj_CFURLCopyFragment, 1,
       
  3455 	 PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")},
       
  3456 	{"CFURLCopyLastPathComponent", (PyCFunction)CFURLRefObj_CFURLCopyLastPathComponent, 1,
       
  3457 	 PyDoc_STR("() -> (CFStringRef _rv)")},
       
  3458 	{"CFURLCopyPathExtension", (PyCFunction)CFURLRefObj_CFURLCopyPathExtension, 1,
       
  3459 	 PyDoc_STR("() -> (CFStringRef _rv)")},
       
  3460 	{"CFURLCreateCopyAppendingPathComponent", (PyCFunction)CFURLRefObj_CFURLCreateCopyAppendingPathComponent, 1,
       
  3461 	 PyDoc_STR("(CFStringRef pathComponent, Boolean isDirectory) -> (CFURLRef _rv)")},
       
  3462 	{"CFURLCreateCopyDeletingLastPathComponent", (PyCFunction)CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent, 1,
       
  3463 	 PyDoc_STR("() -> (CFURLRef _rv)")},
       
  3464 	{"CFURLCreateCopyAppendingPathExtension", (PyCFunction)CFURLRefObj_CFURLCreateCopyAppendingPathExtension, 1,
       
  3465 	 PyDoc_STR("(CFStringRef extension) -> (CFURLRef _rv)")},
       
  3466 	{"CFURLCreateCopyDeletingPathExtension", (PyCFunction)CFURLRefObj_CFURLCreateCopyDeletingPathExtension, 1,
       
  3467 	 PyDoc_STR("() -> (CFURLRef _rv)")},
       
  3468 	{"CFURLGetFSRef", (PyCFunction)CFURLRefObj_CFURLGetFSRef, 1,
       
  3469 	 PyDoc_STR("() -> (Boolean _rv, FSRef fsRef)")},
       
  3470 	{NULL, NULL, 0}
       
  3471 };
       
  3472 
       
  3473 #define CFURLRefObj_getsetlist NULL
       
  3474 
       
  3475 
       
  3476 static int CFURLRefObj_compare(CFURLRefObject *self, CFURLRefObject *other)
       
  3477 {
       
  3478 	/* XXXX Or should we use CFEqual?? */
       
  3479 	if ( self->ob_itself > other->ob_itself ) return 1;
       
  3480 	if ( self->ob_itself < other->ob_itself ) return -1;
       
  3481 	return 0;
       
  3482 }
       
  3483 
       
  3484 static PyObject * CFURLRefObj_repr(CFURLRefObject *self)
       
  3485 {
       
  3486 	char buf[100];
       
  3487 	sprintf(buf, "<CFURL object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
       
  3488 	return PyString_FromString(buf);
       
  3489 }
       
  3490 
       
  3491 static int CFURLRefObj_hash(CFURLRefObject *self)
       
  3492 {
       
  3493 	/* XXXX Or should we use CFHash?? */
       
  3494 	return (int)self->ob_itself;
       
  3495 }
       
  3496 static int CFURLRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds)
       
  3497 {
       
  3498 	CFURLRef itself;
       
  3499 	char *kw[] = {"itself", 0};
       
  3500 
       
  3501 	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFURLRefObj_Convert, &itself))
       
  3502 	{
       
  3503 		((CFURLRefObject *)_self)->ob_itself = itself;
       
  3504 		return 0;
       
  3505 	}
       
  3506 
       
  3507 	/* Any CFTypeRef descendent is allowed as initializer too */
       
  3508 	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself))
       
  3509 	{
       
  3510 		((CFURLRefObject *)_self)->ob_itself = itself;
       
  3511 		return 0;
       
  3512 	}
       
  3513 	return -1;
       
  3514 }
       
  3515 
       
  3516 #define CFURLRefObj_tp_alloc PyType_GenericAlloc
       
  3517 
       
  3518 static PyObject *CFURLRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
       
  3519 {
       
  3520 	PyObject *self;
       
  3521 	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
       
  3522 	((CFURLRefObject *)self)->ob_itself = NULL;
       
  3523 	((CFURLRefObject *)self)->ob_freeit = CFRelease;
       
  3524 	return self;
       
  3525 }
       
  3526 
       
  3527 #define CFURLRefObj_tp_free PyObject_Del
       
  3528 
       
  3529 
       
  3530 PyTypeObject CFURLRef_Type = {
       
  3531 	PyObject_HEAD_INIT(NULL)
       
  3532 	0, /*ob_size*/
       
  3533 	"_CF.CFURLRef", /*tp_name*/
       
  3534 	sizeof(CFURLRefObject), /*tp_basicsize*/
       
  3535 	0, /*tp_itemsize*/
       
  3536 	/* methods */
       
  3537 	(destructor) CFURLRefObj_dealloc, /*tp_dealloc*/
       
  3538 	0, /*tp_print*/
       
  3539 	(getattrfunc)0, /*tp_getattr*/
       
  3540 	(setattrfunc)0, /*tp_setattr*/
       
  3541 	(cmpfunc) CFURLRefObj_compare, /*tp_compare*/
       
  3542 	(reprfunc) CFURLRefObj_repr, /*tp_repr*/
       
  3543 	(PyNumberMethods *)0, /* tp_as_number */
       
  3544 	(PySequenceMethods *)0, /* tp_as_sequence */
       
  3545 	(PyMappingMethods *)0, /* tp_as_mapping */
       
  3546 	(hashfunc) CFURLRefObj_hash, /*tp_hash*/
       
  3547 	0, /*tp_call*/
       
  3548 	0, /*tp_str*/
       
  3549 	PyObject_GenericGetAttr, /*tp_getattro*/
       
  3550 	PyObject_GenericSetAttr, /*tp_setattro */
       
  3551 	0, /*tp_as_buffer*/
       
  3552 	Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
       
  3553 	0, /*tp_doc*/
       
  3554 	0, /*tp_traverse*/
       
  3555 	0, /*tp_clear*/
       
  3556 	0, /*tp_richcompare*/
       
  3557 	0, /*tp_weaklistoffset*/
       
  3558 	0, /*tp_iter*/
       
  3559 	0, /*tp_iternext*/
       
  3560 	CFURLRefObj_methods, /* tp_methods */
       
  3561 	0, /*tp_members*/
       
  3562 	CFURLRefObj_getsetlist, /*tp_getset*/
       
  3563 	0, /*tp_base*/
       
  3564 	0, /*tp_dict*/
       
  3565 	0, /*tp_descr_get*/
       
  3566 	0, /*tp_descr_set*/
       
  3567 	0, /*tp_dictoffset*/
       
  3568 	CFURLRefObj_tp_init, /* tp_init */
       
  3569 	CFURLRefObj_tp_alloc, /* tp_alloc */
       
  3570 	CFURLRefObj_tp_new, /* tp_new */
       
  3571 	CFURLRefObj_tp_free, /* tp_free */
       
  3572 };
       
  3573 
       
  3574 /* -------------------- End object type CFURLRef -------------------- */
       
  3575 
       
  3576 
       
  3577 static PyObject *CF___CFRangeMake(PyObject *_self, PyObject *_args)
       
  3578 {
       
  3579 	PyObject *_res = NULL;
       
  3580 	CFRange _rv;
       
  3581 	CFIndex loc;
       
  3582 	CFIndex len;
       
  3583 #ifndef __CFRangeMake
       
  3584 	PyMac_PRECHECK(__CFRangeMake);
       
  3585 #endif
       
  3586 	if (!PyArg_ParseTuple(_args, "ll",
       
  3587 	                      &loc,
       
  3588 	                      &len))
       
  3589 		return NULL;
       
  3590 	_rv = __CFRangeMake(loc,
       
  3591 	                    len);
       
  3592 	_res = Py_BuildValue("O&",
       
  3593 	                     CFRange_New, _rv);
       
  3594 	return _res;
       
  3595 }
       
  3596 
       
  3597 static PyObject *CF_CFAllocatorGetTypeID(PyObject *_self, PyObject *_args)
       
  3598 {
       
  3599 	PyObject *_res = NULL;
       
  3600 	CFTypeID _rv;
       
  3601 #ifndef CFAllocatorGetTypeID
       
  3602 	PyMac_PRECHECK(CFAllocatorGetTypeID);
       
  3603 #endif
       
  3604 	if (!PyArg_ParseTuple(_args, ""))
       
  3605 		return NULL;
       
  3606 	_rv = CFAllocatorGetTypeID();
       
  3607 	_res = Py_BuildValue("l",
       
  3608 	                     _rv);
       
  3609 	return _res;
       
  3610 }
       
  3611 
       
  3612 static PyObject *CF_CFAllocatorGetPreferredSizeForSize(PyObject *_self, PyObject *_args)
       
  3613 {
       
  3614 	PyObject *_res = NULL;
       
  3615 	CFIndex _rv;
       
  3616 	CFIndex size;
       
  3617 	CFOptionFlags hint;
       
  3618 #ifndef CFAllocatorGetPreferredSizeForSize
       
  3619 	PyMac_PRECHECK(CFAllocatorGetPreferredSizeForSize);
       
  3620 #endif
       
  3621 	if (!PyArg_ParseTuple(_args, "ll",
       
  3622 	                      &size,
       
  3623 	                      &hint))
       
  3624 		return NULL;
       
  3625 	_rv = CFAllocatorGetPreferredSizeForSize((CFAllocatorRef)NULL,
       
  3626 	                                         size,
       
  3627 	                                         hint);
       
  3628 	_res = Py_BuildValue("l",
       
  3629 	                     _rv);
       
  3630 	return _res;
       
  3631 }
       
  3632 
       
  3633 static PyObject *CF_CFCopyTypeIDDescription(PyObject *_self, PyObject *_args)
       
  3634 {
       
  3635 	PyObject *_res = NULL;
       
  3636 	CFStringRef _rv;
       
  3637 	CFTypeID type_id;
       
  3638 #ifndef CFCopyTypeIDDescription
       
  3639 	PyMac_PRECHECK(CFCopyTypeIDDescription);
       
  3640 #endif
       
  3641 	if (!PyArg_ParseTuple(_args, "l",
       
  3642 	                      &type_id))
       
  3643 		return NULL;
       
  3644 	_rv = CFCopyTypeIDDescription(type_id);
       
  3645 	_res = Py_BuildValue("O&",
       
  3646 	                     CFStringRefObj_New, _rv);
       
  3647 	return _res;
       
  3648 }
       
  3649 
       
  3650 static PyObject *CF_CFArrayGetTypeID(PyObject *_self, PyObject *_args)
       
  3651 {
       
  3652 	PyObject *_res = NULL;
       
  3653 	CFTypeID _rv;
       
  3654 #ifndef CFArrayGetTypeID
       
  3655 	PyMac_PRECHECK(CFArrayGetTypeID);
       
  3656 #endif
       
  3657 	if (!PyArg_ParseTuple(_args, ""))
       
  3658 		return NULL;
       
  3659 	_rv = CFArrayGetTypeID();
       
  3660 	_res = Py_BuildValue("l",
       
  3661 	                     _rv);
       
  3662 	return _res;
       
  3663 }
       
  3664 
       
  3665 static PyObject *CF_CFArrayCreateMutable(PyObject *_self, PyObject *_args)
       
  3666 {
       
  3667 	PyObject *_res = NULL;
       
  3668 	CFMutableArrayRef _rv;
       
  3669 	CFIndex capacity;
       
  3670 #ifndef CFArrayCreateMutable
       
  3671 	PyMac_PRECHECK(CFArrayCreateMutable);
       
  3672 #endif
       
  3673 	if (!PyArg_ParseTuple(_args, "l",
       
  3674 	                      &capacity))
       
  3675 		return NULL;
       
  3676 	_rv = CFArrayCreateMutable((CFAllocatorRef)NULL,
       
  3677 	                           capacity,
       
  3678 	                           &kCFTypeArrayCallBacks);
       
  3679 	_res = Py_BuildValue("O&",
       
  3680 	                     CFMutableArrayRefObj_New, _rv);
       
  3681 	return _res;
       
  3682 }
       
  3683 
       
  3684 static PyObject *CF_CFArrayCreateMutableCopy(PyObject *_self, PyObject *_args)
       
  3685 {
       
  3686 	PyObject *_res = NULL;
       
  3687 	CFMutableArrayRef _rv;
       
  3688 	CFIndex capacity;
       
  3689 	CFArrayRef theArray;
       
  3690 #ifndef CFArrayCreateMutableCopy
       
  3691 	PyMac_PRECHECK(CFArrayCreateMutableCopy);
       
  3692 #endif
       
  3693 	if (!PyArg_ParseTuple(_args, "lO&",
       
  3694 	                      &capacity,
       
  3695 	                      CFArrayRefObj_Convert, &theArray))
       
  3696 		return NULL;
       
  3697 	_rv = CFArrayCreateMutableCopy((CFAllocatorRef)NULL,
       
  3698 	                               capacity,
       
  3699 	                               theArray);
       
  3700 	_res = Py_BuildValue("O&",
       
  3701 	                     CFMutableArrayRefObj_New, _rv);
       
  3702 	return _res;
       
  3703 }
       
  3704 
       
  3705 static PyObject *CF_CFDataGetTypeID(PyObject *_self, PyObject *_args)
       
  3706 {
       
  3707 	PyObject *_res = NULL;
       
  3708 	CFTypeID _rv;
       
  3709 #ifndef CFDataGetTypeID
       
  3710 	PyMac_PRECHECK(CFDataGetTypeID);
       
  3711 #endif
       
  3712 	if (!PyArg_ParseTuple(_args, ""))
       
  3713 		return NULL;
       
  3714 	_rv = CFDataGetTypeID();
       
  3715 	_res = Py_BuildValue("l",
       
  3716 	                     _rv);
       
  3717 	return _res;
       
  3718 }
       
  3719 
       
  3720 static PyObject *CF_CFDataCreate(PyObject *_self, PyObject *_args)
       
  3721 {
       
  3722 	PyObject *_res = NULL;
       
  3723 	CFDataRef _rv;
       
  3724 	unsigned char *bytes__in__;
       
  3725 	long bytes__len__;
       
  3726 	int bytes__in_len__;
       
  3727 #ifndef CFDataCreate
       
  3728 	PyMac_PRECHECK(CFDataCreate);
       
  3729 #endif
       
  3730 	if (!PyArg_ParseTuple(_args, "s#",
       
  3731 	                      &bytes__in__, &bytes__in_len__))
       
  3732 		return NULL;
       
  3733 	bytes__len__ = bytes__in_len__;
       
  3734 	_rv = CFDataCreate((CFAllocatorRef)NULL,
       
  3735 	                   bytes__in__, bytes__len__);
       
  3736 	_res = Py_BuildValue("O&",
       
  3737 	                     CFDataRefObj_New, _rv);
       
  3738 	return _res;
       
  3739 }
       
  3740 
       
  3741 static PyObject *CF_CFDataCreateWithBytesNoCopy(PyObject *_self, PyObject *_args)
       
  3742 {
       
  3743 	PyObject *_res = NULL;
       
  3744 	CFDataRef _rv;
       
  3745 	unsigned char *bytes__in__;
       
  3746 	long bytes__len__;
       
  3747 	int bytes__in_len__;
       
  3748 #ifndef CFDataCreateWithBytesNoCopy
       
  3749 	PyMac_PRECHECK(CFDataCreateWithBytesNoCopy);
       
  3750 #endif
       
  3751 	if (!PyArg_ParseTuple(_args, "s#",
       
  3752 	                      &bytes__in__, &bytes__in_len__))
       
  3753 		return NULL;
       
  3754 	bytes__len__ = bytes__in_len__;
       
  3755 	_rv = CFDataCreateWithBytesNoCopy((CFAllocatorRef)NULL,
       
  3756 	                                  bytes__in__, bytes__len__,
       
  3757 	                                  (CFAllocatorRef)NULL);
       
  3758 	_res = Py_BuildValue("O&",
       
  3759 	                     CFDataRefObj_New, _rv);
       
  3760 	return _res;
       
  3761 }
       
  3762 
       
  3763 static PyObject *CF_CFDataCreateMutable(PyObject *_self, PyObject *_args)
       
  3764 {
       
  3765 	PyObject *_res = NULL;
       
  3766 	CFMutableDataRef _rv;
       
  3767 	CFIndex capacity;
       
  3768 #ifndef CFDataCreateMutable
       
  3769 	PyMac_PRECHECK(CFDataCreateMutable);
       
  3770 #endif
       
  3771 	if (!PyArg_ParseTuple(_args, "l",
       
  3772 	                      &capacity))
       
  3773 		return NULL;
       
  3774 	_rv = CFDataCreateMutable((CFAllocatorRef)NULL,
       
  3775 	                          capacity);
       
  3776 	_res = Py_BuildValue("O&",
       
  3777 	                     CFMutableDataRefObj_New, _rv);
       
  3778 	return _res;
       
  3779 }
       
  3780 
       
  3781 static PyObject *CF_CFDataCreateMutableCopy(PyObject *_self, PyObject *_args)
       
  3782 {
       
  3783 	PyObject *_res = NULL;
       
  3784 	CFMutableDataRef _rv;
       
  3785 	CFIndex capacity;
       
  3786 	CFDataRef theData;
       
  3787 #ifndef CFDataCreateMutableCopy
       
  3788 	PyMac_PRECHECK(CFDataCreateMutableCopy);
       
  3789 #endif
       
  3790 	if (!PyArg_ParseTuple(_args, "lO&",
       
  3791 	                      &capacity,
       
  3792 	                      CFDataRefObj_Convert, &theData))
       
  3793 		return NULL;
       
  3794 	_rv = CFDataCreateMutableCopy((CFAllocatorRef)NULL,
       
  3795 	                              capacity,
       
  3796 	                              theData);
       
  3797 	_res = Py_BuildValue("O&",
       
  3798 	                     CFMutableDataRefObj_New, _rv);
       
  3799 	return _res;
       
  3800 }
       
  3801 
       
  3802 static PyObject *CF_CFDictionaryGetTypeID(PyObject *_self, PyObject *_args)
       
  3803 {
       
  3804 	PyObject *_res = NULL;
       
  3805 	CFTypeID _rv;
       
  3806 #ifndef CFDictionaryGetTypeID
       
  3807 	PyMac_PRECHECK(CFDictionaryGetTypeID);
       
  3808 #endif
       
  3809 	if (!PyArg_ParseTuple(_args, ""))
       
  3810 		return NULL;
       
  3811 	_rv = CFDictionaryGetTypeID();
       
  3812 	_res = Py_BuildValue("l",
       
  3813 	                     _rv);
       
  3814 	return _res;
       
  3815 }
       
  3816 
       
  3817 static PyObject *CF_CFDictionaryCreateMutable(PyObject *_self, PyObject *_args)
       
  3818 {
       
  3819 	PyObject *_res = NULL;
       
  3820 	CFMutableDictionaryRef _rv;
       
  3821 	CFIndex capacity;
       
  3822 #ifndef CFDictionaryCreateMutable
       
  3823 	PyMac_PRECHECK(CFDictionaryCreateMutable);
       
  3824 #endif
       
  3825 	if (!PyArg_ParseTuple(_args, "l",
       
  3826 	                      &capacity))
       
  3827 		return NULL;
       
  3828 	_rv = CFDictionaryCreateMutable((CFAllocatorRef)NULL,
       
  3829 	                                capacity,
       
  3830 	                                &kCFTypeDictionaryKeyCallBacks,
       
  3831 	                                &kCFTypeDictionaryValueCallBacks);
       
  3832 	_res = Py_BuildValue("O&",
       
  3833 	                     CFMutableDictionaryRefObj_New, _rv);
       
  3834 	return _res;
       
  3835 }
       
  3836 
       
  3837 static PyObject *CF_CFDictionaryCreateMutableCopy(PyObject *_self, PyObject *_args)
       
  3838 {
       
  3839 	PyObject *_res = NULL;
       
  3840 	CFMutableDictionaryRef _rv;
       
  3841 	CFIndex capacity;
       
  3842 	CFDictionaryRef theDict;
       
  3843 #ifndef CFDictionaryCreateMutableCopy
       
  3844 	PyMac_PRECHECK(CFDictionaryCreateMutableCopy);
       
  3845 #endif
       
  3846 	if (!PyArg_ParseTuple(_args, "lO&",
       
  3847 	                      &capacity,
       
  3848 	                      CFDictionaryRefObj_Convert, &theDict))
       
  3849 		return NULL;
       
  3850 	_rv = CFDictionaryCreateMutableCopy((CFAllocatorRef)NULL,
       
  3851 	                                    capacity,
       
  3852 	                                    theDict);
       
  3853 	_res = Py_BuildValue("O&",
       
  3854 	                     CFMutableDictionaryRefObj_New, _rv);
       
  3855 	return _res;
       
  3856 }
       
  3857 
       
  3858 static PyObject *CF_CFPreferencesCopyAppValue(PyObject *_self, PyObject *_args)
       
  3859 {
       
  3860 	PyObject *_res = NULL;
       
  3861 	CFTypeRef _rv;
       
  3862 	CFStringRef key;
       
  3863 	CFStringRef applicationID;
       
  3864 #ifndef CFPreferencesCopyAppValue
       
  3865 	PyMac_PRECHECK(CFPreferencesCopyAppValue);
       
  3866 #endif
       
  3867 	if (!PyArg_ParseTuple(_args, "O&O&",
       
  3868 	                      CFStringRefObj_Convert, &key,
       
  3869 	                      CFStringRefObj_Convert, &applicationID))
       
  3870 		return NULL;
       
  3871 	_rv = CFPreferencesCopyAppValue(key,
       
  3872 	                                applicationID);
       
  3873 	_res = Py_BuildValue("O&",
       
  3874 	                     CFTypeRefObj_New, _rv);
       
  3875 	return _res;
       
  3876 }
       
  3877 
       
  3878 static PyObject *CF_CFPreferencesGetAppBooleanValue(PyObject *_self, PyObject *_args)
       
  3879 {
       
  3880 	PyObject *_res = NULL;
       
  3881 	Boolean _rv;
       
  3882 	CFStringRef key;
       
  3883 	CFStringRef applicationID;
       
  3884 	Boolean keyExistsAndHasValidFormat;
       
  3885 #ifndef CFPreferencesGetAppBooleanValue
       
  3886 	PyMac_PRECHECK(CFPreferencesGetAppBooleanValue);
       
  3887 #endif
       
  3888 	if (!PyArg_ParseTuple(_args, "O&O&",
       
  3889 	                      CFStringRefObj_Convert, &key,
       
  3890 	                      CFStringRefObj_Convert, &applicationID))
       
  3891 		return NULL;
       
  3892 	_rv = CFPreferencesGetAppBooleanValue(key,
       
  3893 	                                      applicationID,
       
  3894 	                                      &keyExistsAndHasValidFormat);
       
  3895 	_res = Py_BuildValue("ll",
       
  3896 	                     _rv,
       
  3897 	                     keyExistsAndHasValidFormat);
       
  3898 	return _res;
       
  3899 }
       
  3900 
       
  3901 static PyObject *CF_CFPreferencesGetAppIntegerValue(PyObject *_self, PyObject *_args)
       
  3902 {
       
  3903 	PyObject *_res = NULL;
       
  3904 	CFIndex _rv;
       
  3905 	CFStringRef key;
       
  3906 	CFStringRef applicationID;
       
  3907 	Boolean keyExistsAndHasValidFormat;
       
  3908 #ifndef CFPreferencesGetAppIntegerValue
       
  3909 	PyMac_PRECHECK(CFPreferencesGetAppIntegerValue);
       
  3910 #endif
       
  3911 	if (!PyArg_ParseTuple(_args, "O&O&",
       
  3912 	                      CFStringRefObj_Convert, &key,
       
  3913 	                      CFStringRefObj_Convert, &applicationID))
       
  3914 		return NULL;
       
  3915 	_rv = CFPreferencesGetAppIntegerValue(key,
       
  3916 	                                      applicationID,
       
  3917 	                                      &keyExistsAndHasValidFormat);
       
  3918 	_res = Py_BuildValue("ll",
       
  3919 	                     _rv,
       
  3920 	                     keyExistsAndHasValidFormat);
       
  3921 	return _res;
       
  3922 }
       
  3923 
       
  3924 static PyObject *CF_CFPreferencesSetAppValue(PyObject *_self, PyObject *_args)
       
  3925 {
       
  3926 	PyObject *_res = NULL;
       
  3927 	CFStringRef key;
       
  3928 	CFTypeRef value;
       
  3929 	CFStringRef applicationID;
       
  3930 #ifndef CFPreferencesSetAppValue
       
  3931 	PyMac_PRECHECK(CFPreferencesSetAppValue);
       
  3932 #endif
       
  3933 	if (!PyArg_ParseTuple(_args, "O&O&O&",
       
  3934 	                      CFStringRefObj_Convert, &key,
       
  3935 	                      CFTypeRefObj_Convert, &value,
       
  3936 	                      CFStringRefObj_Convert, &applicationID))
       
  3937 		return NULL;
       
  3938 	CFPreferencesSetAppValue(key,
       
  3939 	                         value,
       
  3940 	                         applicationID);
       
  3941 	Py_INCREF(Py_None);
       
  3942 	_res = Py_None;
       
  3943 	return _res;
       
  3944 }
       
  3945 
       
  3946 static PyObject *CF_CFPreferencesAddSuitePreferencesToApp(PyObject *_self, PyObject *_args)
       
  3947 {
       
  3948 	PyObject *_res = NULL;
       
  3949 	CFStringRef applicationID;
       
  3950 	CFStringRef suiteID;
       
  3951 #ifndef CFPreferencesAddSuitePreferencesToApp
       
  3952 	PyMac_PRECHECK(CFPreferencesAddSuitePreferencesToApp);
       
  3953 #endif
       
  3954 	if (!PyArg_ParseTuple(_args, "O&O&",
       
  3955 	                      CFStringRefObj_Convert, &applicationID,
       
  3956 	                      CFStringRefObj_Convert, &suiteID))
       
  3957 		return NULL;
       
  3958 	CFPreferencesAddSuitePreferencesToApp(applicationID,
       
  3959 	                                      suiteID);
       
  3960 	Py_INCREF(Py_None);
       
  3961 	_res = Py_None;
       
  3962 	return _res;
       
  3963 }
       
  3964 
       
  3965 static PyObject *CF_CFPreferencesRemoveSuitePreferencesFromApp(PyObject *_self, PyObject *_args)
       
  3966 {
       
  3967 	PyObject *_res = NULL;
       
  3968 	CFStringRef applicationID;
       
  3969 	CFStringRef suiteID;
       
  3970 #ifndef CFPreferencesRemoveSuitePreferencesFromApp
       
  3971 	PyMac_PRECHECK(CFPreferencesRemoveSuitePreferencesFromApp);
       
  3972 #endif
       
  3973 	if (!PyArg_ParseTuple(_args, "O&O&",
       
  3974 	                      CFStringRefObj_Convert, &applicationID,
       
  3975 	                      CFStringRefObj_Convert, &suiteID))
       
  3976 		return NULL;
       
  3977 	CFPreferencesRemoveSuitePreferencesFromApp(applicationID,
       
  3978 	                                           suiteID);
       
  3979 	Py_INCREF(Py_None);
       
  3980 	_res = Py_None;
       
  3981 	return _res;
       
  3982 }
       
  3983 
       
  3984 static PyObject *CF_CFPreferencesAppSynchronize(PyObject *_self, PyObject *_args)
       
  3985 {
       
  3986 	PyObject *_res = NULL;
       
  3987 	Boolean _rv;
       
  3988 	CFStringRef applicationID;
       
  3989 #ifndef CFPreferencesAppSynchronize
       
  3990 	PyMac_PRECHECK(CFPreferencesAppSynchronize);
       
  3991 #endif
       
  3992 	if (!PyArg_ParseTuple(_args, "O&",
       
  3993 	                      CFStringRefObj_Convert, &applicationID))
       
  3994 		return NULL;
       
  3995 	_rv = CFPreferencesAppSynchronize(applicationID);
       
  3996 	_res = Py_BuildValue("l",
       
  3997 	                     _rv);
       
  3998 	return _res;
       
  3999 }
       
  4000 
       
  4001 static PyObject *CF_CFPreferencesCopyValue(PyObject *_self, PyObject *_args)
       
  4002 {
       
  4003 	PyObject *_res = NULL;
       
  4004 	CFTypeRef _rv;
       
  4005 	CFStringRef key;
       
  4006 	CFStringRef applicationID;
       
  4007 	CFStringRef userName;
       
  4008 	CFStringRef hostName;
       
  4009 #ifndef CFPreferencesCopyValue
       
  4010 	PyMac_PRECHECK(CFPreferencesCopyValue);
       
  4011 #endif
       
  4012 	if (!PyArg_ParseTuple(_args, "O&O&O&O&",
       
  4013 	                      CFStringRefObj_Convert, &key,
       
  4014 	                      CFStringRefObj_Convert, &applicationID,
       
  4015 	                      CFStringRefObj_Convert, &userName,
       
  4016 	                      CFStringRefObj_Convert, &hostName))
       
  4017 		return NULL;
       
  4018 	_rv = CFPreferencesCopyValue(key,
       
  4019 	                             applicationID,
       
  4020 	                             userName,
       
  4021 	                             hostName);
       
  4022 	_res = Py_BuildValue("O&",
       
  4023 	                     CFTypeRefObj_New, _rv);
       
  4024 	return _res;
       
  4025 }
       
  4026 
       
  4027 static PyObject *CF_CFPreferencesCopyMultiple(PyObject *_self, PyObject *_args)
       
  4028 {
       
  4029 	PyObject *_res = NULL;
       
  4030 	CFDictionaryRef _rv;
       
  4031 	CFArrayRef keysToFetch;
       
  4032 	CFStringRef applicationID;
       
  4033 	CFStringRef userName;
       
  4034 	CFStringRef hostName;
       
  4035 #ifndef CFPreferencesCopyMultiple
       
  4036 	PyMac_PRECHECK(CFPreferencesCopyMultiple);
       
  4037 #endif
       
  4038 	if (!PyArg_ParseTuple(_args, "O&O&O&O&",
       
  4039 	                      CFArrayRefObj_Convert, &keysToFetch,
       
  4040 	                      CFStringRefObj_Convert, &applicationID,
       
  4041 	                      CFStringRefObj_Convert, &userName,
       
  4042 	                      CFStringRefObj_Convert, &hostName))
       
  4043 		return NULL;
       
  4044 	_rv = CFPreferencesCopyMultiple(keysToFetch,
       
  4045 	                                applicationID,
       
  4046 	                                userName,
       
  4047 	                                hostName);
       
  4048 	_res = Py_BuildValue("O&",
       
  4049 	                     CFDictionaryRefObj_New, _rv);
       
  4050 	return _res;
       
  4051 }
       
  4052 
       
  4053 static PyObject *CF_CFPreferencesSetValue(PyObject *_self, PyObject *_args)
       
  4054 {
       
  4055 	PyObject *_res = NULL;
       
  4056 	CFStringRef key;
       
  4057 	CFTypeRef value;
       
  4058 	CFStringRef applicationID;
       
  4059 	CFStringRef userName;
       
  4060 	CFStringRef hostName;
       
  4061 #ifndef CFPreferencesSetValue
       
  4062 	PyMac_PRECHECK(CFPreferencesSetValue);
       
  4063 #endif
       
  4064 	if (!PyArg_ParseTuple(_args, "O&O&O&O&O&",
       
  4065 	                      CFStringRefObj_Convert, &key,
       
  4066 	                      CFTypeRefObj_Convert, &value,
       
  4067 	                      CFStringRefObj_Convert, &applicationID,
       
  4068 	                      CFStringRefObj_Convert, &userName,
       
  4069 	                      CFStringRefObj_Convert, &hostName))
       
  4070 		return NULL;
       
  4071 	CFPreferencesSetValue(key,
       
  4072 	                      value,
       
  4073 	                      applicationID,
       
  4074 	                      userName,
       
  4075 	                      hostName);
       
  4076 	Py_INCREF(Py_None);
       
  4077 	_res = Py_None;
       
  4078 	return _res;
       
  4079 }
       
  4080 
       
  4081 static PyObject *CF_CFPreferencesSetMultiple(PyObject *_self, PyObject *_args)
       
  4082 {
       
  4083 	PyObject *_res = NULL;
       
  4084 	CFDictionaryRef keysToSet;
       
  4085 	CFArrayRef keysToRemove;
       
  4086 	CFStringRef applicationID;
       
  4087 	CFStringRef userName;
       
  4088 	CFStringRef hostName;
       
  4089 #ifndef CFPreferencesSetMultiple
       
  4090 	PyMac_PRECHECK(CFPreferencesSetMultiple);
       
  4091 #endif
       
  4092 	if (!PyArg_ParseTuple(_args, "O&O&O&O&O&",
       
  4093 	                      CFDictionaryRefObj_Convert, &keysToSet,
       
  4094 	                      CFArrayRefObj_Convert, &keysToRemove,
       
  4095 	                      CFStringRefObj_Convert, &applicationID,
       
  4096 	                      CFStringRefObj_Convert, &userName,
       
  4097 	                      CFStringRefObj_Convert, &hostName))
       
  4098 		return NULL;
       
  4099 	CFPreferencesSetMultiple(keysToSet,
       
  4100 	                         keysToRemove,
       
  4101 	                         applicationID,
       
  4102 	                         userName,
       
  4103 	                         hostName);
       
  4104 	Py_INCREF(Py_None);
       
  4105 	_res = Py_None;
       
  4106 	return _res;
       
  4107 }
       
  4108 
       
  4109 static PyObject *CF_CFPreferencesSynchronize(PyObject *_self, PyObject *_args)
       
  4110 {
       
  4111 	PyObject *_res = NULL;
       
  4112 	Boolean _rv;
       
  4113 	CFStringRef applicationID;
       
  4114 	CFStringRef userName;
       
  4115 	CFStringRef hostName;
       
  4116 #ifndef CFPreferencesSynchronize
       
  4117 	PyMac_PRECHECK(CFPreferencesSynchronize);
       
  4118 #endif
       
  4119 	if (!PyArg_ParseTuple(_args, "O&O&O&",
       
  4120 	                      CFStringRefObj_Convert, &applicationID,
       
  4121 	                      CFStringRefObj_Convert, &userName,
       
  4122 	                      CFStringRefObj_Convert, &hostName))
       
  4123 		return NULL;
       
  4124 	_rv = CFPreferencesSynchronize(applicationID,
       
  4125 	                               userName,
       
  4126 	                               hostName);
       
  4127 	_res = Py_BuildValue("l",
       
  4128 	                     _rv);
       
  4129 	return _res;
       
  4130 }
       
  4131 
       
  4132 static PyObject *CF_CFPreferencesCopyApplicationList(PyObject *_self, PyObject *_args)
       
  4133 {
       
  4134 	PyObject *_res = NULL;
       
  4135 	CFArrayRef _rv;
       
  4136 	CFStringRef userName;
       
  4137 	CFStringRef hostName;
       
  4138 #ifndef CFPreferencesCopyApplicationList
       
  4139 	PyMac_PRECHECK(CFPreferencesCopyApplicationList);
       
  4140 #endif
       
  4141 	if (!PyArg_ParseTuple(_args, "O&O&",
       
  4142 	                      CFStringRefObj_Convert, &userName,
       
  4143 	                      CFStringRefObj_Convert, &hostName))
       
  4144 		return NULL;
       
  4145 	_rv = CFPreferencesCopyApplicationList(userName,
       
  4146 	                                       hostName);
       
  4147 	_res = Py_BuildValue("O&",
       
  4148 	                     CFArrayRefObj_New, _rv);
       
  4149 	return _res;
       
  4150 }
       
  4151 
       
  4152 static PyObject *CF_CFPreferencesCopyKeyList(PyObject *_self, PyObject *_args)
       
  4153 {
       
  4154 	PyObject *_res = NULL;
       
  4155 	CFArrayRef _rv;
       
  4156 	CFStringRef applicationID;
       
  4157 	CFStringRef userName;
       
  4158 	CFStringRef hostName;
       
  4159 #ifndef CFPreferencesCopyKeyList
       
  4160 	PyMac_PRECHECK(CFPreferencesCopyKeyList);
       
  4161 #endif
       
  4162 	if (!PyArg_ParseTuple(_args, "O&O&O&",
       
  4163 	                      CFStringRefObj_Convert, &applicationID,
       
  4164 	                      CFStringRefObj_Convert, &userName,
       
  4165 	                      CFStringRefObj_Convert, &hostName))
       
  4166 		return NULL;
       
  4167 	_rv = CFPreferencesCopyKeyList(applicationID,
       
  4168 	                               userName,
       
  4169 	                               hostName);
       
  4170 	_res = Py_BuildValue("O&",
       
  4171 	                     CFArrayRefObj_New, _rv);
       
  4172 	return _res;
       
  4173 }
       
  4174 
       
  4175 static PyObject *CF_CFStringGetTypeID(PyObject *_self, PyObject *_args)
       
  4176 {
       
  4177 	PyObject *_res = NULL;
       
  4178 	CFTypeID _rv;
       
  4179 #ifndef CFStringGetTypeID
       
  4180 	PyMac_PRECHECK(CFStringGetTypeID);
       
  4181 #endif
       
  4182 	if (!PyArg_ParseTuple(_args, ""))
       
  4183 		return NULL;
       
  4184 	_rv = CFStringGetTypeID();
       
  4185 	_res = Py_BuildValue("l",
       
  4186 	                     _rv);
       
  4187 	return _res;
       
  4188 }
       
  4189 
       
  4190 static PyObject *CF_CFStringCreateWithPascalString(PyObject *_self, PyObject *_args)
       
  4191 {
       
  4192 	PyObject *_res = NULL;
       
  4193 	CFStringRef _rv;
       
  4194 	Str255 pStr;
       
  4195 	CFStringEncoding encoding;
       
  4196 #ifndef CFStringCreateWithPascalString
       
  4197 	PyMac_PRECHECK(CFStringCreateWithPascalString);
       
  4198 #endif
       
  4199 	if (!PyArg_ParseTuple(_args, "O&l",
       
  4200 	                      PyMac_GetStr255, pStr,
       
  4201 	                      &encoding))
       
  4202 		return NULL;
       
  4203 	_rv = CFStringCreateWithPascalString((CFAllocatorRef)NULL,
       
  4204 	                                     pStr,
       
  4205 	                                     encoding);
       
  4206 	_res = Py_BuildValue("O&",
       
  4207 	                     CFStringRefObj_New, _rv);
       
  4208 	return _res;
       
  4209 }
       
  4210 
       
  4211 static PyObject *CF_CFStringCreateWithCString(PyObject *_self, PyObject *_args)
       
  4212 {
       
  4213 	PyObject *_res = NULL;
       
  4214 	CFStringRef _rv;
       
  4215 	char* cStr;
       
  4216 	CFStringEncoding encoding;
       
  4217 #ifndef CFStringCreateWithCString
       
  4218 	PyMac_PRECHECK(CFStringCreateWithCString);
       
  4219 #endif
       
  4220 	if (!PyArg_ParseTuple(_args, "sl",
       
  4221 	                      &cStr,
       
  4222 	                      &encoding))
       
  4223 		return NULL;
       
  4224 	_rv = CFStringCreateWithCString((CFAllocatorRef)NULL,
       
  4225 	                                cStr,
       
  4226 	                                encoding);
       
  4227 	_res = Py_BuildValue("O&",
       
  4228 	                     CFStringRefObj_New, _rv);
       
  4229 	return _res;
       
  4230 }
       
  4231 
       
  4232 static PyObject *CF_CFStringCreateWithCharacters(PyObject *_self, PyObject *_args)
       
  4233 {
       
  4234 	PyObject *_res = NULL;
       
  4235 	CFStringRef _rv;
       
  4236 	UniChar *chars__in__;
       
  4237 	UniCharCount chars__len__;
       
  4238 	int chars__in_len__;
       
  4239 #ifndef CFStringCreateWithCharacters
       
  4240 	PyMac_PRECHECK(CFStringCreateWithCharacters);
       
  4241 #endif
       
  4242 	if (!PyArg_ParseTuple(_args, "u#",
       
  4243 	                      &chars__in__, &chars__in_len__))
       
  4244 		return NULL;
       
  4245 	chars__len__ = chars__in_len__;
       
  4246 	_rv = CFStringCreateWithCharacters((CFAllocatorRef)NULL,
       
  4247 	                                   chars__in__, chars__len__);
       
  4248 	_res = Py_BuildValue("O&",
       
  4249 	                     CFStringRefObj_New, _rv);
       
  4250 	return _res;
       
  4251 }
       
  4252 
       
  4253 static PyObject *CF_CFStringCreateWithPascalStringNoCopy(PyObject *_self, PyObject *_args)
       
  4254 {
       
  4255 	PyObject *_res = NULL;
       
  4256 	CFStringRef _rv;
       
  4257 	Str255 pStr;
       
  4258 	CFStringEncoding encoding;
       
  4259 #ifndef CFStringCreateWithPascalStringNoCopy
       
  4260 	PyMac_PRECHECK(CFStringCreateWithPascalStringNoCopy);
       
  4261 #endif
       
  4262 	if (!PyArg_ParseTuple(_args, "O&l",
       
  4263 	                      PyMac_GetStr255, pStr,
       
  4264 	                      &encoding))
       
  4265 		return NULL;
       
  4266 	_rv = CFStringCreateWithPascalStringNoCopy((CFAllocatorRef)NULL,
       
  4267 	                                           pStr,
       
  4268 	                                           encoding,
       
  4269 	                                           (CFAllocatorRef)NULL);
       
  4270 	_res = Py_BuildValue("O&",
       
  4271 	                     CFStringRefObj_New, _rv);
       
  4272 	return _res;
       
  4273 }
       
  4274 
       
  4275 static PyObject *CF_CFStringCreateWithCStringNoCopy(PyObject *_self, PyObject *_args)
       
  4276 {
       
  4277 	PyObject *_res = NULL;
       
  4278 	CFStringRef _rv;
       
  4279 	char* cStr;
       
  4280 	CFStringEncoding encoding;
       
  4281 #ifndef CFStringCreateWithCStringNoCopy
       
  4282 	PyMac_PRECHECK(CFStringCreateWithCStringNoCopy);
       
  4283 #endif
       
  4284 	if (!PyArg_ParseTuple(_args, "sl",
       
  4285 	                      &cStr,
       
  4286 	                      &encoding))
       
  4287 		return NULL;
       
  4288 	_rv = CFStringCreateWithCStringNoCopy((CFAllocatorRef)NULL,
       
  4289 	                                      cStr,
       
  4290 	                                      encoding,
       
  4291 	                                      (CFAllocatorRef)NULL);
       
  4292 	_res = Py_BuildValue("O&",
       
  4293 	                     CFStringRefObj_New, _rv);
       
  4294 	return _res;
       
  4295 }
       
  4296 
       
  4297 static PyObject *CF_CFStringCreateWithCharactersNoCopy(PyObject *_self, PyObject *_args)
       
  4298 {
       
  4299 	PyObject *_res = NULL;
       
  4300 	CFStringRef _rv;
       
  4301 	UniChar *chars__in__;
       
  4302 	UniCharCount chars__len__;
       
  4303 	int chars__in_len__;
       
  4304 #ifndef CFStringCreateWithCharactersNoCopy
       
  4305 	PyMac_PRECHECK(CFStringCreateWithCharactersNoCopy);
       
  4306 #endif
       
  4307 	if (!PyArg_ParseTuple(_args, "u#",
       
  4308 	                      &chars__in__, &chars__in_len__))
       
  4309 		return NULL;
       
  4310 	chars__len__ = chars__in_len__;
       
  4311 	_rv = CFStringCreateWithCharactersNoCopy((CFAllocatorRef)NULL,
       
  4312 	                                         chars__in__, chars__len__,
       
  4313 	                                         (CFAllocatorRef)NULL);
       
  4314 	_res = Py_BuildValue("O&",
       
  4315 	                     CFStringRefObj_New, _rv);
       
  4316 	return _res;
       
  4317 }
       
  4318 
       
  4319 static PyObject *CF_CFStringCreateMutable(PyObject *_self, PyObject *_args)
       
  4320 {
       
  4321 	PyObject *_res = NULL;
       
  4322 	CFMutableStringRef _rv;
       
  4323 	CFIndex maxLength;
       
  4324 #ifndef CFStringCreateMutable
       
  4325 	PyMac_PRECHECK(CFStringCreateMutable);
       
  4326 #endif
       
  4327 	if (!PyArg_ParseTuple(_args, "l",
       
  4328 	                      &maxLength))
       
  4329 		return NULL;
       
  4330 	_rv = CFStringCreateMutable((CFAllocatorRef)NULL,
       
  4331 	                            maxLength);
       
  4332 	_res = Py_BuildValue("O&",
       
  4333 	                     CFMutableStringRefObj_New, _rv);
       
  4334 	return _res;
       
  4335 }
       
  4336 
       
  4337 static PyObject *CF_CFStringCreateMutableCopy(PyObject *_self, PyObject *_args)
       
  4338 {
       
  4339 	PyObject *_res = NULL;
       
  4340 	CFMutableStringRef _rv;
       
  4341 	CFIndex maxLength;
       
  4342 	CFStringRef theString;
       
  4343 #ifndef CFStringCreateMutableCopy
       
  4344 	PyMac_PRECHECK(CFStringCreateMutableCopy);
       
  4345 #endif
       
  4346 	if (!PyArg_ParseTuple(_args, "lO&",
       
  4347 	                      &maxLength,
       
  4348 	                      CFStringRefObj_Convert, &theString))
       
  4349 		return NULL;
       
  4350 	_rv = CFStringCreateMutableCopy((CFAllocatorRef)NULL,
       
  4351 	                                maxLength,
       
  4352 	                                theString);
       
  4353 	_res = Py_BuildValue("O&",
       
  4354 	                     CFMutableStringRefObj_New, _rv);
       
  4355 	return _res;
       
  4356 }
       
  4357 
       
  4358 static PyObject *CF_CFStringCreateWithBytes(PyObject *_self, PyObject *_args)
       
  4359 {
       
  4360 	PyObject *_res = NULL;
       
  4361 	CFStringRef _rv;
       
  4362 	unsigned char *bytes__in__;
       
  4363 	long bytes__len__;
       
  4364 	int bytes__in_len__;
       
  4365 	CFStringEncoding encoding;
       
  4366 	Boolean isExternalRepresentation;
       
  4367 #ifndef CFStringCreateWithBytes
       
  4368 	PyMac_PRECHECK(CFStringCreateWithBytes);
       
  4369 #endif
       
  4370 	if (!PyArg_ParseTuple(_args, "s#ll",
       
  4371 	                      &bytes__in__, &bytes__in_len__,
       
  4372 	                      &encoding,
       
  4373 	                      &isExternalRepresentation))
       
  4374 		return NULL;
       
  4375 	bytes__len__ = bytes__in_len__;
       
  4376 	_rv = CFStringCreateWithBytes((CFAllocatorRef)NULL,
       
  4377 	                              bytes__in__, bytes__len__,
       
  4378 	                              encoding,
       
  4379 	                              isExternalRepresentation);
       
  4380 	_res = Py_BuildValue("O&",
       
  4381 	                     CFStringRefObj_New, _rv);
       
  4382 	return _res;
       
  4383 }
       
  4384 
       
  4385 static PyObject *CF_CFStringGetSystemEncoding(PyObject *_self, PyObject *_args)
       
  4386 {
       
  4387 	PyObject *_res = NULL;
       
  4388 	CFStringEncoding _rv;
       
  4389 #ifndef CFStringGetSystemEncoding
       
  4390 	PyMac_PRECHECK(CFStringGetSystemEncoding);
       
  4391 #endif
       
  4392 	if (!PyArg_ParseTuple(_args, ""))
       
  4393 		return NULL;
       
  4394 	_rv = CFStringGetSystemEncoding();
       
  4395 	_res = Py_BuildValue("l",
       
  4396 	                     _rv);
       
  4397 	return _res;
       
  4398 }
       
  4399 
       
  4400 static PyObject *CF_CFStringGetMaximumSizeForEncoding(PyObject *_self, PyObject *_args)
       
  4401 {
       
  4402 	PyObject *_res = NULL;
       
  4403 	CFIndex _rv;
       
  4404 	CFIndex length;
       
  4405 	CFStringEncoding encoding;
       
  4406 #ifndef CFStringGetMaximumSizeForEncoding
       
  4407 	PyMac_PRECHECK(CFStringGetMaximumSizeForEncoding);
       
  4408 #endif
       
  4409 	if (!PyArg_ParseTuple(_args, "ll",
       
  4410 	                      &length,
       
  4411 	                      &encoding))
       
  4412 		return NULL;
       
  4413 	_rv = CFStringGetMaximumSizeForEncoding(length,
       
  4414 	                                        encoding);
       
  4415 	_res = Py_BuildValue("l",
       
  4416 	                     _rv);
       
  4417 	return _res;
       
  4418 }
       
  4419 
       
  4420 static PyObject *CF_CFStringIsEncodingAvailable(PyObject *_self, PyObject *_args)
       
  4421 {
       
  4422 	PyObject *_res = NULL;
       
  4423 	Boolean _rv;
       
  4424 	CFStringEncoding encoding;
       
  4425 #ifndef CFStringIsEncodingAvailable
       
  4426 	PyMac_PRECHECK(CFStringIsEncodingAvailable);
       
  4427 #endif
       
  4428 	if (!PyArg_ParseTuple(_args, "l",
       
  4429 	                      &encoding))
       
  4430 		return NULL;
       
  4431 	_rv = CFStringIsEncodingAvailable(encoding);
       
  4432 	_res = Py_BuildValue("l",
       
  4433 	                     _rv);
       
  4434 	return _res;
       
  4435 }
       
  4436 
       
  4437 static PyObject *CF_CFStringGetNameOfEncoding(PyObject *_self, PyObject *_args)
       
  4438 {
       
  4439 	PyObject *_res = NULL;
       
  4440 	CFStringRef _rv;
       
  4441 	CFStringEncoding encoding;
       
  4442 #ifndef CFStringGetNameOfEncoding
       
  4443 	PyMac_PRECHECK(CFStringGetNameOfEncoding);
       
  4444 #endif
       
  4445 	if (!PyArg_ParseTuple(_args, "l",
       
  4446 	                      &encoding))
       
  4447 		return NULL;
       
  4448 	_rv = CFStringGetNameOfEncoding(encoding);
       
  4449 	_res = Py_BuildValue("O&",
       
  4450 	                     CFStringRefObj_New, _rv);
       
  4451 	return _res;
       
  4452 }
       
  4453 
       
  4454 static PyObject *CF_CFStringConvertEncodingToNSStringEncoding(PyObject *_self, PyObject *_args)
       
  4455 {
       
  4456 	PyObject *_res = NULL;
       
  4457 	UInt32 _rv;
       
  4458 	CFStringEncoding encoding;
       
  4459 #ifndef CFStringConvertEncodingToNSStringEncoding
       
  4460 	PyMac_PRECHECK(CFStringConvertEncodingToNSStringEncoding);
       
  4461 #endif
       
  4462 	if (!PyArg_ParseTuple(_args, "l",
       
  4463 	                      &encoding))
       
  4464 		return NULL;
       
  4465 	_rv = CFStringConvertEncodingToNSStringEncoding(encoding);
       
  4466 	_res = Py_BuildValue("l",
       
  4467 	                     _rv);
       
  4468 	return _res;
       
  4469 }
       
  4470 
       
  4471 static PyObject *CF_CFStringConvertNSStringEncodingToEncoding(PyObject *_self, PyObject *_args)
       
  4472 {
       
  4473 	PyObject *_res = NULL;
       
  4474 	CFStringEncoding _rv;
       
  4475 	UInt32 encoding;
       
  4476 #ifndef CFStringConvertNSStringEncodingToEncoding
       
  4477 	PyMac_PRECHECK(CFStringConvertNSStringEncodingToEncoding);
       
  4478 #endif
       
  4479 	if (!PyArg_ParseTuple(_args, "l",
       
  4480 	                      &encoding))
       
  4481 		return NULL;
       
  4482 	_rv = CFStringConvertNSStringEncodingToEncoding(encoding);
       
  4483 	_res = Py_BuildValue("l",
       
  4484 	                     _rv);
       
  4485 	return _res;
       
  4486 }
       
  4487 
       
  4488 static PyObject *CF_CFStringConvertEncodingToWindowsCodepage(PyObject *_self, PyObject *_args)
       
  4489 {
       
  4490 	PyObject *_res = NULL;
       
  4491 	UInt32 _rv;
       
  4492 	CFStringEncoding encoding;
       
  4493 #ifndef CFStringConvertEncodingToWindowsCodepage
       
  4494 	PyMac_PRECHECK(CFStringConvertEncodingToWindowsCodepage);
       
  4495 #endif
       
  4496 	if (!PyArg_ParseTuple(_args, "l",
       
  4497 	                      &encoding))
       
  4498 		return NULL;
       
  4499 	_rv = CFStringConvertEncodingToWindowsCodepage(encoding);
       
  4500 	_res = Py_BuildValue("l",
       
  4501 	                     _rv);
       
  4502 	return _res;
       
  4503 }
       
  4504 
       
  4505 static PyObject *CF_CFStringConvertWindowsCodepageToEncoding(PyObject *_self, PyObject *_args)
       
  4506 {
       
  4507 	PyObject *_res = NULL;
       
  4508 	CFStringEncoding _rv;
       
  4509 	UInt32 codepage;
       
  4510 #ifndef CFStringConvertWindowsCodepageToEncoding
       
  4511 	PyMac_PRECHECK(CFStringConvertWindowsCodepageToEncoding);
       
  4512 #endif
       
  4513 	if (!PyArg_ParseTuple(_args, "l",
       
  4514 	                      &codepage))
       
  4515 		return NULL;
       
  4516 	_rv = CFStringConvertWindowsCodepageToEncoding(codepage);
       
  4517 	_res = Py_BuildValue("l",
       
  4518 	                     _rv);
       
  4519 	return _res;
       
  4520 }
       
  4521 
       
  4522 static PyObject *CF_CFStringConvertEncodingToIANACharSetName(PyObject *_self, PyObject *_args)
       
  4523 {
       
  4524 	PyObject *_res = NULL;
       
  4525 	CFStringRef _rv;
       
  4526 	CFStringEncoding encoding;
       
  4527 #ifndef CFStringConvertEncodingToIANACharSetName
       
  4528 	PyMac_PRECHECK(CFStringConvertEncodingToIANACharSetName);
       
  4529 #endif
       
  4530 	if (!PyArg_ParseTuple(_args, "l",
       
  4531 	                      &encoding))
       
  4532 		return NULL;
       
  4533 	_rv = CFStringConvertEncodingToIANACharSetName(encoding);
       
  4534 	_res = Py_BuildValue("O&",
       
  4535 	                     CFStringRefObj_New, _rv);
       
  4536 	return _res;
       
  4537 }
       
  4538 
       
  4539 static PyObject *CF_CFStringGetMostCompatibleMacStringEncoding(PyObject *_self, PyObject *_args)
       
  4540 {
       
  4541 	PyObject *_res = NULL;
       
  4542 	CFStringEncoding _rv;
       
  4543 	CFStringEncoding encoding;
       
  4544 #ifndef CFStringGetMostCompatibleMacStringEncoding
       
  4545 	PyMac_PRECHECK(CFStringGetMostCompatibleMacStringEncoding);
       
  4546 #endif
       
  4547 	if (!PyArg_ParseTuple(_args, "l",
       
  4548 	                      &encoding))
       
  4549 		return NULL;
       
  4550 	_rv = CFStringGetMostCompatibleMacStringEncoding(encoding);
       
  4551 	_res = Py_BuildValue("l",
       
  4552 	                     _rv);
       
  4553 	return _res;
       
  4554 }
       
  4555 
       
  4556 static PyObject *CF___CFStringMakeConstantString(PyObject *_self, PyObject *_args)
       
  4557 {
       
  4558 	PyObject *_res = NULL;
       
  4559 	CFStringRef _rv;
       
  4560 	char* cStr;
       
  4561 #ifndef __CFStringMakeConstantString
       
  4562 	PyMac_PRECHECK(__CFStringMakeConstantString);
       
  4563 #endif
       
  4564 	if (!PyArg_ParseTuple(_args, "s",
       
  4565 	                      &cStr))
       
  4566 		return NULL;
       
  4567 	_rv = __CFStringMakeConstantString(cStr);
       
  4568 	_res = Py_BuildValue("O&",
       
  4569 	                     CFStringRefObj_New, _rv);
       
  4570 	return _res;
       
  4571 }
       
  4572 
       
  4573 static PyObject *CF_CFURLGetTypeID(PyObject *_self, PyObject *_args)
       
  4574 {
       
  4575 	PyObject *_res = NULL;
       
  4576 	CFTypeID _rv;
       
  4577 #ifndef CFURLGetTypeID
       
  4578 	PyMac_PRECHECK(CFURLGetTypeID);
       
  4579 #endif
       
  4580 	if (!PyArg_ParseTuple(_args, ""))
       
  4581 		return NULL;
       
  4582 	_rv = CFURLGetTypeID();
       
  4583 	_res = Py_BuildValue("l",
       
  4584 	                     _rv);
       
  4585 	return _res;
       
  4586 }
       
  4587 
       
  4588 static PyObject *CF_CFURLCreateWithBytes(PyObject *_self, PyObject *_args)
       
  4589 {
       
  4590 	PyObject *_res = NULL;
       
  4591 	CFURLRef _rv;
       
  4592 	unsigned char *URLBytes__in__;
       
  4593 	long URLBytes__len__;
       
  4594 	int URLBytes__in_len__;
       
  4595 	CFStringEncoding encoding;
       
  4596 	CFURLRef baseURL;
       
  4597 #ifndef CFURLCreateWithBytes
       
  4598 	PyMac_PRECHECK(CFURLCreateWithBytes);
       
  4599 #endif
       
  4600 	if (!PyArg_ParseTuple(_args, "s#lO&",
       
  4601 	                      &URLBytes__in__, &URLBytes__in_len__,
       
  4602 	                      &encoding,
       
  4603 	                      OptionalCFURLRefObj_Convert, &baseURL))
       
  4604 		return NULL;
       
  4605 	URLBytes__len__ = URLBytes__in_len__;
       
  4606 	_rv = CFURLCreateWithBytes((CFAllocatorRef)NULL,
       
  4607 	                           URLBytes__in__, URLBytes__len__,
       
  4608 	                           encoding,
       
  4609 	                           baseURL);
       
  4610 	_res = Py_BuildValue("O&",
       
  4611 	                     CFURLRefObj_New, _rv);
       
  4612 	return _res;
       
  4613 }
       
  4614 
       
  4615 static PyObject *CF_CFURLCreateFromFileSystemRepresentation(PyObject *_self, PyObject *_args)
       
  4616 {
       
  4617 	PyObject *_res = NULL;
       
  4618 	CFURLRef _rv;
       
  4619 	unsigned char *buffer__in__;
       
  4620 	long buffer__len__;
       
  4621 	int buffer__in_len__;
       
  4622 	Boolean isDirectory;
       
  4623 #ifndef CFURLCreateFromFileSystemRepresentation
       
  4624 	PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentation);
       
  4625 #endif
       
  4626 	if (!PyArg_ParseTuple(_args, "s#l",
       
  4627 	                      &buffer__in__, &buffer__in_len__,
       
  4628 	                      &isDirectory))
       
  4629 		return NULL;
       
  4630 	buffer__len__ = buffer__in_len__;
       
  4631 	_rv = CFURLCreateFromFileSystemRepresentation((CFAllocatorRef)NULL,
       
  4632 	                                              buffer__in__, buffer__len__,
       
  4633 	                                              isDirectory);
       
  4634 	_res = Py_BuildValue("O&",
       
  4635 	                     CFURLRefObj_New, _rv);
       
  4636 	return _res;
       
  4637 }
       
  4638 
       
  4639 static PyObject *CF_CFURLCreateFromFileSystemRepresentationRelativeToBase(PyObject *_self, PyObject *_args)
       
  4640 {
       
  4641 	PyObject *_res = NULL;
       
  4642 	CFURLRef _rv;
       
  4643 	unsigned char *buffer__in__;
       
  4644 	long buffer__len__;
       
  4645 	int buffer__in_len__;
       
  4646 	Boolean isDirectory;
       
  4647 	CFURLRef baseURL;
       
  4648 #ifndef CFURLCreateFromFileSystemRepresentationRelativeToBase
       
  4649 	PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentationRelativeToBase);
       
  4650 #endif
       
  4651 	if (!PyArg_ParseTuple(_args, "s#lO&",
       
  4652 	                      &buffer__in__, &buffer__in_len__,
       
  4653 	                      &isDirectory,
       
  4654 	                      OptionalCFURLRefObj_Convert, &baseURL))
       
  4655 		return NULL;
       
  4656 	buffer__len__ = buffer__in_len__;
       
  4657 	_rv = CFURLCreateFromFileSystemRepresentationRelativeToBase((CFAllocatorRef)NULL,
       
  4658 	                                                            buffer__in__, buffer__len__,
       
  4659 	                                                            isDirectory,
       
  4660 	                                                            baseURL);
       
  4661 	_res = Py_BuildValue("O&",
       
  4662 	                     CFURLRefObj_New, _rv);
       
  4663 	return _res;
       
  4664 }
       
  4665 
       
  4666 static PyObject *CF_CFURLCreateFromFSRef(PyObject *_self, PyObject *_args)
       
  4667 {
       
  4668 	PyObject *_res = NULL;
       
  4669 	CFURLRef _rv;
       
  4670 	FSRef fsRef;
       
  4671 #ifndef CFURLCreateFromFSRef
       
  4672 	PyMac_PRECHECK(CFURLCreateFromFSRef);
       
  4673 #endif
       
  4674 	if (!PyArg_ParseTuple(_args, "O&",
       
  4675 	                      PyMac_GetFSRef, &fsRef))
       
  4676 		return NULL;
       
  4677 	_rv = CFURLCreateFromFSRef((CFAllocatorRef)NULL,
       
  4678 	                           &fsRef);
       
  4679 	_res = Py_BuildValue("O&",
       
  4680 	                     CFURLRefObj_New, _rv);
       
  4681 	return _res;
       
  4682 }
       
  4683 
       
  4684 static PyObject *CF_toCF(PyObject *_self, PyObject *_args)
       
  4685 {
       
  4686 	PyObject *_res = NULL;
       
  4687 
       
  4688 	CFTypeRef rv;
       
  4689 	CFTypeID typeid;
       
  4690 
       
  4691 	if (!PyArg_ParseTuple(_args, "O&", PyCF_Python2CF, &rv))
       
  4692 	        return NULL;
       
  4693 	typeid = CFGetTypeID(rv);
       
  4694 
       
  4695 	if (typeid == CFStringGetTypeID())
       
  4696 	        return Py_BuildValue("O&", CFStringRefObj_New, rv);
       
  4697 	if (typeid == CFArrayGetTypeID())
       
  4698 	        return Py_BuildValue("O&", CFArrayRefObj_New, rv);
       
  4699 	if (typeid == CFDictionaryGetTypeID())
       
  4700 	        return Py_BuildValue("O&", CFDictionaryRefObj_New, rv);
       
  4701 	if (typeid == CFURLGetTypeID())
       
  4702 	        return Py_BuildValue("O&", CFURLRefObj_New, rv);
       
  4703 
       
  4704 	_res = Py_BuildValue("O&", CFTypeRefObj_New, rv);
       
  4705 	return _res;
       
  4706 
       
  4707 }
       
  4708 
       
  4709 static PyMethodDef CF_methods[] = {
       
  4710 	{"__CFRangeMake", (PyCFunction)CF___CFRangeMake, 1,
       
  4711 	 PyDoc_STR("(CFIndex loc, CFIndex len) -> (CFRange _rv)")},
       
  4712 	{"CFAllocatorGetTypeID", (PyCFunction)CF_CFAllocatorGetTypeID, 1,
       
  4713 	 PyDoc_STR("() -> (CFTypeID _rv)")},
       
  4714 	{"CFAllocatorGetPreferredSizeForSize", (PyCFunction)CF_CFAllocatorGetPreferredSizeForSize, 1,
       
  4715 	 PyDoc_STR("(CFIndex size, CFOptionFlags hint) -> (CFIndex _rv)")},
       
  4716 	{"CFCopyTypeIDDescription", (PyCFunction)CF_CFCopyTypeIDDescription, 1,
       
  4717 	 PyDoc_STR("(CFTypeID type_id) -> (CFStringRef _rv)")},
       
  4718 	{"CFArrayGetTypeID", (PyCFunction)CF_CFArrayGetTypeID, 1,
       
  4719 	 PyDoc_STR("() -> (CFTypeID _rv)")},
       
  4720 	{"CFArrayCreateMutable", (PyCFunction)CF_CFArrayCreateMutable, 1,
       
  4721 	 PyDoc_STR("(CFIndex capacity) -> (CFMutableArrayRef _rv)")},
       
  4722 	{"CFArrayCreateMutableCopy", (PyCFunction)CF_CFArrayCreateMutableCopy, 1,
       
  4723 	 PyDoc_STR("(CFIndex capacity, CFArrayRef theArray) -> (CFMutableArrayRef _rv)")},
       
  4724 	{"CFDataGetTypeID", (PyCFunction)CF_CFDataGetTypeID, 1,
       
  4725 	 PyDoc_STR("() -> (CFTypeID _rv)")},
       
  4726 	{"CFDataCreate", (PyCFunction)CF_CFDataCreate, 1,
       
  4727 	 PyDoc_STR("(Buffer bytes) -> (CFDataRef _rv)")},
       
  4728 	{"CFDataCreateWithBytesNoCopy", (PyCFunction)CF_CFDataCreateWithBytesNoCopy, 1,
       
  4729 	 PyDoc_STR("(Buffer bytes) -> (CFDataRef _rv)")},
       
  4730 	{"CFDataCreateMutable", (PyCFunction)CF_CFDataCreateMutable, 1,
       
  4731 	 PyDoc_STR("(CFIndex capacity) -> (CFMutableDataRef _rv)")},
       
  4732 	{"CFDataCreateMutableCopy", (PyCFunction)CF_CFDataCreateMutableCopy, 1,
       
  4733 	 PyDoc_STR("(CFIndex capacity, CFDataRef theData) -> (CFMutableDataRef _rv)")},
       
  4734 	{"CFDictionaryGetTypeID", (PyCFunction)CF_CFDictionaryGetTypeID, 1,
       
  4735 	 PyDoc_STR("() -> (CFTypeID _rv)")},
       
  4736 	{"CFDictionaryCreateMutable", (PyCFunction)CF_CFDictionaryCreateMutable, 1,
       
  4737 	 PyDoc_STR("(CFIndex capacity) -> (CFMutableDictionaryRef _rv)")},
       
  4738 	{"CFDictionaryCreateMutableCopy", (PyCFunction)CF_CFDictionaryCreateMutableCopy, 1,
       
  4739 	 PyDoc_STR("(CFIndex capacity, CFDictionaryRef theDict) -> (CFMutableDictionaryRef _rv)")},
       
  4740 	{"CFPreferencesCopyAppValue", (PyCFunction)CF_CFPreferencesCopyAppValue, 1,
       
  4741 	 PyDoc_STR("(CFStringRef key, CFStringRef applicationID) -> (CFTypeRef _rv)")},
       
  4742 	{"CFPreferencesGetAppBooleanValue", (PyCFunction)CF_CFPreferencesGetAppBooleanValue, 1,
       
  4743 	 PyDoc_STR("(CFStringRef key, CFStringRef applicationID) -> (Boolean _rv, Boolean keyExistsAndHasValidFormat)")},
       
  4744 	{"CFPreferencesGetAppIntegerValue", (PyCFunction)CF_CFPreferencesGetAppIntegerValue, 1,
       
  4745 	 PyDoc_STR("(CFStringRef key, CFStringRef applicationID) -> (CFIndex _rv, Boolean keyExistsAndHasValidFormat)")},
       
  4746 	{"CFPreferencesSetAppValue", (PyCFunction)CF_CFPreferencesSetAppValue, 1,
       
  4747 	 PyDoc_STR("(CFStringRef key, CFTypeRef value, CFStringRef applicationID) -> None")},
       
  4748 	{"CFPreferencesAddSuitePreferencesToApp", (PyCFunction)CF_CFPreferencesAddSuitePreferencesToApp, 1,
       
  4749 	 PyDoc_STR("(CFStringRef applicationID, CFStringRef suiteID) -> None")},
       
  4750 	{"CFPreferencesRemoveSuitePreferencesFromApp", (PyCFunction)CF_CFPreferencesRemoveSuitePreferencesFromApp, 1,
       
  4751 	 PyDoc_STR("(CFStringRef applicationID, CFStringRef suiteID) -> None")},
       
  4752 	{"CFPreferencesAppSynchronize", (PyCFunction)CF_CFPreferencesAppSynchronize, 1,
       
  4753 	 PyDoc_STR("(CFStringRef applicationID) -> (Boolean _rv)")},
       
  4754 	{"CFPreferencesCopyValue", (PyCFunction)CF_CFPreferencesCopyValue, 1,
       
  4755 	 PyDoc_STR("(CFStringRef key, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFTypeRef _rv)")},
       
  4756 	{"CFPreferencesCopyMultiple", (PyCFunction)CF_CFPreferencesCopyMultiple, 1,
       
  4757 	 PyDoc_STR("(CFArrayRef keysToFetch, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFDictionaryRef _rv)")},
       
  4758 	{"CFPreferencesSetValue", (PyCFunction)CF_CFPreferencesSetValue, 1,
       
  4759 	 PyDoc_STR("(CFStringRef key, CFTypeRef value, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None")},
       
  4760 	{"CFPreferencesSetMultiple", (PyCFunction)CF_CFPreferencesSetMultiple, 1,
       
  4761 	 PyDoc_STR("(CFDictionaryRef keysToSet, CFArrayRef keysToRemove, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None")},
       
  4762 	{"CFPreferencesSynchronize", (PyCFunction)CF_CFPreferencesSynchronize, 1,
       
  4763 	 PyDoc_STR("(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (Boolean _rv)")},
       
  4764 	{"CFPreferencesCopyApplicationList", (PyCFunction)CF_CFPreferencesCopyApplicationList, 1,
       
  4765 	 PyDoc_STR("(CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)")},
       
  4766 	{"CFPreferencesCopyKeyList", (PyCFunction)CF_CFPreferencesCopyKeyList, 1,
       
  4767 	 PyDoc_STR("(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)")},
       
  4768 	{"CFStringGetTypeID", (PyCFunction)CF_CFStringGetTypeID, 1,
       
  4769 	 PyDoc_STR("() -> (CFTypeID _rv)")},
       
  4770 	{"CFStringCreateWithPascalString", (PyCFunction)CF_CFStringCreateWithPascalString, 1,
       
  4771 	 PyDoc_STR("(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)")},
       
  4772 	{"CFStringCreateWithCString", (PyCFunction)CF_CFStringCreateWithCString, 1,
       
  4773 	 PyDoc_STR("(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)")},
       
  4774 	{"CFStringCreateWithCharacters", (PyCFunction)CF_CFStringCreateWithCharacters, 1,
       
  4775 	 PyDoc_STR("(Buffer chars) -> (CFStringRef _rv)")},
       
  4776 	{"CFStringCreateWithPascalStringNoCopy", (PyCFunction)CF_CFStringCreateWithPascalStringNoCopy, 1,
       
  4777 	 PyDoc_STR("(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)")},
       
  4778 	{"CFStringCreateWithCStringNoCopy", (PyCFunction)CF_CFStringCreateWithCStringNoCopy, 1,
       
  4779 	 PyDoc_STR("(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)")},
       
  4780 	{"CFStringCreateWithCharactersNoCopy", (PyCFunction)CF_CFStringCreateWithCharactersNoCopy, 1,
       
  4781 	 PyDoc_STR("(Buffer chars) -> (CFStringRef _rv)")},
       
  4782 	{"CFStringCreateMutable", (PyCFunction)CF_CFStringCreateMutable, 1,
       
  4783 	 PyDoc_STR("(CFIndex maxLength) -> (CFMutableStringRef _rv)")},
       
  4784 	{"CFStringCreateMutableCopy", (PyCFunction)CF_CFStringCreateMutableCopy, 1,
       
  4785 	 PyDoc_STR("(CFIndex maxLength, CFStringRef theString) -> (CFMutableStringRef _rv)")},
       
  4786 	{"CFStringCreateWithBytes", (PyCFunction)CF_CFStringCreateWithBytes, 1,
       
  4787 	 PyDoc_STR("(Buffer bytes, CFStringEncoding encoding, Boolean isExternalRepresentation) -> (CFStringRef _rv)")},
       
  4788 	{"CFStringGetSystemEncoding", (PyCFunction)CF_CFStringGetSystemEncoding, 1,
       
  4789 	 PyDoc_STR("() -> (CFStringEncoding _rv)")},
       
  4790 	{"CFStringGetMaximumSizeForEncoding", (PyCFunction)CF_CFStringGetMaximumSizeForEncoding, 1,
       
  4791 	 PyDoc_STR("(CFIndex length, CFStringEncoding encoding) -> (CFIndex _rv)")},
       
  4792 	{"CFStringIsEncodingAvailable", (PyCFunction)CF_CFStringIsEncodingAvailable, 1,
       
  4793 	 PyDoc_STR("(CFStringEncoding encoding) -> (Boolean _rv)")},
       
  4794 	{"CFStringGetNameOfEncoding", (PyCFunction)CF_CFStringGetNameOfEncoding, 1,
       
  4795 	 PyDoc_STR("(CFStringEncoding encoding) -> (CFStringRef _rv)")},
       
  4796 	{"CFStringConvertEncodingToNSStringEncoding", (PyCFunction)CF_CFStringConvertEncodingToNSStringEncoding, 1,
       
  4797 	 PyDoc_STR("(CFStringEncoding encoding) -> (UInt32 _rv)")},
       
  4798 	{"CFStringConvertNSStringEncodingToEncoding", (PyCFunction)CF_CFStringConvertNSStringEncodingToEncoding, 1,
       
  4799 	 PyDoc_STR("(UInt32 encoding) -> (CFStringEncoding _rv)")},
       
  4800 	{"CFStringConvertEncodingToWindowsCodepage", (PyCFunction)CF_CFStringConvertEncodingToWindowsCodepage, 1,
       
  4801 	 PyDoc_STR("(CFStringEncoding encoding) -> (UInt32 _rv)")},
       
  4802 	{"CFStringConvertWindowsCodepageToEncoding", (PyCFunction)CF_CFStringConvertWindowsCodepageToEncoding, 1,
       
  4803 	 PyDoc_STR("(UInt32 codepage) -> (CFStringEncoding _rv)")},
       
  4804 	{"CFStringConvertEncodingToIANACharSetName", (PyCFunction)CF_CFStringConvertEncodingToIANACharSetName, 1,
       
  4805 	 PyDoc_STR("(CFStringEncoding encoding) -> (CFStringRef _rv)")},
       
  4806 	{"CFStringGetMostCompatibleMacStringEncoding", (PyCFunction)CF_CFStringGetMostCompatibleMacStringEncoding, 1,
       
  4807 	 PyDoc_STR("(CFStringEncoding encoding) -> (CFStringEncoding _rv)")},
       
  4808 	{"__CFStringMakeConstantString", (PyCFunction)CF___CFStringMakeConstantString, 1,
       
  4809 	 PyDoc_STR("(char* cStr) -> (CFStringRef _rv)")},
       
  4810 	{"CFURLGetTypeID", (PyCFunction)CF_CFURLGetTypeID, 1,
       
  4811 	 PyDoc_STR("() -> (CFTypeID _rv)")},
       
  4812 	{"CFURLCreateWithBytes", (PyCFunction)CF_CFURLCreateWithBytes, 1,
       
  4813 	 PyDoc_STR("(Buffer URLBytes, CFStringEncoding encoding, CFURLRef baseURL) -> (CFURLRef _rv)")},
       
  4814 	{"CFURLCreateFromFileSystemRepresentation", (PyCFunction)CF_CFURLCreateFromFileSystemRepresentation, 1,
       
  4815 	 PyDoc_STR("(Buffer buffer, Boolean isDirectory) -> (CFURLRef _rv)")},
       
  4816 	{"CFURLCreateFromFileSystemRepresentationRelativeToBase", (PyCFunction)CF_CFURLCreateFromFileSystemRepresentationRelativeToBase, 1,
       
  4817 	 PyDoc_STR("(Buffer buffer, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)")},
       
  4818 	{"CFURLCreateFromFSRef", (PyCFunction)CF_CFURLCreateFromFSRef, 1,
       
  4819 	 PyDoc_STR("(FSRef fsRef) -> (CFURLRef _rv)")},
       
  4820 	{"toCF", (PyCFunction)CF_toCF, 1,
       
  4821 	 PyDoc_STR("(python_object) -> (CF_object)")},
       
  4822 	{NULL, NULL, 0}
       
  4823 };
       
  4824 
       
  4825 
       
  4826 
       
  4827 
       
  4828 /* Routines to convert any CF type to/from the corresponding CFxxxObj */
       
  4829 PyObject *CFObj_New(CFTypeRef itself)
       
  4830 {
       
  4831         if (itself == NULL)
       
  4832         {
       
  4833                 PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
       
  4834                 return NULL;
       
  4835         }
       
  4836         if (CFGetTypeID(itself) == CFArrayGetTypeID()) return CFArrayRefObj_New((CFArrayRef)itself);
       
  4837         if (CFGetTypeID(itself) == CFDictionaryGetTypeID()) return CFDictionaryRefObj_New((CFDictionaryRef)itself);
       
  4838         if (CFGetTypeID(itself) == CFDataGetTypeID()) return CFDataRefObj_New((CFDataRef)itself);
       
  4839         if (CFGetTypeID(itself) == CFStringGetTypeID()) return CFStringRefObj_New((CFStringRef)itself);
       
  4840         if (CFGetTypeID(itself) == CFURLGetTypeID()) return CFURLRefObj_New((CFURLRef)itself);
       
  4841         /* XXXX Or should we use PyCF_CF2Python here?? */
       
  4842         return CFTypeRefObj_New(itself);
       
  4843 }
       
  4844 int CFObj_Convert(PyObject *v, CFTypeRef *p_itself)
       
  4845 {
       
  4846 
       
  4847         if (v == Py_None) { *p_itself = NULL; return 1; }
       
  4848         /* Check for other CF objects here */
       
  4849 
       
  4850         if (!CFTypeRefObj_Check(v) &&
       
  4851                 !CFArrayRefObj_Check(v) &&
       
  4852                 !CFMutableArrayRefObj_Check(v) &&
       
  4853                 !CFDictionaryRefObj_Check(v) &&
       
  4854                 !CFMutableDictionaryRefObj_Check(v) &&
       
  4855                 !CFDataRefObj_Check(v) &&
       
  4856                 !CFMutableDataRefObj_Check(v) &&
       
  4857                 !CFStringRefObj_Check(v) &&
       
  4858                 !CFMutableStringRefObj_Check(v) &&
       
  4859                 !CFURLRefObj_Check(v) )
       
  4860         {
       
  4861                 /* XXXX Or should we use PyCF_Python2CF here?? */
       
  4862                 PyErr_SetString(PyExc_TypeError, "CF object required");
       
  4863                 return 0;
       
  4864         }
       
  4865         *p_itself = ((CFTypeRefObject *)v)->ob_itself;
       
  4866         return 1;
       
  4867 }
       
  4868 
       
  4869 
       
  4870 void init_CF(void)
       
  4871 {
       
  4872 	PyObject *m;
       
  4873 	PyObject *d;
       
  4874 
       
  4875 
       
  4876 
       
  4877 	PyMac_INIT_TOOLBOX_OBJECT_NEW(CFTypeRef, CFObj_New);
       
  4878 	PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFTypeRef, CFObj_Convert);
       
  4879 	PyMac_INIT_TOOLBOX_OBJECT_NEW(CFTypeRef, CFTypeRefObj_New);
       
  4880 	PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFTypeRef, CFTypeRefObj_Convert);
       
  4881 	PyMac_INIT_TOOLBOX_OBJECT_NEW(CFStringRef, CFStringRefObj_New);
       
  4882 	PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFStringRef, CFStringRefObj_Convert);
       
  4883 	PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableStringRef, CFMutableStringRefObj_New);
       
  4884 	PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableStringRef, CFMutableStringRefObj_Convert);
       
  4885 	PyMac_INIT_TOOLBOX_OBJECT_NEW(CFArrayRef, CFArrayRefObj_New);
       
  4886 	PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFArrayRef, CFArrayRefObj_Convert);
       
  4887 	PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableArrayRef, CFMutableArrayRefObj_New);
       
  4888 	PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableArrayRef, CFMutableArrayRefObj_Convert);
       
  4889 	PyMac_INIT_TOOLBOX_OBJECT_NEW(CFDictionaryRef, CFDictionaryRefObj_New);
       
  4890 	PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFDictionaryRef, CFDictionaryRefObj_Convert);
       
  4891 	PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableDictionaryRef, CFMutableDictionaryRefObj_New);
       
  4892 	PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableDictionaryRef, CFMutableDictionaryRefObj_Convert);
       
  4893 	PyMac_INIT_TOOLBOX_OBJECT_NEW(CFURLRef, CFURLRefObj_New);
       
  4894 	PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef, CFURLRefObj_Convert);
       
  4895 
       
  4896 
       
  4897 	m = Py_InitModule("_CF", CF_methods);
       
  4898 	d = PyModule_GetDict(m);
       
  4899 	CF_Error = PyMac_GetOSErrException();
       
  4900 	if (CF_Error == NULL ||
       
  4901 	    PyDict_SetItemString(d, "Error", CF_Error) != 0)
       
  4902 		return;
       
  4903 	CFTypeRef_Type.ob_type = &PyType_Type;
       
  4904 	if (PyType_Ready(&CFTypeRef_Type) < 0) return;
       
  4905 	Py_INCREF(&CFTypeRef_Type);
       
  4906 	PyModule_AddObject(m, "CFTypeRef", (PyObject *)&CFTypeRef_Type);
       
  4907 	/* Backward-compatible name */
       
  4908 	Py_INCREF(&CFTypeRef_Type);
       
  4909 	PyModule_AddObject(m, "CFTypeRefType", (PyObject *)&CFTypeRef_Type);
       
  4910 	CFArrayRef_Type.ob_type = &PyType_Type;
       
  4911 	CFArrayRef_Type.tp_base = &CFTypeRef_Type;
       
  4912 	if (PyType_Ready(&CFArrayRef_Type) < 0) return;
       
  4913 	Py_INCREF(&CFArrayRef_Type);
       
  4914 	PyModule_AddObject(m, "CFArrayRef", (PyObject *)&CFArrayRef_Type);
       
  4915 	/* Backward-compatible name */
       
  4916 	Py_INCREF(&CFArrayRef_Type);
       
  4917 	PyModule_AddObject(m, "CFArrayRefType", (PyObject *)&CFArrayRef_Type);
       
  4918 	CFMutableArrayRef_Type.ob_type = &PyType_Type;
       
  4919 	CFMutableArrayRef_Type.tp_base = &CFArrayRef_Type;
       
  4920 	if (PyType_Ready(&CFMutableArrayRef_Type) < 0) return;
       
  4921 	Py_INCREF(&CFMutableArrayRef_Type);
       
  4922 	PyModule_AddObject(m, "CFMutableArrayRef", (PyObject *)&CFMutableArrayRef_Type);
       
  4923 	/* Backward-compatible name */
       
  4924 	Py_INCREF(&CFMutableArrayRef_Type);
       
  4925 	PyModule_AddObject(m, "CFMutableArrayRefType", (PyObject *)&CFMutableArrayRef_Type);
       
  4926 	CFDictionaryRef_Type.ob_type = &PyType_Type;
       
  4927 	CFDictionaryRef_Type.tp_base = &CFTypeRef_Type;
       
  4928 	if (PyType_Ready(&CFDictionaryRef_Type) < 0) return;
       
  4929 	Py_INCREF(&CFDictionaryRef_Type);
       
  4930 	PyModule_AddObject(m, "CFDictionaryRef", (PyObject *)&CFDictionaryRef_Type);
       
  4931 	/* Backward-compatible name */
       
  4932 	Py_INCREF(&CFDictionaryRef_Type);
       
  4933 	PyModule_AddObject(m, "CFDictionaryRefType", (PyObject *)&CFDictionaryRef_Type);
       
  4934 	CFMutableDictionaryRef_Type.ob_type = &PyType_Type;
       
  4935 	CFMutableDictionaryRef_Type.tp_base = &CFDictionaryRef_Type;
       
  4936 	if (PyType_Ready(&CFMutableDictionaryRef_Type) < 0) return;
       
  4937 	Py_INCREF(&CFMutableDictionaryRef_Type);
       
  4938 	PyModule_AddObject(m, "CFMutableDictionaryRef", (PyObject *)&CFMutableDictionaryRef_Type);
       
  4939 	/* Backward-compatible name */
       
  4940 	Py_INCREF(&CFMutableDictionaryRef_Type);
       
  4941 	PyModule_AddObject(m, "CFMutableDictionaryRefType", (PyObject *)&CFMutableDictionaryRef_Type);
       
  4942 	CFDataRef_Type.ob_type = &PyType_Type;
       
  4943 	CFDataRef_Type.tp_base = &CFTypeRef_Type;
       
  4944 	if (PyType_Ready(&CFDataRef_Type) < 0) return;
       
  4945 	Py_INCREF(&CFDataRef_Type);
       
  4946 	PyModule_AddObject(m, "CFDataRef", (PyObject *)&CFDataRef_Type);
       
  4947 	/* Backward-compatible name */
       
  4948 	Py_INCREF(&CFDataRef_Type);
       
  4949 	PyModule_AddObject(m, "CFDataRefType", (PyObject *)&CFDataRef_Type);
       
  4950 	CFMutableDataRef_Type.ob_type = &PyType_Type;
       
  4951 	CFMutableDataRef_Type.tp_base = &CFDataRef_Type;
       
  4952 	if (PyType_Ready(&CFMutableDataRef_Type) < 0) return;
       
  4953 	Py_INCREF(&CFMutableDataRef_Type);
       
  4954 	PyModule_AddObject(m, "CFMutableDataRef", (PyObject *)&CFMutableDataRef_Type);
       
  4955 	/* Backward-compatible name */
       
  4956 	Py_INCREF(&CFMutableDataRef_Type);
       
  4957 	PyModule_AddObject(m, "CFMutableDataRefType", (PyObject *)&CFMutableDataRef_Type);
       
  4958 	CFStringRef_Type.ob_type = &PyType_Type;
       
  4959 	CFStringRef_Type.tp_base = &CFTypeRef_Type;
       
  4960 	if (PyType_Ready(&CFStringRef_Type) < 0) return;
       
  4961 	Py_INCREF(&CFStringRef_Type);
       
  4962 	PyModule_AddObject(m, "CFStringRef", (PyObject *)&CFStringRef_Type);
       
  4963 	/* Backward-compatible name */
       
  4964 	Py_INCREF(&CFStringRef_Type);
       
  4965 	PyModule_AddObject(m, "CFStringRefType", (PyObject *)&CFStringRef_Type);
       
  4966 	CFMutableStringRef_Type.ob_type = &PyType_Type;
       
  4967 	CFMutableStringRef_Type.tp_base = &CFStringRef_Type;
       
  4968 	if (PyType_Ready(&CFMutableStringRef_Type) < 0) return;
       
  4969 	Py_INCREF(&CFMutableStringRef_Type);
       
  4970 	PyModule_AddObject(m, "CFMutableStringRef", (PyObject *)&CFMutableStringRef_Type);
       
  4971 	/* Backward-compatible name */
       
  4972 	Py_INCREF(&CFMutableStringRef_Type);
       
  4973 	PyModule_AddObject(m, "CFMutableStringRefType", (PyObject *)&CFMutableStringRef_Type);
       
  4974 	CFURLRef_Type.ob_type = &PyType_Type;
       
  4975 	CFURLRef_Type.tp_base = &CFTypeRef_Type;
       
  4976 	if (PyType_Ready(&CFURLRef_Type) < 0) return;
       
  4977 	Py_INCREF(&CFURLRef_Type);
       
  4978 	PyModule_AddObject(m, "CFURLRef", (PyObject *)&CFURLRef_Type);
       
  4979 	/* Backward-compatible name */
       
  4980 	Py_INCREF(&CFURLRef_Type);
       
  4981 	PyModule_AddObject(m, "CFURLRefType", (PyObject *)&CFURLRef_Type);
       
  4982 
       
  4983 #define _STRINGCONST(name) PyModule_AddObject(m, #name, CFStringRefObj_New(name))
       
  4984 	_STRINGCONST(kCFPreferencesAnyApplication);
       
  4985 	_STRINGCONST(kCFPreferencesCurrentApplication);
       
  4986 	_STRINGCONST(kCFPreferencesAnyHost);
       
  4987 	_STRINGCONST(kCFPreferencesCurrentHost);
       
  4988 	_STRINGCONST(kCFPreferencesAnyUser);
       
  4989 	_STRINGCONST(kCFPreferencesCurrentUser);
       
  4990 
       
  4991 
       
  4992 
       
  4993 }
       
  4994 
       
  4995 /* ========================= End module _CF ========================= */
       
  4996