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>
31 #include <CoreServices/CoreServices.h>
34 #ifdef USE_TOOLBOX_OBJECT_GLUE
35 extern PyObject
*_CFTypeRefObj_New(CFTypeRef
);
36 extern int _CFTypeRefObj_Convert(PyObject
*, CFTypeRef
*);
37 #define CFTypeRefObj_New _CFTypeRefObj_New
38 #define CFTypeRefObj_Convert _CFTypeRefObj_Convert
40 extern PyObject
*_CFStringRefObj_New(CFStringRef
);
41 extern int _CFStringRefObj_Convert(PyObject
*, CFStringRef
*);
42 #define CFStringRefObj_New _CFStringRefObj_New
43 #define CFStringRefObj_Convert _CFStringRefObj_Convert
45 extern PyObject
*_CFMutableStringRefObj_New(CFMutableStringRef
);
46 extern int _CFMutableStringRefObj_Convert(PyObject
*, CFMutableStringRef
*);
47 #define CFMutableStringRefObj_New _CFMutableStringRefObj_New
48 #define CFMutableStringRefObj_Convert _CFMutableStringRefObj_Convert
50 extern PyObject
*_CFArrayRefObj_New(CFArrayRef
);
51 extern int _CFArrayRefObj_Convert(PyObject
*, CFArrayRef
*);
52 #define CFArrayRefObj_New _CFArrayRefObj_New
53 #define CFArrayRefObj_Convert _CFArrayRefObj_Convert
55 extern PyObject
*_CFMutableArrayRefObj_New(CFMutableArrayRef
);
56 extern int _CFMutableArrayRefObj_Convert(PyObject
*, CFMutableArrayRef
*);
57 #define CFMutableArrayRefObj_New _CFMutableArrayRefObj_New
58 #define CFMutableArrayRefObj_Convert _CFMutableArrayRefObj_Convert
60 extern PyObject
*_CFDataRefObj_New(CFDataRef
);
61 extern int _CFDataRefObj_Convert(PyObject
*, CFDataRef
*);
62 #define CFDataRefObj_New _CFDataRefObj_New
63 #define CFDataRefObj_Convert _CFDataRefObj_Convert
65 extern PyObject
*_CFMutableDataRefObj_New(CFMutableDataRef
);
66 extern int _CFMutableDataRefObj_Convert(PyObject
*, CFMutableDataRef
*);
67 #define CFMutableDataRefObj_New _CFMutableDataRefObj_New
68 #define CFMutableDataRefObj_Convert _CFMutableDataRefObj_Convert
70 extern PyObject
*_CFDictionaryRefObj_New(CFDictionaryRef
);
71 extern int _CFDictionaryRefObj_Convert(PyObject
*, CFDictionaryRef
*);
72 #define CFDictionaryRefObj_New _CFDictionaryRefObj_New
73 #define CFDictionaryRefObj_Convert _CFDictionaryRefObj_Convert
75 extern PyObject
*_CFMutableDictionaryRefObj_New(CFMutableDictionaryRef
);
76 extern int _CFMutableDictionaryRefObj_Convert(PyObject
*, CFMutableDictionaryRef
*);
77 #define CFMutableDictionaryRefObj_New _CFMutableDictionaryRefObj_New
78 #define CFMutableDictionaryRefObj_Convert _CFMutableDictionaryRefObj_Convert
80 extern PyObject
*_CFURLRefObj_New(CFURLRef
);
81 extern int _CFURLRefObj_Convert(PyObject
*, CFURLRef
*);
82 extern int _OptionalCFURLRefObj_Convert(PyObject
*, CFURLRef
*);
83 #define CFURLRefObj_New _CFURLRefObj_New
84 #define CFURLRefObj_Convert _CFURLRefObj_Convert
85 #define OptionalCFURLRefObj_Convert _OptionalCFURLRefObj_Convert
89 ** Parse/generate CFRange records
91 PyObject
*CFRange_New(CFRange
*itself
)
94 return Py_BuildValue("ll", (long)itself
->location
, (long)itself
->length
);
98 CFRange_Convert(PyObject
*v
, CFRange
*p_itself
)
100 long location
, length
;
102 if( !PyArg_ParseTuple(v
, "ll", &location
, &length
) )
104 p_itself
->location
= (CFIndex
)location
;
105 p_itself
->length
= (CFIndex
)length
;
109 /* Optional CFURL argument or None (passed as NULL) */
111 OptionalCFURLRefObj_Convert(PyObject
*v
, CFURLRef
*p_itself
)
113 if ( v
== Py_None
) {
117 return CFURLRefObj_Convert(v
, p_itself
);
121 static PyObject
*CF_Error
;
123 /* --------------------- Object type CFTypeRef ---------------------- */
125 PyTypeObject CFTypeRef_Type
;
127 #define CFTypeRefObj_Check(x) ((x)->ob_type == &CFTypeRef_Type)
129 typedef struct CFTypeRefObject
{
132 void (*ob_freeit
)(CFTypeRef ptr
);
135 PyObject
*CFTypeRefObj_New(CFTypeRef itself
)
138 if (itself
== NULL
) return PyMac_Error(resNotFound
);
139 it
= PyObject_NEW(CFTypeRefObject
, &CFTypeRef_Type
);
140 if (it
== NULL
) return NULL
;
141 it
->ob_itself
= itself
;
142 it
->ob_freeit
= CFRelease
;
143 return (PyObject
*)it
;
145 int CFTypeRefObj_Convert(PyObject
*v
, CFTypeRef
*p_itself
)
148 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
149 /* Check for other CF objects here */
151 if (!CFTypeRefObj_Check(v
))
153 PyErr_SetString(PyExc_TypeError
, "CFTypeRef required");
156 *p_itself
= ((CFTypeRefObject
*)v
)->ob_itself
;
160 static void CFTypeRefObj_dealloc(CFTypeRefObject
*self
)
162 if (self
->ob_freeit
&& self
->ob_itself
)
164 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
169 static PyObject
*CFTypeRefObj_CFGetTypeID(CFTypeRefObject
*_self
, PyObject
*_args
)
171 PyObject
*_res
= NULL
;
174 PyMac_PRECHECK(CFGetTypeID
);
176 if (!PyArg_ParseTuple(_args
, ""))
178 _rv
= CFGetTypeID(_self
->ob_itself
);
179 _res
= Py_BuildValue("l",
184 static PyObject
*CFTypeRefObj_CFRetain(CFTypeRefObject
*_self
, PyObject
*_args
)
186 PyObject
*_res
= NULL
;
189 PyMac_PRECHECK(CFRetain
);
191 if (!PyArg_ParseTuple(_args
, ""))
193 _rv
= CFRetain(_self
->ob_itself
);
194 _res
= Py_BuildValue("O&",
195 CFTypeRefObj_New
, _rv
);
199 static PyObject
*CFTypeRefObj_CFRelease(CFTypeRefObject
*_self
, PyObject
*_args
)
201 PyObject
*_res
= NULL
;
203 PyMac_PRECHECK(CFRelease
);
205 if (!PyArg_ParseTuple(_args
, ""))
207 CFRelease(_self
->ob_itself
);
213 static PyObject
*CFTypeRefObj_CFGetRetainCount(CFTypeRefObject
*_self
, PyObject
*_args
)
215 PyObject
*_res
= NULL
;
217 #ifndef CFGetRetainCount
218 PyMac_PRECHECK(CFGetRetainCount
);
220 if (!PyArg_ParseTuple(_args
, ""))
222 _rv
= CFGetRetainCount(_self
->ob_itself
);
223 _res
= Py_BuildValue("l",
228 static PyObject
*CFTypeRefObj_CFEqual(CFTypeRefObject
*_self
, PyObject
*_args
)
230 PyObject
*_res
= NULL
;
234 PyMac_PRECHECK(CFEqual
);
236 if (!PyArg_ParseTuple(_args
, "O&",
237 CFTypeRefObj_Convert
, &cf2
))
239 _rv
= CFEqual(_self
->ob_itself
,
241 _res
= Py_BuildValue("l",
246 static PyObject
*CFTypeRefObj_CFHash(CFTypeRefObject
*_self
, PyObject
*_args
)
248 PyObject
*_res
= NULL
;
251 PyMac_PRECHECK(CFHash
);
253 if (!PyArg_ParseTuple(_args
, ""))
255 _rv
= CFHash(_self
->ob_itself
);
256 _res
= Py_BuildValue("l",
261 static PyObject
*CFTypeRefObj_CFCopyDescription(CFTypeRefObject
*_self
, PyObject
*_args
)
263 PyObject
*_res
= NULL
;
265 #ifndef CFCopyDescription
266 PyMac_PRECHECK(CFCopyDescription
);
268 if (!PyArg_ParseTuple(_args
, ""))
270 _rv
= CFCopyDescription(_self
->ob_itself
);
271 _res
= Py_BuildValue("O&",
272 CFStringRefObj_New
, _rv
);
276 static PyObject
*CFTypeRefObj_CFShow(CFTypeRefObject
*_self
, PyObject
*_args
)
278 PyObject
*_res
= NULL
;
280 PyMac_PRECHECK(CFShow
);
282 if (!PyArg_ParseTuple(_args
, ""))
284 CFShow(_self
->ob_itself
);
290 static PyMethodDef CFTypeRefObj_methods
[] = {
291 {"CFGetTypeID", (PyCFunction
)CFTypeRefObj_CFGetTypeID
, 1,
292 "() -> (CFTypeID _rv)"},
293 {"CFRetain", (PyCFunction
)CFTypeRefObj_CFRetain
, 1,
294 "() -> (CFTypeRef _rv)"},
295 {"CFRelease", (PyCFunction
)CFTypeRefObj_CFRelease
, 1,
297 {"CFGetRetainCount", (PyCFunction
)CFTypeRefObj_CFGetRetainCount
, 1,
298 "() -> (CFIndex _rv)"},
299 {"CFEqual", (PyCFunction
)CFTypeRefObj_CFEqual
, 1,
300 "(CFTypeRef cf2) -> (Boolean _rv)"},
301 {"CFHash", (PyCFunction
)CFTypeRefObj_CFHash
, 1,
302 "() -> (CFHashCode _rv)"},
303 {"CFCopyDescription", (PyCFunction
)CFTypeRefObj_CFCopyDescription
, 1,
304 "() -> (CFStringRef _rv)"},
305 {"CFShow", (PyCFunction
)CFTypeRefObj_CFShow
, 1,
310 PyMethodChain CFTypeRefObj_chain
= { CFTypeRefObj_methods
, NULL
};
312 static PyObject
*CFTypeRefObj_getattr(CFTypeRefObject
*self
, char *name
)
314 return Py_FindMethodInChain(&CFTypeRefObj_chain
, (PyObject
*)self
, name
);
317 #define CFTypeRefObj_setattr NULL
319 static int CFTypeRefObj_compare(CFTypeRefObject
*self
, CFTypeRefObject
*other
)
321 /* XXXX Or should we use CFEqual?? */
322 if ( self
->ob_itself
> other
->ob_itself
) return 1;
323 if ( self
->ob_itself
< other
->ob_itself
) return -1;
327 static PyObject
* CFTypeRefObj_repr(CFTypeRefObject
*self
)
330 sprintf(buf
, "<CFTypeRef type-%d object at 0x%8.8x for 0x%8.8x>", CFGetTypeID(self
->ob_itself
), (unsigned)self
, (unsigned)self
->ob_itself
);
331 return PyString_FromString(buf
);
334 static int CFTypeRefObj_hash(CFTypeRefObject
*self
)
336 /* XXXX Or should we use CFHash?? */
337 return (int)self
->ob_itself
;
340 PyTypeObject CFTypeRef_Type
= {
341 PyObject_HEAD_INIT(NULL
)
343 "_CF.CFTypeRef", /*tp_name*/
344 sizeof(CFTypeRefObject
), /*tp_basicsize*/
347 (destructor
) CFTypeRefObj_dealloc
, /*tp_dealloc*/
349 (getattrfunc
) CFTypeRefObj_getattr
, /*tp_getattr*/
350 (setattrfunc
) CFTypeRefObj_setattr
, /*tp_setattr*/
351 (cmpfunc
) CFTypeRefObj_compare
, /*tp_compare*/
352 (reprfunc
) CFTypeRefObj_repr
, /*tp_repr*/
353 (PyNumberMethods
*)0, /* tp_as_number */
354 (PySequenceMethods
*)0, /* tp_as_sequence */
355 (PyMappingMethods
*)0, /* tp_as_mapping */
356 (hashfunc
) CFTypeRefObj_hash
, /*tp_hash*/
359 /* ------------------- End object type CFTypeRef -------------------- */
362 /* --------------------- Object type CFArrayRef --------------------- */
364 PyTypeObject CFArrayRef_Type
;
366 #define CFArrayRefObj_Check(x) ((x)->ob_type == &CFArrayRef_Type)
368 typedef struct CFArrayRefObject
{
370 CFArrayRef ob_itself
;
371 void (*ob_freeit
)(CFTypeRef ptr
);
374 PyObject
*CFArrayRefObj_New(CFArrayRef itself
)
376 CFArrayRefObject
*it
;
377 if (itself
== NULL
) return PyMac_Error(resNotFound
);
378 it
= PyObject_NEW(CFArrayRefObject
, &CFArrayRef_Type
);
379 if (it
== NULL
) return NULL
;
380 it
->ob_itself
= itself
;
381 it
->ob_freeit
= CFRelease
;
382 return (PyObject
*)it
;
384 int CFArrayRefObj_Convert(PyObject
*v
, CFArrayRef
*p_itself
)
387 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
388 /* Check for other CF objects here */
390 if (!CFArrayRefObj_Check(v
))
392 PyErr_SetString(PyExc_TypeError
, "CFArrayRef required");
395 *p_itself
= ((CFArrayRefObject
*)v
)->ob_itself
;
399 static void CFArrayRefObj_dealloc(CFArrayRefObject
*self
)
401 if (self
->ob_freeit
&& self
->ob_itself
)
403 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
408 static PyObject
*CFArrayRefObj_CFArrayCreateCopy(CFArrayRefObject
*_self
, PyObject
*_args
)
410 PyObject
*_res
= NULL
;
412 if (!PyArg_ParseTuple(_args
, ""))
414 _rv
= CFArrayCreateCopy((CFAllocatorRef
)NULL
,
416 _res
= Py_BuildValue("O&",
417 CFArrayRefObj_New
, _rv
);
421 static PyObject
*CFArrayRefObj_CFArrayGetCount(CFArrayRefObject
*_self
, PyObject
*_args
)
423 PyObject
*_res
= NULL
;
425 #ifndef CFArrayGetCount
426 PyMac_PRECHECK(CFArrayGetCount
);
428 if (!PyArg_ParseTuple(_args
, ""))
430 _rv
= CFArrayGetCount(_self
->ob_itself
);
431 _res
= Py_BuildValue("l",
436 static PyObject
*CFArrayRefObj_CFStringCreateByCombiningStrings(CFArrayRefObject
*_self
, PyObject
*_args
)
438 PyObject
*_res
= NULL
;
440 CFStringRef separatorString
;
441 if (!PyArg_ParseTuple(_args
, "O&",
442 CFStringRefObj_Convert
, &separatorString
))
444 _rv
= CFStringCreateByCombiningStrings((CFAllocatorRef
)NULL
,
447 _res
= Py_BuildValue("O&",
448 CFStringRefObj_New
, _rv
);
452 static PyMethodDef CFArrayRefObj_methods
[] = {
453 {"CFArrayCreateCopy", (PyCFunction
)CFArrayRefObj_CFArrayCreateCopy
, 1,
454 "() -> (CFArrayRef _rv)"},
455 {"CFArrayGetCount", (PyCFunction
)CFArrayRefObj_CFArrayGetCount
, 1,
456 "() -> (CFIndex _rv)"},
457 {"CFStringCreateByCombiningStrings", (PyCFunction
)CFArrayRefObj_CFStringCreateByCombiningStrings
, 1,
458 "(CFStringRef separatorString) -> (CFStringRef _rv)"},
462 PyMethodChain CFArrayRefObj_chain
= { CFArrayRefObj_methods
, &CFTypeRefObj_chain
};
464 static PyObject
*CFArrayRefObj_getattr(CFArrayRefObject
*self
, char *name
)
466 return Py_FindMethodInChain(&CFArrayRefObj_chain
, (PyObject
*)self
, name
);
469 #define CFArrayRefObj_setattr NULL
471 static int CFArrayRefObj_compare(CFArrayRefObject
*self
, CFArrayRefObject
*other
)
473 /* XXXX Or should we use CFEqual?? */
474 if ( self
->ob_itself
> other
->ob_itself
) return 1;
475 if ( self
->ob_itself
< other
->ob_itself
) return -1;
479 static PyObject
* CFArrayRefObj_repr(CFArrayRefObject
*self
)
482 sprintf(buf
, "<CFArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
483 return PyString_FromString(buf
);
486 static int CFArrayRefObj_hash(CFArrayRefObject
*self
)
488 /* XXXX Or should we use CFHash?? */
489 return (int)self
->ob_itself
;
492 PyTypeObject CFArrayRef_Type
= {
493 PyObject_HEAD_INIT(NULL
)
495 "_CF.CFArrayRef", /*tp_name*/
496 sizeof(CFArrayRefObject
), /*tp_basicsize*/
499 (destructor
) CFArrayRefObj_dealloc
, /*tp_dealloc*/
501 (getattrfunc
) CFArrayRefObj_getattr
, /*tp_getattr*/
502 (setattrfunc
) CFArrayRefObj_setattr
, /*tp_setattr*/
503 (cmpfunc
) CFArrayRefObj_compare
, /*tp_compare*/
504 (reprfunc
) CFArrayRefObj_repr
, /*tp_repr*/
505 (PyNumberMethods
*)0, /* tp_as_number */
506 (PySequenceMethods
*)0, /* tp_as_sequence */
507 (PyMappingMethods
*)0, /* tp_as_mapping */
508 (hashfunc
) CFArrayRefObj_hash
, /*tp_hash*/
511 /* ------------------- End object type CFArrayRef ------------------- */
514 /* ----------------- Object type CFMutableArrayRef ------------------ */
516 PyTypeObject CFMutableArrayRef_Type
;
518 #define CFMutableArrayRefObj_Check(x) ((x)->ob_type == &CFMutableArrayRef_Type)
520 typedef struct CFMutableArrayRefObject
{
522 CFMutableArrayRef ob_itself
;
523 void (*ob_freeit
)(CFTypeRef ptr
);
524 } CFMutableArrayRefObject
;
526 PyObject
*CFMutableArrayRefObj_New(CFMutableArrayRef itself
)
528 CFMutableArrayRefObject
*it
;
529 if (itself
== NULL
) return PyMac_Error(resNotFound
);
530 it
= PyObject_NEW(CFMutableArrayRefObject
, &CFMutableArrayRef_Type
);
531 if (it
== NULL
) return NULL
;
532 it
->ob_itself
= itself
;
533 it
->ob_freeit
= CFRelease
;
534 return (PyObject
*)it
;
536 int CFMutableArrayRefObj_Convert(PyObject
*v
, CFMutableArrayRef
*p_itself
)
539 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
540 /* Check for other CF objects here */
542 if (!CFMutableArrayRefObj_Check(v
))
544 PyErr_SetString(PyExc_TypeError
, "CFMutableArrayRef required");
547 *p_itself
= ((CFMutableArrayRefObject
*)v
)->ob_itself
;
551 static void CFMutableArrayRefObj_dealloc(CFMutableArrayRefObject
*self
)
553 if (self
->ob_freeit
&& self
->ob_itself
)
555 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
560 static PyObject
*CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
562 PyObject
*_res
= NULL
;
564 #ifndef CFArrayRemoveValueAtIndex
565 PyMac_PRECHECK(CFArrayRemoveValueAtIndex
);
567 if (!PyArg_ParseTuple(_args
, "l",
570 CFArrayRemoveValueAtIndex(_self
->ob_itself
,
577 static PyObject
*CFMutableArrayRefObj_CFArrayRemoveAllValues(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
579 PyObject
*_res
= NULL
;
580 #ifndef CFArrayRemoveAllValues
581 PyMac_PRECHECK(CFArrayRemoveAllValues
);
583 if (!PyArg_ParseTuple(_args
, ""))
585 CFArrayRemoveAllValues(_self
->ob_itself
);
591 static PyObject
*CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
593 PyObject
*_res
= NULL
;
596 #ifndef CFArrayExchangeValuesAtIndices
597 PyMac_PRECHECK(CFArrayExchangeValuesAtIndices
);
599 if (!PyArg_ParseTuple(_args
, "ll",
603 CFArrayExchangeValuesAtIndices(_self
->ob_itself
,
611 static PyObject
*CFMutableArrayRefObj_CFArrayAppendArray(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
613 PyObject
*_res
= NULL
;
614 CFArrayRef otherArray
;
616 #ifndef CFArrayAppendArray
617 PyMac_PRECHECK(CFArrayAppendArray
);
619 if (!PyArg_ParseTuple(_args
, "O&O&",
620 CFArrayRefObj_Convert
, &otherArray
,
621 CFRange_Convert
, &otherRange
))
623 CFArrayAppendArray(_self
->ob_itself
,
631 static PyMethodDef CFMutableArrayRefObj_methods
[] = {
632 {"CFArrayRemoveValueAtIndex", (PyCFunction
)CFMutableArrayRefObj_CFArrayRemoveValueAtIndex
, 1,
633 "(CFIndex idx) -> None"},
634 {"CFArrayRemoveAllValues", (PyCFunction
)CFMutableArrayRefObj_CFArrayRemoveAllValues
, 1,
636 {"CFArrayExchangeValuesAtIndices", (PyCFunction
)CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices
, 1,
637 "(CFIndex idx1, CFIndex idx2) -> None"},
638 {"CFArrayAppendArray", (PyCFunction
)CFMutableArrayRefObj_CFArrayAppendArray
, 1,
639 "(CFArrayRef otherArray, CFRange otherRange) -> None"},
643 PyMethodChain CFMutableArrayRefObj_chain
= { CFMutableArrayRefObj_methods
, &CFArrayRefObj_chain
};
645 static PyObject
*CFMutableArrayRefObj_getattr(CFMutableArrayRefObject
*self
, char *name
)
647 return Py_FindMethodInChain(&CFMutableArrayRefObj_chain
, (PyObject
*)self
, name
);
650 #define CFMutableArrayRefObj_setattr NULL
652 static int CFMutableArrayRefObj_compare(CFMutableArrayRefObject
*self
, CFMutableArrayRefObject
*other
)
654 /* XXXX Or should we use CFEqual?? */
655 if ( self
->ob_itself
> other
->ob_itself
) return 1;
656 if ( self
->ob_itself
< other
->ob_itself
) return -1;
660 static PyObject
* CFMutableArrayRefObj_repr(CFMutableArrayRefObject
*self
)
663 sprintf(buf
, "<CFMutableArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
664 return PyString_FromString(buf
);
667 static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject
*self
)
669 /* XXXX Or should we use CFHash?? */
670 return (int)self
->ob_itself
;
673 PyTypeObject CFMutableArrayRef_Type
= {
674 PyObject_HEAD_INIT(NULL
)
676 "_CF.CFMutableArrayRef", /*tp_name*/
677 sizeof(CFMutableArrayRefObject
), /*tp_basicsize*/
680 (destructor
) CFMutableArrayRefObj_dealloc
, /*tp_dealloc*/
682 (getattrfunc
) CFMutableArrayRefObj_getattr
, /*tp_getattr*/
683 (setattrfunc
) CFMutableArrayRefObj_setattr
, /*tp_setattr*/
684 (cmpfunc
) CFMutableArrayRefObj_compare
, /*tp_compare*/
685 (reprfunc
) CFMutableArrayRefObj_repr
, /*tp_repr*/
686 (PyNumberMethods
*)0, /* tp_as_number */
687 (PySequenceMethods
*)0, /* tp_as_sequence */
688 (PyMappingMethods
*)0, /* tp_as_mapping */
689 (hashfunc
) CFMutableArrayRefObj_hash
, /*tp_hash*/
692 /* --------------- End object type CFMutableArrayRef ---------------- */
695 /* ------------------ Object type CFDictionaryRef ------------------- */
697 PyTypeObject CFDictionaryRef_Type
;
699 #define CFDictionaryRefObj_Check(x) ((x)->ob_type == &CFDictionaryRef_Type)
701 typedef struct CFDictionaryRefObject
{
703 CFDictionaryRef ob_itself
;
704 void (*ob_freeit
)(CFTypeRef ptr
);
705 } CFDictionaryRefObject
;
707 PyObject
*CFDictionaryRefObj_New(CFDictionaryRef itself
)
709 CFDictionaryRefObject
*it
;
710 if (itself
== NULL
) return PyMac_Error(resNotFound
);
711 it
= PyObject_NEW(CFDictionaryRefObject
, &CFDictionaryRef_Type
);
712 if (it
== NULL
) return NULL
;
713 it
->ob_itself
= itself
;
714 it
->ob_freeit
= CFRelease
;
715 return (PyObject
*)it
;
717 int CFDictionaryRefObj_Convert(PyObject
*v
, CFDictionaryRef
*p_itself
)
720 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
721 /* Check for other CF objects here */
723 if (!CFDictionaryRefObj_Check(v
))
725 PyErr_SetString(PyExc_TypeError
, "CFDictionaryRef required");
728 *p_itself
= ((CFDictionaryRefObject
*)v
)->ob_itself
;
732 static void CFDictionaryRefObj_dealloc(CFDictionaryRefObject
*self
)
734 if (self
->ob_freeit
&& self
->ob_itself
)
736 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
741 static PyObject
*CFDictionaryRefObj_CFDictionaryCreateCopy(CFDictionaryRefObject
*_self
, PyObject
*_args
)
743 PyObject
*_res
= NULL
;
745 if (!PyArg_ParseTuple(_args
, ""))
747 _rv
= CFDictionaryCreateCopy((CFAllocatorRef
)NULL
,
749 _res
= Py_BuildValue("O&",
750 CFDictionaryRefObj_New
, _rv
);
754 static PyObject
*CFDictionaryRefObj_CFDictionaryGetCount(CFDictionaryRefObject
*_self
, PyObject
*_args
)
756 PyObject
*_res
= NULL
;
758 #ifndef CFDictionaryGetCount
759 PyMac_PRECHECK(CFDictionaryGetCount
);
761 if (!PyArg_ParseTuple(_args
, ""))
763 _rv
= CFDictionaryGetCount(_self
->ob_itself
);
764 _res
= Py_BuildValue("l",
769 static PyMethodDef CFDictionaryRefObj_methods
[] = {
770 {"CFDictionaryCreateCopy", (PyCFunction
)CFDictionaryRefObj_CFDictionaryCreateCopy
, 1,
771 "() -> (CFDictionaryRef _rv)"},
772 {"CFDictionaryGetCount", (PyCFunction
)CFDictionaryRefObj_CFDictionaryGetCount
, 1,
773 "() -> (CFIndex _rv)"},
777 PyMethodChain CFDictionaryRefObj_chain
= { CFDictionaryRefObj_methods
, &CFTypeRefObj_chain
};
779 static PyObject
*CFDictionaryRefObj_getattr(CFDictionaryRefObject
*self
, char *name
)
781 return Py_FindMethodInChain(&CFDictionaryRefObj_chain
, (PyObject
*)self
, name
);
784 #define CFDictionaryRefObj_setattr NULL
786 static int CFDictionaryRefObj_compare(CFDictionaryRefObject
*self
, CFDictionaryRefObject
*other
)
788 /* XXXX Or should we use CFEqual?? */
789 if ( self
->ob_itself
> other
->ob_itself
) return 1;
790 if ( self
->ob_itself
< other
->ob_itself
) return -1;
794 static PyObject
* CFDictionaryRefObj_repr(CFDictionaryRefObject
*self
)
797 sprintf(buf
, "<CFDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
798 return PyString_FromString(buf
);
801 static int CFDictionaryRefObj_hash(CFDictionaryRefObject
*self
)
803 /* XXXX Or should we use CFHash?? */
804 return (int)self
->ob_itself
;
807 PyTypeObject CFDictionaryRef_Type
= {
808 PyObject_HEAD_INIT(NULL
)
810 "_CF.CFDictionaryRef", /*tp_name*/
811 sizeof(CFDictionaryRefObject
), /*tp_basicsize*/
814 (destructor
) CFDictionaryRefObj_dealloc
, /*tp_dealloc*/
816 (getattrfunc
) CFDictionaryRefObj_getattr
, /*tp_getattr*/
817 (setattrfunc
) CFDictionaryRefObj_setattr
, /*tp_setattr*/
818 (cmpfunc
) CFDictionaryRefObj_compare
, /*tp_compare*/
819 (reprfunc
) CFDictionaryRefObj_repr
, /*tp_repr*/
820 (PyNumberMethods
*)0, /* tp_as_number */
821 (PySequenceMethods
*)0, /* tp_as_sequence */
822 (PyMappingMethods
*)0, /* tp_as_mapping */
823 (hashfunc
) CFDictionaryRefObj_hash
, /*tp_hash*/
826 /* ---------------- End object type CFDictionaryRef ----------------- */
829 /* --------------- Object type CFMutableDictionaryRef --------------- */
831 PyTypeObject CFMutableDictionaryRef_Type
;
833 #define CFMutableDictionaryRefObj_Check(x) ((x)->ob_type == &CFMutableDictionaryRef_Type)
835 typedef struct CFMutableDictionaryRefObject
{
837 CFMutableDictionaryRef ob_itself
;
838 void (*ob_freeit
)(CFTypeRef ptr
);
839 } CFMutableDictionaryRefObject
;
841 PyObject
*CFMutableDictionaryRefObj_New(CFMutableDictionaryRef itself
)
843 CFMutableDictionaryRefObject
*it
;
844 if (itself
== NULL
) return PyMac_Error(resNotFound
);
845 it
= PyObject_NEW(CFMutableDictionaryRefObject
, &CFMutableDictionaryRef_Type
);
846 if (it
== NULL
) return NULL
;
847 it
->ob_itself
= itself
;
848 it
->ob_freeit
= CFRelease
;
849 return (PyObject
*)it
;
851 int CFMutableDictionaryRefObj_Convert(PyObject
*v
, CFMutableDictionaryRef
*p_itself
)
854 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
855 /* Check for other CF objects here */
857 if (!CFMutableDictionaryRefObj_Check(v
))
859 PyErr_SetString(PyExc_TypeError
, "CFMutableDictionaryRef required");
862 *p_itself
= ((CFMutableDictionaryRefObject
*)v
)->ob_itself
;
866 static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject
*self
)
868 if (self
->ob_freeit
&& self
->ob_itself
)
870 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
875 static PyObject
*CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject
*_self
, PyObject
*_args
)
877 PyObject
*_res
= NULL
;
878 #ifndef CFDictionaryRemoveAllValues
879 PyMac_PRECHECK(CFDictionaryRemoveAllValues
);
881 if (!PyArg_ParseTuple(_args
, ""))
883 CFDictionaryRemoveAllValues(_self
->ob_itself
);
889 static PyMethodDef CFMutableDictionaryRefObj_methods
[] = {
890 {"CFDictionaryRemoveAllValues", (PyCFunction
)CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues
, 1,
895 PyMethodChain CFMutableDictionaryRefObj_chain
= { CFMutableDictionaryRefObj_methods
, &CFDictionaryRefObj_chain
};
897 static PyObject
*CFMutableDictionaryRefObj_getattr(CFMutableDictionaryRefObject
*self
, char *name
)
899 return Py_FindMethodInChain(&CFMutableDictionaryRefObj_chain
, (PyObject
*)self
, name
);
902 #define CFMutableDictionaryRefObj_setattr NULL
904 static int CFMutableDictionaryRefObj_compare(CFMutableDictionaryRefObject
*self
, CFMutableDictionaryRefObject
*other
)
906 /* XXXX Or should we use CFEqual?? */
907 if ( self
->ob_itself
> other
->ob_itself
) return 1;
908 if ( self
->ob_itself
< other
->ob_itself
) return -1;
912 static PyObject
* CFMutableDictionaryRefObj_repr(CFMutableDictionaryRefObject
*self
)
915 sprintf(buf
, "<CFMutableDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
916 return PyString_FromString(buf
);
919 static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject
*self
)
921 /* XXXX Or should we use CFHash?? */
922 return (int)self
->ob_itself
;
925 PyTypeObject CFMutableDictionaryRef_Type
= {
926 PyObject_HEAD_INIT(NULL
)
928 "_CF.CFMutableDictionaryRef", /*tp_name*/
929 sizeof(CFMutableDictionaryRefObject
), /*tp_basicsize*/
932 (destructor
) CFMutableDictionaryRefObj_dealloc
, /*tp_dealloc*/
934 (getattrfunc
) CFMutableDictionaryRefObj_getattr
, /*tp_getattr*/
935 (setattrfunc
) CFMutableDictionaryRefObj_setattr
, /*tp_setattr*/
936 (cmpfunc
) CFMutableDictionaryRefObj_compare
, /*tp_compare*/
937 (reprfunc
) CFMutableDictionaryRefObj_repr
, /*tp_repr*/
938 (PyNumberMethods
*)0, /* tp_as_number */
939 (PySequenceMethods
*)0, /* tp_as_sequence */
940 (PyMappingMethods
*)0, /* tp_as_mapping */
941 (hashfunc
) CFMutableDictionaryRefObj_hash
, /*tp_hash*/
944 /* ------------- End object type CFMutableDictionaryRef ------------- */
947 /* --------------------- Object type CFDataRef ---------------------- */
949 PyTypeObject CFDataRef_Type
;
951 #define CFDataRefObj_Check(x) ((x)->ob_type == &CFDataRef_Type)
953 typedef struct CFDataRefObject
{
956 void (*ob_freeit
)(CFTypeRef ptr
);
959 PyObject
*CFDataRefObj_New(CFDataRef itself
)
962 if (itself
== NULL
) return PyMac_Error(resNotFound
);
963 it
= PyObject_NEW(CFDataRefObject
, &CFDataRef_Type
);
964 if (it
== NULL
) return NULL
;
965 it
->ob_itself
= itself
;
966 it
->ob_freeit
= CFRelease
;
967 return (PyObject
*)it
;
969 int CFDataRefObj_Convert(PyObject
*v
, CFDataRef
*p_itself
)
972 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
973 /* Check for other CF objects here */
975 if (!CFDataRefObj_Check(v
))
977 PyErr_SetString(PyExc_TypeError
, "CFDataRef required");
980 *p_itself
= ((CFDataRefObject
*)v
)->ob_itself
;
984 static void CFDataRefObj_dealloc(CFDataRefObject
*self
)
986 if (self
->ob_freeit
&& self
->ob_itself
)
988 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
993 static PyObject
*CFDataRefObj_CFDataCreateCopy(CFDataRefObject
*_self
, PyObject
*_args
)
995 PyObject
*_res
= NULL
;
997 if (!PyArg_ParseTuple(_args
, ""))
999 _rv
= CFDataCreateCopy((CFAllocatorRef
)NULL
,
1001 _res
= Py_BuildValue("O&",
1002 CFDataRefObj_New
, _rv
);
1006 static PyObject
*CFDataRefObj_CFDataGetLength(CFDataRefObject
*_self
, PyObject
*_args
)
1008 PyObject
*_res
= NULL
;
1010 #ifndef CFDataGetLength
1011 PyMac_PRECHECK(CFDataGetLength
);
1013 if (!PyArg_ParseTuple(_args
, ""))
1015 _rv
= CFDataGetLength(_self
->ob_itself
);
1016 _res
= Py_BuildValue("l",
1021 static PyObject
*CFDataRefObj_CFStringCreateFromExternalRepresentation(CFDataRefObject
*_self
, PyObject
*_args
)
1023 PyObject
*_res
= NULL
;
1025 CFStringEncoding encoding
;
1026 if (!PyArg_ParseTuple(_args
, "l",
1029 _rv
= CFStringCreateFromExternalRepresentation((CFAllocatorRef
)NULL
,
1032 _res
= Py_BuildValue("O&",
1033 CFStringRefObj_New
, _rv
);
1037 static PyMethodDef CFDataRefObj_methods
[] = {
1038 {"CFDataCreateCopy", (PyCFunction
)CFDataRefObj_CFDataCreateCopy
, 1,
1039 "() -> (CFDataRef _rv)"},
1040 {"CFDataGetLength", (PyCFunction
)CFDataRefObj_CFDataGetLength
, 1,
1041 "() -> (CFIndex _rv)"},
1042 {"CFStringCreateFromExternalRepresentation", (PyCFunction
)CFDataRefObj_CFStringCreateFromExternalRepresentation
, 1,
1043 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
1047 PyMethodChain CFDataRefObj_chain
= { CFDataRefObj_methods
, &CFTypeRefObj_chain
};
1049 static PyObject
*CFDataRefObj_getattr(CFDataRefObject
*self
, char *name
)
1051 return Py_FindMethodInChain(&CFDataRefObj_chain
, (PyObject
*)self
, name
);
1054 #define CFDataRefObj_setattr NULL
1056 static int CFDataRefObj_compare(CFDataRefObject
*self
, CFDataRefObject
*other
)
1058 /* XXXX Or should we use CFEqual?? */
1059 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1060 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1064 static PyObject
* CFDataRefObj_repr(CFDataRefObject
*self
)
1067 sprintf(buf
, "<CFDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
1068 return PyString_FromString(buf
);
1071 static int CFDataRefObj_hash(CFDataRefObject
*self
)
1073 /* XXXX Or should we use CFHash?? */
1074 return (int)self
->ob_itself
;
1077 PyTypeObject CFDataRef_Type
= {
1078 PyObject_HEAD_INIT(NULL
)
1080 "_CF.CFDataRef", /*tp_name*/
1081 sizeof(CFDataRefObject
), /*tp_basicsize*/
1084 (destructor
) CFDataRefObj_dealloc
, /*tp_dealloc*/
1086 (getattrfunc
) CFDataRefObj_getattr
, /*tp_getattr*/
1087 (setattrfunc
) CFDataRefObj_setattr
, /*tp_setattr*/
1088 (cmpfunc
) CFDataRefObj_compare
, /*tp_compare*/
1089 (reprfunc
) CFDataRefObj_repr
, /*tp_repr*/
1090 (PyNumberMethods
*)0, /* tp_as_number */
1091 (PySequenceMethods
*)0, /* tp_as_sequence */
1092 (PyMappingMethods
*)0, /* tp_as_mapping */
1093 (hashfunc
) CFDataRefObj_hash
, /*tp_hash*/
1096 /* ------------------- End object type CFDataRef -------------------- */
1099 /* ------------------ Object type CFMutableDataRef ------------------ */
1101 PyTypeObject CFMutableDataRef_Type
;
1103 #define CFMutableDataRefObj_Check(x) ((x)->ob_type == &CFMutableDataRef_Type)
1105 typedef struct CFMutableDataRefObject
{
1107 CFMutableDataRef ob_itself
;
1108 void (*ob_freeit
)(CFTypeRef ptr
);
1109 } CFMutableDataRefObject
;
1111 PyObject
*CFMutableDataRefObj_New(CFMutableDataRef itself
)
1113 CFMutableDataRefObject
*it
;
1114 if (itself
== NULL
) return PyMac_Error(resNotFound
);
1115 it
= PyObject_NEW(CFMutableDataRefObject
, &CFMutableDataRef_Type
);
1116 if (it
== NULL
) return NULL
;
1117 it
->ob_itself
= itself
;
1118 it
->ob_freeit
= CFRelease
;
1119 return (PyObject
*)it
;
1121 int CFMutableDataRefObj_Convert(PyObject
*v
, CFMutableDataRef
*p_itself
)
1124 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1125 /* Check for other CF objects here */
1127 if (!CFMutableDataRefObj_Check(v
))
1129 PyErr_SetString(PyExc_TypeError
, "CFMutableDataRef required");
1132 *p_itself
= ((CFMutableDataRefObject
*)v
)->ob_itself
;
1136 static void CFMutableDataRefObj_dealloc(CFMutableDataRefObject
*self
)
1138 if (self
->ob_freeit
&& self
->ob_itself
)
1140 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1145 static PyObject
*CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1147 PyObject
*_res
= NULL
;
1149 #ifndef CFDataSetLength
1150 PyMac_PRECHECK(CFDataSetLength
);
1152 if (!PyArg_ParseTuple(_args
, "l",
1155 CFDataSetLength(_self
->ob_itself
,
1162 static PyObject
*CFMutableDataRefObj_CFDataIncreaseLength(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1164 PyObject
*_res
= NULL
;
1165 CFIndex extraLength
;
1166 #ifndef CFDataIncreaseLength
1167 PyMac_PRECHECK(CFDataIncreaseLength
);
1169 if (!PyArg_ParseTuple(_args
, "l",
1172 CFDataIncreaseLength(_self
->ob_itself
,
1179 static PyObject
*CFMutableDataRefObj_CFDataAppendBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1181 PyObject
*_res
= NULL
;
1182 unsigned char *bytes__in__
;
1184 int bytes__in_len__
;
1185 #ifndef CFDataAppendBytes
1186 PyMac_PRECHECK(CFDataAppendBytes
);
1188 if (!PyArg_ParseTuple(_args
, "s#",
1189 &bytes__in__
, &bytes__in_len__
))
1191 bytes__len__
= bytes__in_len__
;
1192 CFDataAppendBytes(_self
->ob_itself
,
1193 bytes__in__
, bytes__len__
);
1199 static PyObject
*CFMutableDataRefObj_CFDataReplaceBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1201 PyObject
*_res
= NULL
;
1203 unsigned char *newBytes__in__
;
1204 long newBytes__len__
;
1205 int newBytes__in_len__
;
1206 #ifndef CFDataReplaceBytes
1207 PyMac_PRECHECK(CFDataReplaceBytes
);
1209 if (!PyArg_ParseTuple(_args
, "O&s#",
1210 CFRange_Convert
, &range
,
1211 &newBytes__in__
, &newBytes__in_len__
))
1213 newBytes__len__
= newBytes__in_len__
;
1214 CFDataReplaceBytes(_self
->ob_itself
,
1216 newBytes__in__
, newBytes__len__
);
1222 static PyObject
*CFMutableDataRefObj_CFDataDeleteBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1224 PyObject
*_res
= NULL
;
1226 #ifndef CFDataDeleteBytes
1227 PyMac_PRECHECK(CFDataDeleteBytes
);
1229 if (!PyArg_ParseTuple(_args
, "O&",
1230 CFRange_Convert
, &range
))
1232 CFDataDeleteBytes(_self
->ob_itself
,
1239 static PyMethodDef CFMutableDataRefObj_methods
[] = {
1240 {"CFDataSetLength", (PyCFunction
)CFMutableDataRefObj_CFDataSetLength
, 1,
1241 "(CFIndex length) -> None"},
1242 {"CFDataIncreaseLength", (PyCFunction
)CFMutableDataRefObj_CFDataIncreaseLength
, 1,
1243 "(CFIndex extraLength) -> None"},
1244 {"CFDataAppendBytes", (PyCFunction
)CFMutableDataRefObj_CFDataAppendBytes
, 1,
1245 "(Buffer bytes) -> None"},
1246 {"CFDataReplaceBytes", (PyCFunction
)CFMutableDataRefObj_CFDataReplaceBytes
, 1,
1247 "(CFRange range, Buffer newBytes) -> None"},
1248 {"CFDataDeleteBytes", (PyCFunction
)CFMutableDataRefObj_CFDataDeleteBytes
, 1,
1249 "(CFRange range) -> None"},
1253 PyMethodChain CFMutableDataRefObj_chain
= { CFMutableDataRefObj_methods
, &CFDataRefObj_chain
};
1255 static PyObject
*CFMutableDataRefObj_getattr(CFMutableDataRefObject
*self
, char *name
)
1257 return Py_FindMethodInChain(&CFMutableDataRefObj_chain
, (PyObject
*)self
, name
);
1260 #define CFMutableDataRefObj_setattr NULL
1262 static int CFMutableDataRefObj_compare(CFMutableDataRefObject
*self
, CFMutableDataRefObject
*other
)
1264 /* XXXX Or should we use CFEqual?? */
1265 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1266 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1270 static PyObject
* CFMutableDataRefObj_repr(CFMutableDataRefObject
*self
)
1273 sprintf(buf
, "<CFMutableDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
1274 return PyString_FromString(buf
);
1277 static int CFMutableDataRefObj_hash(CFMutableDataRefObject
*self
)
1279 /* XXXX Or should we use CFHash?? */
1280 return (int)self
->ob_itself
;
1283 PyTypeObject CFMutableDataRef_Type
= {
1284 PyObject_HEAD_INIT(NULL
)
1286 "_CF.CFMutableDataRef", /*tp_name*/
1287 sizeof(CFMutableDataRefObject
), /*tp_basicsize*/
1290 (destructor
) CFMutableDataRefObj_dealloc
, /*tp_dealloc*/
1292 (getattrfunc
) CFMutableDataRefObj_getattr
, /*tp_getattr*/
1293 (setattrfunc
) CFMutableDataRefObj_setattr
, /*tp_setattr*/
1294 (cmpfunc
) CFMutableDataRefObj_compare
, /*tp_compare*/
1295 (reprfunc
) CFMutableDataRefObj_repr
, /*tp_repr*/
1296 (PyNumberMethods
*)0, /* tp_as_number */
1297 (PySequenceMethods
*)0, /* tp_as_sequence */
1298 (PyMappingMethods
*)0, /* tp_as_mapping */
1299 (hashfunc
) CFMutableDataRefObj_hash
, /*tp_hash*/
1302 /* ---------------- End object type CFMutableDataRef ---------------- */
1305 /* -------------------- Object type CFStringRef --------------------- */
1307 PyTypeObject CFStringRef_Type
;
1309 #define CFStringRefObj_Check(x) ((x)->ob_type == &CFStringRef_Type)
1311 typedef struct CFStringRefObject
{
1313 CFStringRef ob_itself
;
1314 void (*ob_freeit
)(CFTypeRef ptr
);
1315 } CFStringRefObject
;
1317 PyObject
*CFStringRefObj_New(CFStringRef itself
)
1319 CFStringRefObject
*it
;
1320 if (itself
== NULL
) return PyMac_Error(resNotFound
);
1321 it
= PyObject_NEW(CFStringRefObject
, &CFStringRef_Type
);
1322 if (it
== NULL
) return NULL
;
1323 it
->ob_itself
= itself
;
1324 it
->ob_freeit
= CFRelease
;
1325 return (PyObject
*)it
;
1327 int CFStringRefObj_Convert(PyObject
*v
, CFStringRef
*p_itself
)
1330 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1331 if (PyString_Check(v
)) {
1332 char *cStr
= PyString_AsString(v
);
1333 *p_itself
= CFStringCreateWithCString((CFAllocatorRef
)NULL
, cStr
, 0);
1336 if (PyUnicode_Check(v
)) {
1337 /* We use the CF types here, if Python was configured differently that will give an error */
1338 CFIndex size
= PyUnicode_GetSize(v
);
1339 UniChar
*unichars
= PyUnicode_AsUnicode(v
);
1340 if (!unichars
) return 0;
1341 *p_itself
= CFStringCreateWithCharacters((CFAllocatorRef
)NULL
, unichars
, size
);
1346 if (!CFStringRefObj_Check(v
))
1348 PyErr_SetString(PyExc_TypeError
, "CFStringRef required");
1351 *p_itself
= ((CFStringRefObject
*)v
)->ob_itself
;
1355 static void CFStringRefObj_dealloc(CFStringRefObject
*self
)
1357 if (self
->ob_freeit
&& self
->ob_itself
)
1359 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1364 static PyObject
*CFStringRefObj_CFStringCreateWithSubstring(CFStringRefObject
*_self
, PyObject
*_args
)
1366 PyObject
*_res
= NULL
;
1369 if (!PyArg_ParseTuple(_args
, "O&",
1370 CFRange_Convert
, &range
))
1372 _rv
= CFStringCreateWithSubstring((CFAllocatorRef
)NULL
,
1375 _res
= Py_BuildValue("O&",
1376 CFStringRefObj_New
, _rv
);
1380 static PyObject
*CFStringRefObj_CFStringCreateCopy(CFStringRefObject
*_self
, PyObject
*_args
)
1382 PyObject
*_res
= NULL
;
1384 if (!PyArg_ParseTuple(_args
, ""))
1386 _rv
= CFStringCreateCopy((CFAllocatorRef
)NULL
,
1388 _res
= Py_BuildValue("O&",
1389 CFStringRefObj_New
, _rv
);
1393 static PyObject
*CFStringRefObj_CFStringGetLength(CFStringRefObject
*_self
, PyObject
*_args
)
1395 PyObject
*_res
= NULL
;
1397 #ifndef CFStringGetLength
1398 PyMac_PRECHECK(CFStringGetLength
);
1400 if (!PyArg_ParseTuple(_args
, ""))
1402 _rv
= CFStringGetLength(_self
->ob_itself
);
1403 _res
= Py_BuildValue("l",
1408 static PyObject
*CFStringRefObj_CFStringGetBytes(CFStringRefObject
*_self
, PyObject
*_args
)
1410 PyObject
*_res
= NULL
;
1413 CFStringEncoding encoding
;
1415 Boolean isExternalRepresentation
;
1419 #ifndef CFStringGetBytes
1420 PyMac_PRECHECK(CFStringGetBytes
);
1422 if (!PyArg_ParseTuple(_args
, "O&lbll",
1423 CFRange_Convert
, &range
,
1426 &isExternalRepresentation
,
1429 _rv
= CFStringGetBytes(_self
->ob_itself
,
1433 isExternalRepresentation
,
1437 _res
= Py_BuildValue("lbl",
1444 static PyObject
*CFStringRefObj_CFStringCreateExternalRepresentation(CFStringRefObject
*_self
, PyObject
*_args
)
1446 PyObject
*_res
= NULL
;
1448 CFStringEncoding encoding
;
1450 if (!PyArg_ParseTuple(_args
, "lb",
1454 _rv
= CFStringCreateExternalRepresentation((CFAllocatorRef
)NULL
,
1458 _res
= Py_BuildValue("O&",
1459 CFDataRefObj_New
, _rv
);
1463 static PyObject
*CFStringRefObj_CFStringGetSmallestEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
1465 PyObject
*_res
= NULL
;
1466 CFStringEncoding _rv
;
1467 #ifndef CFStringGetSmallestEncoding
1468 PyMac_PRECHECK(CFStringGetSmallestEncoding
);
1470 if (!PyArg_ParseTuple(_args
, ""))
1472 _rv
= CFStringGetSmallestEncoding(_self
->ob_itself
);
1473 _res
= Py_BuildValue("l",
1478 static PyObject
*CFStringRefObj_CFStringGetFastestEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
1480 PyObject
*_res
= NULL
;
1481 CFStringEncoding _rv
;
1482 #ifndef CFStringGetFastestEncoding
1483 PyMac_PRECHECK(CFStringGetFastestEncoding
);
1485 if (!PyArg_ParseTuple(_args
, ""))
1487 _rv
= CFStringGetFastestEncoding(_self
->ob_itself
);
1488 _res
= Py_BuildValue("l",
1493 static PyObject
*CFStringRefObj_CFStringCompareWithOptions(CFStringRefObject
*_self
, PyObject
*_args
)
1495 PyObject
*_res
= NULL
;
1496 CFComparisonResult _rv
;
1497 CFStringRef theString2
;
1498 CFRange rangeToCompare
;
1499 CFOptionFlags compareOptions
;
1500 #ifndef CFStringCompareWithOptions
1501 PyMac_PRECHECK(CFStringCompareWithOptions
);
1503 if (!PyArg_ParseTuple(_args
, "O&O&l",
1504 CFStringRefObj_Convert
, &theString2
,
1505 CFRange_Convert
, &rangeToCompare
,
1508 _rv
= CFStringCompareWithOptions(_self
->ob_itself
,
1512 _res
= Py_BuildValue("l",
1517 static PyObject
*CFStringRefObj_CFStringCompare(CFStringRefObject
*_self
, PyObject
*_args
)
1519 PyObject
*_res
= NULL
;
1520 CFComparisonResult _rv
;
1521 CFStringRef theString2
;
1522 CFOptionFlags compareOptions
;
1523 #ifndef CFStringCompare
1524 PyMac_PRECHECK(CFStringCompare
);
1526 if (!PyArg_ParseTuple(_args
, "O&l",
1527 CFStringRefObj_Convert
, &theString2
,
1530 _rv
= CFStringCompare(_self
->ob_itself
,
1533 _res
= Py_BuildValue("l",
1538 static PyObject
*CFStringRefObj_CFStringFindWithOptions(CFStringRefObject
*_self
, PyObject
*_args
)
1540 PyObject
*_res
= NULL
;
1542 CFStringRef stringToFind
;
1543 CFRange rangeToSearch
;
1544 CFOptionFlags searchOptions
;
1546 #ifndef CFStringFindWithOptions
1547 PyMac_PRECHECK(CFStringFindWithOptions
);
1549 if (!PyArg_ParseTuple(_args
, "O&O&l",
1550 CFStringRefObj_Convert
, &stringToFind
,
1551 CFRange_Convert
, &rangeToSearch
,
1554 _rv
= CFStringFindWithOptions(_self
->ob_itself
,
1559 _res
= Py_BuildValue("lO&",
1561 CFRange_New
, result
);
1565 static PyObject
*CFStringRefObj_CFStringCreateArrayWithFindResults(CFStringRefObject
*_self
, PyObject
*_args
)
1567 PyObject
*_res
= NULL
;
1569 CFStringRef stringToFind
;
1570 CFRange rangeToSearch
;
1571 CFOptionFlags compareOptions
;
1572 if (!PyArg_ParseTuple(_args
, "O&O&l",
1573 CFStringRefObj_Convert
, &stringToFind
,
1574 CFRange_Convert
, &rangeToSearch
,
1577 _rv
= CFStringCreateArrayWithFindResults((CFAllocatorRef
)NULL
,
1582 _res
= Py_BuildValue("O&",
1583 CFArrayRefObj_New
, _rv
);
1587 static PyObject
*CFStringRefObj_CFStringFind(CFStringRefObject
*_self
, PyObject
*_args
)
1589 PyObject
*_res
= NULL
;
1591 CFStringRef stringToFind
;
1592 CFOptionFlags compareOptions
;
1593 #ifndef CFStringFind
1594 PyMac_PRECHECK(CFStringFind
);
1596 if (!PyArg_ParseTuple(_args
, "O&l",
1597 CFStringRefObj_Convert
, &stringToFind
,
1600 _rv
= CFStringFind(_self
->ob_itself
,
1603 _res
= Py_BuildValue("O&",
1608 static PyObject
*CFStringRefObj_CFStringHasPrefix(CFStringRefObject
*_self
, PyObject
*_args
)
1610 PyObject
*_res
= NULL
;
1613 #ifndef CFStringHasPrefix
1614 PyMac_PRECHECK(CFStringHasPrefix
);
1616 if (!PyArg_ParseTuple(_args
, "O&",
1617 CFStringRefObj_Convert
, &prefix
))
1619 _rv
= CFStringHasPrefix(_self
->ob_itself
,
1621 _res
= Py_BuildValue("l",
1626 static PyObject
*CFStringRefObj_CFStringHasSuffix(CFStringRefObject
*_self
, PyObject
*_args
)
1628 PyObject
*_res
= NULL
;
1631 #ifndef CFStringHasSuffix
1632 PyMac_PRECHECK(CFStringHasSuffix
);
1634 if (!PyArg_ParseTuple(_args
, "O&",
1635 CFStringRefObj_Convert
, &suffix
))
1637 _rv
= CFStringHasSuffix(_self
->ob_itself
,
1639 _res
= Py_BuildValue("l",
1644 static PyObject
*CFStringRefObj_CFStringGetLineBounds(CFStringRefObject
*_self
, PyObject
*_args
)
1646 PyObject
*_res
= NULL
;
1648 CFIndex lineBeginIndex
;
1649 CFIndex lineEndIndex
;
1650 CFIndex contentsEndIndex
;
1651 #ifndef CFStringGetLineBounds
1652 PyMac_PRECHECK(CFStringGetLineBounds
);
1654 if (!PyArg_ParseTuple(_args
, "O&",
1655 CFRange_Convert
, &range
))
1657 CFStringGetLineBounds(_self
->ob_itself
,
1662 _res
= Py_BuildValue("lll",
1669 static PyObject
*CFStringRefObj_CFStringCreateArrayBySeparatingStrings(CFStringRefObject
*_self
, PyObject
*_args
)
1671 PyObject
*_res
= NULL
;
1673 CFStringRef separatorString
;
1674 if (!PyArg_ParseTuple(_args
, "O&",
1675 CFStringRefObj_Convert
, &separatorString
))
1677 _rv
= CFStringCreateArrayBySeparatingStrings((CFAllocatorRef
)NULL
,
1680 _res
= Py_BuildValue("O&",
1681 CFArrayRefObj_New
, _rv
);
1685 static PyObject
*CFStringRefObj_CFStringGetIntValue(CFStringRefObject
*_self
, PyObject
*_args
)
1687 PyObject
*_res
= NULL
;
1689 #ifndef CFStringGetIntValue
1690 PyMac_PRECHECK(CFStringGetIntValue
);
1692 if (!PyArg_ParseTuple(_args
, ""))
1694 _rv
= CFStringGetIntValue(_self
->ob_itself
);
1695 _res
= Py_BuildValue("l",
1700 static PyObject
*CFStringRefObj_CFStringGetDoubleValue(CFStringRefObject
*_self
, PyObject
*_args
)
1702 PyObject
*_res
= NULL
;
1704 #ifndef CFStringGetDoubleValue
1705 PyMac_PRECHECK(CFStringGetDoubleValue
);
1707 if (!PyArg_ParseTuple(_args
, ""))
1709 _rv
= CFStringGetDoubleValue(_self
->ob_itself
);
1710 _res
= Py_BuildValue("d",
1715 static PyObject
*CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
1717 PyObject
*_res
= NULL
;
1718 CFStringEncoding _rv
;
1719 #ifndef CFStringConvertIANACharSetNameToEncoding
1720 PyMac_PRECHECK(CFStringConvertIANACharSetNameToEncoding
);
1722 if (!PyArg_ParseTuple(_args
, ""))
1724 _rv
= CFStringConvertIANACharSetNameToEncoding(_self
->ob_itself
);
1725 _res
= Py_BuildValue("l",
1730 static PyObject
*CFStringRefObj_CFShowStr(CFStringRefObject
*_self
, PyObject
*_args
)
1732 PyObject
*_res
= NULL
;
1734 PyMac_PRECHECK(CFShowStr
);
1736 if (!PyArg_ParseTuple(_args
, ""))
1738 CFShowStr(_self
->ob_itself
);
1744 static PyObject
*CFStringRefObj_CFURLCreateWithString(CFStringRefObject
*_self
, PyObject
*_args
)
1746 PyObject
*_res
= NULL
;
1749 if (!PyArg_ParseTuple(_args
, "O&",
1750 OptionalCFURLRefObj_Convert
, &baseURL
))
1752 _rv
= CFURLCreateWithString((CFAllocatorRef
)NULL
,
1755 _res
= Py_BuildValue("O&",
1756 CFURLRefObj_New
, _rv
);
1760 static PyObject
*CFStringRefObj_CFURLCreateWithFileSystemPath(CFStringRefObject
*_self
, PyObject
*_args
)
1762 PyObject
*_res
= NULL
;
1764 CFURLPathStyle pathStyle
;
1765 Boolean isDirectory
;
1766 if (!PyArg_ParseTuple(_args
, "ll",
1770 _rv
= CFURLCreateWithFileSystemPath((CFAllocatorRef
)NULL
,
1774 _res
= Py_BuildValue("O&",
1775 CFURLRefObj_New
, _rv
);
1779 static PyObject
*CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase(CFStringRefObject
*_self
, PyObject
*_args
)
1781 PyObject
*_res
= NULL
;
1783 CFURLPathStyle pathStyle
;
1784 Boolean isDirectory
;
1786 if (!PyArg_ParseTuple(_args
, "llO&",
1789 OptionalCFURLRefObj_Convert
, &baseURL
))
1791 _rv
= CFURLCreateWithFileSystemPathRelativeToBase((CFAllocatorRef
)NULL
,
1796 _res
= Py_BuildValue("O&",
1797 CFURLRefObj_New
, _rv
);
1801 static PyObject
*CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes(CFStringRefObject
*_self
, PyObject
*_args
)
1803 PyObject
*_res
= NULL
;
1805 CFStringRef charactersToLeaveEscaped
;
1806 if (!PyArg_ParseTuple(_args
, "O&",
1807 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
1809 _rv
= CFURLCreateStringByReplacingPercentEscapes((CFAllocatorRef
)NULL
,
1811 charactersToLeaveEscaped
);
1812 _res
= Py_BuildValue("O&",
1813 CFStringRefObj_New
, _rv
);
1817 static PyObject
*CFStringRefObj_CFURLCreateStringByAddingPercentEscapes(CFStringRefObject
*_self
, PyObject
*_args
)
1819 PyObject
*_res
= NULL
;
1821 CFStringRef charactersToLeaveUnescaped
;
1822 CFStringRef legalURLCharactersToBeEscaped
;
1823 CFStringEncoding encoding
;
1824 if (!PyArg_ParseTuple(_args
, "O&O&l",
1825 CFStringRefObj_Convert
, &charactersToLeaveUnescaped
,
1826 CFStringRefObj_Convert
, &legalURLCharactersToBeEscaped
,
1829 _rv
= CFURLCreateStringByAddingPercentEscapes((CFAllocatorRef
)NULL
,
1831 charactersToLeaveUnescaped
,
1832 legalURLCharactersToBeEscaped
,
1834 _res
= Py_BuildValue("O&",
1835 CFStringRefObj_New
, _rv
);
1839 static PyObject
*CFStringRefObj_CFStringGetString(CFStringRefObject
*_self
, PyObject
*_args
)
1841 PyObject
*_res
= NULL
;
1843 int size
= CFStringGetLength(_self
->ob_itself
)+1;
1844 char *data
= malloc(size
);
1846 if( data
== NULL
) return PyErr_NoMemory();
1847 if ( CFStringGetCString(_self
->ob_itself
, data
, size
, 0) ) {
1848 _res
= (PyObject
*)PyString_FromString(data
);
1850 PyErr_SetString(PyExc_RuntimeError
, "CFStringGetCString could not fit the string");
1858 static PyObject
*CFStringRefObj_CFStringGetUnicode(CFStringRefObject
*_self
, PyObject
*_args
)
1860 PyObject
*_res
= NULL
;
1862 int size
= CFStringGetLength(_self
->ob_itself
)+1;
1863 Py_UNICODE
*data
= malloc(size
*sizeof(Py_UNICODE
));
1867 range
.length
= size
;
1868 if( data
== NULL
) return PyErr_NoMemory();
1869 CFStringGetCharacters(_self
->ob_itself
, range
, data
);
1870 _res
= (PyObject
*)PyUnicode_FromUnicode(data
, size
);
1876 static PyMethodDef CFStringRefObj_methods
[] = {
1877 {"CFStringCreateWithSubstring", (PyCFunction
)CFStringRefObj_CFStringCreateWithSubstring
, 1,
1878 "(CFRange range) -> (CFStringRef _rv)"},
1879 {"CFStringCreateCopy", (PyCFunction
)CFStringRefObj_CFStringCreateCopy
, 1,
1880 "() -> (CFStringRef _rv)"},
1881 {"CFStringGetLength", (PyCFunction
)CFStringRefObj_CFStringGetLength
, 1,
1882 "() -> (CFIndex _rv)"},
1883 {"CFStringGetBytes", (PyCFunction
)CFStringRefObj_CFStringGetBytes
, 1,
1884 "(CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, CFIndex maxBufLen) -> (CFIndex _rv, UInt8 buffer, CFIndex usedBufLen)"},
1885 {"CFStringCreateExternalRepresentation", (PyCFunction
)CFStringRefObj_CFStringCreateExternalRepresentation
, 1,
1886 "(CFStringEncoding encoding, UInt8 lossByte) -> (CFDataRef _rv)"},
1887 {"CFStringGetSmallestEncoding", (PyCFunction
)CFStringRefObj_CFStringGetSmallestEncoding
, 1,
1888 "() -> (CFStringEncoding _rv)"},
1889 {"CFStringGetFastestEncoding", (PyCFunction
)CFStringRefObj_CFStringGetFastestEncoding
, 1,
1890 "() -> (CFStringEncoding _rv)"},
1891 {"CFStringCompareWithOptions", (PyCFunction
)CFStringRefObj_CFStringCompareWithOptions
, 1,
1892 "(CFStringRef theString2, CFRange rangeToCompare, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)"},
1893 {"CFStringCompare", (PyCFunction
)CFStringRefObj_CFStringCompare
, 1,
1894 "(CFStringRef theString2, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)"},
1895 {"CFStringFindWithOptions", (PyCFunction
)CFStringRefObj_CFStringFindWithOptions
, 1,
1896 "(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags searchOptions) -> (Boolean _rv, CFRange result)"},
1897 {"CFStringCreateArrayWithFindResults", (PyCFunction
)CFStringRefObj_CFStringCreateArrayWithFindResults
, 1,
1898 "(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions) -> (CFArrayRef _rv)"},
1899 {"CFStringFind", (PyCFunction
)CFStringRefObj_CFStringFind
, 1,
1900 "(CFStringRef stringToFind, CFOptionFlags compareOptions) -> (CFRange _rv)"},
1901 {"CFStringHasPrefix", (PyCFunction
)CFStringRefObj_CFStringHasPrefix
, 1,
1902 "(CFStringRef prefix) -> (Boolean _rv)"},
1903 {"CFStringHasSuffix", (PyCFunction
)CFStringRefObj_CFStringHasSuffix
, 1,
1904 "(CFStringRef suffix) -> (Boolean _rv)"},
1905 {"CFStringGetLineBounds", (PyCFunction
)CFStringRefObj_CFStringGetLineBounds
, 1,
1906 "(CFRange range) -> (CFIndex lineBeginIndex, CFIndex lineEndIndex, CFIndex contentsEndIndex)"},
1907 {"CFStringCreateArrayBySeparatingStrings", (PyCFunction
)CFStringRefObj_CFStringCreateArrayBySeparatingStrings
, 1,
1908 "(CFStringRef separatorString) -> (CFArrayRef _rv)"},
1909 {"CFStringGetIntValue", (PyCFunction
)CFStringRefObj_CFStringGetIntValue
, 1,
1910 "() -> (SInt32 _rv)"},
1911 {"CFStringGetDoubleValue", (PyCFunction
)CFStringRefObj_CFStringGetDoubleValue
, 1,
1912 "() -> (double _rv)"},
1913 {"CFStringConvertIANACharSetNameToEncoding", (PyCFunction
)CFStringRefObj_CFStringConvertIANACharSetNameToEncoding
, 1,
1914 "() -> (CFStringEncoding _rv)"},
1915 {"CFShowStr", (PyCFunction
)CFStringRefObj_CFShowStr
, 1,
1917 {"CFURLCreateWithString", (PyCFunction
)CFStringRefObj_CFURLCreateWithString
, 1,
1918 "(CFURLRef baseURL) -> (CFURLRef _rv)"},
1919 {"CFURLCreateWithFileSystemPath", (PyCFunction
)CFStringRefObj_CFURLCreateWithFileSystemPath
, 1,
1920 "(CFURLPathStyle pathStyle, Boolean isDirectory) -> (CFURLRef _rv)"},
1921 {"CFURLCreateWithFileSystemPathRelativeToBase", (PyCFunction
)CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase
, 1,
1922 "(CFURLPathStyle pathStyle, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)"},
1923 {"CFURLCreateStringByReplacingPercentEscapes", (PyCFunction
)CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes
, 1,
1924 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
1925 {"CFURLCreateStringByAddingPercentEscapes", (PyCFunction
)CFStringRefObj_CFURLCreateStringByAddingPercentEscapes
, 1,
1926 "(CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding) -> (CFStringRef _rv)"},
1927 {"CFStringGetString", (PyCFunction
)CFStringRefObj_CFStringGetString
, 1,
1928 "() -> (string _rv)"},
1929 {"CFStringGetUnicode", (PyCFunction
)CFStringRefObj_CFStringGetUnicode
, 1,
1930 "() -> (unicode _rv)"},
1934 PyMethodChain CFStringRefObj_chain
= { CFStringRefObj_methods
, &CFTypeRefObj_chain
};
1936 static PyObject
*CFStringRefObj_getattr(CFStringRefObject
*self
, char *name
)
1938 return Py_FindMethodInChain(&CFStringRefObj_chain
, (PyObject
*)self
, name
);
1941 #define CFStringRefObj_setattr NULL
1943 static int CFStringRefObj_compare(CFStringRefObject
*self
, CFStringRefObject
*other
)
1945 /* XXXX Or should we use CFEqual?? */
1946 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1947 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1951 static PyObject
* CFStringRefObj_repr(CFStringRefObject
*self
)
1954 sprintf(buf
, "<CFStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
1955 return PyString_FromString(buf
);
1958 static int CFStringRefObj_hash(CFStringRefObject
*self
)
1960 /* XXXX Or should we use CFHash?? */
1961 return (int)self
->ob_itself
;
1964 PyTypeObject CFStringRef_Type
= {
1965 PyObject_HEAD_INIT(NULL
)
1967 "_CF.CFStringRef", /*tp_name*/
1968 sizeof(CFStringRefObject
), /*tp_basicsize*/
1971 (destructor
) CFStringRefObj_dealloc
, /*tp_dealloc*/
1973 (getattrfunc
) CFStringRefObj_getattr
, /*tp_getattr*/
1974 (setattrfunc
) CFStringRefObj_setattr
, /*tp_setattr*/
1975 (cmpfunc
) CFStringRefObj_compare
, /*tp_compare*/
1976 (reprfunc
) CFStringRefObj_repr
, /*tp_repr*/
1977 (PyNumberMethods
*)0, /* tp_as_number */
1978 (PySequenceMethods
*)0, /* tp_as_sequence */
1979 (PyMappingMethods
*)0, /* tp_as_mapping */
1980 (hashfunc
) CFStringRefObj_hash
, /*tp_hash*/
1983 /* ------------------ End object type CFStringRef ------------------- */
1986 /* ----------------- Object type CFMutableStringRef ----------------- */
1988 PyTypeObject CFMutableStringRef_Type
;
1990 #define CFMutableStringRefObj_Check(x) ((x)->ob_type == &CFMutableStringRef_Type)
1992 typedef struct CFMutableStringRefObject
{
1994 CFMutableStringRef ob_itself
;
1995 void (*ob_freeit
)(CFTypeRef ptr
);
1996 } CFMutableStringRefObject
;
1998 PyObject
*CFMutableStringRefObj_New(CFMutableStringRef itself
)
2000 CFMutableStringRefObject
*it
;
2001 if (itself
== NULL
) return PyMac_Error(resNotFound
);
2002 it
= PyObject_NEW(CFMutableStringRefObject
, &CFMutableStringRef_Type
);
2003 if (it
== NULL
) return NULL
;
2004 it
->ob_itself
= itself
;
2005 it
->ob_freeit
= CFRelease
;
2006 return (PyObject
*)it
;
2008 int CFMutableStringRefObj_Convert(PyObject
*v
, CFMutableStringRef
*p_itself
)
2011 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
2012 /* Check for other CF objects here */
2014 if (!CFMutableStringRefObj_Check(v
))
2016 PyErr_SetString(PyExc_TypeError
, "CFMutableStringRef required");
2019 *p_itself
= ((CFMutableStringRefObject
*)v
)->ob_itself
;
2023 static void CFMutableStringRefObj_dealloc(CFMutableStringRefObject
*self
)
2025 if (self
->ob_freeit
&& self
->ob_itself
)
2027 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
2032 static PyObject
*CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2034 PyObject
*_res
= NULL
;
2035 CFStringRef appendedString
;
2036 #ifndef CFStringAppend
2037 PyMac_PRECHECK(CFStringAppend
);
2039 if (!PyArg_ParseTuple(_args
, "O&",
2040 CFStringRefObj_Convert
, &appendedString
))
2042 CFStringAppend(_self
->ob_itself
,
2049 static PyObject
*CFMutableStringRefObj_CFStringAppendCharacters(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2051 PyObject
*_res
= NULL
;
2052 UniChar
*chars__in__
;
2053 UniCharCount chars__len__
;
2054 int chars__in_len__
;
2055 #ifndef CFStringAppendCharacters
2056 PyMac_PRECHECK(CFStringAppendCharacters
);
2058 if (!PyArg_ParseTuple(_args
, "u#",
2059 &chars__in__
, &chars__in_len__
))
2061 chars__len__
= chars__in_len__
;
2062 CFStringAppendCharacters(_self
->ob_itself
,
2063 chars__in__
, chars__len__
);
2069 static PyObject
*CFMutableStringRefObj_CFStringAppendPascalString(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2071 PyObject
*_res
= NULL
;
2073 CFStringEncoding encoding
;
2074 #ifndef CFStringAppendPascalString
2075 PyMac_PRECHECK(CFStringAppendPascalString
);
2077 if (!PyArg_ParseTuple(_args
, "O&l",
2078 PyMac_GetStr255
, pStr
,
2081 CFStringAppendPascalString(_self
->ob_itself
,
2089 static PyObject
*CFMutableStringRefObj_CFStringAppendCString(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2091 PyObject
*_res
= NULL
;
2093 CFStringEncoding encoding
;
2094 #ifndef CFStringAppendCString
2095 PyMac_PRECHECK(CFStringAppendCString
);
2097 if (!PyArg_ParseTuple(_args
, "sl",
2101 CFStringAppendCString(_self
->ob_itself
,
2109 static PyObject
*CFMutableStringRefObj_CFStringInsert(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2111 PyObject
*_res
= NULL
;
2113 CFStringRef insertedStr
;
2114 #ifndef CFStringInsert
2115 PyMac_PRECHECK(CFStringInsert
);
2117 if (!PyArg_ParseTuple(_args
, "lO&",
2119 CFStringRefObj_Convert
, &insertedStr
))
2121 CFStringInsert(_self
->ob_itself
,
2129 static PyObject
*CFMutableStringRefObj_CFStringDelete(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2131 PyObject
*_res
= NULL
;
2133 #ifndef CFStringDelete
2134 PyMac_PRECHECK(CFStringDelete
);
2136 if (!PyArg_ParseTuple(_args
, "O&",
2137 CFRange_Convert
, &range
))
2139 CFStringDelete(_self
->ob_itself
,
2146 static PyObject
*CFMutableStringRefObj_CFStringReplace(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2148 PyObject
*_res
= NULL
;
2150 CFStringRef replacement
;
2151 #ifndef CFStringReplace
2152 PyMac_PRECHECK(CFStringReplace
);
2154 if (!PyArg_ParseTuple(_args
, "O&O&",
2155 CFRange_Convert
, &range
,
2156 CFStringRefObj_Convert
, &replacement
))
2158 CFStringReplace(_self
->ob_itself
,
2166 static PyObject
*CFMutableStringRefObj_CFStringReplaceAll(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2168 PyObject
*_res
= NULL
;
2169 CFStringRef replacement
;
2170 #ifndef CFStringReplaceAll
2171 PyMac_PRECHECK(CFStringReplaceAll
);
2173 if (!PyArg_ParseTuple(_args
, "O&",
2174 CFStringRefObj_Convert
, &replacement
))
2176 CFStringReplaceAll(_self
->ob_itself
,
2183 static PyObject
*CFMutableStringRefObj_CFStringPad(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2185 PyObject
*_res
= NULL
;
2186 CFStringRef padString
;
2188 CFIndex indexIntoPad
;
2190 PyMac_PRECHECK(CFStringPad
);
2192 if (!PyArg_ParseTuple(_args
, "O&ll",
2193 CFStringRefObj_Convert
, &padString
,
2197 CFStringPad(_self
->ob_itself
,
2206 static PyObject
*CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2208 PyObject
*_res
= NULL
;
2209 CFStringRef trimString
;
2210 #ifndef CFStringTrim
2211 PyMac_PRECHECK(CFStringTrim
);
2213 if (!PyArg_ParseTuple(_args
, "O&",
2214 CFStringRefObj_Convert
, &trimString
))
2216 CFStringTrim(_self
->ob_itself
,
2223 static PyObject
*CFMutableStringRefObj_CFStringTrimWhitespace(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2225 PyObject
*_res
= NULL
;
2226 #ifndef CFStringTrimWhitespace
2227 PyMac_PRECHECK(CFStringTrimWhitespace
);
2229 if (!PyArg_ParseTuple(_args
, ""))
2231 CFStringTrimWhitespace(_self
->ob_itself
);
2237 static PyMethodDef CFMutableStringRefObj_methods
[] = {
2238 {"CFStringAppend", (PyCFunction
)CFMutableStringRefObj_CFStringAppend
, 1,
2239 "(CFStringRef appendedString) -> None"},
2240 {"CFStringAppendCharacters", (PyCFunction
)CFMutableStringRefObj_CFStringAppendCharacters
, 1,
2241 "(Buffer chars) -> None"},
2242 {"CFStringAppendPascalString", (PyCFunction
)CFMutableStringRefObj_CFStringAppendPascalString
, 1,
2243 "(Str255 pStr, CFStringEncoding encoding) -> None"},
2244 {"CFStringAppendCString", (PyCFunction
)CFMutableStringRefObj_CFStringAppendCString
, 1,
2245 "(char* cStr, CFStringEncoding encoding) -> None"},
2246 {"CFStringInsert", (PyCFunction
)CFMutableStringRefObj_CFStringInsert
, 1,
2247 "(CFIndex idx, CFStringRef insertedStr) -> None"},
2248 {"CFStringDelete", (PyCFunction
)CFMutableStringRefObj_CFStringDelete
, 1,
2249 "(CFRange range) -> None"},
2250 {"CFStringReplace", (PyCFunction
)CFMutableStringRefObj_CFStringReplace
, 1,
2251 "(CFRange range, CFStringRef replacement) -> None"},
2252 {"CFStringReplaceAll", (PyCFunction
)CFMutableStringRefObj_CFStringReplaceAll
, 1,
2253 "(CFStringRef replacement) -> None"},
2254 {"CFStringPad", (PyCFunction
)CFMutableStringRefObj_CFStringPad
, 1,
2255 "(CFStringRef padString, CFIndex length, CFIndex indexIntoPad) -> None"},
2256 {"CFStringTrim", (PyCFunction
)CFMutableStringRefObj_CFStringTrim
, 1,
2257 "(CFStringRef trimString) -> None"},
2258 {"CFStringTrimWhitespace", (PyCFunction
)CFMutableStringRefObj_CFStringTrimWhitespace
, 1,
2263 PyMethodChain CFMutableStringRefObj_chain
= { CFMutableStringRefObj_methods
, &CFStringRefObj_chain
};
2265 static PyObject
*CFMutableStringRefObj_getattr(CFMutableStringRefObject
*self
, char *name
)
2267 return Py_FindMethodInChain(&CFMutableStringRefObj_chain
, (PyObject
*)self
, name
);
2270 #define CFMutableStringRefObj_setattr NULL
2272 static int CFMutableStringRefObj_compare(CFMutableStringRefObject
*self
, CFMutableStringRefObject
*other
)
2274 /* XXXX Or should we use CFEqual?? */
2275 if ( self
->ob_itself
> other
->ob_itself
) return 1;
2276 if ( self
->ob_itself
< other
->ob_itself
) return -1;
2280 static PyObject
* CFMutableStringRefObj_repr(CFMutableStringRefObject
*self
)
2283 sprintf(buf
, "<CFMutableStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
2284 return PyString_FromString(buf
);
2287 static int CFMutableStringRefObj_hash(CFMutableStringRefObject
*self
)
2289 /* XXXX Or should we use CFHash?? */
2290 return (int)self
->ob_itself
;
2293 PyTypeObject CFMutableStringRef_Type
= {
2294 PyObject_HEAD_INIT(NULL
)
2296 "_CF.CFMutableStringRef", /*tp_name*/
2297 sizeof(CFMutableStringRefObject
), /*tp_basicsize*/
2300 (destructor
) CFMutableStringRefObj_dealloc
, /*tp_dealloc*/
2302 (getattrfunc
) CFMutableStringRefObj_getattr
, /*tp_getattr*/
2303 (setattrfunc
) CFMutableStringRefObj_setattr
, /*tp_setattr*/
2304 (cmpfunc
) CFMutableStringRefObj_compare
, /*tp_compare*/
2305 (reprfunc
) CFMutableStringRefObj_repr
, /*tp_repr*/
2306 (PyNumberMethods
*)0, /* tp_as_number */
2307 (PySequenceMethods
*)0, /* tp_as_sequence */
2308 (PyMappingMethods
*)0, /* tp_as_mapping */
2309 (hashfunc
) CFMutableStringRefObj_hash
, /*tp_hash*/
2312 /* --------------- End object type CFMutableStringRef --------------- */
2315 /* ---------------------- Object type CFURLRef ---------------------- */
2317 PyTypeObject CFURLRef_Type
;
2319 #define CFURLRefObj_Check(x) ((x)->ob_type == &CFURLRef_Type)
2321 typedef struct CFURLRefObject
{
2324 void (*ob_freeit
)(CFTypeRef ptr
);
2327 PyObject
*CFURLRefObj_New(CFURLRef itself
)
2330 if (itself
== NULL
) return PyMac_Error(resNotFound
);
2331 it
= PyObject_NEW(CFURLRefObject
, &CFURLRef_Type
);
2332 if (it
== NULL
) return NULL
;
2333 it
->ob_itself
= itself
;
2334 it
->ob_freeit
= CFRelease
;
2335 return (PyObject
*)it
;
2337 int CFURLRefObj_Convert(PyObject
*v
, CFURLRef
*p_itself
)
2340 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
2341 /* Check for other CF objects here */
2343 if (!CFURLRefObj_Check(v
))
2345 PyErr_SetString(PyExc_TypeError
, "CFURLRef required");
2348 *p_itself
= ((CFURLRefObject
*)v
)->ob_itself
;
2352 static void CFURLRefObj_dealloc(CFURLRefObject
*self
)
2354 if (self
->ob_freeit
&& self
->ob_itself
)
2356 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
2361 static PyObject
*CFURLRefObj_CFURLCreateData(CFURLRefObject
*_self
, PyObject
*_args
)
2363 PyObject
*_res
= NULL
;
2365 CFStringEncoding encoding
;
2366 Boolean escapeWhitespace
;
2367 if (!PyArg_ParseTuple(_args
, "ll",
2371 _rv
= CFURLCreateData((CFAllocatorRef
)NULL
,
2375 _res
= Py_BuildValue("O&",
2376 CFDataRefObj_New
, _rv
);
2380 static PyObject
*CFURLRefObj_CFURLGetFileSystemRepresentation(CFURLRefObject
*_self
, PyObject
*_args
)
2382 PyObject
*_res
= NULL
;
2384 Boolean resolveAgainstBase
;
2387 #ifndef CFURLGetFileSystemRepresentation
2388 PyMac_PRECHECK(CFURLGetFileSystemRepresentation
);
2390 if (!PyArg_ParseTuple(_args
, "ll",
2391 &resolveAgainstBase
,
2394 _rv
= CFURLGetFileSystemRepresentation(_self
->ob_itself
,
2398 _res
= Py_BuildValue("lb",
2404 static PyObject
*CFURLRefObj_CFURLCopyAbsoluteURL(CFURLRefObject
*_self
, PyObject
*_args
)
2406 PyObject
*_res
= NULL
;
2408 #ifndef CFURLCopyAbsoluteURL
2409 PyMac_PRECHECK(CFURLCopyAbsoluteURL
);
2411 if (!PyArg_ParseTuple(_args
, ""))
2413 _rv
= CFURLCopyAbsoluteURL(_self
->ob_itself
);
2414 _res
= Py_BuildValue("O&",
2415 CFURLRefObj_New
, _rv
);
2419 static PyObject
*CFURLRefObj_CFURLGetString(CFURLRefObject
*_self
, PyObject
*_args
)
2421 PyObject
*_res
= NULL
;
2423 #ifndef CFURLGetString
2424 PyMac_PRECHECK(CFURLGetString
);
2426 if (!PyArg_ParseTuple(_args
, ""))
2428 _rv
= CFURLGetString(_self
->ob_itself
);
2429 _res
= Py_BuildValue("O&",
2430 CFStringRefObj_New
, _rv
);
2434 static PyObject
*CFURLRefObj_CFURLGetBaseURL(CFURLRefObject
*_self
, PyObject
*_args
)
2436 PyObject
*_res
= NULL
;
2438 #ifndef CFURLGetBaseURL
2439 PyMac_PRECHECK(CFURLGetBaseURL
);
2441 if (!PyArg_ParseTuple(_args
, ""))
2443 _rv
= CFURLGetBaseURL(_self
->ob_itself
);
2444 _res
= Py_BuildValue("O&",
2445 CFURLRefObj_New
, _rv
);
2449 static PyObject
*CFURLRefObj_CFURLCanBeDecomposed(CFURLRefObject
*_self
, PyObject
*_args
)
2451 PyObject
*_res
= NULL
;
2453 #ifndef CFURLCanBeDecomposed
2454 PyMac_PRECHECK(CFURLCanBeDecomposed
);
2456 if (!PyArg_ParseTuple(_args
, ""))
2458 _rv
= CFURLCanBeDecomposed(_self
->ob_itself
);
2459 _res
= Py_BuildValue("l",
2464 static PyObject
*CFURLRefObj_CFURLCopyScheme(CFURLRefObject
*_self
, PyObject
*_args
)
2466 PyObject
*_res
= NULL
;
2468 #ifndef CFURLCopyScheme
2469 PyMac_PRECHECK(CFURLCopyScheme
);
2471 if (!PyArg_ParseTuple(_args
, ""))
2473 _rv
= CFURLCopyScheme(_self
->ob_itself
);
2474 _res
= Py_BuildValue("O&",
2475 CFStringRefObj_New
, _rv
);
2479 static PyObject
*CFURLRefObj_CFURLCopyNetLocation(CFURLRefObject
*_self
, PyObject
*_args
)
2481 PyObject
*_res
= NULL
;
2483 #ifndef CFURLCopyNetLocation
2484 PyMac_PRECHECK(CFURLCopyNetLocation
);
2486 if (!PyArg_ParseTuple(_args
, ""))
2488 _rv
= CFURLCopyNetLocation(_self
->ob_itself
);
2489 _res
= Py_BuildValue("O&",
2490 CFStringRefObj_New
, _rv
);
2494 static PyObject
*CFURLRefObj_CFURLCopyPath(CFURLRefObject
*_self
, PyObject
*_args
)
2496 PyObject
*_res
= NULL
;
2498 #ifndef CFURLCopyPath
2499 PyMac_PRECHECK(CFURLCopyPath
);
2501 if (!PyArg_ParseTuple(_args
, ""))
2503 _rv
= CFURLCopyPath(_self
->ob_itself
);
2504 _res
= Py_BuildValue("O&",
2505 CFStringRefObj_New
, _rv
);
2509 static PyObject
*CFURLRefObj_CFURLCopyStrictPath(CFURLRefObject
*_self
, PyObject
*_args
)
2511 PyObject
*_res
= NULL
;
2514 #ifndef CFURLCopyStrictPath
2515 PyMac_PRECHECK(CFURLCopyStrictPath
);
2517 if (!PyArg_ParseTuple(_args
, ""))
2519 _rv
= CFURLCopyStrictPath(_self
->ob_itself
,
2521 _res
= Py_BuildValue("O&l",
2522 CFStringRefObj_New
, _rv
,
2527 static PyObject
*CFURLRefObj_CFURLCopyFileSystemPath(CFURLRefObject
*_self
, PyObject
*_args
)
2529 PyObject
*_res
= NULL
;
2531 CFURLPathStyle pathStyle
;
2532 #ifndef CFURLCopyFileSystemPath
2533 PyMac_PRECHECK(CFURLCopyFileSystemPath
);
2535 if (!PyArg_ParseTuple(_args
, "l",
2538 _rv
= CFURLCopyFileSystemPath(_self
->ob_itself
,
2540 _res
= Py_BuildValue("O&",
2541 CFStringRefObj_New
, _rv
);
2545 static PyObject
*CFURLRefObj_CFURLHasDirectoryPath(CFURLRefObject
*_self
, PyObject
*_args
)
2547 PyObject
*_res
= NULL
;
2549 #ifndef CFURLHasDirectoryPath
2550 PyMac_PRECHECK(CFURLHasDirectoryPath
);
2552 if (!PyArg_ParseTuple(_args
, ""))
2554 _rv
= CFURLHasDirectoryPath(_self
->ob_itself
);
2555 _res
= Py_BuildValue("l",
2560 static PyObject
*CFURLRefObj_CFURLCopyResourceSpecifier(CFURLRefObject
*_self
, PyObject
*_args
)
2562 PyObject
*_res
= NULL
;
2564 #ifndef CFURLCopyResourceSpecifier
2565 PyMac_PRECHECK(CFURLCopyResourceSpecifier
);
2567 if (!PyArg_ParseTuple(_args
, ""))
2569 _rv
= CFURLCopyResourceSpecifier(_self
->ob_itself
);
2570 _res
= Py_BuildValue("O&",
2571 CFStringRefObj_New
, _rv
);
2575 static PyObject
*CFURLRefObj_CFURLCopyHostName(CFURLRefObject
*_self
, PyObject
*_args
)
2577 PyObject
*_res
= NULL
;
2579 #ifndef CFURLCopyHostName
2580 PyMac_PRECHECK(CFURLCopyHostName
);
2582 if (!PyArg_ParseTuple(_args
, ""))
2584 _rv
= CFURLCopyHostName(_self
->ob_itself
);
2585 _res
= Py_BuildValue("O&",
2586 CFStringRefObj_New
, _rv
);
2590 static PyObject
*CFURLRefObj_CFURLGetPortNumber(CFURLRefObject
*_self
, PyObject
*_args
)
2592 PyObject
*_res
= NULL
;
2594 #ifndef CFURLGetPortNumber
2595 PyMac_PRECHECK(CFURLGetPortNumber
);
2597 if (!PyArg_ParseTuple(_args
, ""))
2599 _rv
= CFURLGetPortNumber(_self
->ob_itself
);
2600 _res
= Py_BuildValue("l",
2605 static PyObject
*CFURLRefObj_CFURLCopyUserName(CFURLRefObject
*_self
, PyObject
*_args
)
2607 PyObject
*_res
= NULL
;
2609 #ifndef CFURLCopyUserName
2610 PyMac_PRECHECK(CFURLCopyUserName
);
2612 if (!PyArg_ParseTuple(_args
, ""))
2614 _rv
= CFURLCopyUserName(_self
->ob_itself
);
2615 _res
= Py_BuildValue("O&",
2616 CFStringRefObj_New
, _rv
);
2620 static PyObject
*CFURLRefObj_CFURLCopyPassword(CFURLRefObject
*_self
, PyObject
*_args
)
2622 PyObject
*_res
= NULL
;
2624 #ifndef CFURLCopyPassword
2625 PyMac_PRECHECK(CFURLCopyPassword
);
2627 if (!PyArg_ParseTuple(_args
, ""))
2629 _rv
= CFURLCopyPassword(_self
->ob_itself
);
2630 _res
= Py_BuildValue("O&",
2631 CFStringRefObj_New
, _rv
);
2635 static PyObject
*CFURLRefObj_CFURLCopyParameterString(CFURLRefObject
*_self
, PyObject
*_args
)
2637 PyObject
*_res
= NULL
;
2639 CFStringRef charactersToLeaveEscaped
;
2640 #ifndef CFURLCopyParameterString
2641 PyMac_PRECHECK(CFURLCopyParameterString
);
2643 if (!PyArg_ParseTuple(_args
, "O&",
2644 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
2646 _rv
= CFURLCopyParameterString(_self
->ob_itself
,
2647 charactersToLeaveEscaped
);
2648 _res
= Py_BuildValue("O&",
2649 CFStringRefObj_New
, _rv
);
2653 static PyObject
*CFURLRefObj_CFURLCopyQueryString(CFURLRefObject
*_self
, PyObject
*_args
)
2655 PyObject
*_res
= NULL
;
2657 CFStringRef charactersToLeaveEscaped
;
2658 #ifndef CFURLCopyQueryString
2659 PyMac_PRECHECK(CFURLCopyQueryString
);
2661 if (!PyArg_ParseTuple(_args
, "O&",
2662 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
2664 _rv
= CFURLCopyQueryString(_self
->ob_itself
,
2665 charactersToLeaveEscaped
);
2666 _res
= Py_BuildValue("O&",
2667 CFStringRefObj_New
, _rv
);
2671 static PyObject
*CFURLRefObj_CFURLCopyFragment(CFURLRefObject
*_self
, PyObject
*_args
)
2673 PyObject
*_res
= NULL
;
2675 CFStringRef charactersToLeaveEscaped
;
2676 #ifndef CFURLCopyFragment
2677 PyMac_PRECHECK(CFURLCopyFragment
);
2679 if (!PyArg_ParseTuple(_args
, "O&",
2680 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
2682 _rv
= CFURLCopyFragment(_self
->ob_itself
,
2683 charactersToLeaveEscaped
);
2684 _res
= Py_BuildValue("O&",
2685 CFStringRefObj_New
, _rv
);
2689 static PyObject
*CFURLRefObj_CFURLCopyLastPathComponent(CFURLRefObject
*_self
, PyObject
*_args
)
2691 PyObject
*_res
= NULL
;
2693 #ifndef CFURLCopyLastPathComponent
2694 PyMac_PRECHECK(CFURLCopyLastPathComponent
);
2696 if (!PyArg_ParseTuple(_args
, ""))
2698 _rv
= CFURLCopyLastPathComponent(_self
->ob_itself
);
2699 _res
= Py_BuildValue("O&",
2700 CFStringRefObj_New
, _rv
);
2704 static PyObject
*CFURLRefObj_CFURLCopyPathExtension(CFURLRefObject
*_self
, PyObject
*_args
)
2706 PyObject
*_res
= NULL
;
2708 #ifndef CFURLCopyPathExtension
2709 PyMac_PRECHECK(CFURLCopyPathExtension
);
2711 if (!PyArg_ParseTuple(_args
, ""))
2713 _rv
= CFURLCopyPathExtension(_self
->ob_itself
);
2714 _res
= Py_BuildValue("O&",
2715 CFStringRefObj_New
, _rv
);
2719 static PyObject
*CFURLRefObj_CFURLCreateCopyAppendingPathComponent(CFURLRefObject
*_self
, PyObject
*_args
)
2721 PyObject
*_res
= NULL
;
2723 CFStringRef pathComponent
;
2724 Boolean isDirectory
;
2725 if (!PyArg_ParseTuple(_args
, "O&l",
2726 CFStringRefObj_Convert
, &pathComponent
,
2729 _rv
= CFURLCreateCopyAppendingPathComponent((CFAllocatorRef
)NULL
,
2733 _res
= Py_BuildValue("O&",
2734 CFURLRefObj_New
, _rv
);
2738 static PyObject
*CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent(CFURLRefObject
*_self
, PyObject
*_args
)
2740 PyObject
*_res
= NULL
;
2742 if (!PyArg_ParseTuple(_args
, ""))
2744 _rv
= CFURLCreateCopyDeletingLastPathComponent((CFAllocatorRef
)NULL
,
2746 _res
= Py_BuildValue("O&",
2747 CFURLRefObj_New
, _rv
);
2751 static PyObject
*CFURLRefObj_CFURLCreateCopyAppendingPathExtension(CFURLRefObject
*_self
, PyObject
*_args
)
2753 PyObject
*_res
= NULL
;
2755 CFStringRef extension
;
2756 if (!PyArg_ParseTuple(_args
, "O&",
2757 CFStringRefObj_Convert
, &extension
))
2759 _rv
= CFURLCreateCopyAppendingPathExtension((CFAllocatorRef
)NULL
,
2762 _res
= Py_BuildValue("O&",
2763 CFURLRefObj_New
, _rv
);
2767 static PyObject
*CFURLRefObj_CFURLCreateCopyDeletingPathExtension(CFURLRefObject
*_self
, PyObject
*_args
)
2769 PyObject
*_res
= NULL
;
2771 if (!PyArg_ParseTuple(_args
, ""))
2773 _rv
= CFURLCreateCopyDeletingPathExtension((CFAllocatorRef
)NULL
,
2775 _res
= Py_BuildValue("O&",
2776 CFURLRefObj_New
, _rv
);
2780 static PyObject
*CFURLRefObj_CFURLGetFSRef(CFURLRefObject
*_self
, PyObject
*_args
)
2782 PyObject
*_res
= NULL
;
2785 #ifndef CFURLGetFSRef
2786 PyMac_PRECHECK(CFURLGetFSRef
);
2788 if (!PyArg_ParseTuple(_args
, ""))
2790 _rv
= CFURLGetFSRef(_self
->ob_itself
,
2792 _res
= Py_BuildValue("lO&",
2794 PyMac_BuildFSRef
, &fsRef
);
2798 static PyMethodDef CFURLRefObj_methods
[] = {
2799 {"CFURLCreateData", (PyCFunction
)CFURLRefObj_CFURLCreateData
, 1,
2800 "(CFStringEncoding encoding, Boolean escapeWhitespace) -> (CFDataRef _rv)"},
2801 {"CFURLGetFileSystemRepresentation", (PyCFunction
)CFURLRefObj_CFURLGetFileSystemRepresentation
, 1,
2802 "(Boolean resolveAgainstBase, CFIndex maxBufLen) -> (Boolean _rv, UInt8 buffer)"},
2803 {"CFURLCopyAbsoluteURL", (PyCFunction
)CFURLRefObj_CFURLCopyAbsoluteURL
, 1,
2804 "() -> (CFURLRef _rv)"},
2805 {"CFURLGetString", (PyCFunction
)CFURLRefObj_CFURLGetString
, 1,
2806 "() -> (CFStringRef _rv)"},
2807 {"CFURLGetBaseURL", (PyCFunction
)CFURLRefObj_CFURLGetBaseURL
, 1,
2808 "() -> (CFURLRef _rv)"},
2809 {"CFURLCanBeDecomposed", (PyCFunction
)CFURLRefObj_CFURLCanBeDecomposed
, 1,
2810 "() -> (Boolean _rv)"},
2811 {"CFURLCopyScheme", (PyCFunction
)CFURLRefObj_CFURLCopyScheme
, 1,
2812 "() -> (CFStringRef _rv)"},
2813 {"CFURLCopyNetLocation", (PyCFunction
)CFURLRefObj_CFURLCopyNetLocation
, 1,
2814 "() -> (CFStringRef _rv)"},
2815 {"CFURLCopyPath", (PyCFunction
)CFURLRefObj_CFURLCopyPath
, 1,
2816 "() -> (CFStringRef _rv)"},
2817 {"CFURLCopyStrictPath", (PyCFunction
)CFURLRefObj_CFURLCopyStrictPath
, 1,
2818 "() -> (CFStringRef _rv, Boolean isAbsolute)"},
2819 {"CFURLCopyFileSystemPath", (PyCFunction
)CFURLRefObj_CFURLCopyFileSystemPath
, 1,
2820 "(CFURLPathStyle pathStyle) -> (CFStringRef _rv)"},
2821 {"CFURLHasDirectoryPath", (PyCFunction
)CFURLRefObj_CFURLHasDirectoryPath
, 1,
2822 "() -> (Boolean _rv)"},
2823 {"CFURLCopyResourceSpecifier", (PyCFunction
)CFURLRefObj_CFURLCopyResourceSpecifier
, 1,
2824 "() -> (CFStringRef _rv)"},
2825 {"CFURLCopyHostName", (PyCFunction
)CFURLRefObj_CFURLCopyHostName
, 1,
2826 "() -> (CFStringRef _rv)"},
2827 {"CFURLGetPortNumber", (PyCFunction
)CFURLRefObj_CFURLGetPortNumber
, 1,
2828 "() -> (SInt32 _rv)"},
2829 {"CFURLCopyUserName", (PyCFunction
)CFURLRefObj_CFURLCopyUserName
, 1,
2830 "() -> (CFStringRef _rv)"},
2831 {"CFURLCopyPassword", (PyCFunction
)CFURLRefObj_CFURLCopyPassword
, 1,
2832 "() -> (CFStringRef _rv)"},
2833 {"CFURLCopyParameterString", (PyCFunction
)CFURLRefObj_CFURLCopyParameterString
, 1,
2834 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2835 {"CFURLCopyQueryString", (PyCFunction
)CFURLRefObj_CFURLCopyQueryString
, 1,
2836 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2837 {"CFURLCopyFragment", (PyCFunction
)CFURLRefObj_CFURLCopyFragment
, 1,
2838 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2839 {"CFURLCopyLastPathComponent", (PyCFunction
)CFURLRefObj_CFURLCopyLastPathComponent
, 1,
2840 "() -> (CFStringRef _rv)"},
2841 {"CFURLCopyPathExtension", (PyCFunction
)CFURLRefObj_CFURLCopyPathExtension
, 1,
2842 "() -> (CFStringRef _rv)"},
2843 {"CFURLCreateCopyAppendingPathComponent", (PyCFunction
)CFURLRefObj_CFURLCreateCopyAppendingPathComponent
, 1,
2844 "(CFStringRef pathComponent, Boolean isDirectory) -> (CFURLRef _rv)"},
2845 {"CFURLCreateCopyDeletingLastPathComponent", (PyCFunction
)CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent
, 1,
2846 "() -> (CFURLRef _rv)"},
2847 {"CFURLCreateCopyAppendingPathExtension", (PyCFunction
)CFURLRefObj_CFURLCreateCopyAppendingPathExtension
, 1,
2848 "(CFStringRef extension) -> (CFURLRef _rv)"},
2849 {"CFURLCreateCopyDeletingPathExtension", (PyCFunction
)CFURLRefObj_CFURLCreateCopyDeletingPathExtension
, 1,
2850 "() -> (CFURLRef _rv)"},
2851 {"CFURLGetFSRef", (PyCFunction
)CFURLRefObj_CFURLGetFSRef
, 1,
2852 "() -> (Boolean _rv, FSRef fsRef)"},
2856 PyMethodChain CFURLRefObj_chain
= { CFURLRefObj_methods
, &CFTypeRefObj_chain
};
2858 static PyObject
*CFURLRefObj_getattr(CFURLRefObject
*self
, char *name
)
2860 return Py_FindMethodInChain(&CFURLRefObj_chain
, (PyObject
*)self
, name
);
2863 #define CFURLRefObj_setattr NULL
2865 static int CFURLRefObj_compare(CFURLRefObject
*self
, CFURLRefObject
*other
)
2867 /* XXXX Or should we use CFEqual?? */
2868 if ( self
->ob_itself
> other
->ob_itself
) return 1;
2869 if ( self
->ob_itself
< other
->ob_itself
) return -1;
2873 static PyObject
* CFURLRefObj_repr(CFURLRefObject
*self
)
2876 sprintf(buf
, "<CFURL object at 0x%8.8x for 0x%8.8x>", (unsigned)self
, (unsigned)self
->ob_itself
);
2877 return PyString_FromString(buf
);
2880 static int CFURLRefObj_hash(CFURLRefObject
*self
)
2882 /* XXXX Or should we use CFHash?? */
2883 return (int)self
->ob_itself
;
2886 PyTypeObject CFURLRef_Type
= {
2887 PyObject_HEAD_INIT(NULL
)
2889 "_CF.CFURLRef", /*tp_name*/
2890 sizeof(CFURLRefObject
), /*tp_basicsize*/
2893 (destructor
) CFURLRefObj_dealloc
, /*tp_dealloc*/
2895 (getattrfunc
) CFURLRefObj_getattr
, /*tp_getattr*/
2896 (setattrfunc
) CFURLRefObj_setattr
, /*tp_setattr*/
2897 (cmpfunc
) CFURLRefObj_compare
, /*tp_compare*/
2898 (reprfunc
) CFURLRefObj_repr
, /*tp_repr*/
2899 (PyNumberMethods
*)0, /* tp_as_number */
2900 (PySequenceMethods
*)0, /* tp_as_sequence */
2901 (PyMappingMethods
*)0, /* tp_as_mapping */
2902 (hashfunc
) CFURLRefObj_hash
, /*tp_hash*/
2905 /* -------------------- End object type CFURLRef -------------------- */
2908 static PyObject
*CF___CFRangeMake(PyObject
*_self
, PyObject
*_args
)
2910 PyObject
*_res
= NULL
;
2914 #ifndef __CFRangeMake
2915 PyMac_PRECHECK(__CFRangeMake
);
2917 if (!PyArg_ParseTuple(_args
, "ll",
2921 _rv
= __CFRangeMake(loc
,
2923 _res
= Py_BuildValue("O&",
2928 static PyObject
*CF_CFAllocatorGetTypeID(PyObject
*_self
, PyObject
*_args
)
2930 PyObject
*_res
= NULL
;
2932 #ifndef CFAllocatorGetTypeID
2933 PyMac_PRECHECK(CFAllocatorGetTypeID
);
2935 if (!PyArg_ParseTuple(_args
, ""))
2937 _rv
= CFAllocatorGetTypeID();
2938 _res
= Py_BuildValue("l",
2943 static PyObject
*CF_CFAllocatorGetPreferredSizeForSize(PyObject
*_self
, PyObject
*_args
)
2945 PyObject
*_res
= NULL
;
2949 #ifndef CFAllocatorGetPreferredSizeForSize
2950 PyMac_PRECHECK(CFAllocatorGetPreferredSizeForSize
);
2952 if (!PyArg_ParseTuple(_args
, "ll",
2956 _rv
= CFAllocatorGetPreferredSizeForSize((CFAllocatorRef
)NULL
,
2959 _res
= Py_BuildValue("l",
2964 static PyObject
*CF_CFCopyTypeIDDescription(PyObject
*_self
, PyObject
*_args
)
2966 PyObject
*_res
= NULL
;
2969 #ifndef CFCopyTypeIDDescription
2970 PyMac_PRECHECK(CFCopyTypeIDDescription
);
2972 if (!PyArg_ParseTuple(_args
, "l",
2975 _rv
= CFCopyTypeIDDescription(type_id
);
2976 _res
= Py_BuildValue("O&",
2977 CFStringRefObj_New
, _rv
);
2981 static PyObject
*CF_CFArrayGetTypeID(PyObject
*_self
, PyObject
*_args
)
2983 PyObject
*_res
= NULL
;
2985 #ifndef CFArrayGetTypeID
2986 PyMac_PRECHECK(CFArrayGetTypeID
);
2988 if (!PyArg_ParseTuple(_args
, ""))
2990 _rv
= CFArrayGetTypeID();
2991 _res
= Py_BuildValue("l",
2996 static PyObject
*CF_CFArrayCreateMutable(PyObject
*_self
, PyObject
*_args
)
2998 PyObject
*_res
= NULL
;
2999 CFMutableArrayRef _rv
;
3001 #ifndef CFArrayCreateMutable
3002 PyMac_PRECHECK(CFArrayCreateMutable
);
3004 if (!PyArg_ParseTuple(_args
, "l",
3007 _rv
= CFArrayCreateMutable((CFAllocatorRef
)NULL
,
3009 &kCFTypeArrayCallBacks
);
3010 _res
= Py_BuildValue("O&",
3011 CFMutableArrayRefObj_New
, _rv
);
3015 static PyObject
*CF_CFArrayCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3017 PyObject
*_res
= NULL
;
3018 CFMutableArrayRef _rv
;
3020 CFArrayRef theArray
;
3021 #ifndef CFArrayCreateMutableCopy
3022 PyMac_PRECHECK(CFArrayCreateMutableCopy
);
3024 if (!PyArg_ParseTuple(_args
, "lO&",
3026 CFArrayRefObj_Convert
, &theArray
))
3028 _rv
= CFArrayCreateMutableCopy((CFAllocatorRef
)NULL
,
3031 _res
= Py_BuildValue("O&",
3032 CFMutableArrayRefObj_New
, _rv
);
3036 static PyObject
*CF_CFDataGetTypeID(PyObject
*_self
, PyObject
*_args
)
3038 PyObject
*_res
= NULL
;
3040 #ifndef CFDataGetTypeID
3041 PyMac_PRECHECK(CFDataGetTypeID
);
3043 if (!PyArg_ParseTuple(_args
, ""))
3045 _rv
= CFDataGetTypeID();
3046 _res
= Py_BuildValue("l",
3051 static PyObject
*CF_CFDataCreate(PyObject
*_self
, PyObject
*_args
)
3053 PyObject
*_res
= NULL
;
3055 unsigned char *bytes__in__
;
3057 int bytes__in_len__
;
3058 #ifndef CFDataCreate
3059 PyMac_PRECHECK(CFDataCreate
);
3061 if (!PyArg_ParseTuple(_args
, "s#",
3062 &bytes__in__
, &bytes__in_len__
))
3064 bytes__len__
= bytes__in_len__
;
3065 _rv
= CFDataCreate((CFAllocatorRef
)NULL
,
3066 bytes__in__
, bytes__len__
);
3067 _res
= Py_BuildValue("O&",
3068 CFDataRefObj_New
, _rv
);
3072 static PyObject
*CF_CFDataCreateWithBytesNoCopy(PyObject
*_self
, PyObject
*_args
)
3074 PyObject
*_res
= NULL
;
3076 unsigned char *bytes__in__
;
3078 int bytes__in_len__
;
3079 #ifndef CFDataCreateWithBytesNoCopy
3080 PyMac_PRECHECK(CFDataCreateWithBytesNoCopy
);
3082 if (!PyArg_ParseTuple(_args
, "s#",
3083 &bytes__in__
, &bytes__in_len__
))
3085 bytes__len__
= bytes__in_len__
;
3086 _rv
= CFDataCreateWithBytesNoCopy((CFAllocatorRef
)NULL
,
3087 bytes__in__
, bytes__len__
,
3088 (CFAllocatorRef
)NULL
);
3089 _res
= Py_BuildValue("O&",
3090 CFDataRefObj_New
, _rv
);
3094 static PyObject
*CF_CFDataCreateMutable(PyObject
*_self
, PyObject
*_args
)
3096 PyObject
*_res
= NULL
;
3097 CFMutableDataRef _rv
;
3099 #ifndef CFDataCreateMutable
3100 PyMac_PRECHECK(CFDataCreateMutable
);
3102 if (!PyArg_ParseTuple(_args
, "l",
3105 _rv
= CFDataCreateMutable((CFAllocatorRef
)NULL
,
3107 _res
= Py_BuildValue("O&",
3108 CFMutableDataRefObj_New
, _rv
);
3112 static PyObject
*CF_CFDataCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3114 PyObject
*_res
= NULL
;
3115 CFMutableDataRef _rv
;
3118 #ifndef CFDataCreateMutableCopy
3119 PyMac_PRECHECK(CFDataCreateMutableCopy
);
3121 if (!PyArg_ParseTuple(_args
, "lO&",
3123 CFDataRefObj_Convert
, &theData
))
3125 _rv
= CFDataCreateMutableCopy((CFAllocatorRef
)NULL
,
3128 _res
= Py_BuildValue("O&",
3129 CFMutableDataRefObj_New
, _rv
);
3133 static PyObject
*CF_CFDictionaryGetTypeID(PyObject
*_self
, PyObject
*_args
)
3135 PyObject
*_res
= NULL
;
3137 #ifndef CFDictionaryGetTypeID
3138 PyMac_PRECHECK(CFDictionaryGetTypeID
);
3140 if (!PyArg_ParseTuple(_args
, ""))
3142 _rv
= CFDictionaryGetTypeID();
3143 _res
= Py_BuildValue("l",
3148 static PyObject
*CF_CFDictionaryCreateMutable(PyObject
*_self
, PyObject
*_args
)
3150 PyObject
*_res
= NULL
;
3151 CFMutableDictionaryRef _rv
;
3153 #ifndef CFDictionaryCreateMutable
3154 PyMac_PRECHECK(CFDictionaryCreateMutable
);
3156 if (!PyArg_ParseTuple(_args
, "l",
3159 _rv
= CFDictionaryCreateMutable((CFAllocatorRef
)NULL
,
3161 &kCFTypeDictionaryKeyCallBacks
,
3162 &kCFTypeDictionaryValueCallBacks
);
3163 _res
= Py_BuildValue("O&",
3164 CFMutableDictionaryRefObj_New
, _rv
);
3168 static PyObject
*CF_CFDictionaryCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3170 PyObject
*_res
= NULL
;
3171 CFMutableDictionaryRef _rv
;
3173 CFDictionaryRef theDict
;
3174 #ifndef CFDictionaryCreateMutableCopy
3175 PyMac_PRECHECK(CFDictionaryCreateMutableCopy
);
3177 if (!PyArg_ParseTuple(_args
, "lO&",
3179 CFDictionaryRefObj_Convert
, &theDict
))
3181 _rv
= CFDictionaryCreateMutableCopy((CFAllocatorRef
)NULL
,
3184 _res
= Py_BuildValue("O&",
3185 CFMutableDictionaryRefObj_New
, _rv
);
3189 static PyObject
*CF_CFStringGetTypeID(PyObject
*_self
, PyObject
*_args
)
3191 PyObject
*_res
= NULL
;
3193 #ifndef CFStringGetTypeID
3194 PyMac_PRECHECK(CFStringGetTypeID
);
3196 if (!PyArg_ParseTuple(_args
, ""))
3198 _rv
= CFStringGetTypeID();
3199 _res
= Py_BuildValue("l",
3204 static PyObject
*CF_CFStringCreateWithPascalString(PyObject
*_self
, PyObject
*_args
)
3206 PyObject
*_res
= NULL
;
3209 CFStringEncoding encoding
;
3210 #ifndef CFStringCreateWithPascalString
3211 PyMac_PRECHECK(CFStringCreateWithPascalString
);
3213 if (!PyArg_ParseTuple(_args
, "O&l",
3214 PyMac_GetStr255
, pStr
,
3217 _rv
= CFStringCreateWithPascalString((CFAllocatorRef
)NULL
,
3220 _res
= Py_BuildValue("O&",
3221 CFStringRefObj_New
, _rv
);
3225 static PyObject
*CF_CFStringCreateWithCString(PyObject
*_self
, PyObject
*_args
)
3227 PyObject
*_res
= NULL
;
3230 CFStringEncoding encoding
;
3231 #ifndef CFStringCreateWithCString
3232 PyMac_PRECHECK(CFStringCreateWithCString
);
3234 if (!PyArg_ParseTuple(_args
, "sl",
3238 _rv
= CFStringCreateWithCString((CFAllocatorRef
)NULL
,
3241 _res
= Py_BuildValue("O&",
3242 CFStringRefObj_New
, _rv
);
3246 static PyObject
*CF_CFStringCreateWithCharacters(PyObject
*_self
, PyObject
*_args
)
3248 PyObject
*_res
= NULL
;
3250 UniChar
*chars__in__
;
3251 UniCharCount chars__len__
;
3252 int chars__in_len__
;
3253 #ifndef CFStringCreateWithCharacters
3254 PyMac_PRECHECK(CFStringCreateWithCharacters
);
3256 if (!PyArg_ParseTuple(_args
, "u#",
3257 &chars__in__
, &chars__in_len__
))
3259 chars__len__
= chars__in_len__
;
3260 _rv
= CFStringCreateWithCharacters((CFAllocatorRef
)NULL
,
3261 chars__in__
, chars__len__
);
3262 _res
= Py_BuildValue("O&",
3263 CFStringRefObj_New
, _rv
);
3267 static PyObject
*CF_CFStringCreateWithPascalStringNoCopy(PyObject
*_self
, PyObject
*_args
)
3269 PyObject
*_res
= NULL
;
3272 CFStringEncoding encoding
;
3273 #ifndef CFStringCreateWithPascalStringNoCopy
3274 PyMac_PRECHECK(CFStringCreateWithPascalStringNoCopy
);
3276 if (!PyArg_ParseTuple(_args
, "O&l",
3277 PyMac_GetStr255
, pStr
,
3280 _rv
= CFStringCreateWithPascalStringNoCopy((CFAllocatorRef
)NULL
,
3283 (CFAllocatorRef
)NULL
);
3284 _res
= Py_BuildValue("O&",
3285 CFStringRefObj_New
, _rv
);
3289 static PyObject
*CF_CFStringCreateWithCStringNoCopy(PyObject
*_self
, PyObject
*_args
)
3291 PyObject
*_res
= NULL
;
3294 CFStringEncoding encoding
;
3295 #ifndef CFStringCreateWithCStringNoCopy
3296 PyMac_PRECHECK(CFStringCreateWithCStringNoCopy
);
3298 if (!PyArg_ParseTuple(_args
, "sl",
3302 _rv
= CFStringCreateWithCStringNoCopy((CFAllocatorRef
)NULL
,
3305 (CFAllocatorRef
)NULL
);
3306 _res
= Py_BuildValue("O&",
3307 CFStringRefObj_New
, _rv
);
3311 static PyObject
*CF_CFStringCreateWithCharactersNoCopy(PyObject
*_self
, PyObject
*_args
)
3313 PyObject
*_res
= NULL
;
3315 UniChar
*chars__in__
;
3316 UniCharCount chars__len__
;
3317 int chars__in_len__
;
3318 #ifndef CFStringCreateWithCharactersNoCopy
3319 PyMac_PRECHECK(CFStringCreateWithCharactersNoCopy
);
3321 if (!PyArg_ParseTuple(_args
, "u#",
3322 &chars__in__
, &chars__in_len__
))
3324 chars__len__
= chars__in_len__
;
3325 _rv
= CFStringCreateWithCharactersNoCopy((CFAllocatorRef
)NULL
,
3326 chars__in__
, chars__len__
,
3327 (CFAllocatorRef
)NULL
);
3328 _res
= Py_BuildValue("O&",
3329 CFStringRefObj_New
, _rv
);
3333 static PyObject
*CF_CFStringCreateMutable(PyObject
*_self
, PyObject
*_args
)
3335 PyObject
*_res
= NULL
;
3336 CFMutableStringRef _rv
;
3338 #ifndef CFStringCreateMutable
3339 PyMac_PRECHECK(CFStringCreateMutable
);
3341 if (!PyArg_ParseTuple(_args
, "l",
3344 _rv
= CFStringCreateMutable((CFAllocatorRef
)NULL
,
3346 _res
= Py_BuildValue("O&",
3347 CFMutableStringRefObj_New
, _rv
);
3351 static PyObject
*CF_CFStringCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
3353 PyObject
*_res
= NULL
;
3354 CFMutableStringRef _rv
;
3356 CFStringRef theString
;
3357 #ifndef CFStringCreateMutableCopy
3358 PyMac_PRECHECK(CFStringCreateMutableCopy
);
3360 if (!PyArg_ParseTuple(_args
, "lO&",
3362 CFStringRefObj_Convert
, &theString
))
3364 _rv
= CFStringCreateMutableCopy((CFAllocatorRef
)NULL
,
3367 _res
= Py_BuildValue("O&",
3368 CFMutableStringRefObj_New
, _rv
);
3372 static PyObject
*CF_CFStringCreateWithBytes(PyObject
*_self
, PyObject
*_args
)
3374 PyObject
*_res
= NULL
;
3376 unsigned char *bytes__in__
;
3378 int bytes__in_len__
;
3379 CFStringEncoding encoding
;
3380 Boolean isExternalRepresentation
;
3381 #ifndef CFStringCreateWithBytes
3382 PyMac_PRECHECK(CFStringCreateWithBytes
);
3384 if (!PyArg_ParseTuple(_args
, "s#ll",
3385 &bytes__in__
, &bytes__in_len__
,
3387 &isExternalRepresentation
))
3389 bytes__len__
= bytes__in_len__
;
3390 _rv
= CFStringCreateWithBytes((CFAllocatorRef
)NULL
,
3391 bytes__in__
, bytes__len__
,
3393 isExternalRepresentation
);
3394 _res
= Py_BuildValue("O&",
3395 CFStringRefObj_New
, _rv
);
3399 static PyObject
*CF_CFStringGetSystemEncoding(PyObject
*_self
, PyObject
*_args
)
3401 PyObject
*_res
= NULL
;
3402 CFStringEncoding _rv
;
3403 #ifndef CFStringGetSystemEncoding
3404 PyMac_PRECHECK(CFStringGetSystemEncoding
);
3406 if (!PyArg_ParseTuple(_args
, ""))
3408 _rv
= CFStringGetSystemEncoding();
3409 _res
= Py_BuildValue("l",
3414 static PyObject
*CF_CFStringGetMaximumSizeForEncoding(PyObject
*_self
, PyObject
*_args
)
3416 PyObject
*_res
= NULL
;
3419 CFStringEncoding encoding
;
3420 #ifndef CFStringGetMaximumSizeForEncoding
3421 PyMac_PRECHECK(CFStringGetMaximumSizeForEncoding
);
3423 if (!PyArg_ParseTuple(_args
, "ll",
3427 _rv
= CFStringGetMaximumSizeForEncoding(length
,
3429 _res
= Py_BuildValue("l",
3434 static PyObject
*CF_CFStringIsEncodingAvailable(PyObject
*_self
, PyObject
*_args
)
3436 PyObject
*_res
= NULL
;
3438 CFStringEncoding encoding
;
3439 #ifndef CFStringIsEncodingAvailable
3440 PyMac_PRECHECK(CFStringIsEncodingAvailable
);
3442 if (!PyArg_ParseTuple(_args
, "l",
3445 _rv
= CFStringIsEncodingAvailable(encoding
);
3446 _res
= Py_BuildValue("l",
3451 static PyObject
*CF_CFStringGetNameOfEncoding(PyObject
*_self
, PyObject
*_args
)
3453 PyObject
*_res
= NULL
;
3455 CFStringEncoding encoding
;
3456 #ifndef CFStringGetNameOfEncoding
3457 PyMac_PRECHECK(CFStringGetNameOfEncoding
);
3459 if (!PyArg_ParseTuple(_args
, "l",
3462 _rv
= CFStringGetNameOfEncoding(encoding
);
3463 _res
= Py_BuildValue("O&",
3464 CFStringRefObj_New
, _rv
);
3468 static PyObject
*CF_CFStringConvertEncodingToNSStringEncoding(PyObject
*_self
, PyObject
*_args
)
3470 PyObject
*_res
= NULL
;
3472 CFStringEncoding encoding
;
3473 #ifndef CFStringConvertEncodingToNSStringEncoding
3474 PyMac_PRECHECK(CFStringConvertEncodingToNSStringEncoding
);
3476 if (!PyArg_ParseTuple(_args
, "l",
3479 _rv
= CFStringConvertEncodingToNSStringEncoding(encoding
);
3480 _res
= Py_BuildValue("l",
3485 static PyObject
*CF_CFStringConvertNSStringEncodingToEncoding(PyObject
*_self
, PyObject
*_args
)
3487 PyObject
*_res
= NULL
;
3488 CFStringEncoding _rv
;
3490 #ifndef CFStringConvertNSStringEncodingToEncoding
3491 PyMac_PRECHECK(CFStringConvertNSStringEncodingToEncoding
);
3493 if (!PyArg_ParseTuple(_args
, "l",
3496 _rv
= CFStringConvertNSStringEncodingToEncoding(encoding
);
3497 _res
= Py_BuildValue("l",
3502 static PyObject
*CF_CFStringConvertEncodingToWindowsCodepage(PyObject
*_self
, PyObject
*_args
)
3504 PyObject
*_res
= NULL
;
3506 CFStringEncoding encoding
;
3507 #ifndef CFStringConvertEncodingToWindowsCodepage
3508 PyMac_PRECHECK(CFStringConvertEncodingToWindowsCodepage
);
3510 if (!PyArg_ParseTuple(_args
, "l",
3513 _rv
= CFStringConvertEncodingToWindowsCodepage(encoding
);
3514 _res
= Py_BuildValue("l",
3519 static PyObject
*CF_CFStringConvertWindowsCodepageToEncoding(PyObject
*_self
, PyObject
*_args
)
3521 PyObject
*_res
= NULL
;
3522 CFStringEncoding _rv
;
3524 #ifndef CFStringConvertWindowsCodepageToEncoding
3525 PyMac_PRECHECK(CFStringConvertWindowsCodepageToEncoding
);
3527 if (!PyArg_ParseTuple(_args
, "l",
3530 _rv
= CFStringConvertWindowsCodepageToEncoding(codepage
);
3531 _res
= Py_BuildValue("l",
3536 static PyObject
*CF_CFStringConvertEncodingToIANACharSetName(PyObject
*_self
, PyObject
*_args
)
3538 PyObject
*_res
= NULL
;
3540 CFStringEncoding encoding
;
3541 #ifndef CFStringConvertEncodingToIANACharSetName
3542 PyMac_PRECHECK(CFStringConvertEncodingToIANACharSetName
);
3544 if (!PyArg_ParseTuple(_args
, "l",
3547 _rv
= CFStringConvertEncodingToIANACharSetName(encoding
);
3548 _res
= Py_BuildValue("O&",
3549 CFStringRefObj_New
, _rv
);
3553 static PyObject
*CF_CFStringGetMostCompatibleMacStringEncoding(PyObject
*_self
, PyObject
*_args
)
3555 PyObject
*_res
= NULL
;
3556 CFStringEncoding _rv
;
3557 CFStringEncoding encoding
;
3558 #ifndef CFStringGetMostCompatibleMacStringEncoding
3559 PyMac_PRECHECK(CFStringGetMostCompatibleMacStringEncoding
);
3561 if (!PyArg_ParseTuple(_args
, "l",
3564 _rv
= CFStringGetMostCompatibleMacStringEncoding(encoding
);
3565 _res
= Py_BuildValue("l",
3570 static PyObject
*CF___CFStringMakeConstantString(PyObject
*_self
, PyObject
*_args
)
3572 PyObject
*_res
= NULL
;
3575 #ifndef __CFStringMakeConstantString
3576 PyMac_PRECHECK(__CFStringMakeConstantString
);
3578 if (!PyArg_ParseTuple(_args
, "s",
3581 _rv
= __CFStringMakeConstantString(cStr
);
3582 _res
= Py_BuildValue("O&",
3583 CFStringRefObj_New
, _rv
);
3587 static PyObject
*CF_CFURLGetTypeID(PyObject
*_self
, PyObject
*_args
)
3589 PyObject
*_res
= NULL
;
3591 #ifndef CFURLGetTypeID
3592 PyMac_PRECHECK(CFURLGetTypeID
);
3594 if (!PyArg_ParseTuple(_args
, ""))
3596 _rv
= CFURLGetTypeID();
3597 _res
= Py_BuildValue("l",
3602 static PyObject
*CF_CFURLCreateWithBytes(PyObject
*_self
, PyObject
*_args
)
3604 PyObject
*_res
= NULL
;
3606 unsigned char *URLBytes__in__
;
3607 long URLBytes__len__
;
3608 int URLBytes__in_len__
;
3609 CFStringEncoding encoding
;
3611 #ifndef CFURLCreateWithBytes
3612 PyMac_PRECHECK(CFURLCreateWithBytes
);
3614 if (!PyArg_ParseTuple(_args
, "s#lO&",
3615 &URLBytes__in__
, &URLBytes__in_len__
,
3617 OptionalCFURLRefObj_Convert
, &baseURL
))
3619 URLBytes__len__
= URLBytes__in_len__
;
3620 _rv
= CFURLCreateWithBytes((CFAllocatorRef
)NULL
,
3621 URLBytes__in__
, URLBytes__len__
,
3624 _res
= Py_BuildValue("O&",
3625 CFURLRefObj_New
, _rv
);
3629 static PyObject
*CF_CFURLCreateFromFileSystemRepresentation(PyObject
*_self
, PyObject
*_args
)
3631 PyObject
*_res
= NULL
;
3633 unsigned char *buffer__in__
;
3635 int buffer__in_len__
;
3636 Boolean isDirectory
;
3637 #ifndef CFURLCreateFromFileSystemRepresentation
3638 PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentation
);
3640 if (!PyArg_ParseTuple(_args
, "s#l",
3641 &buffer__in__
, &buffer__in_len__
,
3644 buffer__len__
= buffer__in_len__
;
3645 _rv
= CFURLCreateFromFileSystemRepresentation((CFAllocatorRef
)NULL
,
3646 buffer__in__
, buffer__len__
,
3648 _res
= Py_BuildValue("O&",
3649 CFURLRefObj_New
, _rv
);
3653 static PyObject
*CF_CFURLCreateFromFileSystemRepresentationRelativeToBase(PyObject
*_self
, PyObject
*_args
)
3655 PyObject
*_res
= NULL
;
3657 unsigned char *buffer__in__
;
3659 int buffer__in_len__
;
3660 Boolean isDirectory
;
3662 #ifndef CFURLCreateFromFileSystemRepresentationRelativeToBase
3663 PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentationRelativeToBase
);
3665 if (!PyArg_ParseTuple(_args
, "s#lO&",
3666 &buffer__in__
, &buffer__in_len__
,
3668 OptionalCFURLRefObj_Convert
, &baseURL
))
3670 buffer__len__
= buffer__in_len__
;
3671 _rv
= CFURLCreateFromFileSystemRepresentationRelativeToBase((CFAllocatorRef
)NULL
,
3672 buffer__in__
, buffer__len__
,
3675 _res
= Py_BuildValue("O&",
3676 CFURLRefObj_New
, _rv
);
3680 static PyObject
*CF_CFURLCreateFromFSRef(PyObject
*_self
, PyObject
*_args
)
3682 PyObject
*_res
= NULL
;
3685 #ifndef CFURLCreateFromFSRef
3686 PyMac_PRECHECK(CFURLCreateFromFSRef
);
3688 if (!PyArg_ParseTuple(_args
, "O&",
3689 PyMac_GetFSRef
, &fsRef
))
3691 _rv
= CFURLCreateFromFSRef((CFAllocatorRef
)NULL
,
3693 _res
= Py_BuildValue("O&",
3694 CFURLRefObj_New
, _rv
);
3698 static PyMethodDef CF_methods
[] = {
3699 {"__CFRangeMake", (PyCFunction
)CF___CFRangeMake
, 1,
3700 "(CFIndex loc, CFIndex len) -> (CFRange _rv)"},
3701 {"CFAllocatorGetTypeID", (PyCFunction
)CF_CFAllocatorGetTypeID
, 1,
3702 "() -> (CFTypeID _rv)"},
3703 {"CFAllocatorGetPreferredSizeForSize", (PyCFunction
)CF_CFAllocatorGetPreferredSizeForSize
, 1,
3704 "(CFIndex size, CFOptionFlags hint) -> (CFIndex _rv)"},
3705 {"CFCopyTypeIDDescription", (PyCFunction
)CF_CFCopyTypeIDDescription
, 1,
3706 "(CFTypeID type_id) -> (CFStringRef _rv)"},
3707 {"CFArrayGetTypeID", (PyCFunction
)CF_CFArrayGetTypeID
, 1,
3708 "() -> (CFTypeID _rv)"},
3709 {"CFArrayCreateMutable", (PyCFunction
)CF_CFArrayCreateMutable
, 1,
3710 "(CFIndex capacity) -> (CFMutableArrayRef _rv)"},
3711 {"CFArrayCreateMutableCopy", (PyCFunction
)CF_CFArrayCreateMutableCopy
, 1,
3712 "(CFIndex capacity, CFArrayRef theArray) -> (CFMutableArrayRef _rv)"},
3713 {"CFDataGetTypeID", (PyCFunction
)CF_CFDataGetTypeID
, 1,
3714 "() -> (CFTypeID _rv)"},
3715 {"CFDataCreate", (PyCFunction
)CF_CFDataCreate
, 1,
3716 "(Buffer bytes) -> (CFDataRef _rv)"},
3717 {"CFDataCreateWithBytesNoCopy", (PyCFunction
)CF_CFDataCreateWithBytesNoCopy
, 1,
3718 "(Buffer bytes) -> (CFDataRef _rv)"},
3719 {"CFDataCreateMutable", (PyCFunction
)CF_CFDataCreateMutable
, 1,
3720 "(CFIndex capacity) -> (CFMutableDataRef _rv)"},
3721 {"CFDataCreateMutableCopy", (PyCFunction
)CF_CFDataCreateMutableCopy
, 1,
3722 "(CFIndex capacity, CFDataRef theData) -> (CFMutableDataRef _rv)"},
3723 {"CFDictionaryGetTypeID", (PyCFunction
)CF_CFDictionaryGetTypeID
, 1,
3724 "() -> (CFTypeID _rv)"},
3725 {"CFDictionaryCreateMutable", (PyCFunction
)CF_CFDictionaryCreateMutable
, 1,
3726 "(CFIndex capacity) -> (CFMutableDictionaryRef _rv)"},
3727 {"CFDictionaryCreateMutableCopy", (PyCFunction
)CF_CFDictionaryCreateMutableCopy
, 1,
3728 "(CFIndex capacity, CFDictionaryRef theDict) -> (CFMutableDictionaryRef _rv)"},
3729 {"CFStringGetTypeID", (PyCFunction
)CF_CFStringGetTypeID
, 1,
3730 "() -> (CFTypeID _rv)"},
3731 {"CFStringCreateWithPascalString", (PyCFunction
)CF_CFStringCreateWithPascalString
, 1,
3732 "(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
3733 {"CFStringCreateWithCString", (PyCFunction
)CF_CFStringCreateWithCString
, 1,
3734 "(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
3735 {"CFStringCreateWithCharacters", (PyCFunction
)CF_CFStringCreateWithCharacters
, 1,
3736 "(Buffer chars) -> (CFStringRef _rv)"},
3737 {"CFStringCreateWithPascalStringNoCopy", (PyCFunction
)CF_CFStringCreateWithPascalStringNoCopy
, 1,
3738 "(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
3739 {"CFStringCreateWithCStringNoCopy", (PyCFunction
)CF_CFStringCreateWithCStringNoCopy
, 1,
3740 "(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
3741 {"CFStringCreateWithCharactersNoCopy", (PyCFunction
)CF_CFStringCreateWithCharactersNoCopy
, 1,
3742 "(Buffer chars) -> (CFStringRef _rv)"},
3743 {"CFStringCreateMutable", (PyCFunction
)CF_CFStringCreateMutable
, 1,
3744 "(CFIndex maxLength) -> (CFMutableStringRef _rv)"},
3745 {"CFStringCreateMutableCopy", (PyCFunction
)CF_CFStringCreateMutableCopy
, 1,
3746 "(CFIndex maxLength, CFStringRef theString) -> (CFMutableStringRef _rv)"},
3747 {"CFStringCreateWithBytes", (PyCFunction
)CF_CFStringCreateWithBytes
, 1,
3748 "(Buffer bytes, CFStringEncoding encoding, Boolean isExternalRepresentation) -> (CFStringRef _rv)"},
3749 {"CFStringGetSystemEncoding", (PyCFunction
)CF_CFStringGetSystemEncoding
, 1,
3750 "() -> (CFStringEncoding _rv)"},
3751 {"CFStringGetMaximumSizeForEncoding", (PyCFunction
)CF_CFStringGetMaximumSizeForEncoding
, 1,
3752 "(CFIndex length, CFStringEncoding encoding) -> (CFIndex _rv)"},
3753 {"CFStringIsEncodingAvailable", (PyCFunction
)CF_CFStringIsEncodingAvailable
, 1,
3754 "(CFStringEncoding encoding) -> (Boolean _rv)"},
3755 {"CFStringGetNameOfEncoding", (PyCFunction
)CF_CFStringGetNameOfEncoding
, 1,
3756 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
3757 {"CFStringConvertEncodingToNSStringEncoding", (PyCFunction
)CF_CFStringConvertEncodingToNSStringEncoding
, 1,
3758 "(CFStringEncoding encoding) -> (UInt32 _rv)"},
3759 {"CFStringConvertNSStringEncodingToEncoding", (PyCFunction
)CF_CFStringConvertNSStringEncodingToEncoding
, 1,
3760 "(UInt32 encoding) -> (CFStringEncoding _rv)"},
3761 {"CFStringConvertEncodingToWindowsCodepage", (PyCFunction
)CF_CFStringConvertEncodingToWindowsCodepage
, 1,
3762 "(CFStringEncoding encoding) -> (UInt32 _rv)"},
3763 {"CFStringConvertWindowsCodepageToEncoding", (PyCFunction
)CF_CFStringConvertWindowsCodepageToEncoding
, 1,
3764 "(UInt32 codepage) -> (CFStringEncoding _rv)"},
3765 {"CFStringConvertEncodingToIANACharSetName", (PyCFunction
)CF_CFStringConvertEncodingToIANACharSetName
, 1,
3766 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
3767 {"CFStringGetMostCompatibleMacStringEncoding", (PyCFunction
)CF_CFStringGetMostCompatibleMacStringEncoding
, 1,
3768 "(CFStringEncoding encoding) -> (CFStringEncoding _rv)"},
3769 {"__CFStringMakeConstantString", (PyCFunction
)CF___CFStringMakeConstantString
, 1,
3770 "(char* cStr) -> (CFStringRef _rv)"},
3771 {"CFURLGetTypeID", (PyCFunction
)CF_CFURLGetTypeID
, 1,
3772 "() -> (CFTypeID _rv)"},
3773 {"CFURLCreateWithBytes", (PyCFunction
)CF_CFURLCreateWithBytes
, 1,
3774 "(Buffer URLBytes, CFStringEncoding encoding, CFURLRef baseURL) -> (CFURLRef _rv)"},
3775 {"CFURLCreateFromFileSystemRepresentation", (PyCFunction
)CF_CFURLCreateFromFileSystemRepresentation
, 1,
3776 "(Buffer buffer, Boolean isDirectory) -> (CFURLRef _rv)"},
3777 {"CFURLCreateFromFileSystemRepresentationRelativeToBase", (PyCFunction
)CF_CFURLCreateFromFileSystemRepresentationRelativeToBase
, 1,
3778 "(Buffer buffer, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)"},
3779 {"CFURLCreateFromFSRef", (PyCFunction
)CF_CFURLCreateFromFSRef
, 1,
3780 "(FSRef fsRef) -> (CFURLRef _rv)"},
3794 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFTypeRef
, CFTypeRefObj_New
);
3795 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFTypeRef
, CFTypeRefObj_Convert
);
3796 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFStringRef
, CFStringRefObj_New
);
3797 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFStringRef
, CFStringRefObj_Convert
);
3798 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableStringRef
, CFMutableStringRefObj_New
);
3799 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableStringRef
, CFMutableStringRefObj_Convert
);
3801 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFArrayRef
, CFArrayRefObj_New
);
3802 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFArrayRef
, CFArrayRefObj_Convert
);
3803 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableArrayRef
, CFMutableArrayRefObj_New
);
3804 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableArrayRef
, CFMutableArrayRefObj_Convert
);
3805 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFDictionaryRef
, CFDictionaryRefObj_New
);
3806 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFDictionaryRef
, CFDictionaryRefObj_Convert
);
3807 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableDictionaryRef
, CFMutableDictionaryRefObj_New
);
3808 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableDictionaryRef
, CFMutableDictionaryRefObj_Convert
);
3809 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFURLRef
, CFURLRefObj_New
);
3810 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef
, CFURLRefObj_Convert
);
3811 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef
, CFURLRefObj_Convert
);
3814 m
= Py_InitModule("_CF", CF_methods
);
3815 d
= PyModule_GetDict(m
);
3816 CF_Error
= PyMac_GetOSErrException();
3817 if (CF_Error
== NULL
||
3818 PyDict_SetItemString(d
, "Error", CF_Error
) != 0)
3820 CFTypeRef_Type
.ob_type
= &PyType_Type
;
3821 Py_INCREF(&CFTypeRef_Type
);
3822 if (PyDict_SetItemString(d
, "CFTypeRefType", (PyObject
*)&CFTypeRef_Type
) != 0)
3823 Py_FatalError("can't initialize CFTypeRefType");
3824 CFArrayRef_Type
.ob_type
= &PyType_Type
;
3825 Py_INCREF(&CFArrayRef_Type
);
3826 if (PyDict_SetItemString(d
, "CFArrayRefType", (PyObject
*)&CFArrayRef_Type
) != 0)
3827 Py_FatalError("can't initialize CFArrayRefType");
3828 CFMutableArrayRef_Type
.ob_type
= &PyType_Type
;
3829 Py_INCREF(&CFMutableArrayRef_Type
);
3830 if (PyDict_SetItemString(d
, "CFMutableArrayRefType", (PyObject
*)&CFMutableArrayRef_Type
) != 0)
3831 Py_FatalError("can't initialize CFMutableArrayRefType");
3832 CFDictionaryRef_Type
.ob_type
= &PyType_Type
;
3833 Py_INCREF(&CFDictionaryRef_Type
);
3834 if (PyDict_SetItemString(d
, "CFDictionaryRefType", (PyObject
*)&CFDictionaryRef_Type
) != 0)
3835 Py_FatalError("can't initialize CFDictionaryRefType");
3836 CFMutableDictionaryRef_Type
.ob_type
= &PyType_Type
;
3837 Py_INCREF(&CFMutableDictionaryRef_Type
);
3838 if (PyDict_SetItemString(d
, "CFMutableDictionaryRefType", (PyObject
*)&CFMutableDictionaryRef_Type
) != 0)
3839 Py_FatalError("can't initialize CFMutableDictionaryRefType");
3840 CFDataRef_Type
.ob_type
= &PyType_Type
;
3841 Py_INCREF(&CFDataRef_Type
);
3842 if (PyDict_SetItemString(d
, "CFDataRefType", (PyObject
*)&CFDataRef_Type
) != 0)
3843 Py_FatalError("can't initialize CFDataRefType");
3844 CFMutableDataRef_Type
.ob_type
= &PyType_Type
;
3845 Py_INCREF(&CFMutableDataRef_Type
);
3846 if (PyDict_SetItemString(d
, "CFMutableDataRefType", (PyObject
*)&CFMutableDataRef_Type
) != 0)
3847 Py_FatalError("can't initialize CFMutableDataRefType");
3848 CFStringRef_Type
.ob_type
= &PyType_Type
;
3849 Py_INCREF(&CFStringRef_Type
);
3850 if (PyDict_SetItemString(d
, "CFStringRefType", (PyObject
*)&CFStringRef_Type
) != 0)
3851 Py_FatalError("can't initialize CFStringRefType");
3852 CFMutableStringRef_Type
.ob_type
= &PyType_Type
;
3853 Py_INCREF(&CFMutableStringRef_Type
);
3854 if (PyDict_SetItemString(d
, "CFMutableStringRefType", (PyObject
*)&CFMutableStringRef_Type
) != 0)
3855 Py_FatalError("can't initialize CFMutableStringRefType");
3856 CFURLRef_Type
.ob_type
= &PyType_Type
;
3857 Py_INCREF(&CFURLRef_Type
);
3858 if (PyDict_SetItemString(d
, "CFURLRefType", (PyObject
*)&CFURLRef_Type
) != 0)
3859 Py_FatalError("can't initialize CFURLRefType");
3862 /* ========================= End module _CF ========================= */