2 /* =========================== Module CF ============================ */
9 #include "pymactoolbox.h"
11 /* Macro to test whether a weak-loaded CFM function exists */
12 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
13 PyErr_SetString(PyExc_NotImplementedError, \
14 "Not available in this shared library/OS version"); \
19 #ifdef WITHOUT_FRAMEWORKS
23 #include <CFDictionary.h>
27 #include <CoreServices/CoreServices.h>
30 /* For now we declare them forward here. They'll go to mactoolbox later */
31 staticforward PyObject
*CFTypeRefObj_New(CFTypeRef
);
32 staticforward
int CFTypeRefObj_Convert(PyObject
*, CFTypeRef
*);
33 staticforward PyObject
*CFStringRefObj_New(CFStringRef
);
34 staticforward
int CFStringRefObj_Convert(PyObject
*, CFStringRef
*);
35 staticforward PyObject
*CFURLRefObj_New(CFURLRef
);
36 staticforward
int CFURLRefObj_Convert(PyObject
*, CFURLRef
*);
38 staticforward
int CFURLRefObj_Convert(PyObject
*, CFURLRef
*);
41 #ifdef NOTYET_USE_TOOLBOX_OBJECT_GLUE
42 //extern PyObject *_CFTypeRefObj_New(CFTypeRef);
43 //extern int _CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
45 //#define CFTypeRefObj_New _CFTypeRefObj_New
46 //#define CFTypeRefObj_Convert _CFTypeRefObj_Convert
50 ** Parse/generate CFRange records
52 PyObject
*CFRange_New(CFRange
*itself
)
55 return Py_BuildValue("ll", (long)itself
->location
, (long)itself
->length
);
58 CFRange_Convert(PyObject
*v
, CFRange
*p_itself
)
60 long location
, length
;
62 if( !PyArg_ParseTuple(v
, "ll", &location
, &length
) )
64 p_itself
->location
= (CFIndex
)location
;
65 p_itself
->length
= (CFIndex
)length
;
69 /* Optional CFURL argument or None (passed as NULL) */
71 OptionalCFURLRefObj_Convert(PyObject
*v
, CFURLRef
*p_itself
)
77 return CFURLRefObj_Convert(v
, p_itself
);
81 static PyObject
*CF_Error
;
83 /* --------------------- Object type CFTypeRef ---------------------- */
85 PyTypeObject CFTypeRef_Type
;
87 #define CFTypeRefObj_Check(x) ((x)->ob_type == &CFTypeRef_Type)
89 typedef struct CFTypeRefObject
{
92 void (*ob_freeit
)(CFTypeRef ptr
);
95 PyObject
*CFTypeRefObj_New(CFTypeRef itself
)
98 if (itself
== NULL
) return PyMac_Error(resNotFound
);
99 it
= PyObject_NEW(CFTypeRefObject
, &CFTypeRef_Type
);
100 if (it
== NULL
) return NULL
;
101 it
->ob_itself
= itself
;
102 it
->ob_freeit
= CFRelease
;
103 return (PyObject
*)it
;
105 CFTypeRefObj_Convert(PyObject
*v
, CFTypeRef
*p_itself
)
108 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
109 /* Check for other CF objects here */
111 if (!CFTypeRefObj_Check(v
))
113 PyErr_SetString(PyExc_TypeError
, "CFTypeRef required");
116 *p_itself
= ((CFTypeRefObject
*)v
)->ob_itself
;
120 static void CFTypeRefObj_dealloc(CFTypeRefObject
*self
)
122 if (self
->ob_freeit
&& self
->ob_itself
)
124 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
129 static PyObject
*CFTypeRefObj_CFGetTypeID(CFTypeRefObject
*_self
, PyObject
*_args
)
131 PyObject
*_res
= NULL
;
133 PyMac_PRECHECK(CFGetTypeID
);
134 if (!PyArg_ParseTuple(_args
, ""))
136 _rv
= CFGetTypeID(_self
->ob_itself
);
137 _res
= Py_BuildValue("l",
142 static PyObject
*CFTypeRefObj_CFRetain(CFTypeRefObject
*_self
, PyObject
*_args
)
144 PyObject
*_res
= NULL
;
146 PyMac_PRECHECK(CFRetain
);
147 if (!PyArg_ParseTuple(_args
, ""))
149 _rv
= CFRetain(_self
->ob_itself
);
150 _res
= Py_BuildValue("O&",
151 CFTypeRefObj_New
, _rv
);
155 static PyObject
*CFTypeRefObj_CFRelease(CFTypeRefObject
*_self
, PyObject
*_args
)
157 PyObject
*_res
= NULL
;
158 PyMac_PRECHECK(CFRelease
);
159 if (!PyArg_ParseTuple(_args
, ""))
161 CFRelease(_self
->ob_itself
);
167 static PyObject
*CFTypeRefObj_CFGetRetainCount(CFTypeRefObject
*_self
, PyObject
*_args
)
169 PyObject
*_res
= NULL
;
171 PyMac_PRECHECK(CFGetRetainCount
);
172 if (!PyArg_ParseTuple(_args
, ""))
174 _rv
= CFGetRetainCount(_self
->ob_itself
);
175 _res
= Py_BuildValue("l",
180 static PyObject
*CFTypeRefObj_CFEqual(CFTypeRefObject
*_self
, PyObject
*_args
)
182 PyObject
*_res
= NULL
;
185 PyMac_PRECHECK(CFEqual
);
186 if (!PyArg_ParseTuple(_args
, "O&",
187 CFTypeRefObj_Convert
, &cf2
))
189 _rv
= CFEqual(_self
->ob_itself
,
191 _res
= Py_BuildValue("l",
196 static PyObject
*CFTypeRefObj_CFHash(CFTypeRefObject
*_self
, PyObject
*_args
)
198 PyObject
*_res
= NULL
;
200 PyMac_PRECHECK(CFHash
);
201 if (!PyArg_ParseTuple(_args
, ""))
203 _rv
= CFHash(_self
->ob_itself
);
204 _res
= Py_BuildValue("l",
209 static PyObject
*CFTypeRefObj_CFCopyDescription(CFTypeRefObject
*_self
, PyObject
*_args
)
211 PyObject
*_res
= NULL
;
213 PyMac_PRECHECK(CFCopyDescription
);
214 if (!PyArg_ParseTuple(_args
, ""))
216 _rv
= CFCopyDescription(_self
->ob_itself
);
217 _res
= Py_BuildValue("O&",
218 CFStringRefObj_New
, _rv
);
222 static PyObject
*CFTypeRefObj_CFShow(CFTypeRefObject
*_self
, PyObject
*_args
)
224 PyObject
*_res
= NULL
;
225 PyMac_PRECHECK(CFShow
);
226 if (!PyArg_ParseTuple(_args
, ""))
228 CFShow(_self
->ob_itself
);
234 static PyMethodDef CFTypeRefObj_methods
[] = {
235 {"CFGetTypeID", (PyCFunction
)CFTypeRefObj_CFGetTypeID
, 1,
236 "() -> (CFTypeID _rv)"},
237 {"CFRetain", (PyCFunction
)CFTypeRefObj_CFRetain
, 1,
238 "() -> (CFTypeRef _rv)"},
239 {"CFRelease", (PyCFunction
)CFTypeRefObj_CFRelease
, 1,
241 {"CFGetRetainCount", (PyCFunction
)CFTypeRefObj_CFGetRetainCount
, 1,
242 "() -> (CFIndex _rv)"},
243 {"CFEqual", (PyCFunction
)CFTypeRefObj_CFEqual
, 1,
244 "(CFTypeRef cf2) -> (Boolean _rv)"},
245 {"CFHash", (PyCFunction
)CFTypeRefObj_CFHash
, 1,
246 "() -> (CFHashCode _rv)"},
247 {"CFCopyDescription", (PyCFunction
)CFTypeRefObj_CFCopyDescription
, 1,
248 "() -> (CFStringRef _rv)"},
249 {"CFShow", (PyCFunction
)CFTypeRefObj_CFShow
, 1,
254 PyMethodChain CFTypeRefObj_chain
= { CFTypeRefObj_methods
, NULL
};
256 static PyObject
*CFTypeRefObj_getattr(CFTypeRefObject
*self
, char *name
)
258 return Py_FindMethodInChain(&CFTypeRefObj_chain
, (PyObject
*)self
, name
);
261 #define CFTypeRefObj_setattr NULL
263 static int CFTypeRefObj_compare(CFTypeRefObject
*self
, CFTypeRefObject
*other
)
265 /* XXXX Or should we use CFEqual?? */
266 if ( self
->ob_itself
> other
->ob_itself
) return 1;
267 if ( self
->ob_itself
< other
->ob_itself
) return -1;
271 static PyObject
* CFTypeRefObj_repr(CFTypeRefObject
*self
)
274 sprintf(buf
, "<CFTypeRef type-%d object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self
->ob_itself
), self
, self
->ob_itself
);
275 return PyString_FromString(buf
);
278 static int CFTypeRefObj_hash(CFTypeRefObject
*self
)
280 /* XXXX Or should we use CFHash?? */
281 return (int)self
->ob_itself
;
284 PyTypeObject CFTypeRef_Type
= {
285 PyObject_HEAD_INIT(&PyType_Type
)
287 "CFTypeRef", /*tp_name*/
288 sizeof(CFTypeRefObject
), /*tp_basicsize*/
291 (destructor
) CFTypeRefObj_dealloc
, /*tp_dealloc*/
293 (getattrfunc
) CFTypeRefObj_getattr
, /*tp_getattr*/
294 (setattrfunc
) CFTypeRefObj_setattr
, /*tp_setattr*/
295 (cmpfunc
) CFTypeRefObj_compare
, /*tp_compare*/
296 (reprfunc
) CFTypeRefObj_repr
, /*tp_repr*/
297 (PyNumberMethods
*)0, /* tp_as_number */
298 (PySequenceMethods
*)0, /* tp_as_sequence */
299 (PyMappingMethods
*)0, /* tp_as_mapping */
300 (hashfunc
) CFTypeRefObj_hash
, /*tp_hash*/
303 /* ------------------- End object type CFTypeRef -------------------- */
306 /* --------------------- Object type CFArrayRef --------------------- */
308 PyTypeObject CFArrayRef_Type
;
310 #define CFArrayRefObj_Check(x) ((x)->ob_type == &CFArrayRef_Type)
312 typedef struct CFArrayRefObject
{
314 CFArrayRef ob_itself
;
315 void (*ob_freeit
)(CFTypeRef ptr
);
318 PyObject
*CFArrayRefObj_New(CFArrayRef itself
)
320 CFArrayRefObject
*it
;
321 if (itself
== NULL
) return PyMac_Error(resNotFound
);
322 it
= PyObject_NEW(CFArrayRefObject
, &CFArrayRef_Type
);
323 if (it
== NULL
) return NULL
;
324 it
->ob_itself
= itself
;
325 it
->ob_freeit
= CFRelease
;
326 return (PyObject
*)it
;
328 CFArrayRefObj_Convert(PyObject
*v
, CFArrayRef
*p_itself
)
331 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
332 /* Check for other CF objects here */
334 if (!CFArrayRefObj_Check(v
))
336 PyErr_SetString(PyExc_TypeError
, "CFArrayRef required");
339 *p_itself
= ((CFArrayRefObject
*)v
)->ob_itself
;
343 static void CFArrayRefObj_dealloc(CFArrayRefObject
*self
)
345 if (self
->ob_freeit
&& self
->ob_itself
)
347 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
352 static PyObject
*CFArrayRefObj_CFArrayCreateCopy(CFArrayRefObject
*_self
, PyObject
*_args
)
354 PyObject
*_res
= NULL
;
356 if (!PyArg_ParseTuple(_args
, ""))
358 _rv
= CFArrayCreateCopy((CFAllocatorRef
)NULL
,
360 _res
= Py_BuildValue("O&",
361 CFArrayRefObj_New
, _rv
);
365 static PyObject
*CFArrayRefObj_CFArrayGetCount(CFArrayRefObject
*_self
, PyObject
*_args
)
367 PyObject
*_res
= NULL
;
369 PyMac_PRECHECK(CFArrayGetCount
);
370 if (!PyArg_ParseTuple(_args
, ""))
372 _rv
= CFArrayGetCount(_self
->ob_itself
);
373 _res
= Py_BuildValue("l",
378 static PyObject
*CFArrayRefObj_CFStringCreateByCombiningStrings(CFArrayRefObject
*_self
, PyObject
*_args
)
380 PyObject
*_res
= NULL
;
382 CFStringRef separatorString
;
383 if (!PyArg_ParseTuple(_args
, "O&",
384 CFStringRefObj_Convert
, &separatorString
))
386 _rv
= CFStringCreateByCombiningStrings((CFAllocatorRef
)NULL
,
389 _res
= Py_BuildValue("O&",
390 CFStringRefObj_New
, _rv
);
394 static PyMethodDef CFArrayRefObj_methods
[] = {
395 {"CFArrayCreateCopy", (PyCFunction
)CFArrayRefObj_CFArrayCreateCopy
, 1,
396 "() -> (CFArrayRef _rv)"},
397 {"CFArrayGetCount", (PyCFunction
)CFArrayRefObj_CFArrayGetCount
, 1,
398 "() -> (CFIndex _rv)"},
399 {"CFStringCreateByCombiningStrings", (PyCFunction
)CFArrayRefObj_CFStringCreateByCombiningStrings
, 1,
400 "(CFStringRef separatorString) -> (CFStringRef _rv)"},
404 PyMethodChain CFArrayRefObj_chain
= { CFArrayRefObj_methods
, &CFTypeRefObj_chain
};
406 static PyObject
*CFArrayRefObj_getattr(CFArrayRefObject
*self
, char *name
)
408 return Py_FindMethodInChain(&CFArrayRefObj_chain
, (PyObject
*)self
, name
);
411 #define CFArrayRefObj_setattr NULL
413 static int CFArrayRefObj_compare(CFArrayRefObject
*self
, CFArrayRefObject
*other
)
415 /* XXXX Or should we use CFEqual?? */
416 if ( self
->ob_itself
> other
->ob_itself
) return 1;
417 if ( self
->ob_itself
< other
->ob_itself
) return -1;
421 static PyObject
* CFArrayRefObj_repr(CFArrayRefObject
*self
)
424 sprintf(buf
, "<CFArrayRef object at 0x%08.8x for 0x%08.8x>", self
, self
->ob_itself
);
425 return PyString_FromString(buf
);
428 static int CFArrayRefObj_hash(CFArrayRefObject
*self
)
430 /* XXXX Or should we use CFHash?? */
431 return (int)self
->ob_itself
;
434 PyTypeObject CFArrayRef_Type
= {
435 PyObject_HEAD_INIT(&PyType_Type
)
437 "CFArrayRef", /*tp_name*/
438 sizeof(CFArrayRefObject
), /*tp_basicsize*/
441 (destructor
) CFArrayRefObj_dealloc
, /*tp_dealloc*/
443 (getattrfunc
) CFArrayRefObj_getattr
, /*tp_getattr*/
444 (setattrfunc
) CFArrayRefObj_setattr
, /*tp_setattr*/
445 (cmpfunc
) CFArrayRefObj_compare
, /*tp_compare*/
446 (reprfunc
) CFArrayRefObj_repr
, /*tp_repr*/
447 (PyNumberMethods
*)0, /* tp_as_number */
448 (PySequenceMethods
*)0, /* tp_as_sequence */
449 (PyMappingMethods
*)0, /* tp_as_mapping */
450 (hashfunc
) CFArrayRefObj_hash
, /*tp_hash*/
453 /* ------------------- End object type CFArrayRef ------------------- */
456 /* ----------------- Object type CFMutableArrayRef ------------------ */
458 PyTypeObject CFMutableArrayRef_Type
;
460 #define CFMutableArrayRefObj_Check(x) ((x)->ob_type == &CFMutableArrayRef_Type)
462 typedef struct CFMutableArrayRefObject
{
464 CFMutableArrayRef ob_itself
;
465 void (*ob_freeit
)(CFTypeRef ptr
);
466 } CFMutableArrayRefObject
;
468 PyObject
*CFMutableArrayRefObj_New(CFMutableArrayRef itself
)
470 CFMutableArrayRefObject
*it
;
471 if (itself
== NULL
) return PyMac_Error(resNotFound
);
472 it
= PyObject_NEW(CFMutableArrayRefObject
, &CFMutableArrayRef_Type
);
473 if (it
== NULL
) return NULL
;
474 it
->ob_itself
= itself
;
475 it
->ob_freeit
= CFRelease
;
476 return (PyObject
*)it
;
478 CFMutableArrayRefObj_Convert(PyObject
*v
, CFMutableArrayRef
*p_itself
)
481 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
482 /* Check for other CF objects here */
484 if (!CFMutableArrayRefObj_Check(v
))
486 PyErr_SetString(PyExc_TypeError
, "CFMutableArrayRef required");
489 *p_itself
= ((CFMutableArrayRefObject
*)v
)->ob_itself
;
493 static void CFMutableArrayRefObj_dealloc(CFMutableArrayRefObject
*self
)
495 if (self
->ob_freeit
&& self
->ob_itself
)
497 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
502 static PyObject
*CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
504 PyObject
*_res
= NULL
;
506 PyMac_PRECHECK(CFArrayRemoveValueAtIndex
);
507 if (!PyArg_ParseTuple(_args
, "l",
510 CFArrayRemoveValueAtIndex(_self
->ob_itself
,
517 static PyObject
*CFMutableArrayRefObj_CFArrayRemoveAllValues(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
519 PyObject
*_res
= NULL
;
520 PyMac_PRECHECK(CFArrayRemoveAllValues
);
521 if (!PyArg_ParseTuple(_args
, ""))
523 CFArrayRemoveAllValues(_self
->ob_itself
);
529 static PyObject
*CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices(CFMutableArrayRefObject
*_self
, PyObject
*_args
)
531 PyObject
*_res
= NULL
;
534 PyMac_PRECHECK(CFArrayExchangeValuesAtIndices
);
535 if (!PyArg_ParseTuple(_args
, "ll",
539 CFArrayExchangeValuesAtIndices(_self
->ob_itself
,
547 static PyMethodDef CFMutableArrayRefObj_methods
[] = {
548 {"CFArrayRemoveValueAtIndex", (PyCFunction
)CFMutableArrayRefObj_CFArrayRemoveValueAtIndex
, 1,
549 "(CFIndex idx) -> None"},
550 {"CFArrayRemoveAllValues", (PyCFunction
)CFMutableArrayRefObj_CFArrayRemoveAllValues
, 1,
552 {"CFArrayExchangeValuesAtIndices", (PyCFunction
)CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices
, 1,
553 "(CFIndex idx1, CFIndex idx2) -> None"},
557 PyMethodChain CFMutableArrayRefObj_chain
= { CFMutableArrayRefObj_methods
, &CFArrayRefObj_chain
};
559 static PyObject
*CFMutableArrayRefObj_getattr(CFMutableArrayRefObject
*self
, char *name
)
561 return Py_FindMethodInChain(&CFMutableArrayRefObj_chain
, (PyObject
*)self
, name
);
564 #define CFMutableArrayRefObj_setattr NULL
566 static int CFMutableArrayRefObj_compare(CFMutableArrayRefObject
*self
, CFMutableArrayRefObject
*other
)
568 /* XXXX Or should we use CFEqual?? */
569 if ( self
->ob_itself
> other
->ob_itself
) return 1;
570 if ( self
->ob_itself
< other
->ob_itself
) return -1;
574 static PyObject
* CFMutableArrayRefObj_repr(CFMutableArrayRefObject
*self
)
577 sprintf(buf
, "<CFMutableArrayRef object at 0x%08.8x for 0x%08.8x>", self
, self
->ob_itself
);
578 return PyString_FromString(buf
);
581 static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject
*self
)
583 /* XXXX Or should we use CFHash?? */
584 return (int)self
->ob_itself
;
587 PyTypeObject CFMutableArrayRef_Type
= {
588 PyObject_HEAD_INIT(&PyType_Type
)
590 "CFMutableArrayRef", /*tp_name*/
591 sizeof(CFMutableArrayRefObject
), /*tp_basicsize*/
594 (destructor
) CFMutableArrayRefObj_dealloc
, /*tp_dealloc*/
596 (getattrfunc
) CFMutableArrayRefObj_getattr
, /*tp_getattr*/
597 (setattrfunc
) CFMutableArrayRefObj_setattr
, /*tp_setattr*/
598 (cmpfunc
) CFMutableArrayRefObj_compare
, /*tp_compare*/
599 (reprfunc
) CFMutableArrayRefObj_repr
, /*tp_repr*/
600 (PyNumberMethods
*)0, /* tp_as_number */
601 (PySequenceMethods
*)0, /* tp_as_sequence */
602 (PyMappingMethods
*)0, /* tp_as_mapping */
603 (hashfunc
) CFMutableArrayRefObj_hash
, /*tp_hash*/
606 /* --------------- End object type CFMutableArrayRef ---------------- */
609 /* ------------------ Object type CFDictionaryRef ------------------- */
611 PyTypeObject CFDictionaryRef_Type
;
613 #define CFDictionaryRefObj_Check(x) ((x)->ob_type == &CFDictionaryRef_Type)
615 typedef struct CFDictionaryRefObject
{
617 CFDictionaryRef ob_itself
;
618 void (*ob_freeit
)(CFTypeRef ptr
);
619 } CFDictionaryRefObject
;
621 PyObject
*CFDictionaryRefObj_New(CFDictionaryRef itself
)
623 CFDictionaryRefObject
*it
;
624 if (itself
== NULL
) return PyMac_Error(resNotFound
);
625 it
= PyObject_NEW(CFDictionaryRefObject
, &CFDictionaryRef_Type
);
626 if (it
== NULL
) return NULL
;
627 it
->ob_itself
= itself
;
628 it
->ob_freeit
= CFRelease
;
629 return (PyObject
*)it
;
631 CFDictionaryRefObj_Convert(PyObject
*v
, CFDictionaryRef
*p_itself
)
634 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
635 /* Check for other CF objects here */
637 if (!CFDictionaryRefObj_Check(v
))
639 PyErr_SetString(PyExc_TypeError
, "CFDictionaryRef required");
642 *p_itself
= ((CFDictionaryRefObject
*)v
)->ob_itself
;
646 static void CFDictionaryRefObj_dealloc(CFDictionaryRefObject
*self
)
648 if (self
->ob_freeit
&& self
->ob_itself
)
650 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
655 static PyObject
*CFDictionaryRefObj_CFDictionaryCreateCopy(CFDictionaryRefObject
*_self
, PyObject
*_args
)
657 PyObject
*_res
= NULL
;
659 if (!PyArg_ParseTuple(_args
, ""))
661 _rv
= CFDictionaryCreateCopy((CFAllocatorRef
)NULL
,
663 _res
= Py_BuildValue("O&",
664 CFDictionaryRefObj_New
, _rv
);
668 static PyObject
*CFDictionaryRefObj_CFDictionaryGetCount(CFDictionaryRefObject
*_self
, PyObject
*_args
)
670 PyObject
*_res
= NULL
;
672 PyMac_PRECHECK(CFDictionaryGetCount
);
673 if (!PyArg_ParseTuple(_args
, ""))
675 _rv
= CFDictionaryGetCount(_self
->ob_itself
);
676 _res
= Py_BuildValue("l",
681 static PyMethodDef CFDictionaryRefObj_methods
[] = {
682 {"CFDictionaryCreateCopy", (PyCFunction
)CFDictionaryRefObj_CFDictionaryCreateCopy
, 1,
683 "() -> (CFDictionaryRef _rv)"},
684 {"CFDictionaryGetCount", (PyCFunction
)CFDictionaryRefObj_CFDictionaryGetCount
, 1,
685 "() -> (CFIndex _rv)"},
689 PyMethodChain CFDictionaryRefObj_chain
= { CFDictionaryRefObj_methods
, &CFTypeRefObj_chain
};
691 static PyObject
*CFDictionaryRefObj_getattr(CFDictionaryRefObject
*self
, char *name
)
693 return Py_FindMethodInChain(&CFDictionaryRefObj_chain
, (PyObject
*)self
, name
);
696 #define CFDictionaryRefObj_setattr NULL
698 static int CFDictionaryRefObj_compare(CFDictionaryRefObject
*self
, CFDictionaryRefObject
*other
)
700 /* XXXX Or should we use CFEqual?? */
701 if ( self
->ob_itself
> other
->ob_itself
) return 1;
702 if ( self
->ob_itself
< other
->ob_itself
) return -1;
706 static PyObject
* CFDictionaryRefObj_repr(CFDictionaryRefObject
*self
)
709 sprintf(buf
, "<CFDictionaryRef object at 0x%08.8x for 0x%08.8x>", self
, self
->ob_itself
);
710 return PyString_FromString(buf
);
713 static int CFDictionaryRefObj_hash(CFDictionaryRefObject
*self
)
715 /* XXXX Or should we use CFHash?? */
716 return (int)self
->ob_itself
;
719 PyTypeObject CFDictionaryRef_Type
= {
720 PyObject_HEAD_INIT(&PyType_Type
)
722 "CFDictionaryRef", /*tp_name*/
723 sizeof(CFDictionaryRefObject
), /*tp_basicsize*/
726 (destructor
) CFDictionaryRefObj_dealloc
, /*tp_dealloc*/
728 (getattrfunc
) CFDictionaryRefObj_getattr
, /*tp_getattr*/
729 (setattrfunc
) CFDictionaryRefObj_setattr
, /*tp_setattr*/
730 (cmpfunc
) CFDictionaryRefObj_compare
, /*tp_compare*/
731 (reprfunc
) CFDictionaryRefObj_repr
, /*tp_repr*/
732 (PyNumberMethods
*)0, /* tp_as_number */
733 (PySequenceMethods
*)0, /* tp_as_sequence */
734 (PyMappingMethods
*)0, /* tp_as_mapping */
735 (hashfunc
) CFDictionaryRefObj_hash
, /*tp_hash*/
738 /* ---------------- End object type CFDictionaryRef ----------------- */
741 /* --------------- Object type CFMutableDictionaryRef --------------- */
743 PyTypeObject CFMutableDictionaryRef_Type
;
745 #define CFMutableDictionaryRefObj_Check(x) ((x)->ob_type == &CFMutableDictionaryRef_Type)
747 typedef struct CFMutableDictionaryRefObject
{
749 CFMutableDictionaryRef ob_itself
;
750 void (*ob_freeit
)(CFTypeRef ptr
);
751 } CFMutableDictionaryRefObject
;
753 PyObject
*CFMutableDictionaryRefObj_New(CFMutableDictionaryRef itself
)
755 CFMutableDictionaryRefObject
*it
;
756 if (itself
== NULL
) return PyMac_Error(resNotFound
);
757 it
= PyObject_NEW(CFMutableDictionaryRefObject
, &CFMutableDictionaryRef_Type
);
758 if (it
== NULL
) return NULL
;
759 it
->ob_itself
= itself
;
760 it
->ob_freeit
= CFRelease
;
761 return (PyObject
*)it
;
763 CFMutableDictionaryRefObj_Convert(PyObject
*v
, CFMutableDictionaryRef
*p_itself
)
766 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
767 /* Check for other CF objects here */
769 if (!CFMutableDictionaryRefObj_Check(v
))
771 PyErr_SetString(PyExc_TypeError
, "CFMutableDictionaryRef required");
774 *p_itself
= ((CFMutableDictionaryRefObject
*)v
)->ob_itself
;
778 static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject
*self
)
780 if (self
->ob_freeit
&& self
->ob_itself
)
782 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
787 static PyObject
*CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject
*_self
, PyObject
*_args
)
789 PyObject
*_res
= NULL
;
790 PyMac_PRECHECK(CFDictionaryRemoveAllValues
);
791 if (!PyArg_ParseTuple(_args
, ""))
793 CFDictionaryRemoveAllValues(_self
->ob_itself
);
799 static PyMethodDef CFMutableDictionaryRefObj_methods
[] = {
800 {"CFDictionaryRemoveAllValues", (PyCFunction
)CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues
, 1,
805 PyMethodChain CFMutableDictionaryRefObj_chain
= { CFMutableDictionaryRefObj_methods
, &CFDictionaryRefObj_chain
};
807 static PyObject
*CFMutableDictionaryRefObj_getattr(CFMutableDictionaryRefObject
*self
, char *name
)
809 return Py_FindMethodInChain(&CFMutableDictionaryRefObj_chain
, (PyObject
*)self
, name
);
812 #define CFMutableDictionaryRefObj_setattr NULL
814 static int CFMutableDictionaryRefObj_compare(CFMutableDictionaryRefObject
*self
, CFMutableDictionaryRefObject
*other
)
816 /* XXXX Or should we use CFEqual?? */
817 if ( self
->ob_itself
> other
->ob_itself
) return 1;
818 if ( self
->ob_itself
< other
->ob_itself
) return -1;
822 static PyObject
* CFMutableDictionaryRefObj_repr(CFMutableDictionaryRefObject
*self
)
825 sprintf(buf
, "<CFMutableDictionaryRef object at 0x%08.8x for 0x%08.8x>", self
, self
->ob_itself
);
826 return PyString_FromString(buf
);
829 static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject
*self
)
831 /* XXXX Or should we use CFHash?? */
832 return (int)self
->ob_itself
;
835 PyTypeObject CFMutableDictionaryRef_Type
= {
836 PyObject_HEAD_INIT(&PyType_Type
)
838 "CFMutableDictionaryRef", /*tp_name*/
839 sizeof(CFMutableDictionaryRefObject
), /*tp_basicsize*/
842 (destructor
) CFMutableDictionaryRefObj_dealloc
, /*tp_dealloc*/
844 (getattrfunc
) CFMutableDictionaryRefObj_getattr
, /*tp_getattr*/
845 (setattrfunc
) CFMutableDictionaryRefObj_setattr
, /*tp_setattr*/
846 (cmpfunc
) CFMutableDictionaryRefObj_compare
, /*tp_compare*/
847 (reprfunc
) CFMutableDictionaryRefObj_repr
, /*tp_repr*/
848 (PyNumberMethods
*)0, /* tp_as_number */
849 (PySequenceMethods
*)0, /* tp_as_sequence */
850 (PyMappingMethods
*)0, /* tp_as_mapping */
851 (hashfunc
) CFMutableDictionaryRefObj_hash
, /*tp_hash*/
854 /* ------------- End object type CFMutableDictionaryRef ------------- */
857 /* --------------------- Object type CFDataRef ---------------------- */
859 PyTypeObject CFDataRef_Type
;
861 #define CFDataRefObj_Check(x) ((x)->ob_type == &CFDataRef_Type)
863 typedef struct CFDataRefObject
{
866 void (*ob_freeit
)(CFTypeRef ptr
);
869 PyObject
*CFDataRefObj_New(CFDataRef itself
)
872 if (itself
== NULL
) return PyMac_Error(resNotFound
);
873 it
= PyObject_NEW(CFDataRefObject
, &CFDataRef_Type
);
874 if (it
== NULL
) return NULL
;
875 it
->ob_itself
= itself
;
876 it
->ob_freeit
= CFRelease
;
877 return (PyObject
*)it
;
879 CFDataRefObj_Convert(PyObject
*v
, CFDataRef
*p_itself
)
882 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
883 /* Check for other CF objects here */
885 if (!CFDataRefObj_Check(v
))
887 PyErr_SetString(PyExc_TypeError
, "CFDataRef required");
890 *p_itself
= ((CFDataRefObject
*)v
)->ob_itself
;
894 static void CFDataRefObj_dealloc(CFDataRefObject
*self
)
896 if (self
->ob_freeit
&& self
->ob_itself
)
898 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
903 static PyObject
*CFDataRefObj_CFDataCreateCopy(CFDataRefObject
*_self
, PyObject
*_args
)
905 PyObject
*_res
= NULL
;
907 if (!PyArg_ParseTuple(_args
, ""))
909 _rv
= CFDataCreateCopy((CFAllocatorRef
)NULL
,
911 _res
= Py_BuildValue("O&",
912 CFDataRefObj_New
, _rv
);
916 static PyObject
*CFDataRefObj_CFDataGetLength(CFDataRefObject
*_self
, PyObject
*_args
)
918 PyObject
*_res
= NULL
;
920 PyMac_PRECHECK(CFDataGetLength
);
921 if (!PyArg_ParseTuple(_args
, ""))
923 _rv
= CFDataGetLength(_self
->ob_itself
);
924 _res
= Py_BuildValue("l",
929 static PyObject
*CFDataRefObj_CFStringCreateFromExternalRepresentation(CFDataRefObject
*_self
, PyObject
*_args
)
931 PyObject
*_res
= NULL
;
933 CFStringEncoding encoding
;
934 if (!PyArg_ParseTuple(_args
, "l",
937 _rv
= CFStringCreateFromExternalRepresentation((CFAllocatorRef
)NULL
,
940 _res
= Py_BuildValue("O&",
941 CFStringRefObj_New
, _rv
);
945 static PyMethodDef CFDataRefObj_methods
[] = {
946 {"CFDataCreateCopy", (PyCFunction
)CFDataRefObj_CFDataCreateCopy
, 1,
947 "() -> (CFDataRef _rv)"},
948 {"CFDataGetLength", (PyCFunction
)CFDataRefObj_CFDataGetLength
, 1,
949 "() -> (CFIndex _rv)"},
950 {"CFStringCreateFromExternalRepresentation", (PyCFunction
)CFDataRefObj_CFStringCreateFromExternalRepresentation
, 1,
951 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
955 PyMethodChain CFDataRefObj_chain
= { CFDataRefObj_methods
, &CFTypeRefObj_chain
};
957 static PyObject
*CFDataRefObj_getattr(CFDataRefObject
*self
, char *name
)
959 return Py_FindMethodInChain(&CFDataRefObj_chain
, (PyObject
*)self
, name
);
962 #define CFDataRefObj_setattr NULL
964 static int CFDataRefObj_compare(CFDataRefObject
*self
, CFDataRefObject
*other
)
966 /* XXXX Or should we use CFEqual?? */
967 if ( self
->ob_itself
> other
->ob_itself
) return 1;
968 if ( self
->ob_itself
< other
->ob_itself
) return -1;
972 static PyObject
* CFDataRefObj_repr(CFDataRefObject
*self
)
975 sprintf(buf
, "<CFDataRef object at 0x%08.8x for 0x%08.8x>", self
, self
->ob_itself
);
976 return PyString_FromString(buf
);
979 static int CFDataRefObj_hash(CFDataRefObject
*self
)
981 /* XXXX Or should we use CFHash?? */
982 return (int)self
->ob_itself
;
985 PyTypeObject CFDataRef_Type
= {
986 PyObject_HEAD_INIT(&PyType_Type
)
988 "CFDataRef", /*tp_name*/
989 sizeof(CFDataRefObject
), /*tp_basicsize*/
992 (destructor
) CFDataRefObj_dealloc
, /*tp_dealloc*/
994 (getattrfunc
) CFDataRefObj_getattr
, /*tp_getattr*/
995 (setattrfunc
) CFDataRefObj_setattr
, /*tp_setattr*/
996 (cmpfunc
) CFDataRefObj_compare
, /*tp_compare*/
997 (reprfunc
) CFDataRefObj_repr
, /*tp_repr*/
998 (PyNumberMethods
*)0, /* tp_as_number */
999 (PySequenceMethods
*)0, /* tp_as_sequence */
1000 (PyMappingMethods
*)0, /* tp_as_mapping */
1001 (hashfunc
) CFDataRefObj_hash
, /*tp_hash*/
1004 /* ------------------- End object type CFDataRef -------------------- */
1007 /* ------------------ Object type CFMutableDataRef ------------------ */
1009 PyTypeObject CFMutableDataRef_Type
;
1011 #define CFMutableDataRefObj_Check(x) ((x)->ob_type == &CFMutableDataRef_Type)
1013 typedef struct CFMutableDataRefObject
{
1015 CFMutableDataRef ob_itself
;
1016 void (*ob_freeit
)(CFTypeRef ptr
);
1017 } CFMutableDataRefObject
;
1019 PyObject
*CFMutableDataRefObj_New(CFMutableDataRef itself
)
1021 CFMutableDataRefObject
*it
;
1022 if (itself
== NULL
) return PyMac_Error(resNotFound
);
1023 it
= PyObject_NEW(CFMutableDataRefObject
, &CFMutableDataRef_Type
);
1024 if (it
== NULL
) return NULL
;
1025 it
->ob_itself
= itself
;
1026 it
->ob_freeit
= CFRelease
;
1027 return (PyObject
*)it
;
1029 CFMutableDataRefObj_Convert(PyObject
*v
, CFMutableDataRef
*p_itself
)
1032 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1033 /* Check for other CF objects here */
1035 if (!CFMutableDataRefObj_Check(v
))
1037 PyErr_SetString(PyExc_TypeError
, "CFMutableDataRef required");
1040 *p_itself
= ((CFMutableDataRefObject
*)v
)->ob_itself
;
1044 static void CFMutableDataRefObj_dealloc(CFMutableDataRefObject
*self
)
1046 if (self
->ob_freeit
&& self
->ob_itself
)
1048 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1053 static PyObject
*CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1055 PyObject
*_res
= NULL
;
1057 PyMac_PRECHECK(CFDataSetLength
);
1058 if (!PyArg_ParseTuple(_args
, "l",
1061 CFDataSetLength(_self
->ob_itself
,
1068 static PyObject
*CFMutableDataRefObj_CFDataIncreaseLength(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1070 PyObject
*_res
= NULL
;
1071 CFIndex extraLength
;
1072 PyMac_PRECHECK(CFDataIncreaseLength
);
1073 if (!PyArg_ParseTuple(_args
, "l",
1076 CFDataIncreaseLength(_self
->ob_itself
,
1083 static PyObject
*CFMutableDataRefObj_CFDataAppendBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1085 PyObject
*_res
= NULL
;
1086 unsigned char *bytes__in__
;
1088 int bytes__in_len__
;
1089 PyMac_PRECHECK(CFDataAppendBytes
);
1090 if (!PyArg_ParseTuple(_args
, "s#",
1091 &bytes__in__
, &bytes__in_len__
))
1093 bytes__len__
= bytes__in_len__
;
1094 CFDataAppendBytes(_self
->ob_itself
,
1095 bytes__in__
, bytes__len__
);
1102 static PyObject
*CFMutableDataRefObj_CFDataReplaceBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1104 PyObject
*_res
= NULL
;
1106 unsigned char *newBytes__in__
;
1107 long newBytes__len__
;
1108 int newBytes__in_len__
;
1109 PyMac_PRECHECK(CFDataReplaceBytes
);
1110 if (!PyArg_ParseTuple(_args
, "O&s#",
1111 CFRange_Convert
, &range
,
1112 &newBytes__in__
, &newBytes__in_len__
))
1114 newBytes__len__
= newBytes__in_len__
;
1115 CFDataReplaceBytes(_self
->ob_itself
,
1117 newBytes__in__
, newBytes__len__
);
1120 newBytes__error__
: ;
1124 static PyObject
*CFMutableDataRefObj_CFDataDeleteBytes(CFMutableDataRefObject
*_self
, PyObject
*_args
)
1126 PyObject
*_res
= NULL
;
1128 PyMac_PRECHECK(CFDataDeleteBytes
);
1129 if (!PyArg_ParseTuple(_args
, "O&",
1130 CFRange_Convert
, &range
))
1132 CFDataDeleteBytes(_self
->ob_itself
,
1139 static PyMethodDef CFMutableDataRefObj_methods
[] = {
1140 {"CFDataSetLength", (PyCFunction
)CFMutableDataRefObj_CFDataSetLength
, 1,
1141 "(CFIndex length) -> None"},
1142 {"CFDataIncreaseLength", (PyCFunction
)CFMutableDataRefObj_CFDataIncreaseLength
, 1,
1143 "(CFIndex extraLength) -> None"},
1144 {"CFDataAppendBytes", (PyCFunction
)CFMutableDataRefObj_CFDataAppendBytes
, 1,
1145 "(Buffer bytes) -> None"},
1146 {"CFDataReplaceBytes", (PyCFunction
)CFMutableDataRefObj_CFDataReplaceBytes
, 1,
1147 "(CFRange range, Buffer newBytes) -> None"},
1148 {"CFDataDeleteBytes", (PyCFunction
)CFMutableDataRefObj_CFDataDeleteBytes
, 1,
1149 "(CFRange range) -> None"},
1153 PyMethodChain CFMutableDataRefObj_chain
= { CFMutableDataRefObj_methods
, &CFDataRefObj_chain
};
1155 static PyObject
*CFMutableDataRefObj_getattr(CFMutableDataRefObject
*self
, char *name
)
1157 return Py_FindMethodInChain(&CFMutableDataRefObj_chain
, (PyObject
*)self
, name
);
1160 #define CFMutableDataRefObj_setattr NULL
1162 static int CFMutableDataRefObj_compare(CFMutableDataRefObject
*self
, CFMutableDataRefObject
*other
)
1164 /* XXXX Or should we use CFEqual?? */
1165 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1166 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1170 static PyObject
* CFMutableDataRefObj_repr(CFMutableDataRefObject
*self
)
1173 sprintf(buf
, "<CFMutableDataRef object at 0x%08.8x for 0x%08.8x>", self
, self
->ob_itself
);
1174 return PyString_FromString(buf
);
1177 static int CFMutableDataRefObj_hash(CFMutableDataRefObject
*self
)
1179 /* XXXX Or should we use CFHash?? */
1180 return (int)self
->ob_itself
;
1183 PyTypeObject CFMutableDataRef_Type
= {
1184 PyObject_HEAD_INIT(&PyType_Type
)
1186 "CFMutableDataRef", /*tp_name*/
1187 sizeof(CFMutableDataRefObject
), /*tp_basicsize*/
1190 (destructor
) CFMutableDataRefObj_dealloc
, /*tp_dealloc*/
1192 (getattrfunc
) CFMutableDataRefObj_getattr
, /*tp_getattr*/
1193 (setattrfunc
) CFMutableDataRefObj_setattr
, /*tp_setattr*/
1194 (cmpfunc
) CFMutableDataRefObj_compare
, /*tp_compare*/
1195 (reprfunc
) CFMutableDataRefObj_repr
, /*tp_repr*/
1196 (PyNumberMethods
*)0, /* tp_as_number */
1197 (PySequenceMethods
*)0, /* tp_as_sequence */
1198 (PyMappingMethods
*)0, /* tp_as_mapping */
1199 (hashfunc
) CFMutableDataRefObj_hash
, /*tp_hash*/
1202 /* ---------------- End object type CFMutableDataRef ---------------- */
1205 /* -------------------- Object type CFStringRef --------------------- */
1207 PyTypeObject CFStringRef_Type
;
1209 #define CFStringRefObj_Check(x) ((x)->ob_type == &CFStringRef_Type)
1211 typedef struct CFStringRefObject
{
1213 CFStringRef ob_itself
;
1214 void (*ob_freeit
)(CFTypeRef ptr
);
1215 } CFStringRefObject
;
1217 PyObject
*CFStringRefObj_New(CFStringRef itself
)
1219 CFStringRefObject
*it
;
1220 if (itself
== NULL
) return PyMac_Error(resNotFound
);
1221 it
= PyObject_NEW(CFStringRefObject
, &CFStringRef_Type
);
1222 if (it
== NULL
) return NULL
;
1223 it
->ob_itself
= itself
;
1224 it
->ob_freeit
= CFRelease
;
1225 return (PyObject
*)it
;
1227 CFStringRefObj_Convert(PyObject
*v
, CFStringRef
*p_itself
)
1230 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1231 if (PyString_Check(v
)) {
1232 char *cStr
= PyString_AsString(v
);
1233 *p_itself
= CFStringCreateWithCString((CFAllocatorRef
)NULL
, cStr
, 0);
1236 if (PyUnicode_Check(v
)) {
1237 /* We use the CF types here, if Python was configured differently that will give an error */
1238 CFIndex size
= PyUnicode_GetSize(v
);
1239 UniChar
*unichars
= PyUnicode_AsUnicode(v
);
1240 if (!unichars
) return 0;
1241 *p_itself
= CFStringCreateWithCharacters((CFAllocatorRef
)NULL
, unichars
, size
);
1246 if (!CFStringRefObj_Check(v
))
1248 PyErr_SetString(PyExc_TypeError
, "CFStringRef required");
1251 *p_itself
= ((CFStringRefObject
*)v
)->ob_itself
;
1255 static void CFStringRefObj_dealloc(CFStringRefObject
*self
)
1257 if (self
->ob_freeit
&& self
->ob_itself
)
1259 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1264 static PyObject
*CFStringRefObj_CFStringCreateWithSubstring(CFStringRefObject
*_self
, PyObject
*_args
)
1266 PyObject
*_res
= NULL
;
1269 if (!PyArg_ParseTuple(_args
, "O&",
1270 CFRange_Convert
, &range
))
1272 _rv
= CFStringCreateWithSubstring((CFAllocatorRef
)NULL
,
1275 _res
= Py_BuildValue("O&",
1276 CFStringRefObj_New
, _rv
);
1280 static PyObject
*CFStringRefObj_CFStringCreateCopy(CFStringRefObject
*_self
, PyObject
*_args
)
1282 PyObject
*_res
= NULL
;
1284 if (!PyArg_ParseTuple(_args
, ""))
1286 _rv
= CFStringCreateCopy((CFAllocatorRef
)NULL
,
1288 _res
= Py_BuildValue("O&",
1289 CFStringRefObj_New
, _rv
);
1293 static PyObject
*CFStringRefObj_CFStringGetLength(CFStringRefObject
*_self
, PyObject
*_args
)
1295 PyObject
*_res
= NULL
;
1297 PyMac_PRECHECK(CFStringGetLength
);
1298 if (!PyArg_ParseTuple(_args
, ""))
1300 _rv
= CFStringGetLength(_self
->ob_itself
);
1301 _res
= Py_BuildValue("l",
1306 static PyObject
*CFStringRefObj_CFStringGetBytes(CFStringRefObject
*_self
, PyObject
*_args
)
1308 PyObject
*_res
= NULL
;
1311 CFStringEncoding encoding
;
1313 Boolean isExternalRepresentation
;
1317 PyMac_PRECHECK(CFStringGetBytes
);
1318 if (!PyArg_ParseTuple(_args
, "O&lbll",
1319 CFRange_Convert
, &range
,
1322 &isExternalRepresentation
,
1325 _rv
= CFStringGetBytes(_self
->ob_itself
,
1329 isExternalRepresentation
,
1333 _res
= Py_BuildValue("lbl",
1340 static PyObject
*CFStringRefObj_CFStringCreateExternalRepresentation(CFStringRefObject
*_self
, PyObject
*_args
)
1342 PyObject
*_res
= NULL
;
1344 CFStringEncoding encoding
;
1346 if (!PyArg_ParseTuple(_args
, "lb",
1350 _rv
= CFStringCreateExternalRepresentation((CFAllocatorRef
)NULL
,
1354 _res
= Py_BuildValue("O&",
1355 CFDataRefObj_New
, _rv
);
1359 static PyObject
*CFStringRefObj_CFStringGetSmallestEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
1361 PyObject
*_res
= NULL
;
1362 CFStringEncoding _rv
;
1363 PyMac_PRECHECK(CFStringGetSmallestEncoding
);
1364 if (!PyArg_ParseTuple(_args
, ""))
1366 _rv
= CFStringGetSmallestEncoding(_self
->ob_itself
);
1367 _res
= Py_BuildValue("l",
1372 static PyObject
*CFStringRefObj_CFStringGetFastestEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
1374 PyObject
*_res
= NULL
;
1375 CFStringEncoding _rv
;
1376 PyMac_PRECHECK(CFStringGetFastestEncoding
);
1377 if (!PyArg_ParseTuple(_args
, ""))
1379 _rv
= CFStringGetFastestEncoding(_self
->ob_itself
);
1380 _res
= Py_BuildValue("l",
1385 static PyObject
*CFStringRefObj_CFStringCompareWithOptions(CFStringRefObject
*_self
, PyObject
*_args
)
1387 PyObject
*_res
= NULL
;
1388 CFComparisonResult _rv
;
1389 CFStringRef string2
;
1390 CFRange rangeToCompare
;
1391 CFOptionFlags compareOptions
;
1392 PyMac_PRECHECK(CFStringCompareWithOptions
);
1393 if (!PyArg_ParseTuple(_args
, "O&O&l",
1394 CFStringRefObj_Convert
, &string2
,
1395 CFRange_Convert
, &rangeToCompare
,
1398 _rv
= CFStringCompareWithOptions(_self
->ob_itself
,
1402 _res
= Py_BuildValue("l",
1407 static PyObject
*CFStringRefObj_CFStringCompare(CFStringRefObject
*_self
, PyObject
*_args
)
1409 PyObject
*_res
= NULL
;
1410 CFComparisonResult _rv
;
1411 CFStringRef string2
;
1412 CFOptionFlags compareOptions
;
1413 PyMac_PRECHECK(CFStringCompare
);
1414 if (!PyArg_ParseTuple(_args
, "O&l",
1415 CFStringRefObj_Convert
, &string2
,
1418 _rv
= CFStringCompare(_self
->ob_itself
,
1421 _res
= Py_BuildValue("l",
1426 static PyObject
*CFStringRefObj_CFStringFindWithOptions(CFStringRefObject
*_self
, PyObject
*_args
)
1428 PyObject
*_res
= NULL
;
1430 CFStringRef stringToFind
;
1431 CFRange rangeToSearch
;
1432 CFOptionFlags searchOptions
;
1434 PyMac_PRECHECK(CFStringFindWithOptions
);
1435 if (!PyArg_ParseTuple(_args
, "O&O&l",
1436 CFStringRefObj_Convert
, &stringToFind
,
1437 CFRange_Convert
, &rangeToSearch
,
1440 _rv
= CFStringFindWithOptions(_self
->ob_itself
,
1445 _res
= Py_BuildValue("lO&",
1447 CFRange_New
, result
);
1451 static PyObject
*CFStringRefObj_CFStringCreateArrayWithFindResults(CFStringRefObject
*_self
, PyObject
*_args
)
1453 PyObject
*_res
= NULL
;
1455 CFStringRef stringToFind
;
1456 CFRange rangeToSearch
;
1457 CFOptionFlags compareOptions
;
1458 if (!PyArg_ParseTuple(_args
, "O&O&l",
1459 CFStringRefObj_Convert
, &stringToFind
,
1460 CFRange_Convert
, &rangeToSearch
,
1463 _rv
= CFStringCreateArrayWithFindResults((CFAllocatorRef
)NULL
,
1468 _res
= Py_BuildValue("O&",
1469 CFArrayRefObj_New
, _rv
);
1473 static PyObject
*CFStringRefObj_CFStringFind(CFStringRefObject
*_self
, PyObject
*_args
)
1475 PyObject
*_res
= NULL
;
1477 CFStringRef stringToFind
;
1478 CFOptionFlags compareOptions
;
1479 PyMac_PRECHECK(CFStringFind
);
1480 if (!PyArg_ParseTuple(_args
, "O&l",
1481 CFStringRefObj_Convert
, &stringToFind
,
1484 _rv
= CFStringFind(_self
->ob_itself
,
1487 _res
= Py_BuildValue("O&",
1492 static PyObject
*CFStringRefObj_CFStringHasPrefix(CFStringRefObject
*_self
, PyObject
*_args
)
1494 PyObject
*_res
= NULL
;
1497 PyMac_PRECHECK(CFStringHasPrefix
);
1498 if (!PyArg_ParseTuple(_args
, "O&",
1499 CFStringRefObj_Convert
, &prefix
))
1501 _rv
= CFStringHasPrefix(_self
->ob_itself
,
1503 _res
= Py_BuildValue("l",
1508 static PyObject
*CFStringRefObj_CFStringHasSuffix(CFStringRefObject
*_self
, PyObject
*_args
)
1510 PyObject
*_res
= NULL
;
1513 PyMac_PRECHECK(CFStringHasSuffix
);
1514 if (!PyArg_ParseTuple(_args
, "O&",
1515 CFStringRefObj_Convert
, &suffix
))
1517 _rv
= CFStringHasSuffix(_self
->ob_itself
,
1519 _res
= Py_BuildValue("l",
1524 static PyObject
*CFStringRefObj_CFStringGetLineBounds(CFStringRefObject
*_self
, PyObject
*_args
)
1526 PyObject
*_res
= NULL
;
1528 CFIndex lineBeginIndex
;
1529 CFIndex lineEndIndex
;
1530 CFIndex contentsEndIndex
;
1531 PyMac_PRECHECK(CFStringGetLineBounds
);
1532 if (!PyArg_ParseTuple(_args
, "O&",
1533 CFRange_Convert
, &range
))
1535 CFStringGetLineBounds(_self
->ob_itself
,
1540 _res
= Py_BuildValue("lll",
1547 static PyObject
*CFStringRefObj_CFStringCreateArrayBySeparatingStrings(CFStringRefObject
*_self
, PyObject
*_args
)
1549 PyObject
*_res
= NULL
;
1551 CFStringRef separatorString
;
1552 if (!PyArg_ParseTuple(_args
, "O&",
1553 CFStringRefObj_Convert
, &separatorString
))
1555 _rv
= CFStringCreateArrayBySeparatingStrings((CFAllocatorRef
)NULL
,
1558 _res
= Py_BuildValue("O&",
1559 CFArrayRefObj_New
, _rv
);
1563 static PyObject
*CFStringRefObj_CFStringGetIntValue(CFStringRefObject
*_self
, PyObject
*_args
)
1565 PyObject
*_res
= NULL
;
1567 PyMac_PRECHECK(CFStringGetIntValue
);
1568 if (!PyArg_ParseTuple(_args
, ""))
1570 _rv
= CFStringGetIntValue(_self
->ob_itself
);
1571 _res
= Py_BuildValue("l",
1576 static PyObject
*CFStringRefObj_CFStringGetDoubleValue(CFStringRefObject
*_self
, PyObject
*_args
)
1578 PyObject
*_res
= NULL
;
1580 PyMac_PRECHECK(CFStringGetDoubleValue
);
1581 if (!PyArg_ParseTuple(_args
, ""))
1583 _rv
= CFStringGetDoubleValue(_self
->ob_itself
);
1584 _res
= Py_BuildValue("d",
1589 static PyObject
*CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStringRefObject
*_self
, PyObject
*_args
)
1591 PyObject
*_res
= NULL
;
1592 CFStringEncoding _rv
;
1593 PyMac_PRECHECK(CFStringConvertIANACharSetNameToEncoding
);
1594 if (!PyArg_ParseTuple(_args
, ""))
1596 _rv
= CFStringConvertIANACharSetNameToEncoding(_self
->ob_itself
);
1597 _res
= Py_BuildValue("l",
1602 static PyObject
*CFStringRefObj_CFShowStr(CFStringRefObject
*_self
, PyObject
*_args
)
1604 PyObject
*_res
= NULL
;
1605 PyMac_PRECHECK(CFShowStr
);
1606 if (!PyArg_ParseTuple(_args
, ""))
1608 CFShowStr(_self
->ob_itself
);
1614 static PyObject
*CFStringRefObj_CFURLCreateWithString(CFStringRefObject
*_self
, PyObject
*_args
)
1616 PyObject
*_res
= NULL
;
1619 if (!PyArg_ParseTuple(_args
, "O&",
1620 OptionalCFURLRefObj_Convert
, &baseURL
))
1622 _rv
= CFURLCreateWithString((CFAllocatorRef
)NULL
,
1625 _res
= Py_BuildValue("O&",
1626 CFURLRefObj_New
, _rv
);
1630 static PyObject
*CFStringRefObj_CFURLCreateWithFileSystemPath(CFStringRefObject
*_self
, PyObject
*_args
)
1632 PyObject
*_res
= NULL
;
1634 CFURLPathStyle pathStyle
;
1635 Boolean isDirectory
;
1636 if (!PyArg_ParseTuple(_args
, "ll",
1640 _rv
= CFURLCreateWithFileSystemPath((CFAllocatorRef
)NULL
,
1644 _res
= Py_BuildValue("O&",
1645 CFURLRefObj_New
, _rv
);
1649 static PyObject
*CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes(CFStringRefObject
*_self
, PyObject
*_args
)
1651 PyObject
*_res
= NULL
;
1653 CFStringRef charactersToLeaveEscaped
;
1654 if (!PyArg_ParseTuple(_args
, "O&",
1655 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
1657 _rv
= CFURLCreateStringByReplacingPercentEscapes((CFAllocatorRef
)NULL
,
1659 charactersToLeaveEscaped
);
1660 _res
= Py_BuildValue("O&",
1661 CFStringRefObj_New
, _rv
);
1665 static PyObject
*CFStringRefObj_CFStringGetString(CFStringRefObject
*_self
, PyObject
*_args
)
1667 PyObject
*_res
= NULL
;
1669 int size
= CFStringGetLength(_self
->ob_itself
)+1;
1670 char *data
= malloc(size
);
1672 if( data
== NULL
) return PyErr_NoMemory();
1673 if ( CFStringGetCString(_self
->ob_itself
, data
, size
, 0) ) {
1674 _res
= (PyObject
*)PyString_FromString(data
);
1676 PyErr_SetString(PyExc_RuntimeError
, "CFStringGetCString could not fit the string");
1684 static PyObject
*CFStringRefObj_CFStringGetUnicode(CFStringRefObject
*_self
, PyObject
*_args
)
1686 PyObject
*_res
= NULL
;
1688 int size
= CFStringGetLength(_self
->ob_itself
)+1;
1689 Py_UNICODE
*data
= malloc(size
*sizeof(Py_UNICODE
));
1693 range
.length
= size
;
1694 if( data
== NULL
) return PyErr_NoMemory();
1695 CFStringGetCharacters(_self
->ob_itself
, range
, data
);
1696 _res
= (PyObject
*)PyUnicode_FromUnicode(data
, size
);
1702 static PyMethodDef CFStringRefObj_methods
[] = {
1703 {"CFStringCreateWithSubstring", (PyCFunction
)CFStringRefObj_CFStringCreateWithSubstring
, 1,
1704 "(CFRange range) -> (CFStringRef _rv)"},
1705 {"CFStringCreateCopy", (PyCFunction
)CFStringRefObj_CFStringCreateCopy
, 1,
1706 "() -> (CFStringRef _rv)"},
1707 {"CFStringGetLength", (PyCFunction
)CFStringRefObj_CFStringGetLength
, 1,
1708 "() -> (CFIndex _rv)"},
1709 {"CFStringGetBytes", (PyCFunction
)CFStringRefObj_CFStringGetBytes
, 1,
1710 "(CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, CFIndex maxBufLen) -> (CFIndex _rv, UInt8 buffer, CFIndex usedBufLen)"},
1711 {"CFStringCreateExternalRepresentation", (PyCFunction
)CFStringRefObj_CFStringCreateExternalRepresentation
, 1,
1712 "(CFStringEncoding encoding, UInt8 lossByte) -> (CFDataRef _rv)"},
1713 {"CFStringGetSmallestEncoding", (PyCFunction
)CFStringRefObj_CFStringGetSmallestEncoding
, 1,
1714 "() -> (CFStringEncoding _rv)"},
1715 {"CFStringGetFastestEncoding", (PyCFunction
)CFStringRefObj_CFStringGetFastestEncoding
, 1,
1716 "() -> (CFStringEncoding _rv)"},
1717 {"CFStringCompareWithOptions", (PyCFunction
)CFStringRefObj_CFStringCompareWithOptions
, 1,
1718 "(CFStringRef string2, CFRange rangeToCompare, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)"},
1719 {"CFStringCompare", (PyCFunction
)CFStringRefObj_CFStringCompare
, 1,
1720 "(CFStringRef string2, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)"},
1721 {"CFStringFindWithOptions", (PyCFunction
)CFStringRefObj_CFStringFindWithOptions
, 1,
1722 "(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags searchOptions) -> (Boolean _rv, CFRange result)"},
1723 {"CFStringCreateArrayWithFindResults", (PyCFunction
)CFStringRefObj_CFStringCreateArrayWithFindResults
, 1,
1724 "(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions) -> (CFArrayRef _rv)"},
1725 {"CFStringFind", (PyCFunction
)CFStringRefObj_CFStringFind
, 1,
1726 "(CFStringRef stringToFind, CFOptionFlags compareOptions) -> (CFRange _rv)"},
1727 {"CFStringHasPrefix", (PyCFunction
)CFStringRefObj_CFStringHasPrefix
, 1,
1728 "(CFStringRef prefix) -> (Boolean _rv)"},
1729 {"CFStringHasSuffix", (PyCFunction
)CFStringRefObj_CFStringHasSuffix
, 1,
1730 "(CFStringRef suffix) -> (Boolean _rv)"},
1731 {"CFStringGetLineBounds", (PyCFunction
)CFStringRefObj_CFStringGetLineBounds
, 1,
1732 "(CFRange range) -> (CFIndex lineBeginIndex, CFIndex lineEndIndex, CFIndex contentsEndIndex)"},
1733 {"CFStringCreateArrayBySeparatingStrings", (PyCFunction
)CFStringRefObj_CFStringCreateArrayBySeparatingStrings
, 1,
1734 "(CFStringRef separatorString) -> (CFArrayRef _rv)"},
1735 {"CFStringGetIntValue", (PyCFunction
)CFStringRefObj_CFStringGetIntValue
, 1,
1736 "() -> (SInt32 _rv)"},
1737 {"CFStringGetDoubleValue", (PyCFunction
)CFStringRefObj_CFStringGetDoubleValue
, 1,
1738 "() -> (double _rv)"},
1739 {"CFStringConvertIANACharSetNameToEncoding", (PyCFunction
)CFStringRefObj_CFStringConvertIANACharSetNameToEncoding
, 1,
1740 "() -> (CFStringEncoding _rv)"},
1741 {"CFShowStr", (PyCFunction
)CFStringRefObj_CFShowStr
, 1,
1743 {"CFURLCreateWithString", (PyCFunction
)CFStringRefObj_CFURLCreateWithString
, 1,
1744 "(CFURLRef baseURL) -> (CFURLRef _rv)"},
1745 {"CFURLCreateWithFileSystemPath", (PyCFunction
)CFStringRefObj_CFURLCreateWithFileSystemPath
, 1,
1746 "(CFURLPathStyle pathStyle, Boolean isDirectory) -> (CFURLRef _rv)"},
1747 {"CFURLCreateStringByReplacingPercentEscapes", (PyCFunction
)CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes
, 1,
1748 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
1749 {"CFStringGetString", (PyCFunction
)CFStringRefObj_CFStringGetString
, 1,
1750 "() -> (string _rv)"},
1751 {"CFStringGetUnicode", (PyCFunction
)CFStringRefObj_CFStringGetUnicode
, 1,
1752 "() -> (unicode _rv)"},
1756 PyMethodChain CFStringRefObj_chain
= { CFStringRefObj_methods
, &CFTypeRefObj_chain
};
1758 static PyObject
*CFStringRefObj_getattr(CFStringRefObject
*self
, char *name
)
1760 return Py_FindMethodInChain(&CFStringRefObj_chain
, (PyObject
*)self
, name
);
1763 #define CFStringRefObj_setattr NULL
1765 static int CFStringRefObj_compare(CFStringRefObject
*self
, CFStringRefObject
*other
)
1767 /* XXXX Or should we use CFEqual?? */
1768 if ( self
->ob_itself
> other
->ob_itself
) return 1;
1769 if ( self
->ob_itself
< other
->ob_itself
) return -1;
1773 static PyObject
* CFStringRefObj_repr(CFStringRefObject
*self
)
1776 sprintf(buf
, "<CFStringRef object at 0x%08.8x for 0x%08.8x>", self
, self
->ob_itself
);
1777 return PyString_FromString(buf
);
1780 static int CFStringRefObj_hash(CFStringRefObject
*self
)
1782 /* XXXX Or should we use CFHash?? */
1783 return (int)self
->ob_itself
;
1786 PyTypeObject CFStringRef_Type
= {
1787 PyObject_HEAD_INIT(&PyType_Type
)
1789 "CFStringRef", /*tp_name*/
1790 sizeof(CFStringRefObject
), /*tp_basicsize*/
1793 (destructor
) CFStringRefObj_dealloc
, /*tp_dealloc*/
1795 (getattrfunc
) CFStringRefObj_getattr
, /*tp_getattr*/
1796 (setattrfunc
) CFStringRefObj_setattr
, /*tp_setattr*/
1797 (cmpfunc
) CFStringRefObj_compare
, /*tp_compare*/
1798 (reprfunc
) CFStringRefObj_repr
, /*tp_repr*/
1799 (PyNumberMethods
*)0, /* tp_as_number */
1800 (PySequenceMethods
*)0, /* tp_as_sequence */
1801 (PyMappingMethods
*)0, /* tp_as_mapping */
1802 (hashfunc
) CFStringRefObj_hash
, /*tp_hash*/
1805 /* ------------------ End object type CFStringRef ------------------- */
1808 /* ----------------- Object type CFMutableStringRef ----------------- */
1810 PyTypeObject CFMutableStringRef_Type
;
1812 #define CFMutableStringRefObj_Check(x) ((x)->ob_type == &CFMutableStringRef_Type)
1814 typedef struct CFMutableStringRefObject
{
1816 CFMutableStringRef ob_itself
;
1817 void (*ob_freeit
)(CFTypeRef ptr
);
1818 } CFMutableStringRefObject
;
1820 PyObject
*CFMutableStringRefObj_New(CFMutableStringRef itself
)
1822 CFMutableStringRefObject
*it
;
1823 if (itself
== NULL
) return PyMac_Error(resNotFound
);
1824 it
= PyObject_NEW(CFMutableStringRefObject
, &CFMutableStringRef_Type
);
1825 if (it
== NULL
) return NULL
;
1826 it
->ob_itself
= itself
;
1827 it
->ob_freeit
= CFRelease
;
1828 return (PyObject
*)it
;
1830 CFMutableStringRefObj_Convert(PyObject
*v
, CFMutableStringRef
*p_itself
)
1833 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
1834 /* Check for other CF objects here */
1836 if (!CFMutableStringRefObj_Check(v
))
1838 PyErr_SetString(PyExc_TypeError
, "CFMutableStringRef required");
1841 *p_itself
= ((CFMutableStringRefObject
*)v
)->ob_itself
;
1845 static void CFMutableStringRefObj_dealloc(CFMutableStringRefObject
*self
)
1847 if (self
->ob_freeit
&& self
->ob_itself
)
1849 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
1854 static PyObject
*CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject
*_self
, PyObject
*_args
)
1856 PyObject
*_res
= NULL
;
1857 CFStringRef appendedString
;
1858 PyMac_PRECHECK(CFStringAppend
);
1859 if (!PyArg_ParseTuple(_args
, "O&",
1860 CFStringRefObj_Convert
, &appendedString
))
1862 CFStringAppend(_self
->ob_itself
,
1869 static PyObject
*CFMutableStringRefObj_CFStringAppendPascalString(CFMutableStringRefObject
*_self
, PyObject
*_args
)
1871 PyObject
*_res
= NULL
;
1873 CFStringEncoding encoding
;
1874 PyMac_PRECHECK(CFStringAppendPascalString
);
1875 if (!PyArg_ParseTuple(_args
, "O&l",
1876 PyMac_GetStr255
, &pStr
,
1879 CFStringAppendPascalString(_self
->ob_itself
,
1887 static PyObject
*CFMutableStringRefObj_CFStringAppendCString(CFMutableStringRefObject
*_self
, PyObject
*_args
)
1889 PyObject
*_res
= NULL
;
1891 CFStringEncoding encoding
;
1892 PyMac_PRECHECK(CFStringAppendCString
);
1893 if (!PyArg_ParseTuple(_args
, "sl",
1897 CFStringAppendCString(_self
->ob_itself
,
1905 static PyObject
*CFMutableStringRefObj_CFStringInsert(CFMutableStringRefObject
*_self
, PyObject
*_args
)
1907 PyObject
*_res
= NULL
;
1909 CFStringRef insertedStr
;
1910 PyMac_PRECHECK(CFStringInsert
);
1911 if (!PyArg_ParseTuple(_args
, "lO&",
1913 CFStringRefObj_Convert
, &insertedStr
))
1915 CFStringInsert(_self
->ob_itself
,
1923 static PyObject
*CFMutableStringRefObj_CFStringDelete(CFMutableStringRefObject
*_self
, PyObject
*_args
)
1925 PyObject
*_res
= NULL
;
1927 PyMac_PRECHECK(CFStringDelete
);
1928 if (!PyArg_ParseTuple(_args
, "O&",
1929 CFRange_Convert
, &range
))
1931 CFStringDelete(_self
->ob_itself
,
1938 static PyObject
*CFMutableStringRefObj_CFStringReplace(CFMutableStringRefObject
*_self
, PyObject
*_args
)
1940 PyObject
*_res
= NULL
;
1942 CFStringRef replacement
;
1943 PyMac_PRECHECK(CFStringReplace
);
1944 if (!PyArg_ParseTuple(_args
, "O&O&",
1945 CFRange_Convert
, &range
,
1946 CFStringRefObj_Convert
, &replacement
))
1948 CFStringReplace(_self
->ob_itself
,
1956 static PyObject
*CFMutableStringRefObj_CFStringReplaceAll(CFMutableStringRefObject
*_self
, PyObject
*_args
)
1958 PyObject
*_res
= NULL
;
1959 CFStringRef replacement
;
1960 PyMac_PRECHECK(CFStringReplaceAll
);
1961 if (!PyArg_ParseTuple(_args
, "O&",
1962 CFStringRefObj_Convert
, &replacement
))
1964 CFStringReplaceAll(_self
->ob_itself
,
1971 static PyObject
*CFMutableStringRefObj_CFStringPad(CFMutableStringRefObject
*_self
, PyObject
*_args
)
1973 PyObject
*_res
= NULL
;
1974 CFStringRef padString
;
1976 CFIndex indexIntoPad
;
1977 PyMac_PRECHECK(CFStringPad
);
1978 if (!PyArg_ParseTuple(_args
, "O&ll",
1979 CFStringRefObj_Convert
, &padString
,
1983 CFStringPad(_self
->ob_itself
,
1992 static PyObject
*CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject
*_self
, PyObject
*_args
)
1994 PyObject
*_res
= NULL
;
1995 CFStringRef trimString
;
1996 PyMac_PRECHECK(CFStringTrim
);
1997 if (!PyArg_ParseTuple(_args
, "O&",
1998 CFStringRefObj_Convert
, &trimString
))
2000 CFStringTrim(_self
->ob_itself
,
2007 static PyObject
*CFMutableStringRefObj_CFStringTrimWhitespace(CFMutableStringRefObject
*_self
, PyObject
*_args
)
2009 PyObject
*_res
= NULL
;
2010 PyMac_PRECHECK(CFStringTrimWhitespace
);
2011 if (!PyArg_ParseTuple(_args
, ""))
2013 CFStringTrimWhitespace(_self
->ob_itself
);
2019 static PyMethodDef CFMutableStringRefObj_methods
[] = {
2020 {"CFStringAppend", (PyCFunction
)CFMutableStringRefObj_CFStringAppend
, 1,
2021 "(CFStringRef appendedString) -> None"},
2022 {"CFStringAppendPascalString", (PyCFunction
)CFMutableStringRefObj_CFStringAppendPascalString
, 1,
2023 "(StringPtr pStr, CFStringEncoding encoding) -> None"},
2024 {"CFStringAppendCString", (PyCFunction
)CFMutableStringRefObj_CFStringAppendCString
, 1,
2025 "(char* cStr, CFStringEncoding encoding) -> None"},
2026 {"CFStringInsert", (PyCFunction
)CFMutableStringRefObj_CFStringInsert
, 1,
2027 "(CFIndex idx, CFStringRef insertedStr) -> None"},
2028 {"CFStringDelete", (PyCFunction
)CFMutableStringRefObj_CFStringDelete
, 1,
2029 "(CFRange range) -> None"},
2030 {"CFStringReplace", (PyCFunction
)CFMutableStringRefObj_CFStringReplace
, 1,
2031 "(CFRange range, CFStringRef replacement) -> None"},
2032 {"CFStringReplaceAll", (PyCFunction
)CFMutableStringRefObj_CFStringReplaceAll
, 1,
2033 "(CFStringRef replacement) -> None"},
2034 {"CFStringPad", (PyCFunction
)CFMutableStringRefObj_CFStringPad
, 1,
2035 "(CFStringRef padString, CFIndex length, CFIndex indexIntoPad) -> None"},
2036 {"CFStringTrim", (PyCFunction
)CFMutableStringRefObj_CFStringTrim
, 1,
2037 "(CFStringRef trimString) -> None"},
2038 {"CFStringTrimWhitespace", (PyCFunction
)CFMutableStringRefObj_CFStringTrimWhitespace
, 1,
2043 PyMethodChain CFMutableStringRefObj_chain
= { CFMutableStringRefObj_methods
, &CFStringRefObj_chain
};
2045 static PyObject
*CFMutableStringRefObj_getattr(CFMutableStringRefObject
*self
, char *name
)
2047 return Py_FindMethodInChain(&CFMutableStringRefObj_chain
, (PyObject
*)self
, name
);
2050 #define CFMutableStringRefObj_setattr NULL
2052 static int CFMutableStringRefObj_compare(CFMutableStringRefObject
*self
, CFMutableStringRefObject
*other
)
2054 /* XXXX Or should we use CFEqual?? */
2055 if ( self
->ob_itself
> other
->ob_itself
) return 1;
2056 if ( self
->ob_itself
< other
->ob_itself
) return -1;
2060 static PyObject
* CFMutableStringRefObj_repr(CFMutableStringRefObject
*self
)
2063 sprintf(buf
, "<CFMutableStringRef object at 0x%08.8x for 0x%08.8x>", self
, self
->ob_itself
);
2064 return PyString_FromString(buf
);
2067 static int CFMutableStringRefObj_hash(CFMutableStringRefObject
*self
)
2069 /* XXXX Or should we use CFHash?? */
2070 return (int)self
->ob_itself
;
2073 PyTypeObject CFMutableStringRef_Type
= {
2074 PyObject_HEAD_INIT(&PyType_Type
)
2076 "CFMutableStringRef", /*tp_name*/
2077 sizeof(CFMutableStringRefObject
), /*tp_basicsize*/
2080 (destructor
) CFMutableStringRefObj_dealloc
, /*tp_dealloc*/
2082 (getattrfunc
) CFMutableStringRefObj_getattr
, /*tp_getattr*/
2083 (setattrfunc
) CFMutableStringRefObj_setattr
, /*tp_setattr*/
2084 (cmpfunc
) CFMutableStringRefObj_compare
, /*tp_compare*/
2085 (reprfunc
) CFMutableStringRefObj_repr
, /*tp_repr*/
2086 (PyNumberMethods
*)0, /* tp_as_number */
2087 (PySequenceMethods
*)0, /* tp_as_sequence */
2088 (PyMappingMethods
*)0, /* tp_as_mapping */
2089 (hashfunc
) CFMutableStringRefObj_hash
, /*tp_hash*/
2092 /* --------------- End object type CFMutableStringRef --------------- */
2095 /* ---------------------- Object type CFURLRef ---------------------- */
2097 PyTypeObject CFURLRef_Type
;
2099 #define CFURLRefObj_Check(x) ((x)->ob_type == &CFURLRef_Type)
2101 typedef struct CFURLRefObject
{
2104 void (*ob_freeit
)(CFTypeRef ptr
);
2107 PyObject
*CFURLRefObj_New(CFURLRef itself
)
2110 if (itself
== NULL
) return PyMac_Error(resNotFound
);
2111 it
= PyObject_NEW(CFURLRefObject
, &CFURLRef_Type
);
2112 if (it
== NULL
) return NULL
;
2113 it
->ob_itself
= itself
;
2114 it
->ob_freeit
= CFRelease
;
2115 return (PyObject
*)it
;
2117 CFURLRefObj_Convert(PyObject
*v
, CFURLRef
*p_itself
)
2120 if (v
== Py_None
) { *p_itself
= NULL
; return 1; }
2121 /* Check for other CF objects here */
2123 if (!CFURLRefObj_Check(v
))
2125 PyErr_SetString(PyExc_TypeError
, "CFURLRef required");
2128 *p_itself
= ((CFURLRefObject
*)v
)->ob_itself
;
2132 static void CFURLRefObj_dealloc(CFURLRefObject
*self
)
2134 if (self
->ob_freeit
&& self
->ob_itself
)
2136 self
->ob_freeit((CFTypeRef
)self
->ob_itself
);
2141 static PyObject
*CFURLRefObj_CFURLCreateData(CFURLRefObject
*_self
, PyObject
*_args
)
2143 PyObject
*_res
= NULL
;
2145 CFStringEncoding encoding
;
2146 Boolean escapeWhitespace
;
2147 if (!PyArg_ParseTuple(_args
, "ll",
2151 _rv
= CFURLCreateData((CFAllocatorRef
)NULL
,
2155 _res
= Py_BuildValue("O&",
2156 CFDataRefObj_New
, _rv
);
2160 static PyObject
*CFURLRefObj_CFURLCopyAbsoluteURL(CFURLRefObject
*_self
, PyObject
*_args
)
2162 PyObject
*_res
= NULL
;
2164 PyMac_PRECHECK(CFURLCopyAbsoluteURL
);
2165 if (!PyArg_ParseTuple(_args
, ""))
2167 _rv
= CFURLCopyAbsoluteURL(_self
->ob_itself
);
2168 _res
= Py_BuildValue("O&",
2169 CFURLRefObj_New
, _rv
);
2173 static PyObject
*CFURLRefObj_CFURLGetString(CFURLRefObject
*_self
, PyObject
*_args
)
2175 PyObject
*_res
= NULL
;
2177 PyMac_PRECHECK(CFURLGetString
);
2178 if (!PyArg_ParseTuple(_args
, ""))
2180 _rv
= CFURLGetString(_self
->ob_itself
);
2181 _res
= Py_BuildValue("O&",
2182 CFStringRefObj_New
, _rv
);
2186 static PyObject
*CFURLRefObj_CFURLGetBaseURL(CFURLRefObject
*_self
, PyObject
*_args
)
2188 PyObject
*_res
= NULL
;
2190 PyMac_PRECHECK(CFURLGetBaseURL
);
2191 if (!PyArg_ParseTuple(_args
, ""))
2193 _rv
= CFURLGetBaseURL(_self
->ob_itself
);
2194 _res
= Py_BuildValue("O&",
2195 CFURLRefObj_New
, _rv
);
2199 static PyObject
*CFURLRefObj_CFURLCanBeDecomposed(CFURLRefObject
*_self
, PyObject
*_args
)
2201 PyObject
*_res
= NULL
;
2203 PyMac_PRECHECK(CFURLCanBeDecomposed
);
2204 if (!PyArg_ParseTuple(_args
, ""))
2206 _rv
= CFURLCanBeDecomposed(_self
->ob_itself
);
2207 _res
= Py_BuildValue("l",
2212 static PyObject
*CFURLRefObj_CFURLCopyScheme(CFURLRefObject
*_self
, PyObject
*_args
)
2214 PyObject
*_res
= NULL
;
2216 PyMac_PRECHECK(CFURLCopyScheme
);
2217 if (!PyArg_ParseTuple(_args
, ""))
2219 _rv
= CFURLCopyScheme(_self
->ob_itself
);
2220 _res
= Py_BuildValue("O&",
2221 CFStringRefObj_New
, _rv
);
2225 static PyObject
*CFURLRefObj_CFURLCopyNetLocation(CFURLRefObject
*_self
, PyObject
*_args
)
2227 PyObject
*_res
= NULL
;
2229 PyMac_PRECHECK(CFURLCopyNetLocation
);
2230 if (!PyArg_ParseTuple(_args
, ""))
2232 _rv
= CFURLCopyNetLocation(_self
->ob_itself
);
2233 _res
= Py_BuildValue("O&",
2234 CFStringRefObj_New
, _rv
);
2238 static PyObject
*CFURLRefObj_CFURLCopyPath(CFURLRefObject
*_self
, PyObject
*_args
)
2240 PyObject
*_res
= NULL
;
2242 PyMac_PRECHECK(CFURLCopyPath
);
2243 if (!PyArg_ParseTuple(_args
, ""))
2245 _rv
= CFURLCopyPath(_self
->ob_itself
);
2246 _res
= Py_BuildValue("O&",
2247 CFStringRefObj_New
, _rv
);
2251 static PyObject
*CFURLRefObj_CFURLHasDirectoryPath(CFURLRefObject
*_self
, PyObject
*_args
)
2253 PyObject
*_res
= NULL
;
2255 PyMac_PRECHECK(CFURLHasDirectoryPath
);
2256 if (!PyArg_ParseTuple(_args
, ""))
2258 _rv
= CFURLHasDirectoryPath(_self
->ob_itself
);
2259 _res
= Py_BuildValue("l",
2264 static PyObject
*CFURLRefObj_CFURLCopyResourceSpecifier(CFURLRefObject
*_self
, PyObject
*_args
)
2266 PyObject
*_res
= NULL
;
2268 PyMac_PRECHECK(CFURLCopyResourceSpecifier
);
2269 if (!PyArg_ParseTuple(_args
, ""))
2271 _rv
= CFURLCopyResourceSpecifier(_self
->ob_itself
);
2272 _res
= Py_BuildValue("O&",
2273 CFStringRefObj_New
, _rv
);
2277 static PyObject
*CFURLRefObj_CFURLCopyHostName(CFURLRefObject
*_self
, PyObject
*_args
)
2279 PyObject
*_res
= NULL
;
2281 PyMac_PRECHECK(CFURLCopyHostName
);
2282 if (!PyArg_ParseTuple(_args
, ""))
2284 _rv
= CFURLCopyHostName(_self
->ob_itself
);
2285 _res
= Py_BuildValue("O&",
2286 CFStringRefObj_New
, _rv
);
2290 static PyObject
*CFURLRefObj_CFURLGetPortNumber(CFURLRefObject
*_self
, PyObject
*_args
)
2292 PyObject
*_res
= NULL
;
2294 PyMac_PRECHECK(CFURLGetPortNumber
);
2295 if (!PyArg_ParseTuple(_args
, ""))
2297 _rv
= CFURLGetPortNumber(_self
->ob_itself
);
2298 _res
= Py_BuildValue("l",
2303 static PyObject
*CFURLRefObj_CFURLCopyUserName(CFURLRefObject
*_self
, PyObject
*_args
)
2305 PyObject
*_res
= NULL
;
2307 PyMac_PRECHECK(CFURLCopyUserName
);
2308 if (!PyArg_ParseTuple(_args
, ""))
2310 _rv
= CFURLCopyUserName(_self
->ob_itself
);
2311 _res
= Py_BuildValue("O&",
2312 CFStringRefObj_New
, _rv
);
2316 static PyObject
*CFURLRefObj_CFURLCopyPassword(CFURLRefObject
*_self
, PyObject
*_args
)
2318 PyObject
*_res
= NULL
;
2320 PyMac_PRECHECK(CFURLCopyPassword
);
2321 if (!PyArg_ParseTuple(_args
, ""))
2323 _rv
= CFURLCopyPassword(_self
->ob_itself
);
2324 _res
= Py_BuildValue("O&",
2325 CFStringRefObj_New
, _rv
);
2329 static PyObject
*CFURLRefObj_CFURLCopyParameterString(CFURLRefObject
*_self
, PyObject
*_args
)
2331 PyObject
*_res
= NULL
;
2333 CFStringRef charactersToLeaveEscaped
;
2334 PyMac_PRECHECK(CFURLCopyParameterString
);
2335 if (!PyArg_ParseTuple(_args
, "O&",
2336 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
2338 _rv
= CFURLCopyParameterString(_self
->ob_itself
,
2339 charactersToLeaveEscaped
);
2340 _res
= Py_BuildValue("O&",
2341 CFStringRefObj_New
, _rv
);
2345 static PyObject
*CFURLRefObj_CFURLCopyQueryString(CFURLRefObject
*_self
, PyObject
*_args
)
2347 PyObject
*_res
= NULL
;
2349 CFStringRef charactersToLeaveEscaped
;
2350 PyMac_PRECHECK(CFURLCopyQueryString
);
2351 if (!PyArg_ParseTuple(_args
, "O&",
2352 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
2354 _rv
= CFURLCopyQueryString(_self
->ob_itself
,
2355 charactersToLeaveEscaped
);
2356 _res
= Py_BuildValue("O&",
2357 CFStringRefObj_New
, _rv
);
2361 static PyObject
*CFURLRefObj_CFURLCopyFragment(CFURLRefObject
*_self
, PyObject
*_args
)
2363 PyObject
*_res
= NULL
;
2365 CFStringRef charactersToLeaveEscaped
;
2366 PyMac_PRECHECK(CFURLCopyFragment
);
2367 if (!PyArg_ParseTuple(_args
, "O&",
2368 CFStringRefObj_Convert
, &charactersToLeaveEscaped
))
2370 _rv
= CFURLCopyFragment(_self
->ob_itself
,
2371 charactersToLeaveEscaped
);
2372 _res
= Py_BuildValue("O&",
2373 CFStringRefObj_New
, _rv
);
2377 static PyMethodDef CFURLRefObj_methods
[] = {
2378 {"CFURLCreateData", (PyCFunction
)CFURLRefObj_CFURLCreateData
, 1,
2379 "(CFStringEncoding encoding, Boolean escapeWhitespace) -> (CFDataRef _rv)"},
2380 {"CFURLCopyAbsoluteURL", (PyCFunction
)CFURLRefObj_CFURLCopyAbsoluteURL
, 1,
2381 "() -> (CFURLRef _rv)"},
2382 {"CFURLGetString", (PyCFunction
)CFURLRefObj_CFURLGetString
, 1,
2383 "() -> (CFStringRef _rv)"},
2384 {"CFURLGetBaseURL", (PyCFunction
)CFURLRefObj_CFURLGetBaseURL
, 1,
2385 "() -> (CFURLRef _rv)"},
2386 {"CFURLCanBeDecomposed", (PyCFunction
)CFURLRefObj_CFURLCanBeDecomposed
, 1,
2387 "() -> (Boolean _rv)"},
2388 {"CFURLCopyScheme", (PyCFunction
)CFURLRefObj_CFURLCopyScheme
, 1,
2389 "() -> (CFStringRef _rv)"},
2390 {"CFURLCopyNetLocation", (PyCFunction
)CFURLRefObj_CFURLCopyNetLocation
, 1,
2391 "() -> (CFStringRef _rv)"},
2392 {"CFURLCopyPath", (PyCFunction
)CFURLRefObj_CFURLCopyPath
, 1,
2393 "() -> (CFStringRef _rv)"},
2394 {"CFURLHasDirectoryPath", (PyCFunction
)CFURLRefObj_CFURLHasDirectoryPath
, 1,
2395 "() -> (Boolean _rv)"},
2396 {"CFURLCopyResourceSpecifier", (PyCFunction
)CFURLRefObj_CFURLCopyResourceSpecifier
, 1,
2397 "() -> (CFStringRef _rv)"},
2398 {"CFURLCopyHostName", (PyCFunction
)CFURLRefObj_CFURLCopyHostName
, 1,
2399 "() -> (CFStringRef _rv)"},
2400 {"CFURLGetPortNumber", (PyCFunction
)CFURLRefObj_CFURLGetPortNumber
, 1,
2401 "() -> (SInt32 _rv)"},
2402 {"CFURLCopyUserName", (PyCFunction
)CFURLRefObj_CFURLCopyUserName
, 1,
2403 "() -> (CFStringRef _rv)"},
2404 {"CFURLCopyPassword", (PyCFunction
)CFURLRefObj_CFURLCopyPassword
, 1,
2405 "() -> (CFStringRef _rv)"},
2406 {"CFURLCopyParameterString", (PyCFunction
)CFURLRefObj_CFURLCopyParameterString
, 1,
2407 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2408 {"CFURLCopyQueryString", (PyCFunction
)CFURLRefObj_CFURLCopyQueryString
, 1,
2409 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2410 {"CFURLCopyFragment", (PyCFunction
)CFURLRefObj_CFURLCopyFragment
, 1,
2411 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2415 PyMethodChain CFURLRefObj_chain
= { CFURLRefObj_methods
, &CFTypeRefObj_chain
};
2417 static PyObject
*CFURLRefObj_getattr(CFURLRefObject
*self
, char *name
)
2419 return Py_FindMethodInChain(&CFURLRefObj_chain
, (PyObject
*)self
, name
);
2422 #define CFURLRefObj_setattr NULL
2424 static int CFURLRefObj_compare(CFURLRefObject
*self
, CFURLRefObject
*other
)
2426 /* XXXX Or should we use CFEqual?? */
2427 if ( self
->ob_itself
> other
->ob_itself
) return 1;
2428 if ( self
->ob_itself
< other
->ob_itself
) return -1;
2432 static PyObject
* CFURLRefObj_repr(CFURLRefObject
*self
)
2435 sprintf(buf
, "<CFURL object at 0x%08.8x for 0x%08.8x>", self
, self
->ob_itself
);
2436 return PyString_FromString(buf
);
2439 static int CFURLRefObj_hash(CFURLRefObject
*self
)
2441 /* XXXX Or should we use CFHash?? */
2442 return (int)self
->ob_itself
;
2445 PyTypeObject CFURLRef_Type
= {
2446 PyObject_HEAD_INIT(&PyType_Type
)
2448 "CFURLRef", /*tp_name*/
2449 sizeof(CFURLRefObject
), /*tp_basicsize*/
2452 (destructor
) CFURLRefObj_dealloc
, /*tp_dealloc*/
2454 (getattrfunc
) CFURLRefObj_getattr
, /*tp_getattr*/
2455 (setattrfunc
) CFURLRefObj_setattr
, /*tp_setattr*/
2456 (cmpfunc
) CFURLRefObj_compare
, /*tp_compare*/
2457 (reprfunc
) CFURLRefObj_repr
, /*tp_repr*/
2458 (PyNumberMethods
*)0, /* tp_as_number */
2459 (PySequenceMethods
*)0, /* tp_as_sequence */
2460 (PyMappingMethods
*)0, /* tp_as_mapping */
2461 (hashfunc
) CFURLRefObj_hash
, /*tp_hash*/
2464 /* -------------------- End object type CFURLRef -------------------- */
2467 static PyObject
*CF_CFAllocatorGetTypeID(PyObject
*_self
, PyObject
*_args
)
2469 PyObject
*_res
= NULL
;
2471 PyMac_PRECHECK(CFAllocatorGetTypeID
);
2472 if (!PyArg_ParseTuple(_args
, ""))
2474 _rv
= CFAllocatorGetTypeID();
2475 _res
= Py_BuildValue("l",
2480 static PyObject
*CF_CFAllocatorGetPreferredSizeForSize(PyObject
*_self
, PyObject
*_args
)
2482 PyObject
*_res
= NULL
;
2486 PyMac_PRECHECK(CFAllocatorGetPreferredSizeForSize
);
2487 if (!PyArg_ParseTuple(_args
, "ll",
2491 _rv
= CFAllocatorGetPreferredSizeForSize((CFAllocatorRef
)NULL
,
2494 _res
= Py_BuildValue("l",
2499 static PyObject
*CF_CFCopyTypeIDDescription(PyObject
*_self
, PyObject
*_args
)
2501 PyObject
*_res
= NULL
;
2504 PyMac_PRECHECK(CFCopyTypeIDDescription
);
2505 if (!PyArg_ParseTuple(_args
, "l",
2508 _rv
= CFCopyTypeIDDescription(theType
);
2509 _res
= Py_BuildValue("O&",
2510 CFStringRefObj_New
, _rv
);
2514 static PyObject
*CF_CFArrayGetTypeID(PyObject
*_self
, PyObject
*_args
)
2516 PyObject
*_res
= NULL
;
2518 PyMac_PRECHECK(CFArrayGetTypeID
);
2519 if (!PyArg_ParseTuple(_args
, ""))
2521 _rv
= CFArrayGetTypeID();
2522 _res
= Py_BuildValue("l",
2527 static PyObject
*CF_CFArrayCreateMutable(PyObject
*_self
, PyObject
*_args
)
2529 PyObject
*_res
= NULL
;
2530 CFMutableArrayRef _rv
;
2532 PyMac_PRECHECK(CFArrayCreateMutable
);
2533 if (!PyArg_ParseTuple(_args
, "l",
2536 _rv
= CFArrayCreateMutable((CFAllocatorRef
)NULL
,
2538 &kCFTypeArrayCallBacks
);
2539 _res
= Py_BuildValue("O&",
2540 CFMutableArrayRefObj_New
, _rv
);
2544 static PyObject
*CF_CFArrayCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
2546 PyObject
*_res
= NULL
;
2547 CFMutableArrayRef _rv
;
2549 CFArrayRef srcArray
;
2550 PyMac_PRECHECK(CFArrayCreateMutableCopy
);
2551 if (!PyArg_ParseTuple(_args
, "lO&",
2553 CFArrayRefObj_Convert
, &srcArray
))
2555 _rv
= CFArrayCreateMutableCopy((CFAllocatorRef
)NULL
,
2558 _res
= Py_BuildValue("O&",
2559 CFMutableArrayRefObj_New
, _rv
);
2563 static PyObject
*CF_CFDataGetTypeID(PyObject
*_self
, PyObject
*_args
)
2565 PyObject
*_res
= NULL
;
2567 PyMac_PRECHECK(CFDataGetTypeID
);
2568 if (!PyArg_ParseTuple(_args
, ""))
2570 _rv
= CFDataGetTypeID();
2571 _res
= Py_BuildValue("l",
2576 static PyObject
*CF_CFDataCreate(PyObject
*_self
, PyObject
*_args
)
2578 PyObject
*_res
= NULL
;
2580 unsigned char *bytes__in__
;
2582 int bytes__in_len__
;
2583 PyMac_PRECHECK(CFDataCreate
);
2584 if (!PyArg_ParseTuple(_args
, "s#",
2585 &bytes__in__
, &bytes__in_len__
))
2587 bytes__len__
= bytes__in_len__
;
2588 _rv
= CFDataCreate((CFAllocatorRef
)NULL
,
2589 bytes__in__
, bytes__len__
);
2590 _res
= Py_BuildValue("O&",
2591 CFDataRefObj_New
, _rv
);
2596 static PyObject
*CF_CFDataCreateWithBytesNoCopy(PyObject
*_self
, PyObject
*_args
)
2598 PyObject
*_res
= NULL
;
2600 unsigned char *bytes__in__
;
2602 int bytes__in_len__
;
2603 PyMac_PRECHECK(CFDataCreateWithBytesNoCopy
);
2604 if (!PyArg_ParseTuple(_args
, "s#",
2605 &bytes__in__
, &bytes__in_len__
))
2607 bytes__len__
= bytes__in_len__
;
2608 _rv
= CFDataCreateWithBytesNoCopy((CFAllocatorRef
)NULL
,
2609 bytes__in__
, bytes__len__
,
2610 (CFAllocatorRef
)NULL
);
2611 _res
= Py_BuildValue("O&",
2612 CFDataRefObj_New
, _rv
);
2617 static PyObject
*CF_CFDataCreateMutable(PyObject
*_self
, PyObject
*_args
)
2619 PyObject
*_res
= NULL
;
2620 CFMutableDataRef _rv
;
2622 PyMac_PRECHECK(CFDataCreateMutable
);
2623 if (!PyArg_ParseTuple(_args
, "l",
2626 _rv
= CFDataCreateMutable((CFAllocatorRef
)NULL
,
2628 _res
= Py_BuildValue("O&",
2629 CFMutableDataRefObj_New
, _rv
);
2633 static PyObject
*CF_CFDataCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
2635 PyObject
*_res
= NULL
;
2636 CFMutableDataRef _rv
;
2639 PyMac_PRECHECK(CFDataCreateMutableCopy
);
2640 if (!PyArg_ParseTuple(_args
, "lO&",
2642 CFDataRefObj_Convert
, &data
))
2644 _rv
= CFDataCreateMutableCopy((CFAllocatorRef
)NULL
,
2647 _res
= Py_BuildValue("O&",
2648 CFMutableDataRefObj_New
, _rv
);
2652 static PyObject
*CF_CFDictionaryGetTypeID(PyObject
*_self
, PyObject
*_args
)
2654 PyObject
*_res
= NULL
;
2656 PyMac_PRECHECK(CFDictionaryGetTypeID
);
2657 if (!PyArg_ParseTuple(_args
, ""))
2659 _rv
= CFDictionaryGetTypeID();
2660 _res
= Py_BuildValue("l",
2665 static PyObject
*CF_CFDictionaryCreateMutable(PyObject
*_self
, PyObject
*_args
)
2667 PyObject
*_res
= NULL
;
2668 CFMutableDictionaryRef _rv
;
2670 PyMac_PRECHECK(CFDictionaryCreateMutable
);
2671 if (!PyArg_ParseTuple(_args
, "l",
2674 _rv
= CFDictionaryCreateMutable((CFAllocatorRef
)NULL
,
2676 &kCFTypeDictionaryKeyCallBacks
,
2677 &kCFTypeDictionaryValueCallBacks
);
2678 _res
= Py_BuildValue("O&",
2679 CFMutableDictionaryRefObj_New
, _rv
);
2683 static PyObject
*CF_CFDictionaryCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
2685 PyObject
*_res
= NULL
;
2686 CFMutableDictionaryRef _rv
;
2688 CFDictionaryRef dict
;
2689 PyMac_PRECHECK(CFDictionaryCreateMutableCopy
);
2690 if (!PyArg_ParseTuple(_args
, "lO&",
2692 CFDictionaryRefObj_Convert
, &dict
))
2694 _rv
= CFDictionaryCreateMutableCopy((CFAllocatorRef
)NULL
,
2697 _res
= Py_BuildValue("O&",
2698 CFMutableDictionaryRefObj_New
, _rv
);
2702 static PyObject
*CF_CFStringGetTypeID(PyObject
*_self
, PyObject
*_args
)
2704 PyObject
*_res
= NULL
;
2706 PyMac_PRECHECK(CFStringGetTypeID
);
2707 if (!PyArg_ParseTuple(_args
, ""))
2709 _rv
= CFStringGetTypeID();
2710 _res
= Py_BuildValue("l",
2715 static PyObject
*CF_CFStringCreateWithPascalString(PyObject
*_self
, PyObject
*_args
)
2717 PyObject
*_res
= NULL
;
2720 CFStringEncoding encoding
;
2721 PyMac_PRECHECK(CFStringCreateWithPascalString
);
2722 if (!PyArg_ParseTuple(_args
, "O&l",
2723 PyMac_GetStr255
, &pStr
,
2726 _rv
= CFStringCreateWithPascalString((CFAllocatorRef
)NULL
,
2729 _res
= Py_BuildValue("O&",
2730 CFStringRefObj_New
, _rv
);
2734 static PyObject
*CF_CFStringCreateWithCString(PyObject
*_self
, PyObject
*_args
)
2736 PyObject
*_res
= NULL
;
2739 CFStringEncoding encoding
;
2740 PyMac_PRECHECK(CFStringCreateWithCString
);
2741 if (!PyArg_ParseTuple(_args
, "sl",
2745 _rv
= CFStringCreateWithCString((CFAllocatorRef
)NULL
,
2748 _res
= Py_BuildValue("O&",
2749 CFStringRefObj_New
, _rv
);
2753 static PyObject
*CF_CFStringCreateWithPascalStringNoCopy(PyObject
*_self
, PyObject
*_args
)
2755 PyObject
*_res
= NULL
;
2758 CFStringEncoding encoding
;
2759 PyMac_PRECHECK(CFStringCreateWithPascalStringNoCopy
);
2760 if (!PyArg_ParseTuple(_args
, "O&l",
2761 PyMac_GetStr255
, &pStr
,
2764 _rv
= CFStringCreateWithPascalStringNoCopy((CFAllocatorRef
)NULL
,
2767 (CFAllocatorRef
)NULL
);
2768 _res
= Py_BuildValue("O&",
2769 CFStringRefObj_New
, _rv
);
2773 static PyObject
*CF_CFStringCreateWithCStringNoCopy(PyObject
*_self
, PyObject
*_args
)
2775 PyObject
*_res
= NULL
;
2778 CFStringEncoding encoding
;
2779 PyMac_PRECHECK(CFStringCreateWithCStringNoCopy
);
2780 if (!PyArg_ParseTuple(_args
, "sl",
2784 _rv
= CFStringCreateWithCStringNoCopy((CFAllocatorRef
)NULL
,
2787 (CFAllocatorRef
)NULL
);
2788 _res
= Py_BuildValue("O&",
2789 CFStringRefObj_New
, _rv
);
2793 static PyObject
*CF_CFStringCreateMutable(PyObject
*_self
, PyObject
*_args
)
2795 PyObject
*_res
= NULL
;
2796 CFMutableStringRef _rv
;
2798 PyMac_PRECHECK(CFStringCreateMutable
);
2799 if (!PyArg_ParseTuple(_args
, "l",
2802 _rv
= CFStringCreateMutable((CFAllocatorRef
)NULL
,
2804 _res
= Py_BuildValue("O&",
2805 CFMutableStringRefObj_New
, _rv
);
2809 static PyObject
*CF_CFStringCreateMutableCopy(PyObject
*_self
, PyObject
*_args
)
2811 PyObject
*_res
= NULL
;
2812 CFMutableStringRef _rv
;
2814 CFStringRef theString
;
2815 PyMac_PRECHECK(CFStringCreateMutableCopy
);
2816 if (!PyArg_ParseTuple(_args
, "lO&",
2818 CFStringRefObj_Convert
, &theString
))
2820 _rv
= CFStringCreateMutableCopy((CFAllocatorRef
)NULL
,
2823 _res
= Py_BuildValue("O&",
2824 CFMutableStringRefObj_New
, _rv
);
2828 static PyObject
*CF_CFStringCreateWithBytes(PyObject
*_self
, PyObject
*_args
)
2830 PyObject
*_res
= NULL
;
2832 unsigned char *bytes__in__
;
2834 int bytes__in_len__
;
2835 CFStringEncoding encoding
;
2836 Boolean isExternalRepresentation
;
2837 PyMac_PRECHECK(CFStringCreateWithBytes
);
2838 if (!PyArg_ParseTuple(_args
, "s#ll",
2839 &bytes__in__
, &bytes__in_len__
,
2841 &isExternalRepresentation
))
2843 bytes__len__
= bytes__in_len__
;
2844 _rv
= CFStringCreateWithBytes((CFAllocatorRef
)NULL
,
2845 bytes__in__
, bytes__len__
,
2847 isExternalRepresentation
);
2848 _res
= Py_BuildValue("O&",
2849 CFStringRefObj_New
, _rv
);
2854 static PyObject
*CF_CFStringGetSystemEncoding(PyObject
*_self
, PyObject
*_args
)
2856 PyObject
*_res
= NULL
;
2857 CFStringEncoding _rv
;
2858 PyMac_PRECHECK(CFStringGetSystemEncoding
);
2859 if (!PyArg_ParseTuple(_args
, ""))
2861 _rv
= CFStringGetSystemEncoding();
2862 _res
= Py_BuildValue("l",
2867 static PyObject
*CF_CFStringGetMaximumSizeForEncoding(PyObject
*_self
, PyObject
*_args
)
2869 PyObject
*_res
= NULL
;
2872 CFStringEncoding encoding
;
2873 PyMac_PRECHECK(CFStringGetMaximumSizeForEncoding
);
2874 if (!PyArg_ParseTuple(_args
, "ll",
2878 _rv
= CFStringGetMaximumSizeForEncoding(length
,
2880 _res
= Py_BuildValue("l",
2885 static PyObject
*CF_CFStringIsEncodingAvailable(PyObject
*_self
, PyObject
*_args
)
2887 PyObject
*_res
= NULL
;
2889 CFStringEncoding encoding
;
2890 PyMac_PRECHECK(CFStringIsEncodingAvailable
);
2891 if (!PyArg_ParseTuple(_args
, "l",
2894 _rv
= CFStringIsEncodingAvailable(encoding
);
2895 _res
= Py_BuildValue("l",
2900 static PyObject
*CF_CFStringGetNameOfEncoding(PyObject
*_self
, PyObject
*_args
)
2902 PyObject
*_res
= NULL
;
2904 CFStringEncoding encoding
;
2905 PyMac_PRECHECK(CFStringGetNameOfEncoding
);
2906 if (!PyArg_ParseTuple(_args
, "l",
2909 _rv
= CFStringGetNameOfEncoding(encoding
);
2910 _res
= Py_BuildValue("O&",
2911 CFStringRefObj_New
, _rv
);
2915 static PyObject
*CF_CFStringConvertEncodingToNSStringEncoding(PyObject
*_self
, PyObject
*_args
)
2917 PyObject
*_res
= NULL
;
2919 CFStringEncoding encoding
;
2920 PyMac_PRECHECK(CFStringConvertEncodingToNSStringEncoding
);
2921 if (!PyArg_ParseTuple(_args
, "l",
2924 _rv
= CFStringConvertEncodingToNSStringEncoding(encoding
);
2925 _res
= Py_BuildValue("l",
2930 static PyObject
*CF_CFStringConvertNSStringEncodingToEncoding(PyObject
*_self
, PyObject
*_args
)
2932 PyObject
*_res
= NULL
;
2933 CFStringEncoding _rv
;
2935 PyMac_PRECHECK(CFStringConvertNSStringEncodingToEncoding
);
2936 if (!PyArg_ParseTuple(_args
, "l",
2939 _rv
= CFStringConvertNSStringEncodingToEncoding(encoding
);
2940 _res
= Py_BuildValue("l",
2945 static PyObject
*CF_CFStringConvertEncodingToWindowsCodepage(PyObject
*_self
, PyObject
*_args
)
2947 PyObject
*_res
= NULL
;
2949 CFStringEncoding encoding
;
2950 PyMac_PRECHECK(CFStringConvertEncodingToWindowsCodepage
);
2951 if (!PyArg_ParseTuple(_args
, "l",
2954 _rv
= CFStringConvertEncodingToWindowsCodepage(encoding
);
2955 _res
= Py_BuildValue("l",
2960 static PyObject
*CF_CFStringConvertWindowsCodepageToEncoding(PyObject
*_self
, PyObject
*_args
)
2962 PyObject
*_res
= NULL
;
2963 CFStringEncoding _rv
;
2965 PyMac_PRECHECK(CFStringConvertWindowsCodepageToEncoding
);
2966 if (!PyArg_ParseTuple(_args
, "l",
2969 _rv
= CFStringConvertWindowsCodepageToEncoding(codepage
);
2970 _res
= Py_BuildValue("l",
2975 static PyObject
*CF_CFStringConvertEncodingToIANACharSetName(PyObject
*_self
, PyObject
*_args
)
2977 PyObject
*_res
= NULL
;
2979 CFStringEncoding encoding
;
2980 PyMac_PRECHECK(CFStringConvertEncodingToIANACharSetName
);
2981 if (!PyArg_ParseTuple(_args
, "l",
2984 _rv
= CFStringConvertEncodingToIANACharSetName(encoding
);
2985 _res
= Py_BuildValue("O&",
2986 CFStringRefObj_New
, _rv
);
2990 static PyObject
*CF___CFStringMakeConstantString(PyObject
*_self
, PyObject
*_args
)
2992 PyObject
*_res
= NULL
;
2995 PyMac_PRECHECK(__CFStringMakeConstantString
);
2996 if (!PyArg_ParseTuple(_args
, "s",
2999 _rv
= __CFStringMakeConstantString(cStr
);
3000 _res
= Py_BuildValue("O&",
3001 CFStringRefObj_New
, _rv
);
3005 static PyObject
*CF_CFURLGetTypeID(PyObject
*_self
, PyObject
*_args
)
3007 PyObject
*_res
= NULL
;
3009 PyMac_PRECHECK(CFURLGetTypeID
);
3010 if (!PyArg_ParseTuple(_args
, ""))
3012 _rv
= CFURLGetTypeID();
3013 _res
= Py_BuildValue("l",
3018 static PyObject
*CF_CFURLCreateWithBytes(PyObject
*_self
, PyObject
*_args
)
3020 PyObject
*_res
= NULL
;
3022 unsigned char *URLBytes__in__
;
3023 long URLBytes__len__
;
3024 int URLBytes__in_len__
;
3025 CFStringEncoding encoding
;
3027 PyMac_PRECHECK(CFURLCreateWithBytes
);
3028 if (!PyArg_ParseTuple(_args
, "s#lO&",
3029 &URLBytes__in__
, &URLBytes__in_len__
,
3031 OptionalCFURLRefObj_Convert
, &baseURL
))
3033 URLBytes__len__
= URLBytes__in_len__
;
3034 _rv
= CFURLCreateWithBytes((CFAllocatorRef
)NULL
,
3035 URLBytes__in__
, URLBytes__len__
,
3038 _res
= Py_BuildValue("O&",
3039 CFURLRefObj_New
, _rv
);
3040 URLBytes__error__
: ;
3044 static PyMethodDef CF_methods
[] = {
3045 {"CFAllocatorGetTypeID", (PyCFunction
)CF_CFAllocatorGetTypeID
, 1,
3046 "() -> (CFTypeID _rv)"},
3047 {"CFAllocatorGetPreferredSizeForSize", (PyCFunction
)CF_CFAllocatorGetPreferredSizeForSize
, 1,
3048 "(CFIndex size, CFOptionFlags hint) -> (CFIndex _rv)"},
3049 {"CFCopyTypeIDDescription", (PyCFunction
)CF_CFCopyTypeIDDescription
, 1,
3050 "(CFTypeID theType) -> (CFStringRef _rv)"},
3051 {"CFArrayGetTypeID", (PyCFunction
)CF_CFArrayGetTypeID
, 1,
3052 "() -> (CFTypeID _rv)"},
3053 {"CFArrayCreateMutable", (PyCFunction
)CF_CFArrayCreateMutable
, 1,
3054 "(CFIndex capacity) -> (CFMutableArrayRef _rv)"},
3055 {"CFArrayCreateMutableCopy", (PyCFunction
)CF_CFArrayCreateMutableCopy
, 1,
3056 "(CFIndex capacity, CFArrayRef srcArray) -> (CFMutableArrayRef _rv)"},
3057 {"CFDataGetTypeID", (PyCFunction
)CF_CFDataGetTypeID
, 1,
3058 "() -> (CFTypeID _rv)"},
3059 {"CFDataCreate", (PyCFunction
)CF_CFDataCreate
, 1,
3060 "(Buffer bytes) -> (CFDataRef _rv)"},
3061 {"CFDataCreateWithBytesNoCopy", (PyCFunction
)CF_CFDataCreateWithBytesNoCopy
, 1,
3062 "(Buffer bytes) -> (CFDataRef _rv)"},
3063 {"CFDataCreateMutable", (PyCFunction
)CF_CFDataCreateMutable
, 1,
3064 "(CFIndex capacity) -> (CFMutableDataRef _rv)"},
3065 {"CFDataCreateMutableCopy", (PyCFunction
)CF_CFDataCreateMutableCopy
, 1,
3066 "(CFIndex capacity, CFDataRef data) -> (CFMutableDataRef _rv)"},
3067 {"CFDictionaryGetTypeID", (PyCFunction
)CF_CFDictionaryGetTypeID
, 1,
3068 "() -> (CFTypeID _rv)"},
3069 {"CFDictionaryCreateMutable", (PyCFunction
)CF_CFDictionaryCreateMutable
, 1,
3070 "(CFIndex capacity) -> (CFMutableDictionaryRef _rv)"},
3071 {"CFDictionaryCreateMutableCopy", (PyCFunction
)CF_CFDictionaryCreateMutableCopy
, 1,
3072 "(CFIndex capacity, CFDictionaryRef dict) -> (CFMutableDictionaryRef _rv)"},
3073 {"CFStringGetTypeID", (PyCFunction
)CF_CFStringGetTypeID
, 1,
3074 "() -> (CFTypeID _rv)"},
3075 {"CFStringCreateWithPascalString", (PyCFunction
)CF_CFStringCreateWithPascalString
, 1,
3076 "(StringPtr pStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
3077 {"CFStringCreateWithCString", (PyCFunction
)CF_CFStringCreateWithCString
, 1,
3078 "(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
3079 {"CFStringCreateWithPascalStringNoCopy", (PyCFunction
)CF_CFStringCreateWithPascalStringNoCopy
, 1,
3080 "(StringPtr pStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
3081 {"CFStringCreateWithCStringNoCopy", (PyCFunction
)CF_CFStringCreateWithCStringNoCopy
, 1,
3082 "(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
3083 {"CFStringCreateMutable", (PyCFunction
)CF_CFStringCreateMutable
, 1,
3084 "(CFIndex maxLength) -> (CFMutableStringRef _rv)"},
3085 {"CFStringCreateMutableCopy", (PyCFunction
)CF_CFStringCreateMutableCopy
, 1,
3086 "(CFIndex maxLength, CFStringRef theString) -> (CFMutableStringRef _rv)"},
3087 {"CFStringCreateWithBytes", (PyCFunction
)CF_CFStringCreateWithBytes
, 1,
3088 "(Buffer bytes, CFStringEncoding encoding, Boolean isExternalRepresentation) -> (CFStringRef _rv)"},
3089 {"CFStringGetSystemEncoding", (PyCFunction
)CF_CFStringGetSystemEncoding
, 1,
3090 "() -> (CFStringEncoding _rv)"},
3091 {"CFStringGetMaximumSizeForEncoding", (PyCFunction
)CF_CFStringGetMaximumSizeForEncoding
, 1,
3092 "(CFIndex length, CFStringEncoding encoding) -> (CFIndex _rv)"},
3093 {"CFStringIsEncodingAvailable", (PyCFunction
)CF_CFStringIsEncodingAvailable
, 1,
3094 "(CFStringEncoding encoding) -> (Boolean _rv)"},
3095 {"CFStringGetNameOfEncoding", (PyCFunction
)CF_CFStringGetNameOfEncoding
, 1,
3096 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
3097 {"CFStringConvertEncodingToNSStringEncoding", (PyCFunction
)CF_CFStringConvertEncodingToNSStringEncoding
, 1,
3098 "(CFStringEncoding encoding) -> (UInt32 _rv)"},
3099 {"CFStringConvertNSStringEncodingToEncoding", (PyCFunction
)CF_CFStringConvertNSStringEncodingToEncoding
, 1,
3100 "(UInt32 encoding) -> (CFStringEncoding _rv)"},
3101 {"CFStringConvertEncodingToWindowsCodepage", (PyCFunction
)CF_CFStringConvertEncodingToWindowsCodepage
, 1,
3102 "(CFStringEncoding encoding) -> (UInt32 _rv)"},
3103 {"CFStringConvertWindowsCodepageToEncoding", (PyCFunction
)CF_CFStringConvertWindowsCodepageToEncoding
, 1,
3104 "(UInt32 codepage) -> (CFStringEncoding _rv)"},
3105 {"CFStringConvertEncodingToIANACharSetName", (PyCFunction
)CF_CFStringConvertEncodingToIANACharSetName
, 1,
3106 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
3107 {"__CFStringMakeConstantString", (PyCFunction
)CF___CFStringMakeConstantString
, 1,
3108 "(char* cStr) -> (CFStringRef _rv)"},
3109 {"CFURLGetTypeID", (PyCFunction
)CF_CFURLGetTypeID
, 1,
3110 "() -> (CFTypeID _rv)"},
3111 {"CFURLCreateWithBytes", (PyCFunction
)CF_CFURLCreateWithBytes
, 1,
3112 "(Buffer URLBytes, CFStringEncoding encoding, CFURLRef baseURL) -> (CFURLRef _rv)"},
3126 // PyMac_INIT_TOOLBOX_OBJECT_NEW(Track, TrackObj_New);
3127 // PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Track, TrackObj_Convert);
3130 m
= Py_InitModule("CF", CF_methods
);
3131 d
= PyModule_GetDict(m
);
3132 CF_Error
= PyMac_GetOSErrException();
3133 if (CF_Error
== NULL
||
3134 PyDict_SetItemString(d
, "Error", CF_Error
) != 0)
3136 CFTypeRef_Type
.ob_type
= &PyType_Type
;
3137 Py_INCREF(&CFTypeRef_Type
);
3138 if (PyDict_SetItemString(d
, "CFTypeRefType", (PyObject
*)&CFTypeRef_Type
) != 0)
3139 Py_FatalError("can't initialize CFTypeRefType");
3140 CFArrayRef_Type
.ob_type
= &PyType_Type
;
3141 Py_INCREF(&CFArrayRef_Type
);
3142 if (PyDict_SetItemString(d
, "CFArrayRefType", (PyObject
*)&CFArrayRef_Type
) != 0)
3143 Py_FatalError("can't initialize CFArrayRefType");
3144 CFMutableArrayRef_Type
.ob_type
= &PyType_Type
;
3145 Py_INCREF(&CFMutableArrayRef_Type
);
3146 if (PyDict_SetItemString(d
, "CFMutableArrayRefType", (PyObject
*)&CFMutableArrayRef_Type
) != 0)
3147 Py_FatalError("can't initialize CFMutableArrayRefType");
3148 CFDictionaryRef_Type
.ob_type
= &PyType_Type
;
3149 Py_INCREF(&CFDictionaryRef_Type
);
3150 if (PyDict_SetItemString(d
, "CFDictionaryRefType", (PyObject
*)&CFDictionaryRef_Type
) != 0)
3151 Py_FatalError("can't initialize CFDictionaryRefType");
3152 CFMutableDictionaryRef_Type
.ob_type
= &PyType_Type
;
3153 Py_INCREF(&CFMutableDictionaryRef_Type
);
3154 if (PyDict_SetItemString(d
, "CFMutableDictionaryRefType", (PyObject
*)&CFMutableDictionaryRef_Type
) != 0)
3155 Py_FatalError("can't initialize CFMutableDictionaryRefType");
3156 CFDataRef_Type
.ob_type
= &PyType_Type
;
3157 Py_INCREF(&CFDataRef_Type
);
3158 if (PyDict_SetItemString(d
, "CFDataRefType", (PyObject
*)&CFDataRef_Type
) != 0)
3159 Py_FatalError("can't initialize CFDataRefType");
3160 CFMutableDataRef_Type
.ob_type
= &PyType_Type
;
3161 Py_INCREF(&CFMutableDataRef_Type
);
3162 if (PyDict_SetItemString(d
, "CFMutableDataRefType", (PyObject
*)&CFMutableDataRef_Type
) != 0)
3163 Py_FatalError("can't initialize CFMutableDataRefType");
3164 CFStringRef_Type
.ob_type
= &PyType_Type
;
3165 Py_INCREF(&CFStringRef_Type
);
3166 if (PyDict_SetItemString(d
, "CFStringRefType", (PyObject
*)&CFStringRef_Type
) != 0)
3167 Py_FatalError("can't initialize CFStringRefType");
3168 CFMutableStringRef_Type
.ob_type
= &PyType_Type
;
3169 Py_INCREF(&CFMutableStringRef_Type
);
3170 if (PyDict_SetItemString(d
, "CFMutableStringRefType", (PyObject
*)&CFMutableStringRef_Type
) != 0)
3171 Py_FatalError("can't initialize CFMutableStringRefType");
3172 CFURLRef_Type
.ob_type
= &PyType_Type
;
3173 Py_INCREF(&CFURLRef_Type
);
3174 if (PyDict_SetItemString(d
, "CFURLRefType", (PyObject
*)&CFURLRef_Type
) != 0)
3175 Py_FatalError("can't initialize CFURLRefType");
3178 /* ========================= End module CF ========================== */