This commit was manufactured by cvs2svn to create tag 'r221c2'.
[python/dscho.git] / Mac / Modules / cf / _CFmodule.c
blobd69fce7ba03124554c9f7aea1c104866a57b1df3
2 /* =========================== Module _CF =========================== */
4 #include "Python.h"
8 #ifdef _WIN32
9 #include "pywintoolbox.h"
10 #else
11 #include "macglue.h"
12 #include "pymactoolbox.h"
13 #endif
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"); \
19 return NULL; \
20 }} while(0)
23 #ifdef WITHOUT_FRAMEWORKS
24 #include <CFBase.h>
25 #include <CFArray.h>
26 #include <CFData.h>
27 #include <CFDictionary.h>
28 #include <CFString.h>
29 #include <CFURL.h>
30 #else
31 #include <CoreServices/CoreServices.h>
32 #endif
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
86 #endif
89 ** Parse/generate CFRange records
91 PyObject *CFRange_New(CFRange *itself)
94 return Py_BuildValue("ll", (long)itself->location, (long)itself->length);
97 int
98 CFRange_Convert(PyObject *v, CFRange *p_itself)
100 long location, length;
102 if( !PyArg_ParseTuple(v, "ll", &location, &length) )
103 return 0;
104 p_itself->location = (CFIndex)location;
105 p_itself->length = (CFIndex)length;
106 return 1;
109 /* Optional CFURL argument or None (passed as NULL) */
111 OptionalCFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself)
113 if ( v == Py_None ) {
114 p_itself = NULL;
115 return 1;
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 {
130 PyObject_HEAD
131 CFTypeRef ob_itself;
132 void (*ob_freeit)(CFTypeRef ptr);
133 } CFTypeRefObject;
135 PyObject *CFTypeRefObj_New(CFTypeRef itself)
137 CFTypeRefObject *it;
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");
154 return 0;
156 *p_itself = ((CFTypeRefObject *)v)->ob_itself;
157 return 1;
160 static void CFTypeRefObj_dealloc(CFTypeRefObject *self)
162 if (self->ob_freeit && self->ob_itself)
164 self->ob_freeit((CFTypeRef)self->ob_itself);
166 PyMem_DEL(self);
169 static PyObject *CFTypeRefObj_CFGetTypeID(CFTypeRefObject *_self, PyObject *_args)
171 PyObject *_res = NULL;
172 CFTypeID _rv;
173 #ifndef CFGetTypeID
174 PyMac_PRECHECK(CFGetTypeID);
175 #endif
176 if (!PyArg_ParseTuple(_args, ""))
177 return NULL;
178 _rv = CFGetTypeID(_self->ob_itself);
179 _res = Py_BuildValue("l",
180 _rv);
181 return _res;
184 static PyObject *CFTypeRefObj_CFRetain(CFTypeRefObject *_self, PyObject *_args)
186 PyObject *_res = NULL;
187 CFTypeRef _rv;
188 #ifndef CFRetain
189 PyMac_PRECHECK(CFRetain);
190 #endif
191 if (!PyArg_ParseTuple(_args, ""))
192 return NULL;
193 _rv = CFRetain(_self->ob_itself);
194 _res = Py_BuildValue("O&",
195 CFTypeRefObj_New, _rv);
196 return _res;
199 static PyObject *CFTypeRefObj_CFRelease(CFTypeRefObject *_self, PyObject *_args)
201 PyObject *_res = NULL;
202 #ifndef CFRelease
203 PyMac_PRECHECK(CFRelease);
204 #endif
205 if (!PyArg_ParseTuple(_args, ""))
206 return NULL;
207 CFRelease(_self->ob_itself);
208 Py_INCREF(Py_None);
209 _res = Py_None;
210 return _res;
213 static PyObject *CFTypeRefObj_CFGetRetainCount(CFTypeRefObject *_self, PyObject *_args)
215 PyObject *_res = NULL;
216 CFIndex _rv;
217 #ifndef CFGetRetainCount
218 PyMac_PRECHECK(CFGetRetainCount);
219 #endif
220 if (!PyArg_ParseTuple(_args, ""))
221 return NULL;
222 _rv = CFGetRetainCount(_self->ob_itself);
223 _res = Py_BuildValue("l",
224 _rv);
225 return _res;
228 static PyObject *CFTypeRefObj_CFEqual(CFTypeRefObject *_self, PyObject *_args)
230 PyObject *_res = NULL;
231 Boolean _rv;
232 CFTypeRef cf2;
233 #ifndef CFEqual
234 PyMac_PRECHECK(CFEqual);
235 #endif
236 if (!PyArg_ParseTuple(_args, "O&",
237 CFTypeRefObj_Convert, &cf2))
238 return NULL;
239 _rv = CFEqual(_self->ob_itself,
240 cf2);
241 _res = Py_BuildValue("l",
242 _rv);
243 return _res;
246 static PyObject *CFTypeRefObj_CFHash(CFTypeRefObject *_self, PyObject *_args)
248 PyObject *_res = NULL;
249 CFHashCode _rv;
250 #ifndef CFHash
251 PyMac_PRECHECK(CFHash);
252 #endif
253 if (!PyArg_ParseTuple(_args, ""))
254 return NULL;
255 _rv = CFHash(_self->ob_itself);
256 _res = Py_BuildValue("l",
257 _rv);
258 return _res;
261 static PyObject *CFTypeRefObj_CFCopyDescription(CFTypeRefObject *_self, PyObject *_args)
263 PyObject *_res = NULL;
264 CFStringRef _rv;
265 #ifndef CFCopyDescription
266 PyMac_PRECHECK(CFCopyDescription);
267 #endif
268 if (!PyArg_ParseTuple(_args, ""))
269 return NULL;
270 _rv = CFCopyDescription(_self->ob_itself);
271 _res = Py_BuildValue("O&",
272 CFStringRefObj_New, _rv);
273 return _res;
276 static PyObject *CFTypeRefObj_CFShow(CFTypeRefObject *_self, PyObject *_args)
278 PyObject *_res = NULL;
279 #ifndef CFShow
280 PyMac_PRECHECK(CFShow);
281 #endif
282 if (!PyArg_ParseTuple(_args, ""))
283 return NULL;
284 CFShow(_self->ob_itself);
285 Py_INCREF(Py_None);
286 _res = Py_None;
287 return _res;
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,
296 "() -> None"},
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,
306 "() -> None"},
307 {NULL, NULL, 0}
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;
324 return 0;
327 static PyObject * CFTypeRefObj_repr(CFTypeRefObject *self)
329 char buf[100];
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)
342 0, /*ob_size*/
343 "_CF.CFTypeRef", /*tp_name*/
344 sizeof(CFTypeRefObject), /*tp_basicsize*/
345 0, /*tp_itemsize*/
346 /* methods */
347 (destructor) CFTypeRefObj_dealloc, /*tp_dealloc*/
348 0, /*tp_print*/
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 {
369 PyObject_HEAD
370 CFArrayRef ob_itself;
371 void (*ob_freeit)(CFTypeRef ptr);
372 } CFArrayRefObject;
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");
393 return 0;
395 *p_itself = ((CFArrayRefObject *)v)->ob_itself;
396 return 1;
399 static void CFArrayRefObj_dealloc(CFArrayRefObject *self)
401 if (self->ob_freeit && self->ob_itself)
403 self->ob_freeit((CFTypeRef)self->ob_itself);
405 PyMem_DEL(self);
408 static PyObject *CFArrayRefObj_CFArrayCreateCopy(CFArrayRefObject *_self, PyObject *_args)
410 PyObject *_res = NULL;
411 CFArrayRef _rv;
412 if (!PyArg_ParseTuple(_args, ""))
413 return NULL;
414 _rv = CFArrayCreateCopy((CFAllocatorRef)NULL,
415 _self->ob_itself);
416 _res = Py_BuildValue("O&",
417 CFArrayRefObj_New, _rv);
418 return _res;
421 static PyObject *CFArrayRefObj_CFArrayGetCount(CFArrayRefObject *_self, PyObject *_args)
423 PyObject *_res = NULL;
424 CFIndex _rv;
425 #ifndef CFArrayGetCount
426 PyMac_PRECHECK(CFArrayGetCount);
427 #endif
428 if (!PyArg_ParseTuple(_args, ""))
429 return NULL;
430 _rv = CFArrayGetCount(_self->ob_itself);
431 _res = Py_BuildValue("l",
432 _rv);
433 return _res;
436 static PyObject *CFArrayRefObj_CFStringCreateByCombiningStrings(CFArrayRefObject *_self, PyObject *_args)
438 PyObject *_res = NULL;
439 CFStringRef _rv;
440 CFStringRef separatorString;
441 if (!PyArg_ParseTuple(_args, "O&",
442 CFStringRefObj_Convert, &separatorString))
443 return NULL;
444 _rv = CFStringCreateByCombiningStrings((CFAllocatorRef)NULL,
445 _self->ob_itself,
446 separatorString);
447 _res = Py_BuildValue("O&",
448 CFStringRefObj_New, _rv);
449 return _res;
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)"},
459 {NULL, NULL, 0}
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;
476 return 0;
479 static PyObject * CFArrayRefObj_repr(CFArrayRefObject *self)
481 char buf[100];
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)
494 0, /*ob_size*/
495 "_CF.CFArrayRef", /*tp_name*/
496 sizeof(CFArrayRefObject), /*tp_basicsize*/
497 0, /*tp_itemsize*/
498 /* methods */
499 (destructor) CFArrayRefObj_dealloc, /*tp_dealloc*/
500 0, /*tp_print*/
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 {
521 PyObject_HEAD
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");
545 return 0;
547 *p_itself = ((CFMutableArrayRefObject *)v)->ob_itself;
548 return 1;
551 static void CFMutableArrayRefObj_dealloc(CFMutableArrayRefObject *self)
553 if (self->ob_freeit && self->ob_itself)
555 self->ob_freeit((CFTypeRef)self->ob_itself);
557 PyMem_DEL(self);
560 static PyObject *CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRefObject *_self, PyObject *_args)
562 PyObject *_res = NULL;
563 CFIndex idx;
564 #ifndef CFArrayRemoveValueAtIndex
565 PyMac_PRECHECK(CFArrayRemoveValueAtIndex);
566 #endif
567 if (!PyArg_ParseTuple(_args, "l",
568 &idx))
569 return NULL;
570 CFArrayRemoveValueAtIndex(_self->ob_itself,
571 idx);
572 Py_INCREF(Py_None);
573 _res = Py_None;
574 return _res;
577 static PyObject *CFMutableArrayRefObj_CFArrayRemoveAllValues(CFMutableArrayRefObject *_self, PyObject *_args)
579 PyObject *_res = NULL;
580 #ifndef CFArrayRemoveAllValues
581 PyMac_PRECHECK(CFArrayRemoveAllValues);
582 #endif
583 if (!PyArg_ParseTuple(_args, ""))
584 return NULL;
585 CFArrayRemoveAllValues(_self->ob_itself);
586 Py_INCREF(Py_None);
587 _res = Py_None;
588 return _res;
591 static PyObject *CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices(CFMutableArrayRefObject *_self, PyObject *_args)
593 PyObject *_res = NULL;
594 CFIndex idx1;
595 CFIndex idx2;
596 #ifndef CFArrayExchangeValuesAtIndices
597 PyMac_PRECHECK(CFArrayExchangeValuesAtIndices);
598 #endif
599 if (!PyArg_ParseTuple(_args, "ll",
600 &idx1,
601 &idx2))
602 return NULL;
603 CFArrayExchangeValuesAtIndices(_self->ob_itself,
604 idx1,
605 idx2);
606 Py_INCREF(Py_None);
607 _res = Py_None;
608 return _res;
611 static PyObject *CFMutableArrayRefObj_CFArrayAppendArray(CFMutableArrayRefObject *_self, PyObject *_args)
613 PyObject *_res = NULL;
614 CFArrayRef otherArray;
615 CFRange otherRange;
616 #ifndef CFArrayAppendArray
617 PyMac_PRECHECK(CFArrayAppendArray);
618 #endif
619 if (!PyArg_ParseTuple(_args, "O&O&",
620 CFArrayRefObj_Convert, &otherArray,
621 CFRange_Convert, &otherRange))
622 return NULL;
623 CFArrayAppendArray(_self->ob_itself,
624 otherArray,
625 otherRange);
626 Py_INCREF(Py_None);
627 _res = Py_None;
628 return _res;
631 static PyMethodDef CFMutableArrayRefObj_methods[] = {
632 {"CFArrayRemoveValueAtIndex", (PyCFunction)CFMutableArrayRefObj_CFArrayRemoveValueAtIndex, 1,
633 "(CFIndex idx) -> None"},
634 {"CFArrayRemoveAllValues", (PyCFunction)CFMutableArrayRefObj_CFArrayRemoveAllValues, 1,
635 "() -> None"},
636 {"CFArrayExchangeValuesAtIndices", (PyCFunction)CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices, 1,
637 "(CFIndex idx1, CFIndex idx2) -> None"},
638 {"CFArrayAppendArray", (PyCFunction)CFMutableArrayRefObj_CFArrayAppendArray, 1,
639 "(CFArrayRef otherArray, CFRange otherRange) -> None"},
640 {NULL, NULL, 0}
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;
657 return 0;
660 static PyObject * CFMutableArrayRefObj_repr(CFMutableArrayRefObject *self)
662 char buf[100];
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)
675 0, /*ob_size*/
676 "_CF.CFMutableArrayRef", /*tp_name*/
677 sizeof(CFMutableArrayRefObject), /*tp_basicsize*/
678 0, /*tp_itemsize*/
679 /* methods */
680 (destructor) CFMutableArrayRefObj_dealloc, /*tp_dealloc*/
681 0, /*tp_print*/
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 {
702 PyObject_HEAD
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");
726 return 0;
728 *p_itself = ((CFDictionaryRefObject *)v)->ob_itself;
729 return 1;
732 static void CFDictionaryRefObj_dealloc(CFDictionaryRefObject *self)
734 if (self->ob_freeit && self->ob_itself)
736 self->ob_freeit((CFTypeRef)self->ob_itself);
738 PyMem_DEL(self);
741 static PyObject *CFDictionaryRefObj_CFDictionaryCreateCopy(CFDictionaryRefObject *_self, PyObject *_args)
743 PyObject *_res = NULL;
744 CFDictionaryRef _rv;
745 if (!PyArg_ParseTuple(_args, ""))
746 return NULL;
747 _rv = CFDictionaryCreateCopy((CFAllocatorRef)NULL,
748 _self->ob_itself);
749 _res = Py_BuildValue("O&",
750 CFDictionaryRefObj_New, _rv);
751 return _res;
754 static PyObject *CFDictionaryRefObj_CFDictionaryGetCount(CFDictionaryRefObject *_self, PyObject *_args)
756 PyObject *_res = NULL;
757 CFIndex _rv;
758 #ifndef CFDictionaryGetCount
759 PyMac_PRECHECK(CFDictionaryGetCount);
760 #endif
761 if (!PyArg_ParseTuple(_args, ""))
762 return NULL;
763 _rv = CFDictionaryGetCount(_self->ob_itself);
764 _res = Py_BuildValue("l",
765 _rv);
766 return _res;
769 static PyMethodDef CFDictionaryRefObj_methods[] = {
770 {"CFDictionaryCreateCopy", (PyCFunction)CFDictionaryRefObj_CFDictionaryCreateCopy, 1,
771 "() -> (CFDictionaryRef _rv)"},
772 {"CFDictionaryGetCount", (PyCFunction)CFDictionaryRefObj_CFDictionaryGetCount, 1,
773 "() -> (CFIndex _rv)"},
774 {NULL, NULL, 0}
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;
791 return 0;
794 static PyObject * CFDictionaryRefObj_repr(CFDictionaryRefObject *self)
796 char buf[100];
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)
809 0, /*ob_size*/
810 "_CF.CFDictionaryRef", /*tp_name*/
811 sizeof(CFDictionaryRefObject), /*tp_basicsize*/
812 0, /*tp_itemsize*/
813 /* methods */
814 (destructor) CFDictionaryRefObj_dealloc, /*tp_dealloc*/
815 0, /*tp_print*/
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 {
836 PyObject_HEAD
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");
860 return 0;
862 *p_itself = ((CFMutableDictionaryRefObject *)v)->ob_itself;
863 return 1;
866 static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject *self)
868 if (self->ob_freeit && self->ob_itself)
870 self->ob_freeit((CFTypeRef)self->ob_itself);
872 PyMem_DEL(self);
875 static PyObject *CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject *_self, PyObject *_args)
877 PyObject *_res = NULL;
878 #ifndef CFDictionaryRemoveAllValues
879 PyMac_PRECHECK(CFDictionaryRemoveAllValues);
880 #endif
881 if (!PyArg_ParseTuple(_args, ""))
882 return NULL;
883 CFDictionaryRemoveAllValues(_self->ob_itself);
884 Py_INCREF(Py_None);
885 _res = Py_None;
886 return _res;
889 static PyMethodDef CFMutableDictionaryRefObj_methods[] = {
890 {"CFDictionaryRemoveAllValues", (PyCFunction)CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues, 1,
891 "() -> None"},
892 {NULL, NULL, 0}
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;
909 return 0;
912 static PyObject * CFMutableDictionaryRefObj_repr(CFMutableDictionaryRefObject *self)
914 char buf[100];
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)
927 0, /*ob_size*/
928 "_CF.CFMutableDictionaryRef", /*tp_name*/
929 sizeof(CFMutableDictionaryRefObject), /*tp_basicsize*/
930 0, /*tp_itemsize*/
931 /* methods */
932 (destructor) CFMutableDictionaryRefObj_dealloc, /*tp_dealloc*/
933 0, /*tp_print*/
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 {
954 PyObject_HEAD
955 CFDataRef ob_itself;
956 void (*ob_freeit)(CFTypeRef ptr);
957 } CFDataRefObject;
959 PyObject *CFDataRefObj_New(CFDataRef itself)
961 CFDataRefObject *it;
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");
978 return 0;
980 *p_itself = ((CFDataRefObject *)v)->ob_itself;
981 return 1;
984 static void CFDataRefObj_dealloc(CFDataRefObject *self)
986 if (self->ob_freeit && self->ob_itself)
988 self->ob_freeit((CFTypeRef)self->ob_itself);
990 PyMem_DEL(self);
993 static PyObject *CFDataRefObj_CFDataCreateCopy(CFDataRefObject *_self, PyObject *_args)
995 PyObject *_res = NULL;
996 CFDataRef _rv;
997 if (!PyArg_ParseTuple(_args, ""))
998 return NULL;
999 _rv = CFDataCreateCopy((CFAllocatorRef)NULL,
1000 _self->ob_itself);
1001 _res = Py_BuildValue("O&",
1002 CFDataRefObj_New, _rv);
1003 return _res;
1006 static PyObject *CFDataRefObj_CFDataGetLength(CFDataRefObject *_self, PyObject *_args)
1008 PyObject *_res = NULL;
1009 CFIndex _rv;
1010 #ifndef CFDataGetLength
1011 PyMac_PRECHECK(CFDataGetLength);
1012 #endif
1013 if (!PyArg_ParseTuple(_args, ""))
1014 return NULL;
1015 _rv = CFDataGetLength(_self->ob_itself);
1016 _res = Py_BuildValue("l",
1017 _rv);
1018 return _res;
1021 static PyObject *CFDataRefObj_CFStringCreateFromExternalRepresentation(CFDataRefObject *_self, PyObject *_args)
1023 PyObject *_res = NULL;
1024 CFStringRef _rv;
1025 CFStringEncoding encoding;
1026 if (!PyArg_ParseTuple(_args, "l",
1027 &encoding))
1028 return NULL;
1029 _rv = CFStringCreateFromExternalRepresentation((CFAllocatorRef)NULL,
1030 _self->ob_itself,
1031 encoding);
1032 _res = Py_BuildValue("O&",
1033 CFStringRefObj_New, _rv);
1034 return _res;
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)"},
1044 {NULL, NULL, 0}
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;
1061 return 0;
1064 static PyObject * CFDataRefObj_repr(CFDataRefObject *self)
1066 char buf[100];
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)
1079 0, /*ob_size*/
1080 "_CF.CFDataRef", /*tp_name*/
1081 sizeof(CFDataRefObject), /*tp_basicsize*/
1082 0, /*tp_itemsize*/
1083 /* methods */
1084 (destructor) CFDataRefObj_dealloc, /*tp_dealloc*/
1085 0, /*tp_print*/
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 {
1106 PyObject_HEAD
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");
1130 return 0;
1132 *p_itself = ((CFMutableDataRefObject *)v)->ob_itself;
1133 return 1;
1136 static void CFMutableDataRefObj_dealloc(CFMutableDataRefObject *self)
1138 if (self->ob_freeit && self->ob_itself)
1140 self->ob_freeit((CFTypeRef)self->ob_itself);
1142 PyMem_DEL(self);
1145 static PyObject *CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject *_self, PyObject *_args)
1147 PyObject *_res = NULL;
1148 CFIndex length;
1149 #ifndef CFDataSetLength
1150 PyMac_PRECHECK(CFDataSetLength);
1151 #endif
1152 if (!PyArg_ParseTuple(_args, "l",
1153 &length))
1154 return NULL;
1155 CFDataSetLength(_self->ob_itself,
1156 length);
1157 Py_INCREF(Py_None);
1158 _res = Py_None;
1159 return _res;
1162 static PyObject *CFMutableDataRefObj_CFDataIncreaseLength(CFMutableDataRefObject *_self, PyObject *_args)
1164 PyObject *_res = NULL;
1165 CFIndex extraLength;
1166 #ifndef CFDataIncreaseLength
1167 PyMac_PRECHECK(CFDataIncreaseLength);
1168 #endif
1169 if (!PyArg_ParseTuple(_args, "l",
1170 &extraLength))
1171 return NULL;
1172 CFDataIncreaseLength(_self->ob_itself,
1173 extraLength);
1174 Py_INCREF(Py_None);
1175 _res = Py_None;
1176 return _res;
1179 static PyObject *CFMutableDataRefObj_CFDataAppendBytes(CFMutableDataRefObject *_self, PyObject *_args)
1181 PyObject *_res = NULL;
1182 unsigned char *bytes__in__;
1183 long bytes__len__;
1184 int bytes__in_len__;
1185 #ifndef CFDataAppendBytes
1186 PyMac_PRECHECK(CFDataAppendBytes);
1187 #endif
1188 if (!PyArg_ParseTuple(_args, "s#",
1189 &bytes__in__, &bytes__in_len__))
1190 return NULL;
1191 bytes__len__ = bytes__in_len__;
1192 CFDataAppendBytes(_self->ob_itself,
1193 bytes__in__, bytes__len__);
1194 Py_INCREF(Py_None);
1195 _res = Py_None;
1196 return _res;
1199 static PyObject *CFMutableDataRefObj_CFDataReplaceBytes(CFMutableDataRefObject *_self, PyObject *_args)
1201 PyObject *_res = NULL;
1202 CFRange range;
1203 unsigned char *newBytes__in__;
1204 long newBytes__len__;
1205 int newBytes__in_len__;
1206 #ifndef CFDataReplaceBytes
1207 PyMac_PRECHECK(CFDataReplaceBytes);
1208 #endif
1209 if (!PyArg_ParseTuple(_args, "O&s#",
1210 CFRange_Convert, &range,
1211 &newBytes__in__, &newBytes__in_len__))
1212 return NULL;
1213 newBytes__len__ = newBytes__in_len__;
1214 CFDataReplaceBytes(_self->ob_itself,
1215 range,
1216 newBytes__in__, newBytes__len__);
1217 Py_INCREF(Py_None);
1218 _res = Py_None;
1219 return _res;
1222 static PyObject *CFMutableDataRefObj_CFDataDeleteBytes(CFMutableDataRefObject *_self, PyObject *_args)
1224 PyObject *_res = NULL;
1225 CFRange range;
1226 #ifndef CFDataDeleteBytes
1227 PyMac_PRECHECK(CFDataDeleteBytes);
1228 #endif
1229 if (!PyArg_ParseTuple(_args, "O&",
1230 CFRange_Convert, &range))
1231 return NULL;
1232 CFDataDeleteBytes(_self->ob_itself,
1233 range);
1234 Py_INCREF(Py_None);
1235 _res = Py_None;
1236 return _res;
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"},
1250 {NULL, NULL, 0}
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;
1267 return 0;
1270 static PyObject * CFMutableDataRefObj_repr(CFMutableDataRefObject *self)
1272 char buf[100];
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)
1285 0, /*ob_size*/
1286 "_CF.CFMutableDataRef", /*tp_name*/
1287 sizeof(CFMutableDataRefObject), /*tp_basicsize*/
1288 0, /*tp_itemsize*/
1289 /* methods */
1290 (destructor) CFMutableDataRefObj_dealloc, /*tp_dealloc*/
1291 0, /*tp_print*/
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 {
1312 PyObject_HEAD
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);
1334 return 1;
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);
1342 return 1;
1346 if (!CFStringRefObj_Check(v))
1348 PyErr_SetString(PyExc_TypeError, "CFStringRef required");
1349 return 0;
1351 *p_itself = ((CFStringRefObject *)v)->ob_itself;
1352 return 1;
1355 static void CFStringRefObj_dealloc(CFStringRefObject *self)
1357 if (self->ob_freeit && self->ob_itself)
1359 self->ob_freeit((CFTypeRef)self->ob_itself);
1361 PyMem_DEL(self);
1364 static PyObject *CFStringRefObj_CFStringCreateWithSubstring(CFStringRefObject *_self, PyObject *_args)
1366 PyObject *_res = NULL;
1367 CFStringRef _rv;
1368 CFRange range;
1369 if (!PyArg_ParseTuple(_args, "O&",
1370 CFRange_Convert, &range))
1371 return NULL;
1372 _rv = CFStringCreateWithSubstring((CFAllocatorRef)NULL,
1373 _self->ob_itself,
1374 range);
1375 _res = Py_BuildValue("O&",
1376 CFStringRefObj_New, _rv);
1377 return _res;
1380 static PyObject *CFStringRefObj_CFStringCreateCopy(CFStringRefObject *_self, PyObject *_args)
1382 PyObject *_res = NULL;
1383 CFStringRef _rv;
1384 if (!PyArg_ParseTuple(_args, ""))
1385 return NULL;
1386 _rv = CFStringCreateCopy((CFAllocatorRef)NULL,
1387 _self->ob_itself);
1388 _res = Py_BuildValue("O&",
1389 CFStringRefObj_New, _rv);
1390 return _res;
1393 static PyObject *CFStringRefObj_CFStringGetLength(CFStringRefObject *_self, PyObject *_args)
1395 PyObject *_res = NULL;
1396 CFIndex _rv;
1397 #ifndef CFStringGetLength
1398 PyMac_PRECHECK(CFStringGetLength);
1399 #endif
1400 if (!PyArg_ParseTuple(_args, ""))
1401 return NULL;
1402 _rv = CFStringGetLength(_self->ob_itself);
1403 _res = Py_BuildValue("l",
1404 _rv);
1405 return _res;
1408 static PyObject *CFStringRefObj_CFStringGetBytes(CFStringRefObject *_self, PyObject *_args)
1410 PyObject *_res = NULL;
1411 CFIndex _rv;
1412 CFRange range;
1413 CFStringEncoding encoding;
1414 UInt8 lossByte;
1415 Boolean isExternalRepresentation;
1416 UInt8 buffer;
1417 CFIndex maxBufLen;
1418 CFIndex usedBufLen;
1419 #ifndef CFStringGetBytes
1420 PyMac_PRECHECK(CFStringGetBytes);
1421 #endif
1422 if (!PyArg_ParseTuple(_args, "O&lbll",
1423 CFRange_Convert, &range,
1424 &encoding,
1425 &lossByte,
1426 &isExternalRepresentation,
1427 &maxBufLen))
1428 return NULL;
1429 _rv = CFStringGetBytes(_self->ob_itself,
1430 range,
1431 encoding,
1432 lossByte,
1433 isExternalRepresentation,
1434 &buffer,
1435 maxBufLen,
1436 &usedBufLen);
1437 _res = Py_BuildValue("lbl",
1438 _rv,
1439 buffer,
1440 usedBufLen);
1441 return _res;
1444 static PyObject *CFStringRefObj_CFStringCreateExternalRepresentation(CFStringRefObject *_self, PyObject *_args)
1446 PyObject *_res = NULL;
1447 CFDataRef _rv;
1448 CFStringEncoding encoding;
1449 UInt8 lossByte;
1450 if (!PyArg_ParseTuple(_args, "lb",
1451 &encoding,
1452 &lossByte))
1453 return NULL;
1454 _rv = CFStringCreateExternalRepresentation((CFAllocatorRef)NULL,
1455 _self->ob_itself,
1456 encoding,
1457 lossByte);
1458 _res = Py_BuildValue("O&",
1459 CFDataRefObj_New, _rv);
1460 return _res;
1463 static PyObject *CFStringRefObj_CFStringGetSmallestEncoding(CFStringRefObject *_self, PyObject *_args)
1465 PyObject *_res = NULL;
1466 CFStringEncoding _rv;
1467 #ifndef CFStringGetSmallestEncoding
1468 PyMac_PRECHECK(CFStringGetSmallestEncoding);
1469 #endif
1470 if (!PyArg_ParseTuple(_args, ""))
1471 return NULL;
1472 _rv = CFStringGetSmallestEncoding(_self->ob_itself);
1473 _res = Py_BuildValue("l",
1474 _rv);
1475 return _res;
1478 static PyObject *CFStringRefObj_CFStringGetFastestEncoding(CFStringRefObject *_self, PyObject *_args)
1480 PyObject *_res = NULL;
1481 CFStringEncoding _rv;
1482 #ifndef CFStringGetFastestEncoding
1483 PyMac_PRECHECK(CFStringGetFastestEncoding);
1484 #endif
1485 if (!PyArg_ParseTuple(_args, ""))
1486 return NULL;
1487 _rv = CFStringGetFastestEncoding(_self->ob_itself);
1488 _res = Py_BuildValue("l",
1489 _rv);
1490 return _res;
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);
1502 #endif
1503 if (!PyArg_ParseTuple(_args, "O&O&l",
1504 CFStringRefObj_Convert, &theString2,
1505 CFRange_Convert, &rangeToCompare,
1506 &compareOptions))
1507 return NULL;
1508 _rv = CFStringCompareWithOptions(_self->ob_itself,
1509 theString2,
1510 rangeToCompare,
1511 compareOptions);
1512 _res = Py_BuildValue("l",
1513 _rv);
1514 return _res;
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);
1525 #endif
1526 if (!PyArg_ParseTuple(_args, "O&l",
1527 CFStringRefObj_Convert, &theString2,
1528 &compareOptions))
1529 return NULL;
1530 _rv = CFStringCompare(_self->ob_itself,
1531 theString2,
1532 compareOptions);
1533 _res = Py_BuildValue("l",
1534 _rv);
1535 return _res;
1538 static PyObject *CFStringRefObj_CFStringFindWithOptions(CFStringRefObject *_self, PyObject *_args)
1540 PyObject *_res = NULL;
1541 Boolean _rv;
1542 CFStringRef stringToFind;
1543 CFRange rangeToSearch;
1544 CFOptionFlags searchOptions;
1545 CFRange result;
1546 #ifndef CFStringFindWithOptions
1547 PyMac_PRECHECK(CFStringFindWithOptions);
1548 #endif
1549 if (!PyArg_ParseTuple(_args, "O&O&l",
1550 CFStringRefObj_Convert, &stringToFind,
1551 CFRange_Convert, &rangeToSearch,
1552 &searchOptions))
1553 return NULL;
1554 _rv = CFStringFindWithOptions(_self->ob_itself,
1555 stringToFind,
1556 rangeToSearch,
1557 searchOptions,
1558 &result);
1559 _res = Py_BuildValue("lO&",
1560 _rv,
1561 CFRange_New, result);
1562 return _res;
1565 static PyObject *CFStringRefObj_CFStringCreateArrayWithFindResults(CFStringRefObject *_self, PyObject *_args)
1567 PyObject *_res = NULL;
1568 CFArrayRef _rv;
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,
1575 &compareOptions))
1576 return NULL;
1577 _rv = CFStringCreateArrayWithFindResults((CFAllocatorRef)NULL,
1578 _self->ob_itself,
1579 stringToFind,
1580 rangeToSearch,
1581 compareOptions);
1582 _res = Py_BuildValue("O&",
1583 CFArrayRefObj_New, _rv);
1584 return _res;
1587 static PyObject *CFStringRefObj_CFStringFind(CFStringRefObject *_self, PyObject *_args)
1589 PyObject *_res = NULL;
1590 CFRange _rv;
1591 CFStringRef stringToFind;
1592 CFOptionFlags compareOptions;
1593 #ifndef CFStringFind
1594 PyMac_PRECHECK(CFStringFind);
1595 #endif
1596 if (!PyArg_ParseTuple(_args, "O&l",
1597 CFStringRefObj_Convert, &stringToFind,
1598 &compareOptions))
1599 return NULL;
1600 _rv = CFStringFind(_self->ob_itself,
1601 stringToFind,
1602 compareOptions);
1603 _res = Py_BuildValue("O&",
1604 CFRange_New, _rv);
1605 return _res;
1608 static PyObject *CFStringRefObj_CFStringHasPrefix(CFStringRefObject *_self, PyObject *_args)
1610 PyObject *_res = NULL;
1611 Boolean _rv;
1612 CFStringRef prefix;
1613 #ifndef CFStringHasPrefix
1614 PyMac_PRECHECK(CFStringHasPrefix);
1615 #endif
1616 if (!PyArg_ParseTuple(_args, "O&",
1617 CFStringRefObj_Convert, &prefix))
1618 return NULL;
1619 _rv = CFStringHasPrefix(_self->ob_itself,
1620 prefix);
1621 _res = Py_BuildValue("l",
1622 _rv);
1623 return _res;
1626 static PyObject *CFStringRefObj_CFStringHasSuffix(CFStringRefObject *_self, PyObject *_args)
1628 PyObject *_res = NULL;
1629 Boolean _rv;
1630 CFStringRef suffix;
1631 #ifndef CFStringHasSuffix
1632 PyMac_PRECHECK(CFStringHasSuffix);
1633 #endif
1634 if (!PyArg_ParseTuple(_args, "O&",
1635 CFStringRefObj_Convert, &suffix))
1636 return NULL;
1637 _rv = CFStringHasSuffix(_self->ob_itself,
1638 suffix);
1639 _res = Py_BuildValue("l",
1640 _rv);
1641 return _res;
1644 static PyObject *CFStringRefObj_CFStringGetLineBounds(CFStringRefObject *_self, PyObject *_args)
1646 PyObject *_res = NULL;
1647 CFRange range;
1648 CFIndex lineBeginIndex;
1649 CFIndex lineEndIndex;
1650 CFIndex contentsEndIndex;
1651 #ifndef CFStringGetLineBounds
1652 PyMac_PRECHECK(CFStringGetLineBounds);
1653 #endif
1654 if (!PyArg_ParseTuple(_args, "O&",
1655 CFRange_Convert, &range))
1656 return NULL;
1657 CFStringGetLineBounds(_self->ob_itself,
1658 range,
1659 &lineBeginIndex,
1660 &lineEndIndex,
1661 &contentsEndIndex);
1662 _res = Py_BuildValue("lll",
1663 lineBeginIndex,
1664 lineEndIndex,
1665 contentsEndIndex);
1666 return _res;
1669 static PyObject *CFStringRefObj_CFStringCreateArrayBySeparatingStrings(CFStringRefObject *_self, PyObject *_args)
1671 PyObject *_res = NULL;
1672 CFArrayRef _rv;
1673 CFStringRef separatorString;
1674 if (!PyArg_ParseTuple(_args, "O&",
1675 CFStringRefObj_Convert, &separatorString))
1676 return NULL;
1677 _rv = CFStringCreateArrayBySeparatingStrings((CFAllocatorRef)NULL,
1678 _self->ob_itself,
1679 separatorString);
1680 _res = Py_BuildValue("O&",
1681 CFArrayRefObj_New, _rv);
1682 return _res;
1685 static PyObject *CFStringRefObj_CFStringGetIntValue(CFStringRefObject *_self, PyObject *_args)
1687 PyObject *_res = NULL;
1688 SInt32 _rv;
1689 #ifndef CFStringGetIntValue
1690 PyMac_PRECHECK(CFStringGetIntValue);
1691 #endif
1692 if (!PyArg_ParseTuple(_args, ""))
1693 return NULL;
1694 _rv = CFStringGetIntValue(_self->ob_itself);
1695 _res = Py_BuildValue("l",
1696 _rv);
1697 return _res;
1700 static PyObject *CFStringRefObj_CFStringGetDoubleValue(CFStringRefObject *_self, PyObject *_args)
1702 PyObject *_res = NULL;
1703 double _rv;
1704 #ifndef CFStringGetDoubleValue
1705 PyMac_PRECHECK(CFStringGetDoubleValue);
1706 #endif
1707 if (!PyArg_ParseTuple(_args, ""))
1708 return NULL;
1709 _rv = CFStringGetDoubleValue(_self->ob_itself);
1710 _res = Py_BuildValue("d",
1711 _rv);
1712 return _res;
1715 static PyObject *CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStringRefObject *_self, PyObject *_args)
1717 PyObject *_res = NULL;
1718 CFStringEncoding _rv;
1719 #ifndef CFStringConvertIANACharSetNameToEncoding
1720 PyMac_PRECHECK(CFStringConvertIANACharSetNameToEncoding);
1721 #endif
1722 if (!PyArg_ParseTuple(_args, ""))
1723 return NULL;
1724 _rv = CFStringConvertIANACharSetNameToEncoding(_self->ob_itself);
1725 _res = Py_BuildValue("l",
1726 _rv);
1727 return _res;
1730 static PyObject *CFStringRefObj_CFShowStr(CFStringRefObject *_self, PyObject *_args)
1732 PyObject *_res = NULL;
1733 #ifndef CFShowStr
1734 PyMac_PRECHECK(CFShowStr);
1735 #endif
1736 if (!PyArg_ParseTuple(_args, ""))
1737 return NULL;
1738 CFShowStr(_self->ob_itself);
1739 Py_INCREF(Py_None);
1740 _res = Py_None;
1741 return _res;
1744 static PyObject *CFStringRefObj_CFURLCreateWithString(CFStringRefObject *_self, PyObject *_args)
1746 PyObject *_res = NULL;
1747 CFURLRef _rv;
1748 CFURLRef baseURL;
1749 if (!PyArg_ParseTuple(_args, "O&",
1750 OptionalCFURLRefObj_Convert, &baseURL))
1751 return NULL;
1752 _rv = CFURLCreateWithString((CFAllocatorRef)NULL,
1753 _self->ob_itself,
1754 baseURL);
1755 _res = Py_BuildValue("O&",
1756 CFURLRefObj_New, _rv);
1757 return _res;
1760 static PyObject *CFStringRefObj_CFURLCreateWithFileSystemPath(CFStringRefObject *_self, PyObject *_args)
1762 PyObject *_res = NULL;
1763 CFURLRef _rv;
1764 CFURLPathStyle pathStyle;
1765 Boolean isDirectory;
1766 if (!PyArg_ParseTuple(_args, "ll",
1767 &pathStyle,
1768 &isDirectory))
1769 return NULL;
1770 _rv = CFURLCreateWithFileSystemPath((CFAllocatorRef)NULL,
1771 _self->ob_itself,
1772 pathStyle,
1773 isDirectory);
1774 _res = Py_BuildValue("O&",
1775 CFURLRefObj_New, _rv);
1776 return _res;
1779 static PyObject *CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase(CFStringRefObject *_self, PyObject *_args)
1781 PyObject *_res = NULL;
1782 CFURLRef _rv;
1783 CFURLPathStyle pathStyle;
1784 Boolean isDirectory;
1785 CFURLRef baseURL;
1786 if (!PyArg_ParseTuple(_args, "llO&",
1787 &pathStyle,
1788 &isDirectory,
1789 OptionalCFURLRefObj_Convert, &baseURL))
1790 return NULL;
1791 _rv = CFURLCreateWithFileSystemPathRelativeToBase((CFAllocatorRef)NULL,
1792 _self->ob_itself,
1793 pathStyle,
1794 isDirectory,
1795 baseURL);
1796 _res = Py_BuildValue("O&",
1797 CFURLRefObj_New, _rv);
1798 return _res;
1801 static PyObject *CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes(CFStringRefObject *_self, PyObject *_args)
1803 PyObject *_res = NULL;
1804 CFStringRef _rv;
1805 CFStringRef charactersToLeaveEscaped;
1806 if (!PyArg_ParseTuple(_args, "O&",
1807 CFStringRefObj_Convert, &charactersToLeaveEscaped))
1808 return NULL;
1809 _rv = CFURLCreateStringByReplacingPercentEscapes((CFAllocatorRef)NULL,
1810 _self->ob_itself,
1811 charactersToLeaveEscaped);
1812 _res = Py_BuildValue("O&",
1813 CFStringRefObj_New, _rv);
1814 return _res;
1817 static PyObject *CFStringRefObj_CFURLCreateStringByAddingPercentEscapes(CFStringRefObject *_self, PyObject *_args)
1819 PyObject *_res = NULL;
1820 CFStringRef _rv;
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,
1827 &encoding))
1828 return NULL;
1829 _rv = CFURLCreateStringByAddingPercentEscapes((CFAllocatorRef)NULL,
1830 _self->ob_itself,
1831 charactersToLeaveUnescaped,
1832 legalURLCharactersToBeEscaped,
1833 encoding);
1834 _res = Py_BuildValue("O&",
1835 CFStringRefObj_New, _rv);
1836 return _res;
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);
1849 } else {
1850 PyErr_SetString(PyExc_RuntimeError, "CFStringGetCString could not fit the string");
1851 _res = NULL;
1853 free(data);
1854 return _res;
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));
1864 CFRange range;
1866 range.location = 0;
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);
1871 free(data);
1872 return _res;
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,
1916 "() -> None"},
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)"},
1931 {NULL, NULL, 0}
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;
1948 return 0;
1951 static PyObject * CFStringRefObj_repr(CFStringRefObject *self)
1953 char buf[100];
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)
1966 0, /*ob_size*/
1967 "_CF.CFStringRef", /*tp_name*/
1968 sizeof(CFStringRefObject), /*tp_basicsize*/
1969 0, /*tp_itemsize*/
1970 /* methods */
1971 (destructor) CFStringRefObj_dealloc, /*tp_dealloc*/
1972 0, /*tp_print*/
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 {
1993 PyObject_HEAD
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");
2017 return 0;
2019 *p_itself = ((CFMutableStringRefObject *)v)->ob_itself;
2020 return 1;
2023 static void CFMutableStringRefObj_dealloc(CFMutableStringRefObject *self)
2025 if (self->ob_freeit && self->ob_itself)
2027 self->ob_freeit((CFTypeRef)self->ob_itself);
2029 PyMem_DEL(self);
2032 static PyObject *CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject *_self, PyObject *_args)
2034 PyObject *_res = NULL;
2035 CFStringRef appendedString;
2036 #ifndef CFStringAppend
2037 PyMac_PRECHECK(CFStringAppend);
2038 #endif
2039 if (!PyArg_ParseTuple(_args, "O&",
2040 CFStringRefObj_Convert, &appendedString))
2041 return NULL;
2042 CFStringAppend(_self->ob_itself,
2043 appendedString);
2044 Py_INCREF(Py_None);
2045 _res = Py_None;
2046 return _res;
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);
2057 #endif
2058 if (!PyArg_ParseTuple(_args, "u#",
2059 &chars__in__, &chars__in_len__))
2060 return NULL;
2061 chars__len__ = chars__in_len__;
2062 CFStringAppendCharacters(_self->ob_itself,
2063 chars__in__, chars__len__);
2064 Py_INCREF(Py_None);
2065 _res = Py_None;
2066 return _res;
2069 static PyObject *CFMutableStringRefObj_CFStringAppendPascalString(CFMutableStringRefObject *_self, PyObject *_args)
2071 PyObject *_res = NULL;
2072 Str255 pStr;
2073 CFStringEncoding encoding;
2074 #ifndef CFStringAppendPascalString
2075 PyMac_PRECHECK(CFStringAppendPascalString);
2076 #endif
2077 if (!PyArg_ParseTuple(_args, "O&l",
2078 PyMac_GetStr255, pStr,
2079 &encoding))
2080 return NULL;
2081 CFStringAppendPascalString(_self->ob_itself,
2082 pStr,
2083 encoding);
2084 Py_INCREF(Py_None);
2085 _res = Py_None;
2086 return _res;
2089 static PyObject *CFMutableStringRefObj_CFStringAppendCString(CFMutableStringRefObject *_self, PyObject *_args)
2091 PyObject *_res = NULL;
2092 char* cStr;
2093 CFStringEncoding encoding;
2094 #ifndef CFStringAppendCString
2095 PyMac_PRECHECK(CFStringAppendCString);
2096 #endif
2097 if (!PyArg_ParseTuple(_args, "sl",
2098 &cStr,
2099 &encoding))
2100 return NULL;
2101 CFStringAppendCString(_self->ob_itself,
2102 cStr,
2103 encoding);
2104 Py_INCREF(Py_None);
2105 _res = Py_None;
2106 return _res;
2109 static PyObject *CFMutableStringRefObj_CFStringInsert(CFMutableStringRefObject *_self, PyObject *_args)
2111 PyObject *_res = NULL;
2112 CFIndex idx;
2113 CFStringRef insertedStr;
2114 #ifndef CFStringInsert
2115 PyMac_PRECHECK(CFStringInsert);
2116 #endif
2117 if (!PyArg_ParseTuple(_args, "lO&",
2118 &idx,
2119 CFStringRefObj_Convert, &insertedStr))
2120 return NULL;
2121 CFStringInsert(_self->ob_itself,
2122 idx,
2123 insertedStr);
2124 Py_INCREF(Py_None);
2125 _res = Py_None;
2126 return _res;
2129 static PyObject *CFMutableStringRefObj_CFStringDelete(CFMutableStringRefObject *_self, PyObject *_args)
2131 PyObject *_res = NULL;
2132 CFRange range;
2133 #ifndef CFStringDelete
2134 PyMac_PRECHECK(CFStringDelete);
2135 #endif
2136 if (!PyArg_ParseTuple(_args, "O&",
2137 CFRange_Convert, &range))
2138 return NULL;
2139 CFStringDelete(_self->ob_itself,
2140 range);
2141 Py_INCREF(Py_None);
2142 _res = Py_None;
2143 return _res;
2146 static PyObject *CFMutableStringRefObj_CFStringReplace(CFMutableStringRefObject *_self, PyObject *_args)
2148 PyObject *_res = NULL;
2149 CFRange range;
2150 CFStringRef replacement;
2151 #ifndef CFStringReplace
2152 PyMac_PRECHECK(CFStringReplace);
2153 #endif
2154 if (!PyArg_ParseTuple(_args, "O&O&",
2155 CFRange_Convert, &range,
2156 CFStringRefObj_Convert, &replacement))
2157 return NULL;
2158 CFStringReplace(_self->ob_itself,
2159 range,
2160 replacement);
2161 Py_INCREF(Py_None);
2162 _res = Py_None;
2163 return _res;
2166 static PyObject *CFMutableStringRefObj_CFStringReplaceAll(CFMutableStringRefObject *_self, PyObject *_args)
2168 PyObject *_res = NULL;
2169 CFStringRef replacement;
2170 #ifndef CFStringReplaceAll
2171 PyMac_PRECHECK(CFStringReplaceAll);
2172 #endif
2173 if (!PyArg_ParseTuple(_args, "O&",
2174 CFStringRefObj_Convert, &replacement))
2175 return NULL;
2176 CFStringReplaceAll(_self->ob_itself,
2177 replacement);
2178 Py_INCREF(Py_None);
2179 _res = Py_None;
2180 return _res;
2183 static PyObject *CFMutableStringRefObj_CFStringPad(CFMutableStringRefObject *_self, PyObject *_args)
2185 PyObject *_res = NULL;
2186 CFStringRef padString;
2187 CFIndex length;
2188 CFIndex indexIntoPad;
2189 #ifndef CFStringPad
2190 PyMac_PRECHECK(CFStringPad);
2191 #endif
2192 if (!PyArg_ParseTuple(_args, "O&ll",
2193 CFStringRefObj_Convert, &padString,
2194 &length,
2195 &indexIntoPad))
2196 return NULL;
2197 CFStringPad(_self->ob_itself,
2198 padString,
2199 length,
2200 indexIntoPad);
2201 Py_INCREF(Py_None);
2202 _res = Py_None;
2203 return _res;
2206 static PyObject *CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject *_self, PyObject *_args)
2208 PyObject *_res = NULL;
2209 CFStringRef trimString;
2210 #ifndef CFStringTrim
2211 PyMac_PRECHECK(CFStringTrim);
2212 #endif
2213 if (!PyArg_ParseTuple(_args, "O&",
2214 CFStringRefObj_Convert, &trimString))
2215 return NULL;
2216 CFStringTrim(_self->ob_itself,
2217 trimString);
2218 Py_INCREF(Py_None);
2219 _res = Py_None;
2220 return _res;
2223 static PyObject *CFMutableStringRefObj_CFStringTrimWhitespace(CFMutableStringRefObject *_self, PyObject *_args)
2225 PyObject *_res = NULL;
2226 #ifndef CFStringTrimWhitespace
2227 PyMac_PRECHECK(CFStringTrimWhitespace);
2228 #endif
2229 if (!PyArg_ParseTuple(_args, ""))
2230 return NULL;
2231 CFStringTrimWhitespace(_self->ob_itself);
2232 Py_INCREF(Py_None);
2233 _res = Py_None;
2234 return _res;
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,
2259 "() -> None"},
2260 {NULL, NULL, 0}
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;
2277 return 0;
2280 static PyObject * CFMutableStringRefObj_repr(CFMutableStringRefObject *self)
2282 char buf[100];
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)
2295 0, /*ob_size*/
2296 "_CF.CFMutableStringRef", /*tp_name*/
2297 sizeof(CFMutableStringRefObject), /*tp_basicsize*/
2298 0, /*tp_itemsize*/
2299 /* methods */
2300 (destructor) CFMutableStringRefObj_dealloc, /*tp_dealloc*/
2301 0, /*tp_print*/
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 {
2322 PyObject_HEAD
2323 CFURLRef ob_itself;
2324 void (*ob_freeit)(CFTypeRef ptr);
2325 } CFURLRefObject;
2327 PyObject *CFURLRefObj_New(CFURLRef itself)
2329 CFURLRefObject *it;
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");
2346 return 0;
2348 *p_itself = ((CFURLRefObject *)v)->ob_itself;
2349 return 1;
2352 static void CFURLRefObj_dealloc(CFURLRefObject *self)
2354 if (self->ob_freeit && self->ob_itself)
2356 self->ob_freeit((CFTypeRef)self->ob_itself);
2358 PyMem_DEL(self);
2361 static PyObject *CFURLRefObj_CFURLCreateData(CFURLRefObject *_self, PyObject *_args)
2363 PyObject *_res = NULL;
2364 CFDataRef _rv;
2365 CFStringEncoding encoding;
2366 Boolean escapeWhitespace;
2367 if (!PyArg_ParseTuple(_args, "ll",
2368 &encoding,
2369 &escapeWhitespace))
2370 return NULL;
2371 _rv = CFURLCreateData((CFAllocatorRef)NULL,
2372 _self->ob_itself,
2373 encoding,
2374 escapeWhitespace);
2375 _res = Py_BuildValue("O&",
2376 CFDataRefObj_New, _rv);
2377 return _res;
2380 static PyObject *CFURLRefObj_CFURLGetFileSystemRepresentation(CFURLRefObject *_self, PyObject *_args)
2382 PyObject *_res = NULL;
2383 Boolean _rv;
2384 Boolean resolveAgainstBase;
2385 UInt8 buffer;
2386 CFIndex maxBufLen;
2387 #ifndef CFURLGetFileSystemRepresentation
2388 PyMac_PRECHECK(CFURLGetFileSystemRepresentation);
2389 #endif
2390 if (!PyArg_ParseTuple(_args, "ll",
2391 &resolveAgainstBase,
2392 &maxBufLen))
2393 return NULL;
2394 _rv = CFURLGetFileSystemRepresentation(_self->ob_itself,
2395 resolveAgainstBase,
2396 &buffer,
2397 maxBufLen);
2398 _res = Py_BuildValue("lb",
2399 _rv,
2400 buffer);
2401 return _res;
2404 static PyObject *CFURLRefObj_CFURLCopyAbsoluteURL(CFURLRefObject *_self, PyObject *_args)
2406 PyObject *_res = NULL;
2407 CFURLRef _rv;
2408 #ifndef CFURLCopyAbsoluteURL
2409 PyMac_PRECHECK(CFURLCopyAbsoluteURL);
2410 #endif
2411 if (!PyArg_ParseTuple(_args, ""))
2412 return NULL;
2413 _rv = CFURLCopyAbsoluteURL(_self->ob_itself);
2414 _res = Py_BuildValue("O&",
2415 CFURLRefObj_New, _rv);
2416 return _res;
2419 static PyObject *CFURLRefObj_CFURLGetString(CFURLRefObject *_self, PyObject *_args)
2421 PyObject *_res = NULL;
2422 CFStringRef _rv;
2423 #ifndef CFURLGetString
2424 PyMac_PRECHECK(CFURLGetString);
2425 #endif
2426 if (!PyArg_ParseTuple(_args, ""))
2427 return NULL;
2428 _rv = CFURLGetString(_self->ob_itself);
2429 _res = Py_BuildValue("O&",
2430 CFStringRefObj_New, _rv);
2431 return _res;
2434 static PyObject *CFURLRefObj_CFURLGetBaseURL(CFURLRefObject *_self, PyObject *_args)
2436 PyObject *_res = NULL;
2437 CFURLRef _rv;
2438 #ifndef CFURLGetBaseURL
2439 PyMac_PRECHECK(CFURLGetBaseURL);
2440 #endif
2441 if (!PyArg_ParseTuple(_args, ""))
2442 return NULL;
2443 _rv = CFURLGetBaseURL(_self->ob_itself);
2444 _res = Py_BuildValue("O&",
2445 CFURLRefObj_New, _rv);
2446 return _res;
2449 static PyObject *CFURLRefObj_CFURLCanBeDecomposed(CFURLRefObject *_self, PyObject *_args)
2451 PyObject *_res = NULL;
2452 Boolean _rv;
2453 #ifndef CFURLCanBeDecomposed
2454 PyMac_PRECHECK(CFURLCanBeDecomposed);
2455 #endif
2456 if (!PyArg_ParseTuple(_args, ""))
2457 return NULL;
2458 _rv = CFURLCanBeDecomposed(_self->ob_itself);
2459 _res = Py_BuildValue("l",
2460 _rv);
2461 return _res;
2464 static PyObject *CFURLRefObj_CFURLCopyScheme(CFURLRefObject *_self, PyObject *_args)
2466 PyObject *_res = NULL;
2467 CFStringRef _rv;
2468 #ifndef CFURLCopyScheme
2469 PyMac_PRECHECK(CFURLCopyScheme);
2470 #endif
2471 if (!PyArg_ParseTuple(_args, ""))
2472 return NULL;
2473 _rv = CFURLCopyScheme(_self->ob_itself);
2474 _res = Py_BuildValue("O&",
2475 CFStringRefObj_New, _rv);
2476 return _res;
2479 static PyObject *CFURLRefObj_CFURLCopyNetLocation(CFURLRefObject *_self, PyObject *_args)
2481 PyObject *_res = NULL;
2482 CFStringRef _rv;
2483 #ifndef CFURLCopyNetLocation
2484 PyMac_PRECHECK(CFURLCopyNetLocation);
2485 #endif
2486 if (!PyArg_ParseTuple(_args, ""))
2487 return NULL;
2488 _rv = CFURLCopyNetLocation(_self->ob_itself);
2489 _res = Py_BuildValue("O&",
2490 CFStringRefObj_New, _rv);
2491 return _res;
2494 static PyObject *CFURLRefObj_CFURLCopyPath(CFURLRefObject *_self, PyObject *_args)
2496 PyObject *_res = NULL;
2497 CFStringRef _rv;
2498 #ifndef CFURLCopyPath
2499 PyMac_PRECHECK(CFURLCopyPath);
2500 #endif
2501 if (!PyArg_ParseTuple(_args, ""))
2502 return NULL;
2503 _rv = CFURLCopyPath(_self->ob_itself);
2504 _res = Py_BuildValue("O&",
2505 CFStringRefObj_New, _rv);
2506 return _res;
2509 static PyObject *CFURLRefObj_CFURLCopyStrictPath(CFURLRefObject *_self, PyObject *_args)
2511 PyObject *_res = NULL;
2512 CFStringRef _rv;
2513 Boolean isAbsolute;
2514 #ifndef CFURLCopyStrictPath
2515 PyMac_PRECHECK(CFURLCopyStrictPath);
2516 #endif
2517 if (!PyArg_ParseTuple(_args, ""))
2518 return NULL;
2519 _rv = CFURLCopyStrictPath(_self->ob_itself,
2520 &isAbsolute);
2521 _res = Py_BuildValue("O&l",
2522 CFStringRefObj_New, _rv,
2523 isAbsolute);
2524 return _res;
2527 static PyObject *CFURLRefObj_CFURLCopyFileSystemPath(CFURLRefObject *_self, PyObject *_args)
2529 PyObject *_res = NULL;
2530 CFStringRef _rv;
2531 CFURLPathStyle pathStyle;
2532 #ifndef CFURLCopyFileSystemPath
2533 PyMac_PRECHECK(CFURLCopyFileSystemPath);
2534 #endif
2535 if (!PyArg_ParseTuple(_args, "l",
2536 &pathStyle))
2537 return NULL;
2538 _rv = CFURLCopyFileSystemPath(_self->ob_itself,
2539 pathStyle);
2540 _res = Py_BuildValue("O&",
2541 CFStringRefObj_New, _rv);
2542 return _res;
2545 static PyObject *CFURLRefObj_CFURLHasDirectoryPath(CFURLRefObject *_self, PyObject *_args)
2547 PyObject *_res = NULL;
2548 Boolean _rv;
2549 #ifndef CFURLHasDirectoryPath
2550 PyMac_PRECHECK(CFURLHasDirectoryPath);
2551 #endif
2552 if (!PyArg_ParseTuple(_args, ""))
2553 return NULL;
2554 _rv = CFURLHasDirectoryPath(_self->ob_itself);
2555 _res = Py_BuildValue("l",
2556 _rv);
2557 return _res;
2560 static PyObject *CFURLRefObj_CFURLCopyResourceSpecifier(CFURLRefObject *_self, PyObject *_args)
2562 PyObject *_res = NULL;
2563 CFStringRef _rv;
2564 #ifndef CFURLCopyResourceSpecifier
2565 PyMac_PRECHECK(CFURLCopyResourceSpecifier);
2566 #endif
2567 if (!PyArg_ParseTuple(_args, ""))
2568 return NULL;
2569 _rv = CFURLCopyResourceSpecifier(_self->ob_itself);
2570 _res = Py_BuildValue("O&",
2571 CFStringRefObj_New, _rv);
2572 return _res;
2575 static PyObject *CFURLRefObj_CFURLCopyHostName(CFURLRefObject *_self, PyObject *_args)
2577 PyObject *_res = NULL;
2578 CFStringRef _rv;
2579 #ifndef CFURLCopyHostName
2580 PyMac_PRECHECK(CFURLCopyHostName);
2581 #endif
2582 if (!PyArg_ParseTuple(_args, ""))
2583 return NULL;
2584 _rv = CFURLCopyHostName(_self->ob_itself);
2585 _res = Py_BuildValue("O&",
2586 CFStringRefObj_New, _rv);
2587 return _res;
2590 static PyObject *CFURLRefObj_CFURLGetPortNumber(CFURLRefObject *_self, PyObject *_args)
2592 PyObject *_res = NULL;
2593 SInt32 _rv;
2594 #ifndef CFURLGetPortNumber
2595 PyMac_PRECHECK(CFURLGetPortNumber);
2596 #endif
2597 if (!PyArg_ParseTuple(_args, ""))
2598 return NULL;
2599 _rv = CFURLGetPortNumber(_self->ob_itself);
2600 _res = Py_BuildValue("l",
2601 _rv);
2602 return _res;
2605 static PyObject *CFURLRefObj_CFURLCopyUserName(CFURLRefObject *_self, PyObject *_args)
2607 PyObject *_res = NULL;
2608 CFStringRef _rv;
2609 #ifndef CFURLCopyUserName
2610 PyMac_PRECHECK(CFURLCopyUserName);
2611 #endif
2612 if (!PyArg_ParseTuple(_args, ""))
2613 return NULL;
2614 _rv = CFURLCopyUserName(_self->ob_itself);
2615 _res = Py_BuildValue("O&",
2616 CFStringRefObj_New, _rv);
2617 return _res;
2620 static PyObject *CFURLRefObj_CFURLCopyPassword(CFURLRefObject *_self, PyObject *_args)
2622 PyObject *_res = NULL;
2623 CFStringRef _rv;
2624 #ifndef CFURLCopyPassword
2625 PyMac_PRECHECK(CFURLCopyPassword);
2626 #endif
2627 if (!PyArg_ParseTuple(_args, ""))
2628 return NULL;
2629 _rv = CFURLCopyPassword(_self->ob_itself);
2630 _res = Py_BuildValue("O&",
2631 CFStringRefObj_New, _rv);
2632 return _res;
2635 static PyObject *CFURLRefObj_CFURLCopyParameterString(CFURLRefObject *_self, PyObject *_args)
2637 PyObject *_res = NULL;
2638 CFStringRef _rv;
2639 CFStringRef charactersToLeaveEscaped;
2640 #ifndef CFURLCopyParameterString
2641 PyMac_PRECHECK(CFURLCopyParameterString);
2642 #endif
2643 if (!PyArg_ParseTuple(_args, "O&",
2644 CFStringRefObj_Convert, &charactersToLeaveEscaped))
2645 return NULL;
2646 _rv = CFURLCopyParameterString(_self->ob_itself,
2647 charactersToLeaveEscaped);
2648 _res = Py_BuildValue("O&",
2649 CFStringRefObj_New, _rv);
2650 return _res;
2653 static PyObject *CFURLRefObj_CFURLCopyQueryString(CFURLRefObject *_self, PyObject *_args)
2655 PyObject *_res = NULL;
2656 CFStringRef _rv;
2657 CFStringRef charactersToLeaveEscaped;
2658 #ifndef CFURLCopyQueryString
2659 PyMac_PRECHECK(CFURLCopyQueryString);
2660 #endif
2661 if (!PyArg_ParseTuple(_args, "O&",
2662 CFStringRefObj_Convert, &charactersToLeaveEscaped))
2663 return NULL;
2664 _rv = CFURLCopyQueryString(_self->ob_itself,
2665 charactersToLeaveEscaped);
2666 _res = Py_BuildValue("O&",
2667 CFStringRefObj_New, _rv);
2668 return _res;
2671 static PyObject *CFURLRefObj_CFURLCopyFragment(CFURLRefObject *_self, PyObject *_args)
2673 PyObject *_res = NULL;
2674 CFStringRef _rv;
2675 CFStringRef charactersToLeaveEscaped;
2676 #ifndef CFURLCopyFragment
2677 PyMac_PRECHECK(CFURLCopyFragment);
2678 #endif
2679 if (!PyArg_ParseTuple(_args, "O&",
2680 CFStringRefObj_Convert, &charactersToLeaveEscaped))
2681 return NULL;
2682 _rv = CFURLCopyFragment(_self->ob_itself,
2683 charactersToLeaveEscaped);
2684 _res = Py_BuildValue("O&",
2685 CFStringRefObj_New, _rv);
2686 return _res;
2689 static PyObject *CFURLRefObj_CFURLCopyLastPathComponent(CFURLRefObject *_self, PyObject *_args)
2691 PyObject *_res = NULL;
2692 CFStringRef _rv;
2693 #ifndef CFURLCopyLastPathComponent
2694 PyMac_PRECHECK(CFURLCopyLastPathComponent);
2695 #endif
2696 if (!PyArg_ParseTuple(_args, ""))
2697 return NULL;
2698 _rv = CFURLCopyLastPathComponent(_self->ob_itself);
2699 _res = Py_BuildValue("O&",
2700 CFStringRefObj_New, _rv);
2701 return _res;
2704 static PyObject *CFURLRefObj_CFURLCopyPathExtension(CFURLRefObject *_self, PyObject *_args)
2706 PyObject *_res = NULL;
2707 CFStringRef _rv;
2708 #ifndef CFURLCopyPathExtension
2709 PyMac_PRECHECK(CFURLCopyPathExtension);
2710 #endif
2711 if (!PyArg_ParseTuple(_args, ""))
2712 return NULL;
2713 _rv = CFURLCopyPathExtension(_self->ob_itself);
2714 _res = Py_BuildValue("O&",
2715 CFStringRefObj_New, _rv);
2716 return _res;
2719 static PyObject *CFURLRefObj_CFURLCreateCopyAppendingPathComponent(CFURLRefObject *_self, PyObject *_args)
2721 PyObject *_res = NULL;
2722 CFURLRef _rv;
2723 CFStringRef pathComponent;
2724 Boolean isDirectory;
2725 if (!PyArg_ParseTuple(_args, "O&l",
2726 CFStringRefObj_Convert, &pathComponent,
2727 &isDirectory))
2728 return NULL;
2729 _rv = CFURLCreateCopyAppendingPathComponent((CFAllocatorRef)NULL,
2730 _self->ob_itself,
2731 pathComponent,
2732 isDirectory);
2733 _res = Py_BuildValue("O&",
2734 CFURLRefObj_New, _rv);
2735 return _res;
2738 static PyObject *CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent(CFURLRefObject *_self, PyObject *_args)
2740 PyObject *_res = NULL;
2741 CFURLRef _rv;
2742 if (!PyArg_ParseTuple(_args, ""))
2743 return NULL;
2744 _rv = CFURLCreateCopyDeletingLastPathComponent((CFAllocatorRef)NULL,
2745 _self->ob_itself);
2746 _res = Py_BuildValue("O&",
2747 CFURLRefObj_New, _rv);
2748 return _res;
2751 static PyObject *CFURLRefObj_CFURLCreateCopyAppendingPathExtension(CFURLRefObject *_self, PyObject *_args)
2753 PyObject *_res = NULL;
2754 CFURLRef _rv;
2755 CFStringRef extension;
2756 if (!PyArg_ParseTuple(_args, "O&",
2757 CFStringRefObj_Convert, &extension))
2758 return NULL;
2759 _rv = CFURLCreateCopyAppendingPathExtension((CFAllocatorRef)NULL,
2760 _self->ob_itself,
2761 extension);
2762 _res = Py_BuildValue("O&",
2763 CFURLRefObj_New, _rv);
2764 return _res;
2767 static PyObject *CFURLRefObj_CFURLCreateCopyDeletingPathExtension(CFURLRefObject *_self, PyObject *_args)
2769 PyObject *_res = NULL;
2770 CFURLRef _rv;
2771 if (!PyArg_ParseTuple(_args, ""))
2772 return NULL;
2773 _rv = CFURLCreateCopyDeletingPathExtension((CFAllocatorRef)NULL,
2774 _self->ob_itself);
2775 _res = Py_BuildValue("O&",
2776 CFURLRefObj_New, _rv);
2777 return _res;
2780 static PyObject *CFURLRefObj_CFURLGetFSRef(CFURLRefObject *_self, PyObject *_args)
2782 PyObject *_res = NULL;
2783 Boolean _rv;
2784 FSRef fsRef;
2785 #ifndef CFURLGetFSRef
2786 PyMac_PRECHECK(CFURLGetFSRef);
2787 #endif
2788 if (!PyArg_ParseTuple(_args, ""))
2789 return NULL;
2790 _rv = CFURLGetFSRef(_self->ob_itself,
2791 &fsRef);
2792 _res = Py_BuildValue("lO&",
2793 _rv,
2794 PyMac_BuildFSRef, &fsRef);
2795 return _res;
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)"},
2853 {NULL, NULL, 0}
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;
2870 return 0;
2873 static PyObject * CFURLRefObj_repr(CFURLRefObject *self)
2875 char buf[100];
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)
2888 0, /*ob_size*/
2889 "_CF.CFURLRef", /*tp_name*/
2890 sizeof(CFURLRefObject), /*tp_basicsize*/
2891 0, /*tp_itemsize*/
2892 /* methods */
2893 (destructor) CFURLRefObj_dealloc, /*tp_dealloc*/
2894 0, /*tp_print*/
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;
2911 CFRange _rv;
2912 CFIndex loc;
2913 CFIndex len;
2914 #ifndef __CFRangeMake
2915 PyMac_PRECHECK(__CFRangeMake);
2916 #endif
2917 if (!PyArg_ParseTuple(_args, "ll",
2918 &loc,
2919 &len))
2920 return NULL;
2921 _rv = __CFRangeMake(loc,
2922 len);
2923 _res = Py_BuildValue("O&",
2924 CFRange_New, _rv);
2925 return _res;
2928 static PyObject *CF_CFAllocatorGetTypeID(PyObject *_self, PyObject *_args)
2930 PyObject *_res = NULL;
2931 CFTypeID _rv;
2932 #ifndef CFAllocatorGetTypeID
2933 PyMac_PRECHECK(CFAllocatorGetTypeID);
2934 #endif
2935 if (!PyArg_ParseTuple(_args, ""))
2936 return NULL;
2937 _rv = CFAllocatorGetTypeID();
2938 _res = Py_BuildValue("l",
2939 _rv);
2940 return _res;
2943 static PyObject *CF_CFAllocatorGetPreferredSizeForSize(PyObject *_self, PyObject *_args)
2945 PyObject *_res = NULL;
2946 CFIndex _rv;
2947 CFIndex size;
2948 CFOptionFlags hint;
2949 #ifndef CFAllocatorGetPreferredSizeForSize
2950 PyMac_PRECHECK(CFAllocatorGetPreferredSizeForSize);
2951 #endif
2952 if (!PyArg_ParseTuple(_args, "ll",
2953 &size,
2954 &hint))
2955 return NULL;
2956 _rv = CFAllocatorGetPreferredSizeForSize((CFAllocatorRef)NULL,
2957 size,
2958 hint);
2959 _res = Py_BuildValue("l",
2960 _rv);
2961 return _res;
2964 static PyObject *CF_CFCopyTypeIDDescription(PyObject *_self, PyObject *_args)
2966 PyObject *_res = NULL;
2967 CFStringRef _rv;
2968 CFTypeID type_id;
2969 #ifndef CFCopyTypeIDDescription
2970 PyMac_PRECHECK(CFCopyTypeIDDescription);
2971 #endif
2972 if (!PyArg_ParseTuple(_args, "l",
2973 &type_id))
2974 return NULL;
2975 _rv = CFCopyTypeIDDescription(type_id);
2976 _res = Py_BuildValue("O&",
2977 CFStringRefObj_New, _rv);
2978 return _res;
2981 static PyObject *CF_CFArrayGetTypeID(PyObject *_self, PyObject *_args)
2983 PyObject *_res = NULL;
2984 CFTypeID _rv;
2985 #ifndef CFArrayGetTypeID
2986 PyMac_PRECHECK(CFArrayGetTypeID);
2987 #endif
2988 if (!PyArg_ParseTuple(_args, ""))
2989 return NULL;
2990 _rv = CFArrayGetTypeID();
2991 _res = Py_BuildValue("l",
2992 _rv);
2993 return _res;
2996 static PyObject *CF_CFArrayCreateMutable(PyObject *_self, PyObject *_args)
2998 PyObject *_res = NULL;
2999 CFMutableArrayRef _rv;
3000 CFIndex capacity;
3001 #ifndef CFArrayCreateMutable
3002 PyMac_PRECHECK(CFArrayCreateMutable);
3003 #endif
3004 if (!PyArg_ParseTuple(_args, "l",
3005 &capacity))
3006 return NULL;
3007 _rv = CFArrayCreateMutable((CFAllocatorRef)NULL,
3008 capacity,
3009 &kCFTypeArrayCallBacks);
3010 _res = Py_BuildValue("O&",
3011 CFMutableArrayRefObj_New, _rv);
3012 return _res;
3015 static PyObject *CF_CFArrayCreateMutableCopy(PyObject *_self, PyObject *_args)
3017 PyObject *_res = NULL;
3018 CFMutableArrayRef _rv;
3019 CFIndex capacity;
3020 CFArrayRef theArray;
3021 #ifndef CFArrayCreateMutableCopy
3022 PyMac_PRECHECK(CFArrayCreateMutableCopy);
3023 #endif
3024 if (!PyArg_ParseTuple(_args, "lO&",
3025 &capacity,
3026 CFArrayRefObj_Convert, &theArray))
3027 return NULL;
3028 _rv = CFArrayCreateMutableCopy((CFAllocatorRef)NULL,
3029 capacity,
3030 theArray);
3031 _res = Py_BuildValue("O&",
3032 CFMutableArrayRefObj_New, _rv);
3033 return _res;
3036 static PyObject *CF_CFDataGetTypeID(PyObject *_self, PyObject *_args)
3038 PyObject *_res = NULL;
3039 CFTypeID _rv;
3040 #ifndef CFDataGetTypeID
3041 PyMac_PRECHECK(CFDataGetTypeID);
3042 #endif
3043 if (!PyArg_ParseTuple(_args, ""))
3044 return NULL;
3045 _rv = CFDataGetTypeID();
3046 _res = Py_BuildValue("l",
3047 _rv);
3048 return _res;
3051 static PyObject *CF_CFDataCreate(PyObject *_self, PyObject *_args)
3053 PyObject *_res = NULL;
3054 CFDataRef _rv;
3055 unsigned char *bytes__in__;
3056 long bytes__len__;
3057 int bytes__in_len__;
3058 #ifndef CFDataCreate
3059 PyMac_PRECHECK(CFDataCreate);
3060 #endif
3061 if (!PyArg_ParseTuple(_args, "s#",
3062 &bytes__in__, &bytes__in_len__))
3063 return NULL;
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);
3069 return _res;
3072 static PyObject *CF_CFDataCreateWithBytesNoCopy(PyObject *_self, PyObject *_args)
3074 PyObject *_res = NULL;
3075 CFDataRef _rv;
3076 unsigned char *bytes__in__;
3077 long bytes__len__;
3078 int bytes__in_len__;
3079 #ifndef CFDataCreateWithBytesNoCopy
3080 PyMac_PRECHECK(CFDataCreateWithBytesNoCopy);
3081 #endif
3082 if (!PyArg_ParseTuple(_args, "s#",
3083 &bytes__in__, &bytes__in_len__))
3084 return NULL;
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);
3091 return _res;
3094 static PyObject *CF_CFDataCreateMutable(PyObject *_self, PyObject *_args)
3096 PyObject *_res = NULL;
3097 CFMutableDataRef _rv;
3098 CFIndex capacity;
3099 #ifndef CFDataCreateMutable
3100 PyMac_PRECHECK(CFDataCreateMutable);
3101 #endif
3102 if (!PyArg_ParseTuple(_args, "l",
3103 &capacity))
3104 return NULL;
3105 _rv = CFDataCreateMutable((CFAllocatorRef)NULL,
3106 capacity);
3107 _res = Py_BuildValue("O&",
3108 CFMutableDataRefObj_New, _rv);
3109 return _res;
3112 static PyObject *CF_CFDataCreateMutableCopy(PyObject *_self, PyObject *_args)
3114 PyObject *_res = NULL;
3115 CFMutableDataRef _rv;
3116 CFIndex capacity;
3117 CFDataRef theData;
3118 #ifndef CFDataCreateMutableCopy
3119 PyMac_PRECHECK(CFDataCreateMutableCopy);
3120 #endif
3121 if (!PyArg_ParseTuple(_args, "lO&",
3122 &capacity,
3123 CFDataRefObj_Convert, &theData))
3124 return NULL;
3125 _rv = CFDataCreateMutableCopy((CFAllocatorRef)NULL,
3126 capacity,
3127 theData);
3128 _res = Py_BuildValue("O&",
3129 CFMutableDataRefObj_New, _rv);
3130 return _res;
3133 static PyObject *CF_CFDictionaryGetTypeID(PyObject *_self, PyObject *_args)
3135 PyObject *_res = NULL;
3136 CFTypeID _rv;
3137 #ifndef CFDictionaryGetTypeID
3138 PyMac_PRECHECK(CFDictionaryGetTypeID);
3139 #endif
3140 if (!PyArg_ParseTuple(_args, ""))
3141 return NULL;
3142 _rv = CFDictionaryGetTypeID();
3143 _res = Py_BuildValue("l",
3144 _rv);
3145 return _res;
3148 static PyObject *CF_CFDictionaryCreateMutable(PyObject *_self, PyObject *_args)
3150 PyObject *_res = NULL;
3151 CFMutableDictionaryRef _rv;
3152 CFIndex capacity;
3153 #ifndef CFDictionaryCreateMutable
3154 PyMac_PRECHECK(CFDictionaryCreateMutable);
3155 #endif
3156 if (!PyArg_ParseTuple(_args, "l",
3157 &capacity))
3158 return NULL;
3159 _rv = CFDictionaryCreateMutable((CFAllocatorRef)NULL,
3160 capacity,
3161 &kCFTypeDictionaryKeyCallBacks,
3162 &kCFTypeDictionaryValueCallBacks);
3163 _res = Py_BuildValue("O&",
3164 CFMutableDictionaryRefObj_New, _rv);
3165 return _res;
3168 static PyObject *CF_CFDictionaryCreateMutableCopy(PyObject *_self, PyObject *_args)
3170 PyObject *_res = NULL;
3171 CFMutableDictionaryRef _rv;
3172 CFIndex capacity;
3173 CFDictionaryRef theDict;
3174 #ifndef CFDictionaryCreateMutableCopy
3175 PyMac_PRECHECK(CFDictionaryCreateMutableCopy);
3176 #endif
3177 if (!PyArg_ParseTuple(_args, "lO&",
3178 &capacity,
3179 CFDictionaryRefObj_Convert, &theDict))
3180 return NULL;
3181 _rv = CFDictionaryCreateMutableCopy((CFAllocatorRef)NULL,
3182 capacity,
3183 theDict);
3184 _res = Py_BuildValue("O&",
3185 CFMutableDictionaryRefObj_New, _rv);
3186 return _res;
3189 static PyObject *CF_CFStringGetTypeID(PyObject *_self, PyObject *_args)
3191 PyObject *_res = NULL;
3192 CFTypeID _rv;
3193 #ifndef CFStringGetTypeID
3194 PyMac_PRECHECK(CFStringGetTypeID);
3195 #endif
3196 if (!PyArg_ParseTuple(_args, ""))
3197 return NULL;
3198 _rv = CFStringGetTypeID();
3199 _res = Py_BuildValue("l",
3200 _rv);
3201 return _res;
3204 static PyObject *CF_CFStringCreateWithPascalString(PyObject *_self, PyObject *_args)
3206 PyObject *_res = NULL;
3207 CFStringRef _rv;
3208 Str255 pStr;
3209 CFStringEncoding encoding;
3210 #ifndef CFStringCreateWithPascalString
3211 PyMac_PRECHECK(CFStringCreateWithPascalString);
3212 #endif
3213 if (!PyArg_ParseTuple(_args, "O&l",
3214 PyMac_GetStr255, pStr,
3215 &encoding))
3216 return NULL;
3217 _rv = CFStringCreateWithPascalString((CFAllocatorRef)NULL,
3218 pStr,
3219 encoding);
3220 _res = Py_BuildValue("O&",
3221 CFStringRefObj_New, _rv);
3222 return _res;
3225 static PyObject *CF_CFStringCreateWithCString(PyObject *_self, PyObject *_args)
3227 PyObject *_res = NULL;
3228 CFStringRef _rv;
3229 char* cStr;
3230 CFStringEncoding encoding;
3231 #ifndef CFStringCreateWithCString
3232 PyMac_PRECHECK(CFStringCreateWithCString);
3233 #endif
3234 if (!PyArg_ParseTuple(_args, "sl",
3235 &cStr,
3236 &encoding))
3237 return NULL;
3238 _rv = CFStringCreateWithCString((CFAllocatorRef)NULL,
3239 cStr,
3240 encoding);
3241 _res = Py_BuildValue("O&",
3242 CFStringRefObj_New, _rv);
3243 return _res;
3246 static PyObject *CF_CFStringCreateWithCharacters(PyObject *_self, PyObject *_args)
3248 PyObject *_res = NULL;
3249 CFStringRef _rv;
3250 UniChar *chars__in__;
3251 UniCharCount chars__len__;
3252 int chars__in_len__;
3253 #ifndef CFStringCreateWithCharacters
3254 PyMac_PRECHECK(CFStringCreateWithCharacters);
3255 #endif
3256 if (!PyArg_ParseTuple(_args, "u#",
3257 &chars__in__, &chars__in_len__))
3258 return NULL;
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);
3264 return _res;
3267 static PyObject *CF_CFStringCreateWithPascalStringNoCopy(PyObject *_self, PyObject *_args)
3269 PyObject *_res = NULL;
3270 CFStringRef _rv;
3271 Str255 pStr;
3272 CFStringEncoding encoding;
3273 #ifndef CFStringCreateWithPascalStringNoCopy
3274 PyMac_PRECHECK(CFStringCreateWithPascalStringNoCopy);
3275 #endif
3276 if (!PyArg_ParseTuple(_args, "O&l",
3277 PyMac_GetStr255, pStr,
3278 &encoding))
3279 return NULL;
3280 _rv = CFStringCreateWithPascalStringNoCopy((CFAllocatorRef)NULL,
3281 pStr,
3282 encoding,
3283 (CFAllocatorRef)NULL);
3284 _res = Py_BuildValue("O&",
3285 CFStringRefObj_New, _rv);
3286 return _res;
3289 static PyObject *CF_CFStringCreateWithCStringNoCopy(PyObject *_self, PyObject *_args)
3291 PyObject *_res = NULL;
3292 CFStringRef _rv;
3293 char* cStr;
3294 CFStringEncoding encoding;
3295 #ifndef CFStringCreateWithCStringNoCopy
3296 PyMac_PRECHECK(CFStringCreateWithCStringNoCopy);
3297 #endif
3298 if (!PyArg_ParseTuple(_args, "sl",
3299 &cStr,
3300 &encoding))
3301 return NULL;
3302 _rv = CFStringCreateWithCStringNoCopy((CFAllocatorRef)NULL,
3303 cStr,
3304 encoding,
3305 (CFAllocatorRef)NULL);
3306 _res = Py_BuildValue("O&",
3307 CFStringRefObj_New, _rv);
3308 return _res;
3311 static PyObject *CF_CFStringCreateWithCharactersNoCopy(PyObject *_self, PyObject *_args)
3313 PyObject *_res = NULL;
3314 CFStringRef _rv;
3315 UniChar *chars__in__;
3316 UniCharCount chars__len__;
3317 int chars__in_len__;
3318 #ifndef CFStringCreateWithCharactersNoCopy
3319 PyMac_PRECHECK(CFStringCreateWithCharactersNoCopy);
3320 #endif
3321 if (!PyArg_ParseTuple(_args, "u#",
3322 &chars__in__, &chars__in_len__))
3323 return NULL;
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);
3330 return _res;
3333 static PyObject *CF_CFStringCreateMutable(PyObject *_self, PyObject *_args)
3335 PyObject *_res = NULL;
3336 CFMutableStringRef _rv;
3337 CFIndex maxLength;
3338 #ifndef CFStringCreateMutable
3339 PyMac_PRECHECK(CFStringCreateMutable);
3340 #endif
3341 if (!PyArg_ParseTuple(_args, "l",
3342 &maxLength))
3343 return NULL;
3344 _rv = CFStringCreateMutable((CFAllocatorRef)NULL,
3345 maxLength);
3346 _res = Py_BuildValue("O&",
3347 CFMutableStringRefObj_New, _rv);
3348 return _res;
3351 static PyObject *CF_CFStringCreateMutableCopy(PyObject *_self, PyObject *_args)
3353 PyObject *_res = NULL;
3354 CFMutableStringRef _rv;
3355 CFIndex maxLength;
3356 CFStringRef theString;
3357 #ifndef CFStringCreateMutableCopy
3358 PyMac_PRECHECK(CFStringCreateMutableCopy);
3359 #endif
3360 if (!PyArg_ParseTuple(_args, "lO&",
3361 &maxLength,
3362 CFStringRefObj_Convert, &theString))
3363 return NULL;
3364 _rv = CFStringCreateMutableCopy((CFAllocatorRef)NULL,
3365 maxLength,
3366 theString);
3367 _res = Py_BuildValue("O&",
3368 CFMutableStringRefObj_New, _rv);
3369 return _res;
3372 static PyObject *CF_CFStringCreateWithBytes(PyObject *_self, PyObject *_args)
3374 PyObject *_res = NULL;
3375 CFStringRef _rv;
3376 unsigned char *bytes__in__;
3377 long bytes__len__;
3378 int bytes__in_len__;
3379 CFStringEncoding encoding;
3380 Boolean isExternalRepresentation;
3381 #ifndef CFStringCreateWithBytes
3382 PyMac_PRECHECK(CFStringCreateWithBytes);
3383 #endif
3384 if (!PyArg_ParseTuple(_args, "s#ll",
3385 &bytes__in__, &bytes__in_len__,
3386 &encoding,
3387 &isExternalRepresentation))
3388 return NULL;
3389 bytes__len__ = bytes__in_len__;
3390 _rv = CFStringCreateWithBytes((CFAllocatorRef)NULL,
3391 bytes__in__, bytes__len__,
3392 encoding,
3393 isExternalRepresentation);
3394 _res = Py_BuildValue("O&",
3395 CFStringRefObj_New, _rv);
3396 return _res;
3399 static PyObject *CF_CFStringGetSystemEncoding(PyObject *_self, PyObject *_args)
3401 PyObject *_res = NULL;
3402 CFStringEncoding _rv;
3403 #ifndef CFStringGetSystemEncoding
3404 PyMac_PRECHECK(CFStringGetSystemEncoding);
3405 #endif
3406 if (!PyArg_ParseTuple(_args, ""))
3407 return NULL;
3408 _rv = CFStringGetSystemEncoding();
3409 _res = Py_BuildValue("l",
3410 _rv);
3411 return _res;
3414 static PyObject *CF_CFStringGetMaximumSizeForEncoding(PyObject *_self, PyObject *_args)
3416 PyObject *_res = NULL;
3417 CFIndex _rv;
3418 CFIndex length;
3419 CFStringEncoding encoding;
3420 #ifndef CFStringGetMaximumSizeForEncoding
3421 PyMac_PRECHECK(CFStringGetMaximumSizeForEncoding);
3422 #endif
3423 if (!PyArg_ParseTuple(_args, "ll",
3424 &length,
3425 &encoding))
3426 return NULL;
3427 _rv = CFStringGetMaximumSizeForEncoding(length,
3428 encoding);
3429 _res = Py_BuildValue("l",
3430 _rv);
3431 return _res;
3434 static PyObject *CF_CFStringIsEncodingAvailable(PyObject *_self, PyObject *_args)
3436 PyObject *_res = NULL;
3437 Boolean _rv;
3438 CFStringEncoding encoding;
3439 #ifndef CFStringIsEncodingAvailable
3440 PyMac_PRECHECK(CFStringIsEncodingAvailable);
3441 #endif
3442 if (!PyArg_ParseTuple(_args, "l",
3443 &encoding))
3444 return NULL;
3445 _rv = CFStringIsEncodingAvailable(encoding);
3446 _res = Py_BuildValue("l",
3447 _rv);
3448 return _res;
3451 static PyObject *CF_CFStringGetNameOfEncoding(PyObject *_self, PyObject *_args)
3453 PyObject *_res = NULL;
3454 CFStringRef _rv;
3455 CFStringEncoding encoding;
3456 #ifndef CFStringGetNameOfEncoding
3457 PyMac_PRECHECK(CFStringGetNameOfEncoding);
3458 #endif
3459 if (!PyArg_ParseTuple(_args, "l",
3460 &encoding))
3461 return NULL;
3462 _rv = CFStringGetNameOfEncoding(encoding);
3463 _res = Py_BuildValue("O&",
3464 CFStringRefObj_New, _rv);
3465 return _res;
3468 static PyObject *CF_CFStringConvertEncodingToNSStringEncoding(PyObject *_self, PyObject *_args)
3470 PyObject *_res = NULL;
3471 UInt32 _rv;
3472 CFStringEncoding encoding;
3473 #ifndef CFStringConvertEncodingToNSStringEncoding
3474 PyMac_PRECHECK(CFStringConvertEncodingToNSStringEncoding);
3475 #endif
3476 if (!PyArg_ParseTuple(_args, "l",
3477 &encoding))
3478 return NULL;
3479 _rv = CFStringConvertEncodingToNSStringEncoding(encoding);
3480 _res = Py_BuildValue("l",
3481 _rv);
3482 return _res;
3485 static PyObject *CF_CFStringConvertNSStringEncodingToEncoding(PyObject *_self, PyObject *_args)
3487 PyObject *_res = NULL;
3488 CFStringEncoding _rv;
3489 UInt32 encoding;
3490 #ifndef CFStringConvertNSStringEncodingToEncoding
3491 PyMac_PRECHECK(CFStringConvertNSStringEncodingToEncoding);
3492 #endif
3493 if (!PyArg_ParseTuple(_args, "l",
3494 &encoding))
3495 return NULL;
3496 _rv = CFStringConvertNSStringEncodingToEncoding(encoding);
3497 _res = Py_BuildValue("l",
3498 _rv);
3499 return _res;
3502 static PyObject *CF_CFStringConvertEncodingToWindowsCodepage(PyObject *_self, PyObject *_args)
3504 PyObject *_res = NULL;
3505 UInt32 _rv;
3506 CFStringEncoding encoding;
3507 #ifndef CFStringConvertEncodingToWindowsCodepage
3508 PyMac_PRECHECK(CFStringConvertEncodingToWindowsCodepage);
3509 #endif
3510 if (!PyArg_ParseTuple(_args, "l",
3511 &encoding))
3512 return NULL;
3513 _rv = CFStringConvertEncodingToWindowsCodepage(encoding);
3514 _res = Py_BuildValue("l",
3515 _rv);
3516 return _res;
3519 static PyObject *CF_CFStringConvertWindowsCodepageToEncoding(PyObject *_self, PyObject *_args)
3521 PyObject *_res = NULL;
3522 CFStringEncoding _rv;
3523 UInt32 codepage;
3524 #ifndef CFStringConvertWindowsCodepageToEncoding
3525 PyMac_PRECHECK(CFStringConvertWindowsCodepageToEncoding);
3526 #endif
3527 if (!PyArg_ParseTuple(_args, "l",
3528 &codepage))
3529 return NULL;
3530 _rv = CFStringConvertWindowsCodepageToEncoding(codepage);
3531 _res = Py_BuildValue("l",
3532 _rv);
3533 return _res;
3536 static PyObject *CF_CFStringConvertEncodingToIANACharSetName(PyObject *_self, PyObject *_args)
3538 PyObject *_res = NULL;
3539 CFStringRef _rv;
3540 CFStringEncoding encoding;
3541 #ifndef CFStringConvertEncodingToIANACharSetName
3542 PyMac_PRECHECK(CFStringConvertEncodingToIANACharSetName);
3543 #endif
3544 if (!PyArg_ParseTuple(_args, "l",
3545 &encoding))
3546 return NULL;
3547 _rv = CFStringConvertEncodingToIANACharSetName(encoding);
3548 _res = Py_BuildValue("O&",
3549 CFStringRefObj_New, _rv);
3550 return _res;
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);
3560 #endif
3561 if (!PyArg_ParseTuple(_args, "l",
3562 &encoding))
3563 return NULL;
3564 _rv = CFStringGetMostCompatibleMacStringEncoding(encoding);
3565 _res = Py_BuildValue("l",
3566 _rv);
3567 return _res;
3570 static PyObject *CF___CFStringMakeConstantString(PyObject *_self, PyObject *_args)
3572 PyObject *_res = NULL;
3573 CFStringRef _rv;
3574 char* cStr;
3575 #ifndef __CFStringMakeConstantString
3576 PyMac_PRECHECK(__CFStringMakeConstantString);
3577 #endif
3578 if (!PyArg_ParseTuple(_args, "s",
3579 &cStr))
3580 return NULL;
3581 _rv = __CFStringMakeConstantString(cStr);
3582 _res = Py_BuildValue("O&",
3583 CFStringRefObj_New, _rv);
3584 return _res;
3587 static PyObject *CF_CFURLGetTypeID(PyObject *_self, PyObject *_args)
3589 PyObject *_res = NULL;
3590 CFTypeID _rv;
3591 #ifndef CFURLGetTypeID
3592 PyMac_PRECHECK(CFURLGetTypeID);
3593 #endif
3594 if (!PyArg_ParseTuple(_args, ""))
3595 return NULL;
3596 _rv = CFURLGetTypeID();
3597 _res = Py_BuildValue("l",
3598 _rv);
3599 return _res;
3602 static PyObject *CF_CFURLCreateWithBytes(PyObject *_self, PyObject *_args)
3604 PyObject *_res = NULL;
3605 CFURLRef _rv;
3606 unsigned char *URLBytes__in__;
3607 long URLBytes__len__;
3608 int URLBytes__in_len__;
3609 CFStringEncoding encoding;
3610 CFURLRef baseURL;
3611 #ifndef CFURLCreateWithBytes
3612 PyMac_PRECHECK(CFURLCreateWithBytes);
3613 #endif
3614 if (!PyArg_ParseTuple(_args, "s#lO&",
3615 &URLBytes__in__, &URLBytes__in_len__,
3616 &encoding,
3617 OptionalCFURLRefObj_Convert, &baseURL))
3618 return NULL;
3619 URLBytes__len__ = URLBytes__in_len__;
3620 _rv = CFURLCreateWithBytes((CFAllocatorRef)NULL,
3621 URLBytes__in__, URLBytes__len__,
3622 encoding,
3623 baseURL);
3624 _res = Py_BuildValue("O&",
3625 CFURLRefObj_New, _rv);
3626 return _res;
3629 static PyObject *CF_CFURLCreateFromFileSystemRepresentation(PyObject *_self, PyObject *_args)
3631 PyObject *_res = NULL;
3632 CFURLRef _rv;
3633 unsigned char *buffer__in__;
3634 long buffer__len__;
3635 int buffer__in_len__;
3636 Boolean isDirectory;
3637 #ifndef CFURLCreateFromFileSystemRepresentation
3638 PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentation);
3639 #endif
3640 if (!PyArg_ParseTuple(_args, "s#l",
3641 &buffer__in__, &buffer__in_len__,
3642 &isDirectory))
3643 return NULL;
3644 buffer__len__ = buffer__in_len__;
3645 _rv = CFURLCreateFromFileSystemRepresentation((CFAllocatorRef)NULL,
3646 buffer__in__, buffer__len__,
3647 isDirectory);
3648 _res = Py_BuildValue("O&",
3649 CFURLRefObj_New, _rv);
3650 return _res;
3653 static PyObject *CF_CFURLCreateFromFileSystemRepresentationRelativeToBase(PyObject *_self, PyObject *_args)
3655 PyObject *_res = NULL;
3656 CFURLRef _rv;
3657 unsigned char *buffer__in__;
3658 long buffer__len__;
3659 int buffer__in_len__;
3660 Boolean isDirectory;
3661 CFURLRef baseURL;
3662 #ifndef CFURLCreateFromFileSystemRepresentationRelativeToBase
3663 PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentationRelativeToBase);
3664 #endif
3665 if (!PyArg_ParseTuple(_args, "s#lO&",
3666 &buffer__in__, &buffer__in_len__,
3667 &isDirectory,
3668 OptionalCFURLRefObj_Convert, &baseURL))
3669 return NULL;
3670 buffer__len__ = buffer__in_len__;
3671 _rv = CFURLCreateFromFileSystemRepresentationRelativeToBase((CFAllocatorRef)NULL,
3672 buffer__in__, buffer__len__,
3673 isDirectory,
3674 baseURL);
3675 _res = Py_BuildValue("O&",
3676 CFURLRefObj_New, _rv);
3677 return _res;
3680 static PyObject *CF_CFURLCreateFromFSRef(PyObject *_self, PyObject *_args)
3682 PyObject *_res = NULL;
3683 CFURLRef _rv;
3684 FSRef fsRef;
3685 #ifndef CFURLCreateFromFSRef
3686 PyMac_PRECHECK(CFURLCreateFromFSRef);
3687 #endif
3688 if (!PyArg_ParseTuple(_args, "O&",
3689 PyMac_GetFSRef, &fsRef))
3690 return NULL;
3691 _rv = CFURLCreateFromFSRef((CFAllocatorRef)NULL,
3692 &fsRef);
3693 _res = Py_BuildValue("O&",
3694 CFURLRefObj_New, _rv);
3695 return _res;
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)"},
3781 {NULL, NULL, 0}
3787 void init_CF(void)
3789 PyObject *m;
3790 PyObject *d;
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)
3819 return;
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 ========================= */