2 /* =========================== Module _CF =========================== */
9 #include "pywintoolbox.h"
12 #include "pymactoolbox.h"
15 /* Macro to test whether a weak-loaded CFM function exists */
16 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
17 PyErr_SetString(PyExc_NotImplementedError, \
18 "Not available in this shared library/OS version"); \
23 #ifdef WITHOUT_FRAMEWORKS
27 #include <CFDictionary.h>
30 #include <CFPropertyList.h>
31 #include <CFPreferences.h>
33 #include <CoreServices/CoreServices.h>
36 #include "pycfbridge.h"
38 #ifdef USE_TOOLBOX_OBJECT_GLUE
39 extern PyObject
*_CFObj_New(CFTypeRef
);
40 extern int _CFObj_Convert(PyObject
*, CFTypeRef
*);
41 #define CFObj_New _CFObj_New
42 #define CFObj_Convert _CFObj_Convert
44 extern PyObject
*_CFTypeRefObj_New(CFTypeRef
);
45 extern int _CFTypeRefObj_Convert(PyObject
*, CFTypeRef
*);
46 #define CFTypeRefObj_New _CFTypeRefObj_New
47 #define CFTypeRefObj_Convert _CFTypeRefObj_Convert
49 extern PyObject
*_CFStringRefObj_New(CFStringRef
);
50 extern int _CFStringRefObj_Convert(PyObject
*, CFStringRef
*);
51 #define CFStringRefObj_New _CFStringRefObj_New
52 #define CFStringRefObj_Convert _CFStringRefObj_Convert
54 extern PyObject
*_CFMutableStringRefObj_New(CFMutableStringRef
);
55 extern int _CFMutableStringRefObj_Convert(PyObject
*, CFMutableStringRef
*);
56 #define CFMutableStringRefObj_New _CFMutableStringRefObj_New
57 #define CFMutableStringRefObj_Convert _CFMutableStringRefObj_Convert
59 extern PyObject
*_CFArrayRefObj_New(CFArrayRef
);
60 extern int _CFArrayRefObj_Convert(PyObject
*, CFArrayRef
*);
61 #define CFArrayRefObj_New _CFArrayRefObj_New
62 #define CFArrayRefObj_Convert _CFArrayRefObj_Convert
64 extern PyObject
*_CFMutableArrayRefObj_New(CFMutableArrayRef
);
65 extern int _CFMutableArrayRefObj_Convert(PyObject
*, CFMutableArrayRef
*);
66 #define CFMutableArrayRefObj_New _CFMutableArrayRefObj_New
67 #define CFMutableArrayRefObj_Convert _CFMutableArrayRefObj_Convert
69 extern PyObject
*_CFDataRefObj_New(CFDataRef
);
70 extern int _CFDataRefObj_Convert(PyObject
*, CFDataRef
*);
71 #define CFDataRefObj_New _CFDataRefObj_New
72 #define CFDataRefObj_Convert _CFDataRefObj_Convert
74 extern PyObject
*_CFMutableDataRefObj_New(CFMutableDataRef
);
75 extern int _CFMutableDataRefObj_Convert(PyObject
*, CFMutableDataRef
*);
76 #define CFMutableDataRefObj_New _CFMutableDataRefObj_New
77 #define CFMutableDataRefObj_Convert _CFMutableDataRefObj_Convert
79 extern PyObject
*_CFDictionaryRefObj_New(CFDictionaryRef
);
80 extern int _CFDictionaryRefObj_Convert(PyObject
*, CFDictionaryRef
*);
81 #define CFDictionaryRefObj_New _CFDictionaryRefObj_New
82 #define CFDictionaryRefObj_Convert _CFDictionaryRefObj_Convert
84 extern PyObject
*_CFMutableDictionaryRefObj_New(CFMutableDictionaryRef
);
85 extern int _CFMutableDictionaryRefObj_Convert(PyObject
*, CFMutableDictionaryRef
*);
86 #define CFMutableDictionaryRefObj_New _CFMutableDictionaryRefObj_New
87 #define CFMutableDictionaryRefObj_Convert _CFMutableDictionaryRefObj_Convert
89 extern PyObject
*_CFURLRefObj_New(CFURLRef
);
90 extern int _CFURLRefObj_Convert(PyObject
*, CFURLRef
*);
91 extern int _OptionalCFURLRefObj_Convert(PyObject
*, CFURLRef
*);
92 #define CFURLRefObj_New _CFURLRefObj_New
93 #define CFURLRefObj_Convert _CFURLRefObj_Convert
94 #define OptionalCFURLRefObj_Convert _OptionalCFURLRefObj_Convert
98 ** Parse/generate CFRange records
100 PyObject
*CFRange_New(CFRange
*itself
)
103 return Py_BuildValue("ll", (long)itself
->location
, (long)itself
->length
);
107 CFRange_Convert(PyObject
*v
, CFRange
*p_itself
)
109 long location
, length
;
111 if( !PyArg_ParseTuple(v
, "ll", &location
, &length
) )
113 p_itself
->location
= (CFIndex
)location
;
114 p_itself
->length
= (CFIndex
)length
;
118 /* Optional CFURL argument or None (passed as NULL) */
120 OptionalCFURLRefObj_Convert(PyObject
*v
, CFURLRef
*p_itself
)
122 if ( v
== Py_None
) {
126 return CFURLRefObj_Convert(v
, p_itself
);
129 static PyObject
*CF_Error
;
131 /* --------------------- Object type CFTypeRef ---------------------- */
133 PyTypeObject CFTypeRef_Type
;
135 #define CFTypeRefObj_Check(x) ((x)->ob_type == &CFTypeRef_Type || PyObject_TypeCheck((x), &CFTypeRef_Type))
137 typedef struct CFTypeRefObject
{
140 void (*ob_freeit
)(CFTypeRef ptr
);
143 PyObject
*CFTypeRefObj_New(CFTypeRef itself
)
148 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
151 it
= PyObject_NEW(CFTypeRefObject
, &CFTypeRef_Type
);
152 if (it
== NULL
) return NULL
;
153 it
->ob_itself
= itself
;
154 it
->ob_freeit
= CFRelease
;
155 return (PyObject
*)it
;
157 int CFTypeRefObj_Convert(PyObject
*v
, CFTypeRef
*p_itself
)
160 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
161 /* Check for other CF objects here */
163 if (!CFTypeRefObj_Check(v
))
165 PyErr_SetString(PyExc_TypeError
, "CFTypeRef required");
168 *p_itself
= ((CFTypeRefObject
*)v
)->ob_itself
;
172 static void CFTypeRefObj_dealloc(CFTypeRefObject
*self
)
174 if (self
->ob_freeit
&& self
->ob_itself
)
176 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
178 PyObject_Free((PyObject
*)self
);
181 static PyObject
*CFTypeRefObj_CFGetTypeID(CFTypeRefObject
*_self
, PyObject
*_args
)
183 PyObject
*_res
= NULL
;
186 PyMac_PRECHECK(CFGetTypeID
);
188 if (!PyArg_ParseTuple(_args
, ""))
190 _rv
= CFGetTypeID(_self
->ob_itself
);
191 _res
= Py_BuildValue("l",
196 static PyObject
*CFTypeRefObj_CFRetain(CFTypeRefObject
*_self
, PyObject
*_args
)
198 PyObject
*_res
= NULL
;
201 PyMac_PRECHECK(CFRetain
);
203 if (!PyArg_ParseTuple(_args
, ""))
205 _rv
= CFRetain(_self
->ob_itself
);
206 _res
= Py_BuildValue("O&",
207 CFTypeRefObj_New
, _rv
);
211 static PyObject
*CFTypeRefObj_CFRelease(CFTypeRefObject
*_self
, PyObject
*_args
)
213 PyObject
*_res
= NULL
;
215 PyMac_PRECHECK(CFRelease
);
217 if (!PyArg_ParseTuple(_args
, ""))
219 CFRelease(_self
->ob_itself
);
225 static PyObject
*CFTypeRefObj_CFGetRetainCount(CFTypeRefObject
*_self
, PyObject
*_args
)
227 PyObject
*_res
= NULL
;
229 #ifndef CFGetRetainCount
230 PyMac_PRECHECK(CFGetRetainCount
);
232 if (!PyArg_ParseTuple(_args
, ""))
234 _rv
= CFGetRetainCount(_self
->ob_itself
);
235 _res
= Py_BuildValue("l",
240 static PyObject
*CFTypeRefObj_CFEqual(CFTypeRefObject
*_self
, PyObject
*_args
)
242 PyObject
*_res
= NULL
;
246 PyMac_PRECHECK(CFEqual
);
248 if (!PyArg_ParseTuple(_args
, "O&",
249 CFTypeRefObj_Convert
, &cf2
))
251 _rv
= CFEqual(_self
->ob_itself
,
253 _res
= Py_BuildValue("l",
258 static PyObject
*CFTypeRefObj_CFHash(CFTypeRefObject
*_self
, PyObject
*_args
)
260 PyObject
*_res
= NULL
;
263 PyMac_PRECHECK(CFHash
);
265 if (!PyArg_ParseTuple(_args
, ""))
267 _rv
= CFHash(_self
->ob_itself
);
268 _res
= Py_BuildValue("l",
273 static PyObject
*CFTypeRefObj_CFCopyDescription(CFTypeRefObject
*_self
, PyObject
*_args
)
275 PyObject
*_res
= NULL
;
277 #ifndef CFCopyDescription
278 PyMac_PRECHECK(CFCopyDescription
);
280 if (!PyArg_ParseTuple(_args
, ""))
282 _rv
= CFCopyDescription(_self
->ob_itself
);
283 _res
= Py_BuildValue("O&",
284 CFStringRefObj_New
, _rv
);
288 static PyObject
*CFTypeRefObj_CFPropertyListCreateXMLData(CFTypeRefObject
*_self
, PyObject
*_args
)
290 PyObject
*_res
= NULL
;
292 if (!PyArg_ParseTuple(_args
, ""))
294 _rv
= CFPropertyListCreateXMLData((CFAllocatorRef
)NULL
,
296 _res
= Py_BuildValue("O&",
297 CFDataRefObj_New
, _rv
);
301 static PyObject
*CFTypeRefObj_CFPropertyListCreateDeepCopy(CFTypeRefObject
*_self
, PyObject
*_args
)
303 PyObject
*_res
= NULL
;
305 CFOptionFlags mutabilityOption
;
306 if (!PyArg_ParseTuple(_args
, "l",
309 _rv
= CFPropertyListCreateDeepCopy((CFAllocatorRef
)NULL
,
312 _res
= Py_BuildValue("O&",
313 CFTypeRefObj_New
, _rv
);
317 static PyObject
*CFTypeRefObj_CFShow(CFTypeRefObject
*_self
, PyObject
*_args
)
319 PyObject
*_res
= NULL
;
321 PyMac_PRECHECK(CFShow
);
323 if (!PyArg_ParseTuple(_args
, ""))
325 CFShow(_self
->ob_itself
);
331 static PyObject
*CFTypeRefObj_CFPropertyListCreateFromXMLData(CFTypeRefObject
*_self
, PyObject
*_args
)
333 PyObject
*_res
= NULL
;
336 CFOptionFlags mutabilityOption
;
337 CFStringRef errorString
;
338 if (!PyArg_ParseTuple(_args
, "l",
341 _rv
= CFPropertyListCreateFromXMLData((CFAllocatorRef
)NULL
,
346 CFRelease(errorString
);
348 PyErr_SetString(PyExc_RuntimeError
, "Parse error in XML data");
351 _res
= Py_BuildValue("O&",
352 CFTypeRefObj_New
, _rv
);
357 static PyObject
*CFTypeRefObj_toPython(CFTypeRefObject
*_self
, PyObject
*_args
)
359 PyObject
*_res
= NULL
;
361 _res
= PyCF_CF2Python(_self
->ob_itself
);
366 static PyMethodDef CFTypeRefObj_methods
[] = {
367 {"CFGetTypeID", (PyCFunction
)CFTypeRefObj_CFGetTypeID
, 1,
368 PyDoc_STR("() -> (CFTypeID _rv)")},
369 {"CFRetain", (PyCFunction
)CFTypeRefObj_CFRetain
, 1,
370 PyDoc_STR("() -> (CFTypeRef _rv)")},
371 {"CFRelease", (PyCFunction
)CFTypeRefObj_CFRelease
, 1,
372 PyDoc_STR("() -> None")},
373 {"CFGetRetainCount", (PyCFunction
)CFTypeRefObj_CFGetRetainCount
, 1,
374 PyDoc_STR("() -> (CFIndex _rv)")},
375 {"CFEqual", (PyCFunction
)CFTypeRefObj_CFEqual
, 1,
376 PyDoc_STR("(CFTypeRef cf2) -> (Boolean _rv)")},
377 {"CFHash", (PyCFunction
)CFTypeRefObj_CFHash
, 1,
378 PyDoc_STR("() -> (CFHashCode _rv)")},
379 {"CFCopyDescription", (PyCFunction
)CFTypeRefObj_CFCopyDescription
, 1,
380 PyDoc_STR("() -> (CFStringRef _rv)")},
381 {"CFPropertyListCreateXMLData", (PyCFunction
)CFTypeRefObj_CFPropertyListCreateXMLData
, 1,
382 PyDoc_STR("() -> (CFDataRef _rv)")},
383 {"CFPropertyListCreateDeepCopy", (PyCFunction
)CFTypeRefObj_CFPropertyListCreateDeepCopy
, 1,
384 PyDoc_STR("(CFOptionFlags mutabilityOption) -> (CFTypeRef _rv)")},
385 {"CFShow", (PyCFunction
)CFTypeRefObj_CFShow
, 1,
386 PyDoc_STR("() -> None")},
387 {"CFPropertyListCreateFromXMLData", (PyCFunction
)CFTypeRefObj_CFPropertyListCreateFromXMLData
, 1,
388 PyDoc_STR("(CFOptionFlags mutabilityOption) -> (CFTypeRefObj)")},
389 {"toPython", (PyCFunction
)CFTypeRefObj_toPython
, 1,
390 PyDoc_STR("() -> (python_object)")},
394 PyMethodChain CFTypeRefObj_chain
= { CFTypeRefObj_methods
, NULL
};
396 static PyObject
*CFTypeRefObj_getattr(CFTypeRefObject
*self
, char *name
)
398 return Py_FindMethodInChain(&CFTypeRefObj_chain
, (PyObject
*)self
, name
);
401 #define CFTypeRefObj_setattr NULL
403 static int CFTypeRefObj_compare(CFTypeRefObject
*self
, CFTypeRefObject
*other
)
405 /* XXXX Or should we use CFEqual?? */
406 if ( self
->ob_itself
> other
->ob_itself
) return 1;
407 if ( self
->ob_itself
< other
->ob_itself
) return -1;
411 static PyObject
* CFTypeRefObj_repr(CFTypeRefObject
*self
)
414 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
);
415 return PyString_FromString(buf
);
418 static int CFTypeRefObj_hash(CFTypeRefObject
*self
)
420 /* XXXX Or should we use CFHash?? */
421 return (int)self
->ob_itself
;
424 PyTypeObject CFTypeRef_Type
= {
425 PyObject_HEAD_INIT(NULL
)
427 "_CF.CFTypeRef", /*tp_name*/
428 sizeof(CFTypeRefObject
), /*tp_basicsize*/
431 (destructor
) CFTypeRefObj_dealloc
, /*tp_dealloc*/
433 (getattrfunc
) CFTypeRefObj_getattr
, /*tp_getattr*/
434 (setattrfunc
) CFTypeRefObj_setattr
, /*tp_setattr*/
435 (cmpfunc
) CFTypeRefObj_compare
, /*tp_compare*/
436 (reprfunc
) CFTypeRefObj_repr
, /*tp_repr*/
437 (PyNumberMethods
*)0, /* tp_as_number */
438 (PySequenceMethods
*)0, /* tp_as_sequence */
439 (PyMappingMethods
*)0, /* tp_as_mapping */
440 (hashfunc
) CFTypeRefObj_hash
, /*tp_hash*/
443 /* ------------------- End object type CFTypeRef -------------------- */
446 /* --------------------- Object type CFArrayRef --------------------- */
448 PyTypeObject CFArrayRef_Type
;
450 #define CFArrayRefObj_Check(x) ((x)->ob_type == &CFArrayRef_Type || PyObject_TypeCheck((x), &CFArrayRef_Type))
452 typedef struct CFArrayRefObject
{
454 CFArrayRef ob_itself
;
455 void (*ob_freeit
)(CFTypeRef ptr
);
458 PyObject
*CFArrayRefObj_New(CFArrayRef itself
)
460 CFArrayRefObject
*it
;
463 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
466 it
= PyObject_NEW(CFArrayRefObject
, &CFArrayRef_Type
);
467 if (it
== NULL
) return NULL
;
468 it
->ob_itself
= itself
;
469 it
->ob_freeit
= CFRelease
;
470 return (PyObject
*)it
;
472 int CFArrayRefObj_Convert(PyObject
*v
, CFArrayRef
*p_itself
)
475 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
476 /* Check for other CF objects here */
478 if (!CFArrayRefObj_Check(v
))
480 PyErr_SetString(PyExc_TypeError
, "CFArrayRef required");
483 *p_itself
= ((CFArrayRefObject
*)v
)->ob_itself
;
487 static void CFArrayRefObj_dealloc(CFArrayRefObject
*self
)
489 if (self
->ob_freeit
&& self
->ob_itself
)
491 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
493 PyObject_Free((PyObject
*)self
);
496 static PyObject
*CFArrayRefObj_CFArrayCreateCopy(CFArrayRefObject
*_self
, PyObject
*_args
)
498 PyObject
*_res
= NULL
;
500 if (!PyArg_ParseTuple(_args
, ""))
502 _rv
= CFArrayCreateCopy((CFAllocatorRef
)NULL
,
504 _res
= Py_BuildValue("O&",
505 CFArrayRefObj_New
, _rv
);
509 static PyObject
*CFArrayRefObj_CFArrayGetCount(CFArrayRefObject
*_self
, PyObject
*_args
)
511 PyObject
*_res
= NULL
;
513 #ifndef CFArrayGetCount
514 PyMac_PRECHECK(CFArrayGetCount
);
516 if (!PyArg_ParseTuple(_args
, ""))
518 _rv
= CFArrayGetCount(_self
->ob_itself
);
519 _res
= Py_BuildValue("l",
524 static PyObject
*CFArrayRefObj_CFStringCreateByCombiningStrings(CFArrayRefObject
*_self
, PyObject
*_args
)
526 PyObject
*_res
= NULL
;
528 CFStringRef separatorString
;
529 if (!PyArg_ParseTuple(_args
, "O&",
530 CFStringRefObj_Convert
, &separatorString
))
532 _rv
= CFStringCreateByCombiningStrings((CFAllocatorRef
)NULL
,
535 _res
= Py_BuildValue("O&",
536 CFStringRefObj_New
, _rv
);
540 static PyMethodDef CFArrayRefObj_methods
[] = {
541 {"CFArrayCreateCopy", (PyCFunction
)CFArrayRefObj_CFArrayCreateCopy
, 1,
542 PyDoc_STR("() -> (CFArrayRef _rv)")},
543 {"CFArrayGetCount", (PyCFunction
)CFArrayRefObj_CFArrayGetCount
, 1,
544 PyDoc_STR("() -> (CFIndex _rv)")},
545 {"CFStringCreateByCombiningStrings", (PyCFunction
)CFArrayRefObj_CFStringCreateByCombiningStrings
, 1,
546 PyDoc_STR("(CFStringRef separatorString) -> (CFStringRef _rv)")},
550 PyMethodChain CFArrayRefObj_chain
= { CFArrayRefObj_methods
, &CFTypeRefObj_chain
};
552 static PyObject
*CFArrayRefObj_getattr(CFArrayRefObject
*self
, char *name
)
554 return Py_FindMethodInChain(&CFArrayRefObj_chain
, (PyObject
*)self
, name
);
557 #define CFArrayRefObj_setattr NULL
559 static int CFArrayRefObj_compare(CFArrayRefObject
*self
, CFArrayRefObject
*other
)
561 /* XXXX Or should we use CFEqual?? */
562 if ( self
->ob_itself
> other
->ob_itself
) return 1;
563 if ( self
->ob_itself
< other
->ob_itself
) return -1;
567 static PyObject
* CFArrayRefObj_repr(CFArrayRefObject
*self
)
570 sprintf(buf
, "<CFArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
571 return PyString_FromString(buf
);
574 static int CFArrayRefObj_hash(CFArrayRefObject
*self
)
576 /* XXXX Or should we use CFHash?? */
577 return (int)self
->ob_itself
;
580 PyTypeObject CFArrayRef_Type
= {
581 PyObject_HEAD_INIT(NULL
)
583 "_CF.CFArrayRef", /*tp_name*/
584 sizeof(CFArrayRefObject
), /*tp_basicsize*/
587 (destructor
) CFArrayRefObj_dealloc
, /*tp_dealloc*/
589 (getattrfunc
) CFArrayRefObj_getattr
, /*tp_getattr*/
590 (setattrfunc
) CFArrayRefObj_setattr
, /*tp_setattr*/
591 (cmpfunc
) CFArrayRefObj_compare
, /*tp_compare*/
592 (reprfunc
) CFArrayRefObj_repr
, /*tp_repr*/
593 (PyNumberMethods
*)0, /* tp_as_number */
594 (PySequenceMethods
*)0, /* tp_as_sequence */
595 (PyMappingMethods
*)0, /* tp_as_mapping */
596 (hashfunc
) CFArrayRefObj_hash
, /*tp_hash*/
599 /* ------------------- End object type CFArrayRef ------------------- */
602 /* ----------------- Object type CFMutableArrayRef ------------------ */
604 PyTypeObject CFMutableArrayRef_Type
;
606 #define CFMutableArrayRefObj_Check(x) ((x)->ob_type == &CFMutableArrayRef_Type || PyObject_TypeCheck((x), &CFMutableArrayRef_Type))
608 typedef struct CFMutableArrayRefObject
{
610 CFMutableArrayRef ob_itself
;
611 void (*ob_freeit
)(CFTypeRef ptr
);
612 } CFMutableArrayRefObject
;
614 PyObject
*CFMutableArrayRefObj_New(CFMutableArrayRef itself
)
616 CFMutableArrayRefObject
*it
;
619 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
622 it
= PyObject_NEW(CFMutableArrayRefObject
, &CFMutableArrayRef_Type
);
623 if (it
== NULL
) return NULL
;
624 it
->ob_itself
= itself
;
625 it
->ob_freeit
= CFRelease
;
626 return (PyObject
*)it
;
628 int CFMutableArrayRefObj_Convert(PyObject
*v
, CFMutableArrayRef
*p_itself
)
631 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
632 /* Check for other CF objects here */
634 if (!CFMutableArrayRefObj_Check(v
))
636 PyErr_SetString(PyExc_TypeError
, "CFMutableArrayRef required");
639 *p_itself
= ((CFMutableArrayRefObject
*)v
)->ob_itself
;
643 static void CFMutableArrayRefObj_dealloc(CFMutableArrayRefObject
*self
)
645 if (self
->ob_freeit
&& self
->ob_itself
)
647 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
649 PyObject_Free((PyObject
*)self
);
652 static PyObject
*CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
654 PyObject
*_res
= NULL
;
656 #ifndef CFArrayRemoveValueAtIndex
657 PyMac_PRECHECK(CFArrayRemoveValueAtIndex
);
659 if (!PyArg_ParseTuple(_args
, "l",
662 CFArrayRemoveValueAtIndex(_self
->ob_itself
,
669 static PyObject
*CFMutableArrayRefObj_CFArrayRemoveAllValues(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
671 PyObject
*_res
= NULL
;
672 #ifndef CFArrayRemoveAllValues
673 PyMac_PRECHECK(CFArrayRemoveAllValues
);
675 if (!PyArg_ParseTuple(_args
, ""))
677 CFArrayRemoveAllValues(_self
->ob_itself
);
683 static PyObject
*CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
685 PyObject
*_res
= NULL
;
688 #ifndef CFArrayExchangeValuesAtIndices
689 PyMac_PRECHECK(CFArrayExchangeValuesAtIndices
);
691 if (!PyArg_ParseTuple(_args
, "ll",
695 CFArrayExchangeValuesAtIndices(_self
->ob_itself
,
703 static PyObject
*CFMutableArrayRefObj_CFArrayAppendArray(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
705 PyObject
*_res
= NULL
;
706 CFArrayRef otherArray
;
708 #ifndef CFArrayAppendArray
709 PyMac_PRECHECK(CFArrayAppendArray
);
711 if (!PyArg_ParseTuple(_args
, "O&O&",
712 CFArrayRefObj_Convert
, &otherArray
,
713 CFRange_Convert
, &otherRange
))
715 CFArrayAppendArray(_self
->ob_itself
,
723 static PyMethodDef CFMutableArrayRefObj_methods
[] = {
724 {"CFArrayRemoveValueAtIndex", (PyCFunction
)CFMutableArrayRefObj_CFArrayRemoveValueAtIndex
, 1,
725 PyDoc_STR("(CFIndex idx) -> None")},
726 {"CFArrayRemoveAllValues", (PyCFunction
)CFMutableArrayRefObj_CFArrayRemoveAllValues
, 1,
727 PyDoc_STR("() -> None")},
728 {"CFArrayExchangeValuesAtIndices", (PyCFunction
)CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices
, 1,
729 PyDoc_STR("(CFIndex idx1, CFIndex idx2) -> None")},
730 {"CFArrayAppendArray", (PyCFunction
)CFMutableArrayRefObj_CFArrayAppendArray
, 1,
731 PyDoc_STR("(CFArrayRef otherArray, CFRange otherRange) -> None")},
735 PyMethodChain CFMutableArrayRefObj_chain
= { CFMutableArrayRefObj_methods
, &CFArrayRefObj_chain
};
737 static PyObject
*CFMutableArrayRefObj_getattr(CFMutableArrayRefObject
*self
, char *name
)
739 return Py_FindMethodInChain(&CFMutableArrayRefObj_chain
, (PyObject
*)self
, name
);
742 #define CFMutableArrayRefObj_setattr NULL
744 static int CFMutableArrayRefObj_compare(CFMutableArrayRefObject
*self
, CFMutableArrayRefObject
*other
)
746 /* XXXX Or should we use CFEqual?? */
747 if ( self
->ob_itself
> other
->ob_itself
) return 1;
748 if ( self
->ob_itself
< other
->ob_itself
) return -1;
752 static PyObject
* CFMutableArrayRefObj_repr(CFMutableArrayRefObject
*self
)
755 sprintf(buf
, "<CFMutableArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
756 return PyString_FromString(buf
);
759 static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject
*self
)
761 /* XXXX Or should we use CFHash?? */
762 return (int)self
->ob_itself
;
765 PyTypeObject CFMutableArrayRef_Type
= {
766 PyObject_HEAD_INIT(NULL
)
768 "_CF.CFMutableArrayRef", /*tp_name*/
769 sizeof(CFMutableArrayRefObject
), /*tp_basicsize*/
772 (destructor
) CFMutableArrayRefObj_dealloc
, /*tp_dealloc*/
774 (getattrfunc
) CFMutableArrayRefObj_getattr
, /*tp_getattr*/
775 (setattrfunc
) CFMutableArrayRefObj_setattr
, /*tp_setattr*/
776 (cmpfunc
) CFMutableArrayRefObj_compare
, /*tp_compare*/
777 (reprfunc
) CFMutableArrayRefObj_repr
, /*tp_repr*/
778 (PyNumberMethods
*)0, /* tp_as_number */
779 (PySequenceMethods
*)0, /* tp_as_sequence */
780 (PyMappingMethods
*)0, /* tp_as_mapping */
781 (hashfunc
) CFMutableArrayRefObj_hash
, /*tp_hash*/
784 /* --------------- End object type CFMutableArrayRef ---------------- */
787 /* ------------------ Object type CFDictionaryRef ------------------- */
789 PyTypeObject CFDictionaryRef_Type
;
791 #define CFDictionaryRefObj_Check(x) ((x)->ob_type == &CFDictionaryRef_Type || PyObject_TypeCheck((x), &CFDictionaryRef_Type))
793 typedef struct CFDictionaryRefObject
{
795 CFDictionaryRef ob_itself
;
796 void (*ob_freeit
)(CFTypeRef ptr
);
797 } CFDictionaryRefObject
;
799 PyObject
*CFDictionaryRefObj_New(CFDictionaryRef itself
)
801 CFDictionaryRefObject
*it
;
804 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
807 it
= PyObject_NEW(CFDictionaryRefObject
, &CFDictionaryRef_Type
);
808 if (it
== NULL
) return NULL
;
809 it
->ob_itself
= itself
;
810 it
->ob_freeit
= CFRelease
;
811 return (PyObject
*)it
;
813 int CFDictionaryRefObj_Convert(PyObject
*v
, CFDictionaryRef
*p_itself
)
816 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
817 /* Check for other CF objects here */
819 if (!CFDictionaryRefObj_Check(v
))
821 PyErr_SetString(PyExc_TypeError
, "CFDictionaryRef required");
824 *p_itself
= ((CFDictionaryRefObject
*)v
)->ob_itself
;
828 static void CFDictionaryRefObj_dealloc(CFDictionaryRefObject
*self
)
830 if (self
->ob_freeit
&& self
->ob_itself
)
832 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
834 PyObject_Free((PyObject
*)self
);
837 static PyObject
*CFDictionaryRefObj_CFDictionaryCreateCopy(CFDictionaryRefObject
*_self
, PyObject
*_args
)
839 PyObject
*_res
= NULL
;
841 if (!PyArg_ParseTuple(_args
, ""))
843 _rv
= CFDictionaryCreateCopy((CFAllocatorRef
)NULL
,
845 _res
= Py_BuildValue("O&",
846 CFDictionaryRefObj_New
, _rv
);
850 static PyObject
*CFDictionaryRefObj_CFDictionaryGetCount(CFDictionaryRefObject
*_self
, PyObject
*_args
)
852 PyObject
*_res
= NULL
;
854 #ifndef CFDictionaryGetCount
855 PyMac_PRECHECK(CFDictionaryGetCount
);
857 if (!PyArg_ParseTuple(_args
, ""))
859 _rv
= CFDictionaryGetCount(_self
->ob_itself
);
860 _res
= Py_BuildValue("l",
865 static PyMethodDef CFDictionaryRefObj_methods
[] = {
866 {"CFDictionaryCreateCopy", (PyCFunction
)CFDictionaryRefObj_CFDictionaryCreateCopy
, 1,
867 PyDoc_STR("() -> (CFDictionaryRef _rv)")},
868 {"CFDictionaryGetCount", (PyCFunction
)CFDictionaryRefObj_CFDictionaryGetCount
, 1,
869 PyDoc_STR("() -> (CFIndex _rv)")},
873 PyMethodChain CFDictionaryRefObj_chain
= { CFDictionaryRefObj_methods
, &CFTypeRefObj_chain
};
875 static PyObject
*CFDictionaryRefObj_getattr(CFDictionaryRefObject
*self
, char *name
)
877 return Py_FindMethodInChain(&CFDictionaryRefObj_chain
, (PyObject
*)self
, name
);
880 #define CFDictionaryRefObj_setattr NULL
882 static int CFDictionaryRefObj_compare(CFDictionaryRefObject
*self
, CFDictionaryRefObject
*other
)
884 /* XXXX Or should we use CFEqual?? */
885 if ( self
->ob_itself
> other
->ob_itself
) return 1;
886 if ( self
->ob_itself
< other
->ob_itself
) return -1;
890 static PyObject
* CFDictionaryRefObj_repr(CFDictionaryRefObject
*self
)
893 sprintf(buf
, "<CFDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
894 return PyString_FromString(buf
);
897 static int CFDictionaryRefObj_hash(CFDictionaryRefObject
*self
)
899 /* XXXX Or should we use CFHash?? */
900 return (int)self
->ob_itself
;
903 PyTypeObject CFDictionaryRef_Type
= {
904 PyObject_HEAD_INIT(NULL
)
906 "_CF.CFDictionaryRef", /*tp_name*/
907 sizeof(CFDictionaryRefObject
), /*tp_basicsize*/
910 (destructor
) CFDictionaryRefObj_dealloc
, /*tp_dealloc*/
912 (getattrfunc
) CFDictionaryRefObj_getattr
, /*tp_getattr*/
913 (setattrfunc
) CFDictionaryRefObj_setattr
, /*tp_setattr*/
914 (cmpfunc
) CFDictionaryRefObj_compare
, /*tp_compare*/
915 (reprfunc
) CFDictionaryRefObj_repr
, /*tp_repr*/
916 (PyNumberMethods
*)0, /* tp_as_number */
917 (PySequenceMethods
*)0, /* tp_as_sequence */
918 (PyMappingMethods
*)0, /* tp_as_mapping */
919 (hashfunc
) CFDictionaryRefObj_hash
, /*tp_hash*/
922 /* ---------------- End object type CFDictionaryRef ----------------- */
925 /* --------------- Object type CFMutableDictionaryRef --------------- */
927 PyTypeObject CFMutableDictionaryRef_Type
;
929 #define CFMutableDictionaryRefObj_Check(x) ((x)->ob_type == &CFMutableDictionaryRef_Type || PyObject_TypeCheck((x), &CFMutableDictionaryRef_Type))
931 typedef struct CFMutableDictionaryRefObject
{
933 CFMutableDictionaryRef ob_itself
;
934 void (*ob_freeit
)(CFTypeRef ptr
);
935 } CFMutableDictionaryRefObject
;
937 PyObject
*CFMutableDictionaryRefObj_New(CFMutableDictionaryRef itself
)
939 CFMutableDictionaryRefObject
*it
;
942 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
945 it
= PyObject_NEW(CFMutableDictionaryRefObject
, &CFMutableDictionaryRef_Type
);
946 if (it
== NULL
) return NULL
;
947 it
->ob_itself
= itself
;
948 it
->ob_freeit
= CFRelease
;
949 return (PyObject
*)it
;
951 int CFMutableDictionaryRefObj_Convert(PyObject
*v
, CFMutableDictionaryRef
*p_itself
)
954 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
955 /* Check for other CF objects here */
957 if (!CFMutableDictionaryRefObj_Check(v
))
959 PyErr_SetString(PyExc_TypeError
, "CFMutableDictionaryRef required");
962 *p_itself
= ((CFMutableDictionaryRefObject
*)v
)->ob_itself
;
966 static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject
*self
)
968 if (self
->ob_freeit
&& self
->ob_itself
)
970 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
972 PyObject_Free((PyObject
*)self
);
975 static PyObject
*CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject
*_self
, PyObject
*_args
)
977 PyObject
*_res
= NULL
;
978 #ifndef CFDictionaryRemoveAllValues
979 PyMac_PRECHECK(CFDictionaryRemoveAllValues
);
981 if (!PyArg_ParseTuple(_args
, ""))
983 CFDictionaryRemoveAllValues(_self
->ob_itself
);
989 static PyMethodDef CFMutableDictionaryRefObj_methods
[] = {
990 {"CFDictionaryRemoveAllValues", (PyCFunction
)CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues
, 1,
991 PyDoc_STR("() -> None")},
995 PyMethodChain CFMutableDictionaryRefObj_chain
= { CFMutableDictionaryRefObj_methods
, &CFDictionaryRefObj_chain
};
997 static PyObject
*CFMutableDictionaryRefObj_getattr(CFMutableDictionaryRefObject
*self
, char *name
)
999 return Py_FindMethodInChain(&CFMutableDictionaryRefObj_chain
, (PyObject
*)self
, name
);
1002 #define CFMutableDictionaryRefObj_setattr NULL
1004 static int CFMutableDictionaryRefObj_compare(CFMutableDictionaryRefObject
*self
, CFMutableDictionaryRefObject
*other
)
1006 /* XXXX Or should we use CFEqual?? */
1007 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1008 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1012 static PyObject
* CFMutableDictionaryRefObj_repr(CFMutableDictionaryRefObject
*self
)
1015 sprintf(buf
, "<CFMutableDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
1016 return PyString_FromString(buf
);
1019 static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject
*self
)
1021 /* XXXX Or should we use CFHash?? */
1022 return (int)self
->ob_itself
;
1025 PyTypeObject CFMutableDictionaryRef_Type
= {
1026 PyObject_HEAD_INIT(NULL
)
1028 "_CF.CFMutableDictionaryRef", /*tp_name*/
1029 sizeof(CFMutableDictionaryRefObject
), /*tp_basicsize*/
1032 (destructor
) CFMutableDictionaryRefObj_dealloc
, /*tp_dealloc*/
1034 (getattrfunc
) CFMutableDictionaryRefObj_getattr
, /*tp_getattr*/
1035 (setattrfunc
) CFMutableDictionaryRefObj_setattr
, /*tp_setattr*/
1036 (cmpfunc
) CFMutableDictionaryRefObj_compare
, /*tp_compare*/
1037 (reprfunc
) CFMutableDictionaryRefObj_repr
, /*tp_repr*/
1038 (PyNumberMethods
*)0, /* tp_as_number */
1039 (PySequenceMethods
*)0, /* tp_as_sequence */
1040 (PyMappingMethods
*)0, /* tp_as_mapping */
1041 (hashfunc
) CFMutableDictionaryRefObj_hash
, /*tp_hash*/
1044 /* ------------- End object type CFMutableDictionaryRef ------------- */
1047 /* --------------------- Object type CFDataRef ---------------------- */
1049 PyTypeObject CFDataRef_Type
;
1051 #define CFDataRefObj_Check(x) ((x)->ob_type == &CFDataRef_Type || PyObject_TypeCheck((x), &CFDataRef_Type))
1053 typedef struct CFDataRefObject
{
1055 CFDataRef ob_itself
;
1056 void (*ob_freeit
)(CFTypeRef ptr
);
1059 PyObject
*CFDataRefObj_New(CFDataRef itself
)
1061 CFDataRefObject
*it
;
1064 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
1067 it
= PyObject_NEW(CFDataRefObject
, &CFDataRef_Type
);
1068 if (it
== NULL
) return NULL
;
1069 it
->ob_itself
= itself
;
1070 it
->ob_freeit
= CFRelease
;
1071 return (PyObject
*)it
;
1073 int CFDataRefObj_Convert(PyObject
*v
, CFDataRef
*p_itself
)
1076 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1077 if (PyString_Check(v
)) {
1080 if( PyString_AsStringAndSize(v
, &cStr
, &cLen
) < 0 ) return 0;
1081 *p_itself
= CFDataCreate((CFAllocatorRef
)NULL
, (unsigned char *)cStr
, cLen
);
1085 if (!CFDataRefObj_Check(v
))
1087 PyErr_SetString(PyExc_TypeError
, "CFDataRef required");
1090 *p_itself
= ((CFDataRefObject
*)v
)->ob_itself
;
1094 static void CFDataRefObj_dealloc(CFDataRefObject
*self
)
1096 if (self
->ob_freeit
&& self
->ob_itself
)
1098 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1100 PyObject_Free((PyObject
*)self
);
1103 static PyObject
*CFDataRefObj_CFDataCreateCopy(CFDataRefObject
*_self
, PyObject
*_args
)
1105 PyObject
*_res
= NULL
;
1107 if (!PyArg_ParseTuple(_args
, ""))
1109 _rv
= CFDataCreateCopy((CFAllocatorRef
)NULL
,
1111 _res
= Py_BuildValue("O&",
1112 CFDataRefObj_New
, _rv
);
1116 static PyObject
*CFDataRefObj_CFDataGetLength(CFDataRefObject
*_self
, PyObject
*_args
)
1118 PyObject
*_res
= NULL
;
1120 #ifndef CFDataGetLength
1121 PyMac_PRECHECK(CFDataGetLength
);
1123 if (!PyArg_ParseTuple(_args
, ""))
1125 _rv
= CFDataGetLength(_self
->ob_itself
);
1126 _res
= Py_BuildValue("l",
1131 static PyObject
*CFDataRefObj_CFStringCreateFromExternalRepresentation(CFDataRefObject
*_self
, PyObject
*_args
)
1133 PyObject
*_res
= NULL
;
1135 CFStringEncoding encoding
;
1136 if (!PyArg_ParseTuple(_args
, "l",
1139 _rv
= CFStringCreateFromExternalRepresentation((CFAllocatorRef
)NULL
,
1142 _res
= Py_BuildValue("O&",
1143 CFStringRefObj_New
, _rv
);
1147 static PyObject
*CFDataRefObj_CFDataGetData(CFDataRefObject
*_self
, PyObject
*_args
)
1149 PyObject
*_res
= NULL
;
1151 int size
= CFDataGetLength(_self
->ob_itself
);
1152 char *data
= (char *)CFDataGetBytePtr(_self
->ob_itself
);
1154 _res
= (PyObject
*)PyString_FromStringAndSize(data
, size
);
1159 static PyMethodDef CFDataRefObj_methods
[] = {
1160 {"CFDataCreateCopy", (PyCFunction
)CFDataRefObj_CFDataCreateCopy
, 1,
1161 PyDoc_STR("() -> (CFDataRef _rv)")},
1162 {"CFDataGetLength", (PyCFunction
)CFDataRefObj_CFDataGetLength
, 1,
1163 PyDoc_STR("() -> (CFIndex _rv)")},
1164 {"CFStringCreateFromExternalRepresentation", (PyCFunction
)CFDataRefObj_CFStringCreateFromExternalRepresentation
, 1,
1165 PyDoc_STR("(CFStringEncoding encoding) -> (CFStringRef _rv)")},
1166 {"CFDataGetData", (PyCFunction
)CFDataRefObj_CFDataGetData
, 1,
1167 PyDoc_STR("() -> (string _rv)")},
1171 PyMethodChain CFDataRefObj_chain
= { CFDataRefObj_methods
, &CFTypeRefObj_chain
};
1173 static PyObject
*CFDataRefObj_getattr(CFDataRefObject
*self
, char *name
)
1175 return Py_FindMethodInChain(&CFDataRefObj_chain
, (PyObject
*)self
, name
);
1178 #define CFDataRefObj_setattr NULL
1180 static int CFDataRefObj_compare(CFDataRefObject
*self
, CFDataRefObject
*other
)
1182 /* XXXX Or should we use CFEqual?? */
1183 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1184 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1188 static PyObject
* CFDataRefObj_repr(CFDataRefObject
*self
)
1191 sprintf(buf
, "<CFDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
1192 return PyString_FromString(buf
);
1195 static int CFDataRefObj_hash(CFDataRefObject
*self
)
1197 /* XXXX Or should we use CFHash?? */
1198 return (int)self
->ob_itself
;
1201 PyTypeObject CFDataRef_Type
= {
1202 PyObject_HEAD_INIT(NULL
)
1204 "_CF.CFDataRef", /*tp_name*/
1205 sizeof(CFDataRefObject
), /*tp_basicsize*/
1208 (destructor
) CFDataRefObj_dealloc
, /*tp_dealloc*/
1210 (getattrfunc
) CFDataRefObj_getattr
, /*tp_getattr*/
1211 (setattrfunc
) CFDataRefObj_setattr
, /*tp_setattr*/
1212 (cmpfunc
) CFDataRefObj_compare
, /*tp_compare*/
1213 (reprfunc
) CFDataRefObj_repr
, /*tp_repr*/
1214 (PyNumberMethods
*)0, /* tp_as_number */
1215 (PySequenceMethods
*)0, /* tp_as_sequence */
1216 (PyMappingMethods
*)0, /* tp_as_mapping */
1217 (hashfunc
) CFDataRefObj_hash
, /*tp_hash*/
1220 /* ------------------- End object type CFDataRef -------------------- */
1223 /* ------------------ Object type CFMutableDataRef ------------------ */
1225 PyTypeObject CFMutableDataRef_Type
;
1227 #define CFMutableDataRefObj_Check(x) ((x)->ob_type == &CFMutableDataRef_Type || PyObject_TypeCheck((x), &CFMutableDataRef_Type))
1229 typedef struct CFMutableDataRefObject
{
1231 CFMutableDataRef ob_itself
;
1232 void (*ob_freeit
)(CFTypeRef ptr
);
1233 } CFMutableDataRefObject
;
1235 PyObject
*CFMutableDataRefObj_New(CFMutableDataRef itself
)
1237 CFMutableDataRefObject
*it
;
1240 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
1243 it
= PyObject_NEW(CFMutableDataRefObject
, &CFMutableDataRef_Type
);
1244 if (it
== NULL
) return NULL
;
1245 it
->ob_itself
= itself
;
1246 it
->ob_freeit
= CFRelease
;
1247 return (PyObject
*)it
;
1249 int CFMutableDataRefObj_Convert(PyObject
*v
, CFMutableDataRef
*p_itself
)
1252 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1253 /* Check for other CF objects here */
1255 if (!CFMutableDataRefObj_Check(v
))
1257 PyErr_SetString(PyExc_TypeError
, "CFMutableDataRef required");
1260 *p_itself
= ((CFMutableDataRefObject
*)v
)->ob_itself
;
1264 static void CFMutableDataRefObj_dealloc(CFMutableDataRefObject
*self
)
1266 if (self
->ob_freeit
&& self
->ob_itself
)
1268 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1270 PyObject_Free((PyObject
*)self
);
1273 static PyObject
*CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1275 PyObject
*_res
= NULL
;
1277 #ifndef CFDataSetLength
1278 PyMac_PRECHECK(CFDataSetLength
);
1280 if (!PyArg_ParseTuple(_args
, "l",
1283 CFDataSetLength(_self
->ob_itself
,
1290 static PyObject
*CFMutableDataRefObj_CFDataIncreaseLength(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1292 PyObject
*_res
= NULL
;
1293 CFIndex extraLength
;
1294 #ifndef CFDataIncreaseLength
1295 PyMac_PRECHECK(CFDataIncreaseLength
);
1297 if (!PyArg_ParseTuple(_args
, "l",
1300 CFDataIncreaseLength(_self
->ob_itself
,
1307 static PyObject
*CFMutableDataRefObj_CFDataAppendBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1309 PyObject
*_res
= NULL
;
1310 unsigned char *bytes__in__
;
1312 int bytes__in_len__
;
1313 #ifndef CFDataAppendBytes
1314 PyMac_PRECHECK(CFDataAppendBytes
);
1316 if (!PyArg_ParseTuple(_args
, "s#",
1317 &bytes__in__
, &bytes__in_len__
))
1319 bytes__len__
= bytes__in_len__
;
1320 CFDataAppendBytes(_self
->ob_itself
,
1321 bytes__in__
, bytes__len__
);
1327 static PyObject
*CFMutableDataRefObj_CFDataReplaceBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1329 PyObject
*_res
= NULL
;
1331 unsigned char *newBytes__in__
;
1332 long newBytes__len__
;
1333 int newBytes__in_len__
;
1334 #ifndef CFDataReplaceBytes
1335 PyMac_PRECHECK(CFDataReplaceBytes
);
1337 if (!PyArg_ParseTuple(_args
, "O&s#",
1338 CFRange_Convert
, &range
,
1339 &newBytes__in__
, &newBytes__in_len__
))
1341 newBytes__len__
= newBytes__in_len__
;
1342 CFDataReplaceBytes(_self
->ob_itself
,
1344 newBytes__in__
, newBytes__len__
);
1350 static PyObject
*CFMutableDataRefObj_CFDataDeleteBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1352 PyObject
*_res
= NULL
;
1354 #ifndef CFDataDeleteBytes
1355 PyMac_PRECHECK(CFDataDeleteBytes
);
1357 if (!PyArg_ParseTuple(_args
, "O&",
1358 CFRange_Convert
, &range
))
1360 CFDataDeleteBytes(_self
->ob_itself
,
1367 static PyMethodDef CFMutableDataRefObj_methods
[] = {
1368 {"CFDataSetLength", (PyCFunction
)CFMutableDataRefObj_CFDataSetLength
, 1,
1369 PyDoc_STR("(CFIndex length) -> None")},
1370 {"CFDataIncreaseLength", (PyCFunction
)CFMutableDataRefObj_CFDataIncreaseLength
, 1,
1371 PyDoc_STR("(CFIndex extraLength) -> None")},
1372 {"CFDataAppendBytes", (PyCFunction
)CFMutableDataRefObj_CFDataAppendBytes
, 1,
1373 PyDoc_STR("(Buffer bytes) -> None")},
1374 {"CFDataReplaceBytes", (PyCFunction
)CFMutableDataRefObj_CFDataReplaceBytes
, 1,
1375 PyDoc_STR("(CFRange range, Buffer newBytes) -> None")},
1376 {"CFDataDeleteBytes", (PyCFunction
)CFMutableDataRefObj_CFDataDeleteBytes
, 1,
1377 PyDoc_STR("(CFRange range) -> None")},
1381 PyMethodChain CFMutableDataRefObj_chain
= { CFMutableDataRefObj_methods
, &CFDataRefObj_chain
};
1383 static PyObject
*CFMutableDataRefObj_getattr(CFMutableDataRefObject
*self
, char *name
)
1385 return Py_FindMethodInChain(&CFMutableDataRefObj_chain
, (PyObject
*)self
, name
);
1388 #define CFMutableDataRefObj_setattr NULL
1390 static int CFMutableDataRefObj_compare(CFMutableDataRefObject
*self
, CFMutableDataRefObject
*other
)
1392 /* XXXX Or should we use CFEqual?? */
1393 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1394 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1398 static PyObject
* CFMutableDataRefObj_repr(CFMutableDataRefObject
*self
)
1401 sprintf(buf
, "<CFMutableDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
1402 return PyString_FromString(buf
);
1405 static int CFMutableDataRefObj_hash(CFMutableDataRefObject
*self
)
1407 /* XXXX Or should we use CFHash?? */
1408 return (int)self
->ob_itself
;
1411 PyTypeObject CFMutableDataRef_Type
= {
1412 PyObject_HEAD_INIT(NULL
)
1414 "_CF.CFMutableDataRef", /*tp_name*/
1415 sizeof(CFMutableDataRefObject
), /*tp_basicsize*/
1418 (destructor
) CFMutableDataRefObj_dealloc
, /*tp_dealloc*/
1420 (getattrfunc
) CFMutableDataRefObj_getattr
, /*tp_getattr*/
1421 (setattrfunc
) CFMutableDataRefObj_setattr
, /*tp_setattr*/
1422 (cmpfunc
) CFMutableDataRefObj_compare
, /*tp_compare*/
1423 (reprfunc
) CFMutableDataRefObj_repr
, /*tp_repr*/
1424 (PyNumberMethods
*)0, /* tp_as_number */
1425 (PySequenceMethods
*)0, /* tp_as_sequence */
1426 (PyMappingMethods
*)0, /* tp_as_mapping */
1427 (hashfunc
) CFMutableDataRefObj_hash
, /*tp_hash*/
1430 /* ---------------- End object type CFMutableDataRef ---------------- */
1433 /* -------------------- Object type CFStringRef --------------------- */
1435 PyTypeObject CFStringRef_Type
;
1437 #define CFStringRefObj_Check(x) ((x)->ob_type == &CFStringRef_Type || PyObject_TypeCheck((x), &CFStringRef_Type))
1439 typedef struct CFStringRefObject
{
1441 CFStringRef ob_itself
;
1442 void (*ob_freeit
)(CFTypeRef ptr
);
1443 } CFStringRefObject
;
1445 PyObject
*CFStringRefObj_New(CFStringRef itself
)
1447 CFStringRefObject
*it
;
1450 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
1453 it
= PyObject_NEW(CFStringRefObject
, &CFStringRef_Type
);
1454 if (it
== NULL
) return NULL
;
1455 it
->ob_itself
= itself
;
1456 it
->ob_freeit
= CFRelease
;
1457 return (PyObject
*)it
;
1459 int CFStringRefObj_Convert(PyObject
*v
, CFStringRef
*p_itself
)
1462 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1463 if (PyString_Check(v
)) {
1465 if (!PyArg_Parse(v
, "es", "ascii", &cStr
))
1467 *p_itself
= CFStringCreateWithCString((CFAllocatorRef
)NULL
, cStr
, kCFStringEncodingASCII
);
1470 if (PyUnicode_Check(v
)) {
1471 /* We use the CF types here, if Python was configured differently that will give an error */
1472 CFIndex size
= PyUnicode_GetSize(v
);
1473 UniChar
*unichars
= PyUnicode_AsUnicode(v
);
1474 if (!unichars
) return 0;
1475 *p_itself
= CFStringCreateWithCharacters((CFAllocatorRef
)NULL
, unichars
, size
);
1480 if (!CFStringRefObj_Check(v
))
1482 PyErr_SetString(PyExc_TypeError
, "CFStringRef required");
1485 *p_itself
= ((CFStringRefObject
*)v
)->ob_itself
;
1489 static void CFStringRefObj_dealloc(CFStringRefObject
*self
)
1491 if (self
->ob_freeit
&& self
->ob_itself
)
1493 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1495 PyObject_Free((PyObject
*)self
);
1498 static PyObject
*CFStringRefObj_CFStringCreateWithSubstring(CFStringRefObject
*_self
, PyObject
*_args
)
1500 PyObject
*_res
= NULL
;
1503 if (!PyArg_ParseTuple(_args
, "O&",
1504 CFRange_Convert
, &range
))
1506 _rv
= CFStringCreateWithSubstring((CFAllocatorRef
)NULL
,
1509 _res
= Py_BuildValue("O&",
1510 CFStringRefObj_New
, _rv
);
1514 static PyObject
*CFStringRefObj_CFStringCreateCopy(CFStringRefObject
*_self
, PyObject
*_args
)
1516 PyObject
*_res
= NULL
;
1518 if (!PyArg_ParseTuple(_args
, ""))
1520 _rv
= CFStringCreateCopy((CFAllocatorRef
)NULL
,
1522 _res
= Py_BuildValue("O&",
1523 CFStringRefObj_New
, _rv
);
1527 static PyObject
*CFStringRefObj_CFStringGetLength(CFStringRefObject
*_self
, PyObject
*_args
)
1529 PyObject
*_res
= NULL
;
1531 #ifndef CFStringGetLength
1532 PyMac_PRECHECK(CFStringGetLength
);
1534 if (!PyArg_ParseTuple(_args
, ""))
1536 _rv
= CFStringGetLength(_self
->ob_itself
);
1537 _res
= Py_BuildValue("l",
1542 static PyObject
*CFStringRefObj_CFStringGetBytes(CFStringRefObject
*_self
, PyObject
*_args
)
1544 PyObject
*_res
= NULL
;
1547 CFStringEncoding encoding
;
1549 Boolean isExternalRepresentation
;
1553 #ifndef CFStringGetBytes
1554 PyMac_PRECHECK(CFStringGetBytes
);
1556 if (!PyArg_ParseTuple(_args
, "O&lbll",
1557 CFRange_Convert
, &range
,
1560 &isExternalRepresentation
,
1563 _rv
= CFStringGetBytes(_self
->ob_itself
,
1567 isExternalRepresentation
,
1571 _res
= Py_BuildValue("lbl",
1578 static PyObject
*CFStringRefObj_CFStringCreateExternalRepresentation(CFStringRefObject
*_self
, PyObject
*_args
)
1580 PyObject
*_res
= NULL
;
1582 CFStringEncoding encoding
;
1584 if (!PyArg_ParseTuple(_args
, "lb",
1588 _rv
= CFStringCreateExternalRepresentation((CFAllocatorRef
)NULL
,
1592 _res
= Py_BuildValue("O&",
1593 CFDataRefObj_New
, _rv
);
1597 static PyObject
*CFStringRefObj_CFStringGetSmallestEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
1599 PyObject
*_res
= NULL
;
1600 CFStringEncoding _rv
;
1601 #ifndef CFStringGetSmallestEncoding
1602 PyMac_PRECHECK(CFStringGetSmallestEncoding
);
1604 if (!PyArg_ParseTuple(_args
, ""))
1606 _rv
= CFStringGetSmallestEncoding(_self
->ob_itself
);
1607 _res
= Py_BuildValue("l",
1612 static PyObject
*CFStringRefObj_CFStringGetFastestEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
1614 PyObject
*_res
= NULL
;
1615 CFStringEncoding _rv
;
1616 #ifndef CFStringGetFastestEncoding
1617 PyMac_PRECHECK(CFStringGetFastestEncoding
);
1619 if (!PyArg_ParseTuple(_args
, ""))
1621 _rv
= CFStringGetFastestEncoding(_self
->ob_itself
);
1622 _res
= Py_BuildValue("l",
1627 static PyObject
*CFStringRefObj_CFStringCompareWithOptions(CFStringRefObject
*_self
, PyObject
*_args
)
1629 PyObject
*_res
= NULL
;
1630 CFComparisonResult _rv
;
1631 CFStringRef theString2
;
1632 CFRange rangeToCompare
;
1633 CFOptionFlags compareOptions
;
1634 #ifndef CFStringCompareWithOptions
1635 PyMac_PRECHECK(CFStringCompareWithOptions
);
1637 if (!PyArg_ParseTuple(_args
, "O&O&l",
1638 CFStringRefObj_Convert
, &theString2
,
1639 CFRange_Convert
, &rangeToCompare
,
1642 _rv
= CFStringCompareWithOptions(_self
->ob_itself
,
1646 _res
= Py_BuildValue("l",
1651 static PyObject
*CFStringRefObj_CFStringCompare(CFStringRefObject
*_self
, PyObject
*_args
)
1653 PyObject
*_res
= NULL
;
1654 CFComparisonResult _rv
;
1655 CFStringRef theString2
;
1656 CFOptionFlags compareOptions
;
1657 #ifndef CFStringCompare
1658 PyMac_PRECHECK(CFStringCompare
);
1660 if (!PyArg_ParseTuple(_args
, "O&l",
1661 CFStringRefObj_Convert
, &theString2
,
1664 _rv
= CFStringCompare(_self
->ob_itself
,
1667 _res
= Py_BuildValue("l",
1672 static PyObject
*CFStringRefObj_CFStringFindWithOptions(CFStringRefObject
*_self
, PyObject
*_args
)
1674 PyObject
*_res
= NULL
;
1676 CFStringRef stringToFind
;
1677 CFRange rangeToSearch
;
1678 CFOptionFlags searchOptions
;
1680 #ifndef CFStringFindWithOptions
1681 PyMac_PRECHECK(CFStringFindWithOptions
);
1683 if (!PyArg_ParseTuple(_args
, "O&O&l",
1684 CFStringRefObj_Convert
, &stringToFind
,
1685 CFRange_Convert
, &rangeToSearch
,
1688 _rv
= CFStringFindWithOptions(_self
->ob_itself
,
1693 _res
= Py_BuildValue("lO&",
1695 CFRange_New
, result
);
1699 static PyObject
*CFStringRefObj_CFStringCreateArrayWithFindResults(CFStringRefObject
*_self
, PyObject
*_args
)
1701 PyObject
*_res
= NULL
;
1703 CFStringRef stringToFind
;
1704 CFRange rangeToSearch
;
1705 CFOptionFlags compareOptions
;
1706 if (!PyArg_ParseTuple(_args
, "O&O&l",
1707 CFStringRefObj_Convert
, &stringToFind
,
1708 CFRange_Convert
, &rangeToSearch
,
1711 _rv
= CFStringCreateArrayWithFindResults((CFAllocatorRef
)NULL
,
1716 _res
= Py_BuildValue("O&",
1717 CFArrayRefObj_New
, _rv
);
1721 static PyObject
*CFStringRefObj_CFStringFind(CFStringRefObject
*_self
, PyObject
*_args
)
1723 PyObject
*_res
= NULL
;
1725 CFStringRef stringToFind
;
1726 CFOptionFlags compareOptions
;
1727 #ifndef CFStringFind
1728 PyMac_PRECHECK(CFStringFind
);
1730 if (!PyArg_ParseTuple(_args
, "O&l",
1731 CFStringRefObj_Convert
, &stringToFind
,
1734 _rv
= CFStringFind(_self
->ob_itself
,
1737 _res
= Py_BuildValue("O&",
1742 static PyObject
*CFStringRefObj_CFStringHasPrefix(CFStringRefObject
*_self
, PyObject
*_args
)
1744 PyObject
*_res
= NULL
;
1747 #ifndef CFStringHasPrefix
1748 PyMac_PRECHECK(CFStringHasPrefix
);
1750 if (!PyArg_ParseTuple(_args
, "O&",
1751 CFStringRefObj_Convert
, &prefix
))
1753 _rv
= CFStringHasPrefix(_self
->ob_itself
,
1755 _res
= Py_BuildValue("l",
1760 static PyObject
*CFStringRefObj_CFStringHasSuffix(CFStringRefObject
*_self
, PyObject
*_args
)
1762 PyObject
*_res
= NULL
;
1765 #ifndef CFStringHasSuffix
1766 PyMac_PRECHECK(CFStringHasSuffix
);
1768 if (!PyArg_ParseTuple(_args
, "O&",
1769 CFStringRefObj_Convert
, &suffix
))
1771 _rv
= CFStringHasSuffix(_self
->ob_itself
,
1773 _res
= Py_BuildValue("l",
1778 static PyObject
*CFStringRefObj_CFStringGetLineBounds(CFStringRefObject
*_self
, PyObject
*_args
)
1780 PyObject
*_res
= NULL
;
1782 CFIndex lineBeginIndex
;
1783 CFIndex lineEndIndex
;
1784 CFIndex contentsEndIndex
;
1785 #ifndef CFStringGetLineBounds
1786 PyMac_PRECHECK(CFStringGetLineBounds
);
1788 if (!PyArg_ParseTuple(_args
, "O&",
1789 CFRange_Convert
, &range
))
1791 CFStringGetLineBounds(_self
->ob_itself
,
1796 _res
= Py_BuildValue("lll",
1803 static PyObject
*CFStringRefObj_CFStringCreateArrayBySeparatingStrings(CFStringRefObject
*_self
, PyObject
*_args
)
1805 PyObject
*_res
= NULL
;
1807 CFStringRef separatorString
;
1808 if (!PyArg_ParseTuple(_args
, "O&",
1809 CFStringRefObj_Convert
, &separatorString
))
1811 _rv
= CFStringCreateArrayBySeparatingStrings((CFAllocatorRef
)NULL
,
1814 _res
= Py_BuildValue("O&",
1815 CFArrayRefObj_New
, _rv
);
1819 static PyObject
*CFStringRefObj_CFStringGetIntValue(CFStringRefObject
*_self
, PyObject
*_args
)
1821 PyObject
*_res
= NULL
;
1823 #ifndef CFStringGetIntValue
1824 PyMac_PRECHECK(CFStringGetIntValue
);
1826 if (!PyArg_ParseTuple(_args
, ""))
1828 _rv
= CFStringGetIntValue(_self
->ob_itself
);
1829 _res
= Py_BuildValue("l",
1834 static PyObject
*CFStringRefObj_CFStringGetDoubleValue(CFStringRefObject
*_self
, PyObject
*_args
)
1836 PyObject
*_res
= NULL
;
1838 #ifndef CFStringGetDoubleValue
1839 PyMac_PRECHECK(CFStringGetDoubleValue
);
1841 if (!PyArg_ParseTuple(_args
, ""))
1843 _rv
= CFStringGetDoubleValue(_self
->ob_itself
);
1844 _res
= Py_BuildValue("d",
1849 static PyObject
*CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
1851 PyObject
*_res
= NULL
;
1852 CFStringEncoding _rv
;
1853 #ifndef CFStringConvertIANACharSetNameToEncoding
1854 PyMac_PRECHECK(CFStringConvertIANACharSetNameToEncoding
);
1856 if (!PyArg_ParseTuple(_args
, ""))
1858 _rv
= CFStringConvertIANACharSetNameToEncoding(_self
->ob_itself
);
1859 _res
= Py_BuildValue("l",
1864 static PyObject
*CFStringRefObj_CFShowStr(CFStringRefObject
*_self
, PyObject
*_args
)
1866 PyObject
*_res
= NULL
;
1868 PyMac_PRECHECK(CFShowStr
);
1870 if (!PyArg_ParseTuple(_args
, ""))
1872 CFShowStr(_self
->ob_itself
);
1878 static PyObject
*CFStringRefObj_CFURLCreateWithString(CFStringRefObject
*_self
, PyObject
*_args
)
1880 PyObject
*_res
= NULL
;
1883 if (!PyArg_ParseTuple(_args
, "O&",
1884 OptionalCFURLRefObj_Convert
, &baseURL
))
1886 _rv
= CFURLCreateWithString((CFAllocatorRef
)NULL
,
1889 _res
= Py_BuildValue("O&",
1890 CFURLRefObj_New
, _rv
);
1894 static PyObject
*CFStringRefObj_CFURLCreateWithFileSystemPath(CFStringRefObject
*_self
, PyObject
*_args
)
1896 PyObject
*_res
= NULL
;
1898 CFURLPathStyle pathStyle
;
1899 Boolean isDirectory
;
1900 if (!PyArg_ParseTuple(_args
, "ll",
1904 _rv
= CFURLCreateWithFileSystemPath((CFAllocatorRef
)NULL
,
1908 _res
= Py_BuildValue("O&",
1909 CFURLRefObj_New
, _rv
);
1913 static PyObject
*CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase(CFStringRefObject
*_self
, PyObject
*_args
)
1915 PyObject
*_res
= NULL
;
1917 CFURLPathStyle pathStyle
;
1918 Boolean isDirectory
;
1920 if (!PyArg_ParseTuple(_args
, "llO&",
1923 OptionalCFURLRefObj_Convert
, &baseURL
))
1925 _rv
= CFURLCreateWithFileSystemPathRelativeToBase((CFAllocatorRef
)NULL
,
1930 _res
= Py_BuildValue("O&",
1931 CFURLRefObj_New
, _rv
);
1935 static PyObject
*CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes(CFStringRefObject
*_self
, PyObject
*_args
)
1937 PyObject
*_res
= NULL
;
1939 CFStringRef charactersToLeaveEscaped
;
1940 if (!PyArg_ParseTuple(_args
, "O&",
1941 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
1943 _rv
= CFURLCreateStringByReplacingPercentEscapes((CFAllocatorRef
)NULL
,
1945 charactersToLeaveEscaped
);
1946 _res
= Py_BuildValue("O&",
1947 CFStringRefObj_New
, _rv
);
1951 static PyObject
*CFStringRefObj_CFURLCreateStringByAddingPercentEscapes(CFStringRefObject
*_self
, PyObject
*_args
)
1953 PyObject
*_res
= NULL
;
1955 CFStringRef charactersToLeaveUnescaped
;
1956 CFStringRef legalURLCharactersToBeEscaped
;
1957 CFStringEncoding encoding
;
1958 if (!PyArg_ParseTuple(_args
, "O&O&l",
1959 CFStringRefObj_Convert
, &charactersToLeaveUnescaped
,
1960 CFStringRefObj_Convert
, &legalURLCharactersToBeEscaped
,
1963 _rv
= CFURLCreateStringByAddingPercentEscapes((CFAllocatorRef
)NULL
,
1965 charactersToLeaveUnescaped
,
1966 legalURLCharactersToBeEscaped
,
1968 _res
= Py_BuildValue("O&",
1969 CFStringRefObj_New
, _rv
);
1973 static PyObject
*CFStringRefObj_CFStringGetString(CFStringRefObject
*_self
, PyObject
*_args
)
1975 PyObject
*_res
= NULL
;
1977 int size
= CFStringGetLength(_self
->ob_itself
)+1;
1978 char *data
= malloc(size
);
1980 if( data
== NULL
) return PyErr_NoMemory();
1981 if ( CFStringGetCString(_self
->ob_itself
, data
, size
, 0) ) {
1982 _res
= (PyObject
*)PyString_FromString(data
);
1984 PyErr_SetString(PyExc_RuntimeError
, "CFStringGetCString could not fit the string");
1992 static PyObject
*CFStringRefObj_CFStringGetUnicode(CFStringRefObject
*_self
, PyObject
*_args
)
1994 PyObject
*_res
= NULL
;
1996 int size
= CFStringGetLength(_self
->ob_itself
)+1;
1997 Py_UNICODE
*data
= malloc(size
*sizeof(Py_UNICODE
));
2001 range
.length
= size
;
2002 if( data
== NULL
) return PyErr_NoMemory();
2003 CFStringGetCharacters(_self
->ob_itself
, range
, data
);
2004 _res
= (PyObject
*)PyUnicode_FromUnicode(data
, size
);
2010 static PyMethodDef CFStringRefObj_methods
[] = {
2011 {"CFStringCreateWithSubstring", (PyCFunction
)CFStringRefObj_CFStringCreateWithSubstring
, 1,
2012 PyDoc_STR("(CFRange range) -> (CFStringRef _rv)")},
2013 {"CFStringCreateCopy", (PyCFunction
)CFStringRefObj_CFStringCreateCopy
, 1,
2014 PyDoc_STR("() -> (CFStringRef _rv)")},
2015 {"CFStringGetLength", (PyCFunction
)CFStringRefObj_CFStringGetLength
, 1,
2016 PyDoc_STR("() -> (CFIndex _rv)")},
2017 {"CFStringGetBytes", (PyCFunction
)CFStringRefObj_CFStringGetBytes
, 1,
2018 PyDoc_STR("(CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, CFIndex maxBufLen) -> (CFIndex _rv, UInt8 buffer, CFIndex usedBufLen)")},
2019 {"CFStringCreateExternalRepresentation", (PyCFunction
)CFStringRefObj_CFStringCreateExternalRepresentation
, 1,
2020 PyDoc_STR("(CFStringEncoding encoding, UInt8 lossByte) -> (CFDataRef _rv)")},
2021 {"CFStringGetSmallestEncoding", (PyCFunction
)CFStringRefObj_CFStringGetSmallestEncoding
, 1,
2022 PyDoc_STR("() -> (CFStringEncoding _rv)")},
2023 {"CFStringGetFastestEncoding", (PyCFunction
)CFStringRefObj_CFStringGetFastestEncoding
, 1,
2024 PyDoc_STR("() -> (CFStringEncoding _rv)")},
2025 {"CFStringCompareWithOptions", (PyCFunction
)CFStringRefObj_CFStringCompareWithOptions
, 1,
2026 PyDoc_STR("(CFStringRef theString2, CFRange rangeToCompare, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)")},
2027 {"CFStringCompare", (PyCFunction
)CFStringRefObj_CFStringCompare
, 1,
2028 PyDoc_STR("(CFStringRef theString2, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)")},
2029 {"CFStringFindWithOptions", (PyCFunction
)CFStringRefObj_CFStringFindWithOptions
, 1,
2030 PyDoc_STR("(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags searchOptions) -> (Boolean _rv, CFRange result)")},
2031 {"CFStringCreateArrayWithFindResults", (PyCFunction
)CFStringRefObj_CFStringCreateArrayWithFindResults
, 1,
2032 PyDoc_STR("(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions) -> (CFArrayRef _rv)")},
2033 {"CFStringFind", (PyCFunction
)CFStringRefObj_CFStringFind
, 1,
2034 PyDoc_STR("(CFStringRef stringToFind, CFOptionFlags compareOptions) -> (CFRange _rv)")},
2035 {"CFStringHasPrefix", (PyCFunction
)CFStringRefObj_CFStringHasPrefix
, 1,
2036 PyDoc_STR("(CFStringRef prefix) -> (Boolean _rv)")},
2037 {"CFStringHasSuffix", (PyCFunction
)CFStringRefObj_CFStringHasSuffix
, 1,
2038 PyDoc_STR("(CFStringRef suffix) -> (Boolean _rv)")},
2039 {"CFStringGetLineBounds", (PyCFunction
)CFStringRefObj_CFStringGetLineBounds
, 1,
2040 PyDoc_STR("(CFRange range) -> (CFIndex lineBeginIndex, CFIndex lineEndIndex, CFIndex contentsEndIndex)")},
2041 {"CFStringCreateArrayBySeparatingStrings", (PyCFunction
)CFStringRefObj_CFStringCreateArrayBySeparatingStrings
, 1,
2042 PyDoc_STR("(CFStringRef separatorString) -> (CFArrayRef _rv)")},
2043 {"CFStringGetIntValue", (PyCFunction
)CFStringRefObj_CFStringGetIntValue
, 1,
2044 PyDoc_STR("() -> (SInt32 _rv)")},
2045 {"CFStringGetDoubleValue", (PyCFunction
)CFStringRefObj_CFStringGetDoubleValue
, 1,
2046 PyDoc_STR("() -> (double _rv)")},
2047 {"CFStringConvertIANACharSetNameToEncoding", (PyCFunction
)CFStringRefObj_CFStringConvertIANACharSetNameToEncoding
, 1,
2048 PyDoc_STR("() -> (CFStringEncoding _rv)")},
2049 {"CFShowStr", (PyCFunction
)CFStringRefObj_CFShowStr
, 1,
2050 PyDoc_STR("() -> None")},
2051 {"CFURLCreateWithString", (PyCFunction
)CFStringRefObj_CFURLCreateWithString
, 1,
2052 PyDoc_STR("(CFURLRef baseURL) -> (CFURLRef _rv)")},
2053 {"CFURLCreateWithFileSystemPath", (PyCFunction
)CFStringRefObj_CFURLCreateWithFileSystemPath
, 1,
2054 PyDoc_STR("(CFURLPathStyle pathStyle, Boolean isDirectory) -> (CFURLRef _rv)")},
2055 {"CFURLCreateWithFileSystemPathRelativeToBase", (PyCFunction
)CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase
, 1,
2056 PyDoc_STR("(CFURLPathStyle pathStyle, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)")},
2057 {"CFURLCreateStringByReplacingPercentEscapes", (PyCFunction
)CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes
, 1,
2058 PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")},
2059 {"CFURLCreateStringByAddingPercentEscapes", (PyCFunction
)CFStringRefObj_CFURLCreateStringByAddingPercentEscapes
, 1,
2060 PyDoc_STR("(CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding) -> (CFStringRef _rv)")},
2061 {"CFStringGetString", (PyCFunction
)CFStringRefObj_CFStringGetString
, 1,
2062 PyDoc_STR("() -> (string _rv)")},
2063 {"CFStringGetUnicode", (PyCFunction
)CFStringRefObj_CFStringGetUnicode
, 1,
2064 PyDoc_STR("() -> (unicode _rv)")},
2068 PyMethodChain CFStringRefObj_chain
= { CFStringRefObj_methods
, &CFTypeRefObj_chain
};
2070 static PyObject
*CFStringRefObj_getattr(CFStringRefObject
*self
, char *name
)
2072 return Py_FindMethodInChain(&CFStringRefObj_chain
, (PyObject
*)self
, name
);
2075 #define CFStringRefObj_setattr NULL
2077 static int CFStringRefObj_compare(CFStringRefObject
*self
, CFStringRefObject
*other
)
2079 /* XXXX Or should we use CFEqual?? */
2080 if ( self
->ob_itself
> other
->ob_itself
) return 1;
2081 if ( self
->ob_itself
< other
->ob_itself
) return -1;
2085 static PyObject
* CFStringRefObj_repr(CFStringRefObject
*self
)
2088 sprintf(buf
, "<CFStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
2089 return PyString_FromString(buf
);
2092 static int CFStringRefObj_hash(CFStringRefObject
*self
)
2094 /* XXXX Or should we use CFHash?? */
2095 return (int)self
->ob_itself
;
2098 PyTypeObject CFStringRef_Type
= {
2099 PyObject_HEAD_INIT(NULL
)
2101 "_CF.CFStringRef", /*tp_name*/
2102 sizeof(CFStringRefObject
), /*tp_basicsize*/
2105 (destructor
) CFStringRefObj_dealloc
, /*tp_dealloc*/
2107 (getattrfunc
) CFStringRefObj_getattr
, /*tp_getattr*/
2108 (setattrfunc
) CFStringRefObj_setattr
, /*tp_setattr*/
2109 (cmpfunc
) CFStringRefObj_compare
, /*tp_compare*/
2110 (reprfunc
) CFStringRefObj_repr
, /*tp_repr*/
2111 (PyNumberMethods
*)0, /* tp_as_number */
2112 (PySequenceMethods
*)0, /* tp_as_sequence */
2113 (PyMappingMethods
*)0, /* tp_as_mapping */
2114 (hashfunc
) CFStringRefObj_hash
, /*tp_hash*/
2117 /* ------------------ End object type CFStringRef ------------------- */
2120 /* ----------------- Object type CFMutableStringRef ----------------- */
2122 PyTypeObject CFMutableStringRef_Type
;
2124 #define CFMutableStringRefObj_Check(x) ((x)->ob_type == &CFMutableStringRef_Type || PyObject_TypeCheck((x), &CFMutableStringRef_Type))
2126 typedef struct CFMutableStringRefObject
{
2128 CFMutableStringRef ob_itself
;
2129 void (*ob_freeit
)(CFTypeRef ptr
);
2130 } CFMutableStringRefObject
;
2132 PyObject
*CFMutableStringRefObj_New(CFMutableStringRef itself
)
2134 CFMutableStringRefObject
*it
;
2137 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
2140 it
= PyObject_NEW(CFMutableStringRefObject
, &CFMutableStringRef_Type
);
2141 if (it
== NULL
) return NULL
;
2142 it
->ob_itself
= itself
;
2143 it
->ob_freeit
= CFRelease
;
2144 return (PyObject
*)it
;
2146 int CFMutableStringRefObj_Convert(PyObject
*v
, CFMutableStringRef
*p_itself
)
2149 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
2150 /* Check for other CF objects here */
2152 if (!CFMutableStringRefObj_Check(v
))
2154 PyErr_SetString(PyExc_TypeError
, "CFMutableStringRef required");
2157 *p_itself
= ((CFMutableStringRefObject
*)v
)->ob_itself
;
2161 static void CFMutableStringRefObj_dealloc(CFMutableStringRefObject
*self
)
2163 if (self
->ob_freeit
&& self
->ob_itself
)
2165 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
2167 PyObject_Free((PyObject
*)self
);
2170 static PyObject
*CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2172 PyObject
*_res
= NULL
;
2173 CFStringRef appendedString
;
2174 #ifndef CFStringAppend
2175 PyMac_PRECHECK(CFStringAppend
);
2177 if (!PyArg_ParseTuple(_args
, "O&",
2178 CFStringRefObj_Convert
, &appendedString
))
2180 CFStringAppend(_self
->ob_itself
,
2187 static PyObject
*CFMutableStringRefObj_CFStringAppendCharacters(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2189 PyObject
*_res
= NULL
;
2190 UniChar
*chars__in__
;
2191 UniCharCount chars__len__
;
2192 int chars__in_len__
;
2193 #ifndef CFStringAppendCharacters
2194 PyMac_PRECHECK(CFStringAppendCharacters
);
2196 if (!PyArg_ParseTuple(_args
, "u#",
2197 &chars__in__
, &chars__in_len__
))
2199 chars__len__
= chars__in_len__
;
2200 CFStringAppendCharacters(_self
->ob_itself
,
2201 chars__in__
, chars__len__
);
2207 static PyObject
*CFMutableStringRefObj_CFStringAppendPascalString(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2209 PyObject
*_res
= NULL
;
2211 CFStringEncoding encoding
;
2212 #ifndef CFStringAppendPascalString
2213 PyMac_PRECHECK(CFStringAppendPascalString
);
2215 if (!PyArg_ParseTuple(_args
, "O&l",
2216 PyMac_GetStr255
, pStr
,
2219 CFStringAppendPascalString(_self
->ob_itself
,
2227 static PyObject
*CFMutableStringRefObj_CFStringAppendCString(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2229 PyObject
*_res
= NULL
;
2231 CFStringEncoding encoding
;
2232 #ifndef CFStringAppendCString
2233 PyMac_PRECHECK(CFStringAppendCString
);
2235 if (!PyArg_ParseTuple(_args
, "sl",
2239 CFStringAppendCString(_self
->ob_itself
,
2247 static PyObject
*CFMutableStringRefObj_CFStringInsert(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2249 PyObject
*_res
= NULL
;
2251 CFStringRef insertedStr
;
2252 #ifndef CFStringInsert
2253 PyMac_PRECHECK(CFStringInsert
);
2255 if (!PyArg_ParseTuple(_args
, "lO&",
2257 CFStringRefObj_Convert
, &insertedStr
))
2259 CFStringInsert(_self
->ob_itself
,
2267 static PyObject
*CFMutableStringRefObj_CFStringDelete(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2269 PyObject
*_res
= NULL
;
2271 #ifndef CFStringDelete
2272 PyMac_PRECHECK(CFStringDelete
);
2274 if (!PyArg_ParseTuple(_args
, "O&",
2275 CFRange_Convert
, &range
))
2277 CFStringDelete(_self
->ob_itself
,
2284 static PyObject
*CFMutableStringRefObj_CFStringReplace(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2286 PyObject
*_res
= NULL
;
2288 CFStringRef replacement
;
2289 #ifndef CFStringReplace
2290 PyMac_PRECHECK(CFStringReplace
);
2292 if (!PyArg_ParseTuple(_args
, "O&O&",
2293 CFRange_Convert
, &range
,
2294 CFStringRefObj_Convert
, &replacement
))
2296 CFStringReplace(_self
->ob_itself
,
2304 static PyObject
*CFMutableStringRefObj_CFStringReplaceAll(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2306 PyObject
*_res
= NULL
;
2307 CFStringRef replacement
;
2308 #ifndef CFStringReplaceAll
2309 PyMac_PRECHECK(CFStringReplaceAll
);
2311 if (!PyArg_ParseTuple(_args
, "O&",
2312 CFStringRefObj_Convert
, &replacement
))
2314 CFStringReplaceAll(_self
->ob_itself
,
2321 static PyObject
*CFMutableStringRefObj_CFStringPad(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2323 PyObject
*_res
= NULL
;
2324 CFStringRef padString
;
2326 CFIndex indexIntoPad
;
2328 PyMac_PRECHECK(CFStringPad
);
2330 if (!PyArg_ParseTuple(_args
, "O&ll",
2331 CFStringRefObj_Convert
, &padString
,
2335 CFStringPad(_self
->ob_itself
,
2344 static PyObject
*CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2346 PyObject
*_res
= NULL
;
2347 CFStringRef trimString
;
2348 #ifndef CFStringTrim
2349 PyMac_PRECHECK(CFStringTrim
);
2351 if (!PyArg_ParseTuple(_args
, "O&",
2352 CFStringRefObj_Convert
, &trimString
))
2354 CFStringTrim(_self
->ob_itself
,
2361 static PyObject
*CFMutableStringRefObj_CFStringTrimWhitespace(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2363 PyObject
*_res
= NULL
;
2364 #ifndef CFStringTrimWhitespace
2365 PyMac_PRECHECK(CFStringTrimWhitespace
);
2367 if (!PyArg_ParseTuple(_args
, ""))
2369 CFStringTrimWhitespace(_self
->ob_itself
);
2375 static PyMethodDef CFMutableStringRefObj_methods
[] = {
2376 {"CFStringAppend", (PyCFunction
)CFMutableStringRefObj_CFStringAppend
, 1,
2377 PyDoc_STR("(CFStringRef appendedString) -> None")},
2378 {"CFStringAppendCharacters", (PyCFunction
)CFMutableStringRefObj_CFStringAppendCharacters
, 1,
2379 PyDoc_STR("(Buffer chars) -> None")},
2380 {"CFStringAppendPascalString", (PyCFunction
)CFMutableStringRefObj_CFStringAppendPascalString
, 1,
2381 PyDoc_STR("(Str255 pStr, CFStringEncoding encoding) -> None")},
2382 {"CFStringAppendCString", (PyCFunction
)CFMutableStringRefObj_CFStringAppendCString
, 1,
2383 PyDoc_STR("(char* cStr, CFStringEncoding encoding) -> None")},
2384 {"CFStringInsert", (PyCFunction
)CFMutableStringRefObj_CFStringInsert
, 1,
2385 PyDoc_STR("(CFIndex idx, CFStringRef insertedStr) -> None")},
2386 {"CFStringDelete", (PyCFunction
)CFMutableStringRefObj_CFStringDelete
, 1,
2387 PyDoc_STR("(CFRange range) -> None")},
2388 {"CFStringReplace", (PyCFunction
)CFMutableStringRefObj_CFStringReplace
, 1,
2389 PyDoc_STR("(CFRange range, CFStringRef replacement) -> None")},
2390 {"CFStringReplaceAll", (PyCFunction
)CFMutableStringRefObj_CFStringReplaceAll
, 1,
2391 PyDoc_STR("(CFStringRef replacement) -> None")},
2392 {"CFStringPad", (PyCFunction
)CFMutableStringRefObj_CFStringPad
, 1,
2393 PyDoc_STR("(CFStringRef padString, CFIndex length, CFIndex indexIntoPad) -> None")},
2394 {"CFStringTrim", (PyCFunction
)CFMutableStringRefObj_CFStringTrim
, 1,
2395 PyDoc_STR("(CFStringRef trimString) -> None")},
2396 {"CFStringTrimWhitespace", (PyCFunction
)CFMutableStringRefObj_CFStringTrimWhitespace
, 1,
2397 PyDoc_STR("() -> None")},
2401 PyMethodChain CFMutableStringRefObj_chain
= { CFMutableStringRefObj_methods
, &CFStringRefObj_chain
};
2403 static PyObject
*CFMutableStringRefObj_getattr(CFMutableStringRefObject
*self
, char *name
)
2405 return Py_FindMethodInChain(&CFMutableStringRefObj_chain
, (PyObject
*)self
, name
);
2408 #define CFMutableStringRefObj_setattr NULL
2410 static int CFMutableStringRefObj_compare(CFMutableStringRefObject
*self
, CFMutableStringRefObject
*other
)
2412 /* XXXX Or should we use CFEqual?? */
2413 if ( self
->ob_itself
> other
->ob_itself
) return 1;
2414 if ( self
->ob_itself
< other
->ob_itself
) return -1;
2418 static PyObject
* CFMutableStringRefObj_repr(CFMutableStringRefObject
*self
)
2421 sprintf(buf
, "<CFMutableStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
2422 return PyString_FromString(buf
);
2425 static int CFMutableStringRefObj_hash(CFMutableStringRefObject
*self
)
2427 /* XXXX Or should we use CFHash?? */
2428 return (int)self
->ob_itself
;
2431 PyTypeObject CFMutableStringRef_Type
= {
2432 PyObject_HEAD_INIT(NULL
)
2434 "_CF.CFMutableStringRef", /*tp_name*/
2435 sizeof(CFMutableStringRefObject
), /*tp_basicsize*/
2438 (destructor
) CFMutableStringRefObj_dealloc
, /*tp_dealloc*/
2440 (getattrfunc
) CFMutableStringRefObj_getattr
, /*tp_getattr*/
2441 (setattrfunc
) CFMutableStringRefObj_setattr
, /*tp_setattr*/
2442 (cmpfunc
) CFMutableStringRefObj_compare
, /*tp_compare*/
2443 (reprfunc
) CFMutableStringRefObj_repr
, /*tp_repr*/
2444 (PyNumberMethods
*)0, /* tp_as_number */
2445 (PySequenceMethods
*)0, /* tp_as_sequence */
2446 (PyMappingMethods
*)0, /* tp_as_mapping */
2447 (hashfunc
) CFMutableStringRefObj_hash
, /*tp_hash*/
2450 /* --------------- End object type CFMutableStringRef --------------- */
2453 /* ---------------------- Object type CFURLRef ---------------------- */
2455 PyTypeObject CFURLRef_Type
;
2457 #define CFURLRefObj_Check(x) ((x)->ob_type == &CFURLRef_Type || PyObject_TypeCheck((x), &CFURLRef_Type))
2459 typedef struct CFURLRefObject
{
2462 void (*ob_freeit
)(CFTypeRef ptr
);
2465 PyObject
*CFURLRefObj_New(CFURLRef itself
)
2470 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
2473 it
= PyObject_NEW(CFURLRefObject
, &CFURLRef_Type
);
2474 if (it
== NULL
) return NULL
;
2475 it
->ob_itself
= itself
;
2476 it
->ob_freeit
= CFRelease
;
2477 return (PyObject
*)it
;
2479 int CFURLRefObj_Convert(PyObject
*v
, CFURLRef
*p_itself
)
2482 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
2483 /* Check for other CF objects here */
2485 if (!CFURLRefObj_Check(v
))
2487 PyErr_SetString(PyExc_TypeError
, "CFURLRef required");
2490 *p_itself
= ((CFURLRefObject
*)v
)->ob_itself
;
2494 static void CFURLRefObj_dealloc(CFURLRefObject
*self
)
2496 if (self
->ob_freeit
&& self
->ob_itself
)
2498 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
2500 PyObject_Free((PyObject
*)self
);
2503 static PyObject
*CFURLRefObj_CFURLCreateData(CFURLRefObject
*_self
, PyObject
*_args
)
2505 PyObject
*_res
= NULL
;
2507 CFStringEncoding encoding
;
2508 Boolean escapeWhitespace
;
2509 if (!PyArg_ParseTuple(_args
, "ll",
2513 _rv
= CFURLCreateData((CFAllocatorRef
)NULL
,
2517 _res
= Py_BuildValue("O&",
2518 CFDataRefObj_New
, _rv
);
2522 static PyObject
*CFURLRefObj_CFURLGetFileSystemRepresentation(CFURLRefObject
*_self
, PyObject
*_args
)
2524 PyObject
*_res
= NULL
;
2526 Boolean resolveAgainstBase
;
2529 #ifndef CFURLGetFileSystemRepresentation
2530 PyMac_PRECHECK(CFURLGetFileSystemRepresentation
);
2532 if (!PyArg_ParseTuple(_args
, "ll",
2533 &resolveAgainstBase
,
2536 _rv
= CFURLGetFileSystemRepresentation(_self
->ob_itself
,
2540 _res
= Py_BuildValue("lb",
2546 static PyObject
*CFURLRefObj_CFURLCopyAbsoluteURL(CFURLRefObject
*_self
, PyObject
*_args
)
2548 PyObject
*_res
= NULL
;
2550 #ifndef CFURLCopyAbsoluteURL
2551 PyMac_PRECHECK(CFURLCopyAbsoluteURL
);
2553 if (!PyArg_ParseTuple(_args
, ""))
2555 _rv
= CFURLCopyAbsoluteURL(_self
->ob_itself
);
2556 _res
= Py_BuildValue("O&",
2557 CFURLRefObj_New
, _rv
);
2561 static PyObject
*CFURLRefObj_CFURLGetString(CFURLRefObject
*_self
, PyObject
*_args
)
2563 PyObject
*_res
= NULL
;
2565 #ifndef CFURLGetString
2566 PyMac_PRECHECK(CFURLGetString
);
2568 if (!PyArg_ParseTuple(_args
, ""))
2570 _rv
= CFURLGetString(_self
->ob_itself
);
2571 _res
= Py_BuildValue("O&",
2572 CFStringRefObj_New
, _rv
);
2576 static PyObject
*CFURLRefObj_CFURLGetBaseURL(CFURLRefObject
*_self
, PyObject
*_args
)
2578 PyObject
*_res
= NULL
;
2580 #ifndef CFURLGetBaseURL
2581 PyMac_PRECHECK(CFURLGetBaseURL
);
2583 if (!PyArg_ParseTuple(_args
, ""))
2585 _rv
= CFURLGetBaseURL(_self
->ob_itself
);
2586 _res
= Py_BuildValue("O&",
2587 CFURLRefObj_New
, _rv
);
2591 static PyObject
*CFURLRefObj_CFURLCanBeDecomposed(CFURLRefObject
*_self
, PyObject
*_args
)
2593 PyObject
*_res
= NULL
;
2595 #ifndef CFURLCanBeDecomposed
2596 PyMac_PRECHECK(CFURLCanBeDecomposed
);
2598 if (!PyArg_ParseTuple(_args
, ""))
2600 _rv
= CFURLCanBeDecomposed(_self
->ob_itself
);
2601 _res
= Py_BuildValue("l",
2606 static PyObject
*CFURLRefObj_CFURLCopyScheme(CFURLRefObject
*_self
, PyObject
*_args
)
2608 PyObject
*_res
= NULL
;
2610 #ifndef CFURLCopyScheme
2611 PyMac_PRECHECK(CFURLCopyScheme
);
2613 if (!PyArg_ParseTuple(_args
, ""))
2615 _rv
= CFURLCopyScheme(_self
->ob_itself
);
2616 _res
= Py_BuildValue("O&",
2617 CFStringRefObj_New
, _rv
);
2621 static PyObject
*CFURLRefObj_CFURLCopyNetLocation(CFURLRefObject
*_self
, PyObject
*_args
)
2623 PyObject
*_res
= NULL
;
2625 #ifndef CFURLCopyNetLocation
2626 PyMac_PRECHECK(CFURLCopyNetLocation
);
2628 if (!PyArg_ParseTuple(_args
, ""))
2630 _rv
= CFURLCopyNetLocation(_self
->ob_itself
);
2631 _res
= Py_BuildValue("O&",
2632 CFStringRefObj_New
, _rv
);
2636 static PyObject
*CFURLRefObj_CFURLCopyPath(CFURLRefObject
*_self
, PyObject
*_args
)
2638 PyObject
*_res
= NULL
;
2640 #ifndef CFURLCopyPath
2641 PyMac_PRECHECK(CFURLCopyPath
);
2643 if (!PyArg_ParseTuple(_args
, ""))
2645 _rv
= CFURLCopyPath(_self
->ob_itself
);
2646 _res
= Py_BuildValue("O&",
2647 CFStringRefObj_New
, _rv
);
2651 static PyObject
*CFURLRefObj_CFURLCopyStrictPath(CFURLRefObject
*_self
, PyObject
*_args
)
2653 PyObject
*_res
= NULL
;
2656 #ifndef CFURLCopyStrictPath
2657 PyMac_PRECHECK(CFURLCopyStrictPath
);
2659 if (!PyArg_ParseTuple(_args
, ""))
2661 _rv
= CFURLCopyStrictPath(_self
->ob_itself
,
2663 _res
= Py_BuildValue("O&l",
2664 CFStringRefObj_New
, _rv
,
2669 static PyObject
*CFURLRefObj_CFURLCopyFileSystemPath(CFURLRefObject
*_self
, PyObject
*_args
)
2671 PyObject
*_res
= NULL
;
2673 CFURLPathStyle pathStyle
;
2674 #ifndef CFURLCopyFileSystemPath
2675 PyMac_PRECHECK(CFURLCopyFileSystemPath
);
2677 if (!PyArg_ParseTuple(_args
, "l",
2680 _rv
= CFURLCopyFileSystemPath(_self
->ob_itself
,
2682 _res
= Py_BuildValue("O&",
2683 CFStringRefObj_New
, _rv
);
2687 static PyObject
*CFURLRefObj_CFURLHasDirectoryPath(CFURLRefObject
*_self
, PyObject
*_args
)
2689 PyObject
*_res
= NULL
;
2691 #ifndef CFURLHasDirectoryPath
2692 PyMac_PRECHECK(CFURLHasDirectoryPath
);
2694 if (!PyArg_ParseTuple(_args
, ""))
2696 _rv
= CFURLHasDirectoryPath(_self
->ob_itself
);
2697 _res
= Py_BuildValue("l",
2702 static PyObject
*CFURLRefObj_CFURLCopyResourceSpecifier(CFURLRefObject
*_self
, PyObject
*_args
)
2704 PyObject
*_res
= NULL
;
2706 #ifndef CFURLCopyResourceSpecifier
2707 PyMac_PRECHECK(CFURLCopyResourceSpecifier
);
2709 if (!PyArg_ParseTuple(_args
, ""))
2711 _rv
= CFURLCopyResourceSpecifier(_self
->ob_itself
);
2712 _res
= Py_BuildValue("O&",
2713 CFStringRefObj_New
, _rv
);
2717 static PyObject
*CFURLRefObj_CFURLCopyHostName(CFURLRefObject
*_self
, PyObject
*_args
)
2719 PyObject
*_res
= NULL
;
2721 #ifndef CFURLCopyHostName
2722 PyMac_PRECHECK(CFURLCopyHostName
);
2724 if (!PyArg_ParseTuple(_args
, ""))
2726 _rv
= CFURLCopyHostName(_self
->ob_itself
);
2727 _res
= Py_BuildValue("O&",
2728 CFStringRefObj_New
, _rv
);
2732 static PyObject
*CFURLRefObj_CFURLGetPortNumber(CFURLRefObject
*_self
, PyObject
*_args
)
2734 PyObject
*_res
= NULL
;
2736 #ifndef CFURLGetPortNumber
2737 PyMac_PRECHECK(CFURLGetPortNumber
);
2739 if (!PyArg_ParseTuple(_args
, ""))
2741 _rv
= CFURLGetPortNumber(_self
->ob_itself
);
2742 _res
= Py_BuildValue("l",
2747 static PyObject
*CFURLRefObj_CFURLCopyUserName(CFURLRefObject
*_self
, PyObject
*_args
)
2749 PyObject
*_res
= NULL
;
2751 #ifndef CFURLCopyUserName
2752 PyMac_PRECHECK(CFURLCopyUserName
);
2754 if (!PyArg_ParseTuple(_args
, ""))
2756 _rv
= CFURLCopyUserName(_self
->ob_itself
);
2757 _res
= Py_BuildValue("O&",
2758 CFStringRefObj_New
, _rv
);
2762 static PyObject
*CFURLRefObj_CFURLCopyPassword(CFURLRefObject
*_self
, PyObject
*_args
)
2764 PyObject
*_res
= NULL
;
2766 #ifndef CFURLCopyPassword
2767 PyMac_PRECHECK(CFURLCopyPassword
);
2769 if (!PyArg_ParseTuple(_args
, ""))
2771 _rv
= CFURLCopyPassword(_self
->ob_itself
);
2772 _res
= Py_BuildValue("O&",
2773 CFStringRefObj_New
, _rv
);
2777 static PyObject
*CFURLRefObj_CFURLCopyParameterString(CFURLRefObject
*_self
, PyObject
*_args
)
2779 PyObject
*_res
= NULL
;
2781 CFStringRef charactersToLeaveEscaped
;
2782 #ifndef CFURLCopyParameterString
2783 PyMac_PRECHECK(CFURLCopyParameterString
);
2785 if (!PyArg_ParseTuple(_args
, "O&",
2786 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
2788 _rv
= CFURLCopyParameterString(_self
->ob_itself
,
2789 charactersToLeaveEscaped
);
2790 _res
= Py_BuildValue("O&",
2791 CFStringRefObj_New
, _rv
);
2795 static PyObject
*CFURLRefObj_CFURLCopyQueryString(CFURLRefObject
*_self
, PyObject
*_args
)
2797 PyObject
*_res
= NULL
;
2799 CFStringRef charactersToLeaveEscaped
;
2800 #ifndef CFURLCopyQueryString
2801 PyMac_PRECHECK(CFURLCopyQueryString
);
2803 if (!PyArg_ParseTuple(_args
, "O&",
2804 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
2806 _rv
= CFURLCopyQueryString(_self
->ob_itself
,
2807 charactersToLeaveEscaped
);
2808 _res
= Py_BuildValue("O&",
2809 CFStringRefObj_New
, _rv
);
2813 static PyObject
*CFURLRefObj_CFURLCopyFragment(CFURLRefObject
*_self
, PyObject
*_args
)
2815 PyObject
*_res
= NULL
;
2817 CFStringRef charactersToLeaveEscaped
;
2818 #ifndef CFURLCopyFragment
2819 PyMac_PRECHECK(CFURLCopyFragment
);
2821 if (!PyArg_ParseTuple(_args
, "O&",
2822 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
2824 _rv
= CFURLCopyFragment(_self
->ob_itself
,
2825 charactersToLeaveEscaped
);
2826 _res
= Py_BuildValue("O&",
2827 CFStringRefObj_New
, _rv
);
2831 static PyObject
*CFURLRefObj_CFURLCopyLastPathComponent(CFURLRefObject
*_self
, PyObject
*_args
)
2833 PyObject
*_res
= NULL
;
2835 #ifndef CFURLCopyLastPathComponent
2836 PyMac_PRECHECK(CFURLCopyLastPathComponent
);
2838 if (!PyArg_ParseTuple(_args
, ""))
2840 _rv
= CFURLCopyLastPathComponent(_self
->ob_itself
);
2841 _res
= Py_BuildValue("O&",
2842 CFStringRefObj_New
, _rv
);
2846 static PyObject
*CFURLRefObj_CFURLCopyPathExtension(CFURLRefObject
*_self
, PyObject
*_args
)
2848 PyObject
*_res
= NULL
;
2850 #ifndef CFURLCopyPathExtension
2851 PyMac_PRECHECK(CFURLCopyPathExtension
);
2853 if (!PyArg_ParseTuple(_args
, ""))
2855 _rv
= CFURLCopyPathExtension(_self
->ob_itself
);
2856 _res
= Py_BuildValue("O&",
2857 CFStringRefObj_New
, _rv
);
2861 static PyObject
*CFURLRefObj_CFURLCreateCopyAppendingPathComponent(CFURLRefObject
*_self
, PyObject
*_args
)
2863 PyObject
*_res
= NULL
;
2865 CFStringRef pathComponent
;
2866 Boolean isDirectory
;
2867 if (!PyArg_ParseTuple(_args
, "O&l",
2868 CFStringRefObj_Convert
, &pathComponent
,
2871 _rv
= CFURLCreateCopyAppendingPathComponent((CFAllocatorRef
)NULL
,
2875 _res
= Py_BuildValue("O&",
2876 CFURLRefObj_New
, _rv
);
2880 static PyObject
*CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent(CFURLRefObject
*_self
, PyObject
*_args
)
2882 PyObject
*_res
= NULL
;
2884 if (!PyArg_ParseTuple(_args
, ""))
2886 _rv
= CFURLCreateCopyDeletingLastPathComponent((CFAllocatorRef
)NULL
,
2888 _res
= Py_BuildValue("O&",
2889 CFURLRefObj_New
, _rv
);
2893 static PyObject
*CFURLRefObj_CFURLCreateCopyAppendingPathExtension(CFURLRefObject
*_self
, PyObject
*_args
)
2895 PyObject
*_res
= NULL
;
2897 CFStringRef extension
;
2898 if (!PyArg_ParseTuple(_args
, "O&",
2899 CFStringRefObj_Convert
, &extension
))
2901 _rv
= CFURLCreateCopyAppendingPathExtension((CFAllocatorRef
)NULL
,
2904 _res
= Py_BuildValue("O&",
2905 CFURLRefObj_New
, _rv
);
2909 static PyObject
*CFURLRefObj_CFURLCreateCopyDeletingPathExtension(CFURLRefObject
*_self
, PyObject
*_args
)
2911 PyObject
*_res
= NULL
;
2913 if (!PyArg_ParseTuple(_args
, ""))
2915 _rv
= CFURLCreateCopyDeletingPathExtension((CFAllocatorRef
)NULL
,
2917 _res
= Py_BuildValue("O&",
2918 CFURLRefObj_New
, _rv
);
2922 static PyObject
*CFURLRefObj_CFURLGetFSRef(CFURLRefObject
*_self
, PyObject
*_args
)
2924 PyObject
*_res
= NULL
;
2927 #ifndef CFURLGetFSRef
2928 PyMac_PRECHECK(CFURLGetFSRef
);
2930 if (!PyArg_ParseTuple(_args
, ""))
2932 _rv
= CFURLGetFSRef(_self
->ob_itself
,
2934 _res
= Py_BuildValue("lO&",
2936 PyMac_BuildFSRef
, &fsRef
);
2940 static PyMethodDef CFURLRefObj_methods
[] = {
2941 {"CFURLCreateData", (PyCFunction
)CFURLRefObj_CFURLCreateData
, 1,
2942 PyDoc_STR("(CFStringEncoding encoding, Boolean escapeWhitespace) -> (CFDataRef _rv)")},
2943 {"CFURLGetFileSystemRepresentation", (PyCFunction
)CFURLRefObj_CFURLGetFileSystemRepresentation
, 1,
2944 PyDoc_STR("(Boolean resolveAgainstBase, CFIndex maxBufLen) -> (Boolean _rv, UInt8 buffer)")},
2945 {"CFURLCopyAbsoluteURL", (PyCFunction
)CFURLRefObj_CFURLCopyAbsoluteURL
, 1,
2946 PyDoc_STR("() -> (CFURLRef _rv)")},
2947 {"CFURLGetString", (PyCFunction
)CFURLRefObj_CFURLGetString
, 1,
2948 PyDoc_STR("() -> (CFStringRef _rv)")},
2949 {"CFURLGetBaseURL", (PyCFunction
)CFURLRefObj_CFURLGetBaseURL
, 1,
2950 PyDoc_STR("() -> (CFURLRef _rv)")},
2951 {"CFURLCanBeDecomposed", (PyCFunction
)CFURLRefObj_CFURLCanBeDecomposed
, 1,
2952 PyDoc_STR("() -> (Boolean _rv)")},
2953 {"CFURLCopyScheme", (PyCFunction
)CFURLRefObj_CFURLCopyScheme
, 1,
2954 PyDoc_STR("() -> (CFStringRef _rv)")},
2955 {"CFURLCopyNetLocation", (PyCFunction
)CFURLRefObj_CFURLCopyNetLocation
, 1,
2956 PyDoc_STR("() -> (CFStringRef _rv)")},
2957 {"CFURLCopyPath", (PyCFunction
)CFURLRefObj_CFURLCopyPath
, 1,
2958 PyDoc_STR("() -> (CFStringRef _rv)")},
2959 {"CFURLCopyStrictPath", (PyCFunction
)CFURLRefObj_CFURLCopyStrictPath
, 1,
2960 PyDoc_STR("() -> (CFStringRef _rv, Boolean isAbsolute)")},
2961 {"CFURLCopyFileSystemPath", (PyCFunction
)CFURLRefObj_CFURLCopyFileSystemPath
, 1,
2962 PyDoc_STR("(CFURLPathStyle pathStyle) -> (CFStringRef _rv)")},
2963 {"CFURLHasDirectoryPath", (PyCFunction
)CFURLRefObj_CFURLHasDirectoryPath
, 1,
2964 PyDoc_STR("() -> (Boolean _rv)")},
2965 {"CFURLCopyResourceSpecifier", (PyCFunction
)CFURLRefObj_CFURLCopyResourceSpecifier
, 1,
2966 PyDoc_STR("() -> (CFStringRef _rv)")},
2967 {"CFURLCopyHostName", (PyCFunction
)CFURLRefObj_CFURLCopyHostName
, 1,
2968 PyDoc_STR("() -> (CFStringRef _rv)")},
2969 {"CFURLGetPortNumber", (PyCFunction
)CFURLRefObj_CFURLGetPortNumber
, 1,
2970 PyDoc_STR("() -> (SInt32 _rv)")},
2971 {"CFURLCopyUserName", (PyCFunction
)CFURLRefObj_CFURLCopyUserName
, 1,
2972 PyDoc_STR("() -> (CFStringRef _rv)")},
2973 {"CFURLCopyPassword", (PyCFunction
)CFURLRefObj_CFURLCopyPassword
, 1,
2974 PyDoc_STR("() -> (CFStringRef _rv)")},
2975 {"CFURLCopyParameterString", (PyCFunction
)CFURLRefObj_CFURLCopyParameterString
, 1,
2976 PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")},
2977 {"CFURLCopyQueryString", (PyCFunction
)CFURLRefObj_CFURLCopyQueryString
, 1,
2978 PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")},
2979 {"CFURLCopyFragment", (PyCFunction
)CFURLRefObj_CFURLCopyFragment
, 1,
2980 PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")},
2981 {"CFURLCopyLastPathComponent", (PyCFunction
)CFURLRefObj_CFURLCopyLastPathComponent
, 1,
2982 PyDoc_STR("() -> (CFStringRef _rv)")},
2983 {"CFURLCopyPathExtension", (PyCFunction
)CFURLRefObj_CFURLCopyPathExtension
, 1,
2984 PyDoc_STR("() -> (CFStringRef _rv)")},
2985 {"CFURLCreateCopyAppendingPathComponent", (PyCFunction
)CFURLRefObj_CFURLCreateCopyAppendingPathComponent
, 1,
2986 PyDoc_STR("(CFStringRef pathComponent, Boolean isDirectory) -> (CFURLRef _rv)")},
2987 {"CFURLCreateCopyDeletingLastPathComponent", (PyCFunction
)CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent
, 1,
2988 PyDoc_STR("() -> (CFURLRef _rv)")},
2989 {"CFURLCreateCopyAppendingPathExtension", (PyCFunction
)CFURLRefObj_CFURLCreateCopyAppendingPathExtension
, 1,
2990 PyDoc_STR("(CFStringRef extension) -> (CFURLRef _rv)")},
2991 {"CFURLCreateCopyDeletingPathExtension", (PyCFunction
)CFURLRefObj_CFURLCreateCopyDeletingPathExtension
, 1,
2992 PyDoc_STR("() -> (CFURLRef _rv)")},
2993 {"CFURLGetFSRef", (PyCFunction
)CFURLRefObj_CFURLGetFSRef
, 1,
2994 PyDoc_STR("() -> (Boolean _rv, FSRef fsRef)")},
2998 PyMethodChain CFURLRefObj_chain
= { CFURLRefObj_methods
, &CFTypeRefObj_chain
};
3000 static PyObject
*CFURLRefObj_getattr(CFURLRefObject
*self
, char *name
)
3002 return Py_FindMethodInChain(&CFURLRefObj_chain
, (PyObject
*)self
, name
);
3005 #define CFURLRefObj_setattr NULL
3007 static int CFURLRefObj_compare(CFURLRefObject
*self
, CFURLRefObject
*other
)
3009 /* XXXX Or should we use CFEqual?? */
3010 if ( self
->ob_itself
> other
->ob_itself
) return 1;
3011 if ( self
->ob_itself
< other
->ob_itself
) return -1;
3015 static PyObject
* CFURLRefObj_repr(CFURLRefObject
*self
)
3018 sprintf(buf
, "<CFURL object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
3019 return PyString_FromString(buf
);
3022 static int CFURLRefObj_hash(CFURLRefObject
*self
)
3024 /* XXXX Or should we use CFHash?? */
3025 return (int)self
->ob_itself
;
3028 PyTypeObject CFURLRef_Type
= {
3029 PyObject_HEAD_INIT(NULL
)
3031 "_CF.CFURLRef", /*tp_name*/
3032 sizeof(CFURLRefObject
), /*tp_basicsize*/
3035 (destructor
) CFURLRefObj_dealloc
, /*tp_dealloc*/
3037 (getattrfunc
) CFURLRefObj_getattr
, /*tp_getattr*/
3038 (setattrfunc
) CFURLRefObj_setattr
, /*tp_setattr*/
3039 (cmpfunc
) CFURLRefObj_compare
, /*tp_compare*/
3040 (reprfunc
) CFURLRefObj_repr
, /*tp_repr*/
3041 (PyNumberMethods
*)0, /* tp_as_number */
3042 (PySequenceMethods
*)0, /* tp_as_sequence */
3043 (PyMappingMethods
*)0, /* tp_as_mapping */
3044 (hashfunc
) CFURLRefObj_hash
, /*tp_hash*/
3047 /* -------------------- End object type CFURLRef -------------------- */
3050 static PyObject
*CF___CFRangeMake(PyObject
*_self
, PyObject
*_args
)
3052 PyObject
*_res
= NULL
;
3056 #ifndef __CFRangeMake
3057 PyMac_PRECHECK(__CFRangeMake
);
3059 if (!PyArg_ParseTuple(_args
, "ll",
3063 _rv
= __CFRangeMake(loc
,
3065 _res
= Py_BuildValue("O&",
3070 static PyObject
*CF_CFAllocatorGetTypeID(PyObject
*_self
, PyObject
*_args
)
3072 PyObject
*_res
= NULL
;
3074 #ifndef CFAllocatorGetTypeID
3075 PyMac_PRECHECK(CFAllocatorGetTypeID
);
3077 if (!PyArg_ParseTuple(_args
, ""))
3079 _rv
= CFAllocatorGetTypeID();
3080 _res
= Py_BuildValue("l",
3085 static PyObject
*CF_CFAllocatorGetPreferredSizeForSize(PyObject
*_self
, PyObject
*_args
)
3087 PyObject
*_res
= NULL
;
3091 #ifndef CFAllocatorGetPreferredSizeForSize
3092 PyMac_PRECHECK(CFAllocatorGetPreferredSizeForSize
);
3094 if (!PyArg_ParseTuple(_args
, "ll",
3098 _rv
= CFAllocatorGetPreferredSizeForSize((CFAllocatorRef
)NULL
,
3101 _res
= Py_BuildValue("l",
3106 static PyObject
*CF_CFCopyTypeIDDescription(PyObject
*_self
, PyObject
*_args
)
3108 PyObject
*_res
= NULL
;
3111 #ifndef CFCopyTypeIDDescription
3112 PyMac_PRECHECK(CFCopyTypeIDDescription
);
3114 if (!PyArg_ParseTuple(_args
, "l",
3117 _rv
= CFCopyTypeIDDescription(type_id
);
3118 _res
= Py_BuildValue("O&",
3119 CFStringRefObj_New
, _rv
);
3123 static PyObject
*CF_CFArrayGetTypeID(PyObject
*_self
, PyObject
*_args
)
3125 PyObject
*_res
= NULL
;
3127 #ifndef CFArrayGetTypeID
3128 PyMac_PRECHECK(CFArrayGetTypeID
);
3130 if (!PyArg_ParseTuple(_args
, ""))
3132 _rv
= CFArrayGetTypeID();
3133 _res
= Py_BuildValue("l",
3138 static PyObject
*CF_CFArrayCreateMutable(PyObject
*_self
, PyObject
*_args
)
3140 PyObject
*_res
= NULL
;
3141 CFMutableArrayRef _rv
;
3143 #ifndef CFArrayCreateMutable
3144 PyMac_PRECHECK(CFArrayCreateMutable
);
3146 if (!PyArg_ParseTuple(_args
, "l",
3149 _rv
= CFArrayCreateMutable((CFAllocatorRef
)NULL
,
3151 &kCFTypeArrayCallBacks
);
3152 _res
= Py_BuildValue("O&",
3153 CFMutableArrayRefObj_New
, _rv
);
3157 static PyObject
*CF_CFArrayCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3159 PyObject
*_res
= NULL
;
3160 CFMutableArrayRef _rv
;
3162 CFArrayRef theArray
;
3163 #ifndef CFArrayCreateMutableCopy
3164 PyMac_PRECHECK(CFArrayCreateMutableCopy
);
3166 if (!PyArg_ParseTuple(_args
, "lO&",
3168 CFArrayRefObj_Convert
, &theArray
))
3170 _rv
= CFArrayCreateMutableCopy((CFAllocatorRef
)NULL
,
3173 _res
= Py_BuildValue("O&",
3174 CFMutableArrayRefObj_New
, _rv
);
3178 static PyObject
*CF_CFDataGetTypeID(PyObject
*_self
, PyObject
*_args
)
3180 PyObject
*_res
= NULL
;
3182 #ifndef CFDataGetTypeID
3183 PyMac_PRECHECK(CFDataGetTypeID
);
3185 if (!PyArg_ParseTuple(_args
, ""))
3187 _rv
= CFDataGetTypeID();
3188 _res
= Py_BuildValue("l",
3193 static PyObject
*CF_CFDataCreate(PyObject
*_self
, PyObject
*_args
)
3195 PyObject
*_res
= NULL
;
3197 unsigned char *bytes__in__
;
3199 int bytes__in_len__
;
3200 #ifndef CFDataCreate
3201 PyMac_PRECHECK(CFDataCreate
);
3203 if (!PyArg_ParseTuple(_args
, "s#",
3204 &bytes__in__
, &bytes__in_len__
))
3206 bytes__len__
= bytes__in_len__
;
3207 _rv
= CFDataCreate((CFAllocatorRef
)NULL
,
3208 bytes__in__
, bytes__len__
);
3209 _res
= Py_BuildValue("O&",
3210 CFDataRefObj_New
, _rv
);
3214 static PyObject
*CF_CFDataCreateWithBytesNoCopy(PyObject
*_self
, PyObject
*_args
)
3216 PyObject
*_res
= NULL
;
3218 unsigned char *bytes__in__
;
3220 int bytes__in_len__
;
3221 #ifndef CFDataCreateWithBytesNoCopy
3222 PyMac_PRECHECK(CFDataCreateWithBytesNoCopy
);
3224 if (!PyArg_ParseTuple(_args
, "s#",
3225 &bytes__in__
, &bytes__in_len__
))
3227 bytes__len__
= bytes__in_len__
;
3228 _rv
= CFDataCreateWithBytesNoCopy((CFAllocatorRef
)NULL
,
3229 bytes__in__
, bytes__len__
,
3230 (CFAllocatorRef
)NULL
);
3231 _res
= Py_BuildValue("O&",
3232 CFDataRefObj_New
, _rv
);
3236 static PyObject
*CF_CFDataCreateMutable(PyObject
*_self
, PyObject
*_args
)
3238 PyObject
*_res
= NULL
;
3239 CFMutableDataRef _rv
;
3241 #ifndef CFDataCreateMutable
3242 PyMac_PRECHECK(CFDataCreateMutable
);
3244 if (!PyArg_ParseTuple(_args
, "l",
3247 _rv
= CFDataCreateMutable((CFAllocatorRef
)NULL
,
3249 _res
= Py_BuildValue("O&",
3250 CFMutableDataRefObj_New
, _rv
);
3254 static PyObject
*CF_CFDataCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3256 PyObject
*_res
= NULL
;
3257 CFMutableDataRef _rv
;
3260 #ifndef CFDataCreateMutableCopy
3261 PyMac_PRECHECK(CFDataCreateMutableCopy
);
3263 if (!PyArg_ParseTuple(_args
, "lO&",
3265 CFDataRefObj_Convert
, &theData
))
3267 _rv
= CFDataCreateMutableCopy((CFAllocatorRef
)NULL
,
3270 _res
= Py_BuildValue("O&",
3271 CFMutableDataRefObj_New
, _rv
);
3275 static PyObject
*CF_CFDictionaryGetTypeID(PyObject
*_self
, PyObject
*_args
)
3277 PyObject
*_res
= NULL
;
3279 #ifndef CFDictionaryGetTypeID
3280 PyMac_PRECHECK(CFDictionaryGetTypeID
);
3282 if (!PyArg_ParseTuple(_args
, ""))
3284 _rv
= CFDictionaryGetTypeID();
3285 _res
= Py_BuildValue("l",
3290 static PyObject
*CF_CFDictionaryCreateMutable(PyObject
*_self
, PyObject
*_args
)
3292 PyObject
*_res
= NULL
;
3293 CFMutableDictionaryRef _rv
;
3295 #ifndef CFDictionaryCreateMutable
3296 PyMac_PRECHECK(CFDictionaryCreateMutable
);
3298 if (!PyArg_ParseTuple(_args
, "l",
3301 _rv
= CFDictionaryCreateMutable((CFAllocatorRef
)NULL
,
3303 &kCFTypeDictionaryKeyCallBacks
,
3304 &kCFTypeDictionaryValueCallBacks
);
3305 _res
= Py_BuildValue("O&",
3306 CFMutableDictionaryRefObj_New
, _rv
);
3310 static PyObject
*CF_CFDictionaryCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3312 PyObject
*_res
= NULL
;
3313 CFMutableDictionaryRef _rv
;
3315 CFDictionaryRef theDict
;
3316 #ifndef CFDictionaryCreateMutableCopy
3317 PyMac_PRECHECK(CFDictionaryCreateMutableCopy
);
3319 if (!PyArg_ParseTuple(_args
, "lO&",
3321 CFDictionaryRefObj_Convert
, &theDict
))
3323 _rv
= CFDictionaryCreateMutableCopy((CFAllocatorRef
)NULL
,
3326 _res
= Py_BuildValue("O&",
3327 CFMutableDictionaryRefObj_New
, _rv
);
3331 static PyObject
*CF_CFPreferencesCopyAppValue(PyObject
*_self
, PyObject
*_args
)
3333 PyObject
*_res
= NULL
;
3336 CFStringRef applicationID
;
3337 #ifndef CFPreferencesCopyAppValue
3338 PyMac_PRECHECK(CFPreferencesCopyAppValue
);
3340 if (!PyArg_ParseTuple(_args
, "O&O&",
3341 CFStringRefObj_Convert
, &key
,
3342 CFStringRefObj_Convert
, &applicationID
))
3344 _rv
= CFPreferencesCopyAppValue(key
,
3346 _res
= Py_BuildValue("O&",
3347 CFTypeRefObj_New
, _rv
);
3351 static PyObject
*CF_CFPreferencesGetAppBooleanValue(PyObject
*_self
, PyObject
*_args
)
3353 PyObject
*_res
= NULL
;
3356 CFStringRef applicationID
;
3357 Boolean keyExistsAndHasValidFormat
;
3358 #ifndef CFPreferencesGetAppBooleanValue
3359 PyMac_PRECHECK(CFPreferencesGetAppBooleanValue
);
3361 if (!PyArg_ParseTuple(_args
, "O&O&",
3362 CFStringRefObj_Convert
, &key
,
3363 CFStringRefObj_Convert
, &applicationID
))
3365 _rv
= CFPreferencesGetAppBooleanValue(key
,
3367 &keyExistsAndHasValidFormat
);
3368 _res
= Py_BuildValue("ll",
3370 keyExistsAndHasValidFormat
);
3374 static PyObject
*CF_CFPreferencesGetAppIntegerValue(PyObject
*_self
, PyObject
*_args
)
3376 PyObject
*_res
= NULL
;
3379 CFStringRef applicationID
;
3380 Boolean keyExistsAndHasValidFormat
;
3381 #ifndef CFPreferencesGetAppIntegerValue
3382 PyMac_PRECHECK(CFPreferencesGetAppIntegerValue
);
3384 if (!PyArg_ParseTuple(_args
, "O&O&",
3385 CFStringRefObj_Convert
, &key
,
3386 CFStringRefObj_Convert
, &applicationID
))
3388 _rv
= CFPreferencesGetAppIntegerValue(key
,
3390 &keyExistsAndHasValidFormat
);
3391 _res
= Py_BuildValue("ll",
3393 keyExistsAndHasValidFormat
);
3397 static PyObject
*CF_CFPreferencesSetAppValue(PyObject
*_self
, PyObject
*_args
)
3399 PyObject
*_res
= NULL
;
3402 CFStringRef applicationID
;
3403 #ifndef CFPreferencesSetAppValue
3404 PyMac_PRECHECK(CFPreferencesSetAppValue
);
3406 if (!PyArg_ParseTuple(_args
, "O&O&O&",
3407 CFStringRefObj_Convert
, &key
,
3408 CFTypeRefObj_Convert
, &value
,
3409 CFStringRefObj_Convert
, &applicationID
))
3411 CFPreferencesSetAppValue(key
,
3419 static PyObject
*CF_CFPreferencesAddSuitePreferencesToApp(PyObject
*_self
, PyObject
*_args
)
3421 PyObject
*_res
= NULL
;
3422 CFStringRef applicationID
;
3423 CFStringRef suiteID
;
3424 #ifndef CFPreferencesAddSuitePreferencesToApp
3425 PyMac_PRECHECK(CFPreferencesAddSuitePreferencesToApp
);
3427 if (!PyArg_ParseTuple(_args
, "O&O&",
3428 CFStringRefObj_Convert
, &applicationID
,
3429 CFStringRefObj_Convert
, &suiteID
))
3431 CFPreferencesAddSuitePreferencesToApp(applicationID
,
3438 static PyObject
*CF_CFPreferencesRemoveSuitePreferencesFromApp(PyObject
*_self
, PyObject
*_args
)
3440 PyObject
*_res
= NULL
;
3441 CFStringRef applicationID
;
3442 CFStringRef suiteID
;
3443 #ifndef CFPreferencesRemoveSuitePreferencesFromApp
3444 PyMac_PRECHECK(CFPreferencesRemoveSuitePreferencesFromApp
);
3446 if (!PyArg_ParseTuple(_args
, "O&O&",
3447 CFStringRefObj_Convert
, &applicationID
,
3448 CFStringRefObj_Convert
, &suiteID
))
3450 CFPreferencesRemoveSuitePreferencesFromApp(applicationID
,
3457 static PyObject
*CF_CFPreferencesAppSynchronize(PyObject
*_self
, PyObject
*_args
)
3459 PyObject
*_res
= NULL
;
3461 CFStringRef applicationID
;
3462 #ifndef CFPreferencesAppSynchronize
3463 PyMac_PRECHECK(CFPreferencesAppSynchronize
);
3465 if (!PyArg_ParseTuple(_args
, "O&",
3466 CFStringRefObj_Convert
, &applicationID
))
3468 _rv
= CFPreferencesAppSynchronize(applicationID
);
3469 _res
= Py_BuildValue("l",
3474 static PyObject
*CF_CFPreferencesCopyValue(PyObject
*_self
, PyObject
*_args
)
3476 PyObject
*_res
= NULL
;
3479 CFStringRef applicationID
;
3480 CFStringRef userName
;
3481 CFStringRef hostName
;
3482 #ifndef CFPreferencesCopyValue
3483 PyMac_PRECHECK(CFPreferencesCopyValue
);
3485 if (!PyArg_ParseTuple(_args
, "O&O&O&O&",
3486 CFStringRefObj_Convert
, &key
,
3487 CFStringRefObj_Convert
, &applicationID
,
3488 CFStringRefObj_Convert
, &userName
,
3489 CFStringRefObj_Convert
, &hostName
))
3491 _rv
= CFPreferencesCopyValue(key
,
3495 _res
= Py_BuildValue("O&",
3496 CFTypeRefObj_New
, _rv
);
3500 static PyObject
*CF_CFPreferencesCopyMultiple(PyObject
*_self
, PyObject
*_args
)
3502 PyObject
*_res
= NULL
;
3503 CFDictionaryRef _rv
;
3504 CFArrayRef keysToFetch
;
3505 CFStringRef applicationID
;
3506 CFStringRef userName
;
3507 CFStringRef hostName
;
3508 #ifndef CFPreferencesCopyMultiple
3509 PyMac_PRECHECK(CFPreferencesCopyMultiple
);
3511 if (!PyArg_ParseTuple(_args
, "O&O&O&O&",
3512 CFArrayRefObj_Convert
, &keysToFetch
,
3513 CFStringRefObj_Convert
, &applicationID
,
3514 CFStringRefObj_Convert
, &userName
,
3515 CFStringRefObj_Convert
, &hostName
))
3517 _rv
= CFPreferencesCopyMultiple(keysToFetch
,
3521 _res
= Py_BuildValue("O&",
3522 CFDictionaryRefObj_New
, _rv
);
3526 static PyObject
*CF_CFPreferencesSetValue(PyObject
*_self
, PyObject
*_args
)
3528 PyObject
*_res
= NULL
;
3531 CFStringRef applicationID
;
3532 CFStringRef userName
;
3533 CFStringRef hostName
;
3534 #ifndef CFPreferencesSetValue
3535 PyMac_PRECHECK(CFPreferencesSetValue
);
3537 if (!PyArg_ParseTuple(_args
, "O&O&O&O&O&",
3538 CFStringRefObj_Convert
, &key
,
3539 CFTypeRefObj_Convert
, &value
,
3540 CFStringRefObj_Convert
, &applicationID
,
3541 CFStringRefObj_Convert
, &userName
,
3542 CFStringRefObj_Convert
, &hostName
))
3544 CFPreferencesSetValue(key
,
3554 static PyObject
*CF_CFPreferencesSetMultiple(PyObject
*_self
, PyObject
*_args
)
3556 PyObject
*_res
= NULL
;
3557 CFDictionaryRef keysToSet
;
3558 CFArrayRef keysToRemove
;
3559 CFStringRef applicationID
;
3560 CFStringRef userName
;
3561 CFStringRef hostName
;
3562 #ifndef CFPreferencesSetMultiple
3563 PyMac_PRECHECK(CFPreferencesSetMultiple
);
3565 if (!PyArg_ParseTuple(_args
, "O&O&O&O&O&",
3566 CFDictionaryRefObj_Convert
, &keysToSet
,
3567 CFArrayRefObj_Convert
, &keysToRemove
,
3568 CFStringRefObj_Convert
, &applicationID
,
3569 CFStringRefObj_Convert
, &userName
,
3570 CFStringRefObj_Convert
, &hostName
))
3572 CFPreferencesSetMultiple(keysToSet
,
3582 static PyObject
*CF_CFPreferencesSynchronize(PyObject
*_self
, PyObject
*_args
)
3584 PyObject
*_res
= NULL
;
3586 CFStringRef applicationID
;
3587 CFStringRef userName
;
3588 CFStringRef hostName
;
3589 #ifndef CFPreferencesSynchronize
3590 PyMac_PRECHECK(CFPreferencesSynchronize
);
3592 if (!PyArg_ParseTuple(_args
, "O&O&O&",
3593 CFStringRefObj_Convert
, &applicationID
,
3594 CFStringRefObj_Convert
, &userName
,
3595 CFStringRefObj_Convert
, &hostName
))
3597 _rv
= CFPreferencesSynchronize(applicationID
,
3600 _res
= Py_BuildValue("l",
3605 static PyObject
*CF_CFPreferencesCopyApplicationList(PyObject
*_self
, PyObject
*_args
)
3607 PyObject
*_res
= NULL
;
3609 CFStringRef userName
;
3610 CFStringRef hostName
;
3611 #ifndef CFPreferencesCopyApplicationList
3612 PyMac_PRECHECK(CFPreferencesCopyApplicationList
);
3614 if (!PyArg_ParseTuple(_args
, "O&O&",
3615 CFStringRefObj_Convert
, &userName
,
3616 CFStringRefObj_Convert
, &hostName
))
3618 _rv
= CFPreferencesCopyApplicationList(userName
,
3620 _res
= Py_BuildValue("O&",
3621 CFArrayRefObj_New
, _rv
);
3625 static PyObject
*CF_CFPreferencesCopyKeyList(PyObject
*_self
, PyObject
*_args
)
3627 PyObject
*_res
= NULL
;
3629 CFStringRef applicationID
;
3630 CFStringRef userName
;
3631 CFStringRef hostName
;
3632 #ifndef CFPreferencesCopyKeyList
3633 PyMac_PRECHECK(CFPreferencesCopyKeyList
);
3635 if (!PyArg_ParseTuple(_args
, "O&O&O&",
3636 CFStringRefObj_Convert
, &applicationID
,
3637 CFStringRefObj_Convert
, &userName
,
3638 CFStringRefObj_Convert
, &hostName
))
3640 _rv
= CFPreferencesCopyKeyList(applicationID
,
3643 _res
= Py_BuildValue("O&",
3644 CFArrayRefObj_New
, _rv
);
3648 static PyObject
*CF_CFStringGetTypeID(PyObject
*_self
, PyObject
*_args
)
3650 PyObject
*_res
= NULL
;
3652 #ifndef CFStringGetTypeID
3653 PyMac_PRECHECK(CFStringGetTypeID
);
3655 if (!PyArg_ParseTuple(_args
, ""))
3657 _rv
= CFStringGetTypeID();
3658 _res
= Py_BuildValue("l",
3663 static PyObject
*CF_CFStringCreateWithPascalString(PyObject
*_self
, PyObject
*_args
)
3665 PyObject
*_res
= NULL
;
3668 CFStringEncoding encoding
;
3669 #ifndef CFStringCreateWithPascalString
3670 PyMac_PRECHECK(CFStringCreateWithPascalString
);
3672 if (!PyArg_ParseTuple(_args
, "O&l",
3673 PyMac_GetStr255
, pStr
,
3676 _rv
= CFStringCreateWithPascalString((CFAllocatorRef
)NULL
,
3679 _res
= Py_BuildValue("O&",
3680 CFStringRefObj_New
, _rv
);
3684 static PyObject
*CF_CFStringCreateWithCString(PyObject
*_self
, PyObject
*_args
)
3686 PyObject
*_res
= NULL
;
3689 CFStringEncoding encoding
;
3690 #ifndef CFStringCreateWithCString
3691 PyMac_PRECHECK(CFStringCreateWithCString
);
3693 if (!PyArg_ParseTuple(_args
, "sl",
3697 _rv
= CFStringCreateWithCString((CFAllocatorRef
)NULL
,
3700 _res
= Py_BuildValue("O&",
3701 CFStringRefObj_New
, _rv
);
3705 static PyObject
*CF_CFStringCreateWithCharacters(PyObject
*_self
, PyObject
*_args
)
3707 PyObject
*_res
= NULL
;
3709 UniChar
*chars__in__
;
3710 UniCharCount chars__len__
;
3711 int chars__in_len__
;
3712 #ifndef CFStringCreateWithCharacters
3713 PyMac_PRECHECK(CFStringCreateWithCharacters
);
3715 if (!PyArg_ParseTuple(_args
, "u#",
3716 &chars__in__
, &chars__in_len__
))
3718 chars__len__
= chars__in_len__
;
3719 _rv
= CFStringCreateWithCharacters((CFAllocatorRef
)NULL
,
3720 chars__in__
, chars__len__
);
3721 _res
= Py_BuildValue("O&",
3722 CFStringRefObj_New
, _rv
);
3726 static PyObject
*CF_CFStringCreateWithPascalStringNoCopy(PyObject
*_self
, PyObject
*_args
)
3728 PyObject
*_res
= NULL
;
3731 CFStringEncoding encoding
;
3732 #ifndef CFStringCreateWithPascalStringNoCopy
3733 PyMac_PRECHECK(CFStringCreateWithPascalStringNoCopy
);
3735 if (!PyArg_ParseTuple(_args
, "O&l",
3736 PyMac_GetStr255
, pStr
,
3739 _rv
= CFStringCreateWithPascalStringNoCopy((CFAllocatorRef
)NULL
,
3742 (CFAllocatorRef
)NULL
);
3743 _res
= Py_BuildValue("O&",
3744 CFStringRefObj_New
, _rv
);
3748 static PyObject
*CF_CFStringCreateWithCStringNoCopy(PyObject
*_self
, PyObject
*_args
)
3750 PyObject
*_res
= NULL
;
3753 CFStringEncoding encoding
;
3754 #ifndef CFStringCreateWithCStringNoCopy
3755 PyMac_PRECHECK(CFStringCreateWithCStringNoCopy
);
3757 if (!PyArg_ParseTuple(_args
, "sl",
3761 _rv
= CFStringCreateWithCStringNoCopy((CFAllocatorRef
)NULL
,
3764 (CFAllocatorRef
)NULL
);
3765 _res
= Py_BuildValue("O&",
3766 CFStringRefObj_New
, _rv
);
3770 static PyObject
*CF_CFStringCreateWithCharactersNoCopy(PyObject
*_self
, PyObject
*_args
)
3772 PyObject
*_res
= NULL
;
3774 UniChar
*chars__in__
;
3775 UniCharCount chars__len__
;
3776 int chars__in_len__
;
3777 #ifndef CFStringCreateWithCharactersNoCopy
3778 PyMac_PRECHECK(CFStringCreateWithCharactersNoCopy
);
3780 if (!PyArg_ParseTuple(_args
, "u#",
3781 &chars__in__
, &chars__in_len__
))
3783 chars__len__
= chars__in_len__
;
3784 _rv
= CFStringCreateWithCharactersNoCopy((CFAllocatorRef
)NULL
,
3785 chars__in__
, chars__len__
,
3786 (CFAllocatorRef
)NULL
);
3787 _res
= Py_BuildValue("O&",
3788 CFStringRefObj_New
, _rv
);
3792 static PyObject
*CF_CFStringCreateMutable(PyObject
*_self
, PyObject
*_args
)
3794 PyObject
*_res
= NULL
;
3795 CFMutableStringRef _rv
;
3797 #ifndef CFStringCreateMutable
3798 PyMac_PRECHECK(CFStringCreateMutable
);
3800 if (!PyArg_ParseTuple(_args
, "l",
3803 _rv
= CFStringCreateMutable((CFAllocatorRef
)NULL
,
3805 _res
= Py_BuildValue("O&",
3806 CFMutableStringRefObj_New
, _rv
);
3810 static PyObject
*CF_CFStringCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3812 PyObject
*_res
= NULL
;
3813 CFMutableStringRef _rv
;
3815 CFStringRef theString
;
3816 #ifndef CFStringCreateMutableCopy
3817 PyMac_PRECHECK(CFStringCreateMutableCopy
);
3819 if (!PyArg_ParseTuple(_args
, "lO&",
3821 CFStringRefObj_Convert
, &theString
))
3823 _rv
= CFStringCreateMutableCopy((CFAllocatorRef
)NULL
,
3826 _res
= Py_BuildValue("O&",
3827 CFMutableStringRefObj_New
, _rv
);
3831 static PyObject
*CF_CFStringCreateWithBytes(PyObject
*_self
, PyObject
*_args
)
3833 PyObject
*_res
= NULL
;
3835 unsigned char *bytes__in__
;
3837 int bytes__in_len__
;
3838 CFStringEncoding encoding
;
3839 Boolean isExternalRepresentation
;
3840 #ifndef CFStringCreateWithBytes
3841 PyMac_PRECHECK(CFStringCreateWithBytes
);
3843 if (!PyArg_ParseTuple(_args
, "s#ll",
3844 &bytes__in__
, &bytes__in_len__
,
3846 &isExternalRepresentation
))
3848 bytes__len__
= bytes__in_len__
;
3849 _rv
= CFStringCreateWithBytes((CFAllocatorRef
)NULL
,
3850 bytes__in__
, bytes__len__
,
3852 isExternalRepresentation
);
3853 _res
= Py_BuildValue("O&",
3854 CFStringRefObj_New
, _rv
);
3858 static PyObject
*CF_CFStringGetSystemEncoding(PyObject
*_self
, PyObject
*_args
)
3860 PyObject
*_res
= NULL
;
3861 CFStringEncoding _rv
;
3862 #ifndef CFStringGetSystemEncoding
3863 PyMac_PRECHECK(CFStringGetSystemEncoding
);
3865 if (!PyArg_ParseTuple(_args
, ""))
3867 _rv
= CFStringGetSystemEncoding();
3868 _res
= Py_BuildValue("l",
3873 static PyObject
*CF_CFStringGetMaximumSizeForEncoding(PyObject
*_self
, PyObject
*_args
)
3875 PyObject
*_res
= NULL
;
3878 CFStringEncoding encoding
;
3879 #ifndef CFStringGetMaximumSizeForEncoding
3880 PyMac_PRECHECK(CFStringGetMaximumSizeForEncoding
);
3882 if (!PyArg_ParseTuple(_args
, "ll",
3886 _rv
= CFStringGetMaximumSizeForEncoding(length
,
3888 _res
= Py_BuildValue("l",
3893 static PyObject
*CF_CFStringIsEncodingAvailable(PyObject
*_self
, PyObject
*_args
)
3895 PyObject
*_res
= NULL
;
3897 CFStringEncoding encoding
;
3898 #ifndef CFStringIsEncodingAvailable
3899 PyMac_PRECHECK(CFStringIsEncodingAvailable
);
3901 if (!PyArg_ParseTuple(_args
, "l",
3904 _rv
= CFStringIsEncodingAvailable(encoding
);
3905 _res
= Py_BuildValue("l",
3910 static PyObject
*CF_CFStringGetNameOfEncoding(PyObject
*_self
, PyObject
*_args
)
3912 PyObject
*_res
= NULL
;
3914 CFStringEncoding encoding
;
3915 #ifndef CFStringGetNameOfEncoding
3916 PyMac_PRECHECK(CFStringGetNameOfEncoding
);
3918 if (!PyArg_ParseTuple(_args
, "l",
3921 _rv
= CFStringGetNameOfEncoding(encoding
);
3922 _res
= Py_BuildValue("O&",
3923 CFStringRefObj_New
, _rv
);
3927 static PyObject
*CF_CFStringConvertEncodingToNSStringEncoding(PyObject
*_self
, PyObject
*_args
)
3929 PyObject
*_res
= NULL
;
3931 CFStringEncoding encoding
;
3932 #ifndef CFStringConvertEncodingToNSStringEncoding
3933 PyMac_PRECHECK(CFStringConvertEncodingToNSStringEncoding
);
3935 if (!PyArg_ParseTuple(_args
, "l",
3938 _rv
= CFStringConvertEncodingToNSStringEncoding(encoding
);
3939 _res
= Py_BuildValue("l",
3944 static PyObject
*CF_CFStringConvertNSStringEncodingToEncoding(PyObject
*_self
, PyObject
*_args
)
3946 PyObject
*_res
= NULL
;
3947 CFStringEncoding _rv
;
3949 #ifndef CFStringConvertNSStringEncodingToEncoding
3950 PyMac_PRECHECK(CFStringConvertNSStringEncodingToEncoding
);
3952 if (!PyArg_ParseTuple(_args
, "l",
3955 _rv
= CFStringConvertNSStringEncodingToEncoding(encoding
);
3956 _res
= Py_BuildValue("l",
3961 static PyObject
*CF_CFStringConvertEncodingToWindowsCodepage(PyObject
*_self
, PyObject
*_args
)
3963 PyObject
*_res
= NULL
;
3965 CFStringEncoding encoding
;
3966 #ifndef CFStringConvertEncodingToWindowsCodepage
3967 PyMac_PRECHECK(CFStringConvertEncodingToWindowsCodepage
);
3969 if (!PyArg_ParseTuple(_args
, "l",
3972 _rv
= CFStringConvertEncodingToWindowsCodepage(encoding
);
3973 _res
= Py_BuildValue("l",
3978 static PyObject
*CF_CFStringConvertWindowsCodepageToEncoding(PyObject
*_self
, PyObject
*_args
)
3980 PyObject
*_res
= NULL
;
3981 CFStringEncoding _rv
;
3983 #ifndef CFStringConvertWindowsCodepageToEncoding
3984 PyMac_PRECHECK(CFStringConvertWindowsCodepageToEncoding
);
3986 if (!PyArg_ParseTuple(_args
, "l",
3989 _rv
= CFStringConvertWindowsCodepageToEncoding(codepage
);
3990 _res
= Py_BuildValue("l",
3995 static PyObject
*CF_CFStringConvertEncodingToIANACharSetName(PyObject
*_self
, PyObject
*_args
)
3997 PyObject
*_res
= NULL
;
3999 CFStringEncoding encoding
;
4000 #ifndef CFStringConvertEncodingToIANACharSetName
4001 PyMac_PRECHECK(CFStringConvertEncodingToIANACharSetName
);
4003 if (!PyArg_ParseTuple(_args
, "l",
4006 _rv
= CFStringConvertEncodingToIANACharSetName(encoding
);
4007 _res
= Py_BuildValue("O&",
4008 CFStringRefObj_New
, _rv
);
4012 static PyObject
*CF_CFStringGetMostCompatibleMacStringEncoding(PyObject
*_self
, PyObject
*_args
)
4014 PyObject
*_res
= NULL
;
4015 CFStringEncoding _rv
;
4016 CFStringEncoding encoding
;
4017 #ifndef CFStringGetMostCompatibleMacStringEncoding
4018 PyMac_PRECHECK(CFStringGetMostCompatibleMacStringEncoding
);
4020 if (!PyArg_ParseTuple(_args
, "l",
4023 _rv
= CFStringGetMostCompatibleMacStringEncoding(encoding
);
4024 _res
= Py_BuildValue("l",
4029 static PyObject
*CF___CFStringMakeConstantString(PyObject
*_self
, PyObject
*_args
)
4031 PyObject
*_res
= NULL
;
4034 #ifndef __CFStringMakeConstantString
4035 PyMac_PRECHECK(__CFStringMakeConstantString
);
4037 if (!PyArg_ParseTuple(_args
, "s",
4040 _rv
= __CFStringMakeConstantString(cStr
);
4041 _res
= Py_BuildValue("O&",
4042 CFStringRefObj_New
, _rv
);
4046 static PyObject
*CF_CFURLGetTypeID(PyObject
*_self
, PyObject
*_args
)
4048 PyObject
*_res
= NULL
;
4050 #ifndef CFURLGetTypeID
4051 PyMac_PRECHECK(CFURLGetTypeID
);
4053 if (!PyArg_ParseTuple(_args
, ""))
4055 _rv
= CFURLGetTypeID();
4056 _res
= Py_BuildValue("l",
4061 static PyObject
*CF_CFURLCreateWithBytes(PyObject
*_self
, PyObject
*_args
)
4063 PyObject
*_res
= NULL
;
4065 unsigned char *URLBytes__in__
;
4066 long URLBytes__len__
;
4067 int URLBytes__in_len__
;
4068 CFStringEncoding encoding
;
4070 #ifndef CFURLCreateWithBytes
4071 PyMac_PRECHECK(CFURLCreateWithBytes
);
4073 if (!PyArg_ParseTuple(_args
, "s#lO&",
4074 &URLBytes__in__
, &URLBytes__in_len__
,
4076 OptionalCFURLRefObj_Convert
, &baseURL
))
4078 URLBytes__len__
= URLBytes__in_len__
;
4079 _rv
= CFURLCreateWithBytes((CFAllocatorRef
)NULL
,
4080 URLBytes__in__
, URLBytes__len__
,
4083 _res
= Py_BuildValue("O&",
4084 CFURLRefObj_New
, _rv
);
4088 static PyObject
*CF_CFURLCreateFromFileSystemRepresentation(PyObject
*_self
, PyObject
*_args
)
4090 PyObject
*_res
= NULL
;
4092 unsigned char *buffer__in__
;
4094 int buffer__in_len__
;
4095 Boolean isDirectory
;
4096 #ifndef CFURLCreateFromFileSystemRepresentation
4097 PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentation
);
4099 if (!PyArg_ParseTuple(_args
, "s#l",
4100 &buffer__in__
, &buffer__in_len__
,
4103 buffer__len__
= buffer__in_len__
;
4104 _rv
= CFURLCreateFromFileSystemRepresentation((CFAllocatorRef
)NULL
,
4105 buffer__in__
, buffer__len__
,
4107 _res
= Py_BuildValue("O&",
4108 CFURLRefObj_New
, _rv
);
4112 static PyObject
*CF_CFURLCreateFromFileSystemRepresentationRelativeToBase(PyObject
*_self
, PyObject
*_args
)
4114 PyObject
*_res
= NULL
;
4116 unsigned char *buffer__in__
;
4118 int buffer__in_len__
;
4119 Boolean isDirectory
;
4121 #ifndef CFURLCreateFromFileSystemRepresentationRelativeToBase
4122 PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentationRelativeToBase
);
4124 if (!PyArg_ParseTuple(_args
, "s#lO&",
4125 &buffer__in__
, &buffer__in_len__
,
4127 OptionalCFURLRefObj_Convert
, &baseURL
))
4129 buffer__len__
= buffer__in_len__
;
4130 _rv
= CFURLCreateFromFileSystemRepresentationRelativeToBase((CFAllocatorRef
)NULL
,
4131 buffer__in__
, buffer__len__
,
4134 _res
= Py_BuildValue("O&",
4135 CFURLRefObj_New
, _rv
);
4139 static PyObject
*CF_CFURLCreateFromFSRef(PyObject
*_self
, PyObject
*_args
)
4141 PyObject
*_res
= NULL
;
4144 #ifndef CFURLCreateFromFSRef
4145 PyMac_PRECHECK(CFURLCreateFromFSRef
);
4147 if (!PyArg_ParseTuple(_args
, "O&",
4148 PyMac_GetFSRef
, &fsRef
))
4150 _rv
= CFURLCreateFromFSRef((CFAllocatorRef
)NULL
,
4152 _res
= Py_BuildValue("O&",
4153 CFURLRefObj_New
, _rv
);
4157 static PyObject
*CF_toCF(PyObject
*_self
, PyObject
*_args
)
4159 PyObject
*_res
= NULL
;
4164 if (!PyArg_ParseTuple(_args
, "O&", PyCF_Python2CF
, &rv
))
4166 typeid = CFGetTypeID(rv
);
4168 if (typeid == CFStringGetTypeID())
4169 return Py_BuildValue("O&", CFStringRefObj_New
, rv
);
4170 if (typeid == CFArrayGetTypeID())
4171 return Py_BuildValue("O&", CFArrayRefObj_New
, rv
);
4172 if (typeid == CFDictionaryGetTypeID())
4173 return Py_BuildValue("O&", CFDictionaryRefObj_New
, rv
);
4174 if (typeid == CFURLGetTypeID())
4175 return Py_BuildValue("O&", CFURLRefObj_New
, rv
);
4177 _res
= Py_BuildValue("O&", CFTypeRefObj_New
, rv
);
4182 static PyMethodDef CF_methods
[] = {
4183 {"__CFRangeMake", (PyCFunction
)CF___CFRangeMake
, 1,
4184 PyDoc_STR("(CFIndex loc, CFIndex len) -> (CFRange _rv)")},
4185 {"CFAllocatorGetTypeID", (PyCFunction
)CF_CFAllocatorGetTypeID
, 1,
4186 PyDoc_STR("() -> (CFTypeID _rv)")},
4187 {"CFAllocatorGetPreferredSizeForSize", (PyCFunction
)CF_CFAllocatorGetPreferredSizeForSize
, 1,
4188 PyDoc_STR("(CFIndex size, CFOptionFlags hint) -> (CFIndex _rv)")},
4189 {"CFCopyTypeIDDescription", (PyCFunction
)CF_CFCopyTypeIDDescription
, 1,
4190 PyDoc_STR("(CFTypeID type_id) -> (CFStringRef _rv)")},
4191 {"CFArrayGetTypeID", (PyCFunction
)CF_CFArrayGetTypeID
, 1,
4192 PyDoc_STR("() -> (CFTypeID _rv)")},
4193 {"CFArrayCreateMutable", (PyCFunction
)CF_CFArrayCreateMutable
, 1,
4194 PyDoc_STR("(CFIndex capacity) -> (CFMutableArrayRef _rv)")},
4195 {"CFArrayCreateMutableCopy", (PyCFunction
)CF_CFArrayCreateMutableCopy
, 1,
4196 PyDoc_STR("(CFIndex capacity, CFArrayRef theArray) -> (CFMutableArrayRef _rv)")},
4197 {"CFDataGetTypeID", (PyCFunction
)CF_CFDataGetTypeID
, 1,
4198 PyDoc_STR("() -> (CFTypeID _rv)")},
4199 {"CFDataCreate", (PyCFunction
)CF_CFDataCreate
, 1,
4200 PyDoc_STR("(Buffer bytes) -> (CFDataRef _rv)")},
4201 {"CFDataCreateWithBytesNoCopy", (PyCFunction
)CF_CFDataCreateWithBytesNoCopy
, 1,
4202 PyDoc_STR("(Buffer bytes) -> (CFDataRef _rv)")},
4203 {"CFDataCreateMutable", (PyCFunction
)CF_CFDataCreateMutable
, 1,
4204 PyDoc_STR("(CFIndex capacity) -> (CFMutableDataRef _rv)")},
4205 {"CFDataCreateMutableCopy", (PyCFunction
)CF_CFDataCreateMutableCopy
, 1,
4206 PyDoc_STR("(CFIndex capacity, CFDataRef theData) -> (CFMutableDataRef _rv)")},
4207 {"CFDictionaryGetTypeID", (PyCFunction
)CF_CFDictionaryGetTypeID
, 1,
4208 PyDoc_STR("() -> (CFTypeID _rv)")},
4209 {"CFDictionaryCreateMutable", (PyCFunction
)CF_CFDictionaryCreateMutable
, 1,
4210 PyDoc_STR("(CFIndex capacity) -> (CFMutableDictionaryRef _rv)")},
4211 {"CFDictionaryCreateMutableCopy", (PyCFunction
)CF_CFDictionaryCreateMutableCopy
, 1,
4212 PyDoc_STR("(CFIndex capacity, CFDictionaryRef theDict) -> (CFMutableDictionaryRef _rv)")},
4213 {"CFPreferencesCopyAppValue", (PyCFunction
)CF_CFPreferencesCopyAppValue
, 1,
4214 PyDoc_STR("(CFStringRef key, CFStringRef applicationID) -> (CFTypeRef _rv)")},
4215 {"CFPreferencesGetAppBooleanValue", (PyCFunction
)CF_CFPreferencesGetAppBooleanValue
, 1,
4216 PyDoc_STR("(CFStringRef key, CFStringRef applicationID) -> (Boolean _rv, Boolean keyExistsAndHasValidFormat)")},
4217 {"CFPreferencesGetAppIntegerValue", (PyCFunction
)CF_CFPreferencesGetAppIntegerValue
, 1,
4218 PyDoc_STR("(CFStringRef key, CFStringRef applicationID) -> (CFIndex _rv, Boolean keyExistsAndHasValidFormat)")},
4219 {"CFPreferencesSetAppValue", (PyCFunction
)CF_CFPreferencesSetAppValue
, 1,
4220 PyDoc_STR("(CFStringRef key, CFTypeRef value, CFStringRef applicationID) -> None")},
4221 {"CFPreferencesAddSuitePreferencesToApp", (PyCFunction
)CF_CFPreferencesAddSuitePreferencesToApp
, 1,
4222 PyDoc_STR("(CFStringRef applicationID, CFStringRef suiteID) -> None")},
4223 {"CFPreferencesRemoveSuitePreferencesFromApp", (PyCFunction
)CF_CFPreferencesRemoveSuitePreferencesFromApp
, 1,
4224 PyDoc_STR("(CFStringRef applicationID, CFStringRef suiteID) -> None")},
4225 {"CFPreferencesAppSynchronize", (PyCFunction
)CF_CFPreferencesAppSynchronize
, 1,
4226 PyDoc_STR("(CFStringRef applicationID) -> (Boolean _rv)")},
4227 {"CFPreferencesCopyValue", (PyCFunction
)CF_CFPreferencesCopyValue
, 1,
4228 PyDoc_STR("(CFStringRef key, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFTypeRef _rv)")},
4229 {"CFPreferencesCopyMultiple", (PyCFunction
)CF_CFPreferencesCopyMultiple
, 1,
4230 PyDoc_STR("(CFArrayRef keysToFetch, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFDictionaryRef _rv)")},
4231 {"CFPreferencesSetValue", (PyCFunction
)CF_CFPreferencesSetValue
, 1,
4232 PyDoc_STR("(CFStringRef key, CFTypeRef value, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None")},
4233 {"CFPreferencesSetMultiple", (PyCFunction
)CF_CFPreferencesSetMultiple
, 1,
4234 PyDoc_STR("(CFDictionaryRef keysToSet, CFArrayRef keysToRemove, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None")},
4235 {"CFPreferencesSynchronize", (PyCFunction
)CF_CFPreferencesSynchronize
, 1,
4236 PyDoc_STR("(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (Boolean _rv)")},
4237 {"CFPreferencesCopyApplicationList", (PyCFunction
)CF_CFPreferencesCopyApplicationList
, 1,
4238 PyDoc_STR("(CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)")},
4239 {"CFPreferencesCopyKeyList", (PyCFunction
)CF_CFPreferencesCopyKeyList
, 1,
4240 PyDoc_STR("(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)")},
4241 {"CFStringGetTypeID", (PyCFunction
)CF_CFStringGetTypeID
, 1,
4242 PyDoc_STR("() -> (CFTypeID _rv)")},
4243 {"CFStringCreateWithPascalString", (PyCFunction
)CF_CFStringCreateWithPascalString
, 1,
4244 PyDoc_STR("(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)")},
4245 {"CFStringCreateWithCString", (PyCFunction
)CF_CFStringCreateWithCString
, 1,
4246 PyDoc_STR("(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)")},
4247 {"CFStringCreateWithCharacters", (PyCFunction
)CF_CFStringCreateWithCharacters
, 1,
4248 PyDoc_STR("(Buffer chars) -> (CFStringRef _rv)")},
4249 {"CFStringCreateWithPascalStringNoCopy", (PyCFunction
)CF_CFStringCreateWithPascalStringNoCopy
, 1,
4250 PyDoc_STR("(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)")},
4251 {"CFStringCreateWithCStringNoCopy", (PyCFunction
)CF_CFStringCreateWithCStringNoCopy
, 1,
4252 PyDoc_STR("(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)")},
4253 {"CFStringCreateWithCharactersNoCopy", (PyCFunction
)CF_CFStringCreateWithCharactersNoCopy
, 1,
4254 PyDoc_STR("(Buffer chars) -> (CFStringRef _rv)")},
4255 {"CFStringCreateMutable", (PyCFunction
)CF_CFStringCreateMutable
, 1,
4256 PyDoc_STR("(CFIndex maxLength) -> (CFMutableStringRef _rv)")},
4257 {"CFStringCreateMutableCopy", (PyCFunction
)CF_CFStringCreateMutableCopy
, 1,
4258 PyDoc_STR("(CFIndex maxLength, CFStringRef theString) -> (CFMutableStringRef _rv)")},
4259 {"CFStringCreateWithBytes", (PyCFunction
)CF_CFStringCreateWithBytes
, 1,
4260 PyDoc_STR("(Buffer bytes, CFStringEncoding encoding, Boolean isExternalRepresentation) -> (CFStringRef _rv)")},
4261 {"CFStringGetSystemEncoding", (PyCFunction
)CF_CFStringGetSystemEncoding
, 1,
4262 PyDoc_STR("() -> (CFStringEncoding _rv)")},
4263 {"CFStringGetMaximumSizeForEncoding", (PyCFunction
)CF_CFStringGetMaximumSizeForEncoding
, 1,
4264 PyDoc_STR("(CFIndex length, CFStringEncoding encoding) -> (CFIndex _rv)")},
4265 {"CFStringIsEncodingAvailable", (PyCFunction
)CF_CFStringIsEncodingAvailable
, 1,
4266 PyDoc_STR("(CFStringEncoding encoding) -> (Boolean _rv)")},
4267 {"CFStringGetNameOfEncoding", (PyCFunction
)CF_CFStringGetNameOfEncoding
, 1,
4268 PyDoc_STR("(CFStringEncoding encoding) -> (CFStringRef _rv)")},
4269 {"CFStringConvertEncodingToNSStringEncoding", (PyCFunction
)CF_CFStringConvertEncodingToNSStringEncoding
, 1,
4270 PyDoc_STR("(CFStringEncoding encoding) -> (UInt32 _rv)")},
4271 {"CFStringConvertNSStringEncodingToEncoding", (PyCFunction
)CF_CFStringConvertNSStringEncodingToEncoding
, 1,
4272 PyDoc_STR("(UInt32 encoding) -> (CFStringEncoding _rv)")},
4273 {"CFStringConvertEncodingToWindowsCodepage", (PyCFunction
)CF_CFStringConvertEncodingToWindowsCodepage
, 1,
4274 PyDoc_STR("(CFStringEncoding encoding) -> (UInt32 _rv)")},
4275 {"CFStringConvertWindowsCodepageToEncoding", (PyCFunction
)CF_CFStringConvertWindowsCodepageToEncoding
, 1,
4276 PyDoc_STR("(UInt32 codepage) -> (CFStringEncoding _rv)")},
4277 {"CFStringConvertEncodingToIANACharSetName", (PyCFunction
)CF_CFStringConvertEncodingToIANACharSetName
, 1,
4278 PyDoc_STR("(CFStringEncoding encoding) -> (CFStringRef _rv)")},
4279 {"CFStringGetMostCompatibleMacStringEncoding", (PyCFunction
)CF_CFStringGetMostCompatibleMacStringEncoding
, 1,
4280 PyDoc_STR("(CFStringEncoding encoding) -> (CFStringEncoding _rv)")},
4281 {"__CFStringMakeConstantString", (PyCFunction
)CF___CFStringMakeConstantString
, 1,
4282 PyDoc_STR("(char* cStr) -> (CFStringRef _rv)")},
4283 {"CFURLGetTypeID", (PyCFunction
)CF_CFURLGetTypeID
, 1,
4284 PyDoc_STR("() -> (CFTypeID _rv)")},
4285 {"CFURLCreateWithBytes", (PyCFunction
)CF_CFURLCreateWithBytes
, 1,
4286 PyDoc_STR("(Buffer URLBytes, CFStringEncoding encoding, CFURLRef baseURL) -> (CFURLRef _rv)")},
4287 {"CFURLCreateFromFileSystemRepresentation", (PyCFunction
)CF_CFURLCreateFromFileSystemRepresentation
, 1,
4288 PyDoc_STR("(Buffer buffer, Boolean isDirectory) -> (CFURLRef _rv)")},
4289 {"CFURLCreateFromFileSystemRepresentationRelativeToBase", (PyCFunction
)CF_CFURLCreateFromFileSystemRepresentationRelativeToBase
, 1,
4290 PyDoc_STR("(Buffer buffer, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)")},
4291 {"CFURLCreateFromFSRef", (PyCFunction
)CF_CFURLCreateFromFSRef
, 1,
4292 PyDoc_STR("(FSRef fsRef) -> (CFURLRef _rv)")},
4293 {"toCF", (PyCFunction
)CF_toCF
, 1,
4294 PyDoc_STR("(python_object) -> (CF_object)")},
4301 /* Routines to convert any CF type to/from the corresponding CFxxxObj */
4302 PyObject
*CFObj_New(CFTypeRef itself
)
4306 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
4309 if (CFGetTypeID(itself
) == CFArrayGetTypeID()) return CFArrayRefObj_New((CFArrayRef
)itself
);
4310 if (CFGetTypeID(itself
) == CFDictionaryGetTypeID()) return CFDictionaryRefObj_New((CFDictionaryRef
)itself
);
4311 if (CFGetTypeID(itself
) == CFDataGetTypeID()) return CFDataRefObj_New((CFDataRef
)itself
);
4312 if (CFGetTypeID(itself
) == CFStringGetTypeID()) return CFStringRefObj_New((CFStringRef
)itself
);
4313 if (CFGetTypeID(itself
) == CFURLGetTypeID()) return CFURLRefObj_New((CFURLRef
)itself
);
4314 /* XXXX Or should we use PyCF_CF2Python here?? */
4315 return CFTypeRefObj_New(itself
);
4317 int CFObj_Convert(PyObject
*v
, CFTypeRef
*p_itself
)
4320 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
4321 /* Check for other CF objects here */
4323 if (!CFTypeRefObj_Check(v
) &&
4324 !CFArrayRefObj_Check(v
) &&
4325 !CFMutableArrayRefObj_Check(v
) &&
4326 !CFDictionaryRefObj_Check(v
) &&
4327 !CFMutableDictionaryRefObj_Check(v
) &&
4328 !CFDataRefObj_Check(v
) &&
4329 !CFMutableDataRefObj_Check(v
) &&
4330 !CFStringRefObj_Check(v
) &&
4331 !CFMutableStringRefObj_Check(v
) &&
4332 !CFURLRefObj_Check(v
) )
4334 /* XXXX Or should we use PyCF_Python2CF here?? */
4335 PyErr_SetString(PyExc_TypeError
, "CF object required");
4338 *p_itself
= ((CFTypeRefObject
*)v
)->ob_itself
;
4350 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFTypeRef
, CFTypeRefObj_New
);
4351 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFTypeRef
, CFTypeRefObj_Convert
);
4352 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFStringRef
, CFStringRefObj_New
);
4353 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFStringRef
, CFStringRefObj_Convert
);
4354 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableStringRef
, CFMutableStringRefObj_New
);
4355 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableStringRef
, CFMutableStringRefObj_Convert
);
4357 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFArrayRef
, CFArrayRefObj_New
);
4358 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFArrayRef
, CFArrayRefObj_Convert
);
4359 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableArrayRef
, CFMutableArrayRefObj_New
);
4360 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableArrayRef
, CFMutableArrayRefObj_Convert
);
4361 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFDictionaryRef
, CFDictionaryRefObj_New
);
4362 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFDictionaryRef
, CFDictionaryRefObj_Convert
);
4363 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableDictionaryRef
, CFMutableDictionaryRefObj_New
);
4364 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableDictionaryRef
, CFMutableDictionaryRefObj_Convert
);
4365 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFURLRef
, CFURLRefObj_New
);
4366 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef
, CFURLRefObj_Convert
);
4367 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef
, CFURLRefObj_Convert
);
4370 m
= Py_InitModule("_CF", CF_methods
);
4371 d
= PyModule_GetDict(m
);
4372 CF_Error
= PyMac_GetOSErrException();
4373 if (CF_Error
== NULL
||
4374 PyDict_SetItemString(d
, "Error", CF_Error
) != 0)
4376 CFTypeRef_Type
.ob_type
= &PyType_Type
;
4377 if (PyType_Ready(&CFTypeRef_Type
) < 0) return;
4378 Py_INCREF(&CFTypeRef_Type
);
4379 PyModule_AddObject(m
, "CFTypeRef", (PyObject
*)&CFTypeRef_Type
);
4380 /* Backward-compatible name */
4381 Py_INCREF(&CFTypeRef_Type
);
4382 PyModule_AddObject(m
, "CFTypeRefType", (PyObject
*)&CFTypeRef_Type
);
4383 CFArrayRef_Type
.ob_type
= &PyType_Type
;
4384 if (PyType_Ready(&CFArrayRef_Type
) < 0) return;
4385 Py_INCREF(&CFArrayRef_Type
);
4386 PyModule_AddObject(m
, "CFArrayRef", (PyObject
*)&CFArrayRef_Type
);
4387 /* Backward-compatible name */
4388 Py_INCREF(&CFArrayRef_Type
);
4389 PyModule_AddObject(m
, "CFArrayRefType", (PyObject
*)&CFArrayRef_Type
);
4390 CFMutableArrayRef_Type
.ob_type
= &PyType_Type
;
4391 if (PyType_Ready(&CFMutableArrayRef_Type
) < 0) return;
4392 Py_INCREF(&CFMutableArrayRef_Type
);
4393 PyModule_AddObject(m
, "CFMutableArrayRef", (PyObject
*)&CFMutableArrayRef_Type
);
4394 /* Backward-compatible name */
4395 Py_INCREF(&CFMutableArrayRef_Type
);
4396 PyModule_AddObject(m
, "CFMutableArrayRefType", (PyObject
*)&CFMutableArrayRef_Type
);
4397 CFDictionaryRef_Type
.ob_type
= &PyType_Type
;
4398 if (PyType_Ready(&CFDictionaryRef_Type
) < 0) return;
4399 Py_INCREF(&CFDictionaryRef_Type
);
4400 PyModule_AddObject(m
, "CFDictionaryRef", (PyObject
*)&CFDictionaryRef_Type
);
4401 /* Backward-compatible name */
4402 Py_INCREF(&CFDictionaryRef_Type
);
4403 PyModule_AddObject(m
, "CFDictionaryRefType", (PyObject
*)&CFDictionaryRef_Type
);
4404 CFMutableDictionaryRef_Type
.ob_type
= &PyType_Type
;
4405 if (PyType_Ready(&CFMutableDictionaryRef_Type
) < 0) return;
4406 Py_INCREF(&CFMutableDictionaryRef_Type
);
4407 PyModule_AddObject(m
, "CFMutableDictionaryRef", (PyObject
*)&CFMutableDictionaryRef_Type
);
4408 /* Backward-compatible name */
4409 Py_INCREF(&CFMutableDictionaryRef_Type
);
4410 PyModule_AddObject(m
, "CFMutableDictionaryRefType", (PyObject
*)&CFMutableDictionaryRef_Type
);
4411 CFDataRef_Type
.ob_type
= &PyType_Type
;
4412 if (PyType_Ready(&CFDataRef_Type
) < 0) return;
4413 Py_INCREF(&CFDataRef_Type
);
4414 PyModule_AddObject(m
, "CFDataRef", (PyObject
*)&CFDataRef_Type
);
4415 /* Backward-compatible name */
4416 Py_INCREF(&CFDataRef_Type
);
4417 PyModule_AddObject(m
, "CFDataRefType", (PyObject
*)&CFDataRef_Type
);
4418 CFMutableDataRef_Type
.ob_type
= &PyType_Type
;
4419 if (PyType_Ready(&CFMutableDataRef_Type
) < 0) return;
4420 Py_INCREF(&CFMutableDataRef_Type
);
4421 PyModule_AddObject(m
, "CFMutableDataRef", (PyObject
*)&CFMutableDataRef_Type
);
4422 /* Backward-compatible name */
4423 Py_INCREF(&CFMutableDataRef_Type
);
4424 PyModule_AddObject(m
, "CFMutableDataRefType", (PyObject
*)&CFMutableDataRef_Type
);
4425 CFStringRef_Type
.ob_type
= &PyType_Type
;
4426 if (PyType_Ready(&CFStringRef_Type
) < 0) return;
4427 Py_INCREF(&CFStringRef_Type
);
4428 PyModule_AddObject(m
, "CFStringRef", (PyObject
*)&CFStringRef_Type
);
4429 /* Backward-compatible name */
4430 Py_INCREF(&CFStringRef_Type
);
4431 PyModule_AddObject(m
, "CFStringRefType", (PyObject
*)&CFStringRef_Type
);
4432 CFMutableStringRef_Type
.ob_type
= &PyType_Type
;
4433 if (PyType_Ready(&CFMutableStringRef_Type
) < 0) return;
4434 Py_INCREF(&CFMutableStringRef_Type
);
4435 PyModule_AddObject(m
, "CFMutableStringRef", (PyObject
*)&CFMutableStringRef_Type
);
4436 /* Backward-compatible name */
4437 Py_INCREF(&CFMutableStringRef_Type
);
4438 PyModule_AddObject(m
, "CFMutableStringRefType", (PyObject
*)&CFMutableStringRef_Type
);
4439 CFURLRef_Type
.ob_type
= &PyType_Type
;
4440 if (PyType_Ready(&CFURLRef_Type
) < 0) return;
4441 Py_INCREF(&CFURLRef_Type
);
4442 PyModule_AddObject(m
, "CFURLRef", (PyObject
*)&CFURLRef_Type
);
4443 /* Backward-compatible name */
4444 Py_INCREF(&CFURLRef_Type
);
4445 PyModule_AddObject(m
, "CFURLRefType", (PyObject
*)&CFURLRef_Type
);
4447 #define _STRINGCONST(name) PyModule_AddObject(m, #name, CFStringRefObj_New(name))
4448 _STRINGCONST(kCFPreferencesAnyApplication
);
4449 _STRINGCONST(kCFPreferencesCurrentApplication
);
4450 _STRINGCONST(kCFPreferencesAnyHost
);
4451 _STRINGCONST(kCFPreferencesCurrentHost
);
4452 _STRINGCONST(kCFPreferencesAnyUser
);
4453 _STRINGCONST(kCFPreferencesCurrentUser
);
4459 /* ========================= End module _CF ========================= */