2 /* =========================== Module _CF =========================== */
8 #include "pymactoolbox.h"
10 /* Macro to test whether a weak-loaded CFM function exists */
11 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
12 PyErr_SetString(PyExc_NotImplementedError, \
13 "Not available in this shared library/OS version"); \
18 #include <CoreServices/CoreServices.h>
20 #include "pycfbridge.h"
22 #ifdef USE_TOOLBOX_OBJECT_GLUE
23 extern PyObject
*_CFObj_New(CFTypeRef
);
24 extern int _CFObj_Convert(PyObject
*, CFTypeRef
*);
25 #define CFObj_New _CFObj_New
26 #define CFObj_Convert _CFObj_Convert
28 extern PyObject
*_CFTypeRefObj_New(CFTypeRef
);
29 extern int _CFTypeRefObj_Convert(PyObject
*, CFTypeRef
*);
30 #define CFTypeRefObj_New _CFTypeRefObj_New
31 #define CFTypeRefObj_Convert _CFTypeRefObj_Convert
33 extern PyObject
*_CFStringRefObj_New(CFStringRef
);
34 extern int _CFStringRefObj_Convert(PyObject
*, CFStringRef
*);
35 #define CFStringRefObj_New _CFStringRefObj_New
36 #define CFStringRefObj_Convert _CFStringRefObj_Convert
38 extern PyObject
*_CFMutableStringRefObj_New(CFMutableStringRef
);
39 extern int _CFMutableStringRefObj_Convert(PyObject
*, CFMutableStringRef
*);
40 #define CFMutableStringRefObj_New _CFMutableStringRefObj_New
41 #define CFMutableStringRefObj_Convert _CFMutableStringRefObj_Convert
43 extern PyObject
*_CFArrayRefObj_New(CFArrayRef
);
44 extern int _CFArrayRefObj_Convert(PyObject
*, CFArrayRef
*);
45 #define CFArrayRefObj_New _CFArrayRefObj_New
46 #define CFArrayRefObj_Convert _CFArrayRefObj_Convert
48 extern PyObject
*_CFMutableArrayRefObj_New(CFMutableArrayRef
);
49 extern int _CFMutableArrayRefObj_Convert(PyObject
*, CFMutableArrayRef
*);
50 #define CFMutableArrayRefObj_New _CFMutableArrayRefObj_New
51 #define CFMutableArrayRefObj_Convert _CFMutableArrayRefObj_Convert
53 extern PyObject
*_CFDataRefObj_New(CFDataRef
);
54 extern int _CFDataRefObj_Convert(PyObject
*, CFDataRef
*);
55 #define CFDataRefObj_New _CFDataRefObj_New
56 #define CFDataRefObj_Convert _CFDataRefObj_Convert
58 extern PyObject
*_CFMutableDataRefObj_New(CFMutableDataRef
);
59 extern int _CFMutableDataRefObj_Convert(PyObject
*, CFMutableDataRef
*);
60 #define CFMutableDataRefObj_New _CFMutableDataRefObj_New
61 #define CFMutableDataRefObj_Convert _CFMutableDataRefObj_Convert
63 extern PyObject
*_CFDictionaryRefObj_New(CFDictionaryRef
);
64 extern int _CFDictionaryRefObj_Convert(PyObject
*, CFDictionaryRef
*);
65 #define CFDictionaryRefObj_New _CFDictionaryRefObj_New
66 #define CFDictionaryRefObj_Convert _CFDictionaryRefObj_Convert
68 extern PyObject
*_CFMutableDictionaryRefObj_New(CFMutableDictionaryRef
);
69 extern int _CFMutableDictionaryRefObj_Convert(PyObject
*, CFMutableDictionaryRef
*);
70 #define CFMutableDictionaryRefObj_New _CFMutableDictionaryRefObj_New
71 #define CFMutableDictionaryRefObj_Convert _CFMutableDictionaryRefObj_Convert
73 extern PyObject
*_CFURLRefObj_New(CFURLRef
);
74 extern int _CFURLRefObj_Convert(PyObject
*, CFURLRef
*);
75 extern int _OptionalCFURLRefObj_Convert(PyObject
*, CFURLRef
*);
76 #define CFURLRefObj_New _CFURLRefObj_New
77 #define CFURLRefObj_Convert _CFURLRefObj_Convert
78 #define OptionalCFURLRefObj_Convert _OptionalCFURLRefObj_Convert
82 ** Parse/generate CFRange records
84 PyObject
*CFRange_New(CFRange
*itself
)
87 return Py_BuildValue("ll", (long)itself
->location
, (long)itself
->length
);
91 CFRange_Convert(PyObject
*v
, CFRange
*p_itself
)
93 long location
, length
;
95 if( !PyArg_ParseTuple(v
, "ll", &location
, &length
) )
97 p_itself
->location
= (CFIndex
)location
;
98 p_itself
->length
= (CFIndex
)length
;
102 /* Optional CFURL argument or None (passed as NULL) */
104 OptionalCFURLRefObj_Convert(PyObject
*v
, CFURLRef
*p_itself
)
106 if ( v
== Py_None
) {
110 return CFURLRefObj_Convert(v
, p_itself
);
113 static PyObject
*CF_Error
;
115 /* --------------------- Object type CFTypeRef ---------------------- */
117 PyTypeObject CFTypeRef_Type
;
119 #define CFTypeRefObj_Check(x) ((x)->ob_type == &CFTypeRef_Type || PyObject_TypeCheck((x), &CFTypeRef_Type))
121 typedef struct CFTypeRefObject
{
124 void (*ob_freeit
)(CFTypeRef ptr
);
127 PyObject
*CFTypeRefObj_New(CFTypeRef itself
)
132 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
135 it
= PyObject_NEW(CFTypeRefObject
, &CFTypeRef_Type
);
136 if (it
== NULL
) return NULL
;
137 it
->ob_itself
= itself
;
138 it
->ob_freeit
= CFRelease
;
139 return (PyObject
*)it
;
142 int CFTypeRefObj_Convert(PyObject
*v
, CFTypeRef
*p_itself
)
145 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
146 /* Check for other CF objects here */
148 if (!CFTypeRefObj_Check(v
))
150 PyErr_SetString(PyExc_TypeError
, "CFTypeRef required");
153 *p_itself
= ((CFTypeRefObject
*)v
)->ob_itself
;
157 static void CFTypeRefObj_dealloc(CFTypeRefObject
*self
)
159 if (self
->ob_freeit
&& self
->ob_itself
)
161 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
162 self
->ob_itself
= NULL
;
164 self
->ob_type
->tp_free((PyObject
*)self
);
167 static PyObject
*CFTypeRefObj_CFGetTypeID(CFTypeRefObject
*_self
, PyObject
*_args
)
169 PyObject
*_res
= NULL
;
172 PyMac_PRECHECK(CFGetTypeID
);
174 if (!PyArg_ParseTuple(_args
, ""))
176 _rv
= CFGetTypeID(_self
->ob_itself
);
177 _res
= Py_BuildValue("l",
182 static PyObject
*CFTypeRefObj_CFRetain(CFTypeRefObject
*_self
, PyObject
*_args
)
184 PyObject
*_res
= NULL
;
187 PyMac_PRECHECK(CFRetain
);
189 if (!PyArg_ParseTuple(_args
, ""))
191 _rv
= CFRetain(_self
->ob_itself
);
192 _res
= Py_BuildValue("O&",
193 CFTypeRefObj_New
, _rv
);
197 static PyObject
*CFTypeRefObj_CFRelease(CFTypeRefObject
*_self
, PyObject
*_args
)
199 PyObject
*_res
= NULL
;
201 PyMac_PRECHECK(CFRelease
);
203 if (!PyArg_ParseTuple(_args
, ""))
205 CFRelease(_self
->ob_itself
);
211 static PyObject
*CFTypeRefObj_CFGetRetainCount(CFTypeRefObject
*_self
, PyObject
*_args
)
213 PyObject
*_res
= NULL
;
215 #ifndef CFGetRetainCount
216 PyMac_PRECHECK(CFGetRetainCount
);
218 if (!PyArg_ParseTuple(_args
, ""))
220 _rv
= CFGetRetainCount(_self
->ob_itself
);
221 _res
= Py_BuildValue("l",
226 static PyObject
*CFTypeRefObj_CFEqual(CFTypeRefObject
*_self
, PyObject
*_args
)
228 PyObject
*_res
= NULL
;
232 PyMac_PRECHECK(CFEqual
);
234 if (!PyArg_ParseTuple(_args
, "O&",
235 CFTypeRefObj_Convert
, &cf2
))
237 _rv
= CFEqual(_self
->ob_itself
,
239 _res
= Py_BuildValue("l",
244 static PyObject
*CFTypeRefObj_CFHash(CFTypeRefObject
*_self
, PyObject
*_args
)
246 PyObject
*_res
= NULL
;
249 PyMac_PRECHECK(CFHash
);
251 if (!PyArg_ParseTuple(_args
, ""))
253 _rv
= CFHash(_self
->ob_itself
);
254 _res
= Py_BuildValue("l",
259 static PyObject
*CFTypeRefObj_CFCopyDescription(CFTypeRefObject
*_self
, PyObject
*_args
)
261 PyObject
*_res
= NULL
;
263 #ifndef CFCopyDescription
264 PyMac_PRECHECK(CFCopyDescription
);
266 if (!PyArg_ParseTuple(_args
, ""))
268 _rv
= CFCopyDescription(_self
->ob_itself
);
269 _res
= Py_BuildValue("O&",
270 CFStringRefObj_New
, _rv
);
274 static PyObject
*CFTypeRefObj_CFPropertyListCreateXMLData(CFTypeRefObject
*_self
, PyObject
*_args
)
276 PyObject
*_res
= NULL
;
278 if (!PyArg_ParseTuple(_args
, ""))
280 _rv
= CFPropertyListCreateXMLData((CFAllocatorRef
)NULL
,
282 _res
= Py_BuildValue("O&",
283 CFDataRefObj_New
, _rv
);
287 static PyObject
*CFTypeRefObj_CFPropertyListCreateDeepCopy(CFTypeRefObject
*_self
, PyObject
*_args
)
289 PyObject
*_res
= NULL
;
291 CFOptionFlags mutabilityOption
;
292 if (!PyArg_ParseTuple(_args
, "l",
295 _rv
= CFPropertyListCreateDeepCopy((CFAllocatorRef
)NULL
,
298 _res
= Py_BuildValue("O&",
299 CFTypeRefObj_New
, _rv
);
303 static PyObject
*CFTypeRefObj_CFShow(CFTypeRefObject
*_self
, PyObject
*_args
)
305 PyObject
*_res
= NULL
;
307 PyMac_PRECHECK(CFShow
);
309 if (!PyArg_ParseTuple(_args
, ""))
311 CFShow(_self
->ob_itself
);
317 static PyObject
*CFTypeRefObj_CFPropertyListCreateFromXMLData(CFTypeRefObject
*_self
, PyObject
*_args
)
319 PyObject
*_res
= NULL
;
322 CFOptionFlags mutabilityOption
;
323 CFStringRef errorString
;
324 if (!PyArg_ParseTuple(_args
, "l",
327 _rv
= CFPropertyListCreateFromXMLData((CFAllocatorRef
)NULL
,
332 CFRelease(errorString
);
334 PyErr_SetString(PyExc_RuntimeError
, "Parse error in XML data");
337 _res
= Py_BuildValue("O&",
338 CFTypeRefObj_New
, _rv
);
343 static PyObject
*CFTypeRefObj_toPython(CFTypeRefObject
*_self
, PyObject
*_args
)
345 PyObject
*_res
= NULL
;
347 _res
= PyCF_CF2Python(_self
->ob_itself
);
352 static PyMethodDef CFTypeRefObj_methods
[] = {
353 {"CFGetTypeID", (PyCFunction
)CFTypeRefObj_CFGetTypeID
, 1,
354 PyDoc_STR("() -> (CFTypeID _rv)")},
355 {"CFRetain", (PyCFunction
)CFTypeRefObj_CFRetain
, 1,
356 PyDoc_STR("() -> (CFTypeRef _rv)")},
357 {"CFRelease", (PyCFunction
)CFTypeRefObj_CFRelease
, 1,
358 PyDoc_STR("() -> None")},
359 {"CFGetRetainCount", (PyCFunction
)CFTypeRefObj_CFGetRetainCount
, 1,
360 PyDoc_STR("() -> (CFIndex _rv)")},
361 {"CFEqual", (PyCFunction
)CFTypeRefObj_CFEqual
, 1,
362 PyDoc_STR("(CFTypeRef cf2) -> (Boolean _rv)")},
363 {"CFHash", (PyCFunction
)CFTypeRefObj_CFHash
, 1,
364 PyDoc_STR("() -> (CFHashCode _rv)")},
365 {"CFCopyDescription", (PyCFunction
)CFTypeRefObj_CFCopyDescription
, 1,
366 PyDoc_STR("() -> (CFStringRef _rv)")},
367 {"CFPropertyListCreateXMLData", (PyCFunction
)CFTypeRefObj_CFPropertyListCreateXMLData
, 1,
368 PyDoc_STR("() -> (CFDataRef _rv)")},
369 {"CFPropertyListCreateDeepCopy", (PyCFunction
)CFTypeRefObj_CFPropertyListCreateDeepCopy
, 1,
370 PyDoc_STR("(CFOptionFlags mutabilityOption) -> (CFTypeRef _rv)")},
371 {"CFShow", (PyCFunction
)CFTypeRefObj_CFShow
, 1,
372 PyDoc_STR("() -> None")},
373 {"CFPropertyListCreateFromXMLData", (PyCFunction
)CFTypeRefObj_CFPropertyListCreateFromXMLData
, 1,
374 PyDoc_STR("(CFOptionFlags mutabilityOption) -> (CFTypeRefObj)")},
375 {"toPython", (PyCFunction
)CFTypeRefObj_toPython
, 1,
376 PyDoc_STR("() -> (python_object)")},
380 #define CFTypeRefObj_getsetlist NULL
383 static int CFTypeRefObj_compare(CFTypeRefObject
*self
, CFTypeRefObject
*other
)
385 /* XXXX Or should we use CFEqual?? */
386 if ( self
->ob_itself
> other
->ob_itself
) return 1;
387 if ( self
->ob_itself
< other
->ob_itself
) return -1;
391 static PyObject
* CFTypeRefObj_repr(CFTypeRefObject
*self
)
394 sprintf(buf
, "<CFTypeRef type-%d object at 0x%8.8x for 0x%8.8x>", (int)CFGetTypeID(self
->ob_itself
), (unsigned)self
, (unsigned)self
->ob_itself
);
395 return PyString_FromString(buf
);
398 static int CFTypeRefObj_hash(CFTypeRefObject
*self
)
400 /* XXXX Or should we use CFHash?? */
401 return (int)self
->ob_itself
;
403 static int CFTypeRefObj_tp_init(PyObject
*_self
, PyObject
*_args
, PyObject
*_kwds
)
406 char *kw
[] = {"itself", 0};
408 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFTypeRefObj_Convert
, &itself
))
410 ((CFTypeRefObject
*)_self
)->ob_itself
= itself
;
416 #define CFTypeRefObj_tp_alloc PyType_GenericAlloc
418 static PyObject
*CFTypeRefObj_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
421 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
422 ((CFTypeRefObject
*)self
)->ob_itself
= NULL
;
423 ((CFTypeRefObject
*)self
)->ob_freeit
= CFRelease
;
427 #define CFTypeRefObj_tp_free PyObject_Del
430 PyTypeObject CFTypeRef_Type
= {
431 PyObject_HEAD_INIT(NULL
)
433 "_CF.CFTypeRef", /*tp_name*/
434 sizeof(CFTypeRefObject
), /*tp_basicsize*/
437 (destructor
) CFTypeRefObj_dealloc
, /*tp_dealloc*/
439 (getattrfunc
)0, /*tp_getattr*/
440 (setattrfunc
)0, /*tp_setattr*/
441 (cmpfunc
) CFTypeRefObj_compare
, /*tp_compare*/
442 (reprfunc
) CFTypeRefObj_repr
, /*tp_repr*/
443 (PyNumberMethods
*)0, /* tp_as_number */
444 (PySequenceMethods
*)0, /* tp_as_sequence */
445 (PyMappingMethods
*)0, /* tp_as_mapping */
446 (hashfunc
) CFTypeRefObj_hash
, /*tp_hash*/
449 PyObject_GenericGetAttr
, /*tp_getattro*/
450 PyObject_GenericSetAttr
, /*tp_setattro */
452 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
456 0, /*tp_richcompare*/
457 0, /*tp_weaklistoffset*/
460 CFTypeRefObj_methods
, /* tp_methods */
462 CFTypeRefObj_getsetlist
, /*tp_getset*/
468 CFTypeRefObj_tp_init
, /* tp_init */
469 CFTypeRefObj_tp_alloc
, /* tp_alloc */
470 CFTypeRefObj_tp_new
, /* tp_new */
471 CFTypeRefObj_tp_free
, /* tp_free */
474 /* ------------------- End object type CFTypeRef -------------------- */
477 /* --------------------- Object type CFArrayRef --------------------- */
479 PyTypeObject CFArrayRef_Type
;
481 #define CFArrayRefObj_Check(x) ((x)->ob_type == &CFArrayRef_Type || PyObject_TypeCheck((x), &CFArrayRef_Type))
483 typedef struct CFArrayRefObject
{
485 CFArrayRef ob_itself
;
486 void (*ob_freeit
)(CFTypeRef ptr
);
489 PyObject
*CFArrayRefObj_New(CFArrayRef itself
)
491 CFArrayRefObject
*it
;
494 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
497 it
= PyObject_NEW(CFArrayRefObject
, &CFArrayRef_Type
);
498 if (it
== NULL
) return NULL
;
499 /* XXXX Should we tp_init or tp_new our basetype? */
500 it
->ob_itself
= itself
;
501 it
->ob_freeit
= CFRelease
;
502 return (PyObject
*)it
;
505 int CFArrayRefObj_Convert(PyObject
*v
, CFArrayRef
*p_itself
)
508 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
509 /* Check for other CF objects here */
511 if (!CFArrayRefObj_Check(v
))
513 PyErr_SetString(PyExc_TypeError
, "CFArrayRef required");
516 *p_itself
= ((CFArrayRefObject
*)v
)->ob_itself
;
520 static void CFArrayRefObj_dealloc(CFArrayRefObject
*self
)
522 if (self
->ob_freeit
&& self
->ob_itself
)
524 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
525 self
->ob_itself
= NULL
;
527 CFTypeRef_Type
.tp_dealloc((PyObject
*)self
);
530 static PyObject
*CFArrayRefObj_CFArrayCreateCopy(CFArrayRefObject
*_self
, PyObject
*_args
)
532 PyObject
*_res
= NULL
;
534 if (!PyArg_ParseTuple(_args
, ""))
536 _rv
= CFArrayCreateCopy((CFAllocatorRef
)NULL
,
538 _res
= Py_BuildValue("O&",
539 CFArrayRefObj_New
, _rv
);
543 static PyObject
*CFArrayRefObj_CFArrayGetCount(CFArrayRefObject
*_self
, PyObject
*_args
)
545 PyObject
*_res
= NULL
;
547 #ifndef CFArrayGetCount
548 PyMac_PRECHECK(CFArrayGetCount
);
550 if (!PyArg_ParseTuple(_args
, ""))
552 _rv
= CFArrayGetCount(_self
->ob_itself
);
553 _res
= Py_BuildValue("l",
558 static PyObject
*CFArrayRefObj_CFStringCreateByCombiningStrings(CFArrayRefObject
*_self
, PyObject
*_args
)
560 PyObject
*_res
= NULL
;
562 CFStringRef separatorString
;
563 if (!PyArg_ParseTuple(_args
, "O&",
564 CFStringRefObj_Convert
, &separatorString
))
566 _rv
= CFStringCreateByCombiningStrings((CFAllocatorRef
)NULL
,
569 _res
= Py_BuildValue("O&",
570 CFStringRefObj_New
, _rv
);
574 static PyMethodDef CFArrayRefObj_methods
[] = {
575 {"CFArrayCreateCopy", (PyCFunction
)CFArrayRefObj_CFArrayCreateCopy
, 1,
576 PyDoc_STR("() -> (CFArrayRef _rv)")},
577 {"CFArrayGetCount", (PyCFunction
)CFArrayRefObj_CFArrayGetCount
, 1,
578 PyDoc_STR("() -> (CFIndex _rv)")},
579 {"CFStringCreateByCombiningStrings", (PyCFunction
)CFArrayRefObj_CFStringCreateByCombiningStrings
, 1,
580 PyDoc_STR("(CFStringRef separatorString) -> (CFStringRef _rv)")},
584 #define CFArrayRefObj_getsetlist NULL
587 static int CFArrayRefObj_compare(CFArrayRefObject
*self
, CFArrayRefObject
*other
)
589 /* XXXX Or should we use CFEqual?? */
590 if ( self
->ob_itself
> other
->ob_itself
) return 1;
591 if ( self
->ob_itself
< other
->ob_itself
) return -1;
595 static PyObject
* CFArrayRefObj_repr(CFArrayRefObject
*self
)
598 sprintf(buf
, "<CFArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
599 return PyString_FromString(buf
);
602 static int CFArrayRefObj_hash(CFArrayRefObject
*self
)
604 /* XXXX Or should we use CFHash?? */
605 return (int)self
->ob_itself
;
607 static int CFArrayRefObj_tp_init(PyObject
*_self
, PyObject
*_args
, PyObject
*_kwds
)
610 char *kw
[] = {"itself", 0};
612 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFArrayRefObj_Convert
, &itself
))
614 ((CFArrayRefObject
*)_self
)->ob_itself
= itself
;
618 /* Any CFTypeRef descendent is allowed as initializer too */
619 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFTypeRefObj_Convert
, &itself
))
621 ((CFArrayRefObject
*)_self
)->ob_itself
= itself
;
627 #define CFArrayRefObj_tp_alloc PyType_GenericAlloc
629 static PyObject
*CFArrayRefObj_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
632 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
633 ((CFArrayRefObject
*)self
)->ob_itself
= NULL
;
634 ((CFArrayRefObject
*)self
)->ob_freeit
= CFRelease
;
638 #define CFArrayRefObj_tp_free PyObject_Del
641 PyTypeObject CFArrayRef_Type
= {
642 PyObject_HEAD_INIT(NULL
)
644 "_CF.CFArrayRef", /*tp_name*/
645 sizeof(CFArrayRefObject
), /*tp_basicsize*/
648 (destructor
) CFArrayRefObj_dealloc
, /*tp_dealloc*/
650 (getattrfunc
)0, /*tp_getattr*/
651 (setattrfunc
)0, /*tp_setattr*/
652 (cmpfunc
) CFArrayRefObj_compare
, /*tp_compare*/
653 (reprfunc
) CFArrayRefObj_repr
, /*tp_repr*/
654 (PyNumberMethods
*)0, /* tp_as_number */
655 (PySequenceMethods
*)0, /* tp_as_sequence */
656 (PyMappingMethods
*)0, /* tp_as_mapping */
657 (hashfunc
) CFArrayRefObj_hash
, /*tp_hash*/
660 PyObject_GenericGetAttr
, /*tp_getattro*/
661 PyObject_GenericSetAttr
, /*tp_setattro */
663 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
667 0, /*tp_richcompare*/
668 0, /*tp_weaklistoffset*/
671 CFArrayRefObj_methods
, /* tp_methods */
673 CFArrayRefObj_getsetlist
, /*tp_getset*/
679 CFArrayRefObj_tp_init
, /* tp_init */
680 CFArrayRefObj_tp_alloc
, /* tp_alloc */
681 CFArrayRefObj_tp_new
, /* tp_new */
682 CFArrayRefObj_tp_free
, /* tp_free */
685 /* ------------------- End object type CFArrayRef ------------------- */
688 /* ----------------- Object type CFMutableArrayRef ------------------ */
690 PyTypeObject CFMutableArrayRef_Type
;
692 #define CFMutableArrayRefObj_Check(x) ((x)->ob_type == &CFMutableArrayRef_Type || PyObject_TypeCheck((x), &CFMutableArrayRef_Type))
694 typedef struct CFMutableArrayRefObject
{
696 CFMutableArrayRef ob_itself
;
697 void (*ob_freeit
)(CFTypeRef ptr
);
698 } CFMutableArrayRefObject
;
700 PyObject
*CFMutableArrayRefObj_New(CFMutableArrayRef itself
)
702 CFMutableArrayRefObject
*it
;
705 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
708 it
= PyObject_NEW(CFMutableArrayRefObject
, &CFMutableArrayRef_Type
);
709 if (it
== NULL
) return NULL
;
710 /* XXXX Should we tp_init or tp_new our basetype? */
711 it
->ob_itself
= itself
;
712 it
->ob_freeit
= CFRelease
;
713 return (PyObject
*)it
;
716 int CFMutableArrayRefObj_Convert(PyObject
*v
, CFMutableArrayRef
*p_itself
)
719 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
720 /* Check for other CF objects here */
722 if (!CFMutableArrayRefObj_Check(v
))
724 PyErr_SetString(PyExc_TypeError
, "CFMutableArrayRef required");
727 *p_itself
= ((CFMutableArrayRefObject
*)v
)->ob_itself
;
731 static void CFMutableArrayRefObj_dealloc(CFMutableArrayRefObject
*self
)
733 if (self
->ob_freeit
&& self
->ob_itself
)
735 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
736 self
->ob_itself
= NULL
;
738 CFArrayRef_Type
.tp_dealloc((PyObject
*)self
);
741 static PyObject
*CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
743 PyObject
*_res
= NULL
;
745 #ifndef CFArrayRemoveValueAtIndex
746 PyMac_PRECHECK(CFArrayRemoveValueAtIndex
);
748 if (!PyArg_ParseTuple(_args
, "l",
751 CFArrayRemoveValueAtIndex(_self
->ob_itself
,
758 static PyObject
*CFMutableArrayRefObj_CFArrayRemoveAllValues(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
760 PyObject
*_res
= NULL
;
761 #ifndef CFArrayRemoveAllValues
762 PyMac_PRECHECK(CFArrayRemoveAllValues
);
764 if (!PyArg_ParseTuple(_args
, ""))
766 CFArrayRemoveAllValues(_self
->ob_itself
);
772 static PyObject
*CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
774 PyObject
*_res
= NULL
;
777 #ifndef CFArrayExchangeValuesAtIndices
778 PyMac_PRECHECK(CFArrayExchangeValuesAtIndices
);
780 if (!PyArg_ParseTuple(_args
, "ll",
784 CFArrayExchangeValuesAtIndices(_self
->ob_itself
,
792 static PyObject
*CFMutableArrayRefObj_CFArrayAppendArray(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
794 PyObject
*_res
= NULL
;
795 CFArrayRef otherArray
;
797 #ifndef CFArrayAppendArray
798 PyMac_PRECHECK(CFArrayAppendArray
);
800 if (!PyArg_ParseTuple(_args
, "O&O&",
801 CFArrayRefObj_Convert
, &otherArray
,
802 CFRange_Convert
, &otherRange
))
804 CFArrayAppendArray(_self
->ob_itself
,
812 static PyMethodDef CFMutableArrayRefObj_methods
[] = {
813 {"CFArrayRemoveValueAtIndex", (PyCFunction
)CFMutableArrayRefObj_CFArrayRemoveValueAtIndex
, 1,
814 PyDoc_STR("(CFIndex idx) -> None")},
815 {"CFArrayRemoveAllValues", (PyCFunction
)CFMutableArrayRefObj_CFArrayRemoveAllValues
, 1,
816 PyDoc_STR("() -> None")},
817 {"CFArrayExchangeValuesAtIndices", (PyCFunction
)CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices
, 1,
818 PyDoc_STR("(CFIndex idx1, CFIndex idx2) -> None")},
819 {"CFArrayAppendArray", (PyCFunction
)CFMutableArrayRefObj_CFArrayAppendArray
, 1,
820 PyDoc_STR("(CFArrayRef otherArray, CFRange otherRange) -> None")},
824 #define CFMutableArrayRefObj_getsetlist NULL
827 static int CFMutableArrayRefObj_compare(CFMutableArrayRefObject
*self
, CFMutableArrayRefObject
*other
)
829 /* XXXX Or should we use CFEqual?? */
830 if ( self
->ob_itself
> other
->ob_itself
) return 1;
831 if ( self
->ob_itself
< other
->ob_itself
) return -1;
835 static PyObject
* CFMutableArrayRefObj_repr(CFMutableArrayRefObject
*self
)
838 sprintf(buf
, "<CFMutableArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
839 return PyString_FromString(buf
);
842 static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject
*self
)
844 /* XXXX Or should we use CFHash?? */
845 return (int)self
->ob_itself
;
847 static int CFMutableArrayRefObj_tp_init(PyObject
*_self
, PyObject
*_args
, PyObject
*_kwds
)
849 CFMutableArrayRef itself
;
850 char *kw
[] = {"itself", 0};
852 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFMutableArrayRefObj_Convert
, &itself
))
854 ((CFMutableArrayRefObject
*)_self
)->ob_itself
= itself
;
858 /* Any CFTypeRef descendent is allowed as initializer too */
859 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFTypeRefObj_Convert
, &itself
))
861 ((CFMutableArrayRefObject
*)_self
)->ob_itself
= itself
;
867 #define CFMutableArrayRefObj_tp_alloc PyType_GenericAlloc
869 static PyObject
*CFMutableArrayRefObj_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
872 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
873 ((CFMutableArrayRefObject
*)self
)->ob_itself
= NULL
;
874 ((CFMutableArrayRefObject
*)self
)->ob_freeit
= CFRelease
;
878 #define CFMutableArrayRefObj_tp_free PyObject_Del
881 PyTypeObject CFMutableArrayRef_Type
= {
882 PyObject_HEAD_INIT(NULL
)
884 "_CF.CFMutableArrayRef", /*tp_name*/
885 sizeof(CFMutableArrayRefObject
), /*tp_basicsize*/
888 (destructor
) CFMutableArrayRefObj_dealloc
, /*tp_dealloc*/
890 (getattrfunc
)0, /*tp_getattr*/
891 (setattrfunc
)0, /*tp_setattr*/
892 (cmpfunc
) CFMutableArrayRefObj_compare
, /*tp_compare*/
893 (reprfunc
) CFMutableArrayRefObj_repr
, /*tp_repr*/
894 (PyNumberMethods
*)0, /* tp_as_number */
895 (PySequenceMethods
*)0, /* tp_as_sequence */
896 (PyMappingMethods
*)0, /* tp_as_mapping */
897 (hashfunc
) CFMutableArrayRefObj_hash
, /*tp_hash*/
900 PyObject_GenericGetAttr
, /*tp_getattro*/
901 PyObject_GenericSetAttr
, /*tp_setattro */
903 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
907 0, /*tp_richcompare*/
908 0, /*tp_weaklistoffset*/
911 CFMutableArrayRefObj_methods
, /* tp_methods */
913 CFMutableArrayRefObj_getsetlist
, /*tp_getset*/
919 CFMutableArrayRefObj_tp_init
, /* tp_init */
920 CFMutableArrayRefObj_tp_alloc
, /* tp_alloc */
921 CFMutableArrayRefObj_tp_new
, /* tp_new */
922 CFMutableArrayRefObj_tp_free
, /* tp_free */
925 /* --------------- End object type CFMutableArrayRef ---------------- */
928 /* ------------------ Object type CFDictionaryRef ------------------- */
930 PyTypeObject CFDictionaryRef_Type
;
932 #define CFDictionaryRefObj_Check(x) ((x)->ob_type == &CFDictionaryRef_Type || PyObject_TypeCheck((x), &CFDictionaryRef_Type))
934 typedef struct CFDictionaryRefObject
{
936 CFDictionaryRef ob_itself
;
937 void (*ob_freeit
)(CFTypeRef ptr
);
938 } CFDictionaryRefObject
;
940 PyObject
*CFDictionaryRefObj_New(CFDictionaryRef itself
)
942 CFDictionaryRefObject
*it
;
945 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
948 it
= PyObject_NEW(CFDictionaryRefObject
, &CFDictionaryRef_Type
);
949 if (it
== NULL
) return NULL
;
950 /* XXXX Should we tp_init or tp_new our basetype? */
951 it
->ob_itself
= itself
;
952 it
->ob_freeit
= CFRelease
;
953 return (PyObject
*)it
;
956 int CFDictionaryRefObj_Convert(PyObject
*v
, CFDictionaryRef
*p_itself
)
959 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
960 /* Check for other CF objects here */
962 if (!CFDictionaryRefObj_Check(v
))
964 PyErr_SetString(PyExc_TypeError
, "CFDictionaryRef required");
967 *p_itself
= ((CFDictionaryRefObject
*)v
)->ob_itself
;
971 static void CFDictionaryRefObj_dealloc(CFDictionaryRefObject
*self
)
973 if (self
->ob_freeit
&& self
->ob_itself
)
975 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
976 self
->ob_itself
= NULL
;
978 CFTypeRef_Type
.tp_dealloc((PyObject
*)self
);
981 static PyObject
*CFDictionaryRefObj_CFDictionaryCreateCopy(CFDictionaryRefObject
*_self
, PyObject
*_args
)
983 PyObject
*_res
= NULL
;
985 if (!PyArg_ParseTuple(_args
, ""))
987 _rv
= CFDictionaryCreateCopy((CFAllocatorRef
)NULL
,
989 _res
= Py_BuildValue("O&",
990 CFDictionaryRefObj_New
, _rv
);
994 static PyObject
*CFDictionaryRefObj_CFDictionaryGetCount(CFDictionaryRefObject
*_self
, PyObject
*_args
)
996 PyObject
*_res
= NULL
;
998 #ifndef CFDictionaryGetCount
999 PyMac_PRECHECK(CFDictionaryGetCount
);
1001 if (!PyArg_ParseTuple(_args
, ""))
1003 _rv
= CFDictionaryGetCount(_self
->ob_itself
);
1004 _res
= Py_BuildValue("l",
1009 static PyMethodDef CFDictionaryRefObj_methods
[] = {
1010 {"CFDictionaryCreateCopy", (PyCFunction
)CFDictionaryRefObj_CFDictionaryCreateCopy
, 1,
1011 PyDoc_STR("() -> (CFDictionaryRef _rv)")},
1012 {"CFDictionaryGetCount", (PyCFunction
)CFDictionaryRefObj_CFDictionaryGetCount
, 1,
1013 PyDoc_STR("() -> (CFIndex _rv)")},
1017 #define CFDictionaryRefObj_getsetlist NULL
1020 static int CFDictionaryRefObj_compare(CFDictionaryRefObject
*self
, CFDictionaryRefObject
*other
)
1022 /* XXXX Or should we use CFEqual?? */
1023 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1024 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1028 static PyObject
* CFDictionaryRefObj_repr(CFDictionaryRefObject
*self
)
1031 sprintf(buf
, "<CFDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
1032 return PyString_FromString(buf
);
1035 static int CFDictionaryRefObj_hash(CFDictionaryRefObject
*self
)
1037 /* XXXX Or should we use CFHash?? */
1038 return (int)self
->ob_itself
;
1040 static int CFDictionaryRefObj_tp_init(PyObject
*_self
, PyObject
*_args
, PyObject
*_kwds
)
1042 CFDictionaryRef itself
;
1043 char *kw
[] = {"itself", 0};
1045 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFDictionaryRefObj_Convert
, &itself
))
1047 ((CFDictionaryRefObject
*)_self
)->ob_itself
= itself
;
1051 /* Any CFTypeRef descendent is allowed as initializer too */
1052 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFTypeRefObj_Convert
, &itself
))
1054 ((CFDictionaryRefObject
*)_self
)->ob_itself
= itself
;
1060 #define CFDictionaryRefObj_tp_alloc PyType_GenericAlloc
1062 static PyObject
*CFDictionaryRefObj_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
1065 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
1066 ((CFDictionaryRefObject
*)self
)->ob_itself
= NULL
;
1067 ((CFDictionaryRefObject
*)self
)->ob_freeit
= CFRelease
;
1071 #define CFDictionaryRefObj_tp_free PyObject_Del
1074 PyTypeObject CFDictionaryRef_Type
= {
1075 PyObject_HEAD_INIT(NULL
)
1077 "_CF.CFDictionaryRef", /*tp_name*/
1078 sizeof(CFDictionaryRefObject
), /*tp_basicsize*/
1081 (destructor
) CFDictionaryRefObj_dealloc
, /*tp_dealloc*/
1083 (getattrfunc
)0, /*tp_getattr*/
1084 (setattrfunc
)0, /*tp_setattr*/
1085 (cmpfunc
) CFDictionaryRefObj_compare
, /*tp_compare*/
1086 (reprfunc
) CFDictionaryRefObj_repr
, /*tp_repr*/
1087 (PyNumberMethods
*)0, /* tp_as_number */
1088 (PySequenceMethods
*)0, /* tp_as_sequence */
1089 (PyMappingMethods
*)0, /* tp_as_mapping */
1090 (hashfunc
) CFDictionaryRefObj_hash
, /*tp_hash*/
1093 PyObject_GenericGetAttr
, /*tp_getattro*/
1094 PyObject_GenericSetAttr
, /*tp_setattro */
1096 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1100 0, /*tp_richcompare*/
1101 0, /*tp_weaklistoffset*/
1104 CFDictionaryRefObj_methods
, /* tp_methods */
1106 CFDictionaryRefObj_getsetlist
, /*tp_getset*/
1111 0, /*tp_dictoffset*/
1112 CFDictionaryRefObj_tp_init
, /* tp_init */
1113 CFDictionaryRefObj_tp_alloc
, /* tp_alloc */
1114 CFDictionaryRefObj_tp_new
, /* tp_new */
1115 CFDictionaryRefObj_tp_free
, /* tp_free */
1118 /* ---------------- End object type CFDictionaryRef ----------------- */
1121 /* --------------- Object type CFMutableDictionaryRef --------------- */
1123 PyTypeObject CFMutableDictionaryRef_Type
;
1125 #define CFMutableDictionaryRefObj_Check(x) ((x)->ob_type == &CFMutableDictionaryRef_Type || PyObject_TypeCheck((x), &CFMutableDictionaryRef_Type))
1127 typedef struct CFMutableDictionaryRefObject
{
1129 CFMutableDictionaryRef ob_itself
;
1130 void (*ob_freeit
)(CFTypeRef ptr
);
1131 } CFMutableDictionaryRefObject
;
1133 PyObject
*CFMutableDictionaryRefObj_New(CFMutableDictionaryRef itself
)
1135 CFMutableDictionaryRefObject
*it
;
1138 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
1141 it
= PyObject_NEW(CFMutableDictionaryRefObject
, &CFMutableDictionaryRef_Type
);
1142 if (it
== NULL
) return NULL
;
1143 /* XXXX Should we tp_init or tp_new our basetype? */
1144 it
->ob_itself
= itself
;
1145 it
->ob_freeit
= CFRelease
;
1146 return (PyObject
*)it
;
1149 int CFMutableDictionaryRefObj_Convert(PyObject
*v
, CFMutableDictionaryRef
*p_itself
)
1152 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1153 /* Check for other CF objects here */
1155 if (!CFMutableDictionaryRefObj_Check(v
))
1157 PyErr_SetString(PyExc_TypeError
, "CFMutableDictionaryRef required");
1160 *p_itself
= ((CFMutableDictionaryRefObject
*)v
)->ob_itself
;
1164 static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject
*self
)
1166 if (self
->ob_freeit
&& self
->ob_itself
)
1168 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1169 self
->ob_itself
= NULL
;
1171 CFDictionaryRef_Type
.tp_dealloc((PyObject
*)self
);
1174 static PyObject
*CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject
*_self
, PyObject
*_args
)
1176 PyObject
*_res
= NULL
;
1177 #ifndef CFDictionaryRemoveAllValues
1178 PyMac_PRECHECK(CFDictionaryRemoveAllValues
);
1180 if (!PyArg_ParseTuple(_args
, ""))
1182 CFDictionaryRemoveAllValues(_self
->ob_itself
);
1188 static PyMethodDef CFMutableDictionaryRefObj_methods
[] = {
1189 {"CFDictionaryRemoveAllValues", (PyCFunction
)CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues
, 1,
1190 PyDoc_STR("() -> None")},
1194 #define CFMutableDictionaryRefObj_getsetlist NULL
1197 static int CFMutableDictionaryRefObj_compare(CFMutableDictionaryRefObject
*self
, CFMutableDictionaryRefObject
*other
)
1199 /* XXXX Or should we use CFEqual?? */
1200 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1201 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1205 static PyObject
* CFMutableDictionaryRefObj_repr(CFMutableDictionaryRefObject
*self
)
1208 sprintf(buf
, "<CFMutableDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
1209 return PyString_FromString(buf
);
1212 static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject
*self
)
1214 /* XXXX Or should we use CFHash?? */
1215 return (int)self
->ob_itself
;
1217 static int CFMutableDictionaryRefObj_tp_init(PyObject
*_self
, PyObject
*_args
, PyObject
*_kwds
)
1219 CFMutableDictionaryRef itself
;
1220 char *kw
[] = {"itself", 0};
1222 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFMutableDictionaryRefObj_Convert
, &itself
))
1224 ((CFMutableDictionaryRefObject
*)_self
)->ob_itself
= itself
;
1228 /* Any CFTypeRef descendent is allowed as initializer too */
1229 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFTypeRefObj_Convert
, &itself
))
1231 ((CFMutableDictionaryRefObject
*)_self
)->ob_itself
= itself
;
1237 #define CFMutableDictionaryRefObj_tp_alloc PyType_GenericAlloc
1239 static PyObject
*CFMutableDictionaryRefObj_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
1242 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
1243 ((CFMutableDictionaryRefObject
*)self
)->ob_itself
= NULL
;
1244 ((CFMutableDictionaryRefObject
*)self
)->ob_freeit
= CFRelease
;
1248 #define CFMutableDictionaryRefObj_tp_free PyObject_Del
1251 PyTypeObject CFMutableDictionaryRef_Type
= {
1252 PyObject_HEAD_INIT(NULL
)
1254 "_CF.CFMutableDictionaryRef", /*tp_name*/
1255 sizeof(CFMutableDictionaryRefObject
), /*tp_basicsize*/
1258 (destructor
) CFMutableDictionaryRefObj_dealloc
, /*tp_dealloc*/
1260 (getattrfunc
)0, /*tp_getattr*/
1261 (setattrfunc
)0, /*tp_setattr*/
1262 (cmpfunc
) CFMutableDictionaryRefObj_compare
, /*tp_compare*/
1263 (reprfunc
) CFMutableDictionaryRefObj_repr
, /*tp_repr*/
1264 (PyNumberMethods
*)0, /* tp_as_number */
1265 (PySequenceMethods
*)0, /* tp_as_sequence */
1266 (PyMappingMethods
*)0, /* tp_as_mapping */
1267 (hashfunc
) CFMutableDictionaryRefObj_hash
, /*tp_hash*/
1270 PyObject_GenericGetAttr
, /*tp_getattro*/
1271 PyObject_GenericSetAttr
, /*tp_setattro */
1273 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1277 0, /*tp_richcompare*/
1278 0, /*tp_weaklistoffset*/
1281 CFMutableDictionaryRefObj_methods
, /* tp_methods */
1283 CFMutableDictionaryRefObj_getsetlist
, /*tp_getset*/
1288 0, /*tp_dictoffset*/
1289 CFMutableDictionaryRefObj_tp_init
, /* tp_init */
1290 CFMutableDictionaryRefObj_tp_alloc
, /* tp_alloc */
1291 CFMutableDictionaryRefObj_tp_new
, /* tp_new */
1292 CFMutableDictionaryRefObj_tp_free
, /* tp_free */
1295 /* ------------- End object type CFMutableDictionaryRef ------------- */
1298 /* --------------------- Object type CFDataRef ---------------------- */
1300 PyTypeObject CFDataRef_Type
;
1302 #define CFDataRefObj_Check(x) ((x)->ob_type == &CFDataRef_Type || PyObject_TypeCheck((x), &CFDataRef_Type))
1304 typedef struct CFDataRefObject
{
1306 CFDataRef ob_itself
;
1307 void (*ob_freeit
)(CFTypeRef ptr
);
1310 PyObject
*CFDataRefObj_New(CFDataRef itself
)
1312 CFDataRefObject
*it
;
1315 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
1318 it
= PyObject_NEW(CFDataRefObject
, &CFDataRef_Type
);
1319 if (it
== NULL
) return NULL
;
1320 /* XXXX Should we tp_init or tp_new our basetype? */
1321 it
->ob_itself
= itself
;
1322 it
->ob_freeit
= CFRelease
;
1323 return (PyObject
*)it
;
1326 int CFDataRefObj_Convert(PyObject
*v
, CFDataRef
*p_itself
)
1329 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1330 if (PyString_Check(v
)) {
1333 if( PyString_AsStringAndSize(v
, &cStr
, &cLen
) < 0 ) return 0;
1334 *p_itself
= CFDataCreate((CFAllocatorRef
)NULL
, (unsigned char *)cStr
, cLen
);
1338 if (!CFDataRefObj_Check(v
))
1340 PyErr_SetString(PyExc_TypeError
, "CFDataRef required");
1343 *p_itself
= ((CFDataRefObject
*)v
)->ob_itself
;
1347 static void CFDataRefObj_dealloc(CFDataRefObject
*self
)
1349 if (self
->ob_freeit
&& self
->ob_itself
)
1351 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1352 self
->ob_itself
= NULL
;
1354 CFTypeRef_Type
.tp_dealloc((PyObject
*)self
);
1357 static PyObject
*CFDataRefObj_CFDataCreateCopy(CFDataRefObject
*_self
, PyObject
*_args
)
1359 PyObject
*_res
= NULL
;
1361 if (!PyArg_ParseTuple(_args
, ""))
1363 _rv
= CFDataCreateCopy((CFAllocatorRef
)NULL
,
1365 _res
= Py_BuildValue("O&",
1366 CFDataRefObj_New
, _rv
);
1370 static PyObject
*CFDataRefObj_CFDataGetLength(CFDataRefObject
*_self
, PyObject
*_args
)
1372 PyObject
*_res
= NULL
;
1374 #ifndef CFDataGetLength
1375 PyMac_PRECHECK(CFDataGetLength
);
1377 if (!PyArg_ParseTuple(_args
, ""))
1379 _rv
= CFDataGetLength(_self
->ob_itself
);
1380 _res
= Py_BuildValue("l",
1385 static PyObject
*CFDataRefObj_CFStringCreateFromExternalRepresentation(CFDataRefObject
*_self
, PyObject
*_args
)
1387 PyObject
*_res
= NULL
;
1389 CFStringEncoding encoding
;
1390 if (!PyArg_ParseTuple(_args
, "l",
1393 _rv
= CFStringCreateFromExternalRepresentation((CFAllocatorRef
)NULL
,
1396 _res
= Py_BuildValue("O&",
1397 CFStringRefObj_New
, _rv
);
1401 static PyObject
*CFDataRefObj_CFDataGetData(CFDataRefObject
*_self
, PyObject
*_args
)
1403 PyObject
*_res
= NULL
;
1405 int size
= CFDataGetLength(_self
->ob_itself
);
1406 char *data
= (char *)CFDataGetBytePtr(_self
->ob_itself
);
1408 _res
= (PyObject
*)PyString_FromStringAndSize(data
, size
);
1413 static PyMethodDef CFDataRefObj_methods
[] = {
1414 {"CFDataCreateCopy", (PyCFunction
)CFDataRefObj_CFDataCreateCopy
, 1,
1415 PyDoc_STR("() -> (CFDataRef _rv)")},
1416 {"CFDataGetLength", (PyCFunction
)CFDataRefObj_CFDataGetLength
, 1,
1417 PyDoc_STR("() -> (CFIndex _rv)")},
1418 {"CFStringCreateFromExternalRepresentation", (PyCFunction
)CFDataRefObj_CFStringCreateFromExternalRepresentation
, 1,
1419 PyDoc_STR("(CFStringEncoding encoding) -> (CFStringRef _rv)")},
1420 {"CFDataGetData", (PyCFunction
)CFDataRefObj_CFDataGetData
, 1,
1421 PyDoc_STR("() -> (string _rv)")},
1425 #define CFDataRefObj_getsetlist NULL
1428 static int CFDataRefObj_compare(CFDataRefObject
*self
, CFDataRefObject
*other
)
1430 /* XXXX Or should we use CFEqual?? */
1431 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1432 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1436 static PyObject
* CFDataRefObj_repr(CFDataRefObject
*self
)
1439 sprintf(buf
, "<CFDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
1440 return PyString_FromString(buf
);
1443 static int CFDataRefObj_hash(CFDataRefObject
*self
)
1445 /* XXXX Or should we use CFHash?? */
1446 return (int)self
->ob_itself
;
1448 static int CFDataRefObj_tp_init(PyObject
*_self
, PyObject
*_args
, PyObject
*_kwds
)
1451 char *kw
[] = {"itself", 0};
1453 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFDataRefObj_Convert
, &itself
))
1455 ((CFDataRefObject
*)_self
)->ob_itself
= itself
;
1459 /* Any CFTypeRef descendent is allowed as initializer too */
1460 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFTypeRefObj_Convert
, &itself
))
1462 ((CFDataRefObject
*)_self
)->ob_itself
= itself
;
1468 #define CFDataRefObj_tp_alloc PyType_GenericAlloc
1470 static PyObject
*CFDataRefObj_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
1473 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
1474 ((CFDataRefObject
*)self
)->ob_itself
= NULL
;
1475 ((CFDataRefObject
*)self
)->ob_freeit
= CFRelease
;
1479 #define CFDataRefObj_tp_free PyObject_Del
1482 PyTypeObject CFDataRef_Type
= {
1483 PyObject_HEAD_INIT(NULL
)
1485 "_CF.CFDataRef", /*tp_name*/
1486 sizeof(CFDataRefObject
), /*tp_basicsize*/
1489 (destructor
) CFDataRefObj_dealloc
, /*tp_dealloc*/
1491 (getattrfunc
)0, /*tp_getattr*/
1492 (setattrfunc
)0, /*tp_setattr*/
1493 (cmpfunc
) CFDataRefObj_compare
, /*tp_compare*/
1494 (reprfunc
) CFDataRefObj_repr
, /*tp_repr*/
1495 (PyNumberMethods
*)0, /* tp_as_number */
1496 (PySequenceMethods
*)0, /* tp_as_sequence */
1497 (PyMappingMethods
*)0, /* tp_as_mapping */
1498 (hashfunc
) CFDataRefObj_hash
, /*tp_hash*/
1501 PyObject_GenericGetAttr
, /*tp_getattro*/
1502 PyObject_GenericSetAttr
, /*tp_setattro */
1504 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1508 0, /*tp_richcompare*/
1509 0, /*tp_weaklistoffset*/
1512 CFDataRefObj_methods
, /* tp_methods */
1514 CFDataRefObj_getsetlist
, /*tp_getset*/
1519 0, /*tp_dictoffset*/
1520 CFDataRefObj_tp_init
, /* tp_init */
1521 CFDataRefObj_tp_alloc
, /* tp_alloc */
1522 CFDataRefObj_tp_new
, /* tp_new */
1523 CFDataRefObj_tp_free
, /* tp_free */
1526 /* ------------------- End object type CFDataRef -------------------- */
1529 /* ------------------ Object type CFMutableDataRef ------------------ */
1531 PyTypeObject CFMutableDataRef_Type
;
1533 #define CFMutableDataRefObj_Check(x) ((x)->ob_type == &CFMutableDataRef_Type || PyObject_TypeCheck((x), &CFMutableDataRef_Type))
1535 typedef struct CFMutableDataRefObject
{
1537 CFMutableDataRef ob_itself
;
1538 void (*ob_freeit
)(CFTypeRef ptr
);
1539 } CFMutableDataRefObject
;
1541 PyObject
*CFMutableDataRefObj_New(CFMutableDataRef itself
)
1543 CFMutableDataRefObject
*it
;
1546 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
1549 it
= PyObject_NEW(CFMutableDataRefObject
, &CFMutableDataRef_Type
);
1550 if (it
== NULL
) return NULL
;
1551 /* XXXX Should we tp_init or tp_new our basetype? */
1552 it
->ob_itself
= itself
;
1553 it
->ob_freeit
= CFRelease
;
1554 return (PyObject
*)it
;
1557 int CFMutableDataRefObj_Convert(PyObject
*v
, CFMutableDataRef
*p_itself
)
1560 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1561 /* Check for other CF objects here */
1563 if (!CFMutableDataRefObj_Check(v
))
1565 PyErr_SetString(PyExc_TypeError
, "CFMutableDataRef required");
1568 *p_itself
= ((CFMutableDataRefObject
*)v
)->ob_itself
;
1572 static void CFMutableDataRefObj_dealloc(CFMutableDataRefObject
*self
)
1574 if (self
->ob_freeit
&& self
->ob_itself
)
1576 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1577 self
->ob_itself
= NULL
;
1579 CFDataRef_Type
.tp_dealloc((PyObject
*)self
);
1582 static PyObject
*CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1584 PyObject
*_res
= NULL
;
1586 #ifndef CFDataSetLength
1587 PyMac_PRECHECK(CFDataSetLength
);
1589 if (!PyArg_ParseTuple(_args
, "l",
1592 CFDataSetLength(_self
->ob_itself
,
1599 static PyObject
*CFMutableDataRefObj_CFDataIncreaseLength(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1601 PyObject
*_res
= NULL
;
1602 CFIndex extraLength
;
1603 #ifndef CFDataIncreaseLength
1604 PyMac_PRECHECK(CFDataIncreaseLength
);
1606 if (!PyArg_ParseTuple(_args
, "l",
1609 CFDataIncreaseLength(_self
->ob_itself
,
1616 static PyObject
*CFMutableDataRefObj_CFDataAppendBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1618 PyObject
*_res
= NULL
;
1619 unsigned char *bytes__in__
;
1621 int bytes__in_len__
;
1622 #ifndef CFDataAppendBytes
1623 PyMac_PRECHECK(CFDataAppendBytes
);
1625 if (!PyArg_ParseTuple(_args
, "s#",
1626 &bytes__in__
, &bytes__in_len__
))
1628 bytes__len__
= bytes__in_len__
;
1629 CFDataAppendBytes(_self
->ob_itself
,
1630 bytes__in__
, bytes__len__
);
1636 static PyObject
*CFMutableDataRefObj_CFDataReplaceBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1638 PyObject
*_res
= NULL
;
1640 unsigned char *newBytes__in__
;
1641 long newBytes__len__
;
1642 int newBytes__in_len__
;
1643 #ifndef CFDataReplaceBytes
1644 PyMac_PRECHECK(CFDataReplaceBytes
);
1646 if (!PyArg_ParseTuple(_args
, "O&s#",
1647 CFRange_Convert
, &range
,
1648 &newBytes__in__
, &newBytes__in_len__
))
1650 newBytes__len__
= newBytes__in_len__
;
1651 CFDataReplaceBytes(_self
->ob_itself
,
1653 newBytes__in__
, newBytes__len__
);
1659 static PyObject
*CFMutableDataRefObj_CFDataDeleteBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1661 PyObject
*_res
= NULL
;
1663 #ifndef CFDataDeleteBytes
1664 PyMac_PRECHECK(CFDataDeleteBytes
);
1666 if (!PyArg_ParseTuple(_args
, "O&",
1667 CFRange_Convert
, &range
))
1669 CFDataDeleteBytes(_self
->ob_itself
,
1676 static PyMethodDef CFMutableDataRefObj_methods
[] = {
1677 {"CFDataSetLength", (PyCFunction
)CFMutableDataRefObj_CFDataSetLength
, 1,
1678 PyDoc_STR("(CFIndex length) -> None")},
1679 {"CFDataIncreaseLength", (PyCFunction
)CFMutableDataRefObj_CFDataIncreaseLength
, 1,
1680 PyDoc_STR("(CFIndex extraLength) -> None")},
1681 {"CFDataAppendBytes", (PyCFunction
)CFMutableDataRefObj_CFDataAppendBytes
, 1,
1682 PyDoc_STR("(Buffer bytes) -> None")},
1683 {"CFDataReplaceBytes", (PyCFunction
)CFMutableDataRefObj_CFDataReplaceBytes
, 1,
1684 PyDoc_STR("(CFRange range, Buffer newBytes) -> None")},
1685 {"CFDataDeleteBytes", (PyCFunction
)CFMutableDataRefObj_CFDataDeleteBytes
, 1,
1686 PyDoc_STR("(CFRange range) -> None")},
1690 #define CFMutableDataRefObj_getsetlist NULL
1693 static int CFMutableDataRefObj_compare(CFMutableDataRefObject
*self
, CFMutableDataRefObject
*other
)
1695 /* XXXX Or should we use CFEqual?? */
1696 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1697 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1701 static PyObject
* CFMutableDataRefObj_repr(CFMutableDataRefObject
*self
)
1704 sprintf(buf
, "<CFMutableDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
1705 return PyString_FromString(buf
);
1708 static int CFMutableDataRefObj_hash(CFMutableDataRefObject
*self
)
1710 /* XXXX Or should we use CFHash?? */
1711 return (int)self
->ob_itself
;
1713 static int CFMutableDataRefObj_tp_init(PyObject
*_self
, PyObject
*_args
, PyObject
*_kwds
)
1715 CFMutableDataRef itself
;
1716 char *kw
[] = {"itself", 0};
1718 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFMutableDataRefObj_Convert
, &itself
))
1720 ((CFMutableDataRefObject
*)_self
)->ob_itself
= itself
;
1724 /* Any CFTypeRef descendent is allowed as initializer too */
1725 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFTypeRefObj_Convert
, &itself
))
1727 ((CFMutableDataRefObject
*)_self
)->ob_itself
= itself
;
1733 #define CFMutableDataRefObj_tp_alloc PyType_GenericAlloc
1735 static PyObject
*CFMutableDataRefObj_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
1738 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
1739 ((CFMutableDataRefObject
*)self
)->ob_itself
= NULL
;
1740 ((CFMutableDataRefObject
*)self
)->ob_freeit
= CFRelease
;
1744 #define CFMutableDataRefObj_tp_free PyObject_Del
1747 PyTypeObject CFMutableDataRef_Type
= {
1748 PyObject_HEAD_INIT(NULL
)
1750 "_CF.CFMutableDataRef", /*tp_name*/
1751 sizeof(CFMutableDataRefObject
), /*tp_basicsize*/
1754 (destructor
) CFMutableDataRefObj_dealloc
, /*tp_dealloc*/
1756 (getattrfunc
)0, /*tp_getattr*/
1757 (setattrfunc
)0, /*tp_setattr*/
1758 (cmpfunc
) CFMutableDataRefObj_compare
, /*tp_compare*/
1759 (reprfunc
) CFMutableDataRefObj_repr
, /*tp_repr*/
1760 (PyNumberMethods
*)0, /* tp_as_number */
1761 (PySequenceMethods
*)0, /* tp_as_sequence */
1762 (PyMappingMethods
*)0, /* tp_as_mapping */
1763 (hashfunc
) CFMutableDataRefObj_hash
, /*tp_hash*/
1766 PyObject_GenericGetAttr
, /*tp_getattro*/
1767 PyObject_GenericSetAttr
, /*tp_setattro */
1769 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
1773 0, /*tp_richcompare*/
1774 0, /*tp_weaklistoffset*/
1777 CFMutableDataRefObj_methods
, /* tp_methods */
1779 CFMutableDataRefObj_getsetlist
, /*tp_getset*/
1784 0, /*tp_dictoffset*/
1785 CFMutableDataRefObj_tp_init
, /* tp_init */
1786 CFMutableDataRefObj_tp_alloc
, /* tp_alloc */
1787 CFMutableDataRefObj_tp_new
, /* tp_new */
1788 CFMutableDataRefObj_tp_free
, /* tp_free */
1791 /* ---------------- End object type CFMutableDataRef ---------------- */
1794 /* -------------------- Object type CFStringRef --------------------- */
1796 PyTypeObject CFStringRef_Type
;
1798 #define CFStringRefObj_Check(x) ((x)->ob_type == &CFStringRef_Type || PyObject_TypeCheck((x), &CFStringRef_Type))
1800 typedef struct CFStringRefObject
{
1802 CFStringRef ob_itself
;
1803 void (*ob_freeit
)(CFTypeRef ptr
);
1804 } CFStringRefObject
;
1806 PyObject
*CFStringRefObj_New(CFStringRef itself
)
1808 CFStringRefObject
*it
;
1811 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
1814 it
= PyObject_NEW(CFStringRefObject
, &CFStringRef_Type
);
1815 if (it
== NULL
) return NULL
;
1816 /* XXXX Should we tp_init or tp_new our basetype? */
1817 it
->ob_itself
= itself
;
1818 it
->ob_freeit
= CFRelease
;
1819 return (PyObject
*)it
;
1822 int CFStringRefObj_Convert(PyObject
*v
, CFStringRef
*p_itself
)
1825 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1826 if (PyString_Check(v
)) {
1828 if (!PyArg_Parse(v
, "es", "ascii", &cStr
))
1830 *p_itself
= CFStringCreateWithCString((CFAllocatorRef
)NULL
, cStr
, kCFStringEncodingASCII
);
1834 if (PyUnicode_Check(v
)) {
1835 /* We use the CF types here, if Python was configured differently that will give an error */
1836 CFIndex size
= PyUnicode_GetSize(v
);
1837 UniChar
*unichars
= PyUnicode_AsUnicode(v
);
1838 if (!unichars
) return 0;
1839 *p_itself
= CFStringCreateWithCharacters((CFAllocatorRef
)NULL
, unichars
, size
);
1844 if (!CFStringRefObj_Check(v
))
1846 PyErr_SetString(PyExc_TypeError
, "CFStringRef required");
1849 *p_itself
= ((CFStringRefObject
*)v
)->ob_itself
;
1853 static void CFStringRefObj_dealloc(CFStringRefObject
*self
)
1855 if (self
->ob_freeit
&& self
->ob_itself
)
1857 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1858 self
->ob_itself
= NULL
;
1860 CFTypeRef_Type
.tp_dealloc((PyObject
*)self
);
1863 static PyObject
*CFStringRefObj_CFStringCreateWithSubstring(CFStringRefObject
*_self
, PyObject
*_args
)
1865 PyObject
*_res
= NULL
;
1868 if (!PyArg_ParseTuple(_args
, "O&",
1869 CFRange_Convert
, &range
))
1871 _rv
= CFStringCreateWithSubstring((CFAllocatorRef
)NULL
,
1874 _res
= Py_BuildValue("O&",
1875 CFStringRefObj_New
, _rv
);
1879 static PyObject
*CFStringRefObj_CFStringCreateCopy(CFStringRefObject
*_self
, PyObject
*_args
)
1881 PyObject
*_res
= NULL
;
1883 if (!PyArg_ParseTuple(_args
, ""))
1885 _rv
= CFStringCreateCopy((CFAllocatorRef
)NULL
,
1887 _res
= Py_BuildValue("O&",
1888 CFStringRefObj_New
, _rv
);
1892 static PyObject
*CFStringRefObj_CFStringGetLength(CFStringRefObject
*_self
, PyObject
*_args
)
1894 PyObject
*_res
= NULL
;
1896 #ifndef CFStringGetLength
1897 PyMac_PRECHECK(CFStringGetLength
);
1899 if (!PyArg_ParseTuple(_args
, ""))
1901 _rv
= CFStringGetLength(_self
->ob_itself
);
1902 _res
= Py_BuildValue("l",
1907 static PyObject
*CFStringRefObj_CFStringGetBytes(CFStringRefObject
*_self
, PyObject
*_args
)
1909 PyObject
*_res
= NULL
;
1912 CFStringEncoding encoding
;
1914 Boolean isExternalRepresentation
;
1918 #ifndef CFStringGetBytes
1919 PyMac_PRECHECK(CFStringGetBytes
);
1921 if (!PyArg_ParseTuple(_args
, "O&lbll",
1922 CFRange_Convert
, &range
,
1925 &isExternalRepresentation
,
1928 _rv
= CFStringGetBytes(_self
->ob_itself
,
1932 isExternalRepresentation
,
1936 _res
= Py_BuildValue("lbl",
1943 static PyObject
*CFStringRefObj_CFStringCreateExternalRepresentation(CFStringRefObject
*_self
, PyObject
*_args
)
1945 PyObject
*_res
= NULL
;
1947 CFStringEncoding encoding
;
1949 if (!PyArg_ParseTuple(_args
, "lb",
1953 _rv
= CFStringCreateExternalRepresentation((CFAllocatorRef
)NULL
,
1957 _res
= Py_BuildValue("O&",
1958 CFDataRefObj_New
, _rv
);
1962 static PyObject
*CFStringRefObj_CFStringGetSmallestEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
1964 PyObject
*_res
= NULL
;
1965 CFStringEncoding _rv
;
1966 #ifndef CFStringGetSmallestEncoding
1967 PyMac_PRECHECK(CFStringGetSmallestEncoding
);
1969 if (!PyArg_ParseTuple(_args
, ""))
1971 _rv
= CFStringGetSmallestEncoding(_self
->ob_itself
);
1972 _res
= Py_BuildValue("l",
1977 static PyObject
*CFStringRefObj_CFStringGetFastestEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
1979 PyObject
*_res
= NULL
;
1980 CFStringEncoding _rv
;
1981 #ifndef CFStringGetFastestEncoding
1982 PyMac_PRECHECK(CFStringGetFastestEncoding
);
1984 if (!PyArg_ParseTuple(_args
, ""))
1986 _rv
= CFStringGetFastestEncoding(_self
->ob_itself
);
1987 _res
= Py_BuildValue("l",
1992 static PyObject
*CFStringRefObj_CFStringCompareWithOptions(CFStringRefObject
*_self
, PyObject
*_args
)
1994 PyObject
*_res
= NULL
;
1995 CFComparisonResult _rv
;
1996 CFStringRef theString2
;
1997 CFRange rangeToCompare
;
1998 CFOptionFlags compareOptions
;
1999 #ifndef CFStringCompareWithOptions
2000 PyMac_PRECHECK(CFStringCompareWithOptions
);
2002 if (!PyArg_ParseTuple(_args
, "O&O&l",
2003 CFStringRefObj_Convert
, &theString2
,
2004 CFRange_Convert
, &rangeToCompare
,
2007 _rv
= CFStringCompareWithOptions(_self
->ob_itself
,
2011 _res
= Py_BuildValue("l",
2016 static PyObject
*CFStringRefObj_CFStringCompare(CFStringRefObject
*_self
, PyObject
*_args
)
2018 PyObject
*_res
= NULL
;
2019 CFComparisonResult _rv
;
2020 CFStringRef theString2
;
2021 CFOptionFlags compareOptions
;
2022 #ifndef CFStringCompare
2023 PyMac_PRECHECK(CFStringCompare
);
2025 if (!PyArg_ParseTuple(_args
, "O&l",
2026 CFStringRefObj_Convert
, &theString2
,
2029 _rv
= CFStringCompare(_self
->ob_itself
,
2032 _res
= Py_BuildValue("l",
2037 static PyObject
*CFStringRefObj_CFStringFindWithOptions(CFStringRefObject
*_self
, PyObject
*_args
)
2039 PyObject
*_res
= NULL
;
2041 CFStringRef stringToFind
;
2042 CFRange rangeToSearch
;
2043 CFOptionFlags searchOptions
;
2045 #ifndef CFStringFindWithOptions
2046 PyMac_PRECHECK(CFStringFindWithOptions
);
2048 if (!PyArg_ParseTuple(_args
, "O&O&l",
2049 CFStringRefObj_Convert
, &stringToFind
,
2050 CFRange_Convert
, &rangeToSearch
,
2053 _rv
= CFStringFindWithOptions(_self
->ob_itself
,
2058 _res
= Py_BuildValue("lO&",
2060 CFRange_New
, result
);
2064 static PyObject
*CFStringRefObj_CFStringCreateArrayWithFindResults(CFStringRefObject
*_self
, PyObject
*_args
)
2066 PyObject
*_res
= NULL
;
2068 CFStringRef stringToFind
;
2069 CFRange rangeToSearch
;
2070 CFOptionFlags compareOptions
;
2071 if (!PyArg_ParseTuple(_args
, "O&O&l",
2072 CFStringRefObj_Convert
, &stringToFind
,
2073 CFRange_Convert
, &rangeToSearch
,
2076 _rv
= CFStringCreateArrayWithFindResults((CFAllocatorRef
)NULL
,
2081 _res
= Py_BuildValue("O&",
2082 CFArrayRefObj_New
, _rv
);
2086 static PyObject
*CFStringRefObj_CFStringFind(CFStringRefObject
*_self
, PyObject
*_args
)
2088 PyObject
*_res
= NULL
;
2090 CFStringRef stringToFind
;
2091 CFOptionFlags compareOptions
;
2092 #ifndef CFStringFind
2093 PyMac_PRECHECK(CFStringFind
);
2095 if (!PyArg_ParseTuple(_args
, "O&l",
2096 CFStringRefObj_Convert
, &stringToFind
,
2099 _rv
= CFStringFind(_self
->ob_itself
,
2102 _res
= Py_BuildValue("O&",
2107 static PyObject
*CFStringRefObj_CFStringHasPrefix(CFStringRefObject
*_self
, PyObject
*_args
)
2109 PyObject
*_res
= NULL
;
2112 #ifndef CFStringHasPrefix
2113 PyMac_PRECHECK(CFStringHasPrefix
);
2115 if (!PyArg_ParseTuple(_args
, "O&",
2116 CFStringRefObj_Convert
, &prefix
))
2118 _rv
= CFStringHasPrefix(_self
->ob_itself
,
2120 _res
= Py_BuildValue("l",
2125 static PyObject
*CFStringRefObj_CFStringHasSuffix(CFStringRefObject
*_self
, PyObject
*_args
)
2127 PyObject
*_res
= NULL
;
2130 #ifndef CFStringHasSuffix
2131 PyMac_PRECHECK(CFStringHasSuffix
);
2133 if (!PyArg_ParseTuple(_args
, "O&",
2134 CFStringRefObj_Convert
, &suffix
))
2136 _rv
= CFStringHasSuffix(_self
->ob_itself
,
2138 _res
= Py_BuildValue("l",
2143 static PyObject
*CFStringRefObj_CFStringGetLineBounds(CFStringRefObject
*_self
, PyObject
*_args
)
2145 PyObject
*_res
= NULL
;
2147 CFIndex lineBeginIndex
;
2148 CFIndex lineEndIndex
;
2149 CFIndex contentsEndIndex
;
2150 #ifndef CFStringGetLineBounds
2151 PyMac_PRECHECK(CFStringGetLineBounds
);
2153 if (!PyArg_ParseTuple(_args
, "O&",
2154 CFRange_Convert
, &range
))
2156 CFStringGetLineBounds(_self
->ob_itself
,
2161 _res
= Py_BuildValue("lll",
2168 static PyObject
*CFStringRefObj_CFStringCreateArrayBySeparatingStrings(CFStringRefObject
*_self
, PyObject
*_args
)
2170 PyObject
*_res
= NULL
;
2172 CFStringRef separatorString
;
2173 if (!PyArg_ParseTuple(_args
, "O&",
2174 CFStringRefObj_Convert
, &separatorString
))
2176 _rv
= CFStringCreateArrayBySeparatingStrings((CFAllocatorRef
)NULL
,
2179 _res
= Py_BuildValue("O&",
2180 CFArrayRefObj_New
, _rv
);
2184 static PyObject
*CFStringRefObj_CFStringGetIntValue(CFStringRefObject
*_self
, PyObject
*_args
)
2186 PyObject
*_res
= NULL
;
2188 #ifndef CFStringGetIntValue
2189 PyMac_PRECHECK(CFStringGetIntValue
);
2191 if (!PyArg_ParseTuple(_args
, ""))
2193 _rv
= CFStringGetIntValue(_self
->ob_itself
);
2194 _res
= Py_BuildValue("l",
2199 static PyObject
*CFStringRefObj_CFStringGetDoubleValue(CFStringRefObject
*_self
, PyObject
*_args
)
2201 PyObject
*_res
= NULL
;
2203 #ifndef CFStringGetDoubleValue
2204 PyMac_PRECHECK(CFStringGetDoubleValue
);
2206 if (!PyArg_ParseTuple(_args
, ""))
2208 _rv
= CFStringGetDoubleValue(_self
->ob_itself
);
2209 _res
= Py_BuildValue("d",
2214 static PyObject
*CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
2216 PyObject
*_res
= NULL
;
2217 CFStringEncoding _rv
;
2218 #ifndef CFStringConvertIANACharSetNameToEncoding
2219 PyMac_PRECHECK(CFStringConvertIANACharSetNameToEncoding
);
2221 if (!PyArg_ParseTuple(_args
, ""))
2223 _rv
= CFStringConvertIANACharSetNameToEncoding(_self
->ob_itself
);
2224 _res
= Py_BuildValue("l",
2229 static PyObject
*CFStringRefObj_CFShowStr(CFStringRefObject
*_self
, PyObject
*_args
)
2231 PyObject
*_res
= NULL
;
2233 PyMac_PRECHECK(CFShowStr
);
2235 if (!PyArg_ParseTuple(_args
, ""))
2237 CFShowStr(_self
->ob_itself
);
2243 static PyObject
*CFStringRefObj_CFURLCreateWithString(CFStringRefObject
*_self
, PyObject
*_args
)
2245 PyObject
*_res
= NULL
;
2248 if (!PyArg_ParseTuple(_args
, "O&",
2249 OptionalCFURLRefObj_Convert
, &baseURL
))
2251 _rv
= CFURLCreateWithString((CFAllocatorRef
)NULL
,
2254 _res
= Py_BuildValue("O&",
2255 CFURLRefObj_New
, _rv
);
2259 static PyObject
*CFStringRefObj_CFURLCreateWithFileSystemPath(CFStringRefObject
*_self
, PyObject
*_args
)
2261 PyObject
*_res
= NULL
;
2263 CFURLPathStyle pathStyle
;
2264 Boolean isDirectory
;
2265 if (!PyArg_ParseTuple(_args
, "ll",
2269 _rv
= CFURLCreateWithFileSystemPath((CFAllocatorRef
)NULL
,
2273 _res
= Py_BuildValue("O&",
2274 CFURLRefObj_New
, _rv
);
2278 static PyObject
*CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase(CFStringRefObject
*_self
, PyObject
*_args
)
2280 PyObject
*_res
= NULL
;
2282 CFURLPathStyle pathStyle
;
2283 Boolean isDirectory
;
2285 if (!PyArg_ParseTuple(_args
, "llO&",
2288 OptionalCFURLRefObj_Convert
, &baseURL
))
2290 _rv
= CFURLCreateWithFileSystemPathRelativeToBase((CFAllocatorRef
)NULL
,
2295 _res
= Py_BuildValue("O&",
2296 CFURLRefObj_New
, _rv
);
2300 static PyObject
*CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes(CFStringRefObject
*_self
, PyObject
*_args
)
2302 PyObject
*_res
= NULL
;
2304 CFStringRef charactersToLeaveEscaped
;
2305 if (!PyArg_ParseTuple(_args
, "O&",
2306 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
2308 _rv
= CFURLCreateStringByReplacingPercentEscapes((CFAllocatorRef
)NULL
,
2310 charactersToLeaveEscaped
);
2311 _res
= Py_BuildValue("O&",
2312 CFStringRefObj_New
, _rv
);
2316 static PyObject
*CFStringRefObj_CFURLCreateStringByAddingPercentEscapes(CFStringRefObject
*_self
, PyObject
*_args
)
2318 PyObject
*_res
= NULL
;
2320 CFStringRef charactersToLeaveUnescaped
;
2321 CFStringRef legalURLCharactersToBeEscaped
;
2322 CFStringEncoding encoding
;
2323 if (!PyArg_ParseTuple(_args
, "O&O&l",
2324 CFStringRefObj_Convert
, &charactersToLeaveUnescaped
,
2325 CFStringRefObj_Convert
, &legalURLCharactersToBeEscaped
,
2328 _rv
= CFURLCreateStringByAddingPercentEscapes((CFAllocatorRef
)NULL
,
2330 charactersToLeaveUnescaped
,
2331 legalURLCharactersToBeEscaped
,
2333 _res
= Py_BuildValue("O&",
2334 CFStringRefObj_New
, _rv
);
2338 static PyObject
*CFStringRefObj_CFStringGetString(CFStringRefObject
*_self
, PyObject
*_args
)
2340 PyObject
*_res
= NULL
;
2342 int size
= CFStringGetLength(_self
->ob_itself
)+1;
2343 char *data
= malloc(size
);
2345 if( data
== NULL
) return PyErr_NoMemory();
2346 if ( CFStringGetCString(_self
->ob_itself
, data
, size
, 0) ) {
2347 _res
= (PyObject
*)PyString_FromString(data
);
2349 PyErr_SetString(PyExc_RuntimeError
, "CFStringGetCString could not fit the string");
2357 static PyObject
*CFStringRefObj_CFStringGetUnicode(CFStringRefObject
*_self
, PyObject
*_args
)
2359 PyObject
*_res
= NULL
;
2361 int size
= CFStringGetLength(_self
->ob_itself
)+1;
2362 Py_UNICODE
*data
= malloc(size
*sizeof(Py_UNICODE
));
2366 range
.length
= size
;
2367 if( data
== NULL
) return PyErr_NoMemory();
2368 CFStringGetCharacters(_self
->ob_itself
, range
, data
);
2369 _res
= (PyObject
*)PyUnicode_FromUnicode(data
, size
-1);
2375 static PyMethodDef CFStringRefObj_methods
[] = {
2376 {"CFStringCreateWithSubstring", (PyCFunction
)CFStringRefObj_CFStringCreateWithSubstring
, 1,
2377 PyDoc_STR("(CFRange range) -> (CFStringRef _rv)")},
2378 {"CFStringCreateCopy", (PyCFunction
)CFStringRefObj_CFStringCreateCopy
, 1,
2379 PyDoc_STR("() -> (CFStringRef _rv)")},
2380 {"CFStringGetLength", (PyCFunction
)CFStringRefObj_CFStringGetLength
, 1,
2381 PyDoc_STR("() -> (CFIndex _rv)")},
2382 {"CFStringGetBytes", (PyCFunction
)CFStringRefObj_CFStringGetBytes
, 1,
2383 PyDoc_STR("(CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, CFIndex maxBufLen) -> (CFIndex _rv, UInt8 buffer, CFIndex usedBufLen)")},
2384 {"CFStringCreateExternalRepresentation", (PyCFunction
)CFStringRefObj_CFStringCreateExternalRepresentation
, 1,
2385 PyDoc_STR("(CFStringEncoding encoding, UInt8 lossByte) -> (CFDataRef _rv)")},
2386 {"CFStringGetSmallestEncoding", (PyCFunction
)CFStringRefObj_CFStringGetSmallestEncoding
, 1,
2387 PyDoc_STR("() -> (CFStringEncoding _rv)")},
2388 {"CFStringGetFastestEncoding", (PyCFunction
)CFStringRefObj_CFStringGetFastestEncoding
, 1,
2389 PyDoc_STR("() -> (CFStringEncoding _rv)")},
2390 {"CFStringCompareWithOptions", (PyCFunction
)CFStringRefObj_CFStringCompareWithOptions
, 1,
2391 PyDoc_STR("(CFStringRef theString2, CFRange rangeToCompare, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)")},
2392 {"CFStringCompare", (PyCFunction
)CFStringRefObj_CFStringCompare
, 1,
2393 PyDoc_STR("(CFStringRef theString2, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)")},
2394 {"CFStringFindWithOptions", (PyCFunction
)CFStringRefObj_CFStringFindWithOptions
, 1,
2395 PyDoc_STR("(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags searchOptions) -> (Boolean _rv, CFRange result)")},
2396 {"CFStringCreateArrayWithFindResults", (PyCFunction
)CFStringRefObj_CFStringCreateArrayWithFindResults
, 1,
2397 PyDoc_STR("(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions) -> (CFArrayRef _rv)")},
2398 {"CFStringFind", (PyCFunction
)CFStringRefObj_CFStringFind
, 1,
2399 PyDoc_STR("(CFStringRef stringToFind, CFOptionFlags compareOptions) -> (CFRange _rv)")},
2400 {"CFStringHasPrefix", (PyCFunction
)CFStringRefObj_CFStringHasPrefix
, 1,
2401 PyDoc_STR("(CFStringRef prefix) -> (Boolean _rv)")},
2402 {"CFStringHasSuffix", (PyCFunction
)CFStringRefObj_CFStringHasSuffix
, 1,
2403 PyDoc_STR("(CFStringRef suffix) -> (Boolean _rv)")},
2404 {"CFStringGetLineBounds", (PyCFunction
)CFStringRefObj_CFStringGetLineBounds
, 1,
2405 PyDoc_STR("(CFRange range) -> (CFIndex lineBeginIndex, CFIndex lineEndIndex, CFIndex contentsEndIndex)")},
2406 {"CFStringCreateArrayBySeparatingStrings", (PyCFunction
)CFStringRefObj_CFStringCreateArrayBySeparatingStrings
, 1,
2407 PyDoc_STR("(CFStringRef separatorString) -> (CFArrayRef _rv)")},
2408 {"CFStringGetIntValue", (PyCFunction
)CFStringRefObj_CFStringGetIntValue
, 1,
2409 PyDoc_STR("() -> (SInt32 _rv)")},
2410 {"CFStringGetDoubleValue", (PyCFunction
)CFStringRefObj_CFStringGetDoubleValue
, 1,
2411 PyDoc_STR("() -> (double _rv)")},
2412 {"CFStringConvertIANACharSetNameToEncoding", (PyCFunction
)CFStringRefObj_CFStringConvertIANACharSetNameToEncoding
, 1,
2413 PyDoc_STR("() -> (CFStringEncoding _rv)")},
2414 {"CFShowStr", (PyCFunction
)CFStringRefObj_CFShowStr
, 1,
2415 PyDoc_STR("() -> None")},
2416 {"CFURLCreateWithString", (PyCFunction
)CFStringRefObj_CFURLCreateWithString
, 1,
2417 PyDoc_STR("(CFURLRef baseURL) -> (CFURLRef _rv)")},
2418 {"CFURLCreateWithFileSystemPath", (PyCFunction
)CFStringRefObj_CFURLCreateWithFileSystemPath
, 1,
2419 PyDoc_STR("(CFURLPathStyle pathStyle, Boolean isDirectory) -> (CFURLRef _rv)")},
2420 {"CFURLCreateWithFileSystemPathRelativeToBase", (PyCFunction
)CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase
, 1,
2421 PyDoc_STR("(CFURLPathStyle pathStyle, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)")},
2422 {"CFURLCreateStringByReplacingPercentEscapes", (PyCFunction
)CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes
, 1,
2423 PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")},
2424 {"CFURLCreateStringByAddingPercentEscapes", (PyCFunction
)CFStringRefObj_CFURLCreateStringByAddingPercentEscapes
, 1,
2425 PyDoc_STR("(CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding) -> (CFStringRef _rv)")},
2426 {"CFStringGetString", (PyCFunction
)CFStringRefObj_CFStringGetString
, 1,
2427 PyDoc_STR("() -> (string _rv)")},
2428 {"CFStringGetUnicode", (PyCFunction
)CFStringRefObj_CFStringGetUnicode
, 1,
2429 PyDoc_STR("() -> (unicode _rv)")},
2433 #define CFStringRefObj_getsetlist NULL
2436 static int CFStringRefObj_compare(CFStringRefObject
*self
, CFStringRefObject
*other
)
2438 /* XXXX Or should we use CFEqual?? */
2439 if ( self
->ob_itself
> other
->ob_itself
) return 1;
2440 if ( self
->ob_itself
< other
->ob_itself
) return -1;
2444 static PyObject
* CFStringRefObj_repr(CFStringRefObject
*self
)
2447 sprintf(buf
, "<CFStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
2448 return PyString_FromString(buf
);
2451 static int CFStringRefObj_hash(CFStringRefObject
*self
)
2453 /* XXXX Or should we use CFHash?? */
2454 return (int)self
->ob_itself
;
2456 static int CFStringRefObj_tp_init(PyObject
*_self
, PyObject
*_args
, PyObject
*_kwds
)
2459 char *kw
[] = {"itself", 0};
2461 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFStringRefObj_Convert
, &itself
))
2463 ((CFStringRefObject
*)_self
)->ob_itself
= itself
;
2467 /* Any CFTypeRef descendent is allowed as initializer too */
2468 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFTypeRefObj_Convert
, &itself
))
2470 ((CFStringRefObject
*)_self
)->ob_itself
= itself
;
2476 #define CFStringRefObj_tp_alloc PyType_GenericAlloc
2478 static PyObject
*CFStringRefObj_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
2481 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
2482 ((CFStringRefObject
*)self
)->ob_itself
= NULL
;
2483 ((CFStringRefObject
*)self
)->ob_freeit
= CFRelease
;
2487 #define CFStringRefObj_tp_free PyObject_Del
2490 PyTypeObject CFStringRef_Type
= {
2491 PyObject_HEAD_INIT(NULL
)
2493 "_CF.CFStringRef", /*tp_name*/
2494 sizeof(CFStringRefObject
), /*tp_basicsize*/
2497 (destructor
) CFStringRefObj_dealloc
, /*tp_dealloc*/
2499 (getattrfunc
)0, /*tp_getattr*/
2500 (setattrfunc
)0, /*tp_setattr*/
2501 (cmpfunc
) CFStringRefObj_compare
, /*tp_compare*/
2502 (reprfunc
) CFStringRefObj_repr
, /*tp_repr*/
2503 (PyNumberMethods
*)0, /* tp_as_number */
2504 (PySequenceMethods
*)0, /* tp_as_sequence */
2505 (PyMappingMethods
*)0, /* tp_as_mapping */
2506 (hashfunc
) CFStringRefObj_hash
, /*tp_hash*/
2509 PyObject_GenericGetAttr
, /*tp_getattro*/
2510 PyObject_GenericSetAttr
, /*tp_setattro */
2512 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
2516 0, /*tp_richcompare*/
2517 0, /*tp_weaklistoffset*/
2520 CFStringRefObj_methods
, /* tp_methods */
2522 CFStringRefObj_getsetlist
, /*tp_getset*/
2527 0, /*tp_dictoffset*/
2528 CFStringRefObj_tp_init
, /* tp_init */
2529 CFStringRefObj_tp_alloc
, /* tp_alloc */
2530 CFStringRefObj_tp_new
, /* tp_new */
2531 CFStringRefObj_tp_free
, /* tp_free */
2534 /* ------------------ End object type CFStringRef ------------------- */
2537 /* ----------------- Object type CFMutableStringRef ----------------- */
2539 PyTypeObject CFMutableStringRef_Type
;
2541 #define CFMutableStringRefObj_Check(x) ((x)->ob_type == &CFMutableStringRef_Type || PyObject_TypeCheck((x), &CFMutableStringRef_Type))
2543 typedef struct CFMutableStringRefObject
{
2545 CFMutableStringRef ob_itself
;
2546 void (*ob_freeit
)(CFTypeRef ptr
);
2547 } CFMutableStringRefObject
;
2549 PyObject
*CFMutableStringRefObj_New(CFMutableStringRef itself
)
2551 CFMutableStringRefObject
*it
;
2554 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
2557 it
= PyObject_NEW(CFMutableStringRefObject
, &CFMutableStringRef_Type
);
2558 if (it
== NULL
) return NULL
;
2559 /* XXXX Should we tp_init or tp_new our basetype? */
2560 it
->ob_itself
= itself
;
2561 it
->ob_freeit
= CFRelease
;
2562 return (PyObject
*)it
;
2565 int CFMutableStringRefObj_Convert(PyObject
*v
, CFMutableStringRef
*p_itself
)
2568 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
2569 /* Check for other CF objects here */
2571 if (!CFMutableStringRefObj_Check(v
))
2573 PyErr_SetString(PyExc_TypeError
, "CFMutableStringRef required");
2576 *p_itself
= ((CFMutableStringRefObject
*)v
)->ob_itself
;
2580 static void CFMutableStringRefObj_dealloc(CFMutableStringRefObject
*self
)
2582 if (self
->ob_freeit
&& self
->ob_itself
)
2584 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
2585 self
->ob_itself
= NULL
;
2587 CFStringRef_Type
.tp_dealloc((PyObject
*)self
);
2590 static PyObject
*CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2592 PyObject
*_res
= NULL
;
2593 CFStringRef appendedString
;
2594 #ifndef CFStringAppend
2595 PyMac_PRECHECK(CFStringAppend
);
2597 if (!PyArg_ParseTuple(_args
, "O&",
2598 CFStringRefObj_Convert
, &appendedString
))
2600 CFStringAppend(_self
->ob_itself
,
2607 static PyObject
*CFMutableStringRefObj_CFStringAppendCharacters(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2609 PyObject
*_res
= NULL
;
2610 UniChar
*chars__in__
;
2611 UniCharCount chars__len__
;
2612 int chars__in_len__
;
2613 #ifndef CFStringAppendCharacters
2614 PyMac_PRECHECK(CFStringAppendCharacters
);
2616 if (!PyArg_ParseTuple(_args
, "u#",
2617 &chars__in__
, &chars__in_len__
))
2619 chars__len__
= chars__in_len__
;
2620 CFStringAppendCharacters(_self
->ob_itself
,
2621 chars__in__
, chars__len__
);
2627 static PyObject
*CFMutableStringRefObj_CFStringAppendPascalString(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2629 PyObject
*_res
= NULL
;
2631 CFStringEncoding encoding
;
2632 #ifndef CFStringAppendPascalString
2633 PyMac_PRECHECK(CFStringAppendPascalString
);
2635 if (!PyArg_ParseTuple(_args
, "O&l",
2636 PyMac_GetStr255
, pStr
,
2639 CFStringAppendPascalString(_self
->ob_itself
,
2647 static PyObject
*CFMutableStringRefObj_CFStringAppendCString(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2649 PyObject
*_res
= NULL
;
2651 CFStringEncoding encoding
;
2652 #ifndef CFStringAppendCString
2653 PyMac_PRECHECK(CFStringAppendCString
);
2655 if (!PyArg_ParseTuple(_args
, "sl",
2659 CFStringAppendCString(_self
->ob_itself
,
2667 static PyObject
*CFMutableStringRefObj_CFStringInsert(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2669 PyObject
*_res
= NULL
;
2671 CFStringRef insertedStr
;
2672 #ifndef CFStringInsert
2673 PyMac_PRECHECK(CFStringInsert
);
2675 if (!PyArg_ParseTuple(_args
, "lO&",
2677 CFStringRefObj_Convert
, &insertedStr
))
2679 CFStringInsert(_self
->ob_itself
,
2687 static PyObject
*CFMutableStringRefObj_CFStringDelete(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2689 PyObject
*_res
= NULL
;
2691 #ifndef CFStringDelete
2692 PyMac_PRECHECK(CFStringDelete
);
2694 if (!PyArg_ParseTuple(_args
, "O&",
2695 CFRange_Convert
, &range
))
2697 CFStringDelete(_self
->ob_itself
,
2704 static PyObject
*CFMutableStringRefObj_CFStringReplace(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2706 PyObject
*_res
= NULL
;
2708 CFStringRef replacement
;
2709 #ifndef CFStringReplace
2710 PyMac_PRECHECK(CFStringReplace
);
2712 if (!PyArg_ParseTuple(_args
, "O&O&",
2713 CFRange_Convert
, &range
,
2714 CFStringRefObj_Convert
, &replacement
))
2716 CFStringReplace(_self
->ob_itself
,
2724 static PyObject
*CFMutableStringRefObj_CFStringReplaceAll(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2726 PyObject
*_res
= NULL
;
2727 CFStringRef replacement
;
2728 #ifndef CFStringReplaceAll
2729 PyMac_PRECHECK(CFStringReplaceAll
);
2731 if (!PyArg_ParseTuple(_args
, "O&",
2732 CFStringRefObj_Convert
, &replacement
))
2734 CFStringReplaceAll(_self
->ob_itself
,
2741 static PyObject
*CFMutableStringRefObj_CFStringPad(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2743 PyObject
*_res
= NULL
;
2744 CFStringRef padString
;
2746 CFIndex indexIntoPad
;
2748 PyMac_PRECHECK(CFStringPad
);
2750 if (!PyArg_ParseTuple(_args
, "O&ll",
2751 CFStringRefObj_Convert
, &padString
,
2755 CFStringPad(_self
->ob_itself
,
2764 static PyObject
*CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2766 PyObject
*_res
= NULL
;
2767 CFStringRef trimString
;
2768 #ifndef CFStringTrim
2769 PyMac_PRECHECK(CFStringTrim
);
2771 if (!PyArg_ParseTuple(_args
, "O&",
2772 CFStringRefObj_Convert
, &trimString
))
2774 CFStringTrim(_self
->ob_itself
,
2781 static PyObject
*CFMutableStringRefObj_CFStringTrimWhitespace(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2783 PyObject
*_res
= NULL
;
2784 #ifndef CFStringTrimWhitespace
2785 PyMac_PRECHECK(CFStringTrimWhitespace
);
2787 if (!PyArg_ParseTuple(_args
, ""))
2789 CFStringTrimWhitespace(_self
->ob_itself
);
2795 static PyMethodDef CFMutableStringRefObj_methods
[] = {
2796 {"CFStringAppend", (PyCFunction
)CFMutableStringRefObj_CFStringAppend
, 1,
2797 PyDoc_STR("(CFStringRef appendedString) -> None")},
2798 {"CFStringAppendCharacters", (PyCFunction
)CFMutableStringRefObj_CFStringAppendCharacters
, 1,
2799 PyDoc_STR("(Buffer chars) -> None")},
2800 {"CFStringAppendPascalString", (PyCFunction
)CFMutableStringRefObj_CFStringAppendPascalString
, 1,
2801 PyDoc_STR("(Str255 pStr, CFStringEncoding encoding) -> None")},
2802 {"CFStringAppendCString", (PyCFunction
)CFMutableStringRefObj_CFStringAppendCString
, 1,
2803 PyDoc_STR("(char* cStr, CFStringEncoding encoding) -> None")},
2804 {"CFStringInsert", (PyCFunction
)CFMutableStringRefObj_CFStringInsert
, 1,
2805 PyDoc_STR("(CFIndex idx, CFStringRef insertedStr) -> None")},
2806 {"CFStringDelete", (PyCFunction
)CFMutableStringRefObj_CFStringDelete
, 1,
2807 PyDoc_STR("(CFRange range) -> None")},
2808 {"CFStringReplace", (PyCFunction
)CFMutableStringRefObj_CFStringReplace
, 1,
2809 PyDoc_STR("(CFRange range, CFStringRef replacement) -> None")},
2810 {"CFStringReplaceAll", (PyCFunction
)CFMutableStringRefObj_CFStringReplaceAll
, 1,
2811 PyDoc_STR("(CFStringRef replacement) -> None")},
2812 {"CFStringPad", (PyCFunction
)CFMutableStringRefObj_CFStringPad
, 1,
2813 PyDoc_STR("(CFStringRef padString, CFIndex length, CFIndex indexIntoPad) -> None")},
2814 {"CFStringTrim", (PyCFunction
)CFMutableStringRefObj_CFStringTrim
, 1,
2815 PyDoc_STR("(CFStringRef trimString) -> None")},
2816 {"CFStringTrimWhitespace", (PyCFunction
)CFMutableStringRefObj_CFStringTrimWhitespace
, 1,
2817 PyDoc_STR("() -> None")},
2821 #define CFMutableStringRefObj_getsetlist NULL
2824 static int CFMutableStringRefObj_compare(CFMutableStringRefObject
*self
, CFMutableStringRefObject
*other
)
2826 /* XXXX Or should we use CFEqual?? */
2827 if ( self
->ob_itself
> other
->ob_itself
) return 1;
2828 if ( self
->ob_itself
< other
->ob_itself
) return -1;
2832 static PyObject
* CFMutableStringRefObj_repr(CFMutableStringRefObject
*self
)
2835 sprintf(buf
, "<CFMutableStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
2836 return PyString_FromString(buf
);
2839 static int CFMutableStringRefObj_hash(CFMutableStringRefObject
*self
)
2841 /* XXXX Or should we use CFHash?? */
2842 return (int)self
->ob_itself
;
2844 static int CFMutableStringRefObj_tp_init(PyObject
*_self
, PyObject
*_args
, PyObject
*_kwds
)
2846 CFMutableStringRef itself
;
2847 char *kw
[] = {"itself", 0};
2849 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFMutableStringRefObj_Convert
, &itself
))
2851 ((CFMutableStringRefObject
*)_self
)->ob_itself
= itself
;
2855 /* Any CFTypeRef descendent is allowed as initializer too */
2856 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFTypeRefObj_Convert
, &itself
))
2858 ((CFMutableStringRefObject
*)_self
)->ob_itself
= itself
;
2864 #define CFMutableStringRefObj_tp_alloc PyType_GenericAlloc
2866 static PyObject
*CFMutableStringRefObj_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
2869 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
2870 ((CFMutableStringRefObject
*)self
)->ob_itself
= NULL
;
2871 ((CFMutableStringRefObject
*)self
)->ob_freeit
= CFRelease
;
2875 #define CFMutableStringRefObj_tp_free PyObject_Del
2878 PyTypeObject CFMutableStringRef_Type
= {
2879 PyObject_HEAD_INIT(NULL
)
2881 "_CF.CFMutableStringRef", /*tp_name*/
2882 sizeof(CFMutableStringRefObject
), /*tp_basicsize*/
2885 (destructor
) CFMutableStringRefObj_dealloc
, /*tp_dealloc*/
2887 (getattrfunc
)0, /*tp_getattr*/
2888 (setattrfunc
)0, /*tp_setattr*/
2889 (cmpfunc
) CFMutableStringRefObj_compare
, /*tp_compare*/
2890 (reprfunc
) CFMutableStringRefObj_repr
, /*tp_repr*/
2891 (PyNumberMethods
*)0, /* tp_as_number */
2892 (PySequenceMethods
*)0, /* tp_as_sequence */
2893 (PyMappingMethods
*)0, /* tp_as_mapping */
2894 (hashfunc
) CFMutableStringRefObj_hash
, /*tp_hash*/
2897 PyObject_GenericGetAttr
, /*tp_getattro*/
2898 PyObject_GenericSetAttr
, /*tp_setattro */
2900 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
2904 0, /*tp_richcompare*/
2905 0, /*tp_weaklistoffset*/
2908 CFMutableStringRefObj_methods
, /* tp_methods */
2910 CFMutableStringRefObj_getsetlist
, /*tp_getset*/
2915 0, /*tp_dictoffset*/
2916 CFMutableStringRefObj_tp_init
, /* tp_init */
2917 CFMutableStringRefObj_tp_alloc
, /* tp_alloc */
2918 CFMutableStringRefObj_tp_new
, /* tp_new */
2919 CFMutableStringRefObj_tp_free
, /* tp_free */
2922 /* --------------- End object type CFMutableStringRef --------------- */
2925 /* ---------------------- Object type CFURLRef ---------------------- */
2927 PyTypeObject CFURLRef_Type
;
2929 #define CFURLRefObj_Check(x) ((x)->ob_type == &CFURLRef_Type || PyObject_TypeCheck((x), &CFURLRef_Type))
2931 typedef struct CFURLRefObject
{
2934 void (*ob_freeit
)(CFTypeRef ptr
);
2937 PyObject
*CFURLRefObj_New(CFURLRef itself
)
2942 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
2945 it
= PyObject_NEW(CFURLRefObject
, &CFURLRef_Type
);
2946 if (it
== NULL
) return NULL
;
2947 /* XXXX Should we tp_init or tp_new our basetype? */
2948 it
->ob_itself
= itself
;
2949 it
->ob_freeit
= CFRelease
;
2950 return (PyObject
*)it
;
2953 int CFURLRefObj_Convert(PyObject
*v
, CFURLRef
*p_itself
)
2956 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
2957 /* Check for other CF objects here */
2959 if (!CFURLRefObj_Check(v
))
2961 PyErr_SetString(PyExc_TypeError
, "CFURLRef required");
2964 *p_itself
= ((CFURLRefObject
*)v
)->ob_itself
;
2968 static void CFURLRefObj_dealloc(CFURLRefObject
*self
)
2970 if (self
->ob_freeit
&& self
->ob_itself
)
2972 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
2973 self
->ob_itself
= NULL
;
2975 CFTypeRef_Type
.tp_dealloc((PyObject
*)self
);
2978 static PyObject
*CFURLRefObj_CFURLCreateData(CFURLRefObject
*_self
, PyObject
*_args
)
2980 PyObject
*_res
= NULL
;
2982 CFStringEncoding encoding
;
2983 Boolean escapeWhitespace
;
2984 if (!PyArg_ParseTuple(_args
, "ll",
2988 _rv
= CFURLCreateData((CFAllocatorRef
)NULL
,
2992 _res
= Py_BuildValue("O&",
2993 CFDataRefObj_New
, _rv
);
2997 static PyObject
*CFURLRefObj_CFURLGetFileSystemRepresentation(CFURLRefObject
*_self
, PyObject
*_args
)
2999 PyObject
*_res
= NULL
;
3001 Boolean resolveAgainstBase
;
3004 #ifndef CFURLGetFileSystemRepresentation
3005 PyMac_PRECHECK(CFURLGetFileSystemRepresentation
);
3007 if (!PyArg_ParseTuple(_args
, "ll",
3008 &resolveAgainstBase
,
3011 _rv
= CFURLGetFileSystemRepresentation(_self
->ob_itself
,
3015 _res
= Py_BuildValue("lb",
3021 static PyObject
*CFURLRefObj_CFURLCopyAbsoluteURL(CFURLRefObject
*_self
, PyObject
*_args
)
3023 PyObject
*_res
= NULL
;
3025 #ifndef CFURLCopyAbsoluteURL
3026 PyMac_PRECHECK(CFURLCopyAbsoluteURL
);
3028 if (!PyArg_ParseTuple(_args
, ""))
3030 _rv
= CFURLCopyAbsoluteURL(_self
->ob_itself
);
3031 _res
= Py_BuildValue("O&",
3032 CFURLRefObj_New
, _rv
);
3036 static PyObject
*CFURLRefObj_CFURLGetString(CFURLRefObject
*_self
, PyObject
*_args
)
3038 PyObject
*_res
= NULL
;
3040 #ifndef CFURLGetString
3041 PyMac_PRECHECK(CFURLGetString
);
3043 if (!PyArg_ParseTuple(_args
, ""))
3045 _rv
= CFURLGetString(_self
->ob_itself
);
3046 _res
= Py_BuildValue("O&",
3047 CFStringRefObj_New
, _rv
);
3051 static PyObject
*CFURLRefObj_CFURLGetBaseURL(CFURLRefObject
*_self
, PyObject
*_args
)
3053 PyObject
*_res
= NULL
;
3055 #ifndef CFURLGetBaseURL
3056 PyMac_PRECHECK(CFURLGetBaseURL
);
3058 if (!PyArg_ParseTuple(_args
, ""))
3060 _rv
= CFURLGetBaseURL(_self
->ob_itself
);
3061 _res
= Py_BuildValue("O&",
3062 CFURLRefObj_New
, _rv
);
3066 static PyObject
*CFURLRefObj_CFURLCanBeDecomposed(CFURLRefObject
*_self
, PyObject
*_args
)
3068 PyObject
*_res
= NULL
;
3070 #ifndef CFURLCanBeDecomposed
3071 PyMac_PRECHECK(CFURLCanBeDecomposed
);
3073 if (!PyArg_ParseTuple(_args
, ""))
3075 _rv
= CFURLCanBeDecomposed(_self
->ob_itself
);
3076 _res
= Py_BuildValue("l",
3081 static PyObject
*CFURLRefObj_CFURLCopyScheme(CFURLRefObject
*_self
, PyObject
*_args
)
3083 PyObject
*_res
= NULL
;
3085 #ifndef CFURLCopyScheme
3086 PyMac_PRECHECK(CFURLCopyScheme
);
3088 if (!PyArg_ParseTuple(_args
, ""))
3090 _rv
= CFURLCopyScheme(_self
->ob_itself
);
3091 _res
= Py_BuildValue("O&",
3092 CFStringRefObj_New
, _rv
);
3096 static PyObject
*CFURLRefObj_CFURLCopyNetLocation(CFURLRefObject
*_self
, PyObject
*_args
)
3098 PyObject
*_res
= NULL
;
3100 #ifndef CFURLCopyNetLocation
3101 PyMac_PRECHECK(CFURLCopyNetLocation
);
3103 if (!PyArg_ParseTuple(_args
, ""))
3105 _rv
= CFURLCopyNetLocation(_self
->ob_itself
);
3106 _res
= Py_BuildValue("O&",
3107 CFStringRefObj_New
, _rv
);
3111 static PyObject
*CFURLRefObj_CFURLCopyPath(CFURLRefObject
*_self
, PyObject
*_args
)
3113 PyObject
*_res
= NULL
;
3115 #ifndef CFURLCopyPath
3116 PyMac_PRECHECK(CFURLCopyPath
);
3118 if (!PyArg_ParseTuple(_args
, ""))
3120 _rv
= CFURLCopyPath(_self
->ob_itself
);
3121 _res
= Py_BuildValue("O&",
3122 CFStringRefObj_New
, _rv
);
3126 static PyObject
*CFURLRefObj_CFURLCopyStrictPath(CFURLRefObject
*_self
, PyObject
*_args
)
3128 PyObject
*_res
= NULL
;
3131 #ifndef CFURLCopyStrictPath
3132 PyMac_PRECHECK(CFURLCopyStrictPath
);
3134 if (!PyArg_ParseTuple(_args
, ""))
3136 _rv
= CFURLCopyStrictPath(_self
->ob_itself
,
3138 _res
= Py_BuildValue("O&l",
3139 CFStringRefObj_New
, _rv
,
3144 static PyObject
*CFURLRefObj_CFURLCopyFileSystemPath(CFURLRefObject
*_self
, PyObject
*_args
)
3146 PyObject
*_res
= NULL
;
3148 CFURLPathStyle pathStyle
;
3149 #ifndef CFURLCopyFileSystemPath
3150 PyMac_PRECHECK(CFURLCopyFileSystemPath
);
3152 if (!PyArg_ParseTuple(_args
, "l",
3155 _rv
= CFURLCopyFileSystemPath(_self
->ob_itself
,
3157 _res
= Py_BuildValue("O&",
3158 CFStringRefObj_New
, _rv
);
3162 static PyObject
*CFURLRefObj_CFURLHasDirectoryPath(CFURLRefObject
*_self
, PyObject
*_args
)
3164 PyObject
*_res
= NULL
;
3166 #ifndef CFURLHasDirectoryPath
3167 PyMac_PRECHECK(CFURLHasDirectoryPath
);
3169 if (!PyArg_ParseTuple(_args
, ""))
3171 _rv
= CFURLHasDirectoryPath(_self
->ob_itself
);
3172 _res
= Py_BuildValue("l",
3177 static PyObject
*CFURLRefObj_CFURLCopyResourceSpecifier(CFURLRefObject
*_self
, PyObject
*_args
)
3179 PyObject
*_res
= NULL
;
3181 #ifndef CFURLCopyResourceSpecifier
3182 PyMac_PRECHECK(CFURLCopyResourceSpecifier
);
3184 if (!PyArg_ParseTuple(_args
, ""))
3186 _rv
= CFURLCopyResourceSpecifier(_self
->ob_itself
);
3187 _res
= Py_BuildValue("O&",
3188 CFStringRefObj_New
, _rv
);
3192 static PyObject
*CFURLRefObj_CFURLCopyHostName(CFURLRefObject
*_self
, PyObject
*_args
)
3194 PyObject
*_res
= NULL
;
3196 #ifndef CFURLCopyHostName
3197 PyMac_PRECHECK(CFURLCopyHostName
);
3199 if (!PyArg_ParseTuple(_args
, ""))
3201 _rv
= CFURLCopyHostName(_self
->ob_itself
);
3202 _res
= Py_BuildValue("O&",
3203 CFStringRefObj_New
, _rv
);
3207 static PyObject
*CFURLRefObj_CFURLGetPortNumber(CFURLRefObject
*_self
, PyObject
*_args
)
3209 PyObject
*_res
= NULL
;
3211 #ifndef CFURLGetPortNumber
3212 PyMac_PRECHECK(CFURLGetPortNumber
);
3214 if (!PyArg_ParseTuple(_args
, ""))
3216 _rv
= CFURLGetPortNumber(_self
->ob_itself
);
3217 _res
= Py_BuildValue("l",
3222 static PyObject
*CFURLRefObj_CFURLCopyUserName(CFURLRefObject
*_self
, PyObject
*_args
)
3224 PyObject
*_res
= NULL
;
3226 #ifndef CFURLCopyUserName
3227 PyMac_PRECHECK(CFURLCopyUserName
);
3229 if (!PyArg_ParseTuple(_args
, ""))
3231 _rv
= CFURLCopyUserName(_self
->ob_itself
);
3232 _res
= Py_BuildValue("O&",
3233 CFStringRefObj_New
, _rv
);
3237 static PyObject
*CFURLRefObj_CFURLCopyPassword(CFURLRefObject
*_self
, PyObject
*_args
)
3239 PyObject
*_res
= NULL
;
3241 #ifndef CFURLCopyPassword
3242 PyMac_PRECHECK(CFURLCopyPassword
);
3244 if (!PyArg_ParseTuple(_args
, ""))
3246 _rv
= CFURLCopyPassword(_self
->ob_itself
);
3247 _res
= Py_BuildValue("O&",
3248 CFStringRefObj_New
, _rv
);
3252 static PyObject
*CFURLRefObj_CFURLCopyParameterString(CFURLRefObject
*_self
, PyObject
*_args
)
3254 PyObject
*_res
= NULL
;
3256 CFStringRef charactersToLeaveEscaped
;
3257 #ifndef CFURLCopyParameterString
3258 PyMac_PRECHECK(CFURLCopyParameterString
);
3260 if (!PyArg_ParseTuple(_args
, "O&",
3261 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
3263 _rv
= CFURLCopyParameterString(_self
->ob_itself
,
3264 charactersToLeaveEscaped
);
3265 _res
= Py_BuildValue("O&",
3266 CFStringRefObj_New
, _rv
);
3270 static PyObject
*CFURLRefObj_CFURLCopyQueryString(CFURLRefObject
*_self
, PyObject
*_args
)
3272 PyObject
*_res
= NULL
;
3274 CFStringRef charactersToLeaveEscaped
;
3275 #ifndef CFURLCopyQueryString
3276 PyMac_PRECHECK(CFURLCopyQueryString
);
3278 if (!PyArg_ParseTuple(_args
, "O&",
3279 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
3281 _rv
= CFURLCopyQueryString(_self
->ob_itself
,
3282 charactersToLeaveEscaped
);
3283 _res
= Py_BuildValue("O&",
3284 CFStringRefObj_New
, _rv
);
3288 static PyObject
*CFURLRefObj_CFURLCopyFragment(CFURLRefObject
*_self
, PyObject
*_args
)
3290 PyObject
*_res
= NULL
;
3292 CFStringRef charactersToLeaveEscaped
;
3293 #ifndef CFURLCopyFragment
3294 PyMac_PRECHECK(CFURLCopyFragment
);
3296 if (!PyArg_ParseTuple(_args
, "O&",
3297 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
3299 _rv
= CFURLCopyFragment(_self
->ob_itself
,
3300 charactersToLeaveEscaped
);
3301 _res
= Py_BuildValue("O&",
3302 CFStringRefObj_New
, _rv
);
3306 static PyObject
*CFURLRefObj_CFURLCopyLastPathComponent(CFURLRefObject
*_self
, PyObject
*_args
)
3308 PyObject
*_res
= NULL
;
3310 #ifndef CFURLCopyLastPathComponent
3311 PyMac_PRECHECK(CFURLCopyLastPathComponent
);
3313 if (!PyArg_ParseTuple(_args
, ""))
3315 _rv
= CFURLCopyLastPathComponent(_self
->ob_itself
);
3316 _res
= Py_BuildValue("O&",
3317 CFStringRefObj_New
, _rv
);
3321 static PyObject
*CFURLRefObj_CFURLCopyPathExtension(CFURLRefObject
*_self
, PyObject
*_args
)
3323 PyObject
*_res
= NULL
;
3325 #ifndef CFURLCopyPathExtension
3326 PyMac_PRECHECK(CFURLCopyPathExtension
);
3328 if (!PyArg_ParseTuple(_args
, ""))
3330 _rv
= CFURLCopyPathExtension(_self
->ob_itself
);
3331 _res
= Py_BuildValue("O&",
3332 CFStringRefObj_New
, _rv
);
3336 static PyObject
*CFURLRefObj_CFURLCreateCopyAppendingPathComponent(CFURLRefObject
*_self
, PyObject
*_args
)
3338 PyObject
*_res
= NULL
;
3340 CFStringRef pathComponent
;
3341 Boolean isDirectory
;
3342 if (!PyArg_ParseTuple(_args
, "O&l",
3343 CFStringRefObj_Convert
, &pathComponent
,
3346 _rv
= CFURLCreateCopyAppendingPathComponent((CFAllocatorRef
)NULL
,
3350 _res
= Py_BuildValue("O&",
3351 CFURLRefObj_New
, _rv
);
3355 static PyObject
*CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent(CFURLRefObject
*_self
, PyObject
*_args
)
3357 PyObject
*_res
= NULL
;
3359 if (!PyArg_ParseTuple(_args
, ""))
3361 _rv
= CFURLCreateCopyDeletingLastPathComponent((CFAllocatorRef
)NULL
,
3363 _res
= Py_BuildValue("O&",
3364 CFURLRefObj_New
, _rv
);
3368 static PyObject
*CFURLRefObj_CFURLCreateCopyAppendingPathExtension(CFURLRefObject
*_self
, PyObject
*_args
)
3370 PyObject
*_res
= NULL
;
3372 CFStringRef extension
;
3373 if (!PyArg_ParseTuple(_args
, "O&",
3374 CFStringRefObj_Convert
, &extension
))
3376 _rv
= CFURLCreateCopyAppendingPathExtension((CFAllocatorRef
)NULL
,
3379 _res
= Py_BuildValue("O&",
3380 CFURLRefObj_New
, _rv
);
3384 static PyObject
*CFURLRefObj_CFURLCreateCopyDeletingPathExtension(CFURLRefObject
*_self
, PyObject
*_args
)
3386 PyObject
*_res
= NULL
;
3388 if (!PyArg_ParseTuple(_args
, ""))
3390 _rv
= CFURLCreateCopyDeletingPathExtension((CFAllocatorRef
)NULL
,
3392 _res
= Py_BuildValue("O&",
3393 CFURLRefObj_New
, _rv
);
3397 static PyObject
*CFURLRefObj_CFURLGetFSRef(CFURLRefObject
*_self
, PyObject
*_args
)
3399 PyObject
*_res
= NULL
;
3402 #ifndef CFURLGetFSRef
3403 PyMac_PRECHECK(CFURLGetFSRef
);
3405 if (!PyArg_ParseTuple(_args
, ""))
3407 _rv
= CFURLGetFSRef(_self
->ob_itself
,
3409 _res
= Py_BuildValue("lO&",
3411 PyMac_BuildFSRef
, &fsRef
);
3415 static PyMethodDef CFURLRefObj_methods
[] = {
3416 {"CFURLCreateData", (PyCFunction
)CFURLRefObj_CFURLCreateData
, 1,
3417 PyDoc_STR("(CFStringEncoding encoding, Boolean escapeWhitespace) -> (CFDataRef _rv)")},
3418 {"CFURLGetFileSystemRepresentation", (PyCFunction
)CFURLRefObj_CFURLGetFileSystemRepresentation
, 1,
3419 PyDoc_STR("(Boolean resolveAgainstBase, CFIndex maxBufLen) -> (Boolean _rv, UInt8 buffer)")},
3420 {"CFURLCopyAbsoluteURL", (PyCFunction
)CFURLRefObj_CFURLCopyAbsoluteURL
, 1,
3421 PyDoc_STR("() -> (CFURLRef _rv)")},
3422 {"CFURLGetString", (PyCFunction
)CFURLRefObj_CFURLGetString
, 1,
3423 PyDoc_STR("() -> (CFStringRef _rv)")},
3424 {"CFURLGetBaseURL", (PyCFunction
)CFURLRefObj_CFURLGetBaseURL
, 1,
3425 PyDoc_STR("() -> (CFURLRef _rv)")},
3426 {"CFURLCanBeDecomposed", (PyCFunction
)CFURLRefObj_CFURLCanBeDecomposed
, 1,
3427 PyDoc_STR("() -> (Boolean _rv)")},
3428 {"CFURLCopyScheme", (PyCFunction
)CFURLRefObj_CFURLCopyScheme
, 1,
3429 PyDoc_STR("() -> (CFStringRef _rv)")},
3430 {"CFURLCopyNetLocation", (PyCFunction
)CFURLRefObj_CFURLCopyNetLocation
, 1,
3431 PyDoc_STR("() -> (CFStringRef _rv)")},
3432 {"CFURLCopyPath", (PyCFunction
)CFURLRefObj_CFURLCopyPath
, 1,
3433 PyDoc_STR("() -> (CFStringRef _rv)")},
3434 {"CFURLCopyStrictPath", (PyCFunction
)CFURLRefObj_CFURLCopyStrictPath
, 1,
3435 PyDoc_STR("() -> (CFStringRef _rv, Boolean isAbsolute)")},
3436 {"CFURLCopyFileSystemPath", (PyCFunction
)CFURLRefObj_CFURLCopyFileSystemPath
, 1,
3437 PyDoc_STR("(CFURLPathStyle pathStyle) -> (CFStringRef _rv)")},
3438 {"CFURLHasDirectoryPath", (PyCFunction
)CFURLRefObj_CFURLHasDirectoryPath
, 1,
3439 PyDoc_STR("() -> (Boolean _rv)")},
3440 {"CFURLCopyResourceSpecifier", (PyCFunction
)CFURLRefObj_CFURLCopyResourceSpecifier
, 1,
3441 PyDoc_STR("() -> (CFStringRef _rv)")},
3442 {"CFURLCopyHostName", (PyCFunction
)CFURLRefObj_CFURLCopyHostName
, 1,
3443 PyDoc_STR("() -> (CFStringRef _rv)")},
3444 {"CFURLGetPortNumber", (PyCFunction
)CFURLRefObj_CFURLGetPortNumber
, 1,
3445 PyDoc_STR("() -> (SInt32 _rv)")},
3446 {"CFURLCopyUserName", (PyCFunction
)CFURLRefObj_CFURLCopyUserName
, 1,
3447 PyDoc_STR("() -> (CFStringRef _rv)")},
3448 {"CFURLCopyPassword", (PyCFunction
)CFURLRefObj_CFURLCopyPassword
, 1,
3449 PyDoc_STR("() -> (CFStringRef _rv)")},
3450 {"CFURLCopyParameterString", (PyCFunction
)CFURLRefObj_CFURLCopyParameterString
, 1,
3451 PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")},
3452 {"CFURLCopyQueryString", (PyCFunction
)CFURLRefObj_CFURLCopyQueryString
, 1,
3453 PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")},
3454 {"CFURLCopyFragment", (PyCFunction
)CFURLRefObj_CFURLCopyFragment
, 1,
3455 PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")},
3456 {"CFURLCopyLastPathComponent", (PyCFunction
)CFURLRefObj_CFURLCopyLastPathComponent
, 1,
3457 PyDoc_STR("() -> (CFStringRef _rv)")},
3458 {"CFURLCopyPathExtension", (PyCFunction
)CFURLRefObj_CFURLCopyPathExtension
, 1,
3459 PyDoc_STR("() -> (CFStringRef _rv)")},
3460 {"CFURLCreateCopyAppendingPathComponent", (PyCFunction
)CFURLRefObj_CFURLCreateCopyAppendingPathComponent
, 1,
3461 PyDoc_STR("(CFStringRef pathComponent, Boolean isDirectory) -> (CFURLRef _rv)")},
3462 {"CFURLCreateCopyDeletingLastPathComponent", (PyCFunction
)CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent
, 1,
3463 PyDoc_STR("() -> (CFURLRef _rv)")},
3464 {"CFURLCreateCopyAppendingPathExtension", (PyCFunction
)CFURLRefObj_CFURLCreateCopyAppendingPathExtension
, 1,
3465 PyDoc_STR("(CFStringRef extension) -> (CFURLRef _rv)")},
3466 {"CFURLCreateCopyDeletingPathExtension", (PyCFunction
)CFURLRefObj_CFURLCreateCopyDeletingPathExtension
, 1,
3467 PyDoc_STR("() -> (CFURLRef _rv)")},
3468 {"CFURLGetFSRef", (PyCFunction
)CFURLRefObj_CFURLGetFSRef
, 1,
3469 PyDoc_STR("() -> (Boolean _rv, FSRef fsRef)")},
3473 #define CFURLRefObj_getsetlist NULL
3476 static int CFURLRefObj_compare(CFURLRefObject
*self
, CFURLRefObject
*other
)
3478 /* XXXX Or should we use CFEqual?? */
3479 if ( self
->ob_itself
> other
->ob_itself
) return 1;
3480 if ( self
->ob_itself
< other
->ob_itself
) return -1;
3484 static PyObject
* CFURLRefObj_repr(CFURLRefObject
*self
)
3487 sprintf(buf
, "<CFURL object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
3488 return PyString_FromString(buf
);
3491 static int CFURLRefObj_hash(CFURLRefObject
*self
)
3493 /* XXXX Or should we use CFHash?? */
3494 return (int)self
->ob_itself
;
3496 static int CFURLRefObj_tp_init(PyObject
*_self
, PyObject
*_args
, PyObject
*_kwds
)
3499 char *kw
[] = {"itself", 0};
3501 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFURLRefObj_Convert
, &itself
))
3503 ((CFURLRefObject
*)_self
)->ob_itself
= itself
;
3507 /* Any CFTypeRef descendent is allowed as initializer too */
3508 if (PyArg_ParseTupleAndKeywords(_args
, _kwds
, "O&", kw
, CFTypeRefObj_Convert
, &itself
))
3510 ((CFURLRefObject
*)_self
)->ob_itself
= itself
;
3516 #define CFURLRefObj_tp_alloc PyType_GenericAlloc
3518 static PyObject
*CFURLRefObj_tp_new(PyTypeObject
*type
, PyObject
*_args
, PyObject
*_kwds
)
3521 if ((self
= type
->tp_alloc(type
, 0)) == NULL
) return NULL
;
3522 ((CFURLRefObject
*)self
)->ob_itself
= NULL
;
3523 ((CFURLRefObject
*)self
)->ob_freeit
= CFRelease
;
3527 #define CFURLRefObj_tp_free PyObject_Del
3530 PyTypeObject CFURLRef_Type
= {
3531 PyObject_HEAD_INIT(NULL
)
3533 "_CF.CFURLRef", /*tp_name*/
3534 sizeof(CFURLRefObject
), /*tp_basicsize*/
3537 (destructor
) CFURLRefObj_dealloc
, /*tp_dealloc*/
3539 (getattrfunc
)0, /*tp_getattr*/
3540 (setattrfunc
)0, /*tp_setattr*/
3541 (cmpfunc
) CFURLRefObj_compare
, /*tp_compare*/
3542 (reprfunc
) CFURLRefObj_repr
, /*tp_repr*/
3543 (PyNumberMethods
*)0, /* tp_as_number */
3544 (PySequenceMethods
*)0, /* tp_as_sequence */
3545 (PyMappingMethods
*)0, /* tp_as_mapping */
3546 (hashfunc
) CFURLRefObj_hash
, /*tp_hash*/
3549 PyObject_GenericGetAttr
, /*tp_getattro*/
3550 PyObject_GenericSetAttr
, /*tp_setattro */
3552 Py_TPFLAGS_DEFAULT
|Py_TPFLAGS_BASETYPE
, /* tp_flags */
3556 0, /*tp_richcompare*/
3557 0, /*tp_weaklistoffset*/
3560 CFURLRefObj_methods
, /* tp_methods */
3562 CFURLRefObj_getsetlist
, /*tp_getset*/
3567 0, /*tp_dictoffset*/
3568 CFURLRefObj_tp_init
, /* tp_init */
3569 CFURLRefObj_tp_alloc
, /* tp_alloc */
3570 CFURLRefObj_tp_new
, /* tp_new */
3571 CFURLRefObj_tp_free
, /* tp_free */
3574 /* -------------------- End object type CFURLRef -------------------- */
3577 static PyObject
*CF___CFRangeMake(PyObject
*_self
, PyObject
*_args
)
3579 PyObject
*_res
= NULL
;
3583 #ifndef __CFRangeMake
3584 PyMac_PRECHECK(__CFRangeMake
);
3586 if (!PyArg_ParseTuple(_args
, "ll",
3590 _rv
= __CFRangeMake(loc
,
3592 _res
= Py_BuildValue("O&",
3597 static PyObject
*CF_CFAllocatorGetTypeID(PyObject
*_self
, PyObject
*_args
)
3599 PyObject
*_res
= NULL
;
3601 #ifndef CFAllocatorGetTypeID
3602 PyMac_PRECHECK(CFAllocatorGetTypeID
);
3604 if (!PyArg_ParseTuple(_args
, ""))
3606 _rv
= CFAllocatorGetTypeID();
3607 _res
= Py_BuildValue("l",
3612 static PyObject
*CF_CFAllocatorGetPreferredSizeForSize(PyObject
*_self
, PyObject
*_args
)
3614 PyObject
*_res
= NULL
;
3618 #ifndef CFAllocatorGetPreferredSizeForSize
3619 PyMac_PRECHECK(CFAllocatorGetPreferredSizeForSize
);
3621 if (!PyArg_ParseTuple(_args
, "ll",
3625 _rv
= CFAllocatorGetPreferredSizeForSize((CFAllocatorRef
)NULL
,
3628 _res
= Py_BuildValue("l",
3633 static PyObject
*CF_CFCopyTypeIDDescription(PyObject
*_self
, PyObject
*_args
)
3635 PyObject
*_res
= NULL
;
3638 #ifndef CFCopyTypeIDDescription
3639 PyMac_PRECHECK(CFCopyTypeIDDescription
);
3641 if (!PyArg_ParseTuple(_args
, "l",
3644 _rv
= CFCopyTypeIDDescription(type_id
);
3645 _res
= Py_BuildValue("O&",
3646 CFStringRefObj_New
, _rv
);
3650 static PyObject
*CF_CFArrayGetTypeID(PyObject
*_self
, PyObject
*_args
)
3652 PyObject
*_res
= NULL
;
3654 #ifndef CFArrayGetTypeID
3655 PyMac_PRECHECK(CFArrayGetTypeID
);
3657 if (!PyArg_ParseTuple(_args
, ""))
3659 _rv
= CFArrayGetTypeID();
3660 _res
= Py_BuildValue("l",
3665 static PyObject
*CF_CFArrayCreateMutable(PyObject
*_self
, PyObject
*_args
)
3667 PyObject
*_res
= NULL
;
3668 CFMutableArrayRef _rv
;
3670 #ifndef CFArrayCreateMutable
3671 PyMac_PRECHECK(CFArrayCreateMutable
);
3673 if (!PyArg_ParseTuple(_args
, "l",
3676 _rv
= CFArrayCreateMutable((CFAllocatorRef
)NULL
,
3678 &kCFTypeArrayCallBacks
);
3679 _res
= Py_BuildValue("O&",
3680 CFMutableArrayRefObj_New
, _rv
);
3684 static PyObject
*CF_CFArrayCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3686 PyObject
*_res
= NULL
;
3687 CFMutableArrayRef _rv
;
3689 CFArrayRef theArray
;
3690 #ifndef CFArrayCreateMutableCopy
3691 PyMac_PRECHECK(CFArrayCreateMutableCopy
);
3693 if (!PyArg_ParseTuple(_args
, "lO&",
3695 CFArrayRefObj_Convert
, &theArray
))
3697 _rv
= CFArrayCreateMutableCopy((CFAllocatorRef
)NULL
,
3700 _res
= Py_BuildValue("O&",
3701 CFMutableArrayRefObj_New
, _rv
);
3705 static PyObject
*CF_CFDataGetTypeID(PyObject
*_self
, PyObject
*_args
)
3707 PyObject
*_res
= NULL
;
3709 #ifndef CFDataGetTypeID
3710 PyMac_PRECHECK(CFDataGetTypeID
);
3712 if (!PyArg_ParseTuple(_args
, ""))
3714 _rv
= CFDataGetTypeID();
3715 _res
= Py_BuildValue("l",
3720 static PyObject
*CF_CFDataCreate(PyObject
*_self
, PyObject
*_args
)
3722 PyObject
*_res
= NULL
;
3724 unsigned char *bytes__in__
;
3726 int bytes__in_len__
;
3727 #ifndef CFDataCreate
3728 PyMac_PRECHECK(CFDataCreate
);
3730 if (!PyArg_ParseTuple(_args
, "s#",
3731 &bytes__in__
, &bytes__in_len__
))
3733 bytes__len__
= bytes__in_len__
;
3734 _rv
= CFDataCreate((CFAllocatorRef
)NULL
,
3735 bytes__in__
, bytes__len__
);
3736 _res
= Py_BuildValue("O&",
3737 CFDataRefObj_New
, _rv
);
3741 static PyObject
*CF_CFDataCreateWithBytesNoCopy(PyObject
*_self
, PyObject
*_args
)
3743 PyObject
*_res
= NULL
;
3745 unsigned char *bytes__in__
;
3747 int bytes__in_len__
;
3748 #ifndef CFDataCreateWithBytesNoCopy
3749 PyMac_PRECHECK(CFDataCreateWithBytesNoCopy
);
3751 if (!PyArg_ParseTuple(_args
, "s#",
3752 &bytes__in__
, &bytes__in_len__
))
3754 bytes__len__
= bytes__in_len__
;
3755 _rv
= CFDataCreateWithBytesNoCopy((CFAllocatorRef
)NULL
,
3756 bytes__in__
, bytes__len__
,
3757 (CFAllocatorRef
)NULL
);
3758 _res
= Py_BuildValue("O&",
3759 CFDataRefObj_New
, _rv
);
3763 static PyObject
*CF_CFDataCreateMutable(PyObject
*_self
, PyObject
*_args
)
3765 PyObject
*_res
= NULL
;
3766 CFMutableDataRef _rv
;
3768 #ifndef CFDataCreateMutable
3769 PyMac_PRECHECK(CFDataCreateMutable
);
3771 if (!PyArg_ParseTuple(_args
, "l",
3774 _rv
= CFDataCreateMutable((CFAllocatorRef
)NULL
,
3776 _res
= Py_BuildValue("O&",
3777 CFMutableDataRefObj_New
, _rv
);
3781 static PyObject
*CF_CFDataCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3783 PyObject
*_res
= NULL
;
3784 CFMutableDataRef _rv
;
3787 #ifndef CFDataCreateMutableCopy
3788 PyMac_PRECHECK(CFDataCreateMutableCopy
);
3790 if (!PyArg_ParseTuple(_args
, "lO&",
3792 CFDataRefObj_Convert
, &theData
))
3794 _rv
= CFDataCreateMutableCopy((CFAllocatorRef
)NULL
,
3797 _res
= Py_BuildValue("O&",
3798 CFMutableDataRefObj_New
, _rv
);
3802 static PyObject
*CF_CFDictionaryGetTypeID(PyObject
*_self
, PyObject
*_args
)
3804 PyObject
*_res
= NULL
;
3806 #ifndef CFDictionaryGetTypeID
3807 PyMac_PRECHECK(CFDictionaryGetTypeID
);
3809 if (!PyArg_ParseTuple(_args
, ""))
3811 _rv
= CFDictionaryGetTypeID();
3812 _res
= Py_BuildValue("l",
3817 static PyObject
*CF_CFDictionaryCreateMutable(PyObject
*_self
, PyObject
*_args
)
3819 PyObject
*_res
= NULL
;
3820 CFMutableDictionaryRef _rv
;
3822 #ifndef CFDictionaryCreateMutable
3823 PyMac_PRECHECK(CFDictionaryCreateMutable
);
3825 if (!PyArg_ParseTuple(_args
, "l",
3828 _rv
= CFDictionaryCreateMutable((CFAllocatorRef
)NULL
,
3830 &kCFTypeDictionaryKeyCallBacks
,
3831 &kCFTypeDictionaryValueCallBacks
);
3832 _res
= Py_BuildValue("O&",
3833 CFMutableDictionaryRefObj_New
, _rv
);
3837 static PyObject
*CF_CFDictionaryCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3839 PyObject
*_res
= NULL
;
3840 CFMutableDictionaryRef _rv
;
3842 CFDictionaryRef theDict
;
3843 #ifndef CFDictionaryCreateMutableCopy
3844 PyMac_PRECHECK(CFDictionaryCreateMutableCopy
);
3846 if (!PyArg_ParseTuple(_args
, "lO&",
3848 CFDictionaryRefObj_Convert
, &theDict
))
3850 _rv
= CFDictionaryCreateMutableCopy((CFAllocatorRef
)NULL
,
3853 _res
= Py_BuildValue("O&",
3854 CFMutableDictionaryRefObj_New
, _rv
);
3858 static PyObject
*CF_CFPreferencesCopyAppValue(PyObject
*_self
, PyObject
*_args
)
3860 PyObject
*_res
= NULL
;
3863 CFStringRef applicationID
;
3864 #ifndef CFPreferencesCopyAppValue
3865 PyMac_PRECHECK(CFPreferencesCopyAppValue
);
3867 if (!PyArg_ParseTuple(_args
, "O&O&",
3868 CFStringRefObj_Convert
, &key
,
3869 CFStringRefObj_Convert
, &applicationID
))
3871 _rv
= CFPreferencesCopyAppValue(key
,
3873 _res
= Py_BuildValue("O&",
3874 CFTypeRefObj_New
, _rv
);
3878 static PyObject
*CF_CFPreferencesGetAppBooleanValue(PyObject
*_self
, PyObject
*_args
)
3880 PyObject
*_res
= NULL
;
3883 CFStringRef applicationID
;
3884 Boolean keyExistsAndHasValidFormat
;
3885 #ifndef CFPreferencesGetAppBooleanValue
3886 PyMac_PRECHECK(CFPreferencesGetAppBooleanValue
);
3888 if (!PyArg_ParseTuple(_args
, "O&O&",
3889 CFStringRefObj_Convert
, &key
,
3890 CFStringRefObj_Convert
, &applicationID
))
3892 _rv
= CFPreferencesGetAppBooleanValue(key
,
3894 &keyExistsAndHasValidFormat
);
3895 _res
= Py_BuildValue("ll",
3897 keyExistsAndHasValidFormat
);
3901 static PyObject
*CF_CFPreferencesGetAppIntegerValue(PyObject
*_self
, PyObject
*_args
)
3903 PyObject
*_res
= NULL
;
3906 CFStringRef applicationID
;
3907 Boolean keyExistsAndHasValidFormat
;
3908 #ifndef CFPreferencesGetAppIntegerValue
3909 PyMac_PRECHECK(CFPreferencesGetAppIntegerValue
);
3911 if (!PyArg_ParseTuple(_args
, "O&O&",
3912 CFStringRefObj_Convert
, &key
,
3913 CFStringRefObj_Convert
, &applicationID
))
3915 _rv
= CFPreferencesGetAppIntegerValue(key
,
3917 &keyExistsAndHasValidFormat
);
3918 _res
= Py_BuildValue("ll",
3920 keyExistsAndHasValidFormat
);
3924 static PyObject
*CF_CFPreferencesSetAppValue(PyObject
*_self
, PyObject
*_args
)
3926 PyObject
*_res
= NULL
;
3929 CFStringRef applicationID
;
3930 #ifndef CFPreferencesSetAppValue
3931 PyMac_PRECHECK(CFPreferencesSetAppValue
);
3933 if (!PyArg_ParseTuple(_args
, "O&O&O&",
3934 CFStringRefObj_Convert
, &key
,
3935 CFTypeRefObj_Convert
, &value
,
3936 CFStringRefObj_Convert
, &applicationID
))
3938 CFPreferencesSetAppValue(key
,
3946 static PyObject
*CF_CFPreferencesAddSuitePreferencesToApp(PyObject
*_self
, PyObject
*_args
)
3948 PyObject
*_res
= NULL
;
3949 CFStringRef applicationID
;
3950 CFStringRef suiteID
;
3951 #ifndef CFPreferencesAddSuitePreferencesToApp
3952 PyMac_PRECHECK(CFPreferencesAddSuitePreferencesToApp
);
3954 if (!PyArg_ParseTuple(_args
, "O&O&",
3955 CFStringRefObj_Convert
, &applicationID
,
3956 CFStringRefObj_Convert
, &suiteID
))
3958 CFPreferencesAddSuitePreferencesToApp(applicationID
,
3965 static PyObject
*CF_CFPreferencesRemoveSuitePreferencesFromApp(PyObject
*_self
, PyObject
*_args
)
3967 PyObject
*_res
= NULL
;
3968 CFStringRef applicationID
;
3969 CFStringRef suiteID
;
3970 #ifndef CFPreferencesRemoveSuitePreferencesFromApp
3971 PyMac_PRECHECK(CFPreferencesRemoveSuitePreferencesFromApp
);
3973 if (!PyArg_ParseTuple(_args
, "O&O&",
3974 CFStringRefObj_Convert
, &applicationID
,
3975 CFStringRefObj_Convert
, &suiteID
))
3977 CFPreferencesRemoveSuitePreferencesFromApp(applicationID
,
3984 static PyObject
*CF_CFPreferencesAppSynchronize(PyObject
*_self
, PyObject
*_args
)
3986 PyObject
*_res
= NULL
;
3988 CFStringRef applicationID
;
3989 #ifndef CFPreferencesAppSynchronize
3990 PyMac_PRECHECK(CFPreferencesAppSynchronize
);
3992 if (!PyArg_ParseTuple(_args
, "O&",
3993 CFStringRefObj_Convert
, &applicationID
))
3995 _rv
= CFPreferencesAppSynchronize(applicationID
);
3996 _res
= Py_BuildValue("l",
4001 static PyObject
*CF_CFPreferencesCopyValue(PyObject
*_self
, PyObject
*_args
)
4003 PyObject
*_res
= NULL
;
4006 CFStringRef applicationID
;
4007 CFStringRef userName
;
4008 CFStringRef hostName
;
4009 #ifndef CFPreferencesCopyValue
4010 PyMac_PRECHECK(CFPreferencesCopyValue
);
4012 if (!PyArg_ParseTuple(_args
, "O&O&O&O&",
4013 CFStringRefObj_Convert
, &key
,
4014 CFStringRefObj_Convert
, &applicationID
,
4015 CFStringRefObj_Convert
, &userName
,
4016 CFStringRefObj_Convert
, &hostName
))
4018 _rv
= CFPreferencesCopyValue(key
,
4022 _res
= Py_BuildValue("O&",
4023 CFTypeRefObj_New
, _rv
);
4027 static PyObject
*CF_CFPreferencesCopyMultiple(PyObject
*_self
, PyObject
*_args
)
4029 PyObject
*_res
= NULL
;
4030 CFDictionaryRef _rv
;
4031 CFArrayRef keysToFetch
;
4032 CFStringRef applicationID
;
4033 CFStringRef userName
;
4034 CFStringRef hostName
;
4035 #ifndef CFPreferencesCopyMultiple
4036 PyMac_PRECHECK(CFPreferencesCopyMultiple
);
4038 if (!PyArg_ParseTuple(_args
, "O&O&O&O&",
4039 CFArrayRefObj_Convert
, &keysToFetch
,
4040 CFStringRefObj_Convert
, &applicationID
,
4041 CFStringRefObj_Convert
, &userName
,
4042 CFStringRefObj_Convert
, &hostName
))
4044 _rv
= CFPreferencesCopyMultiple(keysToFetch
,
4048 _res
= Py_BuildValue("O&",
4049 CFDictionaryRefObj_New
, _rv
);
4053 static PyObject
*CF_CFPreferencesSetValue(PyObject
*_self
, PyObject
*_args
)
4055 PyObject
*_res
= NULL
;
4058 CFStringRef applicationID
;
4059 CFStringRef userName
;
4060 CFStringRef hostName
;
4061 #ifndef CFPreferencesSetValue
4062 PyMac_PRECHECK(CFPreferencesSetValue
);
4064 if (!PyArg_ParseTuple(_args
, "O&O&O&O&O&",
4065 CFStringRefObj_Convert
, &key
,
4066 CFTypeRefObj_Convert
, &value
,
4067 CFStringRefObj_Convert
, &applicationID
,
4068 CFStringRefObj_Convert
, &userName
,
4069 CFStringRefObj_Convert
, &hostName
))
4071 CFPreferencesSetValue(key
,
4081 static PyObject
*CF_CFPreferencesSetMultiple(PyObject
*_self
, PyObject
*_args
)
4083 PyObject
*_res
= NULL
;
4084 CFDictionaryRef keysToSet
;
4085 CFArrayRef keysToRemove
;
4086 CFStringRef applicationID
;
4087 CFStringRef userName
;
4088 CFStringRef hostName
;
4089 #ifndef CFPreferencesSetMultiple
4090 PyMac_PRECHECK(CFPreferencesSetMultiple
);
4092 if (!PyArg_ParseTuple(_args
, "O&O&O&O&O&",
4093 CFDictionaryRefObj_Convert
, &keysToSet
,
4094 CFArrayRefObj_Convert
, &keysToRemove
,
4095 CFStringRefObj_Convert
, &applicationID
,
4096 CFStringRefObj_Convert
, &userName
,
4097 CFStringRefObj_Convert
, &hostName
))
4099 CFPreferencesSetMultiple(keysToSet
,
4109 static PyObject
*CF_CFPreferencesSynchronize(PyObject
*_self
, PyObject
*_args
)
4111 PyObject
*_res
= NULL
;
4113 CFStringRef applicationID
;
4114 CFStringRef userName
;
4115 CFStringRef hostName
;
4116 #ifndef CFPreferencesSynchronize
4117 PyMac_PRECHECK(CFPreferencesSynchronize
);
4119 if (!PyArg_ParseTuple(_args
, "O&O&O&",
4120 CFStringRefObj_Convert
, &applicationID
,
4121 CFStringRefObj_Convert
, &userName
,
4122 CFStringRefObj_Convert
, &hostName
))
4124 _rv
= CFPreferencesSynchronize(applicationID
,
4127 _res
= Py_BuildValue("l",
4132 static PyObject
*CF_CFPreferencesCopyApplicationList(PyObject
*_self
, PyObject
*_args
)
4134 PyObject
*_res
= NULL
;
4136 CFStringRef userName
;
4137 CFStringRef hostName
;
4138 #ifndef CFPreferencesCopyApplicationList
4139 PyMac_PRECHECK(CFPreferencesCopyApplicationList
);
4141 if (!PyArg_ParseTuple(_args
, "O&O&",
4142 CFStringRefObj_Convert
, &userName
,
4143 CFStringRefObj_Convert
, &hostName
))
4145 _rv
= CFPreferencesCopyApplicationList(userName
,
4147 _res
= Py_BuildValue("O&",
4148 CFArrayRefObj_New
, _rv
);
4152 static PyObject
*CF_CFPreferencesCopyKeyList(PyObject
*_self
, PyObject
*_args
)
4154 PyObject
*_res
= NULL
;
4156 CFStringRef applicationID
;
4157 CFStringRef userName
;
4158 CFStringRef hostName
;
4159 #ifndef CFPreferencesCopyKeyList
4160 PyMac_PRECHECK(CFPreferencesCopyKeyList
);
4162 if (!PyArg_ParseTuple(_args
, "O&O&O&",
4163 CFStringRefObj_Convert
, &applicationID
,
4164 CFStringRefObj_Convert
, &userName
,
4165 CFStringRefObj_Convert
, &hostName
))
4167 _rv
= CFPreferencesCopyKeyList(applicationID
,
4170 _res
= Py_BuildValue("O&",
4171 CFArrayRefObj_New
, _rv
);
4175 static PyObject
*CF_CFStringGetTypeID(PyObject
*_self
, PyObject
*_args
)
4177 PyObject
*_res
= NULL
;
4179 #ifndef CFStringGetTypeID
4180 PyMac_PRECHECK(CFStringGetTypeID
);
4182 if (!PyArg_ParseTuple(_args
, ""))
4184 _rv
= CFStringGetTypeID();
4185 _res
= Py_BuildValue("l",
4190 static PyObject
*CF_CFStringCreateWithPascalString(PyObject
*_self
, PyObject
*_args
)
4192 PyObject
*_res
= NULL
;
4195 CFStringEncoding encoding
;
4196 #ifndef CFStringCreateWithPascalString
4197 PyMac_PRECHECK(CFStringCreateWithPascalString
);
4199 if (!PyArg_ParseTuple(_args
, "O&l",
4200 PyMac_GetStr255
, pStr
,
4203 _rv
= CFStringCreateWithPascalString((CFAllocatorRef
)NULL
,
4206 _res
= Py_BuildValue("O&",
4207 CFStringRefObj_New
, _rv
);
4211 static PyObject
*CF_CFStringCreateWithCString(PyObject
*_self
, PyObject
*_args
)
4213 PyObject
*_res
= NULL
;
4216 CFStringEncoding encoding
;
4217 #ifndef CFStringCreateWithCString
4218 PyMac_PRECHECK(CFStringCreateWithCString
);
4220 if (!PyArg_ParseTuple(_args
, "sl",
4224 _rv
= CFStringCreateWithCString((CFAllocatorRef
)NULL
,
4227 _res
= Py_BuildValue("O&",
4228 CFStringRefObj_New
, _rv
);
4232 static PyObject
*CF_CFStringCreateWithCharacters(PyObject
*_self
, PyObject
*_args
)
4234 PyObject
*_res
= NULL
;
4236 UniChar
*chars__in__
;
4237 UniCharCount chars__len__
;
4238 int chars__in_len__
;
4239 #ifndef CFStringCreateWithCharacters
4240 PyMac_PRECHECK(CFStringCreateWithCharacters
);
4242 if (!PyArg_ParseTuple(_args
, "u#",
4243 &chars__in__
, &chars__in_len__
))
4245 chars__len__
= chars__in_len__
;
4246 _rv
= CFStringCreateWithCharacters((CFAllocatorRef
)NULL
,
4247 chars__in__
, chars__len__
);
4248 _res
= Py_BuildValue("O&",
4249 CFStringRefObj_New
, _rv
);
4253 static PyObject
*CF_CFStringCreateWithPascalStringNoCopy(PyObject
*_self
, PyObject
*_args
)
4255 PyObject
*_res
= NULL
;
4258 CFStringEncoding encoding
;
4259 #ifndef CFStringCreateWithPascalStringNoCopy
4260 PyMac_PRECHECK(CFStringCreateWithPascalStringNoCopy
);
4262 if (!PyArg_ParseTuple(_args
, "O&l",
4263 PyMac_GetStr255
, pStr
,
4266 _rv
= CFStringCreateWithPascalStringNoCopy((CFAllocatorRef
)NULL
,
4269 (CFAllocatorRef
)NULL
);
4270 _res
= Py_BuildValue("O&",
4271 CFStringRefObj_New
, _rv
);
4275 static PyObject
*CF_CFStringCreateWithCStringNoCopy(PyObject
*_self
, PyObject
*_args
)
4277 PyObject
*_res
= NULL
;
4280 CFStringEncoding encoding
;
4281 #ifndef CFStringCreateWithCStringNoCopy
4282 PyMac_PRECHECK(CFStringCreateWithCStringNoCopy
);
4284 if (!PyArg_ParseTuple(_args
, "sl",
4288 _rv
= CFStringCreateWithCStringNoCopy((CFAllocatorRef
)NULL
,
4291 (CFAllocatorRef
)NULL
);
4292 _res
= Py_BuildValue("O&",
4293 CFStringRefObj_New
, _rv
);
4297 static PyObject
*CF_CFStringCreateWithCharactersNoCopy(PyObject
*_self
, PyObject
*_args
)
4299 PyObject
*_res
= NULL
;
4301 UniChar
*chars__in__
;
4302 UniCharCount chars__len__
;
4303 int chars__in_len__
;
4304 #ifndef CFStringCreateWithCharactersNoCopy
4305 PyMac_PRECHECK(CFStringCreateWithCharactersNoCopy
);
4307 if (!PyArg_ParseTuple(_args
, "u#",
4308 &chars__in__
, &chars__in_len__
))
4310 chars__len__
= chars__in_len__
;
4311 _rv
= CFStringCreateWithCharactersNoCopy((CFAllocatorRef
)NULL
,
4312 chars__in__
, chars__len__
,
4313 (CFAllocatorRef
)NULL
);
4314 _res
= Py_BuildValue("O&",
4315 CFStringRefObj_New
, _rv
);
4319 static PyObject
*CF_CFStringCreateMutable(PyObject
*_self
, PyObject
*_args
)
4321 PyObject
*_res
= NULL
;
4322 CFMutableStringRef _rv
;
4324 #ifndef CFStringCreateMutable
4325 PyMac_PRECHECK(CFStringCreateMutable
);
4327 if (!PyArg_ParseTuple(_args
, "l",
4330 _rv
= CFStringCreateMutable((CFAllocatorRef
)NULL
,
4332 _res
= Py_BuildValue("O&",
4333 CFMutableStringRefObj_New
, _rv
);
4337 static PyObject
*CF_CFStringCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
4339 PyObject
*_res
= NULL
;
4340 CFMutableStringRef _rv
;
4342 CFStringRef theString
;
4343 #ifndef CFStringCreateMutableCopy
4344 PyMac_PRECHECK(CFStringCreateMutableCopy
);
4346 if (!PyArg_ParseTuple(_args
, "lO&",
4348 CFStringRefObj_Convert
, &theString
))
4350 _rv
= CFStringCreateMutableCopy((CFAllocatorRef
)NULL
,
4353 _res
= Py_BuildValue("O&",
4354 CFMutableStringRefObj_New
, _rv
);
4358 static PyObject
*CF_CFStringCreateWithBytes(PyObject
*_self
, PyObject
*_args
)
4360 PyObject
*_res
= NULL
;
4362 unsigned char *bytes__in__
;
4364 int bytes__in_len__
;
4365 CFStringEncoding encoding
;
4366 Boolean isExternalRepresentation
;
4367 #ifndef CFStringCreateWithBytes
4368 PyMac_PRECHECK(CFStringCreateWithBytes
);
4370 if (!PyArg_ParseTuple(_args
, "s#ll",
4371 &bytes__in__
, &bytes__in_len__
,
4373 &isExternalRepresentation
))
4375 bytes__len__
= bytes__in_len__
;
4376 _rv
= CFStringCreateWithBytes((CFAllocatorRef
)NULL
,
4377 bytes__in__
, bytes__len__
,
4379 isExternalRepresentation
);
4380 _res
= Py_BuildValue("O&",
4381 CFStringRefObj_New
, _rv
);
4385 static PyObject
*CF_CFStringGetSystemEncoding(PyObject
*_self
, PyObject
*_args
)
4387 PyObject
*_res
= NULL
;
4388 CFStringEncoding _rv
;
4389 #ifndef CFStringGetSystemEncoding
4390 PyMac_PRECHECK(CFStringGetSystemEncoding
);
4392 if (!PyArg_ParseTuple(_args
, ""))
4394 _rv
= CFStringGetSystemEncoding();
4395 _res
= Py_BuildValue("l",
4400 static PyObject
*CF_CFStringGetMaximumSizeForEncoding(PyObject
*_self
, PyObject
*_args
)
4402 PyObject
*_res
= NULL
;
4405 CFStringEncoding encoding
;
4406 #ifndef CFStringGetMaximumSizeForEncoding
4407 PyMac_PRECHECK(CFStringGetMaximumSizeForEncoding
);
4409 if (!PyArg_ParseTuple(_args
, "ll",
4413 _rv
= CFStringGetMaximumSizeForEncoding(length
,
4415 _res
= Py_BuildValue("l",
4420 static PyObject
*CF_CFStringIsEncodingAvailable(PyObject
*_self
, PyObject
*_args
)
4422 PyObject
*_res
= NULL
;
4424 CFStringEncoding encoding
;
4425 #ifndef CFStringIsEncodingAvailable
4426 PyMac_PRECHECK(CFStringIsEncodingAvailable
);
4428 if (!PyArg_ParseTuple(_args
, "l",
4431 _rv
= CFStringIsEncodingAvailable(encoding
);
4432 _res
= Py_BuildValue("l",
4437 static PyObject
*CF_CFStringGetNameOfEncoding(PyObject
*_self
, PyObject
*_args
)
4439 PyObject
*_res
= NULL
;
4441 CFStringEncoding encoding
;
4442 #ifndef CFStringGetNameOfEncoding
4443 PyMac_PRECHECK(CFStringGetNameOfEncoding
);
4445 if (!PyArg_ParseTuple(_args
, "l",
4448 _rv
= CFStringGetNameOfEncoding(encoding
);
4449 _res
= Py_BuildValue("O&",
4450 CFStringRefObj_New
, _rv
);
4454 static PyObject
*CF_CFStringConvertEncodingToNSStringEncoding(PyObject
*_self
, PyObject
*_args
)
4456 PyObject
*_res
= NULL
;
4458 CFStringEncoding encoding
;
4459 #ifndef CFStringConvertEncodingToNSStringEncoding
4460 PyMac_PRECHECK(CFStringConvertEncodingToNSStringEncoding
);
4462 if (!PyArg_ParseTuple(_args
, "l",
4465 _rv
= CFStringConvertEncodingToNSStringEncoding(encoding
);
4466 _res
= Py_BuildValue("l",
4471 static PyObject
*CF_CFStringConvertNSStringEncodingToEncoding(PyObject
*_self
, PyObject
*_args
)
4473 PyObject
*_res
= NULL
;
4474 CFStringEncoding _rv
;
4476 #ifndef CFStringConvertNSStringEncodingToEncoding
4477 PyMac_PRECHECK(CFStringConvertNSStringEncodingToEncoding
);
4479 if (!PyArg_ParseTuple(_args
, "l",
4482 _rv
= CFStringConvertNSStringEncodingToEncoding(encoding
);
4483 _res
= Py_BuildValue("l",
4488 static PyObject
*CF_CFStringConvertEncodingToWindowsCodepage(PyObject
*_self
, PyObject
*_args
)
4490 PyObject
*_res
= NULL
;
4492 CFStringEncoding encoding
;
4493 #ifndef CFStringConvertEncodingToWindowsCodepage
4494 PyMac_PRECHECK(CFStringConvertEncodingToWindowsCodepage
);
4496 if (!PyArg_ParseTuple(_args
, "l",
4499 _rv
= CFStringConvertEncodingToWindowsCodepage(encoding
);
4500 _res
= Py_BuildValue("l",
4505 static PyObject
*CF_CFStringConvertWindowsCodepageToEncoding(PyObject
*_self
, PyObject
*_args
)
4507 PyObject
*_res
= NULL
;
4508 CFStringEncoding _rv
;
4510 #ifndef CFStringConvertWindowsCodepageToEncoding
4511 PyMac_PRECHECK(CFStringConvertWindowsCodepageToEncoding
);
4513 if (!PyArg_ParseTuple(_args
, "l",
4516 _rv
= CFStringConvertWindowsCodepageToEncoding(codepage
);
4517 _res
= Py_BuildValue("l",
4522 static PyObject
*CF_CFStringConvertEncodingToIANACharSetName(PyObject
*_self
, PyObject
*_args
)
4524 PyObject
*_res
= NULL
;
4526 CFStringEncoding encoding
;
4527 #ifndef CFStringConvertEncodingToIANACharSetName
4528 PyMac_PRECHECK(CFStringConvertEncodingToIANACharSetName
);
4530 if (!PyArg_ParseTuple(_args
, "l",
4533 _rv
= CFStringConvertEncodingToIANACharSetName(encoding
);
4534 _res
= Py_BuildValue("O&",
4535 CFStringRefObj_New
, _rv
);
4539 static PyObject
*CF_CFStringGetMostCompatibleMacStringEncoding(PyObject
*_self
, PyObject
*_args
)
4541 PyObject
*_res
= NULL
;
4542 CFStringEncoding _rv
;
4543 CFStringEncoding encoding
;
4544 #ifndef CFStringGetMostCompatibleMacStringEncoding
4545 PyMac_PRECHECK(CFStringGetMostCompatibleMacStringEncoding
);
4547 if (!PyArg_ParseTuple(_args
, "l",
4550 _rv
= CFStringGetMostCompatibleMacStringEncoding(encoding
);
4551 _res
= Py_BuildValue("l",
4556 static PyObject
*CF___CFStringMakeConstantString(PyObject
*_self
, PyObject
*_args
)
4558 PyObject
*_res
= NULL
;
4561 #ifndef __CFStringMakeConstantString
4562 PyMac_PRECHECK(__CFStringMakeConstantString
);
4564 if (!PyArg_ParseTuple(_args
, "s",
4567 _rv
= __CFStringMakeConstantString(cStr
);
4568 _res
= Py_BuildValue("O&",
4569 CFStringRefObj_New
, _rv
);
4573 static PyObject
*CF_CFURLGetTypeID(PyObject
*_self
, PyObject
*_args
)
4575 PyObject
*_res
= NULL
;
4577 #ifndef CFURLGetTypeID
4578 PyMac_PRECHECK(CFURLGetTypeID
);
4580 if (!PyArg_ParseTuple(_args
, ""))
4582 _rv
= CFURLGetTypeID();
4583 _res
= Py_BuildValue("l",
4588 static PyObject
*CF_CFURLCreateWithBytes(PyObject
*_self
, PyObject
*_args
)
4590 PyObject
*_res
= NULL
;
4592 unsigned char *URLBytes__in__
;
4593 long URLBytes__len__
;
4594 int URLBytes__in_len__
;
4595 CFStringEncoding encoding
;
4597 #ifndef CFURLCreateWithBytes
4598 PyMac_PRECHECK(CFURLCreateWithBytes
);
4600 if (!PyArg_ParseTuple(_args
, "s#lO&",
4601 &URLBytes__in__
, &URLBytes__in_len__
,
4603 OptionalCFURLRefObj_Convert
, &baseURL
))
4605 URLBytes__len__
= URLBytes__in_len__
;
4606 _rv
= CFURLCreateWithBytes((CFAllocatorRef
)NULL
,
4607 URLBytes__in__
, URLBytes__len__
,
4610 _res
= Py_BuildValue("O&",
4611 CFURLRefObj_New
, _rv
);
4615 static PyObject
*CF_CFURLCreateFromFileSystemRepresentation(PyObject
*_self
, PyObject
*_args
)
4617 PyObject
*_res
= NULL
;
4619 unsigned char *buffer__in__
;
4621 int buffer__in_len__
;
4622 Boolean isDirectory
;
4623 #ifndef CFURLCreateFromFileSystemRepresentation
4624 PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentation
);
4626 if (!PyArg_ParseTuple(_args
, "s#l",
4627 &buffer__in__
, &buffer__in_len__
,
4630 buffer__len__
= buffer__in_len__
;
4631 _rv
= CFURLCreateFromFileSystemRepresentation((CFAllocatorRef
)NULL
,
4632 buffer__in__
, buffer__len__
,
4634 _res
= Py_BuildValue("O&",
4635 CFURLRefObj_New
, _rv
);
4639 static PyObject
*CF_CFURLCreateFromFileSystemRepresentationRelativeToBase(PyObject
*_self
, PyObject
*_args
)
4641 PyObject
*_res
= NULL
;
4643 unsigned char *buffer__in__
;
4645 int buffer__in_len__
;
4646 Boolean isDirectory
;
4648 #ifndef CFURLCreateFromFileSystemRepresentationRelativeToBase
4649 PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentationRelativeToBase
);
4651 if (!PyArg_ParseTuple(_args
, "s#lO&",
4652 &buffer__in__
, &buffer__in_len__
,
4654 OptionalCFURLRefObj_Convert
, &baseURL
))
4656 buffer__len__
= buffer__in_len__
;
4657 _rv
= CFURLCreateFromFileSystemRepresentationRelativeToBase((CFAllocatorRef
)NULL
,
4658 buffer__in__
, buffer__len__
,
4661 _res
= Py_BuildValue("O&",
4662 CFURLRefObj_New
, _rv
);
4666 static PyObject
*CF_CFURLCreateFromFSRef(PyObject
*_self
, PyObject
*_args
)
4668 PyObject
*_res
= NULL
;
4671 #ifndef CFURLCreateFromFSRef
4672 PyMac_PRECHECK(CFURLCreateFromFSRef
);
4674 if (!PyArg_ParseTuple(_args
, "O&",
4675 PyMac_GetFSRef
, &fsRef
))
4677 _rv
= CFURLCreateFromFSRef((CFAllocatorRef
)NULL
,
4679 _res
= Py_BuildValue("O&",
4680 CFURLRefObj_New
, _rv
);
4684 static PyObject
*CF_toCF(PyObject
*_self
, PyObject
*_args
)
4686 PyObject
*_res
= NULL
;
4691 if (!PyArg_ParseTuple(_args
, "O&", PyCF_Python2CF
, &rv
))
4693 typeid = CFGetTypeID(rv
);
4695 if (typeid == CFStringGetTypeID())
4696 return Py_BuildValue("O&", CFStringRefObj_New
, rv
);
4697 if (typeid == CFArrayGetTypeID())
4698 return Py_BuildValue("O&", CFArrayRefObj_New
, rv
);
4699 if (typeid == CFDictionaryGetTypeID())
4700 return Py_BuildValue("O&", CFDictionaryRefObj_New
, rv
);
4701 if (typeid == CFURLGetTypeID())
4702 return Py_BuildValue("O&", CFURLRefObj_New
, rv
);
4704 _res
= Py_BuildValue("O&", CFTypeRefObj_New
, rv
);
4709 static PyMethodDef CF_methods
[] = {
4710 {"__CFRangeMake", (PyCFunction
)CF___CFRangeMake
, 1,
4711 PyDoc_STR("(CFIndex loc, CFIndex len) -> (CFRange _rv)")},
4712 {"CFAllocatorGetTypeID", (PyCFunction
)CF_CFAllocatorGetTypeID
, 1,
4713 PyDoc_STR("() -> (CFTypeID _rv)")},
4714 {"CFAllocatorGetPreferredSizeForSize", (PyCFunction
)CF_CFAllocatorGetPreferredSizeForSize
, 1,
4715 PyDoc_STR("(CFIndex size, CFOptionFlags hint) -> (CFIndex _rv)")},
4716 {"CFCopyTypeIDDescription", (PyCFunction
)CF_CFCopyTypeIDDescription
, 1,
4717 PyDoc_STR("(CFTypeID type_id) -> (CFStringRef _rv)")},
4718 {"CFArrayGetTypeID", (PyCFunction
)CF_CFArrayGetTypeID
, 1,
4719 PyDoc_STR("() -> (CFTypeID _rv)")},
4720 {"CFArrayCreateMutable", (PyCFunction
)CF_CFArrayCreateMutable
, 1,
4721 PyDoc_STR("(CFIndex capacity) -> (CFMutableArrayRef _rv)")},
4722 {"CFArrayCreateMutableCopy", (PyCFunction
)CF_CFArrayCreateMutableCopy
, 1,
4723 PyDoc_STR("(CFIndex capacity, CFArrayRef theArray) -> (CFMutableArrayRef _rv)")},
4724 {"CFDataGetTypeID", (PyCFunction
)CF_CFDataGetTypeID
, 1,
4725 PyDoc_STR("() -> (CFTypeID _rv)")},
4726 {"CFDataCreate", (PyCFunction
)CF_CFDataCreate
, 1,
4727 PyDoc_STR("(Buffer bytes) -> (CFDataRef _rv)")},
4728 {"CFDataCreateWithBytesNoCopy", (PyCFunction
)CF_CFDataCreateWithBytesNoCopy
, 1,
4729 PyDoc_STR("(Buffer bytes) -> (CFDataRef _rv)")},
4730 {"CFDataCreateMutable", (PyCFunction
)CF_CFDataCreateMutable
, 1,
4731 PyDoc_STR("(CFIndex capacity) -> (CFMutableDataRef _rv)")},
4732 {"CFDataCreateMutableCopy", (PyCFunction
)CF_CFDataCreateMutableCopy
, 1,
4733 PyDoc_STR("(CFIndex capacity, CFDataRef theData) -> (CFMutableDataRef _rv)")},
4734 {"CFDictionaryGetTypeID", (PyCFunction
)CF_CFDictionaryGetTypeID
, 1,
4735 PyDoc_STR("() -> (CFTypeID _rv)")},
4736 {"CFDictionaryCreateMutable", (PyCFunction
)CF_CFDictionaryCreateMutable
, 1,
4737 PyDoc_STR("(CFIndex capacity) -> (CFMutableDictionaryRef _rv)")},
4738 {"CFDictionaryCreateMutableCopy", (PyCFunction
)CF_CFDictionaryCreateMutableCopy
, 1,
4739 PyDoc_STR("(CFIndex capacity, CFDictionaryRef theDict) -> (CFMutableDictionaryRef _rv)")},
4740 {"CFPreferencesCopyAppValue", (PyCFunction
)CF_CFPreferencesCopyAppValue
, 1,
4741 PyDoc_STR("(CFStringRef key, CFStringRef applicationID) -> (CFTypeRef _rv)")},
4742 {"CFPreferencesGetAppBooleanValue", (PyCFunction
)CF_CFPreferencesGetAppBooleanValue
, 1,
4743 PyDoc_STR("(CFStringRef key, CFStringRef applicationID) -> (Boolean _rv, Boolean keyExistsAndHasValidFormat)")},
4744 {"CFPreferencesGetAppIntegerValue", (PyCFunction
)CF_CFPreferencesGetAppIntegerValue
, 1,
4745 PyDoc_STR("(CFStringRef key, CFStringRef applicationID) -> (CFIndex _rv, Boolean keyExistsAndHasValidFormat)")},
4746 {"CFPreferencesSetAppValue", (PyCFunction
)CF_CFPreferencesSetAppValue
, 1,
4747 PyDoc_STR("(CFStringRef key, CFTypeRef value, CFStringRef applicationID) -> None")},
4748 {"CFPreferencesAddSuitePreferencesToApp", (PyCFunction
)CF_CFPreferencesAddSuitePreferencesToApp
, 1,
4749 PyDoc_STR("(CFStringRef applicationID, CFStringRef suiteID) -> None")},
4750 {"CFPreferencesRemoveSuitePreferencesFromApp", (PyCFunction
)CF_CFPreferencesRemoveSuitePreferencesFromApp
, 1,
4751 PyDoc_STR("(CFStringRef applicationID, CFStringRef suiteID) -> None")},
4752 {"CFPreferencesAppSynchronize", (PyCFunction
)CF_CFPreferencesAppSynchronize
, 1,
4753 PyDoc_STR("(CFStringRef applicationID) -> (Boolean _rv)")},
4754 {"CFPreferencesCopyValue", (PyCFunction
)CF_CFPreferencesCopyValue
, 1,
4755 PyDoc_STR("(CFStringRef key, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFTypeRef _rv)")},
4756 {"CFPreferencesCopyMultiple", (PyCFunction
)CF_CFPreferencesCopyMultiple
, 1,
4757 PyDoc_STR("(CFArrayRef keysToFetch, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFDictionaryRef _rv)")},
4758 {"CFPreferencesSetValue", (PyCFunction
)CF_CFPreferencesSetValue
, 1,
4759 PyDoc_STR("(CFStringRef key, CFTypeRef value, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None")},
4760 {"CFPreferencesSetMultiple", (PyCFunction
)CF_CFPreferencesSetMultiple
, 1,
4761 PyDoc_STR("(CFDictionaryRef keysToSet, CFArrayRef keysToRemove, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None")},
4762 {"CFPreferencesSynchronize", (PyCFunction
)CF_CFPreferencesSynchronize
, 1,
4763 PyDoc_STR("(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (Boolean _rv)")},
4764 {"CFPreferencesCopyApplicationList", (PyCFunction
)CF_CFPreferencesCopyApplicationList
, 1,
4765 PyDoc_STR("(CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)")},
4766 {"CFPreferencesCopyKeyList", (PyCFunction
)CF_CFPreferencesCopyKeyList
, 1,
4767 PyDoc_STR("(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)")},
4768 {"CFStringGetTypeID", (PyCFunction
)CF_CFStringGetTypeID
, 1,
4769 PyDoc_STR("() -> (CFTypeID _rv)")},
4770 {"CFStringCreateWithPascalString", (PyCFunction
)CF_CFStringCreateWithPascalString
, 1,
4771 PyDoc_STR("(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)")},
4772 {"CFStringCreateWithCString", (PyCFunction
)CF_CFStringCreateWithCString
, 1,
4773 PyDoc_STR("(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)")},
4774 {"CFStringCreateWithCharacters", (PyCFunction
)CF_CFStringCreateWithCharacters
, 1,
4775 PyDoc_STR("(Buffer chars) -> (CFStringRef _rv)")},
4776 {"CFStringCreateWithPascalStringNoCopy", (PyCFunction
)CF_CFStringCreateWithPascalStringNoCopy
, 1,
4777 PyDoc_STR("(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)")},
4778 {"CFStringCreateWithCStringNoCopy", (PyCFunction
)CF_CFStringCreateWithCStringNoCopy
, 1,
4779 PyDoc_STR("(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)")},
4780 {"CFStringCreateWithCharactersNoCopy", (PyCFunction
)CF_CFStringCreateWithCharactersNoCopy
, 1,
4781 PyDoc_STR("(Buffer chars) -> (CFStringRef _rv)")},
4782 {"CFStringCreateMutable", (PyCFunction
)CF_CFStringCreateMutable
, 1,
4783 PyDoc_STR("(CFIndex maxLength) -> (CFMutableStringRef _rv)")},
4784 {"CFStringCreateMutableCopy", (PyCFunction
)CF_CFStringCreateMutableCopy
, 1,
4785 PyDoc_STR("(CFIndex maxLength, CFStringRef theString) -> (CFMutableStringRef _rv)")},
4786 {"CFStringCreateWithBytes", (PyCFunction
)CF_CFStringCreateWithBytes
, 1,
4787 PyDoc_STR("(Buffer bytes, CFStringEncoding encoding, Boolean isExternalRepresentation) -> (CFStringRef _rv)")},
4788 {"CFStringGetSystemEncoding", (PyCFunction
)CF_CFStringGetSystemEncoding
, 1,
4789 PyDoc_STR("() -> (CFStringEncoding _rv)")},
4790 {"CFStringGetMaximumSizeForEncoding", (PyCFunction
)CF_CFStringGetMaximumSizeForEncoding
, 1,
4791 PyDoc_STR("(CFIndex length, CFStringEncoding encoding) -> (CFIndex _rv)")},
4792 {"CFStringIsEncodingAvailable", (PyCFunction
)CF_CFStringIsEncodingAvailable
, 1,
4793 PyDoc_STR("(CFStringEncoding encoding) -> (Boolean _rv)")},
4794 {"CFStringGetNameOfEncoding", (PyCFunction
)CF_CFStringGetNameOfEncoding
, 1,
4795 PyDoc_STR("(CFStringEncoding encoding) -> (CFStringRef _rv)")},
4796 {"CFStringConvertEncodingToNSStringEncoding", (PyCFunction
)CF_CFStringConvertEncodingToNSStringEncoding
, 1,
4797 PyDoc_STR("(CFStringEncoding encoding) -> (UInt32 _rv)")},
4798 {"CFStringConvertNSStringEncodingToEncoding", (PyCFunction
)CF_CFStringConvertNSStringEncodingToEncoding
, 1,
4799 PyDoc_STR("(UInt32 encoding) -> (CFStringEncoding _rv)")},
4800 {"CFStringConvertEncodingToWindowsCodepage", (PyCFunction
)CF_CFStringConvertEncodingToWindowsCodepage
, 1,
4801 PyDoc_STR("(CFStringEncoding encoding) -> (UInt32 _rv)")},
4802 {"CFStringConvertWindowsCodepageToEncoding", (PyCFunction
)CF_CFStringConvertWindowsCodepageToEncoding
, 1,
4803 PyDoc_STR("(UInt32 codepage) -> (CFStringEncoding _rv)")},
4804 {"CFStringConvertEncodingToIANACharSetName", (PyCFunction
)CF_CFStringConvertEncodingToIANACharSetName
, 1,
4805 PyDoc_STR("(CFStringEncoding encoding) -> (CFStringRef _rv)")},
4806 {"CFStringGetMostCompatibleMacStringEncoding", (PyCFunction
)CF_CFStringGetMostCompatibleMacStringEncoding
, 1,
4807 PyDoc_STR("(CFStringEncoding encoding) -> (CFStringEncoding _rv)")},
4808 {"__CFStringMakeConstantString", (PyCFunction
)CF___CFStringMakeConstantString
, 1,
4809 PyDoc_STR("(char* cStr) -> (CFStringRef _rv)")},
4810 {"CFURLGetTypeID", (PyCFunction
)CF_CFURLGetTypeID
, 1,
4811 PyDoc_STR("() -> (CFTypeID _rv)")},
4812 {"CFURLCreateWithBytes", (PyCFunction
)CF_CFURLCreateWithBytes
, 1,
4813 PyDoc_STR("(Buffer URLBytes, CFStringEncoding encoding, CFURLRef baseURL) -> (CFURLRef _rv)")},
4814 {"CFURLCreateFromFileSystemRepresentation", (PyCFunction
)CF_CFURLCreateFromFileSystemRepresentation
, 1,
4815 PyDoc_STR("(Buffer buffer, Boolean isDirectory) -> (CFURLRef _rv)")},
4816 {"CFURLCreateFromFileSystemRepresentationRelativeToBase", (PyCFunction
)CF_CFURLCreateFromFileSystemRepresentationRelativeToBase
, 1,
4817 PyDoc_STR("(Buffer buffer, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)")},
4818 {"CFURLCreateFromFSRef", (PyCFunction
)CF_CFURLCreateFromFSRef
, 1,
4819 PyDoc_STR("(FSRef fsRef) -> (CFURLRef _rv)")},
4820 {"toCF", (PyCFunction
)CF_toCF
, 1,
4821 PyDoc_STR("(python_object) -> (CF_object)")},
4828 /* Routines to convert any CF type to/from the corresponding CFxxxObj */
4829 PyObject
*CFObj_New(CFTypeRef itself
)
4833 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
4836 if (CFGetTypeID(itself
) == CFArrayGetTypeID()) return CFArrayRefObj_New((CFArrayRef
)itself
);
4837 if (CFGetTypeID(itself
) == CFDictionaryGetTypeID()) return CFDictionaryRefObj_New((CFDictionaryRef
)itself
);
4838 if (CFGetTypeID(itself
) == CFDataGetTypeID()) return CFDataRefObj_New((CFDataRef
)itself
);
4839 if (CFGetTypeID(itself
) == CFStringGetTypeID()) return CFStringRefObj_New((CFStringRef
)itself
);
4840 if (CFGetTypeID(itself
) == CFURLGetTypeID()) return CFURLRefObj_New((CFURLRef
)itself
);
4841 /* XXXX Or should we use PyCF_CF2Python here?? */
4842 return CFTypeRefObj_New(itself
);
4844 int CFObj_Convert(PyObject
*v
, CFTypeRef
*p_itself
)
4847 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
4848 /* Check for other CF objects here */
4850 if (!CFTypeRefObj_Check(v
) &&
4851 !CFArrayRefObj_Check(v
) &&
4852 !CFMutableArrayRefObj_Check(v
) &&
4853 !CFDictionaryRefObj_Check(v
) &&
4854 !CFMutableDictionaryRefObj_Check(v
) &&
4855 !CFDataRefObj_Check(v
) &&
4856 !CFMutableDataRefObj_Check(v
) &&
4857 !CFStringRefObj_Check(v
) &&
4858 !CFMutableStringRefObj_Check(v
) &&
4859 !CFURLRefObj_Check(v
) )
4861 /* XXXX Or should we use PyCF_Python2CF here?? */
4862 PyErr_SetString(PyExc_TypeError
, "CF object required");
4865 *p_itself
= ((CFTypeRefObject
*)v
)->ob_itself
;
4877 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFTypeRef
, CFObj_New
);
4878 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFTypeRef
, CFObj_Convert
);
4879 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFTypeRef
, CFTypeRefObj_New
);
4880 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFTypeRef
, CFTypeRefObj_Convert
);
4881 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFStringRef
, CFStringRefObj_New
);
4882 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFStringRef
, CFStringRefObj_Convert
);
4883 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableStringRef
, CFMutableStringRefObj_New
);
4884 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableStringRef
, CFMutableStringRefObj_Convert
);
4885 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFArrayRef
, CFArrayRefObj_New
);
4886 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFArrayRef
, CFArrayRefObj_Convert
);
4887 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableArrayRef
, CFMutableArrayRefObj_New
);
4888 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableArrayRef
, CFMutableArrayRefObj_Convert
);
4889 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFDictionaryRef
, CFDictionaryRefObj_New
);
4890 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFDictionaryRef
, CFDictionaryRefObj_Convert
);
4891 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableDictionaryRef
, CFMutableDictionaryRefObj_New
);
4892 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableDictionaryRef
, CFMutableDictionaryRefObj_Convert
);
4893 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFURLRef
, CFURLRefObj_New
);
4894 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef
, CFURLRefObj_Convert
);
4897 m
= Py_InitModule("_CF", CF_methods
);
4898 d
= PyModule_GetDict(m
);
4899 CF_Error
= PyMac_GetOSErrException();
4900 if (CF_Error
== NULL
||
4901 PyDict_SetItemString(d
, "Error", CF_Error
) != 0)
4903 CFTypeRef_Type
.ob_type
= &PyType_Type
;
4904 if (PyType_Ready(&CFTypeRef_Type
) < 0) return;
4905 Py_INCREF(&CFTypeRef_Type
);
4906 PyModule_AddObject(m
, "CFTypeRef", (PyObject
*)&CFTypeRef_Type
);
4907 /* Backward-compatible name */
4908 Py_INCREF(&CFTypeRef_Type
);
4909 PyModule_AddObject(m
, "CFTypeRefType", (PyObject
*)&CFTypeRef_Type
);
4910 CFArrayRef_Type
.ob_type
= &PyType_Type
;
4911 CFArrayRef_Type
.tp_base
= &CFTypeRef_Type
;
4912 if (PyType_Ready(&CFArrayRef_Type
) < 0) return;
4913 Py_INCREF(&CFArrayRef_Type
);
4914 PyModule_AddObject(m
, "CFArrayRef", (PyObject
*)&CFArrayRef_Type
);
4915 /* Backward-compatible name */
4916 Py_INCREF(&CFArrayRef_Type
);
4917 PyModule_AddObject(m
, "CFArrayRefType", (PyObject
*)&CFArrayRef_Type
);
4918 CFMutableArrayRef_Type
.ob_type
= &PyType_Type
;
4919 CFMutableArrayRef_Type
.tp_base
= &CFArrayRef_Type
;
4920 if (PyType_Ready(&CFMutableArrayRef_Type
) < 0) return;
4921 Py_INCREF(&CFMutableArrayRef_Type
);
4922 PyModule_AddObject(m
, "CFMutableArrayRef", (PyObject
*)&CFMutableArrayRef_Type
);
4923 /* Backward-compatible name */
4924 Py_INCREF(&CFMutableArrayRef_Type
);
4925 PyModule_AddObject(m
, "CFMutableArrayRefType", (PyObject
*)&CFMutableArrayRef_Type
);
4926 CFDictionaryRef_Type
.ob_type
= &PyType_Type
;
4927 CFDictionaryRef_Type
.tp_base
= &CFTypeRef_Type
;
4928 if (PyType_Ready(&CFDictionaryRef_Type
) < 0) return;
4929 Py_INCREF(&CFDictionaryRef_Type
);
4930 PyModule_AddObject(m
, "CFDictionaryRef", (PyObject
*)&CFDictionaryRef_Type
);
4931 /* Backward-compatible name */
4932 Py_INCREF(&CFDictionaryRef_Type
);
4933 PyModule_AddObject(m
, "CFDictionaryRefType", (PyObject
*)&CFDictionaryRef_Type
);
4934 CFMutableDictionaryRef_Type
.ob_type
= &PyType_Type
;
4935 CFMutableDictionaryRef_Type
.tp_base
= &CFDictionaryRef_Type
;
4936 if (PyType_Ready(&CFMutableDictionaryRef_Type
) < 0) return;
4937 Py_INCREF(&CFMutableDictionaryRef_Type
);
4938 PyModule_AddObject(m
, "CFMutableDictionaryRef", (PyObject
*)&CFMutableDictionaryRef_Type
);
4939 /* Backward-compatible name */
4940 Py_INCREF(&CFMutableDictionaryRef_Type
);
4941 PyModule_AddObject(m
, "CFMutableDictionaryRefType", (PyObject
*)&CFMutableDictionaryRef_Type
);
4942 CFDataRef_Type
.ob_type
= &PyType_Type
;
4943 CFDataRef_Type
.tp_base
= &CFTypeRef_Type
;
4944 if (PyType_Ready(&CFDataRef_Type
) < 0) return;
4945 Py_INCREF(&CFDataRef_Type
);
4946 PyModule_AddObject(m
, "CFDataRef", (PyObject
*)&CFDataRef_Type
);
4947 /* Backward-compatible name */
4948 Py_INCREF(&CFDataRef_Type
);
4949 PyModule_AddObject(m
, "CFDataRefType", (PyObject
*)&CFDataRef_Type
);
4950 CFMutableDataRef_Type
.ob_type
= &PyType_Type
;
4951 CFMutableDataRef_Type
.tp_base
= &CFDataRef_Type
;
4952 if (PyType_Ready(&CFMutableDataRef_Type
) < 0) return;
4953 Py_INCREF(&CFMutableDataRef_Type
);
4954 PyModule_AddObject(m
, "CFMutableDataRef", (PyObject
*)&CFMutableDataRef_Type
);
4955 /* Backward-compatible name */
4956 Py_INCREF(&CFMutableDataRef_Type
);
4957 PyModule_AddObject(m
, "CFMutableDataRefType", (PyObject
*)&CFMutableDataRef_Type
);
4958 CFStringRef_Type
.ob_type
= &PyType_Type
;
4959 CFStringRef_Type
.tp_base
= &CFTypeRef_Type
;
4960 if (PyType_Ready(&CFStringRef_Type
) < 0) return;
4961 Py_INCREF(&CFStringRef_Type
);
4962 PyModule_AddObject(m
, "CFStringRef", (PyObject
*)&CFStringRef_Type
);
4963 /* Backward-compatible name */
4964 Py_INCREF(&CFStringRef_Type
);
4965 PyModule_AddObject(m
, "CFStringRefType", (PyObject
*)&CFStringRef_Type
);
4966 CFMutableStringRef_Type
.ob_type
= &PyType_Type
;
4967 CFMutableStringRef_Type
.tp_base
= &CFStringRef_Type
;
4968 if (PyType_Ready(&CFMutableStringRef_Type
) < 0) return;
4969 Py_INCREF(&CFMutableStringRef_Type
);
4970 PyModule_AddObject(m
, "CFMutableStringRef", (PyObject
*)&CFMutableStringRef_Type
);
4971 /* Backward-compatible name */
4972 Py_INCREF(&CFMutableStringRef_Type
);
4973 PyModule_AddObject(m
, "CFMutableStringRefType", (PyObject
*)&CFMutableStringRef_Type
);
4974 CFURLRef_Type
.ob_type
= &PyType_Type
;
4975 CFURLRef_Type
.tp_base
= &CFTypeRef_Type
;
4976 if (PyType_Ready(&CFURLRef_Type
) < 0) return;
4977 Py_INCREF(&CFURLRef_Type
);
4978 PyModule_AddObject(m
, "CFURLRef", (PyObject
*)&CFURLRef_Type
);
4979 /* Backward-compatible name */
4980 Py_INCREF(&CFURLRef_Type
);
4981 PyModule_AddObject(m
, "CFURLRefType", (PyObject
*)&CFURLRef_Type
);
4983 #define _STRINGCONST(name) PyModule_AddObject(m, #name, CFStringRefObj_New(name))
4984 _STRINGCONST(kCFPreferencesAnyApplication
);
4985 _STRINGCONST(kCFPreferencesCurrentApplication
);
4986 _STRINGCONST(kCFPreferencesAnyHost
);
4987 _STRINGCONST(kCFPreferencesCurrentHost
);
4988 _STRINGCONST(kCFPreferencesAnyUser
);
4989 _STRINGCONST(kCFPreferencesCurrentUser
);
4995 /* ========================= End module _CF ========================= */