Use full package paths in imports.
[python/dscho.git] / Mac / Modules / cf / _CFmodule.c
blobeb3f3f67238527afd01173920e51a463ffacc0a4
2 /* =========================== Module _CF =========================== */
4 #include "Python.h"
8 #ifdef _WIN32
9 #include "pywintoolbox.h"
10 #else
11 #include "macglue.h"
12 #include "pymactoolbox.h"
13 #endif
15 /* Macro to test whether a weak-loaded CFM function exists */
16 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
17 PyErr_SetString(PyExc_NotImplementedError, \
18 "Not available in this shared library/OS version"); \
19 return NULL; \
20 }} while(0)
23 #ifdef WITHOUT_FRAMEWORKS
24 #include <CFBase.h>
25 #include <CFArray.h>
26 #include <CFData.h>
27 #include <CFDictionary.h>
28 #include <CFString.h>
29 #include <CFURL.h>
30 #include <CFPropertyList.h>
31 #include <CFPreferences.h>
32 #else
33 #include <CoreServices/CoreServices.h>
34 #endif
36 #include "pycfbridge.h"
38 #ifdef USE_TOOLBOX_OBJECT_GLUE
39 extern PyObject *_CFTypeRefObj_New(CFTypeRef);
40 extern int _CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
41 #define CFTypeRefObj_New _CFTypeRefObj_New
42 #define CFTypeRefObj_Convert _CFTypeRefObj_Convert
44 extern PyObject *_CFStringRefObj_New(CFStringRef);
45 extern int _CFStringRefObj_Convert(PyObject *, CFStringRef *);
46 #define CFStringRefObj_New _CFStringRefObj_New
47 #define CFStringRefObj_Convert _CFStringRefObj_Convert
49 extern PyObject *_CFMutableStringRefObj_New(CFMutableStringRef);
50 extern int _CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *);
51 #define CFMutableStringRefObj_New _CFMutableStringRefObj_New
52 #define CFMutableStringRefObj_Convert _CFMutableStringRefObj_Convert
54 extern PyObject *_CFArrayRefObj_New(CFArrayRef);
55 extern int _CFArrayRefObj_Convert(PyObject *, CFArrayRef *);
56 #define CFArrayRefObj_New _CFArrayRefObj_New
57 #define CFArrayRefObj_Convert _CFArrayRefObj_Convert
59 extern PyObject *_CFMutableArrayRefObj_New(CFMutableArrayRef);
60 extern int _CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *);
61 #define CFMutableArrayRefObj_New _CFMutableArrayRefObj_New
62 #define CFMutableArrayRefObj_Convert _CFMutableArrayRefObj_Convert
64 extern PyObject *_CFDataRefObj_New(CFDataRef);
65 extern int _CFDataRefObj_Convert(PyObject *, CFDataRef *);
66 #define CFDataRefObj_New _CFDataRefObj_New
67 #define CFDataRefObj_Convert _CFDataRefObj_Convert
69 extern PyObject *_CFMutableDataRefObj_New(CFMutableDataRef);
70 extern int _CFMutableDataRefObj_Convert(PyObject *, CFMutableDataRef *);
71 #define CFMutableDataRefObj_New _CFMutableDataRefObj_New
72 #define CFMutableDataRefObj_Convert _CFMutableDataRefObj_Convert
74 extern PyObject *_CFDictionaryRefObj_New(CFDictionaryRef);
75 extern int _CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *);
76 #define CFDictionaryRefObj_New _CFDictionaryRefObj_New
77 #define CFDictionaryRefObj_Convert _CFDictionaryRefObj_Convert
79 extern PyObject *_CFMutableDictionaryRefObj_New(CFMutableDictionaryRef);
80 extern int _CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *);
81 #define CFMutableDictionaryRefObj_New _CFMutableDictionaryRefObj_New
82 #define CFMutableDictionaryRefObj_Convert _CFMutableDictionaryRefObj_Convert
84 extern PyObject *_CFURLRefObj_New(CFURLRef);
85 extern int _CFURLRefObj_Convert(PyObject *, CFURLRef *);
86 extern int _OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *);
87 #define CFURLRefObj_New _CFURLRefObj_New
88 #define CFURLRefObj_Convert _CFURLRefObj_Convert
89 #define OptionalCFURLRefObj_Convert _OptionalCFURLRefObj_Convert
90 #endif
93 ** Parse/generate CFRange records
95 PyObject *CFRange_New(CFRange *itself)
98 return Py_BuildValue("ll", (long)itself->location, (long)itself->length);
102 CFRange_Convert(PyObject *v, CFRange *p_itself)
104 long location, length;
106 if( !PyArg_ParseTuple(v, "ll", &location, &length) )
107 return 0;
108 p_itself->location = (CFIndex)location;
109 p_itself->length = (CFIndex)length;
110 return 1;
113 /* Optional CFURL argument or None (passed as NULL) */
115 OptionalCFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself)
117 if ( v == Py_None ) {
118 p_itself = NULL;
119 return 1;
121 return CFURLRefObj_Convert(v, p_itself);
125 static PyObject *CF_Error;
127 /* --------------------- Object type CFTypeRef ---------------------- */
129 PyTypeObject CFTypeRef_Type;
131 #define CFTypeRefObj_Check(x) ((x)->ob_type == &CFTypeRef_Type)
133 typedef struct CFTypeRefObject {
134 PyObject_HEAD
135 CFTypeRef ob_itself;
136 void (*ob_freeit)(CFTypeRef ptr);
137 } CFTypeRefObject;
139 PyObject *CFTypeRefObj_New(CFTypeRef itself)
141 CFTypeRefObject *it;
142 if (itself == NULL)
144 PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
145 return NULL;
147 it = PyObject_NEW(CFTypeRefObject, &CFTypeRef_Type);
148 if (it == NULL) return NULL;
149 it->ob_itself = itself;
150 it->ob_freeit = CFRelease;
151 return (PyObject *)it;
153 int CFTypeRefObj_Convert(PyObject *v, CFTypeRef *p_itself)
156 if (v == Py_None) { *p_itself = NULL; return 1; }
157 /* Check for other CF objects here */
159 if (!CFTypeRefObj_Check(v))
161 PyErr_SetString(PyExc_TypeError, "CFTypeRef required");
162 return 0;
164 *p_itself = ((CFTypeRefObject *)v)->ob_itself;
165 return 1;
168 static void CFTypeRefObj_dealloc(CFTypeRefObject *self)
170 if (self->ob_freeit && self->ob_itself)
172 self->ob_freeit((CFTypeRef)self->ob_itself);
174 PyObject_Del(self);
177 static PyObject *CFTypeRefObj_CFGetTypeID(CFTypeRefObject *_self, PyObject *_args)
179 PyObject *_res = NULL;
180 CFTypeID _rv;
181 #ifndef CFGetTypeID
182 PyMac_PRECHECK(CFGetTypeID);
183 #endif
184 if (!PyArg_ParseTuple(_args, ""))
185 return NULL;
186 _rv = CFGetTypeID(_self->ob_itself);
187 _res = Py_BuildValue("l",
188 _rv);
189 return _res;
192 static PyObject *CFTypeRefObj_CFRetain(CFTypeRefObject *_self, PyObject *_args)
194 PyObject *_res = NULL;
195 CFTypeRef _rv;
196 #ifndef CFRetain
197 PyMac_PRECHECK(CFRetain);
198 #endif
199 if (!PyArg_ParseTuple(_args, ""))
200 return NULL;
201 _rv = CFRetain(_self->ob_itself);
202 _res = Py_BuildValue("O&",
203 CFTypeRefObj_New, _rv);
204 return _res;
207 static PyObject *CFTypeRefObj_CFRelease(CFTypeRefObject *_self, PyObject *_args)
209 PyObject *_res = NULL;
210 #ifndef CFRelease
211 PyMac_PRECHECK(CFRelease);
212 #endif
213 if (!PyArg_ParseTuple(_args, ""))
214 return NULL;
215 CFRelease(_self->ob_itself);
216 Py_INCREF(Py_None);
217 _res = Py_None;
218 return _res;
221 static PyObject *CFTypeRefObj_CFGetRetainCount(CFTypeRefObject *_self, PyObject *_args)
223 PyObject *_res = NULL;
224 CFIndex _rv;
225 #ifndef CFGetRetainCount
226 PyMac_PRECHECK(CFGetRetainCount);
227 #endif
228 if (!PyArg_ParseTuple(_args, ""))
229 return NULL;
230 _rv = CFGetRetainCount(_self->ob_itself);
231 _res = Py_BuildValue("l",
232 _rv);
233 return _res;
236 static PyObject *CFTypeRefObj_CFEqual(CFTypeRefObject *_self, PyObject *_args)
238 PyObject *_res = NULL;
239 Boolean _rv;
240 CFTypeRef cf2;
241 #ifndef CFEqual
242 PyMac_PRECHECK(CFEqual);
243 #endif
244 if (!PyArg_ParseTuple(_args, "O&",
245 CFTypeRefObj_Convert, &cf2))
246 return NULL;
247 _rv = CFEqual(_self->ob_itself,
248 cf2);
249 _res = Py_BuildValue("l",
250 _rv);
251 return _res;
254 static PyObject *CFTypeRefObj_CFHash(CFTypeRefObject *_self, PyObject *_args)
256 PyObject *_res = NULL;
257 CFHashCode _rv;
258 #ifndef CFHash
259 PyMac_PRECHECK(CFHash);
260 #endif
261 if (!PyArg_ParseTuple(_args, ""))
262 return NULL;
263 _rv = CFHash(_self->ob_itself);
264 _res = Py_BuildValue("l",
265 _rv);
266 return _res;
269 static PyObject *CFTypeRefObj_CFCopyDescription(CFTypeRefObject *_self, PyObject *_args)
271 PyObject *_res = NULL;
272 CFStringRef _rv;
273 #ifndef CFCopyDescription
274 PyMac_PRECHECK(CFCopyDescription);
275 #endif
276 if (!PyArg_ParseTuple(_args, ""))
277 return NULL;
278 _rv = CFCopyDescription(_self->ob_itself);
279 _res = Py_BuildValue("O&",
280 CFStringRefObj_New, _rv);
281 return _res;
284 static PyObject *CFTypeRefObj_CFPropertyListCreateXMLData(CFTypeRefObject *_self, PyObject *_args)
286 PyObject *_res = NULL;
287 CFDataRef _rv;
288 if (!PyArg_ParseTuple(_args, ""))
289 return NULL;
290 _rv = CFPropertyListCreateXMLData((CFAllocatorRef)NULL,
291 _self->ob_itself);
292 _res = Py_BuildValue("O&",
293 CFDataRefObj_New, _rv);
294 return _res;
297 static PyObject *CFTypeRefObj_CFPropertyListCreateDeepCopy(CFTypeRefObject *_self, PyObject *_args)
299 PyObject *_res = NULL;
300 CFTypeRef _rv;
301 CFOptionFlags mutabilityOption;
302 if (!PyArg_ParseTuple(_args, "l",
303 &mutabilityOption))
304 return NULL;
305 _rv = CFPropertyListCreateDeepCopy((CFAllocatorRef)NULL,
306 _self->ob_itself,
307 mutabilityOption);
308 _res = Py_BuildValue("O&",
309 CFTypeRefObj_New, _rv);
310 return _res;
313 static PyObject *CFTypeRefObj_CFShow(CFTypeRefObject *_self, PyObject *_args)
315 PyObject *_res = NULL;
316 #ifndef CFShow
317 PyMac_PRECHECK(CFShow);
318 #endif
319 if (!PyArg_ParseTuple(_args, ""))
320 return NULL;
321 CFShow(_self->ob_itself);
322 Py_INCREF(Py_None);
323 _res = Py_None;
324 return _res;
327 static PyObject *CFTypeRefObj_CFPropertyListCreateFromXMLData(CFTypeRefObject *_self, PyObject *_args)
329 PyObject *_res = NULL;
331 CFTypeRef _rv;
332 CFOptionFlags mutabilityOption;
333 CFStringRef errorString;
334 if (!PyArg_ParseTuple(_args, "l",
335 &mutabilityOption))
336 return NULL;
337 _rv = CFPropertyListCreateFromXMLData((CFAllocatorRef)NULL,
338 _self->ob_itself,
339 mutabilityOption,
340 &errorString);
341 if (errorString)
342 CFRelease(errorString);
343 if (_rv == NULL) {
344 PyErr_SetString(PyExc_RuntimeError, "Parse error in XML data");
345 return NULL;
347 _res = Py_BuildValue("O&",
348 CFTypeRefObj_New, _rv);
349 return _res;
353 static PyObject *CFTypeRefObj_toPython(CFTypeRefObject *_self, PyObject *_args)
355 PyObject *_res = NULL;
357 return PyCF_CF2Python(_self->ob_itself);
361 static PyMethodDef CFTypeRefObj_methods[] = {
362 {"CFGetTypeID", (PyCFunction)CFTypeRefObj_CFGetTypeID, 1,
363 "() -> (CFTypeID _rv)"},
364 {"CFRetain", (PyCFunction)CFTypeRefObj_CFRetain, 1,
365 "() -> (CFTypeRef _rv)"},
366 {"CFRelease", (PyCFunction)CFTypeRefObj_CFRelease, 1,
367 "() -> None"},
368 {"CFGetRetainCount", (PyCFunction)CFTypeRefObj_CFGetRetainCount, 1,
369 "() -> (CFIndex _rv)"},
370 {"CFEqual", (PyCFunction)CFTypeRefObj_CFEqual, 1,
371 "(CFTypeRef cf2) -> (Boolean _rv)"},
372 {"CFHash", (PyCFunction)CFTypeRefObj_CFHash, 1,
373 "() -> (CFHashCode _rv)"},
374 {"CFCopyDescription", (PyCFunction)CFTypeRefObj_CFCopyDescription, 1,
375 "() -> (CFStringRef _rv)"},
376 {"CFPropertyListCreateXMLData", (PyCFunction)CFTypeRefObj_CFPropertyListCreateXMLData, 1,
377 "() -> (CFDataRef _rv)"},
378 {"CFPropertyListCreateDeepCopy", (PyCFunction)CFTypeRefObj_CFPropertyListCreateDeepCopy, 1,
379 "(CFOptionFlags mutabilityOption) -> (CFTypeRef _rv)"},
380 {"CFShow", (PyCFunction)CFTypeRefObj_CFShow, 1,
381 "() -> None"},
382 {"CFPropertyListCreateFromXMLData", (PyCFunction)CFTypeRefObj_CFPropertyListCreateFromXMLData, 1,
383 "(CFOptionFlags mutabilityOption) -> (CFTypeRefObj)"},
384 {"toPython", (PyCFunction)CFTypeRefObj_toPython, 1,
385 "() -> (python_object)"},
386 {NULL, NULL, 0}
389 PyMethodChain CFTypeRefObj_chain = { CFTypeRefObj_methods, NULL };
391 static PyObject *CFTypeRefObj_getattr(CFTypeRefObject *self, char *name)
393 return Py_FindMethodInChain(&CFTypeRefObj_chain, (PyObject *)self, name);
396 #define CFTypeRefObj_setattr NULL
398 static int CFTypeRefObj_compare(CFTypeRefObject *self, CFTypeRefObject *other)
400 /* XXXX Or should we use CFEqual?? */
401 if ( self->ob_itself > other->ob_itself ) return 1;
402 if ( self->ob_itself < other->ob_itself ) return -1;
403 return 0;
406 static PyObject * CFTypeRefObj_repr(CFTypeRefObject *self)
408 char buf[100];
409 sprintf(buf, "<CFTypeRef type-%d object at 0x%8.8x for 0x%8.8x>", CFGetTypeID(self->ob_itself), (unsigned)self, (unsigned)self->ob_itself);
410 return PyString_FromString(buf);
413 static int CFTypeRefObj_hash(CFTypeRefObject *self)
415 /* XXXX Or should we use CFHash?? */
416 return (int)self->ob_itself;
419 PyTypeObject CFTypeRef_Type = {
420 PyObject_HEAD_INIT(NULL)
421 0, /*ob_size*/
422 "_CF.CFTypeRef", /*tp_name*/
423 sizeof(CFTypeRefObject), /*tp_basicsize*/
424 0, /*tp_itemsize*/
425 /* methods */
426 (destructor) CFTypeRefObj_dealloc, /*tp_dealloc*/
427 0, /*tp_print*/
428 (getattrfunc) CFTypeRefObj_getattr, /*tp_getattr*/
429 (setattrfunc) CFTypeRefObj_setattr, /*tp_setattr*/
430 (cmpfunc) CFTypeRefObj_compare, /*tp_compare*/
431 (reprfunc) CFTypeRefObj_repr, /*tp_repr*/
432 (PyNumberMethods *)0, /* tp_as_number */
433 (PySequenceMethods *)0, /* tp_as_sequence */
434 (PyMappingMethods *)0, /* tp_as_mapping */
435 (hashfunc) CFTypeRefObj_hash, /*tp_hash*/
438 /* ------------------- End object type CFTypeRef -------------------- */
441 /* --------------------- Object type CFArrayRef --------------------- */
443 PyTypeObject CFArrayRef_Type;
445 #define CFArrayRefObj_Check(x) ((x)->ob_type == &CFArrayRef_Type)
447 typedef struct CFArrayRefObject {
448 PyObject_HEAD
449 CFArrayRef ob_itself;
450 void (*ob_freeit)(CFTypeRef ptr);
451 } CFArrayRefObject;
453 PyObject *CFArrayRefObj_New(CFArrayRef itself)
455 CFArrayRefObject *it;
456 if (itself == NULL)
458 PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
459 return NULL;
461 it = PyObject_NEW(CFArrayRefObject, &CFArrayRef_Type);
462 if (it == NULL) return NULL;
463 it->ob_itself = itself;
464 it->ob_freeit = CFRelease;
465 return (PyObject *)it;
467 int CFArrayRefObj_Convert(PyObject *v, CFArrayRef *p_itself)
470 if (v == Py_None) { *p_itself = NULL; return 1; }
471 /* Check for other CF objects here */
473 if (!CFArrayRefObj_Check(v))
475 PyErr_SetString(PyExc_TypeError, "CFArrayRef required");
476 return 0;
478 *p_itself = ((CFArrayRefObject *)v)->ob_itself;
479 return 1;
482 static void CFArrayRefObj_dealloc(CFArrayRefObject *self)
484 if (self->ob_freeit && self->ob_itself)
486 self->ob_freeit((CFTypeRef)self->ob_itself);
488 PyObject_Del(self);
491 static PyObject *CFArrayRefObj_CFArrayCreateCopy(CFArrayRefObject *_self, PyObject *_args)
493 PyObject *_res = NULL;
494 CFArrayRef _rv;
495 if (!PyArg_ParseTuple(_args, ""))
496 return NULL;
497 _rv = CFArrayCreateCopy((CFAllocatorRef)NULL,
498 _self->ob_itself);
499 _res = Py_BuildValue("O&",
500 CFArrayRefObj_New, _rv);
501 return _res;
504 static PyObject *CFArrayRefObj_CFArrayGetCount(CFArrayRefObject *_self, PyObject *_args)
506 PyObject *_res = NULL;
507 CFIndex _rv;
508 #ifndef CFArrayGetCount
509 PyMac_PRECHECK(CFArrayGetCount);
510 #endif
511 if (!PyArg_ParseTuple(_args, ""))
512 return NULL;
513 _rv = CFArrayGetCount(_self->ob_itself);
514 _res = Py_BuildValue("l",
515 _rv);
516 return _res;
519 static PyObject *CFArrayRefObj_CFStringCreateByCombiningStrings(CFArrayRefObject *_self, PyObject *_args)
521 PyObject *_res = NULL;
522 CFStringRef _rv;
523 CFStringRef separatorString;
524 if (!PyArg_ParseTuple(_args, "O&",
525 CFStringRefObj_Convert, &separatorString))
526 return NULL;
527 _rv = CFStringCreateByCombiningStrings((CFAllocatorRef)NULL,
528 _self->ob_itself,
529 separatorString);
530 _res = Py_BuildValue("O&",
531 CFStringRefObj_New, _rv);
532 return _res;
535 static PyMethodDef CFArrayRefObj_methods[] = {
536 {"CFArrayCreateCopy", (PyCFunction)CFArrayRefObj_CFArrayCreateCopy, 1,
537 "() -> (CFArrayRef _rv)"},
538 {"CFArrayGetCount", (PyCFunction)CFArrayRefObj_CFArrayGetCount, 1,
539 "() -> (CFIndex _rv)"},
540 {"CFStringCreateByCombiningStrings", (PyCFunction)CFArrayRefObj_CFStringCreateByCombiningStrings, 1,
541 "(CFStringRef separatorString) -> (CFStringRef _rv)"},
542 {NULL, NULL, 0}
545 PyMethodChain CFArrayRefObj_chain = { CFArrayRefObj_methods, &CFTypeRefObj_chain };
547 static PyObject *CFArrayRefObj_getattr(CFArrayRefObject *self, char *name)
549 return Py_FindMethodInChain(&CFArrayRefObj_chain, (PyObject *)self, name);
552 #define CFArrayRefObj_setattr NULL
554 static int CFArrayRefObj_compare(CFArrayRefObject *self, CFArrayRefObject *other)
556 /* XXXX Or should we use CFEqual?? */
557 if ( self->ob_itself > other->ob_itself ) return 1;
558 if ( self->ob_itself < other->ob_itself ) return -1;
559 return 0;
562 static PyObject * CFArrayRefObj_repr(CFArrayRefObject *self)
564 char buf[100];
565 sprintf(buf, "<CFArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
566 return PyString_FromString(buf);
569 static int CFArrayRefObj_hash(CFArrayRefObject *self)
571 /* XXXX Or should we use CFHash?? */
572 return (int)self->ob_itself;
575 PyTypeObject CFArrayRef_Type = {
576 PyObject_HEAD_INIT(NULL)
577 0, /*ob_size*/
578 "_CF.CFArrayRef", /*tp_name*/
579 sizeof(CFArrayRefObject), /*tp_basicsize*/
580 0, /*tp_itemsize*/
581 /* methods */
582 (destructor) CFArrayRefObj_dealloc, /*tp_dealloc*/
583 0, /*tp_print*/
584 (getattrfunc) CFArrayRefObj_getattr, /*tp_getattr*/
585 (setattrfunc) CFArrayRefObj_setattr, /*tp_setattr*/
586 (cmpfunc) CFArrayRefObj_compare, /*tp_compare*/
587 (reprfunc) CFArrayRefObj_repr, /*tp_repr*/
588 (PyNumberMethods *)0, /* tp_as_number */
589 (PySequenceMethods *)0, /* tp_as_sequence */
590 (PyMappingMethods *)0, /* tp_as_mapping */
591 (hashfunc) CFArrayRefObj_hash, /*tp_hash*/
594 /* ------------------- End object type CFArrayRef ------------------- */
597 /* ----------------- Object type CFMutableArrayRef ------------------ */
599 PyTypeObject CFMutableArrayRef_Type;
601 #define CFMutableArrayRefObj_Check(x) ((x)->ob_type == &CFMutableArrayRef_Type)
603 typedef struct CFMutableArrayRefObject {
604 PyObject_HEAD
605 CFMutableArrayRef ob_itself;
606 void (*ob_freeit)(CFTypeRef ptr);
607 } CFMutableArrayRefObject;
609 PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef itself)
611 CFMutableArrayRefObject *it;
612 if (itself == NULL)
614 PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
615 return NULL;
617 it = PyObject_NEW(CFMutableArrayRefObject, &CFMutableArrayRef_Type);
618 if (it == NULL) return NULL;
619 it->ob_itself = itself;
620 it->ob_freeit = CFRelease;
621 return (PyObject *)it;
623 int CFMutableArrayRefObj_Convert(PyObject *v, CFMutableArrayRef *p_itself)
626 if (v == Py_None) { *p_itself = NULL; return 1; }
627 /* Check for other CF objects here */
629 if (!CFMutableArrayRefObj_Check(v))
631 PyErr_SetString(PyExc_TypeError, "CFMutableArrayRef required");
632 return 0;
634 *p_itself = ((CFMutableArrayRefObject *)v)->ob_itself;
635 return 1;
638 static void CFMutableArrayRefObj_dealloc(CFMutableArrayRefObject *self)
640 if (self->ob_freeit && self->ob_itself)
642 self->ob_freeit((CFTypeRef)self->ob_itself);
644 PyObject_Del(self);
647 static PyObject *CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRefObject *_self, PyObject *_args)
649 PyObject *_res = NULL;
650 CFIndex idx;
651 #ifndef CFArrayRemoveValueAtIndex
652 PyMac_PRECHECK(CFArrayRemoveValueAtIndex);
653 #endif
654 if (!PyArg_ParseTuple(_args, "l",
655 &idx))
656 return NULL;
657 CFArrayRemoveValueAtIndex(_self->ob_itself,
658 idx);
659 Py_INCREF(Py_None);
660 _res = Py_None;
661 return _res;
664 static PyObject *CFMutableArrayRefObj_CFArrayRemoveAllValues(CFMutableArrayRefObject *_self, PyObject *_args)
666 PyObject *_res = NULL;
667 #ifndef CFArrayRemoveAllValues
668 PyMac_PRECHECK(CFArrayRemoveAllValues);
669 #endif
670 if (!PyArg_ParseTuple(_args, ""))
671 return NULL;
672 CFArrayRemoveAllValues(_self->ob_itself);
673 Py_INCREF(Py_None);
674 _res = Py_None;
675 return _res;
678 static PyObject *CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices(CFMutableArrayRefObject *_self, PyObject *_args)
680 PyObject *_res = NULL;
681 CFIndex idx1;
682 CFIndex idx2;
683 #ifndef CFArrayExchangeValuesAtIndices
684 PyMac_PRECHECK(CFArrayExchangeValuesAtIndices);
685 #endif
686 if (!PyArg_ParseTuple(_args, "ll",
687 &idx1,
688 &idx2))
689 return NULL;
690 CFArrayExchangeValuesAtIndices(_self->ob_itself,
691 idx1,
692 idx2);
693 Py_INCREF(Py_None);
694 _res = Py_None;
695 return _res;
698 static PyObject *CFMutableArrayRefObj_CFArrayAppendArray(CFMutableArrayRefObject *_self, PyObject *_args)
700 PyObject *_res = NULL;
701 CFArrayRef otherArray;
702 CFRange otherRange;
703 #ifndef CFArrayAppendArray
704 PyMac_PRECHECK(CFArrayAppendArray);
705 #endif
706 if (!PyArg_ParseTuple(_args, "O&O&",
707 CFArrayRefObj_Convert, &otherArray,
708 CFRange_Convert, &otherRange))
709 return NULL;
710 CFArrayAppendArray(_self->ob_itself,
711 otherArray,
712 otherRange);
713 Py_INCREF(Py_None);
714 _res = Py_None;
715 return _res;
718 static PyMethodDef CFMutableArrayRefObj_methods[] = {
719 {"CFArrayRemoveValueAtIndex", (PyCFunction)CFMutableArrayRefObj_CFArrayRemoveValueAtIndex, 1,
720 "(CFIndex idx) -> None"},
721 {"CFArrayRemoveAllValues", (PyCFunction)CFMutableArrayRefObj_CFArrayRemoveAllValues, 1,
722 "() -> None"},
723 {"CFArrayExchangeValuesAtIndices", (PyCFunction)CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices, 1,
724 "(CFIndex idx1, CFIndex idx2) -> None"},
725 {"CFArrayAppendArray", (PyCFunction)CFMutableArrayRefObj_CFArrayAppendArray, 1,
726 "(CFArrayRef otherArray, CFRange otherRange) -> None"},
727 {NULL, NULL, 0}
730 PyMethodChain CFMutableArrayRefObj_chain = { CFMutableArrayRefObj_methods, &CFArrayRefObj_chain };
732 static PyObject *CFMutableArrayRefObj_getattr(CFMutableArrayRefObject *self, char *name)
734 return Py_FindMethodInChain(&CFMutableArrayRefObj_chain, (PyObject *)self, name);
737 #define CFMutableArrayRefObj_setattr NULL
739 static int CFMutableArrayRefObj_compare(CFMutableArrayRefObject *self, CFMutableArrayRefObject *other)
741 /* XXXX Or should we use CFEqual?? */
742 if ( self->ob_itself > other->ob_itself ) return 1;
743 if ( self->ob_itself < other->ob_itself ) return -1;
744 return 0;
747 static PyObject * CFMutableArrayRefObj_repr(CFMutableArrayRefObject *self)
749 char buf[100];
750 sprintf(buf, "<CFMutableArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
751 return PyString_FromString(buf);
754 static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject *self)
756 /* XXXX Or should we use CFHash?? */
757 return (int)self->ob_itself;
760 PyTypeObject CFMutableArrayRef_Type = {
761 PyObject_HEAD_INIT(NULL)
762 0, /*ob_size*/
763 "_CF.CFMutableArrayRef", /*tp_name*/
764 sizeof(CFMutableArrayRefObject), /*tp_basicsize*/
765 0, /*tp_itemsize*/
766 /* methods */
767 (destructor) CFMutableArrayRefObj_dealloc, /*tp_dealloc*/
768 0, /*tp_print*/
769 (getattrfunc) CFMutableArrayRefObj_getattr, /*tp_getattr*/
770 (setattrfunc) CFMutableArrayRefObj_setattr, /*tp_setattr*/
771 (cmpfunc) CFMutableArrayRefObj_compare, /*tp_compare*/
772 (reprfunc) CFMutableArrayRefObj_repr, /*tp_repr*/
773 (PyNumberMethods *)0, /* tp_as_number */
774 (PySequenceMethods *)0, /* tp_as_sequence */
775 (PyMappingMethods *)0, /* tp_as_mapping */
776 (hashfunc) CFMutableArrayRefObj_hash, /*tp_hash*/
779 /* --------------- End object type CFMutableArrayRef ---------------- */
782 /* ------------------ Object type CFDictionaryRef ------------------- */
784 PyTypeObject CFDictionaryRef_Type;
786 #define CFDictionaryRefObj_Check(x) ((x)->ob_type == &CFDictionaryRef_Type)
788 typedef struct CFDictionaryRefObject {
789 PyObject_HEAD
790 CFDictionaryRef ob_itself;
791 void (*ob_freeit)(CFTypeRef ptr);
792 } CFDictionaryRefObject;
794 PyObject *CFDictionaryRefObj_New(CFDictionaryRef itself)
796 CFDictionaryRefObject *it;
797 if (itself == NULL)
799 PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
800 return NULL;
802 it = PyObject_NEW(CFDictionaryRefObject, &CFDictionaryRef_Type);
803 if (it == NULL) return NULL;
804 it->ob_itself = itself;
805 it->ob_freeit = CFRelease;
806 return (PyObject *)it;
808 int CFDictionaryRefObj_Convert(PyObject *v, CFDictionaryRef *p_itself)
811 if (v == Py_None) { *p_itself = NULL; return 1; }
812 /* Check for other CF objects here */
814 if (!CFDictionaryRefObj_Check(v))
816 PyErr_SetString(PyExc_TypeError, "CFDictionaryRef required");
817 return 0;
819 *p_itself = ((CFDictionaryRefObject *)v)->ob_itself;
820 return 1;
823 static void CFDictionaryRefObj_dealloc(CFDictionaryRefObject *self)
825 if (self->ob_freeit && self->ob_itself)
827 self->ob_freeit((CFTypeRef)self->ob_itself);
829 PyObject_Del(self);
832 static PyObject *CFDictionaryRefObj_CFDictionaryCreateCopy(CFDictionaryRefObject *_self, PyObject *_args)
834 PyObject *_res = NULL;
835 CFDictionaryRef _rv;
836 if (!PyArg_ParseTuple(_args, ""))
837 return NULL;
838 _rv = CFDictionaryCreateCopy((CFAllocatorRef)NULL,
839 _self->ob_itself);
840 _res = Py_BuildValue("O&",
841 CFDictionaryRefObj_New, _rv);
842 return _res;
845 static PyObject *CFDictionaryRefObj_CFDictionaryGetCount(CFDictionaryRefObject *_self, PyObject *_args)
847 PyObject *_res = NULL;
848 CFIndex _rv;
849 #ifndef CFDictionaryGetCount
850 PyMac_PRECHECK(CFDictionaryGetCount);
851 #endif
852 if (!PyArg_ParseTuple(_args, ""))
853 return NULL;
854 _rv = CFDictionaryGetCount(_self->ob_itself);
855 _res = Py_BuildValue("l",
856 _rv);
857 return _res;
860 static PyMethodDef CFDictionaryRefObj_methods[] = {
861 {"CFDictionaryCreateCopy", (PyCFunction)CFDictionaryRefObj_CFDictionaryCreateCopy, 1,
862 "() -> (CFDictionaryRef _rv)"},
863 {"CFDictionaryGetCount", (PyCFunction)CFDictionaryRefObj_CFDictionaryGetCount, 1,
864 "() -> (CFIndex _rv)"},
865 {NULL, NULL, 0}
868 PyMethodChain CFDictionaryRefObj_chain = { CFDictionaryRefObj_methods, &CFTypeRefObj_chain };
870 static PyObject *CFDictionaryRefObj_getattr(CFDictionaryRefObject *self, char *name)
872 return Py_FindMethodInChain(&CFDictionaryRefObj_chain, (PyObject *)self, name);
875 #define CFDictionaryRefObj_setattr NULL
877 static int CFDictionaryRefObj_compare(CFDictionaryRefObject *self, CFDictionaryRefObject *other)
879 /* XXXX Or should we use CFEqual?? */
880 if ( self->ob_itself > other->ob_itself ) return 1;
881 if ( self->ob_itself < other->ob_itself ) return -1;
882 return 0;
885 static PyObject * CFDictionaryRefObj_repr(CFDictionaryRefObject *self)
887 char buf[100];
888 sprintf(buf, "<CFDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
889 return PyString_FromString(buf);
892 static int CFDictionaryRefObj_hash(CFDictionaryRefObject *self)
894 /* XXXX Or should we use CFHash?? */
895 return (int)self->ob_itself;
898 PyTypeObject CFDictionaryRef_Type = {
899 PyObject_HEAD_INIT(NULL)
900 0, /*ob_size*/
901 "_CF.CFDictionaryRef", /*tp_name*/
902 sizeof(CFDictionaryRefObject), /*tp_basicsize*/
903 0, /*tp_itemsize*/
904 /* methods */
905 (destructor) CFDictionaryRefObj_dealloc, /*tp_dealloc*/
906 0, /*tp_print*/
907 (getattrfunc) CFDictionaryRefObj_getattr, /*tp_getattr*/
908 (setattrfunc) CFDictionaryRefObj_setattr, /*tp_setattr*/
909 (cmpfunc) CFDictionaryRefObj_compare, /*tp_compare*/
910 (reprfunc) CFDictionaryRefObj_repr, /*tp_repr*/
911 (PyNumberMethods *)0, /* tp_as_number */
912 (PySequenceMethods *)0, /* tp_as_sequence */
913 (PyMappingMethods *)0, /* tp_as_mapping */
914 (hashfunc) CFDictionaryRefObj_hash, /*tp_hash*/
917 /* ---------------- End object type CFDictionaryRef ----------------- */
920 /* --------------- Object type CFMutableDictionaryRef --------------- */
922 PyTypeObject CFMutableDictionaryRef_Type;
924 #define CFMutableDictionaryRefObj_Check(x) ((x)->ob_type == &CFMutableDictionaryRef_Type)
926 typedef struct CFMutableDictionaryRefObject {
927 PyObject_HEAD
928 CFMutableDictionaryRef ob_itself;
929 void (*ob_freeit)(CFTypeRef ptr);
930 } CFMutableDictionaryRefObject;
932 PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef itself)
934 CFMutableDictionaryRefObject *it;
935 if (itself == NULL)
937 PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
938 return NULL;
940 it = PyObject_NEW(CFMutableDictionaryRefObject, &CFMutableDictionaryRef_Type);
941 if (it == NULL) return NULL;
942 it->ob_itself = itself;
943 it->ob_freeit = CFRelease;
944 return (PyObject *)it;
946 int CFMutableDictionaryRefObj_Convert(PyObject *v, CFMutableDictionaryRef *p_itself)
949 if (v == Py_None) { *p_itself = NULL; return 1; }
950 /* Check for other CF objects here */
952 if (!CFMutableDictionaryRefObj_Check(v))
954 PyErr_SetString(PyExc_TypeError, "CFMutableDictionaryRef required");
955 return 0;
957 *p_itself = ((CFMutableDictionaryRefObject *)v)->ob_itself;
958 return 1;
961 static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject *self)
963 if (self->ob_freeit && self->ob_itself)
965 self->ob_freeit((CFTypeRef)self->ob_itself);
967 PyObject_Del(self);
970 static PyObject *CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject *_self, PyObject *_args)
972 PyObject *_res = NULL;
973 #ifndef CFDictionaryRemoveAllValues
974 PyMac_PRECHECK(CFDictionaryRemoveAllValues);
975 #endif
976 if (!PyArg_ParseTuple(_args, ""))
977 return NULL;
978 CFDictionaryRemoveAllValues(_self->ob_itself);
979 Py_INCREF(Py_None);
980 _res = Py_None;
981 return _res;
984 static PyMethodDef CFMutableDictionaryRefObj_methods[] = {
985 {"CFDictionaryRemoveAllValues", (PyCFunction)CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues, 1,
986 "() -> None"},
987 {NULL, NULL, 0}
990 PyMethodChain CFMutableDictionaryRefObj_chain = { CFMutableDictionaryRefObj_methods, &CFDictionaryRefObj_chain };
992 static PyObject *CFMutableDictionaryRefObj_getattr(CFMutableDictionaryRefObject *self, char *name)
994 return Py_FindMethodInChain(&CFMutableDictionaryRefObj_chain, (PyObject *)self, name);
997 #define CFMutableDictionaryRefObj_setattr NULL
999 static int CFMutableDictionaryRefObj_compare(CFMutableDictionaryRefObject *self, CFMutableDictionaryRefObject *other)
1001 /* XXXX Or should we use CFEqual?? */
1002 if ( self->ob_itself > other->ob_itself ) return 1;
1003 if ( self->ob_itself < other->ob_itself ) return -1;
1004 return 0;
1007 static PyObject * CFMutableDictionaryRefObj_repr(CFMutableDictionaryRefObject *self)
1009 char buf[100];
1010 sprintf(buf, "<CFMutableDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
1011 return PyString_FromString(buf);
1014 static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject *self)
1016 /* XXXX Or should we use CFHash?? */
1017 return (int)self->ob_itself;
1020 PyTypeObject CFMutableDictionaryRef_Type = {
1021 PyObject_HEAD_INIT(NULL)
1022 0, /*ob_size*/
1023 "_CF.CFMutableDictionaryRef", /*tp_name*/
1024 sizeof(CFMutableDictionaryRefObject), /*tp_basicsize*/
1025 0, /*tp_itemsize*/
1026 /* methods */
1027 (destructor) CFMutableDictionaryRefObj_dealloc, /*tp_dealloc*/
1028 0, /*tp_print*/
1029 (getattrfunc) CFMutableDictionaryRefObj_getattr, /*tp_getattr*/
1030 (setattrfunc) CFMutableDictionaryRefObj_setattr, /*tp_setattr*/
1031 (cmpfunc) CFMutableDictionaryRefObj_compare, /*tp_compare*/
1032 (reprfunc) CFMutableDictionaryRefObj_repr, /*tp_repr*/
1033 (PyNumberMethods *)0, /* tp_as_number */
1034 (PySequenceMethods *)0, /* tp_as_sequence */
1035 (PyMappingMethods *)0, /* tp_as_mapping */
1036 (hashfunc) CFMutableDictionaryRefObj_hash, /*tp_hash*/
1039 /* ------------- End object type CFMutableDictionaryRef ------------- */
1042 /* --------------------- Object type CFDataRef ---------------------- */
1044 PyTypeObject CFDataRef_Type;
1046 #define CFDataRefObj_Check(x) ((x)->ob_type == &CFDataRef_Type)
1048 typedef struct CFDataRefObject {
1049 PyObject_HEAD
1050 CFDataRef ob_itself;
1051 void (*ob_freeit)(CFTypeRef ptr);
1052 } CFDataRefObject;
1054 PyObject *CFDataRefObj_New(CFDataRef itself)
1056 CFDataRefObject *it;
1057 if (itself == NULL)
1059 PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
1060 return NULL;
1062 it = PyObject_NEW(CFDataRefObject, &CFDataRef_Type);
1063 if (it == NULL) return NULL;
1064 it->ob_itself = itself;
1065 it->ob_freeit = CFRelease;
1066 return (PyObject *)it;
1068 int CFDataRefObj_Convert(PyObject *v, CFDataRef *p_itself)
1071 if (v == Py_None) { *p_itself = NULL; return 1; }
1072 if (PyString_Check(v)) {
1073 char *cStr;
1074 int cLen;
1075 if( PyString_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0;
1076 *p_itself = CFDataCreate((CFAllocatorRef)NULL, (unsigned char *)cStr, cLen);
1077 return 1;
1080 if (!CFDataRefObj_Check(v))
1082 PyErr_SetString(PyExc_TypeError, "CFDataRef required");
1083 return 0;
1085 *p_itself = ((CFDataRefObject *)v)->ob_itself;
1086 return 1;
1089 static void CFDataRefObj_dealloc(CFDataRefObject *self)
1091 if (self->ob_freeit && self->ob_itself)
1093 self->ob_freeit((CFTypeRef)self->ob_itself);
1095 PyObject_Del(self);
1098 static PyObject *CFDataRefObj_CFDataCreateCopy(CFDataRefObject *_self, PyObject *_args)
1100 PyObject *_res = NULL;
1101 CFDataRef _rv;
1102 if (!PyArg_ParseTuple(_args, ""))
1103 return NULL;
1104 _rv = CFDataCreateCopy((CFAllocatorRef)NULL,
1105 _self->ob_itself);
1106 _res = Py_BuildValue("O&",
1107 CFDataRefObj_New, _rv);
1108 return _res;
1111 static PyObject *CFDataRefObj_CFDataGetLength(CFDataRefObject *_self, PyObject *_args)
1113 PyObject *_res = NULL;
1114 CFIndex _rv;
1115 #ifndef CFDataGetLength
1116 PyMac_PRECHECK(CFDataGetLength);
1117 #endif
1118 if (!PyArg_ParseTuple(_args, ""))
1119 return NULL;
1120 _rv = CFDataGetLength(_self->ob_itself);
1121 _res = Py_BuildValue("l",
1122 _rv);
1123 return _res;
1126 static PyObject *CFDataRefObj_CFStringCreateFromExternalRepresentation(CFDataRefObject *_self, PyObject *_args)
1128 PyObject *_res = NULL;
1129 CFStringRef _rv;
1130 CFStringEncoding encoding;
1131 if (!PyArg_ParseTuple(_args, "l",
1132 &encoding))
1133 return NULL;
1134 _rv = CFStringCreateFromExternalRepresentation((CFAllocatorRef)NULL,
1135 _self->ob_itself,
1136 encoding);
1137 _res = Py_BuildValue("O&",
1138 CFStringRefObj_New, _rv);
1139 return _res;
1142 static PyObject *CFDataRefObj_CFDataGetData(CFDataRefObject *_self, PyObject *_args)
1144 PyObject *_res = NULL;
1146 int size = CFDataGetLength(_self->ob_itself);
1147 char *data = (char *)CFDataGetBytePtr(_self->ob_itself);
1149 _res = (PyObject *)PyString_FromStringAndSize(data, size);
1150 return _res;
1154 static PyMethodDef CFDataRefObj_methods[] = {
1155 {"CFDataCreateCopy", (PyCFunction)CFDataRefObj_CFDataCreateCopy, 1,
1156 "() -> (CFDataRef _rv)"},
1157 {"CFDataGetLength", (PyCFunction)CFDataRefObj_CFDataGetLength, 1,
1158 "() -> (CFIndex _rv)"},
1159 {"CFStringCreateFromExternalRepresentation", (PyCFunction)CFDataRefObj_CFStringCreateFromExternalRepresentation, 1,
1160 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
1161 {"CFDataGetData", (PyCFunction)CFDataRefObj_CFDataGetData, 1,
1162 "() -> (string _rv)"},
1163 {NULL, NULL, 0}
1166 PyMethodChain CFDataRefObj_chain = { CFDataRefObj_methods, &CFTypeRefObj_chain };
1168 static PyObject *CFDataRefObj_getattr(CFDataRefObject *self, char *name)
1170 return Py_FindMethodInChain(&CFDataRefObj_chain, (PyObject *)self, name);
1173 #define CFDataRefObj_setattr NULL
1175 static int CFDataRefObj_compare(CFDataRefObject *self, CFDataRefObject *other)
1177 /* XXXX Or should we use CFEqual?? */
1178 if ( self->ob_itself > other->ob_itself ) return 1;
1179 if ( self->ob_itself < other->ob_itself ) return -1;
1180 return 0;
1183 static PyObject * CFDataRefObj_repr(CFDataRefObject *self)
1185 char buf[100];
1186 sprintf(buf, "<CFDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
1187 return PyString_FromString(buf);
1190 static int CFDataRefObj_hash(CFDataRefObject *self)
1192 /* XXXX Or should we use CFHash?? */
1193 return (int)self->ob_itself;
1196 PyTypeObject CFDataRef_Type = {
1197 PyObject_HEAD_INIT(NULL)
1198 0, /*ob_size*/
1199 "_CF.CFDataRef", /*tp_name*/
1200 sizeof(CFDataRefObject), /*tp_basicsize*/
1201 0, /*tp_itemsize*/
1202 /* methods */
1203 (destructor) CFDataRefObj_dealloc, /*tp_dealloc*/
1204 0, /*tp_print*/
1205 (getattrfunc) CFDataRefObj_getattr, /*tp_getattr*/
1206 (setattrfunc) CFDataRefObj_setattr, /*tp_setattr*/
1207 (cmpfunc) CFDataRefObj_compare, /*tp_compare*/
1208 (reprfunc) CFDataRefObj_repr, /*tp_repr*/
1209 (PyNumberMethods *)0, /* tp_as_number */
1210 (PySequenceMethods *)0, /* tp_as_sequence */
1211 (PyMappingMethods *)0, /* tp_as_mapping */
1212 (hashfunc) CFDataRefObj_hash, /*tp_hash*/
1215 /* ------------------- End object type CFDataRef -------------------- */
1218 /* ------------------ Object type CFMutableDataRef ------------------ */
1220 PyTypeObject CFMutableDataRef_Type;
1222 #define CFMutableDataRefObj_Check(x) ((x)->ob_type == &CFMutableDataRef_Type)
1224 typedef struct CFMutableDataRefObject {
1225 PyObject_HEAD
1226 CFMutableDataRef ob_itself;
1227 void (*ob_freeit)(CFTypeRef ptr);
1228 } CFMutableDataRefObject;
1230 PyObject *CFMutableDataRefObj_New(CFMutableDataRef itself)
1232 CFMutableDataRefObject *it;
1233 if (itself == NULL)
1235 PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
1236 return NULL;
1238 it = PyObject_NEW(CFMutableDataRefObject, &CFMutableDataRef_Type);
1239 if (it == NULL) return NULL;
1240 it->ob_itself = itself;
1241 it->ob_freeit = CFRelease;
1242 return (PyObject *)it;
1244 int CFMutableDataRefObj_Convert(PyObject *v, CFMutableDataRef *p_itself)
1247 if (v == Py_None) { *p_itself = NULL; return 1; }
1248 /* Check for other CF objects here */
1250 if (!CFMutableDataRefObj_Check(v))
1252 PyErr_SetString(PyExc_TypeError, "CFMutableDataRef required");
1253 return 0;
1255 *p_itself = ((CFMutableDataRefObject *)v)->ob_itself;
1256 return 1;
1259 static void CFMutableDataRefObj_dealloc(CFMutableDataRefObject *self)
1261 if (self->ob_freeit && self->ob_itself)
1263 self->ob_freeit((CFTypeRef)self->ob_itself);
1265 PyObject_Del(self);
1268 static PyObject *CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject *_self, PyObject *_args)
1270 PyObject *_res = NULL;
1271 CFIndex length;
1272 #ifndef CFDataSetLength
1273 PyMac_PRECHECK(CFDataSetLength);
1274 #endif
1275 if (!PyArg_ParseTuple(_args, "l",
1276 &length))
1277 return NULL;
1278 CFDataSetLength(_self->ob_itself,
1279 length);
1280 Py_INCREF(Py_None);
1281 _res = Py_None;
1282 return _res;
1285 static PyObject *CFMutableDataRefObj_CFDataIncreaseLength(CFMutableDataRefObject *_self, PyObject *_args)
1287 PyObject *_res = NULL;
1288 CFIndex extraLength;
1289 #ifndef CFDataIncreaseLength
1290 PyMac_PRECHECK(CFDataIncreaseLength);
1291 #endif
1292 if (!PyArg_ParseTuple(_args, "l",
1293 &extraLength))
1294 return NULL;
1295 CFDataIncreaseLength(_self->ob_itself,
1296 extraLength);
1297 Py_INCREF(Py_None);
1298 _res = Py_None;
1299 return _res;
1302 static PyObject *CFMutableDataRefObj_CFDataAppendBytes(CFMutableDataRefObject *_self, PyObject *_args)
1304 PyObject *_res = NULL;
1305 unsigned char *bytes__in__;
1306 long bytes__len__;
1307 int bytes__in_len__;
1308 #ifndef CFDataAppendBytes
1309 PyMac_PRECHECK(CFDataAppendBytes);
1310 #endif
1311 if (!PyArg_ParseTuple(_args, "s#",
1312 &bytes__in__, &bytes__in_len__))
1313 return NULL;
1314 bytes__len__ = bytes__in_len__;
1315 CFDataAppendBytes(_self->ob_itself,
1316 bytes__in__, bytes__len__);
1317 Py_INCREF(Py_None);
1318 _res = Py_None;
1319 return _res;
1322 static PyObject *CFMutableDataRefObj_CFDataReplaceBytes(CFMutableDataRefObject *_self, PyObject *_args)
1324 PyObject *_res = NULL;
1325 CFRange range;
1326 unsigned char *newBytes__in__;
1327 long newBytes__len__;
1328 int newBytes__in_len__;
1329 #ifndef CFDataReplaceBytes
1330 PyMac_PRECHECK(CFDataReplaceBytes);
1331 #endif
1332 if (!PyArg_ParseTuple(_args, "O&s#",
1333 CFRange_Convert, &range,
1334 &newBytes__in__, &newBytes__in_len__))
1335 return NULL;
1336 newBytes__len__ = newBytes__in_len__;
1337 CFDataReplaceBytes(_self->ob_itself,
1338 range,
1339 newBytes__in__, newBytes__len__);
1340 Py_INCREF(Py_None);
1341 _res = Py_None;
1342 return _res;
1345 static PyObject *CFMutableDataRefObj_CFDataDeleteBytes(CFMutableDataRefObject *_self, PyObject *_args)
1347 PyObject *_res = NULL;
1348 CFRange range;
1349 #ifndef CFDataDeleteBytes
1350 PyMac_PRECHECK(CFDataDeleteBytes);
1351 #endif
1352 if (!PyArg_ParseTuple(_args, "O&",
1353 CFRange_Convert, &range))
1354 return NULL;
1355 CFDataDeleteBytes(_self->ob_itself,
1356 range);
1357 Py_INCREF(Py_None);
1358 _res = Py_None;
1359 return _res;
1362 static PyMethodDef CFMutableDataRefObj_methods[] = {
1363 {"CFDataSetLength", (PyCFunction)CFMutableDataRefObj_CFDataSetLength, 1,
1364 "(CFIndex length) -> None"},
1365 {"CFDataIncreaseLength", (PyCFunction)CFMutableDataRefObj_CFDataIncreaseLength, 1,
1366 "(CFIndex extraLength) -> None"},
1367 {"CFDataAppendBytes", (PyCFunction)CFMutableDataRefObj_CFDataAppendBytes, 1,
1368 "(Buffer bytes) -> None"},
1369 {"CFDataReplaceBytes", (PyCFunction)CFMutableDataRefObj_CFDataReplaceBytes, 1,
1370 "(CFRange range, Buffer newBytes) -> None"},
1371 {"CFDataDeleteBytes", (PyCFunction)CFMutableDataRefObj_CFDataDeleteBytes, 1,
1372 "(CFRange range) -> None"},
1373 {NULL, NULL, 0}
1376 PyMethodChain CFMutableDataRefObj_chain = { CFMutableDataRefObj_methods, &CFDataRefObj_chain };
1378 static PyObject *CFMutableDataRefObj_getattr(CFMutableDataRefObject *self, char *name)
1380 return Py_FindMethodInChain(&CFMutableDataRefObj_chain, (PyObject *)self, name);
1383 #define CFMutableDataRefObj_setattr NULL
1385 static int CFMutableDataRefObj_compare(CFMutableDataRefObject *self, CFMutableDataRefObject *other)
1387 /* XXXX Or should we use CFEqual?? */
1388 if ( self->ob_itself > other->ob_itself ) return 1;
1389 if ( self->ob_itself < other->ob_itself ) return -1;
1390 return 0;
1393 static PyObject * CFMutableDataRefObj_repr(CFMutableDataRefObject *self)
1395 char buf[100];
1396 sprintf(buf, "<CFMutableDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
1397 return PyString_FromString(buf);
1400 static int CFMutableDataRefObj_hash(CFMutableDataRefObject *self)
1402 /* XXXX Or should we use CFHash?? */
1403 return (int)self->ob_itself;
1406 PyTypeObject CFMutableDataRef_Type = {
1407 PyObject_HEAD_INIT(NULL)
1408 0, /*ob_size*/
1409 "_CF.CFMutableDataRef", /*tp_name*/
1410 sizeof(CFMutableDataRefObject), /*tp_basicsize*/
1411 0, /*tp_itemsize*/
1412 /* methods */
1413 (destructor) CFMutableDataRefObj_dealloc, /*tp_dealloc*/
1414 0, /*tp_print*/
1415 (getattrfunc) CFMutableDataRefObj_getattr, /*tp_getattr*/
1416 (setattrfunc) CFMutableDataRefObj_setattr, /*tp_setattr*/
1417 (cmpfunc) CFMutableDataRefObj_compare, /*tp_compare*/
1418 (reprfunc) CFMutableDataRefObj_repr, /*tp_repr*/
1419 (PyNumberMethods *)0, /* tp_as_number */
1420 (PySequenceMethods *)0, /* tp_as_sequence */
1421 (PyMappingMethods *)0, /* tp_as_mapping */
1422 (hashfunc) CFMutableDataRefObj_hash, /*tp_hash*/
1425 /* ---------------- End object type CFMutableDataRef ---------------- */
1428 /* -------------------- Object type CFStringRef --------------------- */
1430 PyTypeObject CFStringRef_Type;
1432 #define CFStringRefObj_Check(x) ((x)->ob_type == &CFStringRef_Type)
1434 typedef struct CFStringRefObject {
1435 PyObject_HEAD
1436 CFStringRef ob_itself;
1437 void (*ob_freeit)(CFTypeRef ptr);
1438 } CFStringRefObject;
1440 PyObject *CFStringRefObj_New(CFStringRef itself)
1442 CFStringRefObject *it;
1443 if (itself == NULL)
1445 PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
1446 return NULL;
1448 it = PyObject_NEW(CFStringRefObject, &CFStringRef_Type);
1449 if (it == NULL) return NULL;
1450 it->ob_itself = itself;
1451 it->ob_freeit = CFRelease;
1452 return (PyObject *)it;
1454 int CFStringRefObj_Convert(PyObject *v, CFStringRef *p_itself)
1457 if (v == Py_None) { *p_itself = NULL; return 1; }
1458 if (PyString_Check(v)) {
1459 char *cStr = PyString_AsString(v);
1460 *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, 0);
1461 return 1;
1463 if (PyUnicode_Check(v)) {
1464 /* We use the CF types here, if Python was configured differently that will give an error */
1465 CFIndex size = PyUnicode_GetSize(v);
1466 UniChar *unichars = PyUnicode_AsUnicode(v);
1467 if (!unichars) return 0;
1468 *p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size);
1469 return 1;
1473 if (!CFStringRefObj_Check(v))
1475 PyErr_SetString(PyExc_TypeError, "CFStringRef required");
1476 return 0;
1478 *p_itself = ((CFStringRefObject *)v)->ob_itself;
1479 return 1;
1482 static void CFStringRefObj_dealloc(CFStringRefObject *self)
1484 if (self->ob_freeit && self->ob_itself)
1486 self->ob_freeit((CFTypeRef)self->ob_itself);
1488 PyObject_Del(self);
1491 static PyObject *CFStringRefObj_CFStringCreateWithSubstring(CFStringRefObject *_self, PyObject *_args)
1493 PyObject *_res = NULL;
1494 CFStringRef _rv;
1495 CFRange range;
1496 if (!PyArg_ParseTuple(_args, "O&",
1497 CFRange_Convert, &range))
1498 return NULL;
1499 _rv = CFStringCreateWithSubstring((CFAllocatorRef)NULL,
1500 _self->ob_itself,
1501 range);
1502 _res = Py_BuildValue("O&",
1503 CFStringRefObj_New, _rv);
1504 return _res;
1507 static PyObject *CFStringRefObj_CFStringCreateCopy(CFStringRefObject *_self, PyObject *_args)
1509 PyObject *_res = NULL;
1510 CFStringRef _rv;
1511 if (!PyArg_ParseTuple(_args, ""))
1512 return NULL;
1513 _rv = CFStringCreateCopy((CFAllocatorRef)NULL,
1514 _self->ob_itself);
1515 _res = Py_BuildValue("O&",
1516 CFStringRefObj_New, _rv);
1517 return _res;
1520 static PyObject *CFStringRefObj_CFStringGetLength(CFStringRefObject *_self, PyObject *_args)
1522 PyObject *_res = NULL;
1523 CFIndex _rv;
1524 #ifndef CFStringGetLength
1525 PyMac_PRECHECK(CFStringGetLength);
1526 #endif
1527 if (!PyArg_ParseTuple(_args, ""))
1528 return NULL;
1529 _rv = CFStringGetLength(_self->ob_itself);
1530 _res = Py_BuildValue("l",
1531 _rv);
1532 return _res;
1535 static PyObject *CFStringRefObj_CFStringGetBytes(CFStringRefObject *_self, PyObject *_args)
1537 PyObject *_res = NULL;
1538 CFIndex _rv;
1539 CFRange range;
1540 CFStringEncoding encoding;
1541 UInt8 lossByte;
1542 Boolean isExternalRepresentation;
1543 UInt8 buffer;
1544 CFIndex maxBufLen;
1545 CFIndex usedBufLen;
1546 #ifndef CFStringGetBytes
1547 PyMac_PRECHECK(CFStringGetBytes);
1548 #endif
1549 if (!PyArg_ParseTuple(_args, "O&lbll",
1550 CFRange_Convert, &range,
1551 &encoding,
1552 &lossByte,
1553 &isExternalRepresentation,
1554 &maxBufLen))
1555 return NULL;
1556 _rv = CFStringGetBytes(_self->ob_itself,
1557 range,
1558 encoding,
1559 lossByte,
1560 isExternalRepresentation,
1561 &buffer,
1562 maxBufLen,
1563 &usedBufLen);
1564 _res = Py_BuildValue("lbl",
1565 _rv,
1566 buffer,
1567 usedBufLen);
1568 return _res;
1571 static PyObject *CFStringRefObj_CFStringCreateExternalRepresentation(CFStringRefObject *_self, PyObject *_args)
1573 PyObject *_res = NULL;
1574 CFDataRef _rv;
1575 CFStringEncoding encoding;
1576 UInt8 lossByte;
1577 if (!PyArg_ParseTuple(_args, "lb",
1578 &encoding,
1579 &lossByte))
1580 return NULL;
1581 _rv = CFStringCreateExternalRepresentation((CFAllocatorRef)NULL,
1582 _self->ob_itself,
1583 encoding,
1584 lossByte);
1585 _res = Py_BuildValue("O&",
1586 CFDataRefObj_New, _rv);
1587 return _res;
1590 static PyObject *CFStringRefObj_CFStringGetSmallestEncoding(CFStringRefObject *_self, PyObject *_args)
1592 PyObject *_res = NULL;
1593 CFStringEncoding _rv;
1594 #ifndef CFStringGetSmallestEncoding
1595 PyMac_PRECHECK(CFStringGetSmallestEncoding);
1596 #endif
1597 if (!PyArg_ParseTuple(_args, ""))
1598 return NULL;
1599 _rv = CFStringGetSmallestEncoding(_self->ob_itself);
1600 _res = Py_BuildValue("l",
1601 _rv);
1602 return _res;
1605 static PyObject *CFStringRefObj_CFStringGetFastestEncoding(CFStringRefObject *_self, PyObject *_args)
1607 PyObject *_res = NULL;
1608 CFStringEncoding _rv;
1609 #ifndef CFStringGetFastestEncoding
1610 PyMac_PRECHECK(CFStringGetFastestEncoding);
1611 #endif
1612 if (!PyArg_ParseTuple(_args, ""))
1613 return NULL;
1614 _rv = CFStringGetFastestEncoding(_self->ob_itself);
1615 _res = Py_BuildValue("l",
1616 _rv);
1617 return _res;
1620 static PyObject *CFStringRefObj_CFStringCompareWithOptions(CFStringRefObject *_self, PyObject *_args)
1622 PyObject *_res = NULL;
1623 CFComparisonResult _rv;
1624 CFStringRef theString2;
1625 CFRange rangeToCompare;
1626 CFOptionFlags compareOptions;
1627 #ifndef CFStringCompareWithOptions
1628 PyMac_PRECHECK(CFStringCompareWithOptions);
1629 #endif
1630 if (!PyArg_ParseTuple(_args, "O&O&l",
1631 CFStringRefObj_Convert, &theString2,
1632 CFRange_Convert, &rangeToCompare,
1633 &compareOptions))
1634 return NULL;
1635 _rv = CFStringCompareWithOptions(_self->ob_itself,
1636 theString2,
1637 rangeToCompare,
1638 compareOptions);
1639 _res = Py_BuildValue("l",
1640 _rv);
1641 return _res;
1644 static PyObject *CFStringRefObj_CFStringCompare(CFStringRefObject *_self, PyObject *_args)
1646 PyObject *_res = NULL;
1647 CFComparisonResult _rv;
1648 CFStringRef theString2;
1649 CFOptionFlags compareOptions;
1650 #ifndef CFStringCompare
1651 PyMac_PRECHECK(CFStringCompare);
1652 #endif
1653 if (!PyArg_ParseTuple(_args, "O&l",
1654 CFStringRefObj_Convert, &theString2,
1655 &compareOptions))
1656 return NULL;
1657 _rv = CFStringCompare(_self->ob_itself,
1658 theString2,
1659 compareOptions);
1660 _res = Py_BuildValue("l",
1661 _rv);
1662 return _res;
1665 static PyObject *CFStringRefObj_CFStringFindWithOptions(CFStringRefObject *_self, PyObject *_args)
1667 PyObject *_res = NULL;
1668 Boolean _rv;
1669 CFStringRef stringToFind;
1670 CFRange rangeToSearch;
1671 CFOptionFlags searchOptions;
1672 CFRange result;
1673 #ifndef CFStringFindWithOptions
1674 PyMac_PRECHECK(CFStringFindWithOptions);
1675 #endif
1676 if (!PyArg_ParseTuple(_args, "O&O&l",
1677 CFStringRefObj_Convert, &stringToFind,
1678 CFRange_Convert, &rangeToSearch,
1679 &searchOptions))
1680 return NULL;
1681 _rv = CFStringFindWithOptions(_self->ob_itself,
1682 stringToFind,
1683 rangeToSearch,
1684 searchOptions,
1685 &result);
1686 _res = Py_BuildValue("lO&",
1687 _rv,
1688 CFRange_New, result);
1689 return _res;
1692 static PyObject *CFStringRefObj_CFStringCreateArrayWithFindResults(CFStringRefObject *_self, PyObject *_args)
1694 PyObject *_res = NULL;
1695 CFArrayRef _rv;
1696 CFStringRef stringToFind;
1697 CFRange rangeToSearch;
1698 CFOptionFlags compareOptions;
1699 if (!PyArg_ParseTuple(_args, "O&O&l",
1700 CFStringRefObj_Convert, &stringToFind,
1701 CFRange_Convert, &rangeToSearch,
1702 &compareOptions))
1703 return NULL;
1704 _rv = CFStringCreateArrayWithFindResults((CFAllocatorRef)NULL,
1705 _self->ob_itself,
1706 stringToFind,
1707 rangeToSearch,
1708 compareOptions);
1709 _res = Py_BuildValue("O&",
1710 CFArrayRefObj_New, _rv);
1711 return _res;
1714 static PyObject *CFStringRefObj_CFStringFind(CFStringRefObject *_self, PyObject *_args)
1716 PyObject *_res = NULL;
1717 CFRange _rv;
1718 CFStringRef stringToFind;
1719 CFOptionFlags compareOptions;
1720 #ifndef CFStringFind
1721 PyMac_PRECHECK(CFStringFind);
1722 #endif
1723 if (!PyArg_ParseTuple(_args, "O&l",
1724 CFStringRefObj_Convert, &stringToFind,
1725 &compareOptions))
1726 return NULL;
1727 _rv = CFStringFind(_self->ob_itself,
1728 stringToFind,
1729 compareOptions);
1730 _res = Py_BuildValue("O&",
1731 CFRange_New, _rv);
1732 return _res;
1735 static PyObject *CFStringRefObj_CFStringHasPrefix(CFStringRefObject *_self, PyObject *_args)
1737 PyObject *_res = NULL;
1738 Boolean _rv;
1739 CFStringRef prefix;
1740 #ifndef CFStringHasPrefix
1741 PyMac_PRECHECK(CFStringHasPrefix);
1742 #endif
1743 if (!PyArg_ParseTuple(_args, "O&",
1744 CFStringRefObj_Convert, &prefix))
1745 return NULL;
1746 _rv = CFStringHasPrefix(_self->ob_itself,
1747 prefix);
1748 _res = Py_BuildValue("l",
1749 _rv);
1750 return _res;
1753 static PyObject *CFStringRefObj_CFStringHasSuffix(CFStringRefObject *_self, PyObject *_args)
1755 PyObject *_res = NULL;
1756 Boolean _rv;
1757 CFStringRef suffix;
1758 #ifndef CFStringHasSuffix
1759 PyMac_PRECHECK(CFStringHasSuffix);
1760 #endif
1761 if (!PyArg_ParseTuple(_args, "O&",
1762 CFStringRefObj_Convert, &suffix))
1763 return NULL;
1764 _rv = CFStringHasSuffix(_self->ob_itself,
1765 suffix);
1766 _res = Py_BuildValue("l",
1767 _rv);
1768 return _res;
1771 static PyObject *CFStringRefObj_CFStringGetLineBounds(CFStringRefObject *_self, PyObject *_args)
1773 PyObject *_res = NULL;
1774 CFRange range;
1775 CFIndex lineBeginIndex;
1776 CFIndex lineEndIndex;
1777 CFIndex contentsEndIndex;
1778 #ifndef CFStringGetLineBounds
1779 PyMac_PRECHECK(CFStringGetLineBounds);
1780 #endif
1781 if (!PyArg_ParseTuple(_args, "O&",
1782 CFRange_Convert, &range))
1783 return NULL;
1784 CFStringGetLineBounds(_self->ob_itself,
1785 range,
1786 &lineBeginIndex,
1787 &lineEndIndex,
1788 &contentsEndIndex);
1789 _res = Py_BuildValue("lll",
1790 lineBeginIndex,
1791 lineEndIndex,
1792 contentsEndIndex);
1793 return _res;
1796 static PyObject *CFStringRefObj_CFStringCreateArrayBySeparatingStrings(CFStringRefObject *_self, PyObject *_args)
1798 PyObject *_res = NULL;
1799 CFArrayRef _rv;
1800 CFStringRef separatorString;
1801 if (!PyArg_ParseTuple(_args, "O&",
1802 CFStringRefObj_Convert, &separatorString))
1803 return NULL;
1804 _rv = CFStringCreateArrayBySeparatingStrings((CFAllocatorRef)NULL,
1805 _self->ob_itself,
1806 separatorString);
1807 _res = Py_BuildValue("O&",
1808 CFArrayRefObj_New, _rv);
1809 return _res;
1812 static PyObject *CFStringRefObj_CFStringGetIntValue(CFStringRefObject *_self, PyObject *_args)
1814 PyObject *_res = NULL;
1815 SInt32 _rv;
1816 #ifndef CFStringGetIntValue
1817 PyMac_PRECHECK(CFStringGetIntValue);
1818 #endif
1819 if (!PyArg_ParseTuple(_args, ""))
1820 return NULL;
1821 _rv = CFStringGetIntValue(_self->ob_itself);
1822 _res = Py_BuildValue("l",
1823 _rv);
1824 return _res;
1827 static PyObject *CFStringRefObj_CFStringGetDoubleValue(CFStringRefObject *_self, PyObject *_args)
1829 PyObject *_res = NULL;
1830 double _rv;
1831 #ifndef CFStringGetDoubleValue
1832 PyMac_PRECHECK(CFStringGetDoubleValue);
1833 #endif
1834 if (!PyArg_ParseTuple(_args, ""))
1835 return NULL;
1836 _rv = CFStringGetDoubleValue(_self->ob_itself);
1837 _res = Py_BuildValue("d",
1838 _rv);
1839 return _res;
1842 static PyObject *CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStringRefObject *_self, PyObject *_args)
1844 PyObject *_res = NULL;
1845 CFStringEncoding _rv;
1846 #ifndef CFStringConvertIANACharSetNameToEncoding
1847 PyMac_PRECHECK(CFStringConvertIANACharSetNameToEncoding);
1848 #endif
1849 if (!PyArg_ParseTuple(_args, ""))
1850 return NULL;
1851 _rv = CFStringConvertIANACharSetNameToEncoding(_self->ob_itself);
1852 _res = Py_BuildValue("l",
1853 _rv);
1854 return _res;
1857 static PyObject *CFStringRefObj_CFShowStr(CFStringRefObject *_self, PyObject *_args)
1859 PyObject *_res = NULL;
1860 #ifndef CFShowStr
1861 PyMac_PRECHECK(CFShowStr);
1862 #endif
1863 if (!PyArg_ParseTuple(_args, ""))
1864 return NULL;
1865 CFShowStr(_self->ob_itself);
1866 Py_INCREF(Py_None);
1867 _res = Py_None;
1868 return _res;
1871 static PyObject *CFStringRefObj_CFURLCreateWithString(CFStringRefObject *_self, PyObject *_args)
1873 PyObject *_res = NULL;
1874 CFURLRef _rv;
1875 CFURLRef baseURL;
1876 if (!PyArg_ParseTuple(_args, "O&",
1877 OptionalCFURLRefObj_Convert, &baseURL))
1878 return NULL;
1879 _rv = CFURLCreateWithString((CFAllocatorRef)NULL,
1880 _self->ob_itself,
1881 baseURL);
1882 _res = Py_BuildValue("O&",
1883 CFURLRefObj_New, _rv);
1884 return _res;
1887 static PyObject *CFStringRefObj_CFURLCreateWithFileSystemPath(CFStringRefObject *_self, PyObject *_args)
1889 PyObject *_res = NULL;
1890 CFURLRef _rv;
1891 CFURLPathStyle pathStyle;
1892 Boolean isDirectory;
1893 if (!PyArg_ParseTuple(_args, "ll",
1894 &pathStyle,
1895 &isDirectory))
1896 return NULL;
1897 _rv = CFURLCreateWithFileSystemPath((CFAllocatorRef)NULL,
1898 _self->ob_itself,
1899 pathStyle,
1900 isDirectory);
1901 _res = Py_BuildValue("O&",
1902 CFURLRefObj_New, _rv);
1903 return _res;
1906 static PyObject *CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase(CFStringRefObject *_self, PyObject *_args)
1908 PyObject *_res = NULL;
1909 CFURLRef _rv;
1910 CFURLPathStyle pathStyle;
1911 Boolean isDirectory;
1912 CFURLRef baseURL;
1913 if (!PyArg_ParseTuple(_args, "llO&",
1914 &pathStyle,
1915 &isDirectory,
1916 OptionalCFURLRefObj_Convert, &baseURL))
1917 return NULL;
1918 _rv = CFURLCreateWithFileSystemPathRelativeToBase((CFAllocatorRef)NULL,
1919 _self->ob_itself,
1920 pathStyle,
1921 isDirectory,
1922 baseURL);
1923 _res = Py_BuildValue("O&",
1924 CFURLRefObj_New, _rv);
1925 return _res;
1928 static PyObject *CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes(CFStringRefObject *_self, PyObject *_args)
1930 PyObject *_res = NULL;
1931 CFStringRef _rv;
1932 CFStringRef charactersToLeaveEscaped;
1933 if (!PyArg_ParseTuple(_args, "O&",
1934 CFStringRefObj_Convert, &charactersToLeaveEscaped))
1935 return NULL;
1936 _rv = CFURLCreateStringByReplacingPercentEscapes((CFAllocatorRef)NULL,
1937 _self->ob_itself,
1938 charactersToLeaveEscaped);
1939 _res = Py_BuildValue("O&",
1940 CFStringRefObj_New, _rv);
1941 return _res;
1944 static PyObject *CFStringRefObj_CFURLCreateStringByAddingPercentEscapes(CFStringRefObject *_self, PyObject *_args)
1946 PyObject *_res = NULL;
1947 CFStringRef _rv;
1948 CFStringRef charactersToLeaveUnescaped;
1949 CFStringRef legalURLCharactersToBeEscaped;
1950 CFStringEncoding encoding;
1951 if (!PyArg_ParseTuple(_args, "O&O&l",
1952 CFStringRefObj_Convert, &charactersToLeaveUnescaped,
1953 CFStringRefObj_Convert, &legalURLCharactersToBeEscaped,
1954 &encoding))
1955 return NULL;
1956 _rv = CFURLCreateStringByAddingPercentEscapes((CFAllocatorRef)NULL,
1957 _self->ob_itself,
1958 charactersToLeaveUnescaped,
1959 legalURLCharactersToBeEscaped,
1960 encoding);
1961 _res = Py_BuildValue("O&",
1962 CFStringRefObj_New, _rv);
1963 return _res;
1966 static PyObject *CFStringRefObj_CFStringGetString(CFStringRefObject *_self, PyObject *_args)
1968 PyObject *_res = NULL;
1970 int size = CFStringGetLength(_self->ob_itself)+1;
1971 char *data = malloc(size);
1973 if( data == NULL ) return PyErr_NoMemory();
1974 if ( CFStringGetCString(_self->ob_itself, data, size, 0) ) {
1975 _res = (PyObject *)PyString_FromString(data);
1976 } else {
1977 PyErr_SetString(PyExc_RuntimeError, "CFStringGetCString could not fit the string");
1978 _res = NULL;
1980 free(data);
1981 return _res;
1985 static PyObject *CFStringRefObj_CFStringGetUnicode(CFStringRefObject *_self, PyObject *_args)
1987 PyObject *_res = NULL;
1989 int size = CFStringGetLength(_self->ob_itself)+1;
1990 Py_UNICODE *data = malloc(size*sizeof(Py_UNICODE));
1991 CFRange range;
1993 range.location = 0;
1994 range.length = size;
1995 if( data == NULL ) return PyErr_NoMemory();
1996 CFStringGetCharacters(_self->ob_itself, range, data);
1997 _res = (PyObject *)PyUnicode_FromUnicode(data, size);
1998 free(data);
1999 return _res;
2003 static PyMethodDef CFStringRefObj_methods[] = {
2004 {"CFStringCreateWithSubstring", (PyCFunction)CFStringRefObj_CFStringCreateWithSubstring, 1,
2005 "(CFRange range) -> (CFStringRef _rv)"},
2006 {"CFStringCreateCopy", (PyCFunction)CFStringRefObj_CFStringCreateCopy, 1,
2007 "() -> (CFStringRef _rv)"},
2008 {"CFStringGetLength", (PyCFunction)CFStringRefObj_CFStringGetLength, 1,
2009 "() -> (CFIndex _rv)"},
2010 {"CFStringGetBytes", (PyCFunction)CFStringRefObj_CFStringGetBytes, 1,
2011 "(CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, CFIndex maxBufLen) -> (CFIndex _rv, UInt8 buffer, CFIndex usedBufLen)"},
2012 {"CFStringCreateExternalRepresentation", (PyCFunction)CFStringRefObj_CFStringCreateExternalRepresentation, 1,
2013 "(CFStringEncoding encoding, UInt8 lossByte) -> (CFDataRef _rv)"},
2014 {"CFStringGetSmallestEncoding", (PyCFunction)CFStringRefObj_CFStringGetSmallestEncoding, 1,
2015 "() -> (CFStringEncoding _rv)"},
2016 {"CFStringGetFastestEncoding", (PyCFunction)CFStringRefObj_CFStringGetFastestEncoding, 1,
2017 "() -> (CFStringEncoding _rv)"},
2018 {"CFStringCompareWithOptions", (PyCFunction)CFStringRefObj_CFStringCompareWithOptions, 1,
2019 "(CFStringRef theString2, CFRange rangeToCompare, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)"},
2020 {"CFStringCompare", (PyCFunction)CFStringRefObj_CFStringCompare, 1,
2021 "(CFStringRef theString2, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)"},
2022 {"CFStringFindWithOptions", (PyCFunction)CFStringRefObj_CFStringFindWithOptions, 1,
2023 "(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags searchOptions) -> (Boolean _rv, CFRange result)"},
2024 {"CFStringCreateArrayWithFindResults", (PyCFunction)CFStringRefObj_CFStringCreateArrayWithFindResults, 1,
2025 "(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions) -> (CFArrayRef _rv)"},
2026 {"CFStringFind", (PyCFunction)CFStringRefObj_CFStringFind, 1,
2027 "(CFStringRef stringToFind, CFOptionFlags compareOptions) -> (CFRange _rv)"},
2028 {"CFStringHasPrefix", (PyCFunction)CFStringRefObj_CFStringHasPrefix, 1,
2029 "(CFStringRef prefix) -> (Boolean _rv)"},
2030 {"CFStringHasSuffix", (PyCFunction)CFStringRefObj_CFStringHasSuffix, 1,
2031 "(CFStringRef suffix) -> (Boolean _rv)"},
2032 {"CFStringGetLineBounds", (PyCFunction)CFStringRefObj_CFStringGetLineBounds, 1,
2033 "(CFRange range) -> (CFIndex lineBeginIndex, CFIndex lineEndIndex, CFIndex contentsEndIndex)"},
2034 {"CFStringCreateArrayBySeparatingStrings", (PyCFunction)CFStringRefObj_CFStringCreateArrayBySeparatingStrings, 1,
2035 "(CFStringRef separatorString) -> (CFArrayRef _rv)"},
2036 {"CFStringGetIntValue", (PyCFunction)CFStringRefObj_CFStringGetIntValue, 1,
2037 "() -> (SInt32 _rv)"},
2038 {"CFStringGetDoubleValue", (PyCFunction)CFStringRefObj_CFStringGetDoubleValue, 1,
2039 "() -> (double _rv)"},
2040 {"CFStringConvertIANACharSetNameToEncoding", (PyCFunction)CFStringRefObj_CFStringConvertIANACharSetNameToEncoding, 1,
2041 "() -> (CFStringEncoding _rv)"},
2042 {"CFShowStr", (PyCFunction)CFStringRefObj_CFShowStr, 1,
2043 "() -> None"},
2044 {"CFURLCreateWithString", (PyCFunction)CFStringRefObj_CFURLCreateWithString, 1,
2045 "(CFURLRef baseURL) -> (CFURLRef _rv)"},
2046 {"CFURLCreateWithFileSystemPath", (PyCFunction)CFStringRefObj_CFURLCreateWithFileSystemPath, 1,
2047 "(CFURLPathStyle pathStyle, Boolean isDirectory) -> (CFURLRef _rv)"},
2048 {"CFURLCreateWithFileSystemPathRelativeToBase", (PyCFunction)CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase, 1,
2049 "(CFURLPathStyle pathStyle, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)"},
2050 {"CFURLCreateStringByReplacingPercentEscapes", (PyCFunction)CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes, 1,
2051 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2052 {"CFURLCreateStringByAddingPercentEscapes", (PyCFunction)CFStringRefObj_CFURLCreateStringByAddingPercentEscapes, 1,
2053 "(CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding) -> (CFStringRef _rv)"},
2054 {"CFStringGetString", (PyCFunction)CFStringRefObj_CFStringGetString, 1,
2055 "() -> (string _rv)"},
2056 {"CFStringGetUnicode", (PyCFunction)CFStringRefObj_CFStringGetUnicode, 1,
2057 "() -> (unicode _rv)"},
2058 {NULL, NULL, 0}
2061 PyMethodChain CFStringRefObj_chain = { CFStringRefObj_methods, &CFTypeRefObj_chain };
2063 static PyObject *CFStringRefObj_getattr(CFStringRefObject *self, char *name)
2065 return Py_FindMethodInChain(&CFStringRefObj_chain, (PyObject *)self, name);
2068 #define CFStringRefObj_setattr NULL
2070 static int CFStringRefObj_compare(CFStringRefObject *self, CFStringRefObject *other)
2072 /* XXXX Or should we use CFEqual?? */
2073 if ( self->ob_itself > other->ob_itself ) return 1;
2074 if ( self->ob_itself < other->ob_itself ) return -1;
2075 return 0;
2078 static PyObject * CFStringRefObj_repr(CFStringRefObject *self)
2080 char buf[100];
2081 sprintf(buf, "<CFStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
2082 return PyString_FromString(buf);
2085 static int CFStringRefObj_hash(CFStringRefObject *self)
2087 /* XXXX Or should we use CFHash?? */
2088 return (int)self->ob_itself;
2091 PyTypeObject CFStringRef_Type = {
2092 PyObject_HEAD_INIT(NULL)
2093 0, /*ob_size*/
2094 "_CF.CFStringRef", /*tp_name*/
2095 sizeof(CFStringRefObject), /*tp_basicsize*/
2096 0, /*tp_itemsize*/
2097 /* methods */
2098 (destructor) CFStringRefObj_dealloc, /*tp_dealloc*/
2099 0, /*tp_print*/
2100 (getattrfunc) CFStringRefObj_getattr, /*tp_getattr*/
2101 (setattrfunc) CFStringRefObj_setattr, /*tp_setattr*/
2102 (cmpfunc) CFStringRefObj_compare, /*tp_compare*/
2103 (reprfunc) CFStringRefObj_repr, /*tp_repr*/
2104 (PyNumberMethods *)0, /* tp_as_number */
2105 (PySequenceMethods *)0, /* tp_as_sequence */
2106 (PyMappingMethods *)0, /* tp_as_mapping */
2107 (hashfunc) CFStringRefObj_hash, /*tp_hash*/
2110 /* ------------------ End object type CFStringRef ------------------- */
2113 /* ----------------- Object type CFMutableStringRef ----------------- */
2115 PyTypeObject CFMutableStringRef_Type;
2117 #define CFMutableStringRefObj_Check(x) ((x)->ob_type == &CFMutableStringRef_Type)
2119 typedef struct CFMutableStringRefObject {
2120 PyObject_HEAD
2121 CFMutableStringRef ob_itself;
2122 void (*ob_freeit)(CFTypeRef ptr);
2123 } CFMutableStringRefObject;
2125 PyObject *CFMutableStringRefObj_New(CFMutableStringRef itself)
2127 CFMutableStringRefObject *it;
2128 if (itself == NULL)
2130 PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
2131 return NULL;
2133 it = PyObject_NEW(CFMutableStringRefObject, &CFMutableStringRef_Type);
2134 if (it == NULL) return NULL;
2135 it->ob_itself = itself;
2136 it->ob_freeit = CFRelease;
2137 return (PyObject *)it;
2139 int CFMutableStringRefObj_Convert(PyObject *v, CFMutableStringRef *p_itself)
2142 if (v == Py_None) { *p_itself = NULL; return 1; }
2143 /* Check for other CF objects here */
2145 if (!CFMutableStringRefObj_Check(v))
2147 PyErr_SetString(PyExc_TypeError, "CFMutableStringRef required");
2148 return 0;
2150 *p_itself = ((CFMutableStringRefObject *)v)->ob_itself;
2151 return 1;
2154 static void CFMutableStringRefObj_dealloc(CFMutableStringRefObject *self)
2156 if (self->ob_freeit && self->ob_itself)
2158 self->ob_freeit((CFTypeRef)self->ob_itself);
2160 PyObject_Del(self);
2163 static PyObject *CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject *_self, PyObject *_args)
2165 PyObject *_res = NULL;
2166 CFStringRef appendedString;
2167 #ifndef CFStringAppend
2168 PyMac_PRECHECK(CFStringAppend);
2169 #endif
2170 if (!PyArg_ParseTuple(_args, "O&",
2171 CFStringRefObj_Convert, &appendedString))
2172 return NULL;
2173 CFStringAppend(_self->ob_itself,
2174 appendedString);
2175 Py_INCREF(Py_None);
2176 _res = Py_None;
2177 return _res;
2180 static PyObject *CFMutableStringRefObj_CFStringAppendCharacters(CFMutableStringRefObject *_self, PyObject *_args)
2182 PyObject *_res = NULL;
2183 UniChar *chars__in__;
2184 UniCharCount chars__len__;
2185 int chars__in_len__;
2186 #ifndef CFStringAppendCharacters
2187 PyMac_PRECHECK(CFStringAppendCharacters);
2188 #endif
2189 if (!PyArg_ParseTuple(_args, "u#",
2190 &chars__in__, &chars__in_len__))
2191 return NULL;
2192 chars__len__ = chars__in_len__;
2193 CFStringAppendCharacters(_self->ob_itself,
2194 chars__in__, chars__len__);
2195 Py_INCREF(Py_None);
2196 _res = Py_None;
2197 return _res;
2200 static PyObject *CFMutableStringRefObj_CFStringAppendPascalString(CFMutableStringRefObject *_self, PyObject *_args)
2202 PyObject *_res = NULL;
2203 Str255 pStr;
2204 CFStringEncoding encoding;
2205 #ifndef CFStringAppendPascalString
2206 PyMac_PRECHECK(CFStringAppendPascalString);
2207 #endif
2208 if (!PyArg_ParseTuple(_args, "O&l",
2209 PyMac_GetStr255, pStr,
2210 &encoding))
2211 return NULL;
2212 CFStringAppendPascalString(_self->ob_itself,
2213 pStr,
2214 encoding);
2215 Py_INCREF(Py_None);
2216 _res = Py_None;
2217 return _res;
2220 static PyObject *CFMutableStringRefObj_CFStringAppendCString(CFMutableStringRefObject *_self, PyObject *_args)
2222 PyObject *_res = NULL;
2223 char* cStr;
2224 CFStringEncoding encoding;
2225 #ifndef CFStringAppendCString
2226 PyMac_PRECHECK(CFStringAppendCString);
2227 #endif
2228 if (!PyArg_ParseTuple(_args, "sl",
2229 &cStr,
2230 &encoding))
2231 return NULL;
2232 CFStringAppendCString(_self->ob_itself,
2233 cStr,
2234 encoding);
2235 Py_INCREF(Py_None);
2236 _res = Py_None;
2237 return _res;
2240 static PyObject *CFMutableStringRefObj_CFStringInsert(CFMutableStringRefObject *_self, PyObject *_args)
2242 PyObject *_res = NULL;
2243 CFIndex idx;
2244 CFStringRef insertedStr;
2245 #ifndef CFStringInsert
2246 PyMac_PRECHECK(CFStringInsert);
2247 #endif
2248 if (!PyArg_ParseTuple(_args, "lO&",
2249 &idx,
2250 CFStringRefObj_Convert, &insertedStr))
2251 return NULL;
2252 CFStringInsert(_self->ob_itself,
2253 idx,
2254 insertedStr);
2255 Py_INCREF(Py_None);
2256 _res = Py_None;
2257 return _res;
2260 static PyObject *CFMutableStringRefObj_CFStringDelete(CFMutableStringRefObject *_self, PyObject *_args)
2262 PyObject *_res = NULL;
2263 CFRange range;
2264 #ifndef CFStringDelete
2265 PyMac_PRECHECK(CFStringDelete);
2266 #endif
2267 if (!PyArg_ParseTuple(_args, "O&",
2268 CFRange_Convert, &range))
2269 return NULL;
2270 CFStringDelete(_self->ob_itself,
2271 range);
2272 Py_INCREF(Py_None);
2273 _res = Py_None;
2274 return _res;
2277 static PyObject *CFMutableStringRefObj_CFStringReplace(CFMutableStringRefObject *_self, PyObject *_args)
2279 PyObject *_res = NULL;
2280 CFRange range;
2281 CFStringRef replacement;
2282 #ifndef CFStringReplace
2283 PyMac_PRECHECK(CFStringReplace);
2284 #endif
2285 if (!PyArg_ParseTuple(_args, "O&O&",
2286 CFRange_Convert, &range,
2287 CFStringRefObj_Convert, &replacement))
2288 return NULL;
2289 CFStringReplace(_self->ob_itself,
2290 range,
2291 replacement);
2292 Py_INCREF(Py_None);
2293 _res = Py_None;
2294 return _res;
2297 static PyObject *CFMutableStringRefObj_CFStringReplaceAll(CFMutableStringRefObject *_self, PyObject *_args)
2299 PyObject *_res = NULL;
2300 CFStringRef replacement;
2301 #ifndef CFStringReplaceAll
2302 PyMac_PRECHECK(CFStringReplaceAll);
2303 #endif
2304 if (!PyArg_ParseTuple(_args, "O&",
2305 CFStringRefObj_Convert, &replacement))
2306 return NULL;
2307 CFStringReplaceAll(_self->ob_itself,
2308 replacement);
2309 Py_INCREF(Py_None);
2310 _res = Py_None;
2311 return _res;
2314 static PyObject *CFMutableStringRefObj_CFStringPad(CFMutableStringRefObject *_self, PyObject *_args)
2316 PyObject *_res = NULL;
2317 CFStringRef padString;
2318 CFIndex length;
2319 CFIndex indexIntoPad;
2320 #ifndef CFStringPad
2321 PyMac_PRECHECK(CFStringPad);
2322 #endif
2323 if (!PyArg_ParseTuple(_args, "O&ll",
2324 CFStringRefObj_Convert, &padString,
2325 &length,
2326 &indexIntoPad))
2327 return NULL;
2328 CFStringPad(_self->ob_itself,
2329 padString,
2330 length,
2331 indexIntoPad);
2332 Py_INCREF(Py_None);
2333 _res = Py_None;
2334 return _res;
2337 static PyObject *CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject *_self, PyObject *_args)
2339 PyObject *_res = NULL;
2340 CFStringRef trimString;
2341 #ifndef CFStringTrim
2342 PyMac_PRECHECK(CFStringTrim);
2343 #endif
2344 if (!PyArg_ParseTuple(_args, "O&",
2345 CFStringRefObj_Convert, &trimString))
2346 return NULL;
2347 CFStringTrim(_self->ob_itself,
2348 trimString);
2349 Py_INCREF(Py_None);
2350 _res = Py_None;
2351 return _res;
2354 static PyObject *CFMutableStringRefObj_CFStringTrimWhitespace(CFMutableStringRefObject *_self, PyObject *_args)
2356 PyObject *_res = NULL;
2357 #ifndef CFStringTrimWhitespace
2358 PyMac_PRECHECK(CFStringTrimWhitespace);
2359 #endif
2360 if (!PyArg_ParseTuple(_args, ""))
2361 return NULL;
2362 CFStringTrimWhitespace(_self->ob_itself);
2363 Py_INCREF(Py_None);
2364 _res = Py_None;
2365 return _res;
2368 static PyMethodDef CFMutableStringRefObj_methods[] = {
2369 {"CFStringAppend", (PyCFunction)CFMutableStringRefObj_CFStringAppend, 1,
2370 "(CFStringRef appendedString) -> None"},
2371 {"CFStringAppendCharacters", (PyCFunction)CFMutableStringRefObj_CFStringAppendCharacters, 1,
2372 "(Buffer chars) -> None"},
2373 {"CFStringAppendPascalString", (PyCFunction)CFMutableStringRefObj_CFStringAppendPascalString, 1,
2374 "(Str255 pStr, CFStringEncoding encoding) -> None"},
2375 {"CFStringAppendCString", (PyCFunction)CFMutableStringRefObj_CFStringAppendCString, 1,
2376 "(char* cStr, CFStringEncoding encoding) -> None"},
2377 {"CFStringInsert", (PyCFunction)CFMutableStringRefObj_CFStringInsert, 1,
2378 "(CFIndex idx, CFStringRef insertedStr) -> None"},
2379 {"CFStringDelete", (PyCFunction)CFMutableStringRefObj_CFStringDelete, 1,
2380 "(CFRange range) -> None"},
2381 {"CFStringReplace", (PyCFunction)CFMutableStringRefObj_CFStringReplace, 1,
2382 "(CFRange range, CFStringRef replacement) -> None"},
2383 {"CFStringReplaceAll", (PyCFunction)CFMutableStringRefObj_CFStringReplaceAll, 1,
2384 "(CFStringRef replacement) -> None"},
2385 {"CFStringPad", (PyCFunction)CFMutableStringRefObj_CFStringPad, 1,
2386 "(CFStringRef padString, CFIndex length, CFIndex indexIntoPad) -> None"},
2387 {"CFStringTrim", (PyCFunction)CFMutableStringRefObj_CFStringTrim, 1,
2388 "(CFStringRef trimString) -> None"},
2389 {"CFStringTrimWhitespace", (PyCFunction)CFMutableStringRefObj_CFStringTrimWhitespace, 1,
2390 "() -> None"},
2391 {NULL, NULL, 0}
2394 PyMethodChain CFMutableStringRefObj_chain = { CFMutableStringRefObj_methods, &CFStringRefObj_chain };
2396 static PyObject *CFMutableStringRefObj_getattr(CFMutableStringRefObject *self, char *name)
2398 return Py_FindMethodInChain(&CFMutableStringRefObj_chain, (PyObject *)self, name);
2401 #define CFMutableStringRefObj_setattr NULL
2403 static int CFMutableStringRefObj_compare(CFMutableStringRefObject *self, CFMutableStringRefObject *other)
2405 /* XXXX Or should we use CFEqual?? */
2406 if ( self->ob_itself > other->ob_itself ) return 1;
2407 if ( self->ob_itself < other->ob_itself ) return -1;
2408 return 0;
2411 static PyObject * CFMutableStringRefObj_repr(CFMutableStringRefObject *self)
2413 char buf[100];
2414 sprintf(buf, "<CFMutableStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
2415 return PyString_FromString(buf);
2418 static int CFMutableStringRefObj_hash(CFMutableStringRefObject *self)
2420 /* XXXX Or should we use CFHash?? */
2421 return (int)self->ob_itself;
2424 PyTypeObject CFMutableStringRef_Type = {
2425 PyObject_HEAD_INIT(NULL)
2426 0, /*ob_size*/
2427 "_CF.CFMutableStringRef", /*tp_name*/
2428 sizeof(CFMutableStringRefObject), /*tp_basicsize*/
2429 0, /*tp_itemsize*/
2430 /* methods */
2431 (destructor) CFMutableStringRefObj_dealloc, /*tp_dealloc*/
2432 0, /*tp_print*/
2433 (getattrfunc) CFMutableStringRefObj_getattr, /*tp_getattr*/
2434 (setattrfunc) CFMutableStringRefObj_setattr, /*tp_setattr*/
2435 (cmpfunc) CFMutableStringRefObj_compare, /*tp_compare*/
2436 (reprfunc) CFMutableStringRefObj_repr, /*tp_repr*/
2437 (PyNumberMethods *)0, /* tp_as_number */
2438 (PySequenceMethods *)0, /* tp_as_sequence */
2439 (PyMappingMethods *)0, /* tp_as_mapping */
2440 (hashfunc) CFMutableStringRefObj_hash, /*tp_hash*/
2443 /* --------------- End object type CFMutableStringRef --------------- */
2446 /* ---------------------- Object type CFURLRef ---------------------- */
2448 PyTypeObject CFURLRef_Type;
2450 #define CFURLRefObj_Check(x) ((x)->ob_type == &CFURLRef_Type)
2452 typedef struct CFURLRefObject {
2453 PyObject_HEAD
2454 CFURLRef ob_itself;
2455 void (*ob_freeit)(CFTypeRef ptr);
2456 } CFURLRefObject;
2458 PyObject *CFURLRefObj_New(CFURLRef itself)
2460 CFURLRefObject *it;
2461 if (itself == NULL)
2463 PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL");
2464 return NULL;
2466 it = PyObject_NEW(CFURLRefObject, &CFURLRef_Type);
2467 if (it == NULL) return NULL;
2468 it->ob_itself = itself;
2469 it->ob_freeit = CFRelease;
2470 return (PyObject *)it;
2472 int CFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself)
2475 if (v == Py_None) { *p_itself = NULL; return 1; }
2476 /* Check for other CF objects here */
2478 if (!CFURLRefObj_Check(v))
2480 PyErr_SetString(PyExc_TypeError, "CFURLRef required");
2481 return 0;
2483 *p_itself = ((CFURLRefObject *)v)->ob_itself;
2484 return 1;
2487 static void CFURLRefObj_dealloc(CFURLRefObject *self)
2489 if (self->ob_freeit && self->ob_itself)
2491 self->ob_freeit((CFTypeRef)self->ob_itself);
2493 PyObject_Del(self);
2496 static PyObject *CFURLRefObj_CFURLCreateData(CFURLRefObject *_self, PyObject *_args)
2498 PyObject *_res = NULL;
2499 CFDataRef _rv;
2500 CFStringEncoding encoding;
2501 Boolean escapeWhitespace;
2502 if (!PyArg_ParseTuple(_args, "ll",
2503 &encoding,
2504 &escapeWhitespace))
2505 return NULL;
2506 _rv = CFURLCreateData((CFAllocatorRef)NULL,
2507 _self->ob_itself,
2508 encoding,
2509 escapeWhitespace);
2510 _res = Py_BuildValue("O&",
2511 CFDataRefObj_New, _rv);
2512 return _res;
2515 static PyObject *CFURLRefObj_CFURLGetFileSystemRepresentation(CFURLRefObject *_self, PyObject *_args)
2517 PyObject *_res = NULL;
2518 Boolean _rv;
2519 Boolean resolveAgainstBase;
2520 UInt8 buffer;
2521 CFIndex maxBufLen;
2522 #ifndef CFURLGetFileSystemRepresentation
2523 PyMac_PRECHECK(CFURLGetFileSystemRepresentation);
2524 #endif
2525 if (!PyArg_ParseTuple(_args, "ll",
2526 &resolveAgainstBase,
2527 &maxBufLen))
2528 return NULL;
2529 _rv = CFURLGetFileSystemRepresentation(_self->ob_itself,
2530 resolveAgainstBase,
2531 &buffer,
2532 maxBufLen);
2533 _res = Py_BuildValue("lb",
2534 _rv,
2535 buffer);
2536 return _res;
2539 static PyObject *CFURLRefObj_CFURLCopyAbsoluteURL(CFURLRefObject *_self, PyObject *_args)
2541 PyObject *_res = NULL;
2542 CFURLRef _rv;
2543 #ifndef CFURLCopyAbsoluteURL
2544 PyMac_PRECHECK(CFURLCopyAbsoluteURL);
2545 #endif
2546 if (!PyArg_ParseTuple(_args, ""))
2547 return NULL;
2548 _rv = CFURLCopyAbsoluteURL(_self->ob_itself);
2549 _res = Py_BuildValue("O&",
2550 CFURLRefObj_New, _rv);
2551 return _res;
2554 static PyObject *CFURLRefObj_CFURLGetString(CFURLRefObject *_self, PyObject *_args)
2556 PyObject *_res = NULL;
2557 CFStringRef _rv;
2558 #ifndef CFURLGetString
2559 PyMac_PRECHECK(CFURLGetString);
2560 #endif
2561 if (!PyArg_ParseTuple(_args, ""))
2562 return NULL;
2563 _rv = CFURLGetString(_self->ob_itself);
2564 _res = Py_BuildValue("O&",
2565 CFStringRefObj_New, _rv);
2566 return _res;
2569 static PyObject *CFURLRefObj_CFURLGetBaseURL(CFURLRefObject *_self, PyObject *_args)
2571 PyObject *_res = NULL;
2572 CFURLRef _rv;
2573 #ifndef CFURLGetBaseURL
2574 PyMac_PRECHECK(CFURLGetBaseURL);
2575 #endif
2576 if (!PyArg_ParseTuple(_args, ""))
2577 return NULL;
2578 _rv = CFURLGetBaseURL(_self->ob_itself);
2579 _res = Py_BuildValue("O&",
2580 CFURLRefObj_New, _rv);
2581 return _res;
2584 static PyObject *CFURLRefObj_CFURLCanBeDecomposed(CFURLRefObject *_self, PyObject *_args)
2586 PyObject *_res = NULL;
2587 Boolean _rv;
2588 #ifndef CFURLCanBeDecomposed
2589 PyMac_PRECHECK(CFURLCanBeDecomposed);
2590 #endif
2591 if (!PyArg_ParseTuple(_args, ""))
2592 return NULL;
2593 _rv = CFURLCanBeDecomposed(_self->ob_itself);
2594 _res = Py_BuildValue("l",
2595 _rv);
2596 return _res;
2599 static PyObject *CFURLRefObj_CFURLCopyScheme(CFURLRefObject *_self, PyObject *_args)
2601 PyObject *_res = NULL;
2602 CFStringRef _rv;
2603 #ifndef CFURLCopyScheme
2604 PyMac_PRECHECK(CFURLCopyScheme);
2605 #endif
2606 if (!PyArg_ParseTuple(_args, ""))
2607 return NULL;
2608 _rv = CFURLCopyScheme(_self->ob_itself);
2609 _res = Py_BuildValue("O&",
2610 CFStringRefObj_New, _rv);
2611 return _res;
2614 static PyObject *CFURLRefObj_CFURLCopyNetLocation(CFURLRefObject *_self, PyObject *_args)
2616 PyObject *_res = NULL;
2617 CFStringRef _rv;
2618 #ifndef CFURLCopyNetLocation
2619 PyMac_PRECHECK(CFURLCopyNetLocation);
2620 #endif
2621 if (!PyArg_ParseTuple(_args, ""))
2622 return NULL;
2623 _rv = CFURLCopyNetLocation(_self->ob_itself);
2624 _res = Py_BuildValue("O&",
2625 CFStringRefObj_New, _rv);
2626 return _res;
2629 static PyObject *CFURLRefObj_CFURLCopyPath(CFURLRefObject *_self, PyObject *_args)
2631 PyObject *_res = NULL;
2632 CFStringRef _rv;
2633 #ifndef CFURLCopyPath
2634 PyMac_PRECHECK(CFURLCopyPath);
2635 #endif
2636 if (!PyArg_ParseTuple(_args, ""))
2637 return NULL;
2638 _rv = CFURLCopyPath(_self->ob_itself);
2639 _res = Py_BuildValue("O&",
2640 CFStringRefObj_New, _rv);
2641 return _res;
2644 static PyObject *CFURLRefObj_CFURLCopyStrictPath(CFURLRefObject *_self, PyObject *_args)
2646 PyObject *_res = NULL;
2647 CFStringRef _rv;
2648 Boolean isAbsolute;
2649 #ifndef CFURLCopyStrictPath
2650 PyMac_PRECHECK(CFURLCopyStrictPath);
2651 #endif
2652 if (!PyArg_ParseTuple(_args, ""))
2653 return NULL;
2654 _rv = CFURLCopyStrictPath(_self->ob_itself,
2655 &isAbsolute);
2656 _res = Py_BuildValue("O&l",
2657 CFStringRefObj_New, _rv,
2658 isAbsolute);
2659 return _res;
2662 static PyObject *CFURLRefObj_CFURLCopyFileSystemPath(CFURLRefObject *_self, PyObject *_args)
2664 PyObject *_res = NULL;
2665 CFStringRef _rv;
2666 CFURLPathStyle pathStyle;
2667 #ifndef CFURLCopyFileSystemPath
2668 PyMac_PRECHECK(CFURLCopyFileSystemPath);
2669 #endif
2670 if (!PyArg_ParseTuple(_args, "l",
2671 &pathStyle))
2672 return NULL;
2673 _rv = CFURLCopyFileSystemPath(_self->ob_itself,
2674 pathStyle);
2675 _res = Py_BuildValue("O&",
2676 CFStringRefObj_New, _rv);
2677 return _res;
2680 static PyObject *CFURLRefObj_CFURLHasDirectoryPath(CFURLRefObject *_self, PyObject *_args)
2682 PyObject *_res = NULL;
2683 Boolean _rv;
2684 #ifndef CFURLHasDirectoryPath
2685 PyMac_PRECHECK(CFURLHasDirectoryPath);
2686 #endif
2687 if (!PyArg_ParseTuple(_args, ""))
2688 return NULL;
2689 _rv = CFURLHasDirectoryPath(_self->ob_itself);
2690 _res = Py_BuildValue("l",
2691 _rv);
2692 return _res;
2695 static PyObject *CFURLRefObj_CFURLCopyResourceSpecifier(CFURLRefObject *_self, PyObject *_args)
2697 PyObject *_res = NULL;
2698 CFStringRef _rv;
2699 #ifndef CFURLCopyResourceSpecifier
2700 PyMac_PRECHECK(CFURLCopyResourceSpecifier);
2701 #endif
2702 if (!PyArg_ParseTuple(_args, ""))
2703 return NULL;
2704 _rv = CFURLCopyResourceSpecifier(_self->ob_itself);
2705 _res = Py_BuildValue("O&",
2706 CFStringRefObj_New, _rv);
2707 return _res;
2710 static PyObject *CFURLRefObj_CFURLCopyHostName(CFURLRefObject *_self, PyObject *_args)
2712 PyObject *_res = NULL;
2713 CFStringRef _rv;
2714 #ifndef CFURLCopyHostName
2715 PyMac_PRECHECK(CFURLCopyHostName);
2716 #endif
2717 if (!PyArg_ParseTuple(_args, ""))
2718 return NULL;
2719 _rv = CFURLCopyHostName(_self->ob_itself);
2720 _res = Py_BuildValue("O&",
2721 CFStringRefObj_New, _rv);
2722 return _res;
2725 static PyObject *CFURLRefObj_CFURLGetPortNumber(CFURLRefObject *_self, PyObject *_args)
2727 PyObject *_res = NULL;
2728 SInt32 _rv;
2729 #ifndef CFURLGetPortNumber
2730 PyMac_PRECHECK(CFURLGetPortNumber);
2731 #endif
2732 if (!PyArg_ParseTuple(_args, ""))
2733 return NULL;
2734 _rv = CFURLGetPortNumber(_self->ob_itself);
2735 _res = Py_BuildValue("l",
2736 _rv);
2737 return _res;
2740 static PyObject *CFURLRefObj_CFURLCopyUserName(CFURLRefObject *_self, PyObject *_args)
2742 PyObject *_res = NULL;
2743 CFStringRef _rv;
2744 #ifndef CFURLCopyUserName
2745 PyMac_PRECHECK(CFURLCopyUserName);
2746 #endif
2747 if (!PyArg_ParseTuple(_args, ""))
2748 return NULL;
2749 _rv = CFURLCopyUserName(_self->ob_itself);
2750 _res = Py_BuildValue("O&",
2751 CFStringRefObj_New, _rv);
2752 return _res;
2755 static PyObject *CFURLRefObj_CFURLCopyPassword(CFURLRefObject *_self, PyObject *_args)
2757 PyObject *_res = NULL;
2758 CFStringRef _rv;
2759 #ifndef CFURLCopyPassword
2760 PyMac_PRECHECK(CFURLCopyPassword);
2761 #endif
2762 if (!PyArg_ParseTuple(_args, ""))
2763 return NULL;
2764 _rv = CFURLCopyPassword(_self->ob_itself);
2765 _res = Py_BuildValue("O&",
2766 CFStringRefObj_New, _rv);
2767 return _res;
2770 static PyObject *CFURLRefObj_CFURLCopyParameterString(CFURLRefObject *_self, PyObject *_args)
2772 PyObject *_res = NULL;
2773 CFStringRef _rv;
2774 CFStringRef charactersToLeaveEscaped;
2775 #ifndef CFURLCopyParameterString
2776 PyMac_PRECHECK(CFURLCopyParameterString);
2777 #endif
2778 if (!PyArg_ParseTuple(_args, "O&",
2779 CFStringRefObj_Convert, &charactersToLeaveEscaped))
2780 return NULL;
2781 _rv = CFURLCopyParameterString(_self->ob_itself,
2782 charactersToLeaveEscaped);
2783 _res = Py_BuildValue("O&",
2784 CFStringRefObj_New, _rv);
2785 return _res;
2788 static PyObject *CFURLRefObj_CFURLCopyQueryString(CFURLRefObject *_self, PyObject *_args)
2790 PyObject *_res = NULL;
2791 CFStringRef _rv;
2792 CFStringRef charactersToLeaveEscaped;
2793 #ifndef CFURLCopyQueryString
2794 PyMac_PRECHECK(CFURLCopyQueryString);
2795 #endif
2796 if (!PyArg_ParseTuple(_args, "O&",
2797 CFStringRefObj_Convert, &charactersToLeaveEscaped))
2798 return NULL;
2799 _rv = CFURLCopyQueryString(_self->ob_itself,
2800 charactersToLeaveEscaped);
2801 _res = Py_BuildValue("O&",
2802 CFStringRefObj_New, _rv);
2803 return _res;
2806 static PyObject *CFURLRefObj_CFURLCopyFragment(CFURLRefObject *_self, PyObject *_args)
2808 PyObject *_res = NULL;
2809 CFStringRef _rv;
2810 CFStringRef charactersToLeaveEscaped;
2811 #ifndef CFURLCopyFragment
2812 PyMac_PRECHECK(CFURLCopyFragment);
2813 #endif
2814 if (!PyArg_ParseTuple(_args, "O&",
2815 CFStringRefObj_Convert, &charactersToLeaveEscaped))
2816 return NULL;
2817 _rv = CFURLCopyFragment(_self->ob_itself,
2818 charactersToLeaveEscaped);
2819 _res = Py_BuildValue("O&",
2820 CFStringRefObj_New, _rv);
2821 return _res;
2824 static PyObject *CFURLRefObj_CFURLCopyLastPathComponent(CFURLRefObject *_self, PyObject *_args)
2826 PyObject *_res = NULL;
2827 CFStringRef _rv;
2828 #ifndef CFURLCopyLastPathComponent
2829 PyMac_PRECHECK(CFURLCopyLastPathComponent);
2830 #endif
2831 if (!PyArg_ParseTuple(_args, ""))
2832 return NULL;
2833 _rv = CFURLCopyLastPathComponent(_self->ob_itself);
2834 _res = Py_BuildValue("O&",
2835 CFStringRefObj_New, _rv);
2836 return _res;
2839 static PyObject *CFURLRefObj_CFURLCopyPathExtension(CFURLRefObject *_self, PyObject *_args)
2841 PyObject *_res = NULL;
2842 CFStringRef _rv;
2843 #ifndef CFURLCopyPathExtension
2844 PyMac_PRECHECK(CFURLCopyPathExtension);
2845 #endif
2846 if (!PyArg_ParseTuple(_args, ""))
2847 return NULL;
2848 _rv = CFURLCopyPathExtension(_self->ob_itself);
2849 _res = Py_BuildValue("O&",
2850 CFStringRefObj_New, _rv);
2851 return _res;
2854 static PyObject *CFURLRefObj_CFURLCreateCopyAppendingPathComponent(CFURLRefObject *_self, PyObject *_args)
2856 PyObject *_res = NULL;
2857 CFURLRef _rv;
2858 CFStringRef pathComponent;
2859 Boolean isDirectory;
2860 if (!PyArg_ParseTuple(_args, "O&l",
2861 CFStringRefObj_Convert, &pathComponent,
2862 &isDirectory))
2863 return NULL;
2864 _rv = CFURLCreateCopyAppendingPathComponent((CFAllocatorRef)NULL,
2865 _self->ob_itself,
2866 pathComponent,
2867 isDirectory);
2868 _res = Py_BuildValue("O&",
2869 CFURLRefObj_New, _rv);
2870 return _res;
2873 static PyObject *CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent(CFURLRefObject *_self, PyObject *_args)
2875 PyObject *_res = NULL;
2876 CFURLRef _rv;
2877 if (!PyArg_ParseTuple(_args, ""))
2878 return NULL;
2879 _rv = CFURLCreateCopyDeletingLastPathComponent((CFAllocatorRef)NULL,
2880 _self->ob_itself);
2881 _res = Py_BuildValue("O&",
2882 CFURLRefObj_New, _rv);
2883 return _res;
2886 static PyObject *CFURLRefObj_CFURLCreateCopyAppendingPathExtension(CFURLRefObject *_self, PyObject *_args)
2888 PyObject *_res = NULL;
2889 CFURLRef _rv;
2890 CFStringRef extension;
2891 if (!PyArg_ParseTuple(_args, "O&",
2892 CFStringRefObj_Convert, &extension))
2893 return NULL;
2894 _rv = CFURLCreateCopyAppendingPathExtension((CFAllocatorRef)NULL,
2895 _self->ob_itself,
2896 extension);
2897 _res = Py_BuildValue("O&",
2898 CFURLRefObj_New, _rv);
2899 return _res;
2902 static PyObject *CFURLRefObj_CFURLCreateCopyDeletingPathExtension(CFURLRefObject *_self, PyObject *_args)
2904 PyObject *_res = NULL;
2905 CFURLRef _rv;
2906 if (!PyArg_ParseTuple(_args, ""))
2907 return NULL;
2908 _rv = CFURLCreateCopyDeletingPathExtension((CFAllocatorRef)NULL,
2909 _self->ob_itself);
2910 _res = Py_BuildValue("O&",
2911 CFURLRefObj_New, _rv);
2912 return _res;
2915 static PyObject *CFURLRefObj_CFURLGetFSRef(CFURLRefObject *_self, PyObject *_args)
2917 PyObject *_res = NULL;
2918 Boolean _rv;
2919 FSRef fsRef;
2920 #ifndef CFURLGetFSRef
2921 PyMac_PRECHECK(CFURLGetFSRef);
2922 #endif
2923 if (!PyArg_ParseTuple(_args, ""))
2924 return NULL;
2925 _rv = CFURLGetFSRef(_self->ob_itself,
2926 &fsRef);
2927 _res = Py_BuildValue("lO&",
2928 _rv,
2929 PyMac_BuildFSRef, &fsRef);
2930 return _res;
2933 static PyMethodDef CFURLRefObj_methods[] = {
2934 {"CFURLCreateData", (PyCFunction)CFURLRefObj_CFURLCreateData, 1,
2935 "(CFStringEncoding encoding, Boolean escapeWhitespace) -> (CFDataRef _rv)"},
2936 {"CFURLGetFileSystemRepresentation", (PyCFunction)CFURLRefObj_CFURLGetFileSystemRepresentation, 1,
2937 "(Boolean resolveAgainstBase, CFIndex maxBufLen) -> (Boolean _rv, UInt8 buffer)"},
2938 {"CFURLCopyAbsoluteURL", (PyCFunction)CFURLRefObj_CFURLCopyAbsoluteURL, 1,
2939 "() -> (CFURLRef _rv)"},
2940 {"CFURLGetString", (PyCFunction)CFURLRefObj_CFURLGetString, 1,
2941 "() -> (CFStringRef _rv)"},
2942 {"CFURLGetBaseURL", (PyCFunction)CFURLRefObj_CFURLGetBaseURL, 1,
2943 "() -> (CFURLRef _rv)"},
2944 {"CFURLCanBeDecomposed", (PyCFunction)CFURLRefObj_CFURLCanBeDecomposed, 1,
2945 "() -> (Boolean _rv)"},
2946 {"CFURLCopyScheme", (PyCFunction)CFURLRefObj_CFURLCopyScheme, 1,
2947 "() -> (CFStringRef _rv)"},
2948 {"CFURLCopyNetLocation", (PyCFunction)CFURLRefObj_CFURLCopyNetLocation, 1,
2949 "() -> (CFStringRef _rv)"},
2950 {"CFURLCopyPath", (PyCFunction)CFURLRefObj_CFURLCopyPath, 1,
2951 "() -> (CFStringRef _rv)"},
2952 {"CFURLCopyStrictPath", (PyCFunction)CFURLRefObj_CFURLCopyStrictPath, 1,
2953 "() -> (CFStringRef _rv, Boolean isAbsolute)"},
2954 {"CFURLCopyFileSystemPath", (PyCFunction)CFURLRefObj_CFURLCopyFileSystemPath, 1,
2955 "(CFURLPathStyle pathStyle) -> (CFStringRef _rv)"},
2956 {"CFURLHasDirectoryPath", (PyCFunction)CFURLRefObj_CFURLHasDirectoryPath, 1,
2957 "() -> (Boolean _rv)"},
2958 {"CFURLCopyResourceSpecifier", (PyCFunction)CFURLRefObj_CFURLCopyResourceSpecifier, 1,
2959 "() -> (CFStringRef _rv)"},
2960 {"CFURLCopyHostName", (PyCFunction)CFURLRefObj_CFURLCopyHostName, 1,
2961 "() -> (CFStringRef _rv)"},
2962 {"CFURLGetPortNumber", (PyCFunction)CFURLRefObj_CFURLGetPortNumber, 1,
2963 "() -> (SInt32 _rv)"},
2964 {"CFURLCopyUserName", (PyCFunction)CFURLRefObj_CFURLCopyUserName, 1,
2965 "() -> (CFStringRef _rv)"},
2966 {"CFURLCopyPassword", (PyCFunction)CFURLRefObj_CFURLCopyPassword, 1,
2967 "() -> (CFStringRef _rv)"},
2968 {"CFURLCopyParameterString", (PyCFunction)CFURLRefObj_CFURLCopyParameterString, 1,
2969 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2970 {"CFURLCopyQueryString", (PyCFunction)CFURLRefObj_CFURLCopyQueryString, 1,
2971 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2972 {"CFURLCopyFragment", (PyCFunction)CFURLRefObj_CFURLCopyFragment, 1,
2973 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2974 {"CFURLCopyLastPathComponent", (PyCFunction)CFURLRefObj_CFURLCopyLastPathComponent, 1,
2975 "() -> (CFStringRef _rv)"},
2976 {"CFURLCopyPathExtension", (PyCFunction)CFURLRefObj_CFURLCopyPathExtension, 1,
2977 "() -> (CFStringRef _rv)"},
2978 {"CFURLCreateCopyAppendingPathComponent", (PyCFunction)CFURLRefObj_CFURLCreateCopyAppendingPathComponent, 1,
2979 "(CFStringRef pathComponent, Boolean isDirectory) -> (CFURLRef _rv)"},
2980 {"CFURLCreateCopyDeletingLastPathComponent", (PyCFunction)CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent, 1,
2981 "() -> (CFURLRef _rv)"},
2982 {"CFURLCreateCopyAppendingPathExtension", (PyCFunction)CFURLRefObj_CFURLCreateCopyAppendingPathExtension, 1,
2983 "(CFStringRef extension) -> (CFURLRef _rv)"},
2984 {"CFURLCreateCopyDeletingPathExtension", (PyCFunction)CFURLRefObj_CFURLCreateCopyDeletingPathExtension, 1,
2985 "() -> (CFURLRef _rv)"},
2986 {"CFURLGetFSRef", (PyCFunction)CFURLRefObj_CFURLGetFSRef, 1,
2987 "() -> (Boolean _rv, FSRef fsRef)"},
2988 {NULL, NULL, 0}
2991 PyMethodChain CFURLRefObj_chain = { CFURLRefObj_methods, &CFTypeRefObj_chain };
2993 static PyObject *CFURLRefObj_getattr(CFURLRefObject *self, char *name)
2995 return Py_FindMethodInChain(&CFURLRefObj_chain, (PyObject *)self, name);
2998 #define CFURLRefObj_setattr NULL
3000 static int CFURLRefObj_compare(CFURLRefObject *self, CFURLRefObject *other)
3002 /* XXXX Or should we use CFEqual?? */
3003 if ( self->ob_itself > other->ob_itself ) return 1;
3004 if ( self->ob_itself < other->ob_itself ) return -1;
3005 return 0;
3008 static PyObject * CFURLRefObj_repr(CFURLRefObject *self)
3010 char buf[100];
3011 sprintf(buf, "<CFURL object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
3012 return PyString_FromString(buf);
3015 static int CFURLRefObj_hash(CFURLRefObject *self)
3017 /* XXXX Or should we use CFHash?? */
3018 return (int)self->ob_itself;
3021 PyTypeObject CFURLRef_Type = {
3022 PyObject_HEAD_INIT(NULL)
3023 0, /*ob_size*/
3024 "_CF.CFURLRef", /*tp_name*/
3025 sizeof(CFURLRefObject), /*tp_basicsize*/
3026 0, /*tp_itemsize*/
3027 /* methods */
3028 (destructor) CFURLRefObj_dealloc, /*tp_dealloc*/
3029 0, /*tp_print*/
3030 (getattrfunc) CFURLRefObj_getattr, /*tp_getattr*/
3031 (setattrfunc) CFURLRefObj_setattr, /*tp_setattr*/
3032 (cmpfunc) CFURLRefObj_compare, /*tp_compare*/
3033 (reprfunc) CFURLRefObj_repr, /*tp_repr*/
3034 (PyNumberMethods *)0, /* tp_as_number */
3035 (PySequenceMethods *)0, /* tp_as_sequence */
3036 (PyMappingMethods *)0, /* tp_as_mapping */
3037 (hashfunc) CFURLRefObj_hash, /*tp_hash*/
3040 /* -------------------- End object type CFURLRef -------------------- */
3043 static PyObject *CF___CFRangeMake(PyObject *_self, PyObject *_args)
3045 PyObject *_res = NULL;
3046 CFRange _rv;
3047 CFIndex loc;
3048 CFIndex len;
3049 #ifndef __CFRangeMake
3050 PyMac_PRECHECK(__CFRangeMake);
3051 #endif
3052 if (!PyArg_ParseTuple(_args, "ll",
3053 &loc,
3054 &len))
3055 return NULL;
3056 _rv = __CFRangeMake(loc,
3057 len);
3058 _res = Py_BuildValue("O&",
3059 CFRange_New, _rv);
3060 return _res;
3063 static PyObject *CF_CFAllocatorGetTypeID(PyObject *_self, PyObject *_args)
3065 PyObject *_res = NULL;
3066 CFTypeID _rv;
3067 #ifndef CFAllocatorGetTypeID
3068 PyMac_PRECHECK(CFAllocatorGetTypeID);
3069 #endif
3070 if (!PyArg_ParseTuple(_args, ""))
3071 return NULL;
3072 _rv = CFAllocatorGetTypeID();
3073 _res = Py_BuildValue("l",
3074 _rv);
3075 return _res;
3078 static PyObject *CF_CFAllocatorGetPreferredSizeForSize(PyObject *_self, PyObject *_args)
3080 PyObject *_res = NULL;
3081 CFIndex _rv;
3082 CFIndex size;
3083 CFOptionFlags hint;
3084 #ifndef CFAllocatorGetPreferredSizeForSize
3085 PyMac_PRECHECK(CFAllocatorGetPreferredSizeForSize);
3086 #endif
3087 if (!PyArg_ParseTuple(_args, "ll",
3088 &size,
3089 &hint))
3090 return NULL;
3091 _rv = CFAllocatorGetPreferredSizeForSize((CFAllocatorRef)NULL,
3092 size,
3093 hint);
3094 _res = Py_BuildValue("l",
3095 _rv);
3096 return _res;
3099 static PyObject *CF_CFCopyTypeIDDescription(PyObject *_self, PyObject *_args)
3101 PyObject *_res = NULL;
3102 CFStringRef _rv;
3103 CFTypeID type_id;
3104 #ifndef CFCopyTypeIDDescription
3105 PyMac_PRECHECK(CFCopyTypeIDDescription);
3106 #endif
3107 if (!PyArg_ParseTuple(_args, "l",
3108 &type_id))
3109 return NULL;
3110 _rv = CFCopyTypeIDDescription(type_id);
3111 _res = Py_BuildValue("O&",
3112 CFStringRefObj_New, _rv);
3113 return _res;
3116 static PyObject *CF_CFArrayGetTypeID(PyObject *_self, PyObject *_args)
3118 PyObject *_res = NULL;
3119 CFTypeID _rv;
3120 #ifndef CFArrayGetTypeID
3121 PyMac_PRECHECK(CFArrayGetTypeID);
3122 #endif
3123 if (!PyArg_ParseTuple(_args, ""))
3124 return NULL;
3125 _rv = CFArrayGetTypeID();
3126 _res = Py_BuildValue("l",
3127 _rv);
3128 return _res;
3131 static PyObject *CF_CFArrayCreateMutable(PyObject *_self, PyObject *_args)
3133 PyObject *_res = NULL;
3134 CFMutableArrayRef _rv;
3135 CFIndex capacity;
3136 #ifndef CFArrayCreateMutable
3137 PyMac_PRECHECK(CFArrayCreateMutable);
3138 #endif
3139 if (!PyArg_ParseTuple(_args, "l",
3140 &capacity))
3141 return NULL;
3142 _rv = CFArrayCreateMutable((CFAllocatorRef)NULL,
3143 capacity,
3144 &kCFTypeArrayCallBacks);
3145 _res = Py_BuildValue("O&",
3146 CFMutableArrayRefObj_New, _rv);
3147 return _res;
3150 static PyObject *CF_CFArrayCreateMutableCopy(PyObject *_self, PyObject *_args)
3152 PyObject *_res = NULL;
3153 CFMutableArrayRef _rv;
3154 CFIndex capacity;
3155 CFArrayRef theArray;
3156 #ifndef CFArrayCreateMutableCopy
3157 PyMac_PRECHECK(CFArrayCreateMutableCopy);
3158 #endif
3159 if (!PyArg_ParseTuple(_args, "lO&",
3160 &capacity,
3161 CFArrayRefObj_Convert, &theArray))
3162 return NULL;
3163 _rv = CFArrayCreateMutableCopy((CFAllocatorRef)NULL,
3164 capacity,
3165 theArray);
3166 _res = Py_BuildValue("O&",
3167 CFMutableArrayRefObj_New, _rv);
3168 return _res;
3171 static PyObject *CF_CFDataGetTypeID(PyObject *_self, PyObject *_args)
3173 PyObject *_res = NULL;
3174 CFTypeID _rv;
3175 #ifndef CFDataGetTypeID
3176 PyMac_PRECHECK(CFDataGetTypeID);
3177 #endif
3178 if (!PyArg_ParseTuple(_args, ""))
3179 return NULL;
3180 _rv = CFDataGetTypeID();
3181 _res = Py_BuildValue("l",
3182 _rv);
3183 return _res;
3186 static PyObject *CF_CFDataCreate(PyObject *_self, PyObject *_args)
3188 PyObject *_res = NULL;
3189 CFDataRef _rv;
3190 unsigned char *bytes__in__;
3191 long bytes__len__;
3192 int bytes__in_len__;
3193 #ifndef CFDataCreate
3194 PyMac_PRECHECK(CFDataCreate);
3195 #endif
3196 if (!PyArg_ParseTuple(_args, "s#",
3197 &bytes__in__, &bytes__in_len__))
3198 return NULL;
3199 bytes__len__ = bytes__in_len__;
3200 _rv = CFDataCreate((CFAllocatorRef)NULL,
3201 bytes__in__, bytes__len__);
3202 _res = Py_BuildValue("O&",
3203 CFDataRefObj_New, _rv);
3204 return _res;
3207 static PyObject *CF_CFDataCreateWithBytesNoCopy(PyObject *_self, PyObject *_args)
3209 PyObject *_res = NULL;
3210 CFDataRef _rv;
3211 unsigned char *bytes__in__;
3212 long bytes__len__;
3213 int bytes__in_len__;
3214 #ifndef CFDataCreateWithBytesNoCopy
3215 PyMac_PRECHECK(CFDataCreateWithBytesNoCopy);
3216 #endif
3217 if (!PyArg_ParseTuple(_args, "s#",
3218 &bytes__in__, &bytes__in_len__))
3219 return NULL;
3220 bytes__len__ = bytes__in_len__;
3221 _rv = CFDataCreateWithBytesNoCopy((CFAllocatorRef)NULL,
3222 bytes__in__, bytes__len__,
3223 (CFAllocatorRef)NULL);
3224 _res = Py_BuildValue("O&",
3225 CFDataRefObj_New, _rv);
3226 return _res;
3229 static PyObject *CF_CFDataCreateMutable(PyObject *_self, PyObject *_args)
3231 PyObject *_res = NULL;
3232 CFMutableDataRef _rv;
3233 CFIndex capacity;
3234 #ifndef CFDataCreateMutable
3235 PyMac_PRECHECK(CFDataCreateMutable);
3236 #endif
3237 if (!PyArg_ParseTuple(_args, "l",
3238 &capacity))
3239 return NULL;
3240 _rv = CFDataCreateMutable((CFAllocatorRef)NULL,
3241 capacity);
3242 _res = Py_BuildValue("O&",
3243 CFMutableDataRefObj_New, _rv);
3244 return _res;
3247 static PyObject *CF_CFDataCreateMutableCopy(PyObject *_self, PyObject *_args)
3249 PyObject *_res = NULL;
3250 CFMutableDataRef _rv;
3251 CFIndex capacity;
3252 CFDataRef theData;
3253 #ifndef CFDataCreateMutableCopy
3254 PyMac_PRECHECK(CFDataCreateMutableCopy);
3255 #endif
3256 if (!PyArg_ParseTuple(_args, "lO&",
3257 &capacity,
3258 CFDataRefObj_Convert, &theData))
3259 return NULL;
3260 _rv = CFDataCreateMutableCopy((CFAllocatorRef)NULL,
3261 capacity,
3262 theData);
3263 _res = Py_BuildValue("O&",
3264 CFMutableDataRefObj_New, _rv);
3265 return _res;
3268 static PyObject *CF_CFDictionaryGetTypeID(PyObject *_self, PyObject *_args)
3270 PyObject *_res = NULL;
3271 CFTypeID _rv;
3272 #ifndef CFDictionaryGetTypeID
3273 PyMac_PRECHECK(CFDictionaryGetTypeID);
3274 #endif
3275 if (!PyArg_ParseTuple(_args, ""))
3276 return NULL;
3277 _rv = CFDictionaryGetTypeID();
3278 _res = Py_BuildValue("l",
3279 _rv);
3280 return _res;
3283 static PyObject *CF_CFDictionaryCreateMutable(PyObject *_self, PyObject *_args)
3285 PyObject *_res = NULL;
3286 CFMutableDictionaryRef _rv;
3287 CFIndex capacity;
3288 #ifndef CFDictionaryCreateMutable
3289 PyMac_PRECHECK(CFDictionaryCreateMutable);
3290 #endif
3291 if (!PyArg_ParseTuple(_args, "l",
3292 &capacity))
3293 return NULL;
3294 _rv = CFDictionaryCreateMutable((CFAllocatorRef)NULL,
3295 capacity,
3296 &kCFTypeDictionaryKeyCallBacks,
3297 &kCFTypeDictionaryValueCallBacks);
3298 _res = Py_BuildValue("O&",
3299 CFMutableDictionaryRefObj_New, _rv);
3300 return _res;
3303 static PyObject *CF_CFDictionaryCreateMutableCopy(PyObject *_self, PyObject *_args)
3305 PyObject *_res = NULL;
3306 CFMutableDictionaryRef _rv;
3307 CFIndex capacity;
3308 CFDictionaryRef theDict;
3309 #ifndef CFDictionaryCreateMutableCopy
3310 PyMac_PRECHECK(CFDictionaryCreateMutableCopy);
3311 #endif
3312 if (!PyArg_ParseTuple(_args, "lO&",
3313 &capacity,
3314 CFDictionaryRefObj_Convert, &theDict))
3315 return NULL;
3316 _rv = CFDictionaryCreateMutableCopy((CFAllocatorRef)NULL,
3317 capacity,
3318 theDict);
3319 _res = Py_BuildValue("O&",
3320 CFMutableDictionaryRefObj_New, _rv);
3321 return _res;
3324 static PyObject *CF_CFPreferencesCopyAppValue(PyObject *_self, PyObject *_args)
3326 PyObject *_res = NULL;
3327 CFTypeRef _rv;
3328 CFStringRef key;
3329 CFStringRef applicationID;
3330 #ifndef CFPreferencesCopyAppValue
3331 PyMac_PRECHECK(CFPreferencesCopyAppValue);
3332 #endif
3333 if (!PyArg_ParseTuple(_args, "O&O&",
3334 CFStringRefObj_Convert, &key,
3335 CFStringRefObj_Convert, &applicationID))
3336 return NULL;
3337 _rv = CFPreferencesCopyAppValue(key,
3338 applicationID);
3339 _res = Py_BuildValue("O&",
3340 CFTypeRefObj_New, _rv);
3341 return _res;
3344 static PyObject *CF_CFPreferencesGetAppBooleanValue(PyObject *_self, PyObject *_args)
3346 PyObject *_res = NULL;
3347 Boolean _rv;
3348 CFStringRef key;
3349 CFStringRef applicationID;
3350 Boolean keyExistsAndHasValidFormat;
3351 #ifndef CFPreferencesGetAppBooleanValue
3352 PyMac_PRECHECK(CFPreferencesGetAppBooleanValue);
3353 #endif
3354 if (!PyArg_ParseTuple(_args, "O&O&",
3355 CFStringRefObj_Convert, &key,
3356 CFStringRefObj_Convert, &applicationID))
3357 return NULL;
3358 _rv = CFPreferencesGetAppBooleanValue(key,
3359 applicationID,
3360 &keyExistsAndHasValidFormat);
3361 _res = Py_BuildValue("ll",
3362 _rv,
3363 keyExistsAndHasValidFormat);
3364 return _res;
3367 static PyObject *CF_CFPreferencesGetAppIntegerValue(PyObject *_self, PyObject *_args)
3369 PyObject *_res = NULL;
3370 CFIndex _rv;
3371 CFStringRef key;
3372 CFStringRef applicationID;
3373 Boolean keyExistsAndHasValidFormat;
3374 #ifndef CFPreferencesGetAppIntegerValue
3375 PyMac_PRECHECK(CFPreferencesGetAppIntegerValue);
3376 #endif
3377 if (!PyArg_ParseTuple(_args, "O&O&",
3378 CFStringRefObj_Convert, &key,
3379 CFStringRefObj_Convert, &applicationID))
3380 return NULL;
3381 _rv = CFPreferencesGetAppIntegerValue(key,
3382 applicationID,
3383 &keyExistsAndHasValidFormat);
3384 _res = Py_BuildValue("ll",
3385 _rv,
3386 keyExistsAndHasValidFormat);
3387 return _res;
3390 static PyObject *CF_CFPreferencesSetAppValue(PyObject *_self, PyObject *_args)
3392 PyObject *_res = NULL;
3393 CFStringRef key;
3394 CFTypeRef value;
3395 CFStringRef applicationID;
3396 #ifndef CFPreferencesSetAppValue
3397 PyMac_PRECHECK(CFPreferencesSetAppValue);
3398 #endif
3399 if (!PyArg_ParseTuple(_args, "O&O&O&",
3400 CFStringRefObj_Convert, &key,
3401 CFTypeRefObj_Convert, &value,
3402 CFStringRefObj_Convert, &applicationID))
3403 return NULL;
3404 CFPreferencesSetAppValue(key,
3405 value,
3406 applicationID);
3407 Py_INCREF(Py_None);
3408 _res = Py_None;
3409 return _res;
3412 static PyObject *CF_CFPreferencesAddSuitePreferencesToApp(PyObject *_self, PyObject *_args)
3414 PyObject *_res = NULL;
3415 CFStringRef applicationID;
3416 CFStringRef suiteID;
3417 #ifndef CFPreferencesAddSuitePreferencesToApp
3418 PyMac_PRECHECK(CFPreferencesAddSuitePreferencesToApp);
3419 #endif
3420 if (!PyArg_ParseTuple(_args, "O&O&",
3421 CFStringRefObj_Convert, &applicationID,
3422 CFStringRefObj_Convert, &suiteID))
3423 return NULL;
3424 CFPreferencesAddSuitePreferencesToApp(applicationID,
3425 suiteID);
3426 Py_INCREF(Py_None);
3427 _res = Py_None;
3428 return _res;
3431 static PyObject *CF_CFPreferencesRemoveSuitePreferencesFromApp(PyObject *_self, PyObject *_args)
3433 PyObject *_res = NULL;
3434 CFStringRef applicationID;
3435 CFStringRef suiteID;
3436 #ifndef CFPreferencesRemoveSuitePreferencesFromApp
3437 PyMac_PRECHECK(CFPreferencesRemoveSuitePreferencesFromApp);
3438 #endif
3439 if (!PyArg_ParseTuple(_args, "O&O&",
3440 CFStringRefObj_Convert, &applicationID,
3441 CFStringRefObj_Convert, &suiteID))
3442 return NULL;
3443 CFPreferencesRemoveSuitePreferencesFromApp(applicationID,
3444 suiteID);
3445 Py_INCREF(Py_None);
3446 _res = Py_None;
3447 return _res;
3450 static PyObject *CF_CFPreferencesAppSynchronize(PyObject *_self, PyObject *_args)
3452 PyObject *_res = NULL;
3453 Boolean _rv;
3454 CFStringRef applicationID;
3455 #ifndef CFPreferencesAppSynchronize
3456 PyMac_PRECHECK(CFPreferencesAppSynchronize);
3457 #endif
3458 if (!PyArg_ParseTuple(_args, "O&",
3459 CFStringRefObj_Convert, &applicationID))
3460 return NULL;
3461 _rv = CFPreferencesAppSynchronize(applicationID);
3462 _res = Py_BuildValue("l",
3463 _rv);
3464 return _res;
3467 static PyObject *CF_CFPreferencesCopyValue(PyObject *_self, PyObject *_args)
3469 PyObject *_res = NULL;
3470 CFTypeRef _rv;
3471 CFStringRef key;
3472 CFStringRef applicationID;
3473 CFStringRef userName;
3474 CFStringRef hostName;
3475 #ifndef CFPreferencesCopyValue
3476 PyMac_PRECHECK(CFPreferencesCopyValue);
3477 #endif
3478 if (!PyArg_ParseTuple(_args, "O&O&O&O&",
3479 CFStringRefObj_Convert, &key,
3480 CFStringRefObj_Convert, &applicationID,
3481 CFStringRefObj_Convert, &userName,
3482 CFStringRefObj_Convert, &hostName))
3483 return NULL;
3484 _rv = CFPreferencesCopyValue(key,
3485 applicationID,
3486 userName,
3487 hostName);
3488 _res = Py_BuildValue("O&",
3489 CFTypeRefObj_New, _rv);
3490 return _res;
3493 static PyObject *CF_CFPreferencesCopyMultiple(PyObject *_self, PyObject *_args)
3495 PyObject *_res = NULL;
3496 CFDictionaryRef _rv;
3497 CFArrayRef keysToFetch;
3498 CFStringRef applicationID;
3499 CFStringRef userName;
3500 CFStringRef hostName;
3501 #ifndef CFPreferencesCopyMultiple
3502 PyMac_PRECHECK(CFPreferencesCopyMultiple);
3503 #endif
3504 if (!PyArg_ParseTuple(_args, "O&O&O&O&",
3505 CFArrayRefObj_Convert, &keysToFetch,
3506 CFStringRefObj_Convert, &applicationID,
3507 CFStringRefObj_Convert, &userName,
3508 CFStringRefObj_Convert, &hostName))
3509 return NULL;
3510 _rv = CFPreferencesCopyMultiple(keysToFetch,
3511 applicationID,
3512 userName,
3513 hostName);
3514 _res = Py_BuildValue("O&",
3515 CFDictionaryRefObj_New, _rv);
3516 return _res;
3519 static PyObject *CF_CFPreferencesSetValue(PyObject *_self, PyObject *_args)
3521 PyObject *_res = NULL;
3522 CFStringRef key;
3523 CFTypeRef value;
3524 CFStringRef applicationID;
3525 CFStringRef userName;
3526 CFStringRef hostName;
3527 #ifndef CFPreferencesSetValue
3528 PyMac_PRECHECK(CFPreferencesSetValue);
3529 #endif
3530 if (!PyArg_ParseTuple(_args, "O&O&O&O&O&",
3531 CFStringRefObj_Convert, &key,
3532 CFTypeRefObj_Convert, &value,
3533 CFStringRefObj_Convert, &applicationID,
3534 CFStringRefObj_Convert, &userName,
3535 CFStringRefObj_Convert, &hostName))
3536 return NULL;
3537 CFPreferencesSetValue(key,
3538 value,
3539 applicationID,
3540 userName,
3541 hostName);
3542 Py_INCREF(Py_None);
3543 _res = Py_None;
3544 return _res;
3547 static PyObject *CF_CFPreferencesSetMultiple(PyObject *_self, PyObject *_args)
3549 PyObject *_res = NULL;
3550 CFDictionaryRef keysToSet;
3551 CFArrayRef keysToRemove;
3552 CFStringRef applicationID;
3553 CFStringRef userName;
3554 CFStringRef hostName;
3555 #ifndef CFPreferencesSetMultiple
3556 PyMac_PRECHECK(CFPreferencesSetMultiple);
3557 #endif
3558 if (!PyArg_ParseTuple(_args, "O&O&O&O&O&",
3559 CFDictionaryRefObj_Convert, &keysToSet,
3560 CFArrayRefObj_Convert, &keysToRemove,
3561 CFStringRefObj_Convert, &applicationID,
3562 CFStringRefObj_Convert, &userName,
3563 CFStringRefObj_Convert, &hostName))
3564 return NULL;
3565 CFPreferencesSetMultiple(keysToSet,
3566 keysToRemove,
3567 applicationID,
3568 userName,
3569 hostName);
3570 Py_INCREF(Py_None);
3571 _res = Py_None;
3572 return _res;
3575 static PyObject *CF_CFPreferencesSynchronize(PyObject *_self, PyObject *_args)
3577 PyObject *_res = NULL;
3578 Boolean _rv;
3579 CFStringRef applicationID;
3580 CFStringRef userName;
3581 CFStringRef hostName;
3582 #ifndef CFPreferencesSynchronize
3583 PyMac_PRECHECK(CFPreferencesSynchronize);
3584 #endif
3585 if (!PyArg_ParseTuple(_args, "O&O&O&",
3586 CFStringRefObj_Convert, &applicationID,
3587 CFStringRefObj_Convert, &userName,
3588 CFStringRefObj_Convert, &hostName))
3589 return NULL;
3590 _rv = CFPreferencesSynchronize(applicationID,
3591 userName,
3592 hostName);
3593 _res = Py_BuildValue("l",
3594 _rv);
3595 return _res;
3598 static PyObject *CF_CFPreferencesCopyApplicationList(PyObject *_self, PyObject *_args)
3600 PyObject *_res = NULL;
3601 CFArrayRef _rv;
3602 CFStringRef userName;
3603 CFStringRef hostName;
3604 #ifndef CFPreferencesCopyApplicationList
3605 PyMac_PRECHECK(CFPreferencesCopyApplicationList);
3606 #endif
3607 if (!PyArg_ParseTuple(_args, "O&O&",
3608 CFStringRefObj_Convert, &userName,
3609 CFStringRefObj_Convert, &hostName))
3610 return NULL;
3611 _rv = CFPreferencesCopyApplicationList(userName,
3612 hostName);
3613 _res = Py_BuildValue("O&",
3614 CFArrayRefObj_New, _rv);
3615 return _res;
3618 static PyObject *CF_CFPreferencesCopyKeyList(PyObject *_self, PyObject *_args)
3620 PyObject *_res = NULL;
3621 CFArrayRef _rv;
3622 CFStringRef applicationID;
3623 CFStringRef userName;
3624 CFStringRef hostName;
3625 #ifndef CFPreferencesCopyKeyList
3626 PyMac_PRECHECK(CFPreferencesCopyKeyList);
3627 #endif
3628 if (!PyArg_ParseTuple(_args, "O&O&O&",
3629 CFStringRefObj_Convert, &applicationID,
3630 CFStringRefObj_Convert, &userName,
3631 CFStringRefObj_Convert, &hostName))
3632 return NULL;
3633 _rv = CFPreferencesCopyKeyList(applicationID,
3634 userName,
3635 hostName);
3636 _res = Py_BuildValue("O&",
3637 CFArrayRefObj_New, _rv);
3638 return _res;
3641 static PyObject *CF_CFStringGetTypeID(PyObject *_self, PyObject *_args)
3643 PyObject *_res = NULL;
3644 CFTypeID _rv;
3645 #ifndef CFStringGetTypeID
3646 PyMac_PRECHECK(CFStringGetTypeID);
3647 #endif
3648 if (!PyArg_ParseTuple(_args, ""))
3649 return NULL;
3650 _rv = CFStringGetTypeID();
3651 _res = Py_BuildValue("l",
3652 _rv);
3653 return _res;
3656 static PyObject *CF_CFStringCreateWithPascalString(PyObject *_self, PyObject *_args)
3658 PyObject *_res = NULL;
3659 CFStringRef _rv;
3660 Str255 pStr;
3661 CFStringEncoding encoding;
3662 #ifndef CFStringCreateWithPascalString
3663 PyMac_PRECHECK(CFStringCreateWithPascalString);
3664 #endif
3665 if (!PyArg_ParseTuple(_args, "O&l",
3666 PyMac_GetStr255, pStr,
3667 &encoding))
3668 return NULL;
3669 _rv = CFStringCreateWithPascalString((CFAllocatorRef)NULL,
3670 pStr,
3671 encoding);
3672 _res = Py_BuildValue("O&",
3673 CFStringRefObj_New, _rv);
3674 return _res;
3677 static PyObject *CF_CFStringCreateWithCString(PyObject *_self, PyObject *_args)
3679 PyObject *_res = NULL;
3680 CFStringRef _rv;
3681 char* cStr;
3682 CFStringEncoding encoding;
3683 #ifndef CFStringCreateWithCString
3684 PyMac_PRECHECK(CFStringCreateWithCString);
3685 #endif
3686 if (!PyArg_ParseTuple(_args, "sl",
3687 &cStr,
3688 &encoding))
3689 return NULL;
3690 _rv = CFStringCreateWithCString((CFAllocatorRef)NULL,
3691 cStr,
3692 encoding);
3693 _res = Py_BuildValue("O&",
3694 CFStringRefObj_New, _rv);
3695 return _res;
3698 static PyObject *CF_CFStringCreateWithCharacters(PyObject *_self, PyObject *_args)
3700 PyObject *_res = NULL;
3701 CFStringRef _rv;
3702 UniChar *chars__in__;
3703 UniCharCount chars__len__;
3704 int chars__in_len__;
3705 #ifndef CFStringCreateWithCharacters
3706 PyMac_PRECHECK(CFStringCreateWithCharacters);
3707 #endif
3708 if (!PyArg_ParseTuple(_args, "u#",
3709 &chars__in__, &chars__in_len__))
3710 return NULL;
3711 chars__len__ = chars__in_len__;
3712 _rv = CFStringCreateWithCharacters((CFAllocatorRef)NULL,
3713 chars__in__, chars__len__);
3714 _res = Py_BuildValue("O&",
3715 CFStringRefObj_New, _rv);
3716 return _res;
3719 static PyObject *CF_CFStringCreateWithPascalStringNoCopy(PyObject *_self, PyObject *_args)
3721 PyObject *_res = NULL;
3722 CFStringRef _rv;
3723 Str255 pStr;
3724 CFStringEncoding encoding;
3725 #ifndef CFStringCreateWithPascalStringNoCopy
3726 PyMac_PRECHECK(CFStringCreateWithPascalStringNoCopy);
3727 #endif
3728 if (!PyArg_ParseTuple(_args, "O&l",
3729 PyMac_GetStr255, pStr,
3730 &encoding))
3731 return NULL;
3732 _rv = CFStringCreateWithPascalStringNoCopy((CFAllocatorRef)NULL,
3733 pStr,
3734 encoding,
3735 (CFAllocatorRef)NULL);
3736 _res = Py_BuildValue("O&",
3737 CFStringRefObj_New, _rv);
3738 return _res;
3741 static PyObject *CF_CFStringCreateWithCStringNoCopy(PyObject *_self, PyObject *_args)
3743 PyObject *_res = NULL;
3744 CFStringRef _rv;
3745 char* cStr;
3746 CFStringEncoding encoding;
3747 #ifndef CFStringCreateWithCStringNoCopy
3748 PyMac_PRECHECK(CFStringCreateWithCStringNoCopy);
3749 #endif
3750 if (!PyArg_ParseTuple(_args, "sl",
3751 &cStr,
3752 &encoding))
3753 return NULL;
3754 _rv = CFStringCreateWithCStringNoCopy((CFAllocatorRef)NULL,
3755 cStr,
3756 encoding,
3757 (CFAllocatorRef)NULL);
3758 _res = Py_BuildValue("O&",
3759 CFStringRefObj_New, _rv);
3760 return _res;
3763 static PyObject *CF_CFStringCreateWithCharactersNoCopy(PyObject *_self, PyObject *_args)
3765 PyObject *_res = NULL;
3766 CFStringRef _rv;
3767 UniChar *chars__in__;
3768 UniCharCount chars__len__;
3769 int chars__in_len__;
3770 #ifndef CFStringCreateWithCharactersNoCopy
3771 PyMac_PRECHECK(CFStringCreateWithCharactersNoCopy);
3772 #endif
3773 if (!PyArg_ParseTuple(_args, "u#",
3774 &chars__in__, &chars__in_len__))
3775 return NULL;
3776 chars__len__ = chars__in_len__;
3777 _rv = CFStringCreateWithCharactersNoCopy((CFAllocatorRef)NULL,
3778 chars__in__, chars__len__,
3779 (CFAllocatorRef)NULL);
3780 _res = Py_BuildValue("O&",
3781 CFStringRefObj_New, _rv);
3782 return _res;
3785 static PyObject *CF_CFStringCreateMutable(PyObject *_self, PyObject *_args)
3787 PyObject *_res = NULL;
3788 CFMutableStringRef _rv;
3789 CFIndex maxLength;
3790 #ifndef CFStringCreateMutable
3791 PyMac_PRECHECK(CFStringCreateMutable);
3792 #endif
3793 if (!PyArg_ParseTuple(_args, "l",
3794 &maxLength))
3795 return NULL;
3796 _rv = CFStringCreateMutable((CFAllocatorRef)NULL,
3797 maxLength);
3798 _res = Py_BuildValue("O&",
3799 CFMutableStringRefObj_New, _rv);
3800 return _res;
3803 static PyObject *CF_CFStringCreateMutableCopy(PyObject *_self, PyObject *_args)
3805 PyObject *_res = NULL;
3806 CFMutableStringRef _rv;
3807 CFIndex maxLength;
3808 CFStringRef theString;
3809 #ifndef CFStringCreateMutableCopy
3810 PyMac_PRECHECK(CFStringCreateMutableCopy);
3811 #endif
3812 if (!PyArg_ParseTuple(_args, "lO&",
3813 &maxLength,
3814 CFStringRefObj_Convert, &theString))
3815 return NULL;
3816 _rv = CFStringCreateMutableCopy((CFAllocatorRef)NULL,
3817 maxLength,
3818 theString);
3819 _res = Py_BuildValue("O&",
3820 CFMutableStringRefObj_New, _rv);
3821 return _res;
3824 static PyObject *CF_CFStringCreateWithBytes(PyObject *_self, PyObject *_args)
3826 PyObject *_res = NULL;
3827 CFStringRef _rv;
3828 unsigned char *bytes__in__;
3829 long bytes__len__;
3830 int bytes__in_len__;
3831 CFStringEncoding encoding;
3832 Boolean isExternalRepresentation;
3833 #ifndef CFStringCreateWithBytes
3834 PyMac_PRECHECK(CFStringCreateWithBytes);
3835 #endif
3836 if (!PyArg_ParseTuple(_args, "s#ll",
3837 &bytes__in__, &bytes__in_len__,
3838 &encoding,
3839 &isExternalRepresentation))
3840 return NULL;
3841 bytes__len__ = bytes__in_len__;
3842 _rv = CFStringCreateWithBytes((CFAllocatorRef)NULL,
3843 bytes__in__, bytes__len__,
3844 encoding,
3845 isExternalRepresentation);
3846 _res = Py_BuildValue("O&",
3847 CFStringRefObj_New, _rv);
3848 return _res;
3851 static PyObject *CF_CFStringGetSystemEncoding(PyObject *_self, PyObject *_args)
3853 PyObject *_res = NULL;
3854 CFStringEncoding _rv;
3855 #ifndef CFStringGetSystemEncoding
3856 PyMac_PRECHECK(CFStringGetSystemEncoding);
3857 #endif
3858 if (!PyArg_ParseTuple(_args, ""))
3859 return NULL;
3860 _rv = CFStringGetSystemEncoding();
3861 _res = Py_BuildValue("l",
3862 _rv);
3863 return _res;
3866 static PyObject *CF_CFStringGetMaximumSizeForEncoding(PyObject *_self, PyObject *_args)
3868 PyObject *_res = NULL;
3869 CFIndex _rv;
3870 CFIndex length;
3871 CFStringEncoding encoding;
3872 #ifndef CFStringGetMaximumSizeForEncoding
3873 PyMac_PRECHECK(CFStringGetMaximumSizeForEncoding);
3874 #endif
3875 if (!PyArg_ParseTuple(_args, "ll",
3876 &length,
3877 &encoding))
3878 return NULL;
3879 _rv = CFStringGetMaximumSizeForEncoding(length,
3880 encoding);
3881 _res = Py_BuildValue("l",
3882 _rv);
3883 return _res;
3886 static PyObject *CF_CFStringIsEncodingAvailable(PyObject *_self, PyObject *_args)
3888 PyObject *_res = NULL;
3889 Boolean _rv;
3890 CFStringEncoding encoding;
3891 #ifndef CFStringIsEncodingAvailable
3892 PyMac_PRECHECK(CFStringIsEncodingAvailable);
3893 #endif
3894 if (!PyArg_ParseTuple(_args, "l",
3895 &encoding))
3896 return NULL;
3897 _rv = CFStringIsEncodingAvailable(encoding);
3898 _res = Py_BuildValue("l",
3899 _rv);
3900 return _res;
3903 static PyObject *CF_CFStringGetNameOfEncoding(PyObject *_self, PyObject *_args)
3905 PyObject *_res = NULL;
3906 CFStringRef _rv;
3907 CFStringEncoding encoding;
3908 #ifndef CFStringGetNameOfEncoding
3909 PyMac_PRECHECK(CFStringGetNameOfEncoding);
3910 #endif
3911 if (!PyArg_ParseTuple(_args, "l",
3912 &encoding))
3913 return NULL;
3914 _rv = CFStringGetNameOfEncoding(encoding);
3915 _res = Py_BuildValue("O&",
3916 CFStringRefObj_New, _rv);
3917 return _res;
3920 static PyObject *CF_CFStringConvertEncodingToNSStringEncoding(PyObject *_self, PyObject *_args)
3922 PyObject *_res = NULL;
3923 UInt32 _rv;
3924 CFStringEncoding encoding;
3925 #ifndef CFStringConvertEncodingToNSStringEncoding
3926 PyMac_PRECHECK(CFStringConvertEncodingToNSStringEncoding);
3927 #endif
3928 if (!PyArg_ParseTuple(_args, "l",
3929 &encoding))
3930 return NULL;
3931 _rv = CFStringConvertEncodingToNSStringEncoding(encoding);
3932 _res = Py_BuildValue("l",
3933 _rv);
3934 return _res;
3937 static PyObject *CF_CFStringConvertNSStringEncodingToEncoding(PyObject *_self, PyObject *_args)
3939 PyObject *_res = NULL;
3940 CFStringEncoding _rv;
3941 UInt32 encoding;
3942 #ifndef CFStringConvertNSStringEncodingToEncoding
3943 PyMac_PRECHECK(CFStringConvertNSStringEncodingToEncoding);
3944 #endif
3945 if (!PyArg_ParseTuple(_args, "l",
3946 &encoding))
3947 return NULL;
3948 _rv = CFStringConvertNSStringEncodingToEncoding(encoding);
3949 _res = Py_BuildValue("l",
3950 _rv);
3951 return _res;
3954 static PyObject *CF_CFStringConvertEncodingToWindowsCodepage(PyObject *_self, PyObject *_args)
3956 PyObject *_res = NULL;
3957 UInt32 _rv;
3958 CFStringEncoding encoding;
3959 #ifndef CFStringConvertEncodingToWindowsCodepage
3960 PyMac_PRECHECK(CFStringConvertEncodingToWindowsCodepage);
3961 #endif
3962 if (!PyArg_ParseTuple(_args, "l",
3963 &encoding))
3964 return NULL;
3965 _rv = CFStringConvertEncodingToWindowsCodepage(encoding);
3966 _res = Py_BuildValue("l",
3967 _rv);
3968 return _res;
3971 static PyObject *CF_CFStringConvertWindowsCodepageToEncoding(PyObject *_self, PyObject *_args)
3973 PyObject *_res = NULL;
3974 CFStringEncoding _rv;
3975 UInt32 codepage;
3976 #ifndef CFStringConvertWindowsCodepageToEncoding
3977 PyMac_PRECHECK(CFStringConvertWindowsCodepageToEncoding);
3978 #endif
3979 if (!PyArg_ParseTuple(_args, "l",
3980 &codepage))
3981 return NULL;
3982 _rv = CFStringConvertWindowsCodepageToEncoding(codepage);
3983 _res = Py_BuildValue("l",
3984 _rv);
3985 return _res;
3988 static PyObject *CF_CFStringConvertEncodingToIANACharSetName(PyObject *_self, PyObject *_args)
3990 PyObject *_res = NULL;
3991 CFStringRef _rv;
3992 CFStringEncoding encoding;
3993 #ifndef CFStringConvertEncodingToIANACharSetName
3994 PyMac_PRECHECK(CFStringConvertEncodingToIANACharSetName);
3995 #endif
3996 if (!PyArg_ParseTuple(_args, "l",
3997 &encoding))
3998 return NULL;
3999 _rv = CFStringConvertEncodingToIANACharSetName(encoding);
4000 _res = Py_BuildValue("O&",
4001 CFStringRefObj_New, _rv);
4002 return _res;
4005 static PyObject *CF_CFStringGetMostCompatibleMacStringEncoding(PyObject *_self, PyObject *_args)
4007 PyObject *_res = NULL;
4008 CFStringEncoding _rv;
4009 CFStringEncoding encoding;
4010 #ifndef CFStringGetMostCompatibleMacStringEncoding
4011 PyMac_PRECHECK(CFStringGetMostCompatibleMacStringEncoding);
4012 #endif
4013 if (!PyArg_ParseTuple(_args, "l",
4014 &encoding))
4015 return NULL;
4016 _rv = CFStringGetMostCompatibleMacStringEncoding(encoding);
4017 _res = Py_BuildValue("l",
4018 _rv);
4019 return _res;
4022 static PyObject *CF___CFStringMakeConstantString(PyObject *_self, PyObject *_args)
4024 PyObject *_res = NULL;
4025 CFStringRef _rv;
4026 char* cStr;
4027 #ifndef __CFStringMakeConstantString
4028 PyMac_PRECHECK(__CFStringMakeConstantString);
4029 #endif
4030 if (!PyArg_ParseTuple(_args, "s",
4031 &cStr))
4032 return NULL;
4033 _rv = __CFStringMakeConstantString(cStr);
4034 _res = Py_BuildValue("O&",
4035 CFStringRefObj_New, _rv);
4036 return _res;
4039 static PyObject *CF_CFURLGetTypeID(PyObject *_self, PyObject *_args)
4041 PyObject *_res = NULL;
4042 CFTypeID _rv;
4043 #ifndef CFURLGetTypeID
4044 PyMac_PRECHECK(CFURLGetTypeID);
4045 #endif
4046 if (!PyArg_ParseTuple(_args, ""))
4047 return NULL;
4048 _rv = CFURLGetTypeID();
4049 _res = Py_BuildValue("l",
4050 _rv);
4051 return _res;
4054 static PyObject *CF_CFURLCreateWithBytes(PyObject *_self, PyObject *_args)
4056 PyObject *_res = NULL;
4057 CFURLRef _rv;
4058 unsigned char *URLBytes__in__;
4059 long URLBytes__len__;
4060 int URLBytes__in_len__;
4061 CFStringEncoding encoding;
4062 CFURLRef baseURL;
4063 #ifndef CFURLCreateWithBytes
4064 PyMac_PRECHECK(CFURLCreateWithBytes);
4065 #endif
4066 if (!PyArg_ParseTuple(_args, "s#lO&",
4067 &URLBytes__in__, &URLBytes__in_len__,
4068 &encoding,
4069 OptionalCFURLRefObj_Convert, &baseURL))
4070 return NULL;
4071 URLBytes__len__ = URLBytes__in_len__;
4072 _rv = CFURLCreateWithBytes((CFAllocatorRef)NULL,
4073 URLBytes__in__, URLBytes__len__,
4074 encoding,
4075 baseURL);
4076 _res = Py_BuildValue("O&",
4077 CFURLRefObj_New, _rv);
4078 return _res;
4081 static PyObject *CF_CFURLCreateFromFileSystemRepresentation(PyObject *_self, PyObject *_args)
4083 PyObject *_res = NULL;
4084 CFURLRef _rv;
4085 unsigned char *buffer__in__;
4086 long buffer__len__;
4087 int buffer__in_len__;
4088 Boolean isDirectory;
4089 #ifndef CFURLCreateFromFileSystemRepresentation
4090 PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentation);
4091 #endif
4092 if (!PyArg_ParseTuple(_args, "s#l",
4093 &buffer__in__, &buffer__in_len__,
4094 &isDirectory))
4095 return NULL;
4096 buffer__len__ = buffer__in_len__;
4097 _rv = CFURLCreateFromFileSystemRepresentation((CFAllocatorRef)NULL,
4098 buffer__in__, buffer__len__,
4099 isDirectory);
4100 _res = Py_BuildValue("O&",
4101 CFURLRefObj_New, _rv);
4102 return _res;
4105 static PyObject *CF_CFURLCreateFromFileSystemRepresentationRelativeToBase(PyObject *_self, PyObject *_args)
4107 PyObject *_res = NULL;
4108 CFURLRef _rv;
4109 unsigned char *buffer__in__;
4110 long buffer__len__;
4111 int buffer__in_len__;
4112 Boolean isDirectory;
4113 CFURLRef baseURL;
4114 #ifndef CFURLCreateFromFileSystemRepresentationRelativeToBase
4115 PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentationRelativeToBase);
4116 #endif
4117 if (!PyArg_ParseTuple(_args, "s#lO&",
4118 &buffer__in__, &buffer__in_len__,
4119 &isDirectory,
4120 OptionalCFURLRefObj_Convert, &baseURL))
4121 return NULL;
4122 buffer__len__ = buffer__in_len__;
4123 _rv = CFURLCreateFromFileSystemRepresentationRelativeToBase((CFAllocatorRef)NULL,
4124 buffer__in__, buffer__len__,
4125 isDirectory,
4126 baseURL);
4127 _res = Py_BuildValue("O&",
4128 CFURLRefObj_New, _rv);
4129 return _res;
4132 static PyObject *CF_CFURLCreateFromFSRef(PyObject *_self, PyObject *_args)
4134 PyObject *_res = NULL;
4135 CFURLRef _rv;
4136 FSRef fsRef;
4137 #ifndef CFURLCreateFromFSRef
4138 PyMac_PRECHECK(CFURLCreateFromFSRef);
4139 #endif
4140 if (!PyArg_ParseTuple(_args, "O&",
4141 PyMac_GetFSRef, &fsRef))
4142 return NULL;
4143 _rv = CFURLCreateFromFSRef((CFAllocatorRef)NULL,
4144 &fsRef);
4145 _res = Py_BuildValue("O&",
4146 CFURLRefObj_New, _rv);
4147 return _res;
4150 static PyObject *CF_toCF(PyObject *_self, PyObject *_args)
4152 PyObject *_res = NULL;
4154 CFTypeRef rv;
4155 CFTypeID typeid;
4157 if (!PyArg_ParseTuple(_args, "O&", PyCF_Python2CF, &rv))
4158 return NULL;
4159 typeid = CFGetTypeID(rv);
4161 if (typeid == CFStringGetTypeID())
4162 return Py_BuildValue("O&", CFStringRefObj_New, rv);
4163 if (typeid == CFArrayGetTypeID())
4164 return Py_BuildValue("O&", CFArrayRefObj_New, rv);
4165 if (typeid == CFDictionaryGetTypeID())
4166 return Py_BuildValue("O&", CFDictionaryRefObj_New, rv);
4167 if (typeid == CFURLGetTypeID())
4168 return Py_BuildValue("O&", CFURLRefObj_New, rv);
4170 return Py_BuildValue("O&", CFTypeRefObj_New, rv);
4174 static PyMethodDef CF_methods[] = {
4175 {"__CFRangeMake", (PyCFunction)CF___CFRangeMake, 1,
4176 "(CFIndex loc, CFIndex len) -> (CFRange _rv)"},
4177 {"CFAllocatorGetTypeID", (PyCFunction)CF_CFAllocatorGetTypeID, 1,
4178 "() -> (CFTypeID _rv)"},
4179 {"CFAllocatorGetPreferredSizeForSize", (PyCFunction)CF_CFAllocatorGetPreferredSizeForSize, 1,
4180 "(CFIndex size, CFOptionFlags hint) -> (CFIndex _rv)"},
4181 {"CFCopyTypeIDDescription", (PyCFunction)CF_CFCopyTypeIDDescription, 1,
4182 "(CFTypeID type_id) -> (CFStringRef _rv)"},
4183 {"CFArrayGetTypeID", (PyCFunction)CF_CFArrayGetTypeID, 1,
4184 "() -> (CFTypeID _rv)"},
4185 {"CFArrayCreateMutable", (PyCFunction)CF_CFArrayCreateMutable, 1,
4186 "(CFIndex capacity) -> (CFMutableArrayRef _rv)"},
4187 {"CFArrayCreateMutableCopy", (PyCFunction)CF_CFArrayCreateMutableCopy, 1,
4188 "(CFIndex capacity, CFArrayRef theArray) -> (CFMutableArrayRef _rv)"},
4189 {"CFDataGetTypeID", (PyCFunction)CF_CFDataGetTypeID, 1,
4190 "() -> (CFTypeID _rv)"},
4191 {"CFDataCreate", (PyCFunction)CF_CFDataCreate, 1,
4192 "(Buffer bytes) -> (CFDataRef _rv)"},
4193 {"CFDataCreateWithBytesNoCopy", (PyCFunction)CF_CFDataCreateWithBytesNoCopy, 1,
4194 "(Buffer bytes) -> (CFDataRef _rv)"},
4195 {"CFDataCreateMutable", (PyCFunction)CF_CFDataCreateMutable, 1,
4196 "(CFIndex capacity) -> (CFMutableDataRef _rv)"},
4197 {"CFDataCreateMutableCopy", (PyCFunction)CF_CFDataCreateMutableCopy, 1,
4198 "(CFIndex capacity, CFDataRef theData) -> (CFMutableDataRef _rv)"},
4199 {"CFDictionaryGetTypeID", (PyCFunction)CF_CFDictionaryGetTypeID, 1,
4200 "() -> (CFTypeID _rv)"},
4201 {"CFDictionaryCreateMutable", (PyCFunction)CF_CFDictionaryCreateMutable, 1,
4202 "(CFIndex capacity) -> (CFMutableDictionaryRef _rv)"},
4203 {"CFDictionaryCreateMutableCopy", (PyCFunction)CF_CFDictionaryCreateMutableCopy, 1,
4204 "(CFIndex capacity, CFDictionaryRef theDict) -> (CFMutableDictionaryRef _rv)"},
4205 {"CFPreferencesCopyAppValue", (PyCFunction)CF_CFPreferencesCopyAppValue, 1,
4206 "(CFStringRef key, CFStringRef applicationID) -> (CFTypeRef _rv)"},
4207 {"CFPreferencesGetAppBooleanValue", (PyCFunction)CF_CFPreferencesGetAppBooleanValue, 1,
4208 "(CFStringRef key, CFStringRef applicationID) -> (Boolean _rv, Boolean keyExistsAndHasValidFormat)"},
4209 {"CFPreferencesGetAppIntegerValue", (PyCFunction)CF_CFPreferencesGetAppIntegerValue, 1,
4210 "(CFStringRef key, CFStringRef applicationID) -> (CFIndex _rv, Boolean keyExistsAndHasValidFormat)"},
4211 {"CFPreferencesSetAppValue", (PyCFunction)CF_CFPreferencesSetAppValue, 1,
4212 "(CFStringRef key, CFTypeRef value, CFStringRef applicationID) -> None"},
4213 {"CFPreferencesAddSuitePreferencesToApp", (PyCFunction)CF_CFPreferencesAddSuitePreferencesToApp, 1,
4214 "(CFStringRef applicationID, CFStringRef suiteID) -> None"},
4215 {"CFPreferencesRemoveSuitePreferencesFromApp", (PyCFunction)CF_CFPreferencesRemoveSuitePreferencesFromApp, 1,
4216 "(CFStringRef applicationID, CFStringRef suiteID) -> None"},
4217 {"CFPreferencesAppSynchronize", (PyCFunction)CF_CFPreferencesAppSynchronize, 1,
4218 "(CFStringRef applicationID) -> (Boolean _rv)"},
4219 {"CFPreferencesCopyValue", (PyCFunction)CF_CFPreferencesCopyValue, 1,
4220 "(CFStringRef key, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFTypeRef _rv)"},
4221 {"CFPreferencesCopyMultiple", (PyCFunction)CF_CFPreferencesCopyMultiple, 1,
4222 "(CFArrayRef keysToFetch, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFDictionaryRef _rv)"},
4223 {"CFPreferencesSetValue", (PyCFunction)CF_CFPreferencesSetValue, 1,
4224 "(CFStringRef key, CFTypeRef value, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None"},
4225 {"CFPreferencesSetMultiple", (PyCFunction)CF_CFPreferencesSetMultiple, 1,
4226 "(CFDictionaryRef keysToSet, CFArrayRef keysToRemove, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None"},
4227 {"CFPreferencesSynchronize", (PyCFunction)CF_CFPreferencesSynchronize, 1,
4228 "(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (Boolean _rv)"},
4229 {"CFPreferencesCopyApplicationList", (PyCFunction)CF_CFPreferencesCopyApplicationList, 1,
4230 "(CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)"},
4231 {"CFPreferencesCopyKeyList", (PyCFunction)CF_CFPreferencesCopyKeyList, 1,
4232 "(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)"},
4233 {"CFStringGetTypeID", (PyCFunction)CF_CFStringGetTypeID, 1,
4234 "() -> (CFTypeID _rv)"},
4235 {"CFStringCreateWithPascalString", (PyCFunction)CF_CFStringCreateWithPascalString, 1,
4236 "(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
4237 {"CFStringCreateWithCString", (PyCFunction)CF_CFStringCreateWithCString, 1,
4238 "(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
4239 {"CFStringCreateWithCharacters", (PyCFunction)CF_CFStringCreateWithCharacters, 1,
4240 "(Buffer chars) -> (CFStringRef _rv)"},
4241 {"CFStringCreateWithPascalStringNoCopy", (PyCFunction)CF_CFStringCreateWithPascalStringNoCopy, 1,
4242 "(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
4243 {"CFStringCreateWithCStringNoCopy", (PyCFunction)CF_CFStringCreateWithCStringNoCopy, 1,
4244 "(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
4245 {"CFStringCreateWithCharactersNoCopy", (PyCFunction)CF_CFStringCreateWithCharactersNoCopy, 1,
4246 "(Buffer chars) -> (CFStringRef _rv)"},
4247 {"CFStringCreateMutable", (PyCFunction)CF_CFStringCreateMutable, 1,
4248 "(CFIndex maxLength) -> (CFMutableStringRef _rv)"},
4249 {"CFStringCreateMutableCopy", (PyCFunction)CF_CFStringCreateMutableCopy, 1,
4250 "(CFIndex maxLength, CFStringRef theString) -> (CFMutableStringRef _rv)"},
4251 {"CFStringCreateWithBytes", (PyCFunction)CF_CFStringCreateWithBytes, 1,
4252 "(Buffer bytes, CFStringEncoding encoding, Boolean isExternalRepresentation) -> (CFStringRef _rv)"},
4253 {"CFStringGetSystemEncoding", (PyCFunction)CF_CFStringGetSystemEncoding, 1,
4254 "() -> (CFStringEncoding _rv)"},
4255 {"CFStringGetMaximumSizeForEncoding", (PyCFunction)CF_CFStringGetMaximumSizeForEncoding, 1,
4256 "(CFIndex length, CFStringEncoding encoding) -> (CFIndex _rv)"},
4257 {"CFStringIsEncodingAvailable", (PyCFunction)CF_CFStringIsEncodingAvailable, 1,
4258 "(CFStringEncoding encoding) -> (Boolean _rv)"},
4259 {"CFStringGetNameOfEncoding", (PyCFunction)CF_CFStringGetNameOfEncoding, 1,
4260 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
4261 {"CFStringConvertEncodingToNSStringEncoding", (PyCFunction)CF_CFStringConvertEncodingToNSStringEncoding, 1,
4262 "(CFStringEncoding encoding) -> (UInt32 _rv)"},
4263 {"CFStringConvertNSStringEncodingToEncoding", (PyCFunction)CF_CFStringConvertNSStringEncodingToEncoding, 1,
4264 "(UInt32 encoding) -> (CFStringEncoding _rv)"},
4265 {"CFStringConvertEncodingToWindowsCodepage", (PyCFunction)CF_CFStringConvertEncodingToWindowsCodepage, 1,
4266 "(CFStringEncoding encoding) -> (UInt32 _rv)"},
4267 {"CFStringConvertWindowsCodepageToEncoding", (PyCFunction)CF_CFStringConvertWindowsCodepageToEncoding, 1,
4268 "(UInt32 codepage) -> (CFStringEncoding _rv)"},
4269 {"CFStringConvertEncodingToIANACharSetName", (PyCFunction)CF_CFStringConvertEncodingToIANACharSetName, 1,
4270 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
4271 {"CFStringGetMostCompatibleMacStringEncoding", (PyCFunction)CF_CFStringGetMostCompatibleMacStringEncoding, 1,
4272 "(CFStringEncoding encoding) -> (CFStringEncoding _rv)"},
4273 {"__CFStringMakeConstantString", (PyCFunction)CF___CFStringMakeConstantString, 1,
4274 "(char* cStr) -> (CFStringRef _rv)"},
4275 {"CFURLGetTypeID", (PyCFunction)CF_CFURLGetTypeID, 1,
4276 "() -> (CFTypeID _rv)"},
4277 {"CFURLCreateWithBytes", (PyCFunction)CF_CFURLCreateWithBytes, 1,
4278 "(Buffer URLBytes, CFStringEncoding encoding, CFURLRef baseURL) -> (CFURLRef _rv)"},
4279 {"CFURLCreateFromFileSystemRepresentation", (PyCFunction)CF_CFURLCreateFromFileSystemRepresentation, 1,
4280 "(Buffer buffer, Boolean isDirectory) -> (CFURLRef _rv)"},
4281 {"CFURLCreateFromFileSystemRepresentationRelativeToBase", (PyCFunction)CF_CFURLCreateFromFileSystemRepresentationRelativeToBase, 1,
4282 "(Buffer buffer, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)"},
4283 {"CFURLCreateFromFSRef", (PyCFunction)CF_CFURLCreateFromFSRef, 1,
4284 "(FSRef fsRef) -> (CFURLRef _rv)"},
4285 {"toCF", (PyCFunction)CF_toCF, 1,
4286 "(python_object) -> (CF_object)"},
4287 {NULL, NULL, 0}
4293 void init_CF(void)
4295 PyObject *m;
4296 PyObject *d;
4300 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFTypeRef, CFTypeRefObj_New);
4301 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFTypeRef, CFTypeRefObj_Convert);
4302 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFStringRef, CFStringRefObj_New);
4303 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFStringRef, CFStringRefObj_Convert);
4304 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableStringRef, CFMutableStringRefObj_New);
4305 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableStringRef, CFMutableStringRefObj_Convert);
4307 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFArrayRef, CFArrayRefObj_New);
4308 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFArrayRef, CFArrayRefObj_Convert);
4309 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableArrayRef, CFMutableArrayRefObj_New);
4310 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableArrayRef, CFMutableArrayRefObj_Convert);
4311 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFDictionaryRef, CFDictionaryRefObj_New);
4312 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFDictionaryRef, CFDictionaryRefObj_Convert);
4313 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableDictionaryRef, CFMutableDictionaryRefObj_New);
4314 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableDictionaryRef, CFMutableDictionaryRefObj_Convert);
4315 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFURLRef, CFURLRefObj_New);
4316 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef, CFURLRefObj_Convert);
4317 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef, CFURLRefObj_Convert);
4320 m = Py_InitModule("_CF", CF_methods);
4321 d = PyModule_GetDict(m);
4322 CF_Error = PyMac_GetOSErrException();
4323 if (CF_Error == NULL ||
4324 PyDict_SetItemString(d, "Error", CF_Error) != 0)
4325 return;
4326 CFTypeRef_Type.ob_type = &PyType_Type;
4327 Py_INCREF(&CFTypeRef_Type);
4328 if (PyDict_SetItemString(d, "CFTypeRefType", (PyObject *)&CFTypeRef_Type) != 0)
4329 Py_FatalError("can't initialize CFTypeRefType");
4330 CFArrayRef_Type.ob_type = &PyType_Type;
4331 Py_INCREF(&CFArrayRef_Type);
4332 if (PyDict_SetItemString(d, "CFArrayRefType", (PyObject *)&CFArrayRef_Type) != 0)
4333 Py_FatalError("can't initialize CFArrayRefType");
4334 CFMutableArrayRef_Type.ob_type = &PyType_Type;
4335 Py_INCREF(&CFMutableArrayRef_Type);
4336 if (PyDict_SetItemString(d, "CFMutableArrayRefType", (PyObject *)&CFMutableArrayRef_Type) != 0)
4337 Py_FatalError("can't initialize CFMutableArrayRefType");
4338 CFDictionaryRef_Type.ob_type = &PyType_Type;
4339 Py_INCREF(&CFDictionaryRef_Type);
4340 if (PyDict_SetItemString(d, "CFDictionaryRefType", (PyObject *)&CFDictionaryRef_Type) != 0)
4341 Py_FatalError("can't initialize CFDictionaryRefType");
4342 CFMutableDictionaryRef_Type.ob_type = &PyType_Type;
4343 Py_INCREF(&CFMutableDictionaryRef_Type);
4344 if (PyDict_SetItemString(d, "CFMutableDictionaryRefType", (PyObject *)&CFMutableDictionaryRef_Type) != 0)
4345 Py_FatalError("can't initialize CFMutableDictionaryRefType");
4346 CFDataRef_Type.ob_type = &PyType_Type;
4347 Py_INCREF(&CFDataRef_Type);
4348 if (PyDict_SetItemString(d, "CFDataRefType", (PyObject *)&CFDataRef_Type) != 0)
4349 Py_FatalError("can't initialize CFDataRefType");
4350 CFMutableDataRef_Type.ob_type = &PyType_Type;
4351 Py_INCREF(&CFMutableDataRef_Type);
4352 if (PyDict_SetItemString(d, "CFMutableDataRefType", (PyObject *)&CFMutableDataRef_Type) != 0)
4353 Py_FatalError("can't initialize CFMutableDataRefType");
4354 CFStringRef_Type.ob_type = &PyType_Type;
4355 Py_INCREF(&CFStringRef_Type);
4356 if (PyDict_SetItemString(d, "CFStringRefType", (PyObject *)&CFStringRef_Type) != 0)
4357 Py_FatalError("can't initialize CFStringRefType");
4358 CFMutableStringRef_Type.ob_type = &PyType_Type;
4359 Py_INCREF(&CFMutableStringRef_Type);
4360 if (PyDict_SetItemString(d, "CFMutableStringRefType", (PyObject *)&CFMutableStringRef_Type) != 0)
4361 Py_FatalError("can't initialize CFMutableStringRefType");
4362 CFURLRef_Type.ob_type = &PyType_Type;
4363 Py_INCREF(&CFURLRef_Type);
4364 if (PyDict_SetItemString(d, "CFURLRefType", (PyObject *)&CFURLRef_Type) != 0)
4365 Py_FatalError("can't initialize CFURLRefType");
4367 #define _STRINGCONST(name) PyModule_AddObject(m, #name, CFStringRefObj_New(name))
4368 _STRINGCONST(kCFPreferencesAnyApplication);
4369 _STRINGCONST(kCFPreferencesCurrentApplication);
4370 _STRINGCONST(kCFPreferencesAnyHost);
4371 _STRINGCONST(kCFPreferencesCurrentHost);
4372 _STRINGCONST(kCFPreferencesAnyUser);
4373 _STRINGCONST(kCFPreferencesCurrentUser);
4379 /* ========================= End module _CF ========================= */