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
*_CFTypeRefObj_New(CFTypeRef
);
40 extern int _CFTypeRefObj_Convert(PyObject
*, CFTypeRef
*);
41 #define CFTypeRefObj_New _CFTypeRefObj_New
42 #define CFTypeRefObj_Convert _CFTypeRefObj_Convert
44 extern PyObject
*_CFStringRefObj_New(CFStringRef
);
45 extern int _CFStringRefObj_Convert(PyObject
*, CFStringRef
*);
46 #define CFStringRefObj_New _CFStringRefObj_New
47 #define CFStringRefObj_Convert _CFStringRefObj_Convert
49 extern PyObject
*_CFMutableStringRefObj_New(CFMutableStringRef
);
50 extern int _CFMutableStringRefObj_Convert(PyObject
*, CFMutableStringRef
*);
51 #define CFMutableStringRefObj_New _CFMutableStringRefObj_New
52 #define CFMutableStringRefObj_Convert _CFMutableStringRefObj_Convert
54 extern PyObject
*_CFArrayRefObj_New(CFArrayRef
);
55 extern int _CFArrayRefObj_Convert(PyObject
*, CFArrayRef
*);
56 #define CFArrayRefObj_New _CFArrayRefObj_New
57 #define CFArrayRefObj_Convert _CFArrayRefObj_Convert
59 extern PyObject
*_CFMutableArrayRefObj_New(CFMutableArrayRef
);
60 extern int _CFMutableArrayRefObj_Convert(PyObject
*, CFMutableArrayRef
*);
61 #define CFMutableArrayRefObj_New _CFMutableArrayRefObj_New
62 #define CFMutableArrayRefObj_Convert _CFMutableArrayRefObj_Convert
64 extern PyObject
*_CFDataRefObj_New(CFDataRef
);
65 extern int _CFDataRefObj_Convert(PyObject
*, CFDataRef
*);
66 #define CFDataRefObj_New _CFDataRefObj_New
67 #define CFDataRefObj_Convert _CFDataRefObj_Convert
69 extern PyObject
*_CFMutableDataRefObj_New(CFMutableDataRef
);
70 extern int _CFMutableDataRefObj_Convert(PyObject
*, CFMutableDataRef
*);
71 #define CFMutableDataRefObj_New _CFMutableDataRefObj_New
72 #define CFMutableDataRefObj_Convert _CFMutableDataRefObj_Convert
74 extern PyObject
*_CFDictionaryRefObj_New(CFDictionaryRef
);
75 extern int _CFDictionaryRefObj_Convert(PyObject
*, CFDictionaryRef
*);
76 #define CFDictionaryRefObj_New _CFDictionaryRefObj_New
77 #define CFDictionaryRefObj_Convert _CFDictionaryRefObj_Convert
79 extern PyObject
*_CFMutableDictionaryRefObj_New(CFMutableDictionaryRef
);
80 extern int _CFMutableDictionaryRefObj_Convert(PyObject
*, CFMutableDictionaryRef
*);
81 #define CFMutableDictionaryRefObj_New _CFMutableDictionaryRefObj_New
82 #define CFMutableDictionaryRefObj_Convert _CFMutableDictionaryRefObj_Convert
84 extern PyObject
*_CFURLRefObj_New(CFURLRef
);
85 extern int _CFURLRefObj_Convert(PyObject
*, CFURLRef
*);
86 extern int _OptionalCFURLRefObj_Convert(PyObject
*, CFURLRef
*);
87 #define CFURLRefObj_New _CFURLRefObj_New
88 #define CFURLRefObj_Convert _CFURLRefObj_Convert
89 #define OptionalCFURLRefObj_Convert _OptionalCFURLRefObj_Convert
93 ** Parse/generate CFRange records
95 PyObject
*CFRange_New(CFRange
*itself
)
98 return Py_BuildValue("ll", (long)itself
->location
, (long)itself
->length
);
102 CFRange_Convert(PyObject
*v
, CFRange
*p_itself
)
104 long location
, length
;
106 if( !PyArg_ParseTuple(v
, "ll", &location
, &length
) )
108 p_itself
->location
= (CFIndex
)location
;
109 p_itself
->length
= (CFIndex
)length
;
113 /* Optional CFURL argument or None (passed as NULL) */
115 OptionalCFURLRefObj_Convert(PyObject
*v
, CFURLRef
*p_itself
)
117 if ( v
== Py_None
) {
121 return CFURLRefObj_Convert(v
, p_itself
);
125 static PyObject
*CF_Error
;
127 /* --------------------- Object type CFTypeRef ---------------------- */
129 PyTypeObject CFTypeRef_Type
;
131 #define CFTypeRefObj_Check(x) ((x)->ob_type == &CFTypeRef_Type)
133 typedef struct CFTypeRefObject
{
136 void (*ob_freeit
)(CFTypeRef ptr
);
139 PyObject
*CFTypeRefObj_New(CFTypeRef itself
)
144 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
147 it
= PyObject_NEW(CFTypeRefObject
, &CFTypeRef_Type
);
148 if (it
== NULL
) return NULL
;
149 it
->ob_itself
= itself
;
150 it
->ob_freeit
= CFRelease
;
151 return (PyObject
*)it
;
153 int CFTypeRefObj_Convert(PyObject
*v
, CFTypeRef
*p_itself
)
156 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
157 /* Check for other CF objects here */
159 if (!CFTypeRefObj_Check(v
))
161 PyErr_SetString(PyExc_TypeError
, "CFTypeRef required");
164 *p_itself
= ((CFTypeRefObject
*)v
)->ob_itself
;
168 static void CFTypeRefObj_dealloc(CFTypeRefObject
*self
)
170 if (self
->ob_freeit
&& self
->ob_itself
)
172 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
177 static PyObject
*CFTypeRefObj_CFGetTypeID(CFTypeRefObject
*_self
, PyObject
*_args
)
179 PyObject
*_res
= NULL
;
182 PyMac_PRECHECK(CFGetTypeID
);
184 if (!PyArg_ParseTuple(_args
, ""))
186 _rv
= CFGetTypeID(_self
->ob_itself
);
187 _res
= Py_BuildValue("l",
192 static PyObject
*CFTypeRefObj_CFRetain(CFTypeRefObject
*_self
, PyObject
*_args
)
194 PyObject
*_res
= NULL
;
197 PyMac_PRECHECK(CFRetain
);
199 if (!PyArg_ParseTuple(_args
, ""))
201 _rv
= CFRetain(_self
->ob_itself
);
202 _res
= Py_BuildValue("O&",
203 CFTypeRefObj_New
, _rv
);
207 static PyObject
*CFTypeRefObj_CFRelease(CFTypeRefObject
*_self
, PyObject
*_args
)
209 PyObject
*_res
= NULL
;
211 PyMac_PRECHECK(CFRelease
);
213 if (!PyArg_ParseTuple(_args
, ""))
215 CFRelease(_self
->ob_itself
);
221 static PyObject
*CFTypeRefObj_CFGetRetainCount(CFTypeRefObject
*_self
, PyObject
*_args
)
223 PyObject
*_res
= NULL
;
225 #ifndef CFGetRetainCount
226 PyMac_PRECHECK(CFGetRetainCount
);
228 if (!PyArg_ParseTuple(_args
, ""))
230 _rv
= CFGetRetainCount(_self
->ob_itself
);
231 _res
= Py_BuildValue("l",
236 static PyObject
*CFTypeRefObj_CFEqual(CFTypeRefObject
*_self
, PyObject
*_args
)
238 PyObject
*_res
= NULL
;
242 PyMac_PRECHECK(CFEqual
);
244 if (!PyArg_ParseTuple(_args
, "O&",
245 CFTypeRefObj_Convert
, &cf2
))
247 _rv
= CFEqual(_self
->ob_itself
,
249 _res
= Py_BuildValue("l",
254 static PyObject
*CFTypeRefObj_CFHash(CFTypeRefObject
*_self
, PyObject
*_args
)
256 PyObject
*_res
= NULL
;
259 PyMac_PRECHECK(CFHash
);
261 if (!PyArg_ParseTuple(_args
, ""))
263 _rv
= CFHash(_self
->ob_itself
);
264 _res
= Py_BuildValue("l",
269 static PyObject
*CFTypeRefObj_CFCopyDescription(CFTypeRefObject
*_self
, PyObject
*_args
)
271 PyObject
*_res
= NULL
;
273 #ifndef CFCopyDescription
274 PyMac_PRECHECK(CFCopyDescription
);
276 if (!PyArg_ParseTuple(_args
, ""))
278 _rv
= CFCopyDescription(_self
->ob_itself
);
279 _res
= Py_BuildValue("O&",
280 CFStringRefObj_New
, _rv
);
284 static PyObject
*CFTypeRefObj_CFPropertyListCreateXMLData(CFTypeRefObject
*_self
, PyObject
*_args
)
286 PyObject
*_res
= NULL
;
288 if (!PyArg_ParseTuple(_args
, ""))
290 _rv
= CFPropertyListCreateXMLData((CFAllocatorRef
)NULL
,
292 _res
= Py_BuildValue("O&",
293 CFDataRefObj_New
, _rv
);
297 static PyObject
*CFTypeRefObj_CFPropertyListCreateDeepCopy(CFTypeRefObject
*_self
, PyObject
*_args
)
299 PyObject
*_res
= NULL
;
301 CFOptionFlags mutabilityOption
;
302 if (!PyArg_ParseTuple(_args
, "l",
305 _rv
= CFPropertyListCreateDeepCopy((CFAllocatorRef
)NULL
,
308 _res
= Py_BuildValue("O&",
309 CFTypeRefObj_New
, _rv
);
313 static PyObject
*CFTypeRefObj_CFShow(CFTypeRefObject
*_self
, PyObject
*_args
)
315 PyObject
*_res
= NULL
;
317 PyMac_PRECHECK(CFShow
);
319 if (!PyArg_ParseTuple(_args
, ""))
321 CFShow(_self
->ob_itself
);
327 static PyObject
*CFTypeRefObj_CFPropertyListCreateFromXMLData(CFTypeRefObject
*_self
, PyObject
*_args
)
329 PyObject
*_res
= NULL
;
332 CFOptionFlags mutabilityOption
;
333 CFStringRef errorString
;
334 if (!PyArg_ParseTuple(_args
, "l",
337 _rv
= CFPropertyListCreateFromXMLData((CFAllocatorRef
)NULL
,
342 CFRelease(errorString
);
344 PyErr_SetString(PyExc_RuntimeError
, "Parse error in XML data");
347 _res
= Py_BuildValue("O&",
348 CFTypeRefObj_New
, _rv
);
353 static PyObject
*CFTypeRefObj_toPython(CFTypeRefObject
*_self
, PyObject
*_args
)
355 PyObject
*_res
= NULL
;
357 return PyCF_CF2Python(_self
->ob_itself
);
361 static PyMethodDef CFTypeRefObj_methods
[] = {
362 {"CFGetTypeID", (PyCFunction
)CFTypeRefObj_CFGetTypeID
, 1,
363 "() -> (CFTypeID _rv)"},
364 {"CFRetain", (PyCFunction
)CFTypeRefObj_CFRetain
, 1,
365 "() -> (CFTypeRef _rv)"},
366 {"CFRelease", (PyCFunction
)CFTypeRefObj_CFRelease
, 1,
368 {"CFGetRetainCount", (PyCFunction
)CFTypeRefObj_CFGetRetainCount
, 1,
369 "() -> (CFIndex _rv)"},
370 {"CFEqual", (PyCFunction
)CFTypeRefObj_CFEqual
, 1,
371 "(CFTypeRef cf2) -> (Boolean _rv)"},
372 {"CFHash", (PyCFunction
)CFTypeRefObj_CFHash
, 1,
373 "() -> (CFHashCode _rv)"},
374 {"CFCopyDescription", (PyCFunction
)CFTypeRefObj_CFCopyDescription
, 1,
375 "() -> (CFStringRef _rv)"},
376 {"CFPropertyListCreateXMLData", (PyCFunction
)CFTypeRefObj_CFPropertyListCreateXMLData
, 1,
377 "() -> (CFDataRef _rv)"},
378 {"CFPropertyListCreateDeepCopy", (PyCFunction
)CFTypeRefObj_CFPropertyListCreateDeepCopy
, 1,
379 "(CFOptionFlags mutabilityOption) -> (CFTypeRef _rv)"},
380 {"CFShow", (PyCFunction
)CFTypeRefObj_CFShow
, 1,
382 {"CFPropertyListCreateFromXMLData", (PyCFunction
)CFTypeRefObj_CFPropertyListCreateFromXMLData
, 1,
383 "(CFOptionFlags mutabilityOption) -> (CFTypeRefObj)"},
384 {"toPython", (PyCFunction
)CFTypeRefObj_toPython
, 1,
385 "() -> (python_object)"},
389 PyMethodChain CFTypeRefObj_chain
= { CFTypeRefObj_methods
, NULL
};
391 static PyObject
*CFTypeRefObj_getattr(CFTypeRefObject
*self
, char *name
)
393 return Py_FindMethodInChain(&CFTypeRefObj_chain
, (PyObject
*)self
, name
);
396 #define CFTypeRefObj_setattr NULL
398 static int CFTypeRefObj_compare(CFTypeRefObject
*self
, CFTypeRefObject
*other
)
400 /* XXXX Or should we use CFEqual?? */
401 if ( self
->ob_itself
> other
->ob_itself
) return 1;
402 if ( self
->ob_itself
< other
->ob_itself
) return -1;
406 static PyObject
* CFTypeRefObj_repr(CFTypeRefObject
*self
)
409 sprintf(buf
, "<CFTypeRef type-%d object at 0x%8.8x for 0x%8.8x>", CFGetTypeID(self
->ob_itself
), (unsigned)self
, (unsigned)self
->ob_itself
);
410 return PyString_FromString(buf
);
413 static int CFTypeRefObj_hash(CFTypeRefObject
*self
)
415 /* XXXX Or should we use CFHash?? */
416 return (int)self
->ob_itself
;
419 PyTypeObject CFTypeRef_Type
= {
420 PyObject_HEAD_INIT(NULL
)
422 "_CF.CFTypeRef", /*tp_name*/
423 sizeof(CFTypeRefObject
), /*tp_basicsize*/
426 (destructor
) CFTypeRefObj_dealloc
, /*tp_dealloc*/
428 (getattrfunc
) CFTypeRefObj_getattr
, /*tp_getattr*/
429 (setattrfunc
) CFTypeRefObj_setattr
, /*tp_setattr*/
430 (cmpfunc
) CFTypeRefObj_compare
, /*tp_compare*/
431 (reprfunc
) CFTypeRefObj_repr
, /*tp_repr*/
432 (PyNumberMethods
*)0, /* tp_as_number */
433 (PySequenceMethods
*)0, /* tp_as_sequence */
434 (PyMappingMethods
*)0, /* tp_as_mapping */
435 (hashfunc
) CFTypeRefObj_hash
, /*tp_hash*/
438 /* ------------------- End object type CFTypeRef -------------------- */
441 /* --------------------- Object type CFArrayRef --------------------- */
443 PyTypeObject CFArrayRef_Type
;
445 #define CFArrayRefObj_Check(x) ((x)->ob_type == &CFArrayRef_Type)
447 typedef struct CFArrayRefObject
{
449 CFArrayRef ob_itself
;
450 void (*ob_freeit
)(CFTypeRef ptr
);
453 PyObject
*CFArrayRefObj_New(CFArrayRef itself
)
455 CFArrayRefObject
*it
;
458 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
461 it
= PyObject_NEW(CFArrayRefObject
, &CFArrayRef_Type
);
462 if (it
== NULL
) return NULL
;
463 it
->ob_itself
= itself
;
464 it
->ob_freeit
= CFRelease
;
465 return (PyObject
*)it
;
467 int CFArrayRefObj_Convert(PyObject
*v
, CFArrayRef
*p_itself
)
470 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
471 /* Check for other CF objects here */
473 if (!CFArrayRefObj_Check(v
))
475 PyErr_SetString(PyExc_TypeError
, "CFArrayRef required");
478 *p_itself
= ((CFArrayRefObject
*)v
)->ob_itself
;
482 static void CFArrayRefObj_dealloc(CFArrayRefObject
*self
)
484 if (self
->ob_freeit
&& self
->ob_itself
)
486 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
491 static PyObject
*CFArrayRefObj_CFArrayCreateCopy(CFArrayRefObject
*_self
, PyObject
*_args
)
493 PyObject
*_res
= NULL
;
495 if (!PyArg_ParseTuple(_args
, ""))
497 _rv
= CFArrayCreateCopy((CFAllocatorRef
)NULL
,
499 _res
= Py_BuildValue("O&",
500 CFArrayRefObj_New
, _rv
);
504 static PyObject
*CFArrayRefObj_CFArrayGetCount(CFArrayRefObject
*_self
, PyObject
*_args
)
506 PyObject
*_res
= NULL
;
508 #ifndef CFArrayGetCount
509 PyMac_PRECHECK(CFArrayGetCount
);
511 if (!PyArg_ParseTuple(_args
, ""))
513 _rv
= CFArrayGetCount(_self
->ob_itself
);
514 _res
= Py_BuildValue("l",
519 static PyObject
*CFArrayRefObj_CFStringCreateByCombiningStrings(CFArrayRefObject
*_self
, PyObject
*_args
)
521 PyObject
*_res
= NULL
;
523 CFStringRef separatorString
;
524 if (!PyArg_ParseTuple(_args
, "O&",
525 CFStringRefObj_Convert
, &separatorString
))
527 _rv
= CFStringCreateByCombiningStrings((CFAllocatorRef
)NULL
,
530 _res
= Py_BuildValue("O&",
531 CFStringRefObj_New
, _rv
);
535 static PyMethodDef CFArrayRefObj_methods
[] = {
536 {"CFArrayCreateCopy", (PyCFunction
)CFArrayRefObj_CFArrayCreateCopy
, 1,
537 "() -> (CFArrayRef _rv)"},
538 {"CFArrayGetCount", (PyCFunction
)CFArrayRefObj_CFArrayGetCount
, 1,
539 "() -> (CFIndex _rv)"},
540 {"CFStringCreateByCombiningStrings", (PyCFunction
)CFArrayRefObj_CFStringCreateByCombiningStrings
, 1,
541 "(CFStringRef separatorString) -> (CFStringRef _rv)"},
545 PyMethodChain CFArrayRefObj_chain
= { CFArrayRefObj_methods
, &CFTypeRefObj_chain
};
547 static PyObject
*CFArrayRefObj_getattr(CFArrayRefObject
*self
, char *name
)
549 return Py_FindMethodInChain(&CFArrayRefObj_chain
, (PyObject
*)self
, name
);
552 #define CFArrayRefObj_setattr NULL
554 static int CFArrayRefObj_compare(CFArrayRefObject
*self
, CFArrayRefObject
*other
)
556 /* XXXX Or should we use CFEqual?? */
557 if ( self
->ob_itself
> other
->ob_itself
) return 1;
558 if ( self
->ob_itself
< other
->ob_itself
) return -1;
562 static PyObject
* CFArrayRefObj_repr(CFArrayRefObject
*self
)
565 sprintf(buf
, "<CFArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
566 return PyString_FromString(buf
);
569 static int CFArrayRefObj_hash(CFArrayRefObject
*self
)
571 /* XXXX Or should we use CFHash?? */
572 return (int)self
->ob_itself
;
575 PyTypeObject CFArrayRef_Type
= {
576 PyObject_HEAD_INIT(NULL
)
578 "_CF.CFArrayRef", /*tp_name*/
579 sizeof(CFArrayRefObject
), /*tp_basicsize*/
582 (destructor
) CFArrayRefObj_dealloc
, /*tp_dealloc*/
584 (getattrfunc
) CFArrayRefObj_getattr
, /*tp_getattr*/
585 (setattrfunc
) CFArrayRefObj_setattr
, /*tp_setattr*/
586 (cmpfunc
) CFArrayRefObj_compare
, /*tp_compare*/
587 (reprfunc
) CFArrayRefObj_repr
, /*tp_repr*/
588 (PyNumberMethods
*)0, /* tp_as_number */
589 (PySequenceMethods
*)0, /* tp_as_sequence */
590 (PyMappingMethods
*)0, /* tp_as_mapping */
591 (hashfunc
) CFArrayRefObj_hash
, /*tp_hash*/
594 /* ------------------- End object type CFArrayRef ------------------- */
597 /* ----------------- Object type CFMutableArrayRef ------------------ */
599 PyTypeObject CFMutableArrayRef_Type
;
601 #define CFMutableArrayRefObj_Check(x) ((x)->ob_type == &CFMutableArrayRef_Type)
603 typedef struct CFMutableArrayRefObject
{
605 CFMutableArrayRef ob_itself
;
606 void (*ob_freeit
)(CFTypeRef ptr
);
607 } CFMutableArrayRefObject
;
609 PyObject
*CFMutableArrayRefObj_New(CFMutableArrayRef itself
)
611 CFMutableArrayRefObject
*it
;
614 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
617 it
= PyObject_NEW(CFMutableArrayRefObject
, &CFMutableArrayRef_Type
);
618 if (it
== NULL
) return NULL
;
619 it
->ob_itself
= itself
;
620 it
->ob_freeit
= CFRelease
;
621 return (PyObject
*)it
;
623 int CFMutableArrayRefObj_Convert(PyObject
*v
, CFMutableArrayRef
*p_itself
)
626 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
627 /* Check for other CF objects here */
629 if (!CFMutableArrayRefObj_Check(v
))
631 PyErr_SetString(PyExc_TypeError
, "CFMutableArrayRef required");
634 *p_itself
= ((CFMutableArrayRefObject
*)v
)->ob_itself
;
638 static void CFMutableArrayRefObj_dealloc(CFMutableArrayRefObject
*self
)
640 if (self
->ob_freeit
&& self
->ob_itself
)
642 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
647 static PyObject
*CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
649 PyObject
*_res
= NULL
;
651 #ifndef CFArrayRemoveValueAtIndex
652 PyMac_PRECHECK(CFArrayRemoveValueAtIndex
);
654 if (!PyArg_ParseTuple(_args
, "l",
657 CFArrayRemoveValueAtIndex(_self
->ob_itself
,
664 static PyObject
*CFMutableArrayRefObj_CFArrayRemoveAllValues(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
666 PyObject
*_res
= NULL
;
667 #ifndef CFArrayRemoveAllValues
668 PyMac_PRECHECK(CFArrayRemoveAllValues
);
670 if (!PyArg_ParseTuple(_args
, ""))
672 CFArrayRemoveAllValues(_self
->ob_itself
);
678 static PyObject
*CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
680 PyObject
*_res
= NULL
;
683 #ifndef CFArrayExchangeValuesAtIndices
684 PyMac_PRECHECK(CFArrayExchangeValuesAtIndices
);
686 if (!PyArg_ParseTuple(_args
, "ll",
690 CFArrayExchangeValuesAtIndices(_self
->ob_itself
,
698 static PyObject
*CFMutableArrayRefObj_CFArrayAppendArray(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
700 PyObject
*_res
= NULL
;
701 CFArrayRef otherArray
;
703 #ifndef CFArrayAppendArray
704 PyMac_PRECHECK(CFArrayAppendArray
);
706 if (!PyArg_ParseTuple(_args
, "O&O&",
707 CFArrayRefObj_Convert
, &otherArray
,
708 CFRange_Convert
, &otherRange
))
710 CFArrayAppendArray(_self
->ob_itself
,
718 static PyMethodDef CFMutableArrayRefObj_methods
[] = {
719 {"CFArrayRemoveValueAtIndex", (PyCFunction
)CFMutableArrayRefObj_CFArrayRemoveValueAtIndex
, 1,
720 "(CFIndex idx) -> None"},
721 {"CFArrayRemoveAllValues", (PyCFunction
)CFMutableArrayRefObj_CFArrayRemoveAllValues
, 1,
723 {"CFArrayExchangeValuesAtIndices", (PyCFunction
)CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices
, 1,
724 "(CFIndex idx1, CFIndex idx2) -> None"},
725 {"CFArrayAppendArray", (PyCFunction
)CFMutableArrayRefObj_CFArrayAppendArray
, 1,
726 "(CFArrayRef otherArray, CFRange otherRange) -> None"},
730 PyMethodChain CFMutableArrayRefObj_chain
= { CFMutableArrayRefObj_methods
, &CFArrayRefObj_chain
};
732 static PyObject
*CFMutableArrayRefObj_getattr(CFMutableArrayRefObject
*self
, char *name
)
734 return Py_FindMethodInChain(&CFMutableArrayRefObj_chain
, (PyObject
*)self
, name
);
737 #define CFMutableArrayRefObj_setattr NULL
739 static int CFMutableArrayRefObj_compare(CFMutableArrayRefObject
*self
, CFMutableArrayRefObject
*other
)
741 /* XXXX Or should we use CFEqual?? */
742 if ( self
->ob_itself
> other
->ob_itself
) return 1;
743 if ( self
->ob_itself
< other
->ob_itself
) return -1;
747 static PyObject
* CFMutableArrayRefObj_repr(CFMutableArrayRefObject
*self
)
750 sprintf(buf
, "<CFMutableArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
751 return PyString_FromString(buf
);
754 static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject
*self
)
756 /* XXXX Or should we use CFHash?? */
757 return (int)self
->ob_itself
;
760 PyTypeObject CFMutableArrayRef_Type
= {
761 PyObject_HEAD_INIT(NULL
)
763 "_CF.CFMutableArrayRef", /*tp_name*/
764 sizeof(CFMutableArrayRefObject
), /*tp_basicsize*/
767 (destructor
) CFMutableArrayRefObj_dealloc
, /*tp_dealloc*/
769 (getattrfunc
) CFMutableArrayRefObj_getattr
, /*tp_getattr*/
770 (setattrfunc
) CFMutableArrayRefObj_setattr
, /*tp_setattr*/
771 (cmpfunc
) CFMutableArrayRefObj_compare
, /*tp_compare*/
772 (reprfunc
) CFMutableArrayRefObj_repr
, /*tp_repr*/
773 (PyNumberMethods
*)0, /* tp_as_number */
774 (PySequenceMethods
*)0, /* tp_as_sequence */
775 (PyMappingMethods
*)0, /* tp_as_mapping */
776 (hashfunc
) CFMutableArrayRefObj_hash
, /*tp_hash*/
779 /* --------------- End object type CFMutableArrayRef ---------------- */
782 /* ------------------ Object type CFDictionaryRef ------------------- */
784 PyTypeObject CFDictionaryRef_Type
;
786 #define CFDictionaryRefObj_Check(x) ((x)->ob_type == &CFDictionaryRef_Type)
788 typedef struct CFDictionaryRefObject
{
790 CFDictionaryRef ob_itself
;
791 void (*ob_freeit
)(CFTypeRef ptr
);
792 } CFDictionaryRefObject
;
794 PyObject
*CFDictionaryRefObj_New(CFDictionaryRef itself
)
796 CFDictionaryRefObject
*it
;
799 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
802 it
= PyObject_NEW(CFDictionaryRefObject
, &CFDictionaryRef_Type
);
803 if (it
== NULL
) return NULL
;
804 it
->ob_itself
= itself
;
805 it
->ob_freeit
= CFRelease
;
806 return (PyObject
*)it
;
808 int CFDictionaryRefObj_Convert(PyObject
*v
, CFDictionaryRef
*p_itself
)
811 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
812 /* Check for other CF objects here */
814 if (!CFDictionaryRefObj_Check(v
))
816 PyErr_SetString(PyExc_TypeError
, "CFDictionaryRef required");
819 *p_itself
= ((CFDictionaryRefObject
*)v
)->ob_itself
;
823 static void CFDictionaryRefObj_dealloc(CFDictionaryRefObject
*self
)
825 if (self
->ob_freeit
&& self
->ob_itself
)
827 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
832 static PyObject
*CFDictionaryRefObj_CFDictionaryCreateCopy(CFDictionaryRefObject
*_self
, PyObject
*_args
)
834 PyObject
*_res
= NULL
;
836 if (!PyArg_ParseTuple(_args
, ""))
838 _rv
= CFDictionaryCreateCopy((CFAllocatorRef
)NULL
,
840 _res
= Py_BuildValue("O&",
841 CFDictionaryRefObj_New
, _rv
);
845 static PyObject
*CFDictionaryRefObj_CFDictionaryGetCount(CFDictionaryRefObject
*_self
, PyObject
*_args
)
847 PyObject
*_res
= NULL
;
849 #ifndef CFDictionaryGetCount
850 PyMac_PRECHECK(CFDictionaryGetCount
);
852 if (!PyArg_ParseTuple(_args
, ""))
854 _rv
= CFDictionaryGetCount(_self
->ob_itself
);
855 _res
= Py_BuildValue("l",
860 static PyMethodDef CFDictionaryRefObj_methods
[] = {
861 {"CFDictionaryCreateCopy", (PyCFunction
)CFDictionaryRefObj_CFDictionaryCreateCopy
, 1,
862 "() -> (CFDictionaryRef _rv)"},
863 {"CFDictionaryGetCount", (PyCFunction
)CFDictionaryRefObj_CFDictionaryGetCount
, 1,
864 "() -> (CFIndex _rv)"},
868 PyMethodChain CFDictionaryRefObj_chain
= { CFDictionaryRefObj_methods
, &CFTypeRefObj_chain
};
870 static PyObject
*CFDictionaryRefObj_getattr(CFDictionaryRefObject
*self
, char *name
)
872 return Py_FindMethodInChain(&CFDictionaryRefObj_chain
, (PyObject
*)self
, name
);
875 #define CFDictionaryRefObj_setattr NULL
877 static int CFDictionaryRefObj_compare(CFDictionaryRefObject
*self
, CFDictionaryRefObject
*other
)
879 /* XXXX Or should we use CFEqual?? */
880 if ( self
->ob_itself
> other
->ob_itself
) return 1;
881 if ( self
->ob_itself
< other
->ob_itself
) return -1;
885 static PyObject
* CFDictionaryRefObj_repr(CFDictionaryRefObject
*self
)
888 sprintf(buf
, "<CFDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
889 return PyString_FromString(buf
);
892 static int CFDictionaryRefObj_hash(CFDictionaryRefObject
*self
)
894 /* XXXX Or should we use CFHash?? */
895 return (int)self
->ob_itself
;
898 PyTypeObject CFDictionaryRef_Type
= {
899 PyObject_HEAD_INIT(NULL
)
901 "_CF.CFDictionaryRef", /*tp_name*/
902 sizeof(CFDictionaryRefObject
), /*tp_basicsize*/
905 (destructor
) CFDictionaryRefObj_dealloc
, /*tp_dealloc*/
907 (getattrfunc
) CFDictionaryRefObj_getattr
, /*tp_getattr*/
908 (setattrfunc
) CFDictionaryRefObj_setattr
, /*tp_setattr*/
909 (cmpfunc
) CFDictionaryRefObj_compare
, /*tp_compare*/
910 (reprfunc
) CFDictionaryRefObj_repr
, /*tp_repr*/
911 (PyNumberMethods
*)0, /* tp_as_number */
912 (PySequenceMethods
*)0, /* tp_as_sequence */
913 (PyMappingMethods
*)0, /* tp_as_mapping */
914 (hashfunc
) CFDictionaryRefObj_hash
, /*tp_hash*/
917 /* ---------------- End object type CFDictionaryRef ----------------- */
920 /* --------------- Object type CFMutableDictionaryRef --------------- */
922 PyTypeObject CFMutableDictionaryRef_Type
;
924 #define CFMutableDictionaryRefObj_Check(x) ((x)->ob_type == &CFMutableDictionaryRef_Type)
926 typedef struct CFMutableDictionaryRefObject
{
928 CFMutableDictionaryRef ob_itself
;
929 void (*ob_freeit
)(CFTypeRef ptr
);
930 } CFMutableDictionaryRefObject
;
932 PyObject
*CFMutableDictionaryRefObj_New(CFMutableDictionaryRef itself
)
934 CFMutableDictionaryRefObject
*it
;
937 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
940 it
= PyObject_NEW(CFMutableDictionaryRefObject
, &CFMutableDictionaryRef_Type
);
941 if (it
== NULL
) return NULL
;
942 it
->ob_itself
= itself
;
943 it
->ob_freeit
= CFRelease
;
944 return (PyObject
*)it
;
946 int CFMutableDictionaryRefObj_Convert(PyObject
*v
, CFMutableDictionaryRef
*p_itself
)
949 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
950 /* Check for other CF objects here */
952 if (!CFMutableDictionaryRefObj_Check(v
))
954 PyErr_SetString(PyExc_TypeError
, "CFMutableDictionaryRef required");
957 *p_itself
= ((CFMutableDictionaryRefObject
*)v
)->ob_itself
;
961 static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject
*self
)
963 if (self
->ob_freeit
&& self
->ob_itself
)
965 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
970 static PyObject
*CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject
*_self
, PyObject
*_args
)
972 PyObject
*_res
= NULL
;
973 #ifndef CFDictionaryRemoveAllValues
974 PyMac_PRECHECK(CFDictionaryRemoveAllValues
);
976 if (!PyArg_ParseTuple(_args
, ""))
978 CFDictionaryRemoveAllValues(_self
->ob_itself
);
984 static PyMethodDef CFMutableDictionaryRefObj_methods
[] = {
985 {"CFDictionaryRemoveAllValues", (PyCFunction
)CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues
, 1,
990 PyMethodChain CFMutableDictionaryRefObj_chain
= { CFMutableDictionaryRefObj_methods
, &CFDictionaryRefObj_chain
};
992 static PyObject
*CFMutableDictionaryRefObj_getattr(CFMutableDictionaryRefObject
*self
, char *name
)
994 return Py_FindMethodInChain(&CFMutableDictionaryRefObj_chain
, (PyObject
*)self
, name
);
997 #define CFMutableDictionaryRefObj_setattr NULL
999 static int CFMutableDictionaryRefObj_compare(CFMutableDictionaryRefObject
*self
, CFMutableDictionaryRefObject
*other
)
1001 /* XXXX Or should we use CFEqual?? */
1002 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1003 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1007 static PyObject
* CFMutableDictionaryRefObj_repr(CFMutableDictionaryRefObject
*self
)
1010 sprintf(buf
, "<CFMutableDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
1011 return PyString_FromString(buf
);
1014 static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject
*self
)
1016 /* XXXX Or should we use CFHash?? */
1017 return (int)self
->ob_itself
;
1020 PyTypeObject CFMutableDictionaryRef_Type
= {
1021 PyObject_HEAD_INIT(NULL
)
1023 "_CF.CFMutableDictionaryRef", /*tp_name*/
1024 sizeof(CFMutableDictionaryRefObject
), /*tp_basicsize*/
1027 (destructor
) CFMutableDictionaryRefObj_dealloc
, /*tp_dealloc*/
1029 (getattrfunc
) CFMutableDictionaryRefObj_getattr
, /*tp_getattr*/
1030 (setattrfunc
) CFMutableDictionaryRefObj_setattr
, /*tp_setattr*/
1031 (cmpfunc
) CFMutableDictionaryRefObj_compare
, /*tp_compare*/
1032 (reprfunc
) CFMutableDictionaryRefObj_repr
, /*tp_repr*/
1033 (PyNumberMethods
*)0, /* tp_as_number */
1034 (PySequenceMethods
*)0, /* tp_as_sequence */
1035 (PyMappingMethods
*)0, /* tp_as_mapping */
1036 (hashfunc
) CFMutableDictionaryRefObj_hash
, /*tp_hash*/
1039 /* ------------- End object type CFMutableDictionaryRef ------------- */
1042 /* --------------------- Object type CFDataRef ---------------------- */
1044 PyTypeObject CFDataRef_Type
;
1046 #define CFDataRefObj_Check(x) ((x)->ob_type == &CFDataRef_Type)
1048 typedef struct CFDataRefObject
{
1050 CFDataRef ob_itself
;
1051 void (*ob_freeit
)(CFTypeRef ptr
);
1054 PyObject
*CFDataRefObj_New(CFDataRef itself
)
1056 CFDataRefObject
*it
;
1059 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
1062 it
= PyObject_NEW(CFDataRefObject
, &CFDataRef_Type
);
1063 if (it
== NULL
) return NULL
;
1064 it
->ob_itself
= itself
;
1065 it
->ob_freeit
= CFRelease
;
1066 return (PyObject
*)it
;
1068 int CFDataRefObj_Convert(PyObject
*v
, CFDataRef
*p_itself
)
1071 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1072 if (PyString_Check(v
)) {
1075 if( PyString_AsStringAndSize(v
, &cStr
, &cLen
) < 0 ) return 0;
1076 *p_itself
= CFDataCreate((CFAllocatorRef
)NULL
, (unsigned char *)cStr
, cLen
);
1080 if (!CFDataRefObj_Check(v
))
1082 PyErr_SetString(PyExc_TypeError
, "CFDataRef required");
1085 *p_itself
= ((CFDataRefObject
*)v
)->ob_itself
;
1089 static void CFDataRefObj_dealloc(CFDataRefObject
*self
)
1091 if (self
->ob_freeit
&& self
->ob_itself
)
1093 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1098 static PyObject
*CFDataRefObj_CFDataCreateCopy(CFDataRefObject
*_self
, PyObject
*_args
)
1100 PyObject
*_res
= NULL
;
1102 if (!PyArg_ParseTuple(_args
, ""))
1104 _rv
= CFDataCreateCopy((CFAllocatorRef
)NULL
,
1106 _res
= Py_BuildValue("O&",
1107 CFDataRefObj_New
, _rv
);
1111 static PyObject
*CFDataRefObj_CFDataGetLength(CFDataRefObject
*_self
, PyObject
*_args
)
1113 PyObject
*_res
= NULL
;
1115 #ifndef CFDataGetLength
1116 PyMac_PRECHECK(CFDataGetLength
);
1118 if (!PyArg_ParseTuple(_args
, ""))
1120 _rv
= CFDataGetLength(_self
->ob_itself
);
1121 _res
= Py_BuildValue("l",
1126 static PyObject
*CFDataRefObj_CFStringCreateFromExternalRepresentation(CFDataRefObject
*_self
, PyObject
*_args
)
1128 PyObject
*_res
= NULL
;
1130 CFStringEncoding encoding
;
1131 if (!PyArg_ParseTuple(_args
, "l",
1134 _rv
= CFStringCreateFromExternalRepresentation((CFAllocatorRef
)NULL
,
1137 _res
= Py_BuildValue("O&",
1138 CFStringRefObj_New
, _rv
);
1142 static PyObject
*CFDataRefObj_CFDataGetData(CFDataRefObject
*_self
, PyObject
*_args
)
1144 PyObject
*_res
= NULL
;
1146 int size
= CFDataGetLength(_self
->ob_itself
);
1147 char *data
= (char *)CFDataGetBytePtr(_self
->ob_itself
);
1149 _res
= (PyObject
*)PyString_FromStringAndSize(data
, size
);
1154 static PyMethodDef CFDataRefObj_methods
[] = {
1155 {"CFDataCreateCopy", (PyCFunction
)CFDataRefObj_CFDataCreateCopy
, 1,
1156 "() -> (CFDataRef _rv)"},
1157 {"CFDataGetLength", (PyCFunction
)CFDataRefObj_CFDataGetLength
, 1,
1158 "() -> (CFIndex _rv)"},
1159 {"CFStringCreateFromExternalRepresentation", (PyCFunction
)CFDataRefObj_CFStringCreateFromExternalRepresentation
, 1,
1160 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
1161 {"CFDataGetData", (PyCFunction
)CFDataRefObj_CFDataGetData
, 1,
1162 "() -> (string _rv)"},
1166 PyMethodChain CFDataRefObj_chain
= { CFDataRefObj_methods
, &CFTypeRefObj_chain
};
1168 static PyObject
*CFDataRefObj_getattr(CFDataRefObject
*self
, char *name
)
1170 return Py_FindMethodInChain(&CFDataRefObj_chain
, (PyObject
*)self
, name
);
1173 #define CFDataRefObj_setattr NULL
1175 static int CFDataRefObj_compare(CFDataRefObject
*self
, CFDataRefObject
*other
)
1177 /* XXXX Or should we use CFEqual?? */
1178 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1179 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1183 static PyObject
* CFDataRefObj_repr(CFDataRefObject
*self
)
1186 sprintf(buf
, "<CFDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
1187 return PyString_FromString(buf
);
1190 static int CFDataRefObj_hash(CFDataRefObject
*self
)
1192 /* XXXX Or should we use CFHash?? */
1193 return (int)self
->ob_itself
;
1196 PyTypeObject CFDataRef_Type
= {
1197 PyObject_HEAD_INIT(NULL
)
1199 "_CF.CFDataRef", /*tp_name*/
1200 sizeof(CFDataRefObject
), /*tp_basicsize*/
1203 (destructor
) CFDataRefObj_dealloc
, /*tp_dealloc*/
1205 (getattrfunc
) CFDataRefObj_getattr
, /*tp_getattr*/
1206 (setattrfunc
) CFDataRefObj_setattr
, /*tp_setattr*/
1207 (cmpfunc
) CFDataRefObj_compare
, /*tp_compare*/
1208 (reprfunc
) CFDataRefObj_repr
, /*tp_repr*/
1209 (PyNumberMethods
*)0, /* tp_as_number */
1210 (PySequenceMethods
*)0, /* tp_as_sequence */
1211 (PyMappingMethods
*)0, /* tp_as_mapping */
1212 (hashfunc
) CFDataRefObj_hash
, /*tp_hash*/
1215 /* ------------------- End object type CFDataRef -------------------- */
1218 /* ------------------ Object type CFMutableDataRef ------------------ */
1220 PyTypeObject CFMutableDataRef_Type
;
1222 #define CFMutableDataRefObj_Check(x) ((x)->ob_type == &CFMutableDataRef_Type)
1224 typedef struct CFMutableDataRefObject
{
1226 CFMutableDataRef ob_itself
;
1227 void (*ob_freeit
)(CFTypeRef ptr
);
1228 } CFMutableDataRefObject
;
1230 PyObject
*CFMutableDataRefObj_New(CFMutableDataRef itself
)
1232 CFMutableDataRefObject
*it
;
1235 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
1238 it
= PyObject_NEW(CFMutableDataRefObject
, &CFMutableDataRef_Type
);
1239 if (it
== NULL
) return NULL
;
1240 it
->ob_itself
= itself
;
1241 it
->ob_freeit
= CFRelease
;
1242 return (PyObject
*)it
;
1244 int CFMutableDataRefObj_Convert(PyObject
*v
, CFMutableDataRef
*p_itself
)
1247 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1248 /* Check for other CF objects here */
1250 if (!CFMutableDataRefObj_Check(v
))
1252 PyErr_SetString(PyExc_TypeError
, "CFMutableDataRef required");
1255 *p_itself
= ((CFMutableDataRefObject
*)v
)->ob_itself
;
1259 static void CFMutableDataRefObj_dealloc(CFMutableDataRefObject
*self
)
1261 if (self
->ob_freeit
&& self
->ob_itself
)
1263 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1268 static PyObject
*CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1270 PyObject
*_res
= NULL
;
1272 #ifndef CFDataSetLength
1273 PyMac_PRECHECK(CFDataSetLength
);
1275 if (!PyArg_ParseTuple(_args
, "l",
1278 CFDataSetLength(_self
->ob_itself
,
1285 static PyObject
*CFMutableDataRefObj_CFDataIncreaseLength(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1287 PyObject
*_res
= NULL
;
1288 CFIndex extraLength
;
1289 #ifndef CFDataIncreaseLength
1290 PyMac_PRECHECK(CFDataIncreaseLength
);
1292 if (!PyArg_ParseTuple(_args
, "l",
1295 CFDataIncreaseLength(_self
->ob_itself
,
1302 static PyObject
*CFMutableDataRefObj_CFDataAppendBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1304 PyObject
*_res
= NULL
;
1305 unsigned char *bytes__in__
;
1307 int bytes__in_len__
;
1308 #ifndef CFDataAppendBytes
1309 PyMac_PRECHECK(CFDataAppendBytes
);
1311 if (!PyArg_ParseTuple(_args
, "s#",
1312 &bytes__in__
, &bytes__in_len__
))
1314 bytes__len__
= bytes__in_len__
;
1315 CFDataAppendBytes(_self
->ob_itself
,
1316 bytes__in__
, bytes__len__
);
1322 static PyObject
*CFMutableDataRefObj_CFDataReplaceBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1324 PyObject
*_res
= NULL
;
1326 unsigned char *newBytes__in__
;
1327 long newBytes__len__
;
1328 int newBytes__in_len__
;
1329 #ifndef CFDataReplaceBytes
1330 PyMac_PRECHECK(CFDataReplaceBytes
);
1332 if (!PyArg_ParseTuple(_args
, "O&s#",
1333 CFRange_Convert
, &range
,
1334 &newBytes__in__
, &newBytes__in_len__
))
1336 newBytes__len__
= newBytes__in_len__
;
1337 CFDataReplaceBytes(_self
->ob_itself
,
1339 newBytes__in__
, newBytes__len__
);
1345 static PyObject
*CFMutableDataRefObj_CFDataDeleteBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1347 PyObject
*_res
= NULL
;
1349 #ifndef CFDataDeleteBytes
1350 PyMac_PRECHECK(CFDataDeleteBytes
);
1352 if (!PyArg_ParseTuple(_args
, "O&",
1353 CFRange_Convert
, &range
))
1355 CFDataDeleteBytes(_self
->ob_itself
,
1362 static PyMethodDef CFMutableDataRefObj_methods
[] = {
1363 {"CFDataSetLength", (PyCFunction
)CFMutableDataRefObj_CFDataSetLength
, 1,
1364 "(CFIndex length) -> None"},
1365 {"CFDataIncreaseLength", (PyCFunction
)CFMutableDataRefObj_CFDataIncreaseLength
, 1,
1366 "(CFIndex extraLength) -> None"},
1367 {"CFDataAppendBytes", (PyCFunction
)CFMutableDataRefObj_CFDataAppendBytes
, 1,
1368 "(Buffer bytes) -> None"},
1369 {"CFDataReplaceBytes", (PyCFunction
)CFMutableDataRefObj_CFDataReplaceBytes
, 1,
1370 "(CFRange range, Buffer newBytes) -> None"},
1371 {"CFDataDeleteBytes", (PyCFunction
)CFMutableDataRefObj_CFDataDeleteBytes
, 1,
1372 "(CFRange range) -> None"},
1376 PyMethodChain CFMutableDataRefObj_chain
= { CFMutableDataRefObj_methods
, &CFDataRefObj_chain
};
1378 static PyObject
*CFMutableDataRefObj_getattr(CFMutableDataRefObject
*self
, char *name
)
1380 return Py_FindMethodInChain(&CFMutableDataRefObj_chain
, (PyObject
*)self
, name
);
1383 #define CFMutableDataRefObj_setattr NULL
1385 static int CFMutableDataRefObj_compare(CFMutableDataRefObject
*self
, CFMutableDataRefObject
*other
)
1387 /* XXXX Or should we use CFEqual?? */
1388 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1389 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1393 static PyObject
* CFMutableDataRefObj_repr(CFMutableDataRefObject
*self
)
1396 sprintf(buf
, "<CFMutableDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
1397 return PyString_FromString(buf
);
1400 static int CFMutableDataRefObj_hash(CFMutableDataRefObject
*self
)
1402 /* XXXX Or should we use CFHash?? */
1403 return (int)self
->ob_itself
;
1406 PyTypeObject CFMutableDataRef_Type
= {
1407 PyObject_HEAD_INIT(NULL
)
1409 "_CF.CFMutableDataRef", /*tp_name*/
1410 sizeof(CFMutableDataRefObject
), /*tp_basicsize*/
1413 (destructor
) CFMutableDataRefObj_dealloc
, /*tp_dealloc*/
1415 (getattrfunc
) CFMutableDataRefObj_getattr
, /*tp_getattr*/
1416 (setattrfunc
) CFMutableDataRefObj_setattr
, /*tp_setattr*/
1417 (cmpfunc
) CFMutableDataRefObj_compare
, /*tp_compare*/
1418 (reprfunc
) CFMutableDataRefObj_repr
, /*tp_repr*/
1419 (PyNumberMethods
*)0, /* tp_as_number */
1420 (PySequenceMethods
*)0, /* tp_as_sequence */
1421 (PyMappingMethods
*)0, /* tp_as_mapping */
1422 (hashfunc
) CFMutableDataRefObj_hash
, /*tp_hash*/
1425 /* ---------------- End object type CFMutableDataRef ---------------- */
1428 /* -------------------- Object type CFStringRef --------------------- */
1430 PyTypeObject CFStringRef_Type
;
1432 #define CFStringRefObj_Check(x) ((x)->ob_type == &CFStringRef_Type)
1434 typedef struct CFStringRefObject
{
1436 CFStringRef ob_itself
;
1437 void (*ob_freeit
)(CFTypeRef ptr
);
1438 } CFStringRefObject
;
1440 PyObject
*CFStringRefObj_New(CFStringRef itself
)
1442 CFStringRefObject
*it
;
1445 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
1448 it
= PyObject_NEW(CFStringRefObject
, &CFStringRef_Type
);
1449 if (it
== NULL
) return NULL
;
1450 it
->ob_itself
= itself
;
1451 it
->ob_freeit
= CFRelease
;
1452 return (PyObject
*)it
;
1454 int CFStringRefObj_Convert(PyObject
*v
, CFStringRef
*p_itself
)
1457 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1458 if (PyString_Check(v
)) {
1459 char *cStr
= PyString_AsString(v
);
1460 *p_itself
= CFStringCreateWithCString((CFAllocatorRef
)NULL
, cStr
, 0);
1463 if (PyUnicode_Check(v
)) {
1464 /* We use the CF types here, if Python was configured differently that will give an error */
1465 CFIndex size
= PyUnicode_GetSize(v
);
1466 UniChar
*unichars
= PyUnicode_AsUnicode(v
);
1467 if (!unichars
) return 0;
1468 *p_itself
= CFStringCreateWithCharacters((CFAllocatorRef
)NULL
, unichars
, size
);
1473 if (!CFStringRefObj_Check(v
))
1475 PyErr_SetString(PyExc_TypeError
, "CFStringRef required");
1478 *p_itself
= ((CFStringRefObject
*)v
)->ob_itself
;
1482 static void CFStringRefObj_dealloc(CFStringRefObject
*self
)
1484 if (self
->ob_freeit
&& self
->ob_itself
)
1486 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1491 static PyObject
*CFStringRefObj_CFStringCreateWithSubstring(CFStringRefObject
*_self
, PyObject
*_args
)
1493 PyObject
*_res
= NULL
;
1496 if (!PyArg_ParseTuple(_args
, "O&",
1497 CFRange_Convert
, &range
))
1499 _rv
= CFStringCreateWithSubstring((CFAllocatorRef
)NULL
,
1502 _res
= Py_BuildValue("O&",
1503 CFStringRefObj_New
, _rv
);
1507 static PyObject
*CFStringRefObj_CFStringCreateCopy(CFStringRefObject
*_self
, PyObject
*_args
)
1509 PyObject
*_res
= NULL
;
1511 if (!PyArg_ParseTuple(_args
, ""))
1513 _rv
= CFStringCreateCopy((CFAllocatorRef
)NULL
,
1515 _res
= Py_BuildValue("O&",
1516 CFStringRefObj_New
, _rv
);
1520 static PyObject
*CFStringRefObj_CFStringGetLength(CFStringRefObject
*_self
, PyObject
*_args
)
1522 PyObject
*_res
= NULL
;
1524 #ifndef CFStringGetLength
1525 PyMac_PRECHECK(CFStringGetLength
);
1527 if (!PyArg_ParseTuple(_args
, ""))
1529 _rv
= CFStringGetLength(_self
->ob_itself
);
1530 _res
= Py_BuildValue("l",
1535 static PyObject
*CFStringRefObj_CFStringGetBytes(CFStringRefObject
*_self
, PyObject
*_args
)
1537 PyObject
*_res
= NULL
;
1540 CFStringEncoding encoding
;
1542 Boolean isExternalRepresentation
;
1546 #ifndef CFStringGetBytes
1547 PyMac_PRECHECK(CFStringGetBytes
);
1549 if (!PyArg_ParseTuple(_args
, "O&lbll",
1550 CFRange_Convert
, &range
,
1553 &isExternalRepresentation
,
1556 _rv
= CFStringGetBytes(_self
->ob_itself
,
1560 isExternalRepresentation
,
1564 _res
= Py_BuildValue("lbl",
1571 static PyObject
*CFStringRefObj_CFStringCreateExternalRepresentation(CFStringRefObject
*_self
, PyObject
*_args
)
1573 PyObject
*_res
= NULL
;
1575 CFStringEncoding encoding
;
1577 if (!PyArg_ParseTuple(_args
, "lb",
1581 _rv
= CFStringCreateExternalRepresentation((CFAllocatorRef
)NULL
,
1585 _res
= Py_BuildValue("O&",
1586 CFDataRefObj_New
, _rv
);
1590 static PyObject
*CFStringRefObj_CFStringGetSmallestEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
1592 PyObject
*_res
= NULL
;
1593 CFStringEncoding _rv
;
1594 #ifndef CFStringGetSmallestEncoding
1595 PyMac_PRECHECK(CFStringGetSmallestEncoding
);
1597 if (!PyArg_ParseTuple(_args
, ""))
1599 _rv
= CFStringGetSmallestEncoding(_self
->ob_itself
);
1600 _res
= Py_BuildValue("l",
1605 static PyObject
*CFStringRefObj_CFStringGetFastestEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
1607 PyObject
*_res
= NULL
;
1608 CFStringEncoding _rv
;
1609 #ifndef CFStringGetFastestEncoding
1610 PyMac_PRECHECK(CFStringGetFastestEncoding
);
1612 if (!PyArg_ParseTuple(_args
, ""))
1614 _rv
= CFStringGetFastestEncoding(_self
->ob_itself
);
1615 _res
= Py_BuildValue("l",
1620 static PyObject
*CFStringRefObj_CFStringCompareWithOptions(CFStringRefObject
*_self
, PyObject
*_args
)
1622 PyObject
*_res
= NULL
;
1623 CFComparisonResult _rv
;
1624 CFStringRef theString2
;
1625 CFRange rangeToCompare
;
1626 CFOptionFlags compareOptions
;
1627 #ifndef CFStringCompareWithOptions
1628 PyMac_PRECHECK(CFStringCompareWithOptions
);
1630 if (!PyArg_ParseTuple(_args
, "O&O&l",
1631 CFStringRefObj_Convert
, &theString2
,
1632 CFRange_Convert
, &rangeToCompare
,
1635 _rv
= CFStringCompareWithOptions(_self
->ob_itself
,
1639 _res
= Py_BuildValue("l",
1644 static PyObject
*CFStringRefObj_CFStringCompare(CFStringRefObject
*_self
, PyObject
*_args
)
1646 PyObject
*_res
= NULL
;
1647 CFComparisonResult _rv
;
1648 CFStringRef theString2
;
1649 CFOptionFlags compareOptions
;
1650 #ifndef CFStringCompare
1651 PyMac_PRECHECK(CFStringCompare
);
1653 if (!PyArg_ParseTuple(_args
, "O&l",
1654 CFStringRefObj_Convert
, &theString2
,
1657 _rv
= CFStringCompare(_self
->ob_itself
,
1660 _res
= Py_BuildValue("l",
1665 static PyObject
*CFStringRefObj_CFStringFindWithOptions(CFStringRefObject
*_self
, PyObject
*_args
)
1667 PyObject
*_res
= NULL
;
1669 CFStringRef stringToFind
;
1670 CFRange rangeToSearch
;
1671 CFOptionFlags searchOptions
;
1673 #ifndef CFStringFindWithOptions
1674 PyMac_PRECHECK(CFStringFindWithOptions
);
1676 if (!PyArg_ParseTuple(_args
, "O&O&l",
1677 CFStringRefObj_Convert
, &stringToFind
,
1678 CFRange_Convert
, &rangeToSearch
,
1681 _rv
= CFStringFindWithOptions(_self
->ob_itself
,
1686 _res
= Py_BuildValue("lO&",
1688 CFRange_New
, result
);
1692 static PyObject
*CFStringRefObj_CFStringCreateArrayWithFindResults(CFStringRefObject
*_self
, PyObject
*_args
)
1694 PyObject
*_res
= NULL
;
1696 CFStringRef stringToFind
;
1697 CFRange rangeToSearch
;
1698 CFOptionFlags compareOptions
;
1699 if (!PyArg_ParseTuple(_args
, "O&O&l",
1700 CFStringRefObj_Convert
, &stringToFind
,
1701 CFRange_Convert
, &rangeToSearch
,
1704 _rv
= CFStringCreateArrayWithFindResults((CFAllocatorRef
)NULL
,
1709 _res
= Py_BuildValue("O&",
1710 CFArrayRefObj_New
, _rv
);
1714 static PyObject
*CFStringRefObj_CFStringFind(CFStringRefObject
*_self
, PyObject
*_args
)
1716 PyObject
*_res
= NULL
;
1718 CFStringRef stringToFind
;
1719 CFOptionFlags compareOptions
;
1720 #ifndef CFStringFind
1721 PyMac_PRECHECK(CFStringFind
);
1723 if (!PyArg_ParseTuple(_args
, "O&l",
1724 CFStringRefObj_Convert
, &stringToFind
,
1727 _rv
= CFStringFind(_self
->ob_itself
,
1730 _res
= Py_BuildValue("O&",
1735 static PyObject
*CFStringRefObj_CFStringHasPrefix(CFStringRefObject
*_self
, PyObject
*_args
)
1737 PyObject
*_res
= NULL
;
1740 #ifndef CFStringHasPrefix
1741 PyMac_PRECHECK(CFStringHasPrefix
);
1743 if (!PyArg_ParseTuple(_args
, "O&",
1744 CFStringRefObj_Convert
, &prefix
))
1746 _rv
= CFStringHasPrefix(_self
->ob_itself
,
1748 _res
= Py_BuildValue("l",
1753 static PyObject
*CFStringRefObj_CFStringHasSuffix(CFStringRefObject
*_self
, PyObject
*_args
)
1755 PyObject
*_res
= NULL
;
1758 #ifndef CFStringHasSuffix
1759 PyMac_PRECHECK(CFStringHasSuffix
);
1761 if (!PyArg_ParseTuple(_args
, "O&",
1762 CFStringRefObj_Convert
, &suffix
))
1764 _rv
= CFStringHasSuffix(_self
->ob_itself
,
1766 _res
= Py_BuildValue("l",
1771 static PyObject
*CFStringRefObj_CFStringGetLineBounds(CFStringRefObject
*_self
, PyObject
*_args
)
1773 PyObject
*_res
= NULL
;
1775 CFIndex lineBeginIndex
;
1776 CFIndex lineEndIndex
;
1777 CFIndex contentsEndIndex
;
1778 #ifndef CFStringGetLineBounds
1779 PyMac_PRECHECK(CFStringGetLineBounds
);
1781 if (!PyArg_ParseTuple(_args
, "O&",
1782 CFRange_Convert
, &range
))
1784 CFStringGetLineBounds(_self
->ob_itself
,
1789 _res
= Py_BuildValue("lll",
1796 static PyObject
*CFStringRefObj_CFStringCreateArrayBySeparatingStrings(CFStringRefObject
*_self
, PyObject
*_args
)
1798 PyObject
*_res
= NULL
;
1800 CFStringRef separatorString
;
1801 if (!PyArg_ParseTuple(_args
, "O&",
1802 CFStringRefObj_Convert
, &separatorString
))
1804 _rv
= CFStringCreateArrayBySeparatingStrings((CFAllocatorRef
)NULL
,
1807 _res
= Py_BuildValue("O&",
1808 CFArrayRefObj_New
, _rv
);
1812 static PyObject
*CFStringRefObj_CFStringGetIntValue(CFStringRefObject
*_self
, PyObject
*_args
)
1814 PyObject
*_res
= NULL
;
1816 #ifndef CFStringGetIntValue
1817 PyMac_PRECHECK(CFStringGetIntValue
);
1819 if (!PyArg_ParseTuple(_args
, ""))
1821 _rv
= CFStringGetIntValue(_self
->ob_itself
);
1822 _res
= Py_BuildValue("l",
1827 static PyObject
*CFStringRefObj_CFStringGetDoubleValue(CFStringRefObject
*_self
, PyObject
*_args
)
1829 PyObject
*_res
= NULL
;
1831 #ifndef CFStringGetDoubleValue
1832 PyMac_PRECHECK(CFStringGetDoubleValue
);
1834 if (!PyArg_ParseTuple(_args
, ""))
1836 _rv
= CFStringGetDoubleValue(_self
->ob_itself
);
1837 _res
= Py_BuildValue("d",
1842 static PyObject
*CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
1844 PyObject
*_res
= NULL
;
1845 CFStringEncoding _rv
;
1846 #ifndef CFStringConvertIANACharSetNameToEncoding
1847 PyMac_PRECHECK(CFStringConvertIANACharSetNameToEncoding
);
1849 if (!PyArg_ParseTuple(_args
, ""))
1851 _rv
= CFStringConvertIANACharSetNameToEncoding(_self
->ob_itself
);
1852 _res
= Py_BuildValue("l",
1857 static PyObject
*CFStringRefObj_CFShowStr(CFStringRefObject
*_self
, PyObject
*_args
)
1859 PyObject
*_res
= NULL
;
1861 PyMac_PRECHECK(CFShowStr
);
1863 if (!PyArg_ParseTuple(_args
, ""))
1865 CFShowStr(_self
->ob_itself
);
1871 static PyObject
*CFStringRefObj_CFURLCreateWithString(CFStringRefObject
*_self
, PyObject
*_args
)
1873 PyObject
*_res
= NULL
;
1876 if (!PyArg_ParseTuple(_args
, "O&",
1877 OptionalCFURLRefObj_Convert
, &baseURL
))
1879 _rv
= CFURLCreateWithString((CFAllocatorRef
)NULL
,
1882 _res
= Py_BuildValue("O&",
1883 CFURLRefObj_New
, _rv
);
1887 static PyObject
*CFStringRefObj_CFURLCreateWithFileSystemPath(CFStringRefObject
*_self
, PyObject
*_args
)
1889 PyObject
*_res
= NULL
;
1891 CFURLPathStyle pathStyle
;
1892 Boolean isDirectory
;
1893 if (!PyArg_ParseTuple(_args
, "ll",
1897 _rv
= CFURLCreateWithFileSystemPath((CFAllocatorRef
)NULL
,
1901 _res
= Py_BuildValue("O&",
1902 CFURLRefObj_New
, _rv
);
1906 static PyObject
*CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase(CFStringRefObject
*_self
, PyObject
*_args
)
1908 PyObject
*_res
= NULL
;
1910 CFURLPathStyle pathStyle
;
1911 Boolean isDirectory
;
1913 if (!PyArg_ParseTuple(_args
, "llO&",
1916 OptionalCFURLRefObj_Convert
, &baseURL
))
1918 _rv
= CFURLCreateWithFileSystemPathRelativeToBase((CFAllocatorRef
)NULL
,
1923 _res
= Py_BuildValue("O&",
1924 CFURLRefObj_New
, _rv
);
1928 static PyObject
*CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes(CFStringRefObject
*_self
, PyObject
*_args
)
1930 PyObject
*_res
= NULL
;
1932 CFStringRef charactersToLeaveEscaped
;
1933 if (!PyArg_ParseTuple(_args
, "O&",
1934 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
1936 _rv
= CFURLCreateStringByReplacingPercentEscapes((CFAllocatorRef
)NULL
,
1938 charactersToLeaveEscaped
);
1939 _res
= Py_BuildValue("O&",
1940 CFStringRefObj_New
, _rv
);
1944 static PyObject
*CFStringRefObj_CFURLCreateStringByAddingPercentEscapes(CFStringRefObject
*_self
, PyObject
*_args
)
1946 PyObject
*_res
= NULL
;
1948 CFStringRef charactersToLeaveUnescaped
;
1949 CFStringRef legalURLCharactersToBeEscaped
;
1950 CFStringEncoding encoding
;
1951 if (!PyArg_ParseTuple(_args
, "O&O&l",
1952 CFStringRefObj_Convert
, &charactersToLeaveUnescaped
,
1953 CFStringRefObj_Convert
, &legalURLCharactersToBeEscaped
,
1956 _rv
= CFURLCreateStringByAddingPercentEscapes((CFAllocatorRef
)NULL
,
1958 charactersToLeaveUnescaped
,
1959 legalURLCharactersToBeEscaped
,
1961 _res
= Py_BuildValue("O&",
1962 CFStringRefObj_New
, _rv
);
1966 static PyObject
*CFStringRefObj_CFStringGetString(CFStringRefObject
*_self
, PyObject
*_args
)
1968 PyObject
*_res
= NULL
;
1970 int size
= CFStringGetLength(_self
->ob_itself
)+1;
1971 char *data
= malloc(size
);
1973 if( data
== NULL
) return PyErr_NoMemory();
1974 if ( CFStringGetCString(_self
->ob_itself
, data
, size
, 0) ) {
1975 _res
= (PyObject
*)PyString_FromString(data
);
1977 PyErr_SetString(PyExc_RuntimeError
, "CFStringGetCString could not fit the string");
1985 static PyObject
*CFStringRefObj_CFStringGetUnicode(CFStringRefObject
*_self
, PyObject
*_args
)
1987 PyObject
*_res
= NULL
;
1989 int size
= CFStringGetLength(_self
->ob_itself
)+1;
1990 Py_UNICODE
*data
= malloc(size
*sizeof(Py_UNICODE
));
1994 range
.length
= size
;
1995 if( data
== NULL
) return PyErr_NoMemory();
1996 CFStringGetCharacters(_self
->ob_itself
, range
, data
);
1997 _res
= (PyObject
*)PyUnicode_FromUnicode(data
, size
);
2003 static PyMethodDef CFStringRefObj_methods
[] = {
2004 {"CFStringCreateWithSubstring", (PyCFunction
)CFStringRefObj_CFStringCreateWithSubstring
, 1,
2005 "(CFRange range) -> (CFStringRef _rv)"},
2006 {"CFStringCreateCopy", (PyCFunction
)CFStringRefObj_CFStringCreateCopy
, 1,
2007 "() -> (CFStringRef _rv)"},
2008 {"CFStringGetLength", (PyCFunction
)CFStringRefObj_CFStringGetLength
, 1,
2009 "() -> (CFIndex _rv)"},
2010 {"CFStringGetBytes", (PyCFunction
)CFStringRefObj_CFStringGetBytes
, 1,
2011 "(CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, CFIndex maxBufLen) -> (CFIndex _rv, UInt8 buffer, CFIndex usedBufLen)"},
2012 {"CFStringCreateExternalRepresentation", (PyCFunction
)CFStringRefObj_CFStringCreateExternalRepresentation
, 1,
2013 "(CFStringEncoding encoding, UInt8 lossByte) -> (CFDataRef _rv)"},
2014 {"CFStringGetSmallestEncoding", (PyCFunction
)CFStringRefObj_CFStringGetSmallestEncoding
, 1,
2015 "() -> (CFStringEncoding _rv)"},
2016 {"CFStringGetFastestEncoding", (PyCFunction
)CFStringRefObj_CFStringGetFastestEncoding
, 1,
2017 "() -> (CFStringEncoding _rv)"},
2018 {"CFStringCompareWithOptions", (PyCFunction
)CFStringRefObj_CFStringCompareWithOptions
, 1,
2019 "(CFStringRef theString2, CFRange rangeToCompare, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)"},
2020 {"CFStringCompare", (PyCFunction
)CFStringRefObj_CFStringCompare
, 1,
2021 "(CFStringRef theString2, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)"},
2022 {"CFStringFindWithOptions", (PyCFunction
)CFStringRefObj_CFStringFindWithOptions
, 1,
2023 "(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags searchOptions) -> (Boolean _rv, CFRange result)"},
2024 {"CFStringCreateArrayWithFindResults", (PyCFunction
)CFStringRefObj_CFStringCreateArrayWithFindResults
, 1,
2025 "(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions) -> (CFArrayRef _rv)"},
2026 {"CFStringFind", (PyCFunction
)CFStringRefObj_CFStringFind
, 1,
2027 "(CFStringRef stringToFind, CFOptionFlags compareOptions) -> (CFRange _rv)"},
2028 {"CFStringHasPrefix", (PyCFunction
)CFStringRefObj_CFStringHasPrefix
, 1,
2029 "(CFStringRef prefix) -> (Boolean _rv)"},
2030 {"CFStringHasSuffix", (PyCFunction
)CFStringRefObj_CFStringHasSuffix
, 1,
2031 "(CFStringRef suffix) -> (Boolean _rv)"},
2032 {"CFStringGetLineBounds", (PyCFunction
)CFStringRefObj_CFStringGetLineBounds
, 1,
2033 "(CFRange range) -> (CFIndex lineBeginIndex, CFIndex lineEndIndex, CFIndex contentsEndIndex)"},
2034 {"CFStringCreateArrayBySeparatingStrings", (PyCFunction
)CFStringRefObj_CFStringCreateArrayBySeparatingStrings
, 1,
2035 "(CFStringRef separatorString) -> (CFArrayRef _rv)"},
2036 {"CFStringGetIntValue", (PyCFunction
)CFStringRefObj_CFStringGetIntValue
, 1,
2037 "() -> (SInt32 _rv)"},
2038 {"CFStringGetDoubleValue", (PyCFunction
)CFStringRefObj_CFStringGetDoubleValue
, 1,
2039 "() -> (double _rv)"},
2040 {"CFStringConvertIANACharSetNameToEncoding", (PyCFunction
)CFStringRefObj_CFStringConvertIANACharSetNameToEncoding
, 1,
2041 "() -> (CFStringEncoding _rv)"},
2042 {"CFShowStr", (PyCFunction
)CFStringRefObj_CFShowStr
, 1,
2044 {"CFURLCreateWithString", (PyCFunction
)CFStringRefObj_CFURLCreateWithString
, 1,
2045 "(CFURLRef baseURL) -> (CFURLRef _rv)"},
2046 {"CFURLCreateWithFileSystemPath", (PyCFunction
)CFStringRefObj_CFURLCreateWithFileSystemPath
, 1,
2047 "(CFURLPathStyle pathStyle, Boolean isDirectory) -> (CFURLRef _rv)"},
2048 {"CFURLCreateWithFileSystemPathRelativeToBase", (PyCFunction
)CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase
, 1,
2049 "(CFURLPathStyle pathStyle, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)"},
2050 {"CFURLCreateStringByReplacingPercentEscapes", (PyCFunction
)CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes
, 1,
2051 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2052 {"CFURLCreateStringByAddingPercentEscapes", (PyCFunction
)CFStringRefObj_CFURLCreateStringByAddingPercentEscapes
, 1,
2053 "(CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding) -> (CFStringRef _rv)"},
2054 {"CFStringGetString", (PyCFunction
)CFStringRefObj_CFStringGetString
, 1,
2055 "() -> (string _rv)"},
2056 {"CFStringGetUnicode", (PyCFunction
)CFStringRefObj_CFStringGetUnicode
, 1,
2057 "() -> (unicode _rv)"},
2061 PyMethodChain CFStringRefObj_chain
= { CFStringRefObj_methods
, &CFTypeRefObj_chain
};
2063 static PyObject
*CFStringRefObj_getattr(CFStringRefObject
*self
, char *name
)
2065 return Py_FindMethodInChain(&CFStringRefObj_chain
, (PyObject
*)self
, name
);
2068 #define CFStringRefObj_setattr NULL
2070 static int CFStringRefObj_compare(CFStringRefObject
*self
, CFStringRefObject
*other
)
2072 /* XXXX Or should we use CFEqual?? */
2073 if ( self
->ob_itself
> other
->ob_itself
) return 1;
2074 if ( self
->ob_itself
< other
->ob_itself
) return -1;
2078 static PyObject
* CFStringRefObj_repr(CFStringRefObject
*self
)
2081 sprintf(buf
, "<CFStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
2082 return PyString_FromString(buf
);
2085 static int CFStringRefObj_hash(CFStringRefObject
*self
)
2087 /* XXXX Or should we use CFHash?? */
2088 return (int)self
->ob_itself
;
2091 PyTypeObject CFStringRef_Type
= {
2092 PyObject_HEAD_INIT(NULL
)
2094 "_CF.CFStringRef", /*tp_name*/
2095 sizeof(CFStringRefObject
), /*tp_basicsize*/
2098 (destructor
) CFStringRefObj_dealloc
, /*tp_dealloc*/
2100 (getattrfunc
) CFStringRefObj_getattr
, /*tp_getattr*/
2101 (setattrfunc
) CFStringRefObj_setattr
, /*tp_setattr*/
2102 (cmpfunc
) CFStringRefObj_compare
, /*tp_compare*/
2103 (reprfunc
) CFStringRefObj_repr
, /*tp_repr*/
2104 (PyNumberMethods
*)0, /* tp_as_number */
2105 (PySequenceMethods
*)0, /* tp_as_sequence */
2106 (PyMappingMethods
*)0, /* tp_as_mapping */
2107 (hashfunc
) CFStringRefObj_hash
, /*tp_hash*/
2110 /* ------------------ End object type CFStringRef ------------------- */
2113 /* ----------------- Object type CFMutableStringRef ----------------- */
2115 PyTypeObject CFMutableStringRef_Type
;
2117 #define CFMutableStringRefObj_Check(x) ((x)->ob_type == &CFMutableStringRef_Type)
2119 typedef struct CFMutableStringRefObject
{
2121 CFMutableStringRef ob_itself
;
2122 void (*ob_freeit
)(CFTypeRef ptr
);
2123 } CFMutableStringRefObject
;
2125 PyObject
*CFMutableStringRefObj_New(CFMutableStringRef itself
)
2127 CFMutableStringRefObject
*it
;
2130 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
2133 it
= PyObject_NEW(CFMutableStringRefObject
, &CFMutableStringRef_Type
);
2134 if (it
== NULL
) return NULL
;
2135 it
->ob_itself
= itself
;
2136 it
->ob_freeit
= CFRelease
;
2137 return (PyObject
*)it
;
2139 int CFMutableStringRefObj_Convert(PyObject
*v
, CFMutableStringRef
*p_itself
)
2142 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
2143 /* Check for other CF objects here */
2145 if (!CFMutableStringRefObj_Check(v
))
2147 PyErr_SetString(PyExc_TypeError
, "CFMutableStringRef required");
2150 *p_itself
= ((CFMutableStringRefObject
*)v
)->ob_itself
;
2154 static void CFMutableStringRefObj_dealloc(CFMutableStringRefObject
*self
)
2156 if (self
->ob_freeit
&& self
->ob_itself
)
2158 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
2163 static PyObject
*CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2165 PyObject
*_res
= NULL
;
2166 CFStringRef appendedString
;
2167 #ifndef CFStringAppend
2168 PyMac_PRECHECK(CFStringAppend
);
2170 if (!PyArg_ParseTuple(_args
, "O&",
2171 CFStringRefObj_Convert
, &appendedString
))
2173 CFStringAppend(_self
->ob_itself
,
2180 static PyObject
*CFMutableStringRefObj_CFStringAppendCharacters(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2182 PyObject
*_res
= NULL
;
2183 UniChar
*chars__in__
;
2184 UniCharCount chars__len__
;
2185 int chars__in_len__
;
2186 #ifndef CFStringAppendCharacters
2187 PyMac_PRECHECK(CFStringAppendCharacters
);
2189 if (!PyArg_ParseTuple(_args
, "u#",
2190 &chars__in__
, &chars__in_len__
))
2192 chars__len__
= chars__in_len__
;
2193 CFStringAppendCharacters(_self
->ob_itself
,
2194 chars__in__
, chars__len__
);
2200 static PyObject
*CFMutableStringRefObj_CFStringAppendPascalString(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2202 PyObject
*_res
= NULL
;
2204 CFStringEncoding encoding
;
2205 #ifndef CFStringAppendPascalString
2206 PyMac_PRECHECK(CFStringAppendPascalString
);
2208 if (!PyArg_ParseTuple(_args
, "O&l",
2209 PyMac_GetStr255
, pStr
,
2212 CFStringAppendPascalString(_self
->ob_itself
,
2220 static PyObject
*CFMutableStringRefObj_CFStringAppendCString(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2222 PyObject
*_res
= NULL
;
2224 CFStringEncoding encoding
;
2225 #ifndef CFStringAppendCString
2226 PyMac_PRECHECK(CFStringAppendCString
);
2228 if (!PyArg_ParseTuple(_args
, "sl",
2232 CFStringAppendCString(_self
->ob_itself
,
2240 static PyObject
*CFMutableStringRefObj_CFStringInsert(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2242 PyObject
*_res
= NULL
;
2244 CFStringRef insertedStr
;
2245 #ifndef CFStringInsert
2246 PyMac_PRECHECK(CFStringInsert
);
2248 if (!PyArg_ParseTuple(_args
, "lO&",
2250 CFStringRefObj_Convert
, &insertedStr
))
2252 CFStringInsert(_self
->ob_itself
,
2260 static PyObject
*CFMutableStringRefObj_CFStringDelete(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2262 PyObject
*_res
= NULL
;
2264 #ifndef CFStringDelete
2265 PyMac_PRECHECK(CFStringDelete
);
2267 if (!PyArg_ParseTuple(_args
, "O&",
2268 CFRange_Convert
, &range
))
2270 CFStringDelete(_self
->ob_itself
,
2277 static PyObject
*CFMutableStringRefObj_CFStringReplace(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2279 PyObject
*_res
= NULL
;
2281 CFStringRef replacement
;
2282 #ifndef CFStringReplace
2283 PyMac_PRECHECK(CFStringReplace
);
2285 if (!PyArg_ParseTuple(_args
, "O&O&",
2286 CFRange_Convert
, &range
,
2287 CFStringRefObj_Convert
, &replacement
))
2289 CFStringReplace(_self
->ob_itself
,
2297 static PyObject
*CFMutableStringRefObj_CFStringReplaceAll(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2299 PyObject
*_res
= NULL
;
2300 CFStringRef replacement
;
2301 #ifndef CFStringReplaceAll
2302 PyMac_PRECHECK(CFStringReplaceAll
);
2304 if (!PyArg_ParseTuple(_args
, "O&",
2305 CFStringRefObj_Convert
, &replacement
))
2307 CFStringReplaceAll(_self
->ob_itself
,
2314 static PyObject
*CFMutableStringRefObj_CFStringPad(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2316 PyObject
*_res
= NULL
;
2317 CFStringRef padString
;
2319 CFIndex indexIntoPad
;
2321 PyMac_PRECHECK(CFStringPad
);
2323 if (!PyArg_ParseTuple(_args
, "O&ll",
2324 CFStringRefObj_Convert
, &padString
,
2328 CFStringPad(_self
->ob_itself
,
2337 static PyObject
*CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2339 PyObject
*_res
= NULL
;
2340 CFStringRef trimString
;
2341 #ifndef CFStringTrim
2342 PyMac_PRECHECK(CFStringTrim
);
2344 if (!PyArg_ParseTuple(_args
, "O&",
2345 CFStringRefObj_Convert
, &trimString
))
2347 CFStringTrim(_self
->ob_itself
,
2354 static PyObject
*CFMutableStringRefObj_CFStringTrimWhitespace(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2356 PyObject
*_res
= NULL
;
2357 #ifndef CFStringTrimWhitespace
2358 PyMac_PRECHECK(CFStringTrimWhitespace
);
2360 if (!PyArg_ParseTuple(_args
, ""))
2362 CFStringTrimWhitespace(_self
->ob_itself
);
2368 static PyMethodDef CFMutableStringRefObj_methods
[] = {
2369 {"CFStringAppend", (PyCFunction
)CFMutableStringRefObj_CFStringAppend
, 1,
2370 "(CFStringRef appendedString) -> None"},
2371 {"CFStringAppendCharacters", (PyCFunction
)CFMutableStringRefObj_CFStringAppendCharacters
, 1,
2372 "(Buffer chars) -> None"},
2373 {"CFStringAppendPascalString", (PyCFunction
)CFMutableStringRefObj_CFStringAppendPascalString
, 1,
2374 "(Str255 pStr, CFStringEncoding encoding) -> None"},
2375 {"CFStringAppendCString", (PyCFunction
)CFMutableStringRefObj_CFStringAppendCString
, 1,
2376 "(char* cStr, CFStringEncoding encoding) -> None"},
2377 {"CFStringInsert", (PyCFunction
)CFMutableStringRefObj_CFStringInsert
, 1,
2378 "(CFIndex idx, CFStringRef insertedStr) -> None"},
2379 {"CFStringDelete", (PyCFunction
)CFMutableStringRefObj_CFStringDelete
, 1,
2380 "(CFRange range) -> None"},
2381 {"CFStringReplace", (PyCFunction
)CFMutableStringRefObj_CFStringReplace
, 1,
2382 "(CFRange range, CFStringRef replacement) -> None"},
2383 {"CFStringReplaceAll", (PyCFunction
)CFMutableStringRefObj_CFStringReplaceAll
, 1,
2384 "(CFStringRef replacement) -> None"},
2385 {"CFStringPad", (PyCFunction
)CFMutableStringRefObj_CFStringPad
, 1,
2386 "(CFStringRef padString, CFIndex length, CFIndex indexIntoPad) -> None"},
2387 {"CFStringTrim", (PyCFunction
)CFMutableStringRefObj_CFStringTrim
, 1,
2388 "(CFStringRef trimString) -> None"},
2389 {"CFStringTrimWhitespace", (PyCFunction
)CFMutableStringRefObj_CFStringTrimWhitespace
, 1,
2394 PyMethodChain CFMutableStringRefObj_chain
= { CFMutableStringRefObj_methods
, &CFStringRefObj_chain
};
2396 static PyObject
*CFMutableStringRefObj_getattr(CFMutableStringRefObject
*self
, char *name
)
2398 return Py_FindMethodInChain(&CFMutableStringRefObj_chain
, (PyObject
*)self
, name
);
2401 #define CFMutableStringRefObj_setattr NULL
2403 static int CFMutableStringRefObj_compare(CFMutableStringRefObject
*self
, CFMutableStringRefObject
*other
)
2405 /* XXXX Or should we use CFEqual?? */
2406 if ( self
->ob_itself
> other
->ob_itself
) return 1;
2407 if ( self
->ob_itself
< other
->ob_itself
) return -1;
2411 static PyObject
* CFMutableStringRefObj_repr(CFMutableStringRefObject
*self
)
2414 sprintf(buf
, "<CFMutableStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
2415 return PyString_FromString(buf
);
2418 static int CFMutableStringRefObj_hash(CFMutableStringRefObject
*self
)
2420 /* XXXX Or should we use CFHash?? */
2421 return (int)self
->ob_itself
;
2424 PyTypeObject CFMutableStringRef_Type
= {
2425 PyObject_HEAD_INIT(NULL
)
2427 "_CF.CFMutableStringRef", /*tp_name*/
2428 sizeof(CFMutableStringRefObject
), /*tp_basicsize*/
2431 (destructor
) CFMutableStringRefObj_dealloc
, /*tp_dealloc*/
2433 (getattrfunc
) CFMutableStringRefObj_getattr
, /*tp_getattr*/
2434 (setattrfunc
) CFMutableStringRefObj_setattr
, /*tp_setattr*/
2435 (cmpfunc
) CFMutableStringRefObj_compare
, /*tp_compare*/
2436 (reprfunc
) CFMutableStringRefObj_repr
, /*tp_repr*/
2437 (PyNumberMethods
*)0, /* tp_as_number */
2438 (PySequenceMethods
*)0, /* tp_as_sequence */
2439 (PyMappingMethods
*)0, /* tp_as_mapping */
2440 (hashfunc
) CFMutableStringRefObj_hash
, /*tp_hash*/
2443 /* --------------- End object type CFMutableStringRef --------------- */
2446 /* ---------------------- Object type CFURLRef ---------------------- */
2448 PyTypeObject CFURLRef_Type
;
2450 #define CFURLRefObj_Check(x) ((x)->ob_type == &CFURLRef_Type)
2452 typedef struct CFURLRefObject
{
2455 void (*ob_freeit
)(CFTypeRef ptr
);
2458 PyObject
*CFURLRefObj_New(CFURLRef itself
)
2463 PyErr_SetString(PyExc_RuntimeError
, "cannot wrap NULL");
2466 it
= PyObject_NEW(CFURLRefObject
, &CFURLRef_Type
);
2467 if (it
== NULL
) return NULL
;
2468 it
->ob_itself
= itself
;
2469 it
->ob_freeit
= CFRelease
;
2470 return (PyObject
*)it
;
2472 int CFURLRefObj_Convert(PyObject
*v
, CFURLRef
*p_itself
)
2475 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
2476 /* Check for other CF objects here */
2478 if (!CFURLRefObj_Check(v
))
2480 PyErr_SetString(PyExc_TypeError
, "CFURLRef required");
2483 *p_itself
= ((CFURLRefObject
*)v
)->ob_itself
;
2487 static void CFURLRefObj_dealloc(CFURLRefObject
*self
)
2489 if (self
->ob_freeit
&& self
->ob_itself
)
2491 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
2496 static PyObject
*CFURLRefObj_CFURLCreateData(CFURLRefObject
*_self
, PyObject
*_args
)
2498 PyObject
*_res
= NULL
;
2500 CFStringEncoding encoding
;
2501 Boolean escapeWhitespace
;
2502 if (!PyArg_ParseTuple(_args
, "ll",
2506 _rv
= CFURLCreateData((CFAllocatorRef
)NULL
,
2510 _res
= Py_BuildValue("O&",
2511 CFDataRefObj_New
, _rv
);
2515 static PyObject
*CFURLRefObj_CFURLGetFileSystemRepresentation(CFURLRefObject
*_self
, PyObject
*_args
)
2517 PyObject
*_res
= NULL
;
2519 Boolean resolveAgainstBase
;
2522 #ifndef CFURLGetFileSystemRepresentation
2523 PyMac_PRECHECK(CFURLGetFileSystemRepresentation
);
2525 if (!PyArg_ParseTuple(_args
, "ll",
2526 &resolveAgainstBase
,
2529 _rv
= CFURLGetFileSystemRepresentation(_self
->ob_itself
,
2533 _res
= Py_BuildValue("lb",
2539 static PyObject
*CFURLRefObj_CFURLCopyAbsoluteURL(CFURLRefObject
*_self
, PyObject
*_args
)
2541 PyObject
*_res
= NULL
;
2543 #ifndef CFURLCopyAbsoluteURL
2544 PyMac_PRECHECK(CFURLCopyAbsoluteURL
);
2546 if (!PyArg_ParseTuple(_args
, ""))
2548 _rv
= CFURLCopyAbsoluteURL(_self
->ob_itself
);
2549 _res
= Py_BuildValue("O&",
2550 CFURLRefObj_New
, _rv
);
2554 static PyObject
*CFURLRefObj_CFURLGetString(CFURLRefObject
*_self
, PyObject
*_args
)
2556 PyObject
*_res
= NULL
;
2558 #ifndef CFURLGetString
2559 PyMac_PRECHECK(CFURLGetString
);
2561 if (!PyArg_ParseTuple(_args
, ""))
2563 _rv
= CFURLGetString(_self
->ob_itself
);
2564 _res
= Py_BuildValue("O&",
2565 CFStringRefObj_New
, _rv
);
2569 static PyObject
*CFURLRefObj_CFURLGetBaseURL(CFURLRefObject
*_self
, PyObject
*_args
)
2571 PyObject
*_res
= NULL
;
2573 #ifndef CFURLGetBaseURL
2574 PyMac_PRECHECK(CFURLGetBaseURL
);
2576 if (!PyArg_ParseTuple(_args
, ""))
2578 _rv
= CFURLGetBaseURL(_self
->ob_itself
);
2579 _res
= Py_BuildValue("O&",
2580 CFURLRefObj_New
, _rv
);
2584 static PyObject
*CFURLRefObj_CFURLCanBeDecomposed(CFURLRefObject
*_self
, PyObject
*_args
)
2586 PyObject
*_res
= NULL
;
2588 #ifndef CFURLCanBeDecomposed
2589 PyMac_PRECHECK(CFURLCanBeDecomposed
);
2591 if (!PyArg_ParseTuple(_args
, ""))
2593 _rv
= CFURLCanBeDecomposed(_self
->ob_itself
);
2594 _res
= Py_BuildValue("l",
2599 static PyObject
*CFURLRefObj_CFURLCopyScheme(CFURLRefObject
*_self
, PyObject
*_args
)
2601 PyObject
*_res
= NULL
;
2603 #ifndef CFURLCopyScheme
2604 PyMac_PRECHECK(CFURLCopyScheme
);
2606 if (!PyArg_ParseTuple(_args
, ""))
2608 _rv
= CFURLCopyScheme(_self
->ob_itself
);
2609 _res
= Py_BuildValue("O&",
2610 CFStringRefObj_New
, _rv
);
2614 static PyObject
*CFURLRefObj_CFURLCopyNetLocation(CFURLRefObject
*_self
, PyObject
*_args
)
2616 PyObject
*_res
= NULL
;
2618 #ifndef CFURLCopyNetLocation
2619 PyMac_PRECHECK(CFURLCopyNetLocation
);
2621 if (!PyArg_ParseTuple(_args
, ""))
2623 _rv
= CFURLCopyNetLocation(_self
->ob_itself
);
2624 _res
= Py_BuildValue("O&",
2625 CFStringRefObj_New
, _rv
);
2629 static PyObject
*CFURLRefObj_CFURLCopyPath(CFURLRefObject
*_self
, PyObject
*_args
)
2631 PyObject
*_res
= NULL
;
2633 #ifndef CFURLCopyPath
2634 PyMac_PRECHECK(CFURLCopyPath
);
2636 if (!PyArg_ParseTuple(_args
, ""))
2638 _rv
= CFURLCopyPath(_self
->ob_itself
);
2639 _res
= Py_BuildValue("O&",
2640 CFStringRefObj_New
, _rv
);
2644 static PyObject
*CFURLRefObj_CFURLCopyStrictPath(CFURLRefObject
*_self
, PyObject
*_args
)
2646 PyObject
*_res
= NULL
;
2649 #ifndef CFURLCopyStrictPath
2650 PyMac_PRECHECK(CFURLCopyStrictPath
);
2652 if (!PyArg_ParseTuple(_args
, ""))
2654 _rv
= CFURLCopyStrictPath(_self
->ob_itself
,
2656 _res
= Py_BuildValue("O&l",
2657 CFStringRefObj_New
, _rv
,
2662 static PyObject
*CFURLRefObj_CFURLCopyFileSystemPath(CFURLRefObject
*_self
, PyObject
*_args
)
2664 PyObject
*_res
= NULL
;
2666 CFURLPathStyle pathStyle
;
2667 #ifndef CFURLCopyFileSystemPath
2668 PyMac_PRECHECK(CFURLCopyFileSystemPath
);
2670 if (!PyArg_ParseTuple(_args
, "l",
2673 _rv
= CFURLCopyFileSystemPath(_self
->ob_itself
,
2675 _res
= Py_BuildValue("O&",
2676 CFStringRefObj_New
, _rv
);
2680 static PyObject
*CFURLRefObj_CFURLHasDirectoryPath(CFURLRefObject
*_self
, PyObject
*_args
)
2682 PyObject
*_res
= NULL
;
2684 #ifndef CFURLHasDirectoryPath
2685 PyMac_PRECHECK(CFURLHasDirectoryPath
);
2687 if (!PyArg_ParseTuple(_args
, ""))
2689 _rv
= CFURLHasDirectoryPath(_self
->ob_itself
);
2690 _res
= Py_BuildValue("l",
2695 static PyObject
*CFURLRefObj_CFURLCopyResourceSpecifier(CFURLRefObject
*_self
, PyObject
*_args
)
2697 PyObject
*_res
= NULL
;
2699 #ifndef CFURLCopyResourceSpecifier
2700 PyMac_PRECHECK(CFURLCopyResourceSpecifier
);
2702 if (!PyArg_ParseTuple(_args
, ""))
2704 _rv
= CFURLCopyResourceSpecifier(_self
->ob_itself
);
2705 _res
= Py_BuildValue("O&",
2706 CFStringRefObj_New
, _rv
);
2710 static PyObject
*CFURLRefObj_CFURLCopyHostName(CFURLRefObject
*_self
, PyObject
*_args
)
2712 PyObject
*_res
= NULL
;
2714 #ifndef CFURLCopyHostName
2715 PyMac_PRECHECK(CFURLCopyHostName
);
2717 if (!PyArg_ParseTuple(_args
, ""))
2719 _rv
= CFURLCopyHostName(_self
->ob_itself
);
2720 _res
= Py_BuildValue("O&",
2721 CFStringRefObj_New
, _rv
);
2725 static PyObject
*CFURLRefObj_CFURLGetPortNumber(CFURLRefObject
*_self
, PyObject
*_args
)
2727 PyObject
*_res
= NULL
;
2729 #ifndef CFURLGetPortNumber
2730 PyMac_PRECHECK(CFURLGetPortNumber
);
2732 if (!PyArg_ParseTuple(_args
, ""))
2734 _rv
= CFURLGetPortNumber(_self
->ob_itself
);
2735 _res
= Py_BuildValue("l",
2740 static PyObject
*CFURLRefObj_CFURLCopyUserName(CFURLRefObject
*_self
, PyObject
*_args
)
2742 PyObject
*_res
= NULL
;
2744 #ifndef CFURLCopyUserName
2745 PyMac_PRECHECK(CFURLCopyUserName
);
2747 if (!PyArg_ParseTuple(_args
, ""))
2749 _rv
= CFURLCopyUserName(_self
->ob_itself
);
2750 _res
= Py_BuildValue("O&",
2751 CFStringRefObj_New
, _rv
);
2755 static PyObject
*CFURLRefObj_CFURLCopyPassword(CFURLRefObject
*_self
, PyObject
*_args
)
2757 PyObject
*_res
= NULL
;
2759 #ifndef CFURLCopyPassword
2760 PyMac_PRECHECK(CFURLCopyPassword
);
2762 if (!PyArg_ParseTuple(_args
, ""))
2764 _rv
= CFURLCopyPassword(_self
->ob_itself
);
2765 _res
= Py_BuildValue("O&",
2766 CFStringRefObj_New
, _rv
);
2770 static PyObject
*CFURLRefObj_CFURLCopyParameterString(CFURLRefObject
*_self
, PyObject
*_args
)
2772 PyObject
*_res
= NULL
;
2774 CFStringRef charactersToLeaveEscaped
;
2775 #ifndef CFURLCopyParameterString
2776 PyMac_PRECHECK(CFURLCopyParameterString
);
2778 if (!PyArg_ParseTuple(_args
, "O&",
2779 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
2781 _rv
= CFURLCopyParameterString(_self
->ob_itself
,
2782 charactersToLeaveEscaped
);
2783 _res
= Py_BuildValue("O&",
2784 CFStringRefObj_New
, _rv
);
2788 static PyObject
*CFURLRefObj_CFURLCopyQueryString(CFURLRefObject
*_self
, PyObject
*_args
)
2790 PyObject
*_res
= NULL
;
2792 CFStringRef charactersToLeaveEscaped
;
2793 #ifndef CFURLCopyQueryString
2794 PyMac_PRECHECK(CFURLCopyQueryString
);
2796 if (!PyArg_ParseTuple(_args
, "O&",
2797 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
2799 _rv
= CFURLCopyQueryString(_self
->ob_itself
,
2800 charactersToLeaveEscaped
);
2801 _res
= Py_BuildValue("O&",
2802 CFStringRefObj_New
, _rv
);
2806 static PyObject
*CFURLRefObj_CFURLCopyFragment(CFURLRefObject
*_self
, PyObject
*_args
)
2808 PyObject
*_res
= NULL
;
2810 CFStringRef charactersToLeaveEscaped
;
2811 #ifndef CFURLCopyFragment
2812 PyMac_PRECHECK(CFURLCopyFragment
);
2814 if (!PyArg_ParseTuple(_args
, "O&",
2815 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
2817 _rv
= CFURLCopyFragment(_self
->ob_itself
,
2818 charactersToLeaveEscaped
);
2819 _res
= Py_BuildValue("O&",
2820 CFStringRefObj_New
, _rv
);
2824 static PyObject
*CFURLRefObj_CFURLCopyLastPathComponent(CFURLRefObject
*_self
, PyObject
*_args
)
2826 PyObject
*_res
= NULL
;
2828 #ifndef CFURLCopyLastPathComponent
2829 PyMac_PRECHECK(CFURLCopyLastPathComponent
);
2831 if (!PyArg_ParseTuple(_args
, ""))
2833 _rv
= CFURLCopyLastPathComponent(_self
->ob_itself
);
2834 _res
= Py_BuildValue("O&",
2835 CFStringRefObj_New
, _rv
);
2839 static PyObject
*CFURLRefObj_CFURLCopyPathExtension(CFURLRefObject
*_self
, PyObject
*_args
)
2841 PyObject
*_res
= NULL
;
2843 #ifndef CFURLCopyPathExtension
2844 PyMac_PRECHECK(CFURLCopyPathExtension
);
2846 if (!PyArg_ParseTuple(_args
, ""))
2848 _rv
= CFURLCopyPathExtension(_self
->ob_itself
);
2849 _res
= Py_BuildValue("O&",
2850 CFStringRefObj_New
, _rv
);
2854 static PyObject
*CFURLRefObj_CFURLCreateCopyAppendingPathComponent(CFURLRefObject
*_self
, PyObject
*_args
)
2856 PyObject
*_res
= NULL
;
2858 CFStringRef pathComponent
;
2859 Boolean isDirectory
;
2860 if (!PyArg_ParseTuple(_args
, "O&l",
2861 CFStringRefObj_Convert
, &pathComponent
,
2864 _rv
= CFURLCreateCopyAppendingPathComponent((CFAllocatorRef
)NULL
,
2868 _res
= Py_BuildValue("O&",
2869 CFURLRefObj_New
, _rv
);
2873 static PyObject
*CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent(CFURLRefObject
*_self
, PyObject
*_args
)
2875 PyObject
*_res
= NULL
;
2877 if (!PyArg_ParseTuple(_args
, ""))
2879 _rv
= CFURLCreateCopyDeletingLastPathComponent((CFAllocatorRef
)NULL
,
2881 _res
= Py_BuildValue("O&",
2882 CFURLRefObj_New
, _rv
);
2886 static PyObject
*CFURLRefObj_CFURLCreateCopyAppendingPathExtension(CFURLRefObject
*_self
, PyObject
*_args
)
2888 PyObject
*_res
= NULL
;
2890 CFStringRef extension
;
2891 if (!PyArg_ParseTuple(_args
, "O&",
2892 CFStringRefObj_Convert
, &extension
))
2894 _rv
= CFURLCreateCopyAppendingPathExtension((CFAllocatorRef
)NULL
,
2897 _res
= Py_BuildValue("O&",
2898 CFURLRefObj_New
, _rv
);
2902 static PyObject
*CFURLRefObj_CFURLCreateCopyDeletingPathExtension(CFURLRefObject
*_self
, PyObject
*_args
)
2904 PyObject
*_res
= NULL
;
2906 if (!PyArg_ParseTuple(_args
, ""))
2908 _rv
= CFURLCreateCopyDeletingPathExtension((CFAllocatorRef
)NULL
,
2910 _res
= Py_BuildValue("O&",
2911 CFURLRefObj_New
, _rv
);
2915 static PyObject
*CFURLRefObj_CFURLGetFSRef(CFURLRefObject
*_self
, PyObject
*_args
)
2917 PyObject
*_res
= NULL
;
2920 #ifndef CFURLGetFSRef
2921 PyMac_PRECHECK(CFURLGetFSRef
);
2923 if (!PyArg_ParseTuple(_args
, ""))
2925 _rv
= CFURLGetFSRef(_self
->ob_itself
,
2927 _res
= Py_BuildValue("lO&",
2929 PyMac_BuildFSRef
, &fsRef
);
2933 static PyMethodDef CFURLRefObj_methods
[] = {
2934 {"CFURLCreateData", (PyCFunction
)CFURLRefObj_CFURLCreateData
, 1,
2935 "(CFStringEncoding encoding, Boolean escapeWhitespace) -> (CFDataRef _rv)"},
2936 {"CFURLGetFileSystemRepresentation", (PyCFunction
)CFURLRefObj_CFURLGetFileSystemRepresentation
, 1,
2937 "(Boolean resolveAgainstBase, CFIndex maxBufLen) -> (Boolean _rv, UInt8 buffer)"},
2938 {"CFURLCopyAbsoluteURL", (PyCFunction
)CFURLRefObj_CFURLCopyAbsoluteURL
, 1,
2939 "() -> (CFURLRef _rv)"},
2940 {"CFURLGetString", (PyCFunction
)CFURLRefObj_CFURLGetString
, 1,
2941 "() -> (CFStringRef _rv)"},
2942 {"CFURLGetBaseURL", (PyCFunction
)CFURLRefObj_CFURLGetBaseURL
, 1,
2943 "() -> (CFURLRef _rv)"},
2944 {"CFURLCanBeDecomposed", (PyCFunction
)CFURLRefObj_CFURLCanBeDecomposed
, 1,
2945 "() -> (Boolean _rv)"},
2946 {"CFURLCopyScheme", (PyCFunction
)CFURLRefObj_CFURLCopyScheme
, 1,
2947 "() -> (CFStringRef _rv)"},
2948 {"CFURLCopyNetLocation", (PyCFunction
)CFURLRefObj_CFURLCopyNetLocation
, 1,
2949 "() -> (CFStringRef _rv)"},
2950 {"CFURLCopyPath", (PyCFunction
)CFURLRefObj_CFURLCopyPath
, 1,
2951 "() -> (CFStringRef _rv)"},
2952 {"CFURLCopyStrictPath", (PyCFunction
)CFURLRefObj_CFURLCopyStrictPath
, 1,
2953 "() -> (CFStringRef _rv, Boolean isAbsolute)"},
2954 {"CFURLCopyFileSystemPath", (PyCFunction
)CFURLRefObj_CFURLCopyFileSystemPath
, 1,
2955 "(CFURLPathStyle pathStyle) -> (CFStringRef _rv)"},
2956 {"CFURLHasDirectoryPath", (PyCFunction
)CFURLRefObj_CFURLHasDirectoryPath
, 1,
2957 "() -> (Boolean _rv)"},
2958 {"CFURLCopyResourceSpecifier", (PyCFunction
)CFURLRefObj_CFURLCopyResourceSpecifier
, 1,
2959 "() -> (CFStringRef _rv)"},
2960 {"CFURLCopyHostName", (PyCFunction
)CFURLRefObj_CFURLCopyHostName
, 1,
2961 "() -> (CFStringRef _rv)"},
2962 {"CFURLGetPortNumber", (PyCFunction
)CFURLRefObj_CFURLGetPortNumber
, 1,
2963 "() -> (SInt32 _rv)"},
2964 {"CFURLCopyUserName", (PyCFunction
)CFURLRefObj_CFURLCopyUserName
, 1,
2965 "() -> (CFStringRef _rv)"},
2966 {"CFURLCopyPassword", (PyCFunction
)CFURLRefObj_CFURLCopyPassword
, 1,
2967 "() -> (CFStringRef _rv)"},
2968 {"CFURLCopyParameterString", (PyCFunction
)CFURLRefObj_CFURLCopyParameterString
, 1,
2969 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2970 {"CFURLCopyQueryString", (PyCFunction
)CFURLRefObj_CFURLCopyQueryString
, 1,
2971 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2972 {"CFURLCopyFragment", (PyCFunction
)CFURLRefObj_CFURLCopyFragment
, 1,
2973 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2974 {"CFURLCopyLastPathComponent", (PyCFunction
)CFURLRefObj_CFURLCopyLastPathComponent
, 1,
2975 "() -> (CFStringRef _rv)"},
2976 {"CFURLCopyPathExtension", (PyCFunction
)CFURLRefObj_CFURLCopyPathExtension
, 1,
2977 "() -> (CFStringRef _rv)"},
2978 {"CFURLCreateCopyAppendingPathComponent", (PyCFunction
)CFURLRefObj_CFURLCreateCopyAppendingPathComponent
, 1,
2979 "(CFStringRef pathComponent, Boolean isDirectory) -> (CFURLRef _rv)"},
2980 {"CFURLCreateCopyDeletingLastPathComponent", (PyCFunction
)CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent
, 1,
2981 "() -> (CFURLRef _rv)"},
2982 {"CFURLCreateCopyAppendingPathExtension", (PyCFunction
)CFURLRefObj_CFURLCreateCopyAppendingPathExtension
, 1,
2983 "(CFStringRef extension) -> (CFURLRef _rv)"},
2984 {"CFURLCreateCopyDeletingPathExtension", (PyCFunction
)CFURLRefObj_CFURLCreateCopyDeletingPathExtension
, 1,
2985 "() -> (CFURLRef _rv)"},
2986 {"CFURLGetFSRef", (PyCFunction
)CFURLRefObj_CFURLGetFSRef
, 1,
2987 "() -> (Boolean _rv, FSRef fsRef)"},
2991 PyMethodChain CFURLRefObj_chain
= { CFURLRefObj_methods
, &CFTypeRefObj_chain
};
2993 static PyObject
*CFURLRefObj_getattr(CFURLRefObject
*self
, char *name
)
2995 return Py_FindMethodInChain(&CFURLRefObj_chain
, (PyObject
*)self
, name
);
2998 #define CFURLRefObj_setattr NULL
3000 static int CFURLRefObj_compare(CFURLRefObject
*self
, CFURLRefObject
*other
)
3002 /* XXXX Or should we use CFEqual?? */
3003 if ( self
->ob_itself
> other
->ob_itself
) return 1;
3004 if ( self
->ob_itself
< other
->ob_itself
) return -1;
3008 static PyObject
* CFURLRefObj_repr(CFURLRefObject
*self
)
3011 sprintf(buf
, "<CFURL object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
3012 return PyString_FromString(buf
);
3015 static int CFURLRefObj_hash(CFURLRefObject
*self
)
3017 /* XXXX Or should we use CFHash?? */
3018 return (int)self
->ob_itself
;
3021 PyTypeObject CFURLRef_Type
= {
3022 PyObject_HEAD_INIT(NULL
)
3024 "_CF.CFURLRef", /*tp_name*/
3025 sizeof(CFURLRefObject
), /*tp_basicsize*/
3028 (destructor
) CFURLRefObj_dealloc
, /*tp_dealloc*/
3030 (getattrfunc
) CFURLRefObj_getattr
, /*tp_getattr*/
3031 (setattrfunc
) CFURLRefObj_setattr
, /*tp_setattr*/
3032 (cmpfunc
) CFURLRefObj_compare
, /*tp_compare*/
3033 (reprfunc
) CFURLRefObj_repr
, /*tp_repr*/
3034 (PyNumberMethods
*)0, /* tp_as_number */
3035 (PySequenceMethods
*)0, /* tp_as_sequence */
3036 (PyMappingMethods
*)0, /* tp_as_mapping */
3037 (hashfunc
) CFURLRefObj_hash
, /*tp_hash*/
3040 /* -------------------- End object type CFURLRef -------------------- */
3043 static PyObject
*CF___CFRangeMake(PyObject
*_self
, PyObject
*_args
)
3045 PyObject
*_res
= NULL
;
3049 #ifndef __CFRangeMake
3050 PyMac_PRECHECK(__CFRangeMake
);
3052 if (!PyArg_ParseTuple(_args
, "ll",
3056 _rv
= __CFRangeMake(loc
,
3058 _res
= Py_BuildValue("O&",
3063 static PyObject
*CF_CFAllocatorGetTypeID(PyObject
*_self
, PyObject
*_args
)
3065 PyObject
*_res
= NULL
;
3067 #ifndef CFAllocatorGetTypeID
3068 PyMac_PRECHECK(CFAllocatorGetTypeID
);
3070 if (!PyArg_ParseTuple(_args
, ""))
3072 _rv
= CFAllocatorGetTypeID();
3073 _res
= Py_BuildValue("l",
3078 static PyObject
*CF_CFAllocatorGetPreferredSizeForSize(PyObject
*_self
, PyObject
*_args
)
3080 PyObject
*_res
= NULL
;
3084 #ifndef CFAllocatorGetPreferredSizeForSize
3085 PyMac_PRECHECK(CFAllocatorGetPreferredSizeForSize
);
3087 if (!PyArg_ParseTuple(_args
, "ll",
3091 _rv
= CFAllocatorGetPreferredSizeForSize((CFAllocatorRef
)NULL
,
3094 _res
= Py_BuildValue("l",
3099 static PyObject
*CF_CFCopyTypeIDDescription(PyObject
*_self
, PyObject
*_args
)
3101 PyObject
*_res
= NULL
;
3104 #ifndef CFCopyTypeIDDescription
3105 PyMac_PRECHECK(CFCopyTypeIDDescription
);
3107 if (!PyArg_ParseTuple(_args
, "l",
3110 _rv
= CFCopyTypeIDDescription(type_id
);
3111 _res
= Py_BuildValue("O&",
3112 CFStringRefObj_New
, _rv
);
3116 static PyObject
*CF_CFArrayGetTypeID(PyObject
*_self
, PyObject
*_args
)
3118 PyObject
*_res
= NULL
;
3120 #ifndef CFArrayGetTypeID
3121 PyMac_PRECHECK(CFArrayGetTypeID
);
3123 if (!PyArg_ParseTuple(_args
, ""))
3125 _rv
= CFArrayGetTypeID();
3126 _res
= Py_BuildValue("l",
3131 static PyObject
*CF_CFArrayCreateMutable(PyObject
*_self
, PyObject
*_args
)
3133 PyObject
*_res
= NULL
;
3134 CFMutableArrayRef _rv
;
3136 #ifndef CFArrayCreateMutable
3137 PyMac_PRECHECK(CFArrayCreateMutable
);
3139 if (!PyArg_ParseTuple(_args
, "l",
3142 _rv
= CFArrayCreateMutable((CFAllocatorRef
)NULL
,
3144 &kCFTypeArrayCallBacks
);
3145 _res
= Py_BuildValue("O&",
3146 CFMutableArrayRefObj_New
, _rv
);
3150 static PyObject
*CF_CFArrayCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3152 PyObject
*_res
= NULL
;
3153 CFMutableArrayRef _rv
;
3155 CFArrayRef theArray
;
3156 #ifndef CFArrayCreateMutableCopy
3157 PyMac_PRECHECK(CFArrayCreateMutableCopy
);
3159 if (!PyArg_ParseTuple(_args
, "lO&",
3161 CFArrayRefObj_Convert
, &theArray
))
3163 _rv
= CFArrayCreateMutableCopy((CFAllocatorRef
)NULL
,
3166 _res
= Py_BuildValue("O&",
3167 CFMutableArrayRefObj_New
, _rv
);
3171 static PyObject
*CF_CFDataGetTypeID(PyObject
*_self
, PyObject
*_args
)
3173 PyObject
*_res
= NULL
;
3175 #ifndef CFDataGetTypeID
3176 PyMac_PRECHECK(CFDataGetTypeID
);
3178 if (!PyArg_ParseTuple(_args
, ""))
3180 _rv
= CFDataGetTypeID();
3181 _res
= Py_BuildValue("l",
3186 static PyObject
*CF_CFDataCreate(PyObject
*_self
, PyObject
*_args
)
3188 PyObject
*_res
= NULL
;
3190 unsigned char *bytes__in__
;
3192 int bytes__in_len__
;
3193 #ifndef CFDataCreate
3194 PyMac_PRECHECK(CFDataCreate
);
3196 if (!PyArg_ParseTuple(_args
, "s#",
3197 &bytes__in__
, &bytes__in_len__
))
3199 bytes__len__
= bytes__in_len__
;
3200 _rv
= CFDataCreate((CFAllocatorRef
)NULL
,
3201 bytes__in__
, bytes__len__
);
3202 _res
= Py_BuildValue("O&",
3203 CFDataRefObj_New
, _rv
);
3207 static PyObject
*CF_CFDataCreateWithBytesNoCopy(PyObject
*_self
, PyObject
*_args
)
3209 PyObject
*_res
= NULL
;
3211 unsigned char *bytes__in__
;
3213 int bytes__in_len__
;
3214 #ifndef CFDataCreateWithBytesNoCopy
3215 PyMac_PRECHECK(CFDataCreateWithBytesNoCopy
);
3217 if (!PyArg_ParseTuple(_args
, "s#",
3218 &bytes__in__
, &bytes__in_len__
))
3220 bytes__len__
= bytes__in_len__
;
3221 _rv
= CFDataCreateWithBytesNoCopy((CFAllocatorRef
)NULL
,
3222 bytes__in__
, bytes__len__
,
3223 (CFAllocatorRef
)NULL
);
3224 _res
= Py_BuildValue("O&",
3225 CFDataRefObj_New
, _rv
);
3229 static PyObject
*CF_CFDataCreateMutable(PyObject
*_self
, PyObject
*_args
)
3231 PyObject
*_res
= NULL
;
3232 CFMutableDataRef _rv
;
3234 #ifndef CFDataCreateMutable
3235 PyMac_PRECHECK(CFDataCreateMutable
);
3237 if (!PyArg_ParseTuple(_args
, "l",
3240 _rv
= CFDataCreateMutable((CFAllocatorRef
)NULL
,
3242 _res
= Py_BuildValue("O&",
3243 CFMutableDataRefObj_New
, _rv
);
3247 static PyObject
*CF_CFDataCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3249 PyObject
*_res
= NULL
;
3250 CFMutableDataRef _rv
;
3253 #ifndef CFDataCreateMutableCopy
3254 PyMac_PRECHECK(CFDataCreateMutableCopy
);
3256 if (!PyArg_ParseTuple(_args
, "lO&",
3258 CFDataRefObj_Convert
, &theData
))
3260 _rv
= CFDataCreateMutableCopy((CFAllocatorRef
)NULL
,
3263 _res
= Py_BuildValue("O&",
3264 CFMutableDataRefObj_New
, _rv
);
3268 static PyObject
*CF_CFDictionaryGetTypeID(PyObject
*_self
, PyObject
*_args
)
3270 PyObject
*_res
= NULL
;
3272 #ifndef CFDictionaryGetTypeID
3273 PyMac_PRECHECK(CFDictionaryGetTypeID
);
3275 if (!PyArg_ParseTuple(_args
, ""))
3277 _rv
= CFDictionaryGetTypeID();
3278 _res
= Py_BuildValue("l",
3283 static PyObject
*CF_CFDictionaryCreateMutable(PyObject
*_self
, PyObject
*_args
)
3285 PyObject
*_res
= NULL
;
3286 CFMutableDictionaryRef _rv
;
3288 #ifndef CFDictionaryCreateMutable
3289 PyMac_PRECHECK(CFDictionaryCreateMutable
);
3291 if (!PyArg_ParseTuple(_args
, "l",
3294 _rv
= CFDictionaryCreateMutable((CFAllocatorRef
)NULL
,
3296 &kCFTypeDictionaryKeyCallBacks
,
3297 &kCFTypeDictionaryValueCallBacks
);
3298 _res
= Py_BuildValue("O&",
3299 CFMutableDictionaryRefObj_New
, _rv
);
3303 static PyObject
*CF_CFDictionaryCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3305 PyObject
*_res
= NULL
;
3306 CFMutableDictionaryRef _rv
;
3308 CFDictionaryRef theDict
;
3309 #ifndef CFDictionaryCreateMutableCopy
3310 PyMac_PRECHECK(CFDictionaryCreateMutableCopy
);
3312 if (!PyArg_ParseTuple(_args
, "lO&",
3314 CFDictionaryRefObj_Convert
, &theDict
))
3316 _rv
= CFDictionaryCreateMutableCopy((CFAllocatorRef
)NULL
,
3319 _res
= Py_BuildValue("O&",
3320 CFMutableDictionaryRefObj_New
, _rv
);
3324 static PyObject
*CF_CFPreferencesCopyAppValue(PyObject
*_self
, PyObject
*_args
)
3326 PyObject
*_res
= NULL
;
3329 CFStringRef applicationID
;
3330 #ifndef CFPreferencesCopyAppValue
3331 PyMac_PRECHECK(CFPreferencesCopyAppValue
);
3333 if (!PyArg_ParseTuple(_args
, "O&O&",
3334 CFStringRefObj_Convert
, &key
,
3335 CFStringRefObj_Convert
, &applicationID
))
3337 _rv
= CFPreferencesCopyAppValue(key
,
3339 _res
= Py_BuildValue("O&",
3340 CFTypeRefObj_New
, _rv
);
3344 static PyObject
*CF_CFPreferencesGetAppBooleanValue(PyObject
*_self
, PyObject
*_args
)
3346 PyObject
*_res
= NULL
;
3349 CFStringRef applicationID
;
3350 Boolean keyExistsAndHasValidFormat
;
3351 #ifndef CFPreferencesGetAppBooleanValue
3352 PyMac_PRECHECK(CFPreferencesGetAppBooleanValue
);
3354 if (!PyArg_ParseTuple(_args
, "O&O&",
3355 CFStringRefObj_Convert
, &key
,
3356 CFStringRefObj_Convert
, &applicationID
))
3358 _rv
= CFPreferencesGetAppBooleanValue(key
,
3360 &keyExistsAndHasValidFormat
);
3361 _res
= Py_BuildValue("ll",
3363 keyExistsAndHasValidFormat
);
3367 static PyObject
*CF_CFPreferencesGetAppIntegerValue(PyObject
*_self
, PyObject
*_args
)
3369 PyObject
*_res
= NULL
;
3372 CFStringRef applicationID
;
3373 Boolean keyExistsAndHasValidFormat
;
3374 #ifndef CFPreferencesGetAppIntegerValue
3375 PyMac_PRECHECK(CFPreferencesGetAppIntegerValue
);
3377 if (!PyArg_ParseTuple(_args
, "O&O&",
3378 CFStringRefObj_Convert
, &key
,
3379 CFStringRefObj_Convert
, &applicationID
))
3381 _rv
= CFPreferencesGetAppIntegerValue(key
,
3383 &keyExistsAndHasValidFormat
);
3384 _res
= Py_BuildValue("ll",
3386 keyExistsAndHasValidFormat
);
3390 static PyObject
*CF_CFPreferencesSetAppValue(PyObject
*_self
, PyObject
*_args
)
3392 PyObject
*_res
= NULL
;
3395 CFStringRef applicationID
;
3396 #ifndef CFPreferencesSetAppValue
3397 PyMac_PRECHECK(CFPreferencesSetAppValue
);
3399 if (!PyArg_ParseTuple(_args
, "O&O&O&",
3400 CFStringRefObj_Convert
, &key
,
3401 CFTypeRefObj_Convert
, &value
,
3402 CFStringRefObj_Convert
, &applicationID
))
3404 CFPreferencesSetAppValue(key
,
3412 static PyObject
*CF_CFPreferencesAddSuitePreferencesToApp(PyObject
*_self
, PyObject
*_args
)
3414 PyObject
*_res
= NULL
;
3415 CFStringRef applicationID
;
3416 CFStringRef suiteID
;
3417 #ifndef CFPreferencesAddSuitePreferencesToApp
3418 PyMac_PRECHECK(CFPreferencesAddSuitePreferencesToApp
);
3420 if (!PyArg_ParseTuple(_args
, "O&O&",
3421 CFStringRefObj_Convert
, &applicationID
,
3422 CFStringRefObj_Convert
, &suiteID
))
3424 CFPreferencesAddSuitePreferencesToApp(applicationID
,
3431 static PyObject
*CF_CFPreferencesRemoveSuitePreferencesFromApp(PyObject
*_self
, PyObject
*_args
)
3433 PyObject
*_res
= NULL
;
3434 CFStringRef applicationID
;
3435 CFStringRef suiteID
;
3436 #ifndef CFPreferencesRemoveSuitePreferencesFromApp
3437 PyMac_PRECHECK(CFPreferencesRemoveSuitePreferencesFromApp
);
3439 if (!PyArg_ParseTuple(_args
, "O&O&",
3440 CFStringRefObj_Convert
, &applicationID
,
3441 CFStringRefObj_Convert
, &suiteID
))
3443 CFPreferencesRemoveSuitePreferencesFromApp(applicationID
,
3450 static PyObject
*CF_CFPreferencesAppSynchronize(PyObject
*_self
, PyObject
*_args
)
3452 PyObject
*_res
= NULL
;
3454 CFStringRef applicationID
;
3455 #ifndef CFPreferencesAppSynchronize
3456 PyMac_PRECHECK(CFPreferencesAppSynchronize
);
3458 if (!PyArg_ParseTuple(_args
, "O&",
3459 CFStringRefObj_Convert
, &applicationID
))
3461 _rv
= CFPreferencesAppSynchronize(applicationID
);
3462 _res
= Py_BuildValue("l",
3467 static PyObject
*CF_CFPreferencesCopyValue(PyObject
*_self
, PyObject
*_args
)
3469 PyObject
*_res
= NULL
;
3472 CFStringRef applicationID
;
3473 CFStringRef userName
;
3474 CFStringRef hostName
;
3475 #ifndef CFPreferencesCopyValue
3476 PyMac_PRECHECK(CFPreferencesCopyValue
);
3478 if (!PyArg_ParseTuple(_args
, "O&O&O&O&",
3479 CFStringRefObj_Convert
, &key
,
3480 CFStringRefObj_Convert
, &applicationID
,
3481 CFStringRefObj_Convert
, &userName
,
3482 CFStringRefObj_Convert
, &hostName
))
3484 _rv
= CFPreferencesCopyValue(key
,
3488 _res
= Py_BuildValue("O&",
3489 CFTypeRefObj_New
, _rv
);
3493 static PyObject
*CF_CFPreferencesCopyMultiple(PyObject
*_self
, PyObject
*_args
)
3495 PyObject
*_res
= NULL
;
3496 CFDictionaryRef _rv
;
3497 CFArrayRef keysToFetch
;
3498 CFStringRef applicationID
;
3499 CFStringRef userName
;
3500 CFStringRef hostName
;
3501 #ifndef CFPreferencesCopyMultiple
3502 PyMac_PRECHECK(CFPreferencesCopyMultiple
);
3504 if (!PyArg_ParseTuple(_args
, "O&O&O&O&",
3505 CFArrayRefObj_Convert
, &keysToFetch
,
3506 CFStringRefObj_Convert
, &applicationID
,
3507 CFStringRefObj_Convert
, &userName
,
3508 CFStringRefObj_Convert
, &hostName
))
3510 _rv
= CFPreferencesCopyMultiple(keysToFetch
,
3514 _res
= Py_BuildValue("O&",
3515 CFDictionaryRefObj_New
, _rv
);
3519 static PyObject
*CF_CFPreferencesSetValue(PyObject
*_self
, PyObject
*_args
)
3521 PyObject
*_res
= NULL
;
3524 CFStringRef applicationID
;
3525 CFStringRef userName
;
3526 CFStringRef hostName
;
3527 #ifndef CFPreferencesSetValue
3528 PyMac_PRECHECK(CFPreferencesSetValue
);
3530 if (!PyArg_ParseTuple(_args
, "O&O&O&O&O&",
3531 CFStringRefObj_Convert
, &key
,
3532 CFTypeRefObj_Convert
, &value
,
3533 CFStringRefObj_Convert
, &applicationID
,
3534 CFStringRefObj_Convert
, &userName
,
3535 CFStringRefObj_Convert
, &hostName
))
3537 CFPreferencesSetValue(key
,
3547 static PyObject
*CF_CFPreferencesSetMultiple(PyObject
*_self
, PyObject
*_args
)
3549 PyObject
*_res
= NULL
;
3550 CFDictionaryRef keysToSet
;
3551 CFArrayRef keysToRemove
;
3552 CFStringRef applicationID
;
3553 CFStringRef userName
;
3554 CFStringRef hostName
;
3555 #ifndef CFPreferencesSetMultiple
3556 PyMac_PRECHECK(CFPreferencesSetMultiple
);
3558 if (!PyArg_ParseTuple(_args
, "O&O&O&O&O&",
3559 CFDictionaryRefObj_Convert
, &keysToSet
,
3560 CFArrayRefObj_Convert
, &keysToRemove
,
3561 CFStringRefObj_Convert
, &applicationID
,
3562 CFStringRefObj_Convert
, &userName
,
3563 CFStringRefObj_Convert
, &hostName
))
3565 CFPreferencesSetMultiple(keysToSet
,
3575 static PyObject
*CF_CFPreferencesSynchronize(PyObject
*_self
, PyObject
*_args
)
3577 PyObject
*_res
= NULL
;
3579 CFStringRef applicationID
;
3580 CFStringRef userName
;
3581 CFStringRef hostName
;
3582 #ifndef CFPreferencesSynchronize
3583 PyMac_PRECHECK(CFPreferencesSynchronize
);
3585 if (!PyArg_ParseTuple(_args
, "O&O&O&",
3586 CFStringRefObj_Convert
, &applicationID
,
3587 CFStringRefObj_Convert
, &userName
,
3588 CFStringRefObj_Convert
, &hostName
))
3590 _rv
= CFPreferencesSynchronize(applicationID
,
3593 _res
= Py_BuildValue("l",
3598 static PyObject
*CF_CFPreferencesCopyApplicationList(PyObject
*_self
, PyObject
*_args
)
3600 PyObject
*_res
= NULL
;
3602 CFStringRef userName
;
3603 CFStringRef hostName
;
3604 #ifndef CFPreferencesCopyApplicationList
3605 PyMac_PRECHECK(CFPreferencesCopyApplicationList
);
3607 if (!PyArg_ParseTuple(_args
, "O&O&",
3608 CFStringRefObj_Convert
, &userName
,
3609 CFStringRefObj_Convert
, &hostName
))
3611 _rv
= CFPreferencesCopyApplicationList(userName
,
3613 _res
= Py_BuildValue("O&",
3614 CFArrayRefObj_New
, _rv
);
3618 static PyObject
*CF_CFPreferencesCopyKeyList(PyObject
*_self
, PyObject
*_args
)
3620 PyObject
*_res
= NULL
;
3622 CFStringRef applicationID
;
3623 CFStringRef userName
;
3624 CFStringRef hostName
;
3625 #ifndef CFPreferencesCopyKeyList
3626 PyMac_PRECHECK(CFPreferencesCopyKeyList
);
3628 if (!PyArg_ParseTuple(_args
, "O&O&O&",
3629 CFStringRefObj_Convert
, &applicationID
,
3630 CFStringRefObj_Convert
, &userName
,
3631 CFStringRefObj_Convert
, &hostName
))
3633 _rv
= CFPreferencesCopyKeyList(applicationID
,
3636 _res
= Py_BuildValue("O&",
3637 CFArrayRefObj_New
, _rv
);
3641 static PyObject
*CF_CFStringGetTypeID(PyObject
*_self
, PyObject
*_args
)
3643 PyObject
*_res
= NULL
;
3645 #ifndef CFStringGetTypeID
3646 PyMac_PRECHECK(CFStringGetTypeID
);
3648 if (!PyArg_ParseTuple(_args
, ""))
3650 _rv
= CFStringGetTypeID();
3651 _res
= Py_BuildValue("l",
3656 static PyObject
*CF_CFStringCreateWithPascalString(PyObject
*_self
, PyObject
*_args
)
3658 PyObject
*_res
= NULL
;
3661 CFStringEncoding encoding
;
3662 #ifndef CFStringCreateWithPascalString
3663 PyMac_PRECHECK(CFStringCreateWithPascalString
);
3665 if (!PyArg_ParseTuple(_args
, "O&l",
3666 PyMac_GetStr255
, pStr
,
3669 _rv
= CFStringCreateWithPascalString((CFAllocatorRef
)NULL
,
3672 _res
= Py_BuildValue("O&",
3673 CFStringRefObj_New
, _rv
);
3677 static PyObject
*CF_CFStringCreateWithCString(PyObject
*_self
, PyObject
*_args
)
3679 PyObject
*_res
= NULL
;
3682 CFStringEncoding encoding
;
3683 #ifndef CFStringCreateWithCString
3684 PyMac_PRECHECK(CFStringCreateWithCString
);
3686 if (!PyArg_ParseTuple(_args
, "sl",
3690 _rv
= CFStringCreateWithCString((CFAllocatorRef
)NULL
,
3693 _res
= Py_BuildValue("O&",
3694 CFStringRefObj_New
, _rv
);
3698 static PyObject
*CF_CFStringCreateWithCharacters(PyObject
*_self
, PyObject
*_args
)
3700 PyObject
*_res
= NULL
;
3702 UniChar
*chars__in__
;
3703 UniCharCount chars__len__
;
3704 int chars__in_len__
;
3705 #ifndef CFStringCreateWithCharacters
3706 PyMac_PRECHECK(CFStringCreateWithCharacters
);
3708 if (!PyArg_ParseTuple(_args
, "u#",
3709 &chars__in__
, &chars__in_len__
))
3711 chars__len__
= chars__in_len__
;
3712 _rv
= CFStringCreateWithCharacters((CFAllocatorRef
)NULL
,
3713 chars__in__
, chars__len__
);
3714 _res
= Py_BuildValue("O&",
3715 CFStringRefObj_New
, _rv
);
3719 static PyObject
*CF_CFStringCreateWithPascalStringNoCopy(PyObject
*_self
, PyObject
*_args
)
3721 PyObject
*_res
= NULL
;
3724 CFStringEncoding encoding
;
3725 #ifndef CFStringCreateWithPascalStringNoCopy
3726 PyMac_PRECHECK(CFStringCreateWithPascalStringNoCopy
);
3728 if (!PyArg_ParseTuple(_args
, "O&l",
3729 PyMac_GetStr255
, pStr
,
3732 _rv
= CFStringCreateWithPascalStringNoCopy((CFAllocatorRef
)NULL
,
3735 (CFAllocatorRef
)NULL
);
3736 _res
= Py_BuildValue("O&",
3737 CFStringRefObj_New
, _rv
);
3741 static PyObject
*CF_CFStringCreateWithCStringNoCopy(PyObject
*_self
, PyObject
*_args
)
3743 PyObject
*_res
= NULL
;
3746 CFStringEncoding encoding
;
3747 #ifndef CFStringCreateWithCStringNoCopy
3748 PyMac_PRECHECK(CFStringCreateWithCStringNoCopy
);
3750 if (!PyArg_ParseTuple(_args
, "sl",
3754 _rv
= CFStringCreateWithCStringNoCopy((CFAllocatorRef
)NULL
,
3757 (CFAllocatorRef
)NULL
);
3758 _res
= Py_BuildValue("O&",
3759 CFStringRefObj_New
, _rv
);
3763 static PyObject
*CF_CFStringCreateWithCharactersNoCopy(PyObject
*_self
, PyObject
*_args
)
3765 PyObject
*_res
= NULL
;
3767 UniChar
*chars__in__
;
3768 UniCharCount chars__len__
;
3769 int chars__in_len__
;
3770 #ifndef CFStringCreateWithCharactersNoCopy
3771 PyMac_PRECHECK(CFStringCreateWithCharactersNoCopy
);
3773 if (!PyArg_ParseTuple(_args
, "u#",
3774 &chars__in__
, &chars__in_len__
))
3776 chars__len__
= chars__in_len__
;
3777 _rv
= CFStringCreateWithCharactersNoCopy((CFAllocatorRef
)NULL
,
3778 chars__in__
, chars__len__
,
3779 (CFAllocatorRef
)NULL
);
3780 _res
= Py_BuildValue("O&",
3781 CFStringRefObj_New
, _rv
);
3785 static PyObject
*CF_CFStringCreateMutable(PyObject
*_self
, PyObject
*_args
)
3787 PyObject
*_res
= NULL
;
3788 CFMutableStringRef _rv
;
3790 #ifndef CFStringCreateMutable
3791 PyMac_PRECHECK(CFStringCreateMutable
);
3793 if (!PyArg_ParseTuple(_args
, "l",
3796 _rv
= CFStringCreateMutable((CFAllocatorRef
)NULL
,
3798 _res
= Py_BuildValue("O&",
3799 CFMutableStringRefObj_New
, _rv
);
3803 static PyObject
*CF_CFStringCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3805 PyObject
*_res
= NULL
;
3806 CFMutableStringRef _rv
;
3808 CFStringRef theString
;
3809 #ifndef CFStringCreateMutableCopy
3810 PyMac_PRECHECK(CFStringCreateMutableCopy
);
3812 if (!PyArg_ParseTuple(_args
, "lO&",
3814 CFStringRefObj_Convert
, &theString
))
3816 _rv
= CFStringCreateMutableCopy((CFAllocatorRef
)NULL
,
3819 _res
= Py_BuildValue("O&",
3820 CFMutableStringRefObj_New
, _rv
);
3824 static PyObject
*CF_CFStringCreateWithBytes(PyObject
*_self
, PyObject
*_args
)
3826 PyObject
*_res
= NULL
;
3828 unsigned char *bytes__in__
;
3830 int bytes__in_len__
;
3831 CFStringEncoding encoding
;
3832 Boolean isExternalRepresentation
;
3833 #ifndef CFStringCreateWithBytes
3834 PyMac_PRECHECK(CFStringCreateWithBytes
);
3836 if (!PyArg_ParseTuple(_args
, "s#ll",
3837 &bytes__in__
, &bytes__in_len__
,
3839 &isExternalRepresentation
))
3841 bytes__len__
= bytes__in_len__
;
3842 _rv
= CFStringCreateWithBytes((CFAllocatorRef
)NULL
,
3843 bytes__in__
, bytes__len__
,
3845 isExternalRepresentation
);
3846 _res
= Py_BuildValue("O&",
3847 CFStringRefObj_New
, _rv
);
3851 static PyObject
*CF_CFStringGetSystemEncoding(PyObject
*_self
, PyObject
*_args
)
3853 PyObject
*_res
= NULL
;
3854 CFStringEncoding _rv
;
3855 #ifndef CFStringGetSystemEncoding
3856 PyMac_PRECHECK(CFStringGetSystemEncoding
);
3858 if (!PyArg_ParseTuple(_args
, ""))
3860 _rv
= CFStringGetSystemEncoding();
3861 _res
= Py_BuildValue("l",
3866 static PyObject
*CF_CFStringGetMaximumSizeForEncoding(PyObject
*_self
, PyObject
*_args
)
3868 PyObject
*_res
= NULL
;
3871 CFStringEncoding encoding
;
3872 #ifndef CFStringGetMaximumSizeForEncoding
3873 PyMac_PRECHECK(CFStringGetMaximumSizeForEncoding
);
3875 if (!PyArg_ParseTuple(_args
, "ll",
3879 _rv
= CFStringGetMaximumSizeForEncoding(length
,
3881 _res
= Py_BuildValue("l",
3886 static PyObject
*CF_CFStringIsEncodingAvailable(PyObject
*_self
, PyObject
*_args
)
3888 PyObject
*_res
= NULL
;
3890 CFStringEncoding encoding
;
3891 #ifndef CFStringIsEncodingAvailable
3892 PyMac_PRECHECK(CFStringIsEncodingAvailable
);
3894 if (!PyArg_ParseTuple(_args
, "l",
3897 _rv
= CFStringIsEncodingAvailable(encoding
);
3898 _res
= Py_BuildValue("l",
3903 static PyObject
*CF_CFStringGetNameOfEncoding(PyObject
*_self
, PyObject
*_args
)
3905 PyObject
*_res
= NULL
;
3907 CFStringEncoding encoding
;
3908 #ifndef CFStringGetNameOfEncoding
3909 PyMac_PRECHECK(CFStringGetNameOfEncoding
);
3911 if (!PyArg_ParseTuple(_args
, "l",
3914 _rv
= CFStringGetNameOfEncoding(encoding
);
3915 _res
= Py_BuildValue("O&",
3916 CFStringRefObj_New
, _rv
);
3920 static PyObject
*CF_CFStringConvertEncodingToNSStringEncoding(PyObject
*_self
, PyObject
*_args
)
3922 PyObject
*_res
= NULL
;
3924 CFStringEncoding encoding
;
3925 #ifndef CFStringConvertEncodingToNSStringEncoding
3926 PyMac_PRECHECK(CFStringConvertEncodingToNSStringEncoding
);
3928 if (!PyArg_ParseTuple(_args
, "l",
3931 _rv
= CFStringConvertEncodingToNSStringEncoding(encoding
);
3932 _res
= Py_BuildValue("l",
3937 static PyObject
*CF_CFStringConvertNSStringEncodingToEncoding(PyObject
*_self
, PyObject
*_args
)
3939 PyObject
*_res
= NULL
;
3940 CFStringEncoding _rv
;
3942 #ifndef CFStringConvertNSStringEncodingToEncoding
3943 PyMac_PRECHECK(CFStringConvertNSStringEncodingToEncoding
);
3945 if (!PyArg_ParseTuple(_args
, "l",
3948 _rv
= CFStringConvertNSStringEncodingToEncoding(encoding
);
3949 _res
= Py_BuildValue("l",
3954 static PyObject
*CF_CFStringConvertEncodingToWindowsCodepage(PyObject
*_self
, PyObject
*_args
)
3956 PyObject
*_res
= NULL
;
3958 CFStringEncoding encoding
;
3959 #ifndef CFStringConvertEncodingToWindowsCodepage
3960 PyMac_PRECHECK(CFStringConvertEncodingToWindowsCodepage
);
3962 if (!PyArg_ParseTuple(_args
, "l",
3965 _rv
= CFStringConvertEncodingToWindowsCodepage(encoding
);
3966 _res
= Py_BuildValue("l",
3971 static PyObject
*CF_CFStringConvertWindowsCodepageToEncoding(PyObject
*_self
, PyObject
*_args
)
3973 PyObject
*_res
= NULL
;
3974 CFStringEncoding _rv
;
3976 #ifndef CFStringConvertWindowsCodepageToEncoding
3977 PyMac_PRECHECK(CFStringConvertWindowsCodepageToEncoding
);
3979 if (!PyArg_ParseTuple(_args
, "l",
3982 _rv
= CFStringConvertWindowsCodepageToEncoding(codepage
);
3983 _res
= Py_BuildValue("l",
3988 static PyObject
*CF_CFStringConvertEncodingToIANACharSetName(PyObject
*_self
, PyObject
*_args
)
3990 PyObject
*_res
= NULL
;
3992 CFStringEncoding encoding
;
3993 #ifndef CFStringConvertEncodingToIANACharSetName
3994 PyMac_PRECHECK(CFStringConvertEncodingToIANACharSetName
);
3996 if (!PyArg_ParseTuple(_args
, "l",
3999 _rv
= CFStringConvertEncodingToIANACharSetName(encoding
);
4000 _res
= Py_BuildValue("O&",
4001 CFStringRefObj_New
, _rv
);
4005 static PyObject
*CF_CFStringGetMostCompatibleMacStringEncoding(PyObject
*_self
, PyObject
*_args
)
4007 PyObject
*_res
= NULL
;
4008 CFStringEncoding _rv
;
4009 CFStringEncoding encoding
;
4010 #ifndef CFStringGetMostCompatibleMacStringEncoding
4011 PyMac_PRECHECK(CFStringGetMostCompatibleMacStringEncoding
);
4013 if (!PyArg_ParseTuple(_args
, "l",
4016 _rv
= CFStringGetMostCompatibleMacStringEncoding(encoding
);
4017 _res
= Py_BuildValue("l",
4022 static PyObject
*CF___CFStringMakeConstantString(PyObject
*_self
, PyObject
*_args
)
4024 PyObject
*_res
= NULL
;
4027 #ifndef __CFStringMakeConstantString
4028 PyMac_PRECHECK(__CFStringMakeConstantString
);
4030 if (!PyArg_ParseTuple(_args
, "s",
4033 _rv
= __CFStringMakeConstantString(cStr
);
4034 _res
= Py_BuildValue("O&",
4035 CFStringRefObj_New
, _rv
);
4039 static PyObject
*CF_CFURLGetTypeID(PyObject
*_self
, PyObject
*_args
)
4041 PyObject
*_res
= NULL
;
4043 #ifndef CFURLGetTypeID
4044 PyMac_PRECHECK(CFURLGetTypeID
);
4046 if (!PyArg_ParseTuple(_args
, ""))
4048 _rv
= CFURLGetTypeID();
4049 _res
= Py_BuildValue("l",
4054 static PyObject
*CF_CFURLCreateWithBytes(PyObject
*_self
, PyObject
*_args
)
4056 PyObject
*_res
= NULL
;
4058 unsigned char *URLBytes__in__
;
4059 long URLBytes__len__
;
4060 int URLBytes__in_len__
;
4061 CFStringEncoding encoding
;
4063 #ifndef CFURLCreateWithBytes
4064 PyMac_PRECHECK(CFURLCreateWithBytes
);
4066 if (!PyArg_ParseTuple(_args
, "s#lO&",
4067 &URLBytes__in__
, &URLBytes__in_len__
,
4069 OptionalCFURLRefObj_Convert
, &baseURL
))
4071 URLBytes__len__
= URLBytes__in_len__
;
4072 _rv
= CFURLCreateWithBytes((CFAllocatorRef
)NULL
,
4073 URLBytes__in__
, URLBytes__len__
,
4076 _res
= Py_BuildValue("O&",
4077 CFURLRefObj_New
, _rv
);
4081 static PyObject
*CF_CFURLCreateFromFileSystemRepresentation(PyObject
*_self
, PyObject
*_args
)
4083 PyObject
*_res
= NULL
;
4085 unsigned char *buffer__in__
;
4087 int buffer__in_len__
;
4088 Boolean isDirectory
;
4089 #ifndef CFURLCreateFromFileSystemRepresentation
4090 PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentation
);
4092 if (!PyArg_ParseTuple(_args
, "s#l",
4093 &buffer__in__
, &buffer__in_len__
,
4096 buffer__len__
= buffer__in_len__
;
4097 _rv
= CFURLCreateFromFileSystemRepresentation((CFAllocatorRef
)NULL
,
4098 buffer__in__
, buffer__len__
,
4100 _res
= Py_BuildValue("O&",
4101 CFURLRefObj_New
, _rv
);
4105 static PyObject
*CF_CFURLCreateFromFileSystemRepresentationRelativeToBase(PyObject
*_self
, PyObject
*_args
)
4107 PyObject
*_res
= NULL
;
4109 unsigned char *buffer__in__
;
4111 int buffer__in_len__
;
4112 Boolean isDirectory
;
4114 #ifndef CFURLCreateFromFileSystemRepresentationRelativeToBase
4115 PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentationRelativeToBase
);
4117 if (!PyArg_ParseTuple(_args
, "s#lO&",
4118 &buffer__in__
, &buffer__in_len__
,
4120 OptionalCFURLRefObj_Convert
, &baseURL
))
4122 buffer__len__
= buffer__in_len__
;
4123 _rv
= CFURLCreateFromFileSystemRepresentationRelativeToBase((CFAllocatorRef
)NULL
,
4124 buffer__in__
, buffer__len__
,
4127 _res
= Py_BuildValue("O&",
4128 CFURLRefObj_New
, _rv
);
4132 static PyObject
*CF_CFURLCreateFromFSRef(PyObject
*_self
, PyObject
*_args
)
4134 PyObject
*_res
= NULL
;
4137 #ifndef CFURLCreateFromFSRef
4138 PyMac_PRECHECK(CFURLCreateFromFSRef
);
4140 if (!PyArg_ParseTuple(_args
, "O&",
4141 PyMac_GetFSRef
, &fsRef
))
4143 _rv
= CFURLCreateFromFSRef((CFAllocatorRef
)NULL
,
4145 _res
= Py_BuildValue("O&",
4146 CFURLRefObj_New
, _rv
);
4150 static PyObject
*CF_toCF(PyObject
*_self
, PyObject
*_args
)
4152 PyObject
*_res
= NULL
;
4157 if (!PyArg_ParseTuple(_args
, "O&", PyCF_Python2CF
, &rv
))
4159 typeid = CFGetTypeID(rv
);
4161 if (typeid == CFStringGetTypeID())
4162 return Py_BuildValue("O&", CFStringRefObj_New
, rv
);
4163 if (typeid == CFArrayGetTypeID())
4164 return Py_BuildValue("O&", CFArrayRefObj_New
, rv
);
4165 if (typeid == CFDictionaryGetTypeID())
4166 return Py_BuildValue("O&", CFDictionaryRefObj_New
, rv
);
4167 if (typeid == CFURLGetTypeID())
4168 return Py_BuildValue("O&", CFURLRefObj_New
, rv
);
4170 return Py_BuildValue("O&", CFTypeRefObj_New
, rv
);
4174 static PyMethodDef CF_methods
[] = {
4175 {"__CFRangeMake", (PyCFunction
)CF___CFRangeMake
, 1,
4176 "(CFIndex loc, CFIndex len) -> (CFRange _rv)"},
4177 {"CFAllocatorGetTypeID", (PyCFunction
)CF_CFAllocatorGetTypeID
, 1,
4178 "() -> (CFTypeID _rv)"},
4179 {"CFAllocatorGetPreferredSizeForSize", (PyCFunction
)CF_CFAllocatorGetPreferredSizeForSize
, 1,
4180 "(CFIndex size, CFOptionFlags hint) -> (CFIndex _rv)"},
4181 {"CFCopyTypeIDDescription", (PyCFunction
)CF_CFCopyTypeIDDescription
, 1,
4182 "(CFTypeID type_id) -> (CFStringRef _rv)"},
4183 {"CFArrayGetTypeID", (PyCFunction
)CF_CFArrayGetTypeID
, 1,
4184 "() -> (CFTypeID _rv)"},
4185 {"CFArrayCreateMutable", (PyCFunction
)CF_CFArrayCreateMutable
, 1,
4186 "(CFIndex capacity) -> (CFMutableArrayRef _rv)"},
4187 {"CFArrayCreateMutableCopy", (PyCFunction
)CF_CFArrayCreateMutableCopy
, 1,
4188 "(CFIndex capacity, CFArrayRef theArray) -> (CFMutableArrayRef _rv)"},
4189 {"CFDataGetTypeID", (PyCFunction
)CF_CFDataGetTypeID
, 1,
4190 "() -> (CFTypeID _rv)"},
4191 {"CFDataCreate", (PyCFunction
)CF_CFDataCreate
, 1,
4192 "(Buffer bytes) -> (CFDataRef _rv)"},
4193 {"CFDataCreateWithBytesNoCopy", (PyCFunction
)CF_CFDataCreateWithBytesNoCopy
, 1,
4194 "(Buffer bytes) -> (CFDataRef _rv)"},
4195 {"CFDataCreateMutable", (PyCFunction
)CF_CFDataCreateMutable
, 1,
4196 "(CFIndex capacity) -> (CFMutableDataRef _rv)"},
4197 {"CFDataCreateMutableCopy", (PyCFunction
)CF_CFDataCreateMutableCopy
, 1,
4198 "(CFIndex capacity, CFDataRef theData) -> (CFMutableDataRef _rv)"},
4199 {"CFDictionaryGetTypeID", (PyCFunction
)CF_CFDictionaryGetTypeID
, 1,
4200 "() -> (CFTypeID _rv)"},
4201 {"CFDictionaryCreateMutable", (PyCFunction
)CF_CFDictionaryCreateMutable
, 1,
4202 "(CFIndex capacity) -> (CFMutableDictionaryRef _rv)"},
4203 {"CFDictionaryCreateMutableCopy", (PyCFunction
)CF_CFDictionaryCreateMutableCopy
, 1,
4204 "(CFIndex capacity, CFDictionaryRef theDict) -> (CFMutableDictionaryRef _rv)"},
4205 {"CFPreferencesCopyAppValue", (PyCFunction
)CF_CFPreferencesCopyAppValue
, 1,
4206 "(CFStringRef key, CFStringRef applicationID) -> (CFTypeRef _rv)"},
4207 {"CFPreferencesGetAppBooleanValue", (PyCFunction
)CF_CFPreferencesGetAppBooleanValue
, 1,
4208 "(CFStringRef key, CFStringRef applicationID) -> (Boolean _rv, Boolean keyExistsAndHasValidFormat)"},
4209 {"CFPreferencesGetAppIntegerValue", (PyCFunction
)CF_CFPreferencesGetAppIntegerValue
, 1,
4210 "(CFStringRef key, CFStringRef applicationID) -> (CFIndex _rv, Boolean keyExistsAndHasValidFormat)"},
4211 {"CFPreferencesSetAppValue", (PyCFunction
)CF_CFPreferencesSetAppValue
, 1,
4212 "(CFStringRef key, CFTypeRef value, CFStringRef applicationID) -> None"},
4213 {"CFPreferencesAddSuitePreferencesToApp", (PyCFunction
)CF_CFPreferencesAddSuitePreferencesToApp
, 1,
4214 "(CFStringRef applicationID, CFStringRef suiteID) -> None"},
4215 {"CFPreferencesRemoveSuitePreferencesFromApp", (PyCFunction
)CF_CFPreferencesRemoveSuitePreferencesFromApp
, 1,
4216 "(CFStringRef applicationID, CFStringRef suiteID) -> None"},
4217 {"CFPreferencesAppSynchronize", (PyCFunction
)CF_CFPreferencesAppSynchronize
, 1,
4218 "(CFStringRef applicationID) -> (Boolean _rv)"},
4219 {"CFPreferencesCopyValue", (PyCFunction
)CF_CFPreferencesCopyValue
, 1,
4220 "(CFStringRef key, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFTypeRef _rv)"},
4221 {"CFPreferencesCopyMultiple", (PyCFunction
)CF_CFPreferencesCopyMultiple
, 1,
4222 "(CFArrayRef keysToFetch, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFDictionaryRef _rv)"},
4223 {"CFPreferencesSetValue", (PyCFunction
)CF_CFPreferencesSetValue
, 1,
4224 "(CFStringRef key, CFTypeRef value, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None"},
4225 {"CFPreferencesSetMultiple", (PyCFunction
)CF_CFPreferencesSetMultiple
, 1,
4226 "(CFDictionaryRef keysToSet, CFArrayRef keysToRemove, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None"},
4227 {"CFPreferencesSynchronize", (PyCFunction
)CF_CFPreferencesSynchronize
, 1,
4228 "(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (Boolean _rv)"},
4229 {"CFPreferencesCopyApplicationList", (PyCFunction
)CF_CFPreferencesCopyApplicationList
, 1,
4230 "(CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)"},
4231 {"CFPreferencesCopyKeyList", (PyCFunction
)CF_CFPreferencesCopyKeyList
, 1,
4232 "(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)"},
4233 {"CFStringGetTypeID", (PyCFunction
)CF_CFStringGetTypeID
, 1,
4234 "() -> (CFTypeID _rv)"},
4235 {"CFStringCreateWithPascalString", (PyCFunction
)CF_CFStringCreateWithPascalString
, 1,
4236 "(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
4237 {"CFStringCreateWithCString", (PyCFunction
)CF_CFStringCreateWithCString
, 1,
4238 "(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
4239 {"CFStringCreateWithCharacters", (PyCFunction
)CF_CFStringCreateWithCharacters
, 1,
4240 "(Buffer chars) -> (CFStringRef _rv)"},
4241 {"CFStringCreateWithPascalStringNoCopy", (PyCFunction
)CF_CFStringCreateWithPascalStringNoCopy
, 1,
4242 "(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
4243 {"CFStringCreateWithCStringNoCopy", (PyCFunction
)CF_CFStringCreateWithCStringNoCopy
, 1,
4244 "(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
4245 {"CFStringCreateWithCharactersNoCopy", (PyCFunction
)CF_CFStringCreateWithCharactersNoCopy
, 1,
4246 "(Buffer chars) -> (CFStringRef _rv)"},
4247 {"CFStringCreateMutable", (PyCFunction
)CF_CFStringCreateMutable
, 1,
4248 "(CFIndex maxLength) -> (CFMutableStringRef _rv)"},
4249 {"CFStringCreateMutableCopy", (PyCFunction
)CF_CFStringCreateMutableCopy
, 1,
4250 "(CFIndex maxLength, CFStringRef theString) -> (CFMutableStringRef _rv)"},
4251 {"CFStringCreateWithBytes", (PyCFunction
)CF_CFStringCreateWithBytes
, 1,
4252 "(Buffer bytes, CFStringEncoding encoding, Boolean isExternalRepresentation) -> (CFStringRef _rv)"},
4253 {"CFStringGetSystemEncoding", (PyCFunction
)CF_CFStringGetSystemEncoding
, 1,
4254 "() -> (CFStringEncoding _rv)"},
4255 {"CFStringGetMaximumSizeForEncoding", (PyCFunction
)CF_CFStringGetMaximumSizeForEncoding
, 1,
4256 "(CFIndex length, CFStringEncoding encoding) -> (CFIndex _rv)"},
4257 {"CFStringIsEncodingAvailable", (PyCFunction
)CF_CFStringIsEncodingAvailable
, 1,
4258 "(CFStringEncoding encoding) -> (Boolean _rv)"},
4259 {"CFStringGetNameOfEncoding", (PyCFunction
)CF_CFStringGetNameOfEncoding
, 1,
4260 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
4261 {"CFStringConvertEncodingToNSStringEncoding", (PyCFunction
)CF_CFStringConvertEncodingToNSStringEncoding
, 1,
4262 "(CFStringEncoding encoding) -> (UInt32 _rv)"},
4263 {"CFStringConvertNSStringEncodingToEncoding", (PyCFunction
)CF_CFStringConvertNSStringEncodingToEncoding
, 1,
4264 "(UInt32 encoding) -> (CFStringEncoding _rv)"},
4265 {"CFStringConvertEncodingToWindowsCodepage", (PyCFunction
)CF_CFStringConvertEncodingToWindowsCodepage
, 1,
4266 "(CFStringEncoding encoding) -> (UInt32 _rv)"},
4267 {"CFStringConvertWindowsCodepageToEncoding", (PyCFunction
)CF_CFStringConvertWindowsCodepageToEncoding
, 1,
4268 "(UInt32 codepage) -> (CFStringEncoding _rv)"},
4269 {"CFStringConvertEncodingToIANACharSetName", (PyCFunction
)CF_CFStringConvertEncodingToIANACharSetName
, 1,
4270 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
4271 {"CFStringGetMostCompatibleMacStringEncoding", (PyCFunction
)CF_CFStringGetMostCompatibleMacStringEncoding
, 1,
4272 "(CFStringEncoding encoding) -> (CFStringEncoding _rv)"},
4273 {"__CFStringMakeConstantString", (PyCFunction
)CF___CFStringMakeConstantString
, 1,
4274 "(char* cStr) -> (CFStringRef _rv)"},
4275 {"CFURLGetTypeID", (PyCFunction
)CF_CFURLGetTypeID
, 1,
4276 "() -> (CFTypeID _rv)"},
4277 {"CFURLCreateWithBytes", (PyCFunction
)CF_CFURLCreateWithBytes
, 1,
4278 "(Buffer URLBytes, CFStringEncoding encoding, CFURLRef baseURL) -> (CFURLRef _rv)"},
4279 {"CFURLCreateFromFileSystemRepresentation", (PyCFunction
)CF_CFURLCreateFromFileSystemRepresentation
, 1,
4280 "(Buffer buffer, Boolean isDirectory) -> (CFURLRef _rv)"},
4281 {"CFURLCreateFromFileSystemRepresentationRelativeToBase", (PyCFunction
)CF_CFURLCreateFromFileSystemRepresentationRelativeToBase
, 1,
4282 "(Buffer buffer, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)"},
4283 {"CFURLCreateFromFSRef", (PyCFunction
)CF_CFURLCreateFromFSRef
, 1,
4284 "(FSRef fsRef) -> (CFURLRef _rv)"},
4285 {"toCF", (PyCFunction
)CF_toCF
, 1,
4286 "(python_object) -> (CF_object)"},
4300 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFTypeRef
, CFTypeRefObj_New
);
4301 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFTypeRef
, CFTypeRefObj_Convert
);
4302 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFStringRef
, CFStringRefObj_New
);
4303 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFStringRef
, CFStringRefObj_Convert
);
4304 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableStringRef
, CFMutableStringRefObj_New
);
4305 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableStringRef
, CFMutableStringRefObj_Convert
);
4307 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFArrayRef
, CFArrayRefObj_New
);
4308 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFArrayRef
, CFArrayRefObj_Convert
);
4309 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableArrayRef
, CFMutableArrayRefObj_New
);
4310 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableArrayRef
, CFMutableArrayRefObj_Convert
);
4311 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFDictionaryRef
, CFDictionaryRefObj_New
);
4312 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFDictionaryRef
, CFDictionaryRefObj_Convert
);
4313 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableDictionaryRef
, CFMutableDictionaryRefObj_New
);
4314 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableDictionaryRef
, CFMutableDictionaryRefObj_Convert
);
4315 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFURLRef
, CFURLRefObj_New
);
4316 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef
, CFURLRefObj_Convert
);
4317 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef
, CFURLRefObj_Convert
);
4320 m
= Py_InitModule("_CF", CF_methods
);
4321 d
= PyModule_GetDict(m
);
4322 CF_Error
= PyMac_GetOSErrException();
4323 if (CF_Error
== NULL
||
4324 PyDict_SetItemString(d
, "Error", CF_Error
) != 0)
4326 CFTypeRef_Type
.ob_type
= &PyType_Type
;
4327 Py_INCREF(&CFTypeRef_Type
);
4328 if (PyDict_SetItemString(d
, "CFTypeRefType", (PyObject
*)&CFTypeRef_Type
) != 0)
4329 Py_FatalError("can't initialize CFTypeRefType");
4330 CFArrayRef_Type
.ob_type
= &PyType_Type
;
4331 Py_INCREF(&CFArrayRef_Type
);
4332 if (PyDict_SetItemString(d
, "CFArrayRefType", (PyObject
*)&CFArrayRef_Type
) != 0)
4333 Py_FatalError("can't initialize CFArrayRefType");
4334 CFMutableArrayRef_Type
.ob_type
= &PyType_Type
;
4335 Py_INCREF(&CFMutableArrayRef_Type
);
4336 if (PyDict_SetItemString(d
, "CFMutableArrayRefType", (PyObject
*)&CFMutableArrayRef_Type
) != 0)
4337 Py_FatalError("can't initialize CFMutableArrayRefType");
4338 CFDictionaryRef_Type
.ob_type
= &PyType_Type
;
4339 Py_INCREF(&CFDictionaryRef_Type
);
4340 if (PyDict_SetItemString(d
, "CFDictionaryRefType", (PyObject
*)&CFDictionaryRef_Type
) != 0)
4341 Py_FatalError("can't initialize CFDictionaryRefType");
4342 CFMutableDictionaryRef_Type
.ob_type
= &PyType_Type
;
4343 Py_INCREF(&CFMutableDictionaryRef_Type
);
4344 if (PyDict_SetItemString(d
, "CFMutableDictionaryRefType", (PyObject
*)&CFMutableDictionaryRef_Type
) != 0)
4345 Py_FatalError("can't initialize CFMutableDictionaryRefType");
4346 CFDataRef_Type
.ob_type
= &PyType_Type
;
4347 Py_INCREF(&CFDataRef_Type
);
4348 if (PyDict_SetItemString(d
, "CFDataRefType", (PyObject
*)&CFDataRef_Type
) != 0)
4349 Py_FatalError("can't initialize CFDataRefType");
4350 CFMutableDataRef_Type
.ob_type
= &PyType_Type
;
4351 Py_INCREF(&CFMutableDataRef_Type
);
4352 if (PyDict_SetItemString(d
, "CFMutableDataRefType", (PyObject
*)&CFMutableDataRef_Type
) != 0)
4353 Py_FatalError("can't initialize CFMutableDataRefType");
4354 CFStringRef_Type
.ob_type
= &PyType_Type
;
4355 Py_INCREF(&CFStringRef_Type
);
4356 if (PyDict_SetItemString(d
, "CFStringRefType", (PyObject
*)&CFStringRef_Type
) != 0)
4357 Py_FatalError("can't initialize CFStringRefType");
4358 CFMutableStringRef_Type
.ob_type
= &PyType_Type
;
4359 Py_INCREF(&CFMutableStringRef_Type
);
4360 if (PyDict_SetItemString(d
, "CFMutableStringRefType", (PyObject
*)&CFMutableStringRef_Type
) != 0)
4361 Py_FatalError("can't initialize CFMutableStringRefType");
4362 CFURLRef_Type
.ob_type
= &PyType_Type
;
4363 Py_INCREF(&CFURLRef_Type
);
4364 if (PyDict_SetItemString(d
, "CFURLRefType", (PyObject
*)&CFURLRef_Type
) != 0)
4365 Py_FatalError("can't initialize CFURLRefType");
4367 #define _STRINGCONST(name) PyModule_AddObject(m, #name, CFStringRefObj_New(name))
4368 _STRINGCONST(kCFPreferencesAnyApplication
);
4369 _STRINGCONST(kCFPreferencesCurrentApplication
);
4370 _STRINGCONST(kCFPreferencesAnyHost
);
4371 _STRINGCONST(kCFPreferencesCurrentHost
);
4372 _STRINGCONST(kCFPreferencesAnyUser
);
4373 _STRINGCONST(kCFPreferencesCurrentUser
);
4379 /* ========================= End module _CF ========================= */