blob: d436c90350214bc24de4ba158dcbdf4033b2e758 [file] [log] [blame]
Jack Jansen686f9c32001-06-26 21:51:18 +00001
2/* =========================== Module CF ============================ */
3
4#include "Python.h"
5
6
7
8#include "macglue.h"
9#include "pymactoolbox.h"
10
11#ifdef WITHOUT_FRAMEWORKS
12#include <CoreFoundation.h>
13#else
14#include <CoreFoundation.h>
15#endif
16
17/* For now we declare them forward here. They'll go to mactoolbox later */
Jack Jansen7becc912001-06-28 22:08:26 +000018staticforward PyObject *CFTypeRefObj_New(CFTypeRef);
19staticforward int CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
20staticforward PyObject *CFStringRefObj_New(CFStringRef);
21staticforward int CFStringRefObj_Convert(PyObject *, CFStringRef *);
22
23staticforward int CFURLRefObj_Convert(PyObject *, CFURLRef *);
Jack Jansen686f9c32001-06-26 21:51:18 +000024
Jack Jansenbc7c8962001-06-27 22:00:55 +000025// ADD declarations
Jack Jansen686f9c32001-06-26 21:51:18 +000026#ifdef NOTYET_USE_TOOLBOX_OBJECT_GLUE
27//extern PyObject *_CFTypeRefObj_New(CFTypeRef);
28//extern int _CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
29
30//#define CFTypeRefObj_New _CFTypeRefObj_New
31//#define CFTypeRefObj_Convert _CFTypeRefObj_Convert
32#endif
33
Jack Jansenbc7c8962001-06-27 22:00:55 +000034/*
Jack Jansen7becc912001-06-28 22:08:26 +000035** Parse/generate CFRange records
Jack Jansenbc7c8962001-06-27 22:00:55 +000036*/
37PyObject *CFRange_New(CFRange *itself)
38{
39
40 return Py_BuildValue("ll", (long)itself->location, (long)itself->length);
41}
42
43CFRange_Convert(PyObject *v, CFRange *p_itself)
44{
45 long location, length;
46
47 if( !PyArg_ParseTuple(v, "ll", &location, &length) )
48 return 0;
49 p_itself->location = (CFIndex)location;
50 p_itself->length = (CFIndex)length;
51 return 1;
52}
53
Jack Jansen7becc912001-06-28 22:08:26 +000054/* Optional CFURL argument or None (passed as NULL) */
55int
56OptionalCFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself)
57{
58 if ( v == Py_None ) {
59 p_itself = NULL;
60 return 1;
61 }
62 return CFURLRefObj_Convert(v, p_itself);
63}
64
Jack Jansen686f9c32001-06-26 21:51:18 +000065
66static PyObject *CF_Error;
67
68/* --------------------- Object type CFTypeRef ---------------------- */
69
70PyTypeObject CFTypeRef_Type;
71
72#define CFTypeRefObj_Check(x) ((x)->ob_type == &CFTypeRef_Type)
73
74typedef struct CFTypeRefObject {
75 PyObject_HEAD
76 CFTypeRef ob_itself;
77 void (*ob_freeit)(CFTypeRef ptr);
78} CFTypeRefObject;
79
80PyObject *CFTypeRefObj_New(CFTypeRef itself)
81{
82 CFTypeRefObject *it;
83 if (itself == NULL) return PyMac_Error(resNotFound);
84 CFRetain(itself);
85 it = PyObject_NEW(CFTypeRefObject, &CFTypeRef_Type);
86 if (it == NULL) return NULL;
87 it->ob_itself = itself;
88 it->ob_freeit = CFRelease;
89 return (PyObject *)it;
90}
91CFTypeRefObj_Convert(PyObject *v, CFTypeRef *p_itself)
92{
93
94 if (v == Py_None) { *p_itself = NULL; return 1; }
95 /* Check for other CF objects here */
96
97 if (!CFTypeRefObj_Check(v))
98 {
99 PyErr_SetString(PyExc_TypeError, "CFTypeRef required");
100 return 0;
101 }
102 *p_itself = ((CFTypeRefObject *)v)->ob_itself;
103 return 1;
104}
105
106static void CFTypeRefObj_dealloc(CFTypeRefObject *self)
107{
108 if (self->ob_freeit && self->ob_itself)
109 {
110 self->ob_freeit((CFTypeRef)self->ob_itself);
111 }
112 PyMem_DEL(self);
113}
114
115static PyObject *CFTypeRefObj_CFGetTypeID(CFTypeRefObject *_self, PyObject *_args)
116{
117 PyObject *_res = NULL;
118 CFTypeID _rv;
119 if (!PyArg_ParseTuple(_args, ""))
120 return NULL;
121 _rv = CFGetTypeID(_self->ob_itself);
122 _res = Py_BuildValue("l",
123 _rv);
124 return _res;
125}
126
127static PyObject *CFTypeRefObj_CFRetain(CFTypeRefObject *_self, PyObject *_args)
128{
129 PyObject *_res = NULL;
130 CFTypeRef _rv;
131 if (!PyArg_ParseTuple(_args, ""))
132 return NULL;
133 _rv = CFRetain(_self->ob_itself);
134 _res = Py_BuildValue("O&",
135 CFTypeRefObj_New, _rv);
136 return _res;
137}
138
139static PyObject *CFTypeRefObj_CFRelease(CFTypeRefObject *_self, PyObject *_args)
140{
141 PyObject *_res = NULL;
142 if (!PyArg_ParseTuple(_args, ""))
143 return NULL;
144 CFRelease(_self->ob_itself);
145 Py_INCREF(Py_None);
146 _res = Py_None;
147 return _res;
148}
149
150static PyObject *CFTypeRefObj_CFGetRetainCount(CFTypeRefObject *_self, PyObject *_args)
151{
152 PyObject *_res = NULL;
153 CFIndex _rv;
154 if (!PyArg_ParseTuple(_args, ""))
155 return NULL;
156 _rv = CFGetRetainCount(_self->ob_itself);
157 _res = Py_BuildValue("l",
158 _rv);
159 return _res;
160}
161
162static PyObject *CFTypeRefObj_CFEqual(CFTypeRefObject *_self, PyObject *_args)
163{
164 PyObject *_res = NULL;
165 Boolean _rv;
166 CFTypeRef cf2;
167 if (!PyArg_ParseTuple(_args, "O&",
168 CFTypeRefObj_Convert, &cf2))
169 return NULL;
170 _rv = CFEqual(_self->ob_itself,
171 cf2);
172 _res = Py_BuildValue("l",
173 _rv);
174 return _res;
175}
176
177static PyObject *CFTypeRefObj_CFHash(CFTypeRefObject *_self, PyObject *_args)
178{
179 PyObject *_res = NULL;
180 CFHashCode _rv;
181 if (!PyArg_ParseTuple(_args, ""))
182 return NULL;
183 _rv = CFHash(_self->ob_itself);
184 _res = Py_BuildValue("l",
185 _rv);
186 return _res;
187}
188
189static PyObject *CFTypeRefObj_CFCopyDescription(CFTypeRefObject *_self, PyObject *_args)
190{
191 PyObject *_res = NULL;
192 CFStringRef _rv;
193 if (!PyArg_ParseTuple(_args, ""))
194 return NULL;
195 _rv = CFCopyDescription(_self->ob_itself);
196 _res = Py_BuildValue("O&",
197 CFStringRefObj_New, _rv);
198 return _res;
199}
200
Jack Jansenbc7c8962001-06-27 22:00:55 +0000201static PyObject *CFTypeRefObj_CFShow(CFTypeRefObject *_self, PyObject *_args)
202{
203 PyObject *_res = NULL;
204 if (!PyArg_ParseTuple(_args, ""))
205 return NULL;
206 CFShow(_self->ob_itself);
207 Py_INCREF(Py_None);
208 _res = Py_None;
209 return _res;
210}
211
Jack Jansen686f9c32001-06-26 21:51:18 +0000212static PyMethodDef CFTypeRefObj_methods[] = {
213 {"CFGetTypeID", (PyCFunction)CFTypeRefObj_CFGetTypeID, 1,
214 "() -> (CFTypeID _rv)"},
215 {"CFRetain", (PyCFunction)CFTypeRefObj_CFRetain, 1,
216 "() -> (CFTypeRef _rv)"},
217 {"CFRelease", (PyCFunction)CFTypeRefObj_CFRelease, 1,
218 "() -> None"},
219 {"CFGetRetainCount", (PyCFunction)CFTypeRefObj_CFGetRetainCount, 1,
220 "() -> (CFIndex _rv)"},
221 {"CFEqual", (PyCFunction)CFTypeRefObj_CFEqual, 1,
222 "(CFTypeRef cf2) -> (Boolean _rv)"},
223 {"CFHash", (PyCFunction)CFTypeRefObj_CFHash, 1,
224 "() -> (CFHashCode _rv)"},
225 {"CFCopyDescription", (PyCFunction)CFTypeRefObj_CFCopyDescription, 1,
226 "() -> (CFStringRef _rv)"},
Jack Jansenbc7c8962001-06-27 22:00:55 +0000227 {"CFShow", (PyCFunction)CFTypeRefObj_CFShow, 1,
228 "() -> None"},
Jack Jansen686f9c32001-06-26 21:51:18 +0000229 {NULL, NULL, 0}
230};
231
232PyMethodChain CFTypeRefObj_chain = { CFTypeRefObj_methods, NULL };
233
234static PyObject *CFTypeRefObj_getattr(CFTypeRefObject *self, char *name)
235{
236 return Py_FindMethodInChain(&CFTypeRefObj_chain, (PyObject *)self, name);
237}
238
239#define CFTypeRefObj_setattr NULL
240
241static int CFTypeRefObj_compare(CFTypeRefObject *self, CFTypeRefObject *other)
242{
243 /* XXXX Or should we use CFEqual?? */
244 if ( self->ob_itself > other->ob_itself ) return 1;
245 if ( self->ob_itself < other->ob_itself ) return -1;
246 return 0;
247}
248
249static PyObject * CFTypeRefObj_repr(CFTypeRefObject *self)
250{
251 char buf[100];
252 sprintf(buf, "<CFTypeRef type-%d object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself);
253 return PyString_FromString(buf);
254}
255
256static int CFTypeRefObj_hash(CFTypeRefObject *self)
257{
258 /* XXXX Or should we use CFHash?? */
259 return (int)self->ob_itself;
260}
261
262PyTypeObject CFTypeRef_Type = {
263 PyObject_HEAD_INIT(&PyType_Type)
264 0, /*ob_size*/
265 "CFTypeRef", /*tp_name*/
266 sizeof(CFTypeRefObject), /*tp_basicsize*/
267 0, /*tp_itemsize*/
268 /* methods */
269 (destructor) CFTypeRefObj_dealloc, /*tp_dealloc*/
270 0, /*tp_print*/
271 (getattrfunc) CFTypeRefObj_getattr, /*tp_getattr*/
272 (setattrfunc) CFTypeRefObj_setattr, /*tp_setattr*/
273 (cmpfunc) CFTypeRefObj_compare, /*tp_compare*/
274 (reprfunc) CFTypeRefObj_repr, /*tp_repr*/
275 (PyNumberMethods *)0, /* tp_as_number */
276 (PySequenceMethods *)0, /* tp_as_sequence */
277 (PyMappingMethods *)0, /* tp_as_mapping */
278 (hashfunc) CFTypeRefObj_hash, /*tp_hash*/
279};
280
281/* ------------------- End object type CFTypeRef -------------------- */
282
283
Jack Jansenbc7c8962001-06-27 22:00:55 +0000284/* --------------------- Object type CFArrayRef --------------------- */
285
286PyTypeObject CFArrayRef_Type;
287
288#define CFArrayRefObj_Check(x) ((x)->ob_type == &CFArrayRef_Type)
289
290typedef struct CFArrayRefObject {
291 PyObject_HEAD
292 CFArrayRef ob_itself;
293 void (*ob_freeit)(CFTypeRef ptr);
294} CFArrayRefObject;
295
296PyObject *CFArrayRefObj_New(CFArrayRef itself)
297{
298 CFArrayRefObject *it;
299 if (itself == NULL) return PyMac_Error(resNotFound);
300 CFRetain(itself);
301 it = PyObject_NEW(CFArrayRefObject, &CFArrayRef_Type);
302 if (it == NULL) return NULL;
303 it->ob_itself = itself;
304 it->ob_freeit = CFRelease;
305 return (PyObject *)it;
306}
307CFArrayRefObj_Convert(PyObject *v, CFArrayRef *p_itself)
308{
309
310 if (v == Py_None) { *p_itself = NULL; return 1; }
311 /* Check for other CF objects here */
312
313 if (!CFArrayRefObj_Check(v))
314 {
315 PyErr_SetString(PyExc_TypeError, "CFArrayRef required");
316 return 0;
317 }
318 *p_itself = ((CFArrayRefObject *)v)->ob_itself;
319 return 1;
320}
321
322static void CFArrayRefObj_dealloc(CFArrayRefObject *self)
323{
324 if (self->ob_freeit && self->ob_itself)
325 {
326 self->ob_freeit((CFTypeRef)self->ob_itself);
327 }
328 PyMem_DEL(self);
329}
330
331static PyObject *CFArrayRefObj_CFArrayGetCount(CFArrayRefObject *_self, PyObject *_args)
332{
333 PyObject *_res = NULL;
334 CFIndex _rv;
335 if (!PyArg_ParseTuple(_args, ""))
336 return NULL;
337 _rv = CFArrayGetCount(_self->ob_itself);
338 _res = Py_BuildValue("l",
339 _rv);
340 return _res;
341}
342
343static PyMethodDef CFArrayRefObj_methods[] = {
344 {"CFArrayGetCount", (PyCFunction)CFArrayRefObj_CFArrayGetCount, 1,
345 "() -> (CFIndex _rv)"},
346 {NULL, NULL, 0}
347};
348
Jack Jansen7becc912001-06-28 22:08:26 +0000349PyMethodChain CFArrayRefObj_chain = { CFArrayRefObj_methods, &CFTypeRefObj_chain };
Jack Jansenbc7c8962001-06-27 22:00:55 +0000350
351static PyObject *CFArrayRefObj_getattr(CFArrayRefObject *self, char *name)
352{
353 return Py_FindMethodInChain(&CFArrayRefObj_chain, (PyObject *)self, name);
354}
355
356#define CFArrayRefObj_setattr NULL
357
358static int CFArrayRefObj_compare(CFArrayRefObject *self, CFArrayRefObject *other)
359{
360 /* XXXX Or should we use CFEqual?? */
361 if ( self->ob_itself > other->ob_itself ) return 1;
362 if ( self->ob_itself < other->ob_itself ) return -1;
363 return 0;
364}
365
366static PyObject * CFArrayRefObj_repr(CFArrayRefObject *self)
367{
368 char buf[100];
Jack Jansen7becc912001-06-28 22:08:26 +0000369 sprintf(buf, "<CFArrayRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself);
Jack Jansenbc7c8962001-06-27 22:00:55 +0000370 return PyString_FromString(buf);
371}
372
373static int CFArrayRefObj_hash(CFArrayRefObject *self)
374{
375 /* XXXX Or should we use CFHash?? */
376 return (int)self->ob_itself;
377}
378
379PyTypeObject CFArrayRef_Type = {
380 PyObject_HEAD_INIT(&PyType_Type)
381 0, /*ob_size*/
382 "CFArrayRef", /*tp_name*/
383 sizeof(CFArrayRefObject), /*tp_basicsize*/
384 0, /*tp_itemsize*/
385 /* methods */
386 (destructor) CFArrayRefObj_dealloc, /*tp_dealloc*/
387 0, /*tp_print*/
388 (getattrfunc) CFArrayRefObj_getattr, /*tp_getattr*/
389 (setattrfunc) CFArrayRefObj_setattr, /*tp_setattr*/
390 (cmpfunc) CFArrayRefObj_compare, /*tp_compare*/
391 (reprfunc) CFArrayRefObj_repr, /*tp_repr*/
392 (PyNumberMethods *)0, /* tp_as_number */
393 (PySequenceMethods *)0, /* tp_as_sequence */
394 (PyMappingMethods *)0, /* tp_as_mapping */
395 (hashfunc) CFArrayRefObj_hash, /*tp_hash*/
396};
397
398/* ------------------- End object type CFArrayRef ------------------- */
399
400
401/* ----------------- Object type CFMutableArrayRef ------------------ */
402
403PyTypeObject CFMutableArrayRef_Type;
404
405#define CFMutableArrayRefObj_Check(x) ((x)->ob_type == &CFMutableArrayRef_Type)
406
407typedef struct CFMutableArrayRefObject {
408 PyObject_HEAD
409 CFMutableArrayRef ob_itself;
410 void (*ob_freeit)(CFTypeRef ptr);
411} CFMutableArrayRefObject;
412
413PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef itself)
414{
415 CFMutableArrayRefObject *it;
416 if (itself == NULL) return PyMac_Error(resNotFound);
417 CFRetain(itself);
418 it = PyObject_NEW(CFMutableArrayRefObject, &CFMutableArrayRef_Type);
419 if (it == NULL) return NULL;
420 it->ob_itself = itself;
421 it->ob_freeit = CFRelease;
422 return (PyObject *)it;
423}
424CFMutableArrayRefObj_Convert(PyObject *v, CFMutableArrayRef *p_itself)
425{
426
427 if (v == Py_None) { *p_itself = NULL; return 1; }
428 /* Check for other CF objects here */
429
430 if (!CFMutableArrayRefObj_Check(v))
431 {
432 PyErr_SetString(PyExc_TypeError, "CFMutableArrayRef required");
433 return 0;
434 }
435 *p_itself = ((CFMutableArrayRefObject *)v)->ob_itself;
436 return 1;
437}
438
439static void CFMutableArrayRefObj_dealloc(CFMutableArrayRefObject *self)
440{
441 if (self->ob_freeit && self->ob_itself)
442 {
443 self->ob_freeit((CFTypeRef)self->ob_itself);
444 }
445 PyMem_DEL(self);
446}
447
448static PyObject *CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRefObject *_self, PyObject *_args)
449{
450 PyObject *_res = NULL;
451 CFIndex idx;
452 if (!PyArg_ParseTuple(_args, "l",
453 &idx))
454 return NULL;
455 CFArrayRemoveValueAtIndex(_self->ob_itself,
456 idx);
457 Py_INCREF(Py_None);
458 _res = Py_None;
459 return _res;
460}
461
462static PyObject *CFMutableArrayRefObj_CFArrayRemoveAllValues(CFMutableArrayRefObject *_self, PyObject *_args)
463{
464 PyObject *_res = NULL;
465 if (!PyArg_ParseTuple(_args, ""))
466 return NULL;
467 CFArrayRemoveAllValues(_self->ob_itself);
468 Py_INCREF(Py_None);
469 _res = Py_None;
470 return _res;
471}
472
473static PyObject *CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices(CFMutableArrayRefObject *_self, PyObject *_args)
474{
475 PyObject *_res = NULL;
476 CFIndex idx1;
477 CFIndex idx2;
478 if (!PyArg_ParseTuple(_args, "ll",
479 &idx1,
480 &idx2))
481 return NULL;
482 CFArrayExchangeValuesAtIndices(_self->ob_itself,
483 idx1,
484 idx2);
485 Py_INCREF(Py_None);
486 _res = Py_None;
487 return _res;
488}
489
490static PyMethodDef CFMutableArrayRefObj_methods[] = {
491 {"CFArrayRemoveValueAtIndex", (PyCFunction)CFMutableArrayRefObj_CFArrayRemoveValueAtIndex, 1,
492 "(CFIndex idx) -> None"},
493 {"CFArrayRemoveAllValues", (PyCFunction)CFMutableArrayRefObj_CFArrayRemoveAllValues, 1,
494 "() -> None"},
495 {"CFArrayExchangeValuesAtIndices", (PyCFunction)CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices, 1,
496 "(CFIndex idx1, CFIndex idx2) -> None"},
497 {NULL, NULL, 0}
498};
499
Jack Jansen7becc912001-06-28 22:08:26 +0000500PyMethodChain CFMutableArrayRefObj_chain = { CFMutableArrayRefObj_methods, &CFArrayRefObj_chain };
Jack Jansenbc7c8962001-06-27 22:00:55 +0000501
502static PyObject *CFMutableArrayRefObj_getattr(CFMutableArrayRefObject *self, char *name)
503{
504 return Py_FindMethodInChain(&CFMutableArrayRefObj_chain, (PyObject *)self, name);
505}
506
507#define CFMutableArrayRefObj_setattr NULL
508
509static int CFMutableArrayRefObj_compare(CFMutableArrayRefObject *self, CFMutableArrayRefObject *other)
510{
511 /* XXXX Or should we use CFEqual?? */
512 if ( self->ob_itself > other->ob_itself ) return 1;
513 if ( self->ob_itself < other->ob_itself ) return -1;
514 return 0;
515}
516
517static PyObject * CFMutableArrayRefObj_repr(CFMutableArrayRefObject *self)
518{
519 char buf[100];
Jack Jansen7becc912001-06-28 22:08:26 +0000520 sprintf(buf, "<CFMutableArrayRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself);
Jack Jansenbc7c8962001-06-27 22:00:55 +0000521 return PyString_FromString(buf);
522}
523
524static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject *self)
525{
526 /* XXXX Or should we use CFHash?? */
527 return (int)self->ob_itself;
528}
529
530PyTypeObject CFMutableArrayRef_Type = {
531 PyObject_HEAD_INIT(&PyType_Type)
532 0, /*ob_size*/
533 "CFMutableArrayRef", /*tp_name*/
534 sizeof(CFMutableArrayRefObject), /*tp_basicsize*/
535 0, /*tp_itemsize*/
536 /* methods */
537 (destructor) CFMutableArrayRefObj_dealloc, /*tp_dealloc*/
538 0, /*tp_print*/
539 (getattrfunc) CFMutableArrayRefObj_getattr, /*tp_getattr*/
540 (setattrfunc) CFMutableArrayRefObj_setattr, /*tp_setattr*/
541 (cmpfunc) CFMutableArrayRefObj_compare, /*tp_compare*/
542 (reprfunc) CFMutableArrayRefObj_repr, /*tp_repr*/
543 (PyNumberMethods *)0, /* tp_as_number */
544 (PySequenceMethods *)0, /* tp_as_sequence */
545 (PyMappingMethods *)0, /* tp_as_mapping */
546 (hashfunc) CFMutableArrayRefObj_hash, /*tp_hash*/
547};
548
549/* --------------- End object type CFMutableArrayRef ---------------- */
550
551
552/* ------------------ Object type CFDictionaryRef ------------------- */
553
554PyTypeObject CFDictionaryRef_Type;
555
556#define CFDictionaryRefObj_Check(x) ((x)->ob_type == &CFDictionaryRef_Type)
557
558typedef struct CFDictionaryRefObject {
559 PyObject_HEAD
560 CFDictionaryRef ob_itself;
561 void (*ob_freeit)(CFTypeRef ptr);
562} CFDictionaryRefObject;
563
564PyObject *CFDictionaryRefObj_New(CFDictionaryRef itself)
565{
566 CFDictionaryRefObject *it;
567 if (itself == NULL) return PyMac_Error(resNotFound);
568 CFRetain(itself);
569 it = PyObject_NEW(CFDictionaryRefObject, &CFDictionaryRef_Type);
570 if (it == NULL) return NULL;
571 it->ob_itself = itself;
572 it->ob_freeit = CFRelease;
573 return (PyObject *)it;
574}
575CFDictionaryRefObj_Convert(PyObject *v, CFDictionaryRef *p_itself)
576{
577
578 if (v == Py_None) { *p_itself = NULL; return 1; }
579 /* Check for other CF objects here */
580
581 if (!CFDictionaryRefObj_Check(v))
582 {
583 PyErr_SetString(PyExc_TypeError, "CFDictionaryRef required");
584 return 0;
585 }
586 *p_itself = ((CFDictionaryRefObject *)v)->ob_itself;
587 return 1;
588}
589
590static void CFDictionaryRefObj_dealloc(CFDictionaryRefObject *self)
591{
592 if (self->ob_freeit && self->ob_itself)
593 {
594 self->ob_freeit((CFTypeRef)self->ob_itself);
595 }
596 PyMem_DEL(self);
597}
598
599static PyObject *CFDictionaryRefObj_CFDictionaryGetCount(CFDictionaryRefObject *_self, PyObject *_args)
600{
601 PyObject *_res = NULL;
602 CFIndex _rv;
603 if (!PyArg_ParseTuple(_args, ""))
604 return NULL;
605 _rv = CFDictionaryGetCount(_self->ob_itself);
606 _res = Py_BuildValue("l",
607 _rv);
608 return _res;
609}
610
611static PyMethodDef CFDictionaryRefObj_methods[] = {
612 {"CFDictionaryGetCount", (PyCFunction)CFDictionaryRefObj_CFDictionaryGetCount, 1,
613 "() -> (CFIndex _rv)"},
614 {NULL, NULL, 0}
615};
616
Jack Jansen7becc912001-06-28 22:08:26 +0000617PyMethodChain CFDictionaryRefObj_chain = { CFDictionaryRefObj_methods, &CFTypeRefObj_chain };
Jack Jansenbc7c8962001-06-27 22:00:55 +0000618
619static PyObject *CFDictionaryRefObj_getattr(CFDictionaryRefObject *self, char *name)
620{
621 return Py_FindMethodInChain(&CFDictionaryRefObj_chain, (PyObject *)self, name);
622}
623
624#define CFDictionaryRefObj_setattr NULL
625
626static int CFDictionaryRefObj_compare(CFDictionaryRefObject *self, CFDictionaryRefObject *other)
627{
628 /* XXXX Or should we use CFEqual?? */
629 if ( self->ob_itself > other->ob_itself ) return 1;
630 if ( self->ob_itself < other->ob_itself ) return -1;
631 return 0;
632}
633
634static PyObject * CFDictionaryRefObj_repr(CFDictionaryRefObject *self)
635{
636 char buf[100];
Jack Jansen7becc912001-06-28 22:08:26 +0000637 sprintf(buf, "<CFDictionaryRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself);
Jack Jansenbc7c8962001-06-27 22:00:55 +0000638 return PyString_FromString(buf);
639}
640
641static int CFDictionaryRefObj_hash(CFDictionaryRefObject *self)
642{
643 /* XXXX Or should we use CFHash?? */
644 return (int)self->ob_itself;
645}
646
647PyTypeObject CFDictionaryRef_Type = {
648 PyObject_HEAD_INIT(&PyType_Type)
649 0, /*ob_size*/
650 "CFDictionaryRef", /*tp_name*/
651 sizeof(CFDictionaryRefObject), /*tp_basicsize*/
652 0, /*tp_itemsize*/
653 /* methods */
654 (destructor) CFDictionaryRefObj_dealloc, /*tp_dealloc*/
655 0, /*tp_print*/
656 (getattrfunc) CFDictionaryRefObj_getattr, /*tp_getattr*/
657 (setattrfunc) CFDictionaryRefObj_setattr, /*tp_setattr*/
658 (cmpfunc) CFDictionaryRefObj_compare, /*tp_compare*/
659 (reprfunc) CFDictionaryRefObj_repr, /*tp_repr*/
660 (PyNumberMethods *)0, /* tp_as_number */
661 (PySequenceMethods *)0, /* tp_as_sequence */
662 (PyMappingMethods *)0, /* tp_as_mapping */
663 (hashfunc) CFDictionaryRefObj_hash, /*tp_hash*/
664};
665
666/* ---------------- End object type CFDictionaryRef ----------------- */
667
668
669/* --------------- Object type CFMutableDictionaryRef --------------- */
670
671PyTypeObject CFMutableDictionaryRef_Type;
672
673#define CFMutableDictionaryRefObj_Check(x) ((x)->ob_type == &CFMutableDictionaryRef_Type)
674
675typedef struct CFMutableDictionaryRefObject {
676 PyObject_HEAD
677 CFMutableDictionaryRef ob_itself;
678 void (*ob_freeit)(CFTypeRef ptr);
679} CFMutableDictionaryRefObject;
680
681PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef itself)
682{
683 CFMutableDictionaryRefObject *it;
684 if (itself == NULL) return PyMac_Error(resNotFound);
685 CFRetain(itself);
686 it = PyObject_NEW(CFMutableDictionaryRefObject, &CFMutableDictionaryRef_Type);
687 if (it == NULL) return NULL;
688 it->ob_itself = itself;
689 it->ob_freeit = CFRelease;
690 return (PyObject *)it;
691}
692CFMutableDictionaryRefObj_Convert(PyObject *v, CFMutableDictionaryRef *p_itself)
693{
694
695 if (v == Py_None) { *p_itself = NULL; return 1; }
696 /* Check for other CF objects here */
697
698 if (!CFMutableDictionaryRefObj_Check(v))
699 {
700 PyErr_SetString(PyExc_TypeError, "CFMutableDictionaryRef required");
701 return 0;
702 }
703 *p_itself = ((CFMutableDictionaryRefObject *)v)->ob_itself;
704 return 1;
705}
706
707static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject *self)
708{
709 if (self->ob_freeit && self->ob_itself)
710 {
711 self->ob_freeit((CFTypeRef)self->ob_itself);
712 }
713 PyMem_DEL(self);
714}
715
716static PyObject *CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject *_self, PyObject *_args)
717{
718 PyObject *_res = NULL;
719 if (!PyArg_ParseTuple(_args, ""))
720 return NULL;
721 CFDictionaryRemoveAllValues(_self->ob_itself);
722 Py_INCREF(Py_None);
723 _res = Py_None;
724 return _res;
725}
726
727static PyMethodDef CFMutableDictionaryRefObj_methods[] = {
728 {"CFDictionaryRemoveAllValues", (PyCFunction)CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues, 1,
729 "() -> None"},
730 {NULL, NULL, 0}
731};
732
Jack Jansen7becc912001-06-28 22:08:26 +0000733PyMethodChain CFMutableDictionaryRefObj_chain = { CFMutableDictionaryRefObj_methods, &CFDictionaryRefObj_chain };
Jack Jansenbc7c8962001-06-27 22:00:55 +0000734
735static PyObject *CFMutableDictionaryRefObj_getattr(CFMutableDictionaryRefObject *self, char *name)
736{
737 return Py_FindMethodInChain(&CFMutableDictionaryRefObj_chain, (PyObject *)self, name);
738}
739
740#define CFMutableDictionaryRefObj_setattr NULL
741
742static int CFMutableDictionaryRefObj_compare(CFMutableDictionaryRefObject *self, CFMutableDictionaryRefObject *other)
743{
744 /* XXXX Or should we use CFEqual?? */
745 if ( self->ob_itself > other->ob_itself ) return 1;
746 if ( self->ob_itself < other->ob_itself ) return -1;
747 return 0;
748}
749
750static PyObject * CFMutableDictionaryRefObj_repr(CFMutableDictionaryRefObject *self)
751{
752 char buf[100];
Jack Jansen7becc912001-06-28 22:08:26 +0000753 sprintf(buf, "<CFMutableDictionaryRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself);
Jack Jansenbc7c8962001-06-27 22:00:55 +0000754 return PyString_FromString(buf);
755}
756
757static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject *self)
758{
759 /* XXXX Or should we use CFHash?? */
760 return (int)self->ob_itself;
761}
762
763PyTypeObject CFMutableDictionaryRef_Type = {
764 PyObject_HEAD_INIT(&PyType_Type)
765 0, /*ob_size*/
766 "CFMutableDictionaryRef", /*tp_name*/
767 sizeof(CFMutableDictionaryRefObject), /*tp_basicsize*/
768 0, /*tp_itemsize*/
769 /* methods */
770 (destructor) CFMutableDictionaryRefObj_dealloc, /*tp_dealloc*/
771 0, /*tp_print*/
772 (getattrfunc) CFMutableDictionaryRefObj_getattr, /*tp_getattr*/
773 (setattrfunc) CFMutableDictionaryRefObj_setattr, /*tp_setattr*/
774 (cmpfunc) CFMutableDictionaryRefObj_compare, /*tp_compare*/
775 (reprfunc) CFMutableDictionaryRefObj_repr, /*tp_repr*/
776 (PyNumberMethods *)0, /* tp_as_number */
777 (PySequenceMethods *)0, /* tp_as_sequence */
778 (PyMappingMethods *)0, /* tp_as_mapping */
779 (hashfunc) CFMutableDictionaryRefObj_hash, /*tp_hash*/
780};
781
782/* ------------- End object type CFMutableDictionaryRef ------------- */
783
784
785/* --------------------- Object type CFDataRef ---------------------- */
786
787PyTypeObject CFDataRef_Type;
788
789#define CFDataRefObj_Check(x) ((x)->ob_type == &CFDataRef_Type)
790
791typedef struct CFDataRefObject {
792 PyObject_HEAD
793 CFDataRef ob_itself;
794 void (*ob_freeit)(CFTypeRef ptr);
795} CFDataRefObject;
796
797PyObject *CFDataRefObj_New(CFDataRef itself)
798{
799 CFDataRefObject *it;
800 if (itself == NULL) return PyMac_Error(resNotFound);
801 CFRetain(itself);
802 it = PyObject_NEW(CFDataRefObject, &CFDataRef_Type);
803 if (it == NULL) return NULL;
804 it->ob_itself = itself;
805 it->ob_freeit = CFRelease;
806 return (PyObject *)it;
807}
808CFDataRefObj_Convert(PyObject *v, CFDataRef *p_itself)
809{
810
811 if (v == Py_None) { *p_itself = NULL; return 1; }
812 /* Check for other CF objects here */
813
814 if (!CFDataRefObj_Check(v))
815 {
816 PyErr_SetString(PyExc_TypeError, "CFDataRef required");
817 return 0;
818 }
819 *p_itself = ((CFDataRefObject *)v)->ob_itself;
820 return 1;
821}
822
823static void CFDataRefObj_dealloc(CFDataRefObject *self)
824{
825 if (self->ob_freeit && self->ob_itself)
826 {
827 self->ob_freeit((CFTypeRef)self->ob_itself);
828 }
829 PyMem_DEL(self);
830}
831
832static PyObject *CFDataRefObj_CFDataGetLength(CFDataRefObject *_self, PyObject *_args)
833{
834 PyObject *_res = NULL;
835 CFIndex _rv;
836 if (!PyArg_ParseTuple(_args, ""))
837 return NULL;
838 _rv = CFDataGetLength(_self->ob_itself);
839 _res = Py_BuildValue("l",
840 _rv);
841 return _res;
842}
843
844static PyMethodDef CFDataRefObj_methods[] = {
845 {"CFDataGetLength", (PyCFunction)CFDataRefObj_CFDataGetLength, 1,
846 "() -> (CFIndex _rv)"},
847 {NULL, NULL, 0}
848};
849
Jack Jansen7becc912001-06-28 22:08:26 +0000850PyMethodChain CFDataRefObj_chain = { CFDataRefObj_methods, &CFTypeRefObj_chain };
Jack Jansenbc7c8962001-06-27 22:00:55 +0000851
852static PyObject *CFDataRefObj_getattr(CFDataRefObject *self, char *name)
853{
854 return Py_FindMethodInChain(&CFDataRefObj_chain, (PyObject *)self, name);
855}
856
857#define CFDataRefObj_setattr NULL
858
859static int CFDataRefObj_compare(CFDataRefObject *self, CFDataRefObject *other)
860{
861 /* XXXX Or should we use CFEqual?? */
862 if ( self->ob_itself > other->ob_itself ) return 1;
863 if ( self->ob_itself < other->ob_itself ) return -1;
864 return 0;
865}
866
867static PyObject * CFDataRefObj_repr(CFDataRefObject *self)
868{
869 char buf[100];
Jack Jansen7becc912001-06-28 22:08:26 +0000870 sprintf(buf, "<CFDataRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself);
Jack Jansenbc7c8962001-06-27 22:00:55 +0000871 return PyString_FromString(buf);
872}
873
874static int CFDataRefObj_hash(CFDataRefObject *self)
875{
876 /* XXXX Or should we use CFHash?? */
877 return (int)self->ob_itself;
878}
879
880PyTypeObject CFDataRef_Type = {
881 PyObject_HEAD_INIT(&PyType_Type)
882 0, /*ob_size*/
883 "CFDataRef", /*tp_name*/
884 sizeof(CFDataRefObject), /*tp_basicsize*/
885 0, /*tp_itemsize*/
886 /* methods */
887 (destructor) CFDataRefObj_dealloc, /*tp_dealloc*/
888 0, /*tp_print*/
889 (getattrfunc) CFDataRefObj_getattr, /*tp_getattr*/
890 (setattrfunc) CFDataRefObj_setattr, /*tp_setattr*/
891 (cmpfunc) CFDataRefObj_compare, /*tp_compare*/
892 (reprfunc) CFDataRefObj_repr, /*tp_repr*/
893 (PyNumberMethods *)0, /* tp_as_number */
894 (PySequenceMethods *)0, /* tp_as_sequence */
895 (PyMappingMethods *)0, /* tp_as_mapping */
896 (hashfunc) CFDataRefObj_hash, /*tp_hash*/
897};
898
899/* ------------------- End object type CFDataRef -------------------- */
900
901
902/* ------------------ Object type CFMutableDataRef ------------------ */
903
904PyTypeObject CFMutableDataRef_Type;
905
906#define CFMutableDataRefObj_Check(x) ((x)->ob_type == &CFMutableDataRef_Type)
907
908typedef struct CFMutableDataRefObject {
909 PyObject_HEAD
910 CFMutableDataRef ob_itself;
911 void (*ob_freeit)(CFTypeRef ptr);
912} CFMutableDataRefObject;
913
914PyObject *CFMutableDataRefObj_New(CFMutableDataRef itself)
915{
916 CFMutableDataRefObject *it;
917 if (itself == NULL) return PyMac_Error(resNotFound);
918 CFRetain(itself);
919 it = PyObject_NEW(CFMutableDataRefObject, &CFMutableDataRef_Type);
920 if (it == NULL) return NULL;
921 it->ob_itself = itself;
922 it->ob_freeit = CFRelease;
923 return (PyObject *)it;
924}
925CFMutableDataRefObj_Convert(PyObject *v, CFMutableDataRef *p_itself)
926{
927
928 if (v == Py_None) { *p_itself = NULL; return 1; }
929 /* Check for other CF objects here */
930
931 if (!CFMutableDataRefObj_Check(v))
932 {
933 PyErr_SetString(PyExc_TypeError, "CFMutableDataRef required");
934 return 0;
935 }
936 *p_itself = ((CFMutableDataRefObject *)v)->ob_itself;
937 return 1;
938}
939
940static void CFMutableDataRefObj_dealloc(CFMutableDataRefObject *self)
941{
942 if (self->ob_freeit && self->ob_itself)
943 {
944 self->ob_freeit((CFTypeRef)self->ob_itself);
945 }
946 PyMem_DEL(self);
947}
948
949static PyObject *CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject *_self, PyObject *_args)
950{
951 PyObject *_res = NULL;
952 CFIndex length;
953 if (!PyArg_ParseTuple(_args, "l",
954 &length))
955 return NULL;
956 CFDataSetLength(_self->ob_itself,
957 length);
958 Py_INCREF(Py_None);
959 _res = Py_None;
960 return _res;
961}
962
963static PyObject *CFMutableDataRefObj_CFDataIncreaseLength(CFMutableDataRefObject *_self, PyObject *_args)
964{
965 PyObject *_res = NULL;
966 CFIndex extraLength;
967 if (!PyArg_ParseTuple(_args, "l",
968 &extraLength))
969 return NULL;
970 CFDataIncreaseLength(_self->ob_itself,
971 extraLength);
972 Py_INCREF(Py_None);
973 _res = Py_None;
974 return _res;
975}
976
977static PyObject *CFMutableDataRefObj_CFDataAppendBytes(CFMutableDataRefObject *_self, PyObject *_args)
978{
979 PyObject *_res = NULL;
980 unsigned char *bytes__in__;
981 long bytes__len__;
982 int bytes__in_len__;
983 if (!PyArg_ParseTuple(_args, "s#",
984 &bytes__in__, &bytes__in_len__))
985 return NULL;
986 bytes__len__ = bytes__in_len__;
987 CFDataAppendBytes(_self->ob_itself,
988 bytes__in__, bytes__len__);
989 Py_INCREF(Py_None);
990 _res = Py_None;
991 bytes__error__: ;
992 return _res;
993}
994
995static PyObject *CFMutableDataRefObj_CFDataReplaceBytes(CFMutableDataRefObject *_self, PyObject *_args)
996{
997 PyObject *_res = NULL;
998 CFRange range;
999 unsigned char *newBytes__in__;
1000 long newBytes__len__;
1001 int newBytes__in_len__;
1002 if (!PyArg_ParseTuple(_args, "O&s#",
1003 CFRange_Convert, &range,
1004 &newBytes__in__, &newBytes__in_len__))
1005 return NULL;
1006 newBytes__len__ = newBytes__in_len__;
1007 CFDataReplaceBytes(_self->ob_itself,
1008 range,
1009 newBytes__in__, newBytes__len__);
1010 Py_INCREF(Py_None);
1011 _res = Py_None;
1012 newBytes__error__: ;
1013 return _res;
1014}
1015
1016static PyObject *CFMutableDataRefObj_CFDataDeleteBytes(CFMutableDataRefObject *_self, PyObject *_args)
1017{
1018 PyObject *_res = NULL;
1019 CFRange range;
1020 if (!PyArg_ParseTuple(_args, "O&",
1021 CFRange_Convert, &range))
1022 return NULL;
1023 CFDataDeleteBytes(_self->ob_itself,
1024 range);
1025 Py_INCREF(Py_None);
1026 _res = Py_None;
1027 return _res;
1028}
1029
1030static PyMethodDef CFMutableDataRefObj_methods[] = {
1031 {"CFDataSetLength", (PyCFunction)CFMutableDataRefObj_CFDataSetLength, 1,
1032 "(CFIndex length) -> None"},
1033 {"CFDataIncreaseLength", (PyCFunction)CFMutableDataRefObj_CFDataIncreaseLength, 1,
1034 "(CFIndex extraLength) -> None"},
1035 {"CFDataAppendBytes", (PyCFunction)CFMutableDataRefObj_CFDataAppendBytes, 1,
1036 "(Buffer bytes) -> None"},
1037 {"CFDataReplaceBytes", (PyCFunction)CFMutableDataRefObj_CFDataReplaceBytes, 1,
1038 "(CFRange range, Buffer newBytes) -> None"},
1039 {"CFDataDeleteBytes", (PyCFunction)CFMutableDataRefObj_CFDataDeleteBytes, 1,
1040 "(CFRange range) -> None"},
1041 {NULL, NULL, 0}
1042};
1043
Jack Jansen7becc912001-06-28 22:08:26 +00001044PyMethodChain CFMutableDataRefObj_chain = { CFMutableDataRefObj_methods, &CFDataRefObj_chain };
Jack Jansenbc7c8962001-06-27 22:00:55 +00001045
1046static PyObject *CFMutableDataRefObj_getattr(CFMutableDataRefObject *self, char *name)
1047{
1048 return Py_FindMethodInChain(&CFMutableDataRefObj_chain, (PyObject *)self, name);
1049}
1050
1051#define CFMutableDataRefObj_setattr NULL
1052
1053static int CFMutableDataRefObj_compare(CFMutableDataRefObject *self, CFMutableDataRefObject *other)
1054{
1055 /* XXXX Or should we use CFEqual?? */
1056 if ( self->ob_itself > other->ob_itself ) return 1;
1057 if ( self->ob_itself < other->ob_itself ) return -1;
1058 return 0;
1059}
1060
1061static PyObject * CFMutableDataRefObj_repr(CFMutableDataRefObject *self)
1062{
1063 char buf[100];
Jack Jansen7becc912001-06-28 22:08:26 +00001064 sprintf(buf, "<CFMutableDataRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself);
Jack Jansenbc7c8962001-06-27 22:00:55 +00001065 return PyString_FromString(buf);
1066}
1067
1068static int CFMutableDataRefObj_hash(CFMutableDataRefObject *self)
1069{
1070 /* XXXX Or should we use CFHash?? */
1071 return (int)self->ob_itself;
1072}
1073
1074PyTypeObject CFMutableDataRef_Type = {
1075 PyObject_HEAD_INIT(&PyType_Type)
1076 0, /*ob_size*/
1077 "CFMutableDataRef", /*tp_name*/
1078 sizeof(CFMutableDataRefObject), /*tp_basicsize*/
1079 0, /*tp_itemsize*/
1080 /* methods */
1081 (destructor) CFMutableDataRefObj_dealloc, /*tp_dealloc*/
1082 0, /*tp_print*/
1083 (getattrfunc) CFMutableDataRefObj_getattr, /*tp_getattr*/
1084 (setattrfunc) CFMutableDataRefObj_setattr, /*tp_setattr*/
1085 (cmpfunc) CFMutableDataRefObj_compare, /*tp_compare*/
1086 (reprfunc) CFMutableDataRefObj_repr, /*tp_repr*/
1087 (PyNumberMethods *)0, /* tp_as_number */
1088 (PySequenceMethods *)0, /* tp_as_sequence */
1089 (PyMappingMethods *)0, /* tp_as_mapping */
1090 (hashfunc) CFMutableDataRefObj_hash, /*tp_hash*/
1091};
1092
1093/* ---------------- End object type CFMutableDataRef ---------------- */
1094
1095
Jack Jansen686f9c32001-06-26 21:51:18 +00001096/* -------------------- Object type CFStringRef --------------------- */
1097
1098PyTypeObject CFStringRef_Type;
1099
1100#define CFStringRefObj_Check(x) ((x)->ob_type == &CFStringRef_Type)
1101
1102typedef struct CFStringRefObject {
1103 PyObject_HEAD
1104 CFStringRef ob_itself;
1105 void (*ob_freeit)(CFTypeRef ptr);
1106} CFStringRefObject;
1107
1108PyObject *CFStringRefObj_New(CFStringRef itself)
1109{
1110 CFStringRefObject *it;
1111 if (itself == NULL) return PyMac_Error(resNotFound);
1112 CFRetain(itself);
1113 it = PyObject_NEW(CFStringRefObject, &CFStringRef_Type);
1114 if (it == NULL) return NULL;
1115 it->ob_itself = itself;
1116 it->ob_freeit = CFRelease;
1117 return (PyObject *)it;
1118}
1119CFStringRefObj_Convert(PyObject *v, CFStringRef *p_itself)
1120{
1121
1122 if (v == Py_None) { *p_itself = NULL; return 1; }
1123 /* Check for other CF objects here */
1124
1125 if (!CFStringRefObj_Check(v))
1126 {
1127 PyErr_SetString(PyExc_TypeError, "CFStringRef required");
1128 return 0;
1129 }
1130 *p_itself = ((CFStringRefObject *)v)->ob_itself;
1131 return 1;
1132}
1133
1134static void CFStringRefObj_dealloc(CFStringRefObject *self)
1135{
1136 if (self->ob_freeit && self->ob_itself)
1137 {
1138 self->ob_freeit((CFTypeRef)self->ob_itself);
1139 }
1140 PyMem_DEL(self);
1141}
1142
Jack Jansenbc7c8962001-06-27 22:00:55 +00001143static PyObject *CFStringRefObj_CFStringGetLength(CFStringRefObject *_self, PyObject *_args)
1144{
1145 PyObject *_res = NULL;
1146 CFIndex _rv;
1147 if (!PyArg_ParseTuple(_args, ""))
1148 return NULL;
1149 _rv = CFStringGetLength(_self->ob_itself);
1150 _res = Py_BuildValue("l",
1151 _rv);
1152 return _res;
1153}
1154
1155static PyObject *CFStringRefObj_CFStringGetCString(CFStringRefObject *_self, PyObject *_args)
1156{
1157 PyObject *_res = NULL;
1158 Boolean _rv;
1159 char buffer;
1160 CFIndex bufferSize;
1161 CFStringEncoding encoding;
1162 if (!PyArg_ParseTuple(_args, "ll",
1163 &bufferSize,
1164 &encoding))
1165 return NULL;
1166 _rv = CFStringGetCString(_self->ob_itself,
1167 &buffer,
1168 bufferSize,
1169 encoding);
1170 _res = Py_BuildValue("lc",
1171 _rv,
1172 buffer);
1173 return _res;
1174}
1175
1176static PyObject *CFStringRefObj_CFStringGetBytes(CFStringRefObject *_self, PyObject *_args)
1177{
1178 PyObject *_res = NULL;
1179 CFIndex _rv;
1180 CFRange range;
1181 CFStringEncoding encoding;
1182 UInt8 lossByte;
1183 Boolean isExternalRepresentation;
1184 UInt8 buffer;
1185 CFIndex maxBufLen;
1186 CFIndex usedBufLen;
1187 if (!PyArg_ParseTuple(_args, "O&lbll",
1188 CFRange_Convert, &range,
1189 &encoding,
1190 &lossByte,
1191 &isExternalRepresentation,
1192 &maxBufLen))
1193 return NULL;
1194 _rv = CFStringGetBytes(_self->ob_itself,
1195 range,
1196 encoding,
1197 lossByte,
1198 isExternalRepresentation,
1199 &buffer,
1200 maxBufLen,
1201 &usedBufLen);
1202 _res = Py_BuildValue("lbl",
1203 _rv,
1204 buffer,
1205 usedBufLen);
1206 return _res;
1207}
1208
1209static PyObject *CFStringRefObj_CFStringGetSmallestEncoding(CFStringRefObject *_self, PyObject *_args)
1210{
1211 PyObject *_res = NULL;
1212 CFStringEncoding _rv;
1213 if (!PyArg_ParseTuple(_args, ""))
1214 return NULL;
1215 _rv = CFStringGetSmallestEncoding(_self->ob_itself);
1216 _res = Py_BuildValue("l",
1217 _rv);
1218 return _res;
1219}
1220
1221static PyObject *CFStringRefObj_CFStringGetFastestEncoding(CFStringRefObject *_self, PyObject *_args)
1222{
1223 PyObject *_res = NULL;
1224 CFStringEncoding _rv;
1225 if (!PyArg_ParseTuple(_args, ""))
1226 return NULL;
1227 _rv = CFStringGetFastestEncoding(_self->ob_itself);
1228 _res = Py_BuildValue("l",
1229 _rv);
1230 return _res;
1231}
1232
1233static PyObject *CFStringRefObj_CFStringCompareWithOptions(CFStringRefObject *_self, PyObject *_args)
1234{
1235 PyObject *_res = NULL;
1236 CFComparisonResult _rv;
1237 CFStringRef string2;
1238 CFRange rangeToCompare;
1239 CFOptionFlags compareOptions;
1240 if (!PyArg_ParseTuple(_args, "O&O&l",
1241 CFStringRefObj_Convert, &string2,
1242 CFRange_Convert, &rangeToCompare,
1243 &compareOptions))
1244 return NULL;
1245 _rv = CFStringCompareWithOptions(_self->ob_itself,
1246 string2,
1247 rangeToCompare,
1248 compareOptions);
1249 _res = Py_BuildValue("l",
1250 _rv);
1251 return _res;
1252}
1253
1254static PyObject *CFStringRefObj_CFStringCompare(CFStringRefObject *_self, PyObject *_args)
1255{
1256 PyObject *_res = NULL;
1257 CFComparisonResult _rv;
1258 CFStringRef string2;
1259 CFOptionFlags compareOptions;
1260 if (!PyArg_ParseTuple(_args, "O&l",
1261 CFStringRefObj_Convert, &string2,
1262 &compareOptions))
1263 return NULL;
1264 _rv = CFStringCompare(_self->ob_itself,
1265 string2,
1266 compareOptions);
1267 _res = Py_BuildValue("l",
1268 _rv);
1269 return _res;
1270}
1271
1272static PyObject *CFStringRefObj_CFStringFindWithOptions(CFStringRefObject *_self, PyObject *_args)
1273{
1274 PyObject *_res = NULL;
1275 Boolean _rv;
1276 CFStringRef stringToFind;
1277 CFRange rangeToSearch;
1278 CFOptionFlags searchOptions;
1279 CFRange result;
1280 if (!PyArg_ParseTuple(_args, "O&O&l",
1281 CFStringRefObj_Convert, &stringToFind,
1282 CFRange_Convert, &rangeToSearch,
1283 &searchOptions))
1284 return NULL;
1285 _rv = CFStringFindWithOptions(_self->ob_itself,
1286 stringToFind,
1287 rangeToSearch,
1288 searchOptions,
1289 &result);
1290 _res = Py_BuildValue("lO&",
1291 _rv,
1292 CFRange_New, result);
1293 return _res;
1294}
1295
1296static PyObject *CFStringRefObj_CFStringFind(CFStringRefObject *_self, PyObject *_args)
1297{
1298 PyObject *_res = NULL;
1299 CFRange _rv;
1300 CFStringRef stringToFind;
1301 CFOptionFlags compareOptions;
1302 if (!PyArg_ParseTuple(_args, "O&l",
1303 CFStringRefObj_Convert, &stringToFind,
1304 &compareOptions))
1305 return NULL;
1306 _rv = CFStringFind(_self->ob_itself,
1307 stringToFind,
1308 compareOptions);
1309 _res = Py_BuildValue("O&",
1310 CFRange_New, _rv);
1311 return _res;
1312}
1313
1314static PyObject *CFStringRefObj_CFStringHasPrefix(CFStringRefObject *_self, PyObject *_args)
1315{
1316 PyObject *_res = NULL;
1317 Boolean _rv;
1318 CFStringRef prefix;
1319 if (!PyArg_ParseTuple(_args, "O&",
1320 CFStringRefObj_Convert, &prefix))
1321 return NULL;
1322 _rv = CFStringHasPrefix(_self->ob_itself,
1323 prefix);
1324 _res = Py_BuildValue("l",
1325 _rv);
1326 return _res;
1327}
1328
1329static PyObject *CFStringRefObj_CFStringHasSuffix(CFStringRefObject *_self, PyObject *_args)
1330{
1331 PyObject *_res = NULL;
1332 Boolean _rv;
1333 CFStringRef suffix;
1334 if (!PyArg_ParseTuple(_args, "O&",
1335 CFStringRefObj_Convert, &suffix))
1336 return NULL;
1337 _rv = CFStringHasSuffix(_self->ob_itself,
1338 suffix);
1339 _res = Py_BuildValue("l",
1340 _rv);
1341 return _res;
1342}
1343
1344static PyObject *CFStringRefObj_CFStringGetLineBounds(CFStringRefObject *_self, PyObject *_args)
1345{
1346 PyObject *_res = NULL;
1347 CFRange range;
1348 CFIndex lineBeginIndex;
1349 CFIndex lineEndIndex;
1350 CFIndex contentsEndIndex;
1351 if (!PyArg_ParseTuple(_args, "O&",
1352 CFRange_Convert, &range))
1353 return NULL;
1354 CFStringGetLineBounds(_self->ob_itself,
1355 range,
1356 &lineBeginIndex,
1357 &lineEndIndex,
1358 &contentsEndIndex);
1359 _res = Py_BuildValue("lll",
1360 lineBeginIndex,
1361 lineEndIndex,
1362 contentsEndIndex);
1363 return _res;
1364}
1365
1366static PyObject *CFStringRefObj_CFStringGetIntValue(CFStringRefObject *_self, PyObject *_args)
1367{
1368 PyObject *_res = NULL;
1369 SInt32 _rv;
1370 if (!PyArg_ParseTuple(_args, ""))
1371 return NULL;
1372 _rv = CFStringGetIntValue(_self->ob_itself);
1373 _res = Py_BuildValue("l",
1374 _rv);
1375 return _res;
1376}
1377
1378static PyObject *CFStringRefObj_CFStringGetDoubleValue(CFStringRefObject *_self, PyObject *_args)
1379{
1380 PyObject *_res = NULL;
1381 double _rv;
1382 if (!PyArg_ParseTuple(_args, ""))
1383 return NULL;
1384 _rv = CFStringGetDoubleValue(_self->ob_itself);
1385 _res = Py_BuildValue("d",
1386 _rv);
1387 return _res;
1388}
1389
1390static PyObject *CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStringRefObject *_self, PyObject *_args)
1391{
1392 PyObject *_res = NULL;
1393 CFStringEncoding _rv;
1394 if (!PyArg_ParseTuple(_args, ""))
1395 return NULL;
1396 _rv = CFStringConvertIANACharSetNameToEncoding(_self->ob_itself);
1397 _res = Py_BuildValue("l",
1398 _rv);
1399 return _res;
1400}
1401
1402static PyObject *CFStringRefObj_CFShowStr(CFStringRefObject *_self, PyObject *_args)
1403{
1404 PyObject *_res = NULL;
1405 if (!PyArg_ParseTuple(_args, ""))
1406 return NULL;
1407 CFShowStr(_self->ob_itself);
1408 Py_INCREF(Py_None);
1409 _res = Py_None;
1410 return _res;
1411}
1412
Jack Jansen686f9c32001-06-26 21:51:18 +00001413static PyMethodDef CFStringRefObj_methods[] = {
Jack Jansenbc7c8962001-06-27 22:00:55 +00001414 {"CFStringGetLength", (PyCFunction)CFStringRefObj_CFStringGetLength, 1,
1415 "() -> (CFIndex _rv)"},
1416 {"CFStringGetCString", (PyCFunction)CFStringRefObj_CFStringGetCString, 1,
1417 "(CFIndex bufferSize, CFStringEncoding encoding) -> (Boolean _rv, char buffer)"},
1418 {"CFStringGetBytes", (PyCFunction)CFStringRefObj_CFStringGetBytes, 1,
1419 "(CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, CFIndex maxBufLen) -> (CFIndex _rv, UInt8 buffer, CFIndex usedBufLen)"},
1420 {"CFStringGetSmallestEncoding", (PyCFunction)CFStringRefObj_CFStringGetSmallestEncoding, 1,
1421 "() -> (CFStringEncoding _rv)"},
1422 {"CFStringGetFastestEncoding", (PyCFunction)CFStringRefObj_CFStringGetFastestEncoding, 1,
1423 "() -> (CFStringEncoding _rv)"},
1424 {"CFStringCompareWithOptions", (PyCFunction)CFStringRefObj_CFStringCompareWithOptions, 1,
1425 "(CFStringRef string2, CFRange rangeToCompare, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)"},
1426 {"CFStringCompare", (PyCFunction)CFStringRefObj_CFStringCompare, 1,
1427 "(CFStringRef string2, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)"},
1428 {"CFStringFindWithOptions", (PyCFunction)CFStringRefObj_CFStringFindWithOptions, 1,
1429 "(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags searchOptions) -> (Boolean _rv, CFRange result)"},
1430 {"CFStringFind", (PyCFunction)CFStringRefObj_CFStringFind, 1,
1431 "(CFStringRef stringToFind, CFOptionFlags compareOptions) -> (CFRange _rv)"},
1432 {"CFStringHasPrefix", (PyCFunction)CFStringRefObj_CFStringHasPrefix, 1,
1433 "(CFStringRef prefix) -> (Boolean _rv)"},
1434 {"CFStringHasSuffix", (PyCFunction)CFStringRefObj_CFStringHasSuffix, 1,
1435 "(CFStringRef suffix) -> (Boolean _rv)"},
1436 {"CFStringGetLineBounds", (PyCFunction)CFStringRefObj_CFStringGetLineBounds, 1,
1437 "(CFRange range) -> (CFIndex lineBeginIndex, CFIndex lineEndIndex, CFIndex contentsEndIndex)"},
1438 {"CFStringGetIntValue", (PyCFunction)CFStringRefObj_CFStringGetIntValue, 1,
1439 "() -> (SInt32 _rv)"},
1440 {"CFStringGetDoubleValue", (PyCFunction)CFStringRefObj_CFStringGetDoubleValue, 1,
1441 "() -> (double _rv)"},
1442 {"CFStringConvertIANACharSetNameToEncoding", (PyCFunction)CFStringRefObj_CFStringConvertIANACharSetNameToEncoding, 1,
1443 "() -> (CFStringEncoding _rv)"},
1444 {"CFShowStr", (PyCFunction)CFStringRefObj_CFShowStr, 1,
1445 "() -> None"},
Jack Jansen686f9c32001-06-26 21:51:18 +00001446 {NULL, NULL, 0}
1447};
1448
Jack Jansen7becc912001-06-28 22:08:26 +00001449PyMethodChain CFStringRefObj_chain = { CFStringRefObj_methods, &CFTypeRefObj_chain };
Jack Jansen686f9c32001-06-26 21:51:18 +00001450
1451static PyObject *CFStringRefObj_getattr(CFStringRefObject *self, char *name)
1452{
1453 return Py_FindMethodInChain(&CFStringRefObj_chain, (PyObject *)self, name);
1454}
1455
1456#define CFStringRefObj_setattr NULL
1457
1458static int CFStringRefObj_compare(CFStringRefObject *self, CFStringRefObject *other)
1459{
1460 /* XXXX Or should we use CFEqual?? */
1461 if ( self->ob_itself > other->ob_itself ) return 1;
1462 if ( self->ob_itself < other->ob_itself ) return -1;
1463 return 0;
1464}
1465
1466static PyObject * CFStringRefObj_repr(CFStringRefObject *self)
1467{
1468 char buf[100];
Jack Jansen7becc912001-06-28 22:08:26 +00001469 sprintf(buf, "<CFStringRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself);
Jack Jansen686f9c32001-06-26 21:51:18 +00001470 return PyString_FromString(buf);
1471}
1472
1473static int CFStringRefObj_hash(CFStringRefObject *self)
1474{
1475 /* XXXX Or should we use CFHash?? */
1476 return (int)self->ob_itself;
1477}
1478
1479PyTypeObject CFStringRef_Type = {
1480 PyObject_HEAD_INIT(&PyType_Type)
1481 0, /*ob_size*/
1482 "CFStringRef", /*tp_name*/
1483 sizeof(CFStringRefObject), /*tp_basicsize*/
1484 0, /*tp_itemsize*/
1485 /* methods */
1486 (destructor) CFStringRefObj_dealloc, /*tp_dealloc*/
1487 0, /*tp_print*/
1488 (getattrfunc) CFStringRefObj_getattr, /*tp_getattr*/
1489 (setattrfunc) CFStringRefObj_setattr, /*tp_setattr*/
1490 (cmpfunc) CFStringRefObj_compare, /*tp_compare*/
1491 (reprfunc) CFStringRefObj_repr, /*tp_repr*/
1492 (PyNumberMethods *)0, /* tp_as_number */
1493 (PySequenceMethods *)0, /* tp_as_sequence */
1494 (PyMappingMethods *)0, /* tp_as_mapping */
1495 (hashfunc) CFStringRefObj_hash, /*tp_hash*/
1496};
1497
1498/* ------------------ End object type CFStringRef ------------------- */
1499
1500
Jack Jansenbc7c8962001-06-27 22:00:55 +00001501/* ----------------- Object type CFMutableStringRef ----------------- */
1502
1503PyTypeObject CFMutableStringRef_Type;
1504
1505#define CFMutableStringRefObj_Check(x) ((x)->ob_type == &CFMutableStringRef_Type)
1506
1507typedef struct CFMutableStringRefObject {
1508 PyObject_HEAD
1509 CFMutableStringRef ob_itself;
1510 void (*ob_freeit)(CFTypeRef ptr);
1511} CFMutableStringRefObject;
1512
1513PyObject *CFMutableStringRefObj_New(CFMutableStringRef itself)
1514{
1515 CFMutableStringRefObject *it;
1516 if (itself == NULL) return PyMac_Error(resNotFound);
1517 CFRetain(itself);
1518 it = PyObject_NEW(CFMutableStringRefObject, &CFMutableStringRef_Type);
1519 if (it == NULL) return NULL;
1520 it->ob_itself = itself;
1521 it->ob_freeit = CFRelease;
1522 return (PyObject *)it;
1523}
1524CFMutableStringRefObj_Convert(PyObject *v, CFMutableStringRef *p_itself)
1525{
1526
1527 if (v == Py_None) { *p_itself = NULL; return 1; }
1528 /* Check for other CF objects here */
1529
1530 if (!CFMutableStringRefObj_Check(v))
1531 {
1532 PyErr_SetString(PyExc_TypeError, "CFMutableStringRef required");
1533 return 0;
1534 }
1535 *p_itself = ((CFMutableStringRefObject *)v)->ob_itself;
1536 return 1;
1537}
1538
1539static void CFMutableStringRefObj_dealloc(CFMutableStringRefObject *self)
1540{
1541 if (self->ob_freeit && self->ob_itself)
1542 {
1543 self->ob_freeit((CFTypeRef)self->ob_itself);
1544 }
1545 PyMem_DEL(self);
1546}
1547
1548static PyObject *CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject *_self, PyObject *_args)
1549{
1550 PyObject *_res = NULL;
1551 CFStringRef appendedString;
1552 if (!PyArg_ParseTuple(_args, "O&",
1553 CFStringRefObj_Convert, &appendedString))
1554 return NULL;
1555 CFStringAppend(_self->ob_itself,
1556 appendedString);
1557 Py_INCREF(Py_None);
1558 _res = Py_None;
1559 return _res;
1560}
1561
1562static PyObject *CFMutableStringRefObj_CFStringAppendPascalString(CFMutableStringRefObject *_self, PyObject *_args)
1563{
1564 PyObject *_res = NULL;
1565 StringPtr pStr;
1566 CFStringEncoding encoding;
1567 if (!PyArg_ParseTuple(_args, "O&l",
1568 PyMac_GetStr255, &pStr,
1569 &encoding))
1570 return NULL;
1571 CFStringAppendPascalString(_self->ob_itself,
1572 pStr,
1573 encoding);
1574 Py_INCREF(Py_None);
1575 _res = Py_None;
1576 return _res;
1577}
1578
1579static PyObject *CFMutableStringRefObj_CFStringAppendCString(CFMutableStringRefObject *_self, PyObject *_args)
1580{
1581 PyObject *_res = NULL;
1582 char* cStr;
1583 CFStringEncoding encoding;
1584 if (!PyArg_ParseTuple(_args, "sl",
1585 &cStr,
1586 &encoding))
1587 return NULL;
1588 CFStringAppendCString(_self->ob_itself,
1589 cStr,
1590 encoding);
1591 Py_INCREF(Py_None);
1592 _res = Py_None;
1593 return _res;
1594}
1595
1596static PyObject *CFMutableStringRefObj_CFStringInsert(CFMutableStringRefObject *_self, PyObject *_args)
1597{
1598 PyObject *_res = NULL;
1599 CFIndex idx;
1600 CFStringRef insertedStr;
1601 if (!PyArg_ParseTuple(_args, "lO&",
1602 &idx,
1603 CFStringRefObj_Convert, &insertedStr))
1604 return NULL;
1605 CFStringInsert(_self->ob_itself,
1606 idx,
1607 insertedStr);
1608 Py_INCREF(Py_None);
1609 _res = Py_None;
1610 return _res;
1611}
1612
1613static PyObject *CFMutableStringRefObj_CFStringDelete(CFMutableStringRefObject *_self, PyObject *_args)
1614{
1615 PyObject *_res = NULL;
1616 CFRange range;
1617 if (!PyArg_ParseTuple(_args, "O&",
1618 CFRange_Convert, &range))
1619 return NULL;
1620 CFStringDelete(_self->ob_itself,
1621 range);
1622 Py_INCREF(Py_None);
1623 _res = Py_None;
1624 return _res;
1625}
1626
1627static PyObject *CFMutableStringRefObj_CFStringReplace(CFMutableStringRefObject *_self, PyObject *_args)
1628{
1629 PyObject *_res = NULL;
1630 CFRange range;
1631 CFStringRef replacement;
1632 if (!PyArg_ParseTuple(_args, "O&O&",
1633 CFRange_Convert, &range,
1634 CFStringRefObj_Convert, &replacement))
1635 return NULL;
1636 CFStringReplace(_self->ob_itself,
1637 range,
1638 replacement);
1639 Py_INCREF(Py_None);
1640 _res = Py_None;
1641 return _res;
1642}
1643
1644static PyObject *CFMutableStringRefObj_CFStringReplaceAll(CFMutableStringRefObject *_self, PyObject *_args)
1645{
1646 PyObject *_res = NULL;
1647 CFStringRef replacement;
1648 if (!PyArg_ParseTuple(_args, "O&",
1649 CFStringRefObj_Convert, &replacement))
1650 return NULL;
1651 CFStringReplaceAll(_self->ob_itself,
1652 replacement);
1653 Py_INCREF(Py_None);
1654 _res = Py_None;
1655 return _res;
1656}
1657
1658static PyObject *CFMutableStringRefObj_CFStringPad(CFMutableStringRefObject *_self, PyObject *_args)
1659{
1660 PyObject *_res = NULL;
1661 CFStringRef padString;
1662 CFIndex length;
1663 CFIndex indexIntoPad;
1664 if (!PyArg_ParseTuple(_args, "O&ll",
1665 CFStringRefObj_Convert, &padString,
1666 &length,
1667 &indexIntoPad))
1668 return NULL;
1669 CFStringPad(_self->ob_itself,
1670 padString,
1671 length,
1672 indexIntoPad);
1673 Py_INCREF(Py_None);
1674 _res = Py_None;
1675 return _res;
1676}
1677
1678static PyObject *CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject *_self, PyObject *_args)
1679{
1680 PyObject *_res = NULL;
1681 CFStringRef trimString;
1682 if (!PyArg_ParseTuple(_args, "O&",
1683 CFStringRefObj_Convert, &trimString))
1684 return NULL;
1685 CFStringTrim(_self->ob_itself,
1686 trimString);
1687 Py_INCREF(Py_None);
1688 _res = Py_None;
1689 return _res;
1690}
1691
1692static PyObject *CFMutableStringRefObj_CFStringTrimWhitespace(CFMutableStringRefObject *_self, PyObject *_args)
1693{
1694 PyObject *_res = NULL;
1695 if (!PyArg_ParseTuple(_args, ""))
1696 return NULL;
1697 CFStringTrimWhitespace(_self->ob_itself);
1698 Py_INCREF(Py_None);
1699 _res = Py_None;
1700 return _res;
1701}
1702
1703static PyMethodDef CFMutableStringRefObj_methods[] = {
1704 {"CFStringAppend", (PyCFunction)CFMutableStringRefObj_CFStringAppend, 1,
1705 "(CFStringRef appendedString) -> None"},
1706 {"CFStringAppendPascalString", (PyCFunction)CFMutableStringRefObj_CFStringAppendPascalString, 1,
1707 "(StringPtr pStr, CFStringEncoding encoding) -> None"},
1708 {"CFStringAppendCString", (PyCFunction)CFMutableStringRefObj_CFStringAppendCString, 1,
1709 "(char* cStr, CFStringEncoding encoding) -> None"},
1710 {"CFStringInsert", (PyCFunction)CFMutableStringRefObj_CFStringInsert, 1,
1711 "(CFIndex idx, CFStringRef insertedStr) -> None"},
1712 {"CFStringDelete", (PyCFunction)CFMutableStringRefObj_CFStringDelete, 1,
1713 "(CFRange range) -> None"},
1714 {"CFStringReplace", (PyCFunction)CFMutableStringRefObj_CFStringReplace, 1,
1715 "(CFRange range, CFStringRef replacement) -> None"},
1716 {"CFStringReplaceAll", (PyCFunction)CFMutableStringRefObj_CFStringReplaceAll, 1,
1717 "(CFStringRef replacement) -> None"},
1718 {"CFStringPad", (PyCFunction)CFMutableStringRefObj_CFStringPad, 1,
1719 "(CFStringRef padString, CFIndex length, CFIndex indexIntoPad) -> None"},
1720 {"CFStringTrim", (PyCFunction)CFMutableStringRefObj_CFStringTrim, 1,
1721 "(CFStringRef trimString) -> None"},
1722 {"CFStringTrimWhitespace", (PyCFunction)CFMutableStringRefObj_CFStringTrimWhitespace, 1,
1723 "() -> None"},
1724 {NULL, NULL, 0}
1725};
1726
Jack Jansen7becc912001-06-28 22:08:26 +00001727PyMethodChain CFMutableStringRefObj_chain = { CFMutableStringRefObj_methods, &CFStringRefObj_chain };
Jack Jansenbc7c8962001-06-27 22:00:55 +00001728
1729static PyObject *CFMutableStringRefObj_getattr(CFMutableStringRefObject *self, char *name)
1730{
1731 return Py_FindMethodInChain(&CFMutableStringRefObj_chain, (PyObject *)self, name);
1732}
1733
1734#define CFMutableStringRefObj_setattr NULL
1735
1736static int CFMutableStringRefObj_compare(CFMutableStringRefObject *self, CFMutableStringRefObject *other)
1737{
1738 /* XXXX Or should we use CFEqual?? */
1739 if ( self->ob_itself > other->ob_itself ) return 1;
1740 if ( self->ob_itself < other->ob_itself ) return -1;
1741 return 0;
1742}
1743
1744static PyObject * CFMutableStringRefObj_repr(CFMutableStringRefObject *self)
1745{
1746 char buf[100];
Jack Jansen7becc912001-06-28 22:08:26 +00001747 sprintf(buf, "<CFMutableStringRef object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself);
Jack Jansenbc7c8962001-06-27 22:00:55 +00001748 return PyString_FromString(buf);
1749}
1750
1751static int CFMutableStringRefObj_hash(CFMutableStringRefObject *self)
1752{
1753 /* XXXX Or should we use CFHash?? */
1754 return (int)self->ob_itself;
1755}
1756
1757PyTypeObject CFMutableStringRef_Type = {
1758 PyObject_HEAD_INIT(&PyType_Type)
1759 0, /*ob_size*/
1760 "CFMutableStringRef", /*tp_name*/
1761 sizeof(CFMutableStringRefObject), /*tp_basicsize*/
1762 0, /*tp_itemsize*/
1763 /* methods */
1764 (destructor) CFMutableStringRefObj_dealloc, /*tp_dealloc*/
1765 0, /*tp_print*/
1766 (getattrfunc) CFMutableStringRefObj_getattr, /*tp_getattr*/
1767 (setattrfunc) CFMutableStringRefObj_setattr, /*tp_setattr*/
1768 (cmpfunc) CFMutableStringRefObj_compare, /*tp_compare*/
1769 (reprfunc) CFMutableStringRefObj_repr, /*tp_repr*/
1770 (PyNumberMethods *)0, /* tp_as_number */
1771 (PySequenceMethods *)0, /* tp_as_sequence */
1772 (PyMappingMethods *)0, /* tp_as_mapping */
1773 (hashfunc) CFMutableStringRefObj_hash, /*tp_hash*/
1774};
1775
1776/* --------------- End object type CFMutableStringRef --------------- */
1777
1778
Jack Jansen7becc912001-06-28 22:08:26 +00001779/* ---------------------- Object type CFURLRef ---------------------- */
1780
1781PyTypeObject CFURLRef_Type;
1782
1783#define CFURLRefObj_Check(x) ((x)->ob_type == &CFURLRef_Type)
1784
1785typedef struct CFURLRefObject {
1786 PyObject_HEAD
1787 CFURLRef ob_itself;
1788 void (*ob_freeit)(CFTypeRef ptr);
1789} CFURLRefObject;
1790
1791PyObject *CFURLRefObj_New(CFURLRef itself)
1792{
1793 CFURLRefObject *it;
1794 if (itself == NULL) return PyMac_Error(resNotFound);
1795 CFRetain(itself);
1796 it = PyObject_NEW(CFURLRefObject, &CFURLRef_Type);
1797 if (it == NULL) return NULL;
1798 it->ob_itself = itself;
1799 it->ob_freeit = CFRelease;
1800 return (PyObject *)it;
1801}
1802CFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself)
1803{
1804
1805 if (v == Py_None) { *p_itself = NULL; return 1; }
1806 /* Check for other CF objects here */
1807
1808 if (!CFURLRefObj_Check(v))
1809 {
1810 PyErr_SetString(PyExc_TypeError, "CFURLRef required");
1811 return 0;
1812 }
1813 *p_itself = ((CFURLRefObject *)v)->ob_itself;
1814 return 1;
1815}
1816
1817static void CFURLRefObj_dealloc(CFURLRefObject *self)
1818{
1819 if (self->ob_freeit && self->ob_itself)
1820 {
1821 self->ob_freeit((CFTypeRef)self->ob_itself);
1822 }
1823 PyMem_DEL(self);
1824}
1825
1826static PyObject *CFURLRefObj_CFURLCopyAbsoluteURL(CFURLRefObject *_self, PyObject *_args)
1827{
1828 PyObject *_res = NULL;
1829 CFURLRef _rv;
1830 if (!PyArg_ParseTuple(_args, ""))
1831 return NULL;
1832 _rv = CFURLCopyAbsoluteURL(_self->ob_itself);
1833 _res = Py_BuildValue("O&",
1834 CFURLRefObj_New, _rv);
1835 return _res;
1836}
1837
1838static PyObject *CFURLRefObj_CFURLGetString(CFURLRefObject *_self, PyObject *_args)
1839{
1840 PyObject *_res = NULL;
1841 CFStringRef _rv;
1842 if (!PyArg_ParseTuple(_args, ""))
1843 return NULL;
1844 _rv = CFURLGetString(_self->ob_itself);
1845 _res = Py_BuildValue("O&",
1846 CFStringRefObj_New, _rv);
1847 return _res;
1848}
1849
1850static PyObject *CFURLRefObj_CFURLGetBaseURL(CFURLRefObject *_self, PyObject *_args)
1851{
1852 PyObject *_res = NULL;
1853 CFURLRef _rv;
1854 if (!PyArg_ParseTuple(_args, ""))
1855 return NULL;
1856 _rv = CFURLGetBaseURL(_self->ob_itself);
1857 _res = Py_BuildValue("O&",
1858 CFURLRefObj_New, _rv);
1859 return _res;
1860}
1861
1862static PyObject *CFURLRefObj_CFURLCanBeDecomposed(CFURLRefObject *_self, PyObject *_args)
1863{
1864 PyObject *_res = NULL;
1865 Boolean _rv;
1866 if (!PyArg_ParseTuple(_args, ""))
1867 return NULL;
1868 _rv = CFURLCanBeDecomposed(_self->ob_itself);
1869 _res = Py_BuildValue("l",
1870 _rv);
1871 return _res;
1872}
1873
1874static PyObject *CFURLRefObj_CFURLCopyScheme(CFURLRefObject *_self, PyObject *_args)
1875{
1876 PyObject *_res = NULL;
1877 CFStringRef _rv;
1878 if (!PyArg_ParseTuple(_args, ""))
1879 return NULL;
1880 _rv = CFURLCopyScheme(_self->ob_itself);
1881 _res = Py_BuildValue("O&",
1882 CFStringRefObj_New, _rv);
1883 return _res;
1884}
1885
1886static PyObject *CFURLRefObj_CFURLCopyNetLocation(CFURLRefObject *_self, PyObject *_args)
1887{
1888 PyObject *_res = NULL;
1889 CFStringRef _rv;
1890 if (!PyArg_ParseTuple(_args, ""))
1891 return NULL;
1892 _rv = CFURLCopyNetLocation(_self->ob_itself);
1893 _res = Py_BuildValue("O&",
1894 CFStringRefObj_New, _rv);
1895 return _res;
1896}
1897
1898static PyObject *CFURLRefObj_CFURLCopyPath(CFURLRefObject *_self, PyObject *_args)
1899{
1900 PyObject *_res = NULL;
1901 CFStringRef _rv;
1902 if (!PyArg_ParseTuple(_args, ""))
1903 return NULL;
1904 _rv = CFURLCopyPath(_self->ob_itself);
1905 _res = Py_BuildValue("O&",
1906 CFStringRefObj_New, _rv);
1907 return _res;
1908}
1909
1910static PyObject *CFURLRefObj_CFURLHasDirectoryPath(CFURLRefObject *_self, PyObject *_args)
1911{
1912 PyObject *_res = NULL;
1913 Boolean _rv;
1914 if (!PyArg_ParseTuple(_args, ""))
1915 return NULL;
1916 _rv = CFURLHasDirectoryPath(_self->ob_itself);
1917 _res = Py_BuildValue("l",
1918 _rv);
1919 return _res;
1920}
1921
1922static PyObject *CFURLRefObj_CFURLCopyResourceSpecifier(CFURLRefObject *_self, PyObject *_args)
1923{
1924 PyObject *_res = NULL;
1925 CFStringRef _rv;
1926 if (!PyArg_ParseTuple(_args, ""))
1927 return NULL;
1928 _rv = CFURLCopyResourceSpecifier(_self->ob_itself);
1929 _res = Py_BuildValue("O&",
1930 CFStringRefObj_New, _rv);
1931 return _res;
1932}
1933
1934static PyObject *CFURLRefObj_CFURLCopyHostName(CFURLRefObject *_self, PyObject *_args)
1935{
1936 PyObject *_res = NULL;
1937 CFStringRef _rv;
1938 if (!PyArg_ParseTuple(_args, ""))
1939 return NULL;
1940 _rv = CFURLCopyHostName(_self->ob_itself);
1941 _res = Py_BuildValue("O&",
1942 CFStringRefObj_New, _rv);
1943 return _res;
1944}
1945
1946static PyObject *CFURLRefObj_CFURLGetPortNumber(CFURLRefObject *_self, PyObject *_args)
1947{
1948 PyObject *_res = NULL;
1949 SInt32 _rv;
1950 if (!PyArg_ParseTuple(_args, ""))
1951 return NULL;
1952 _rv = CFURLGetPortNumber(_self->ob_itself);
1953 _res = Py_BuildValue("l",
1954 _rv);
1955 return _res;
1956}
1957
1958static PyObject *CFURLRefObj_CFURLCopyUserName(CFURLRefObject *_self, PyObject *_args)
1959{
1960 PyObject *_res = NULL;
1961 CFStringRef _rv;
1962 if (!PyArg_ParseTuple(_args, ""))
1963 return NULL;
1964 _rv = CFURLCopyUserName(_self->ob_itself);
1965 _res = Py_BuildValue("O&",
1966 CFStringRefObj_New, _rv);
1967 return _res;
1968}
1969
1970static PyObject *CFURLRefObj_CFURLCopyPassword(CFURLRefObject *_self, PyObject *_args)
1971{
1972 PyObject *_res = NULL;
1973 CFStringRef _rv;
1974 if (!PyArg_ParseTuple(_args, ""))
1975 return NULL;
1976 _rv = CFURLCopyPassword(_self->ob_itself);
1977 _res = Py_BuildValue("O&",
1978 CFStringRefObj_New, _rv);
1979 return _res;
1980}
1981
1982static PyObject *CFURLRefObj_CFURLCopyParameterString(CFURLRefObject *_self, PyObject *_args)
1983{
1984 PyObject *_res = NULL;
1985 CFStringRef _rv;
1986 CFStringRef charactersToLeaveEscaped;
1987 if (!PyArg_ParseTuple(_args, "O&",
1988 CFStringRefObj_Convert, &charactersToLeaveEscaped))
1989 return NULL;
1990 _rv = CFURLCopyParameterString(_self->ob_itself,
1991 charactersToLeaveEscaped);
1992 _res = Py_BuildValue("O&",
1993 CFStringRefObj_New, _rv);
1994 return _res;
1995}
1996
1997static PyObject *CFURLRefObj_CFURLCopyQueryString(CFURLRefObject *_self, PyObject *_args)
1998{
1999 PyObject *_res = NULL;
2000 CFStringRef _rv;
2001 CFStringRef charactersToLeaveEscaped;
2002 if (!PyArg_ParseTuple(_args, "O&",
2003 CFStringRefObj_Convert, &charactersToLeaveEscaped))
2004 return NULL;
2005 _rv = CFURLCopyQueryString(_self->ob_itself,
2006 charactersToLeaveEscaped);
2007 _res = Py_BuildValue("O&",
2008 CFStringRefObj_New, _rv);
2009 return _res;
2010}
2011
2012static PyObject *CFURLRefObj_CFURLCopyFragment(CFURLRefObject *_self, PyObject *_args)
2013{
2014 PyObject *_res = NULL;
2015 CFStringRef _rv;
2016 CFStringRef charactersToLeaveEscaped;
2017 if (!PyArg_ParseTuple(_args, "O&",
2018 CFStringRefObj_Convert, &charactersToLeaveEscaped))
2019 return NULL;
2020 _rv = CFURLCopyFragment(_self->ob_itself,
2021 charactersToLeaveEscaped);
2022 _res = Py_BuildValue("O&",
2023 CFStringRefObj_New, _rv);
2024 return _res;
2025}
2026
2027static PyMethodDef CFURLRefObj_methods[] = {
2028 {"CFURLCopyAbsoluteURL", (PyCFunction)CFURLRefObj_CFURLCopyAbsoluteURL, 1,
2029 "() -> (CFURLRef _rv)"},
2030 {"CFURLGetString", (PyCFunction)CFURLRefObj_CFURLGetString, 1,
2031 "() -> (CFStringRef _rv)"},
2032 {"CFURLGetBaseURL", (PyCFunction)CFURLRefObj_CFURLGetBaseURL, 1,
2033 "() -> (CFURLRef _rv)"},
2034 {"CFURLCanBeDecomposed", (PyCFunction)CFURLRefObj_CFURLCanBeDecomposed, 1,
2035 "() -> (Boolean _rv)"},
2036 {"CFURLCopyScheme", (PyCFunction)CFURLRefObj_CFURLCopyScheme, 1,
2037 "() -> (CFStringRef _rv)"},
2038 {"CFURLCopyNetLocation", (PyCFunction)CFURLRefObj_CFURLCopyNetLocation, 1,
2039 "() -> (CFStringRef _rv)"},
2040 {"CFURLCopyPath", (PyCFunction)CFURLRefObj_CFURLCopyPath, 1,
2041 "() -> (CFStringRef _rv)"},
2042 {"CFURLHasDirectoryPath", (PyCFunction)CFURLRefObj_CFURLHasDirectoryPath, 1,
2043 "() -> (Boolean _rv)"},
2044 {"CFURLCopyResourceSpecifier", (PyCFunction)CFURLRefObj_CFURLCopyResourceSpecifier, 1,
2045 "() -> (CFStringRef _rv)"},
2046 {"CFURLCopyHostName", (PyCFunction)CFURLRefObj_CFURLCopyHostName, 1,
2047 "() -> (CFStringRef _rv)"},
2048 {"CFURLGetPortNumber", (PyCFunction)CFURLRefObj_CFURLGetPortNumber, 1,
2049 "() -> (SInt32 _rv)"},
2050 {"CFURLCopyUserName", (PyCFunction)CFURLRefObj_CFURLCopyUserName, 1,
2051 "() -> (CFStringRef _rv)"},
2052 {"CFURLCopyPassword", (PyCFunction)CFURLRefObj_CFURLCopyPassword, 1,
2053 "() -> (CFStringRef _rv)"},
2054 {"CFURLCopyParameterString", (PyCFunction)CFURLRefObj_CFURLCopyParameterString, 1,
2055 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2056 {"CFURLCopyQueryString", (PyCFunction)CFURLRefObj_CFURLCopyQueryString, 1,
2057 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2058 {"CFURLCopyFragment", (PyCFunction)CFURLRefObj_CFURLCopyFragment, 1,
2059 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2060 {NULL, NULL, 0}
2061};
2062
2063PyMethodChain CFURLRefObj_chain = { CFURLRefObj_methods, &CFTypeRefObj_chain };
2064
2065static PyObject *CFURLRefObj_getattr(CFURLRefObject *self, char *name)
2066{
2067 return Py_FindMethodInChain(&CFURLRefObj_chain, (PyObject *)self, name);
2068}
2069
2070#define CFURLRefObj_setattr NULL
2071
2072static int CFURLRefObj_compare(CFURLRefObject *self, CFURLRefObject *other)
2073{
2074 /* XXXX Or should we use CFEqual?? */
2075 if ( self->ob_itself > other->ob_itself ) return 1;
2076 if ( self->ob_itself < other->ob_itself ) return -1;
2077 return 0;
2078}
2079
2080static PyObject * CFURLRefObj_repr(CFURLRefObject *self)
2081{
2082 char buf[100];
2083 sprintf(buf, "<CFURL object at 0x%08.8x for 0x%08.8x>", CFGetTypeID(self->ob_itself), self, self->ob_itself);
2084 return PyString_FromString(buf);
2085}
2086
2087static int CFURLRefObj_hash(CFURLRefObject *self)
2088{
2089 /* XXXX Or should we use CFHash?? */
2090 return (int)self->ob_itself;
2091}
2092
2093PyTypeObject CFURLRef_Type = {
2094 PyObject_HEAD_INIT(&PyType_Type)
2095 0, /*ob_size*/
2096 "CFURLRef", /*tp_name*/
2097 sizeof(CFURLRefObject), /*tp_basicsize*/
2098 0, /*tp_itemsize*/
2099 /* methods */
2100 (destructor) CFURLRefObj_dealloc, /*tp_dealloc*/
2101 0, /*tp_print*/
2102 (getattrfunc) CFURLRefObj_getattr, /*tp_getattr*/
2103 (setattrfunc) CFURLRefObj_setattr, /*tp_setattr*/
2104 (cmpfunc) CFURLRefObj_compare, /*tp_compare*/
2105 (reprfunc) CFURLRefObj_repr, /*tp_repr*/
2106 (PyNumberMethods *)0, /* tp_as_number */
2107 (PySequenceMethods *)0, /* tp_as_sequence */
2108 (PyMappingMethods *)0, /* tp_as_mapping */
2109 (hashfunc) CFURLRefObj_hash, /*tp_hash*/
2110};
2111
2112/* -------------------- End object type CFURLRef -------------------- */
2113
2114
Jack Jansen686f9c32001-06-26 21:51:18 +00002115static PyObject *CF_CFAllocatorGetTypeID(PyObject *_self, PyObject *_args)
2116{
2117 PyObject *_res = NULL;
2118 CFTypeID _rv;
2119 if (!PyArg_ParseTuple(_args, ""))
2120 return NULL;
2121 _rv = CFAllocatorGetTypeID();
2122 _res = Py_BuildValue("l",
2123 _rv);
2124 return _res;
2125}
2126
2127static PyObject *CF_CFAllocatorGetPreferredSizeForSize(PyObject *_self, PyObject *_args)
2128{
2129 PyObject *_res = NULL;
2130 CFIndex _rv;
2131 CFIndex size;
2132 CFOptionFlags hint;
2133 if (!PyArg_ParseTuple(_args, "ll",
2134 &size,
2135 &hint))
2136 return NULL;
2137 _rv = CFAllocatorGetPreferredSizeForSize((CFAllocatorRef)NULL,
2138 size,
2139 hint);
2140 _res = Py_BuildValue("l",
2141 _rv);
2142 return _res;
2143}
2144
2145static PyObject *CF_CFCopyTypeIDDescription(PyObject *_self, PyObject *_args)
2146{
2147 PyObject *_res = NULL;
2148 CFStringRef _rv;
2149 CFTypeID theType;
2150 if (!PyArg_ParseTuple(_args, "l",
2151 &theType))
2152 return NULL;
2153 _rv = CFCopyTypeIDDescription(theType);
2154 _res = Py_BuildValue("O&",
2155 CFStringRefObj_New, _rv);
2156 return _res;
2157}
2158
Jack Jansenbc7c8962001-06-27 22:00:55 +00002159static PyObject *CF_CFArrayGetTypeID(PyObject *_self, PyObject *_args)
2160{
2161 PyObject *_res = NULL;
2162 CFTypeID _rv;
2163 if (!PyArg_ParseTuple(_args, ""))
2164 return NULL;
2165 _rv = CFArrayGetTypeID();
2166 _res = Py_BuildValue("l",
2167 _rv);
2168 return _res;
2169}
2170
2171static PyObject *CF_CFArrayCreateCopy(PyObject *_self, PyObject *_args)
2172{
2173 PyObject *_res = NULL;
2174 CFArrayRef _rv;
2175 CFArrayRef srcArray;
2176 if (!PyArg_ParseTuple(_args, "O&",
2177 CFArrayRefObj_Convert, &srcArray))
2178 return NULL;
2179 _rv = CFArrayCreateCopy((CFAllocatorRef)NULL,
2180 srcArray);
2181 _res = Py_BuildValue("O&",
2182 CFArrayRefObj_New, _rv);
2183 return _res;
2184}
2185
2186static PyObject *CF_CFArrayCreateMutable(PyObject *_self, PyObject *_args)
2187{
2188 PyObject *_res = NULL;
2189 CFMutableArrayRef _rv;
2190 CFIndex capacity;
2191 if (!PyArg_ParseTuple(_args, "l",
2192 &capacity))
2193 return NULL;
2194 _rv = CFArrayCreateMutable((CFAllocatorRef)NULL,
2195 capacity,
2196 &kCFTypeArrayCallBacks);
2197 _res = Py_BuildValue("O&",
2198 CFMutableArrayRefObj_New, _rv);
2199 return _res;
2200}
2201
2202static PyObject *CF_CFArrayCreateMutableCopy(PyObject *_self, PyObject *_args)
2203{
2204 PyObject *_res = NULL;
2205 CFMutableArrayRef _rv;
2206 CFIndex capacity;
2207 CFArrayRef srcArray;
2208 if (!PyArg_ParseTuple(_args, "lO&",
2209 &capacity,
2210 CFArrayRefObj_Convert, &srcArray))
2211 return NULL;
2212 _rv = CFArrayCreateMutableCopy((CFAllocatorRef)NULL,
2213 capacity,
2214 srcArray);
2215 _res = Py_BuildValue("O&",
2216 CFMutableArrayRefObj_New, _rv);
2217 return _res;
2218}
2219
2220static PyObject *CF_CFDataGetTypeID(PyObject *_self, PyObject *_args)
2221{
2222 PyObject *_res = NULL;
2223 CFTypeID _rv;
2224 if (!PyArg_ParseTuple(_args, ""))
2225 return NULL;
2226 _rv = CFDataGetTypeID();
2227 _res = Py_BuildValue("l",
2228 _rv);
2229 return _res;
2230}
2231
2232static PyObject *CF_CFDataCreate(PyObject *_self, PyObject *_args)
2233{
2234 PyObject *_res = NULL;
2235 CFDataRef _rv;
2236 unsigned char *bytes__in__;
2237 long bytes__len__;
2238 int bytes__in_len__;
2239 if (!PyArg_ParseTuple(_args, "s#",
2240 &bytes__in__, &bytes__in_len__))
2241 return NULL;
2242 bytes__len__ = bytes__in_len__;
2243 _rv = CFDataCreate((CFAllocatorRef)NULL,
2244 bytes__in__, bytes__len__);
2245 _res = Py_BuildValue("O&",
2246 CFDataRefObj_New, _rv);
2247 bytes__error__: ;
2248 return _res;
2249}
2250
2251static PyObject *CF_CFDataCreateWithBytesNoCopy(PyObject *_self, PyObject *_args)
2252{
2253 PyObject *_res = NULL;
2254 CFDataRef _rv;
2255 unsigned char *bytes__in__;
2256 long bytes__len__;
2257 int bytes__in_len__;
2258 if (!PyArg_ParseTuple(_args, "s#",
2259 &bytes__in__, &bytes__in_len__))
2260 return NULL;
2261 bytes__len__ = bytes__in_len__;
2262 _rv = CFDataCreateWithBytesNoCopy((CFAllocatorRef)NULL,
2263 bytes__in__, bytes__len__,
2264 (CFAllocatorRef)NULL);
2265 _res = Py_BuildValue("O&",
2266 CFDataRefObj_New, _rv);
2267 bytes__error__: ;
2268 return _res;
2269}
2270
2271static PyObject *CF_CFDataCreateCopy(PyObject *_self, PyObject *_args)
2272{
2273 PyObject *_res = NULL;
2274 CFDataRef _rv;
2275 CFDataRef data;
2276 if (!PyArg_ParseTuple(_args, "O&",
2277 CFDataRefObj_Convert, &data))
2278 return NULL;
2279 _rv = CFDataCreateCopy((CFAllocatorRef)NULL,
2280 data);
2281 _res = Py_BuildValue("O&",
2282 CFDataRefObj_New, _rv);
2283 return _res;
2284}
2285
2286static PyObject *CF_CFDataCreateMutable(PyObject *_self, PyObject *_args)
2287{
2288 PyObject *_res = NULL;
2289 CFMutableDataRef _rv;
2290 CFIndex capacity;
2291 if (!PyArg_ParseTuple(_args, "l",
2292 &capacity))
2293 return NULL;
2294 _rv = CFDataCreateMutable((CFAllocatorRef)NULL,
2295 capacity);
2296 _res = Py_BuildValue("O&",
2297 CFMutableDataRefObj_New, _rv);
2298 return _res;
2299}
2300
2301static PyObject *CF_CFDataCreateMutableCopy(PyObject *_self, PyObject *_args)
2302{
2303 PyObject *_res = NULL;
2304 CFMutableDataRef _rv;
2305 CFIndex capacity;
2306 CFDataRef data;
2307 if (!PyArg_ParseTuple(_args, "lO&",
2308 &capacity,
2309 CFDataRefObj_Convert, &data))
2310 return NULL;
2311 _rv = CFDataCreateMutableCopy((CFAllocatorRef)NULL,
2312 capacity,
2313 data);
2314 _res = Py_BuildValue("O&",
2315 CFMutableDataRefObj_New, _rv);
2316 return _res;
2317}
2318
2319static PyObject *CF_CFDictionaryGetTypeID(PyObject *_self, PyObject *_args)
2320{
2321 PyObject *_res = NULL;
2322 CFTypeID _rv;
2323 if (!PyArg_ParseTuple(_args, ""))
2324 return NULL;
2325 _rv = CFDictionaryGetTypeID();
2326 _res = Py_BuildValue("l",
2327 _rv);
2328 return _res;
2329}
2330
2331static PyObject *CF_CFDictionaryCreateCopy(PyObject *_self, PyObject *_args)
2332{
2333 PyObject *_res = NULL;
2334 CFDictionaryRef _rv;
2335 CFDictionaryRef dict;
2336 if (!PyArg_ParseTuple(_args, "O&",
2337 CFDictionaryRefObj_Convert, &dict))
2338 return NULL;
2339 _rv = CFDictionaryCreateCopy((CFAllocatorRef)NULL,
2340 dict);
2341 _res = Py_BuildValue("O&",
2342 CFDictionaryRefObj_New, _rv);
2343 return _res;
2344}
2345
2346static PyObject *CF_CFDictionaryCreateMutable(PyObject *_self, PyObject *_args)
2347{
2348 PyObject *_res = NULL;
2349 CFMutableDictionaryRef _rv;
2350 CFIndex capacity;
2351 if (!PyArg_ParseTuple(_args, "l",
2352 &capacity))
2353 return NULL;
2354 _rv = CFDictionaryCreateMutable((CFAllocatorRef)NULL,
2355 capacity,
2356 &kCFTypeDictionaryKeyCallBacks,
2357 &kCFTypeDictionaryValueCallBacks);
2358 _res = Py_BuildValue("O&",
2359 CFMutableDictionaryRefObj_New, _rv);
2360 return _res;
2361}
2362
2363static PyObject *CF_CFDictionaryCreateMutableCopy(PyObject *_self, PyObject *_args)
2364{
2365 PyObject *_res = NULL;
2366 CFMutableDictionaryRef _rv;
2367 CFIndex capacity;
2368 CFDictionaryRef dict;
2369 if (!PyArg_ParseTuple(_args, "lO&",
2370 &capacity,
2371 CFDictionaryRefObj_Convert, &dict))
2372 return NULL;
2373 _rv = CFDictionaryCreateMutableCopy((CFAllocatorRef)NULL,
2374 capacity,
2375 dict);
2376 _res = Py_BuildValue("O&",
2377 CFMutableDictionaryRefObj_New, _rv);
2378 return _res;
2379}
2380
2381static PyObject *CF_CFStringGetTypeID(PyObject *_self, PyObject *_args)
2382{
2383 PyObject *_res = NULL;
2384 CFTypeID _rv;
2385 if (!PyArg_ParseTuple(_args, ""))
2386 return NULL;
2387 _rv = CFStringGetTypeID();
2388 _res = Py_BuildValue("l",
2389 _rv);
2390 return _res;
2391}
2392
2393static PyObject *CF_CFStringCreateWithPascalString(PyObject *_self, PyObject *_args)
2394{
2395 PyObject *_res = NULL;
2396 CFStringRef _rv;
2397 StringPtr pStr;
2398 CFStringEncoding encoding;
2399 if (!PyArg_ParseTuple(_args, "O&l",
2400 PyMac_GetStr255, &pStr,
2401 &encoding))
2402 return NULL;
2403 _rv = CFStringCreateWithPascalString((CFAllocatorRef)NULL,
2404 pStr,
2405 encoding);
2406 _res = Py_BuildValue("O&",
2407 CFStringRefObj_New, _rv);
2408 return _res;
2409}
2410
2411static PyObject *CF_CFStringCreateWithCString(PyObject *_self, PyObject *_args)
2412{
2413 PyObject *_res = NULL;
2414 CFStringRef _rv;
2415 char* cStr;
2416 CFStringEncoding encoding;
2417 if (!PyArg_ParseTuple(_args, "sl",
2418 &cStr,
2419 &encoding))
2420 return NULL;
2421 _rv = CFStringCreateWithCString((CFAllocatorRef)NULL,
2422 cStr,
2423 encoding);
2424 _res = Py_BuildValue("O&",
2425 CFStringRefObj_New, _rv);
2426 return _res;
2427}
2428
2429static PyObject *CF_CFStringCreateWithPascalStringNoCopy(PyObject *_self, PyObject *_args)
2430{
2431 PyObject *_res = NULL;
2432 CFStringRef _rv;
2433 StringPtr pStr;
2434 CFStringEncoding encoding;
2435 if (!PyArg_ParseTuple(_args, "O&l",
2436 PyMac_GetStr255, &pStr,
2437 &encoding))
2438 return NULL;
2439 _rv = CFStringCreateWithPascalStringNoCopy((CFAllocatorRef)NULL,
2440 pStr,
2441 encoding,
2442 (CFAllocatorRef)NULL);
2443 _res = Py_BuildValue("O&",
2444 CFStringRefObj_New, _rv);
2445 return _res;
2446}
2447
2448static PyObject *CF_CFStringCreateWithCStringNoCopy(PyObject *_self, PyObject *_args)
2449{
2450 PyObject *_res = NULL;
2451 CFStringRef _rv;
2452 char* cStr;
2453 CFStringEncoding encoding;
2454 if (!PyArg_ParseTuple(_args, "sl",
2455 &cStr,
2456 &encoding))
2457 return NULL;
2458 _rv = CFStringCreateWithCStringNoCopy((CFAllocatorRef)NULL,
2459 cStr,
2460 encoding,
2461 (CFAllocatorRef)NULL);
2462 _res = Py_BuildValue("O&",
2463 CFStringRefObj_New, _rv);
2464 return _res;
2465}
2466
2467static PyObject *CF_CFStringCreateWithSubstring(PyObject *_self, PyObject *_args)
2468{
2469 PyObject *_res = NULL;
2470 CFStringRef _rv;
2471 CFStringRef str;
2472 CFRange range;
2473 if (!PyArg_ParseTuple(_args, "O&O&",
2474 CFStringRefObj_Convert, &str,
2475 CFRange_Convert, &range))
2476 return NULL;
2477 _rv = CFStringCreateWithSubstring((CFAllocatorRef)NULL,
2478 str,
2479 range);
2480 _res = Py_BuildValue("O&",
2481 CFStringRefObj_New, _rv);
2482 return _res;
2483}
2484
2485static PyObject *CF_CFStringCreateCopy(PyObject *_self, PyObject *_args)
2486{
2487 PyObject *_res = NULL;
2488 CFStringRef _rv;
2489 CFStringRef theString;
2490 if (!PyArg_ParseTuple(_args, "O&",
2491 CFStringRefObj_Convert, &theString))
2492 return NULL;
2493 _rv = CFStringCreateCopy((CFAllocatorRef)NULL,
2494 theString);
2495 _res = Py_BuildValue("O&",
2496 CFStringRefObj_New, _rv);
2497 return _res;
2498}
2499
2500static PyObject *CF_CFStringCreateMutable(PyObject *_self, PyObject *_args)
2501{
2502 PyObject *_res = NULL;
2503 CFMutableStringRef _rv;
2504 CFIndex maxLength;
2505 if (!PyArg_ParseTuple(_args, "l",
2506 &maxLength))
2507 return NULL;
2508 _rv = CFStringCreateMutable((CFAllocatorRef)NULL,
2509 maxLength);
2510 _res = Py_BuildValue("O&",
2511 CFMutableStringRefObj_New, _rv);
2512 return _res;
2513}
2514
2515static PyObject *CF_CFStringCreateMutableCopy(PyObject *_self, PyObject *_args)
2516{
2517 PyObject *_res = NULL;
2518 CFMutableStringRef _rv;
2519 CFIndex maxLength;
2520 CFStringRef theString;
2521 if (!PyArg_ParseTuple(_args, "lO&",
2522 &maxLength,
2523 CFStringRefObj_Convert, &theString))
2524 return NULL;
2525 _rv = CFStringCreateMutableCopy((CFAllocatorRef)NULL,
2526 maxLength,
2527 theString);
2528 _res = Py_BuildValue("O&",
2529 CFMutableStringRefObj_New, _rv);
2530 return _res;
2531}
2532
2533static PyObject *CF_CFStringCreateWithBytes(PyObject *_self, PyObject *_args)
2534{
2535 PyObject *_res = NULL;
2536 CFStringRef _rv;
2537 unsigned char *bytes__in__;
2538 long bytes__len__;
2539 int bytes__in_len__;
2540 CFStringEncoding encoding;
2541 Boolean isExternalRepresentation;
2542 if (!PyArg_ParseTuple(_args, "s#ll",
2543 &bytes__in__, &bytes__in_len__,
2544 &encoding,
2545 &isExternalRepresentation))
2546 return NULL;
2547 bytes__len__ = bytes__in_len__;
2548 _rv = CFStringCreateWithBytes((CFAllocatorRef)NULL,
2549 bytes__in__, bytes__len__,
2550 encoding,
2551 isExternalRepresentation);
2552 _res = Py_BuildValue("O&",
2553 CFStringRefObj_New, _rv);
2554 bytes__error__: ;
2555 return _res;
2556}
2557
2558static PyObject *CF_CFStringCreateFromExternalRepresentation(PyObject *_self, PyObject *_args)
2559{
2560 PyObject *_res = NULL;
2561 CFStringRef _rv;
2562 CFDataRef data;
2563 CFStringEncoding encoding;
2564 if (!PyArg_ParseTuple(_args, "O&l",
2565 CFDataRefObj_Convert, &data,
2566 &encoding))
2567 return NULL;
2568 _rv = CFStringCreateFromExternalRepresentation((CFAllocatorRef)NULL,
2569 data,
2570 encoding);
2571 _res = Py_BuildValue("O&",
2572 CFStringRefObj_New, _rv);
2573 return _res;
2574}
2575
2576static PyObject *CF_CFStringCreateExternalRepresentation(PyObject *_self, PyObject *_args)
2577{
2578 PyObject *_res = NULL;
2579 CFDataRef _rv;
2580 CFStringRef theString;
2581 CFStringEncoding encoding;
2582 UInt8 lossByte;
2583 if (!PyArg_ParseTuple(_args, "O&lb",
2584 CFStringRefObj_Convert, &theString,
2585 &encoding,
2586 &lossByte))
2587 return NULL;
2588 _rv = CFStringCreateExternalRepresentation((CFAllocatorRef)NULL,
2589 theString,
2590 encoding,
2591 lossByte);
2592 _res = Py_BuildValue("O&",
2593 CFDataRefObj_New, _rv);
2594 return _res;
2595}
2596
2597static PyObject *CF_CFStringGetSystemEncoding(PyObject *_self, PyObject *_args)
2598{
2599 PyObject *_res = NULL;
2600 CFStringEncoding _rv;
2601 if (!PyArg_ParseTuple(_args, ""))
2602 return NULL;
2603 _rv = CFStringGetSystemEncoding();
2604 _res = Py_BuildValue("l",
2605 _rv);
2606 return _res;
2607}
2608
2609static PyObject *CF_CFStringGetMaximumSizeForEncoding(PyObject *_self, PyObject *_args)
2610{
2611 PyObject *_res = NULL;
2612 CFIndex _rv;
2613 CFIndex length;
2614 CFStringEncoding encoding;
2615 if (!PyArg_ParseTuple(_args, "ll",
2616 &length,
2617 &encoding))
2618 return NULL;
2619 _rv = CFStringGetMaximumSizeForEncoding(length,
2620 encoding);
2621 _res = Py_BuildValue("l",
2622 _rv);
2623 return _res;
2624}
2625
2626static PyObject *CF_CFStringCreateArrayWithFindResults(PyObject *_self, PyObject *_args)
2627{
2628 PyObject *_res = NULL;
2629 CFArrayRef _rv;
2630 CFStringRef theString;
2631 CFStringRef stringToFind;
2632 CFRange rangeToSearch;
2633 CFOptionFlags compareOptions;
2634 if (!PyArg_ParseTuple(_args, "O&O&O&l",
2635 CFStringRefObj_Convert, &theString,
2636 CFStringRefObj_Convert, &stringToFind,
2637 CFRange_Convert, &rangeToSearch,
2638 &compareOptions))
2639 return NULL;
2640 _rv = CFStringCreateArrayWithFindResults((CFAllocatorRef)NULL,
2641 theString,
2642 stringToFind,
2643 rangeToSearch,
2644 compareOptions);
2645 _res = Py_BuildValue("O&",
2646 CFArrayRefObj_New, _rv);
2647 return _res;
2648}
2649
2650static PyObject *CF_CFStringCreateByCombiningStrings(PyObject *_self, PyObject *_args)
2651{
2652 PyObject *_res = NULL;
2653 CFStringRef _rv;
2654 CFArrayRef theArray;
2655 CFStringRef separatorString;
2656 if (!PyArg_ParseTuple(_args, "O&O&",
2657 CFArrayRefObj_Convert, &theArray,
2658 CFStringRefObj_Convert, &separatorString))
2659 return NULL;
2660 _rv = CFStringCreateByCombiningStrings((CFAllocatorRef)NULL,
2661 theArray,
2662 separatorString);
2663 _res = Py_BuildValue("O&",
2664 CFStringRefObj_New, _rv);
2665 return _res;
2666}
2667
2668static PyObject *CF_CFStringCreateArrayBySeparatingStrings(PyObject *_self, PyObject *_args)
2669{
2670 PyObject *_res = NULL;
2671 CFArrayRef _rv;
2672 CFStringRef theString;
2673 CFStringRef separatorString;
2674 if (!PyArg_ParseTuple(_args, "O&O&",
2675 CFStringRefObj_Convert, &theString,
2676 CFStringRefObj_Convert, &separatorString))
2677 return NULL;
2678 _rv = CFStringCreateArrayBySeparatingStrings((CFAllocatorRef)NULL,
2679 theString,
2680 separatorString);
2681 _res = Py_BuildValue("O&",
2682 CFArrayRefObj_New, _rv);
2683 return _res;
2684}
2685
2686static PyObject *CF_CFStringIsEncodingAvailable(PyObject *_self, PyObject *_args)
2687{
2688 PyObject *_res = NULL;
2689 Boolean _rv;
2690 CFStringEncoding encoding;
2691 if (!PyArg_ParseTuple(_args, "l",
2692 &encoding))
2693 return NULL;
2694 _rv = CFStringIsEncodingAvailable(encoding);
2695 _res = Py_BuildValue("l",
2696 _rv);
2697 return _res;
2698}
2699
2700static PyObject *CF_CFStringGetNameOfEncoding(PyObject *_self, PyObject *_args)
2701{
2702 PyObject *_res = NULL;
2703 CFStringRef _rv;
2704 CFStringEncoding encoding;
2705 if (!PyArg_ParseTuple(_args, "l",
2706 &encoding))
2707 return NULL;
2708 _rv = CFStringGetNameOfEncoding(encoding);
2709 _res = Py_BuildValue("O&",
2710 CFStringRefObj_New, _rv);
2711 return _res;
2712}
2713
2714static PyObject *CF_CFStringConvertEncodingToNSStringEncoding(PyObject *_self, PyObject *_args)
2715{
2716 PyObject *_res = NULL;
2717 UInt32 _rv;
2718 CFStringEncoding encoding;
2719 if (!PyArg_ParseTuple(_args, "l",
2720 &encoding))
2721 return NULL;
2722 _rv = CFStringConvertEncodingToNSStringEncoding(encoding);
2723 _res = Py_BuildValue("l",
2724 _rv);
2725 return _res;
2726}
2727
2728static PyObject *CF_CFStringConvertNSStringEncodingToEncoding(PyObject *_self, PyObject *_args)
2729{
2730 PyObject *_res = NULL;
2731 CFStringEncoding _rv;
2732 UInt32 encoding;
2733 if (!PyArg_ParseTuple(_args, "l",
2734 &encoding))
2735 return NULL;
2736 _rv = CFStringConvertNSStringEncodingToEncoding(encoding);
2737 _res = Py_BuildValue("l",
2738 _rv);
2739 return _res;
2740}
2741
2742static PyObject *CF_CFStringConvertEncodingToWindowsCodepage(PyObject *_self, PyObject *_args)
2743{
2744 PyObject *_res = NULL;
2745 UInt32 _rv;
2746 CFStringEncoding encoding;
2747 if (!PyArg_ParseTuple(_args, "l",
2748 &encoding))
2749 return NULL;
2750 _rv = CFStringConvertEncodingToWindowsCodepage(encoding);
2751 _res = Py_BuildValue("l",
2752 _rv);
2753 return _res;
2754}
2755
2756static PyObject *CF_CFStringConvertWindowsCodepageToEncoding(PyObject *_self, PyObject *_args)
2757{
2758 PyObject *_res = NULL;
2759 CFStringEncoding _rv;
2760 UInt32 codepage;
2761 if (!PyArg_ParseTuple(_args, "l",
2762 &codepage))
2763 return NULL;
2764 _rv = CFStringConvertWindowsCodepageToEncoding(codepage);
2765 _res = Py_BuildValue("l",
2766 _rv);
2767 return _res;
2768}
2769
2770static PyObject *CF_CFStringConvertEncodingToIANACharSetName(PyObject *_self, PyObject *_args)
2771{
2772 PyObject *_res = NULL;
2773 CFStringRef _rv;
2774 CFStringEncoding encoding;
2775 if (!PyArg_ParseTuple(_args, "l",
2776 &encoding))
2777 return NULL;
2778 _rv = CFStringConvertEncodingToIANACharSetName(encoding);
2779 _res = Py_BuildValue("O&",
2780 CFStringRefObj_New, _rv);
2781 return _res;
2782}
2783
2784static PyObject *CF___CFStringMakeConstantString(PyObject *_self, PyObject *_args)
2785{
2786 PyObject *_res = NULL;
2787 CFStringRef _rv;
2788 char* cStr;
2789 if (!PyArg_ParseTuple(_args, "s",
2790 &cStr))
2791 return NULL;
2792 _rv = __CFStringMakeConstantString(cStr);
2793 _res = Py_BuildValue("O&",
2794 CFStringRefObj_New, _rv);
2795 return _res;
2796}
2797
Jack Jansen7becc912001-06-28 22:08:26 +00002798static PyObject *CF_CFURLGetTypeID(PyObject *_self, PyObject *_args)
2799{
2800 PyObject *_res = NULL;
2801 CFTypeID _rv;
2802 if (!PyArg_ParseTuple(_args, ""))
2803 return NULL;
2804 _rv = CFURLGetTypeID();
2805 _res = Py_BuildValue("l",
2806 _rv);
2807 return _res;
2808}
2809
2810static PyObject *CF_CFURLCreateWithBytes(PyObject *_self, PyObject *_args)
2811{
2812 PyObject *_res = NULL;
2813 CFURLRef _rv;
2814 unsigned char *URLBytes__in__;
2815 long URLBytes__len__;
2816 int URLBytes__in_len__;
2817 CFStringEncoding encoding;
2818 CFURLRef baseURL;
2819 if (!PyArg_ParseTuple(_args, "s#lO&",
2820 &URLBytes__in__, &URLBytes__in_len__,
2821 &encoding,
2822 OptionalCFURLRefObj_Convert, &baseURL))
2823 return NULL;
2824 URLBytes__len__ = URLBytes__in_len__;
2825 _rv = CFURLCreateWithBytes((CFAllocatorRef)NULL,
2826 URLBytes__in__, URLBytes__len__,
2827 encoding,
2828 baseURL);
2829 _res = Py_BuildValue("O&",
2830 CFURLRefObj_New, _rv);
2831 URLBytes__error__: ;
2832 return _res;
2833}
2834
2835static PyObject *CF_CFURLCreateData(PyObject *_self, PyObject *_args)
2836{
2837 PyObject *_res = NULL;
2838 CFDataRef _rv;
2839 CFURLRef url;
2840 CFStringEncoding encoding;
2841 Boolean escapeWhitespace;
2842 if (!PyArg_ParseTuple(_args, "O&ll",
2843 CFURLRefObj_Convert, &url,
2844 &encoding,
2845 &escapeWhitespace))
2846 return NULL;
2847 _rv = CFURLCreateData((CFAllocatorRef)NULL,
2848 url,
2849 encoding,
2850 escapeWhitespace);
2851 _res = Py_BuildValue("O&",
2852 CFDataRefObj_New, _rv);
2853 return _res;
2854}
2855
2856static PyObject *CF_CFURLCreateWithString(PyObject *_self, PyObject *_args)
2857{
2858 PyObject *_res = NULL;
2859 CFURLRef _rv;
2860 CFStringRef URLString;
2861 CFURLRef baseURL;
2862 if (!PyArg_ParseTuple(_args, "O&O&",
2863 CFStringRefObj_Convert, &URLString,
2864 OptionalCFURLRefObj_Convert, &baseURL))
2865 return NULL;
2866 _rv = CFURLCreateWithString((CFAllocatorRef)NULL,
2867 URLString,
2868 baseURL);
2869 _res = Py_BuildValue("O&",
2870 CFURLRefObj_New, _rv);
2871 return _res;
2872}
2873
2874static PyObject *CF_CFURLCreateStringByReplacingPercentEscapes(PyObject *_self, PyObject *_args)
2875{
2876 PyObject *_res = NULL;
2877 CFStringRef _rv;
2878 CFStringRef originalString;
2879 CFStringRef charactersToLeaveEscaped;
2880 if (!PyArg_ParseTuple(_args, "O&O&",
2881 CFStringRefObj_Convert, &originalString,
2882 CFStringRefObj_Convert, &charactersToLeaveEscaped))
2883 return NULL;
2884 _rv = CFURLCreateStringByReplacingPercentEscapes((CFAllocatorRef)NULL,
2885 originalString,
2886 charactersToLeaveEscaped);
2887 _res = Py_BuildValue("O&",
2888 CFStringRefObj_New, _rv);
2889 return _res;
2890}
2891
Jack Jansen686f9c32001-06-26 21:51:18 +00002892static PyMethodDef CF_methods[] = {
2893 {"CFAllocatorGetTypeID", (PyCFunction)CF_CFAllocatorGetTypeID, 1,
2894 "() -> (CFTypeID _rv)"},
2895 {"CFAllocatorGetPreferredSizeForSize", (PyCFunction)CF_CFAllocatorGetPreferredSizeForSize, 1,
2896 "(CFIndex size, CFOptionFlags hint) -> (CFIndex _rv)"},
2897 {"CFCopyTypeIDDescription", (PyCFunction)CF_CFCopyTypeIDDescription, 1,
2898 "(CFTypeID theType) -> (CFStringRef _rv)"},
Jack Jansenbc7c8962001-06-27 22:00:55 +00002899 {"CFArrayGetTypeID", (PyCFunction)CF_CFArrayGetTypeID, 1,
2900 "() -> (CFTypeID _rv)"},
2901 {"CFArrayCreateCopy", (PyCFunction)CF_CFArrayCreateCopy, 1,
2902 "(CFArrayRef srcArray) -> (CFArrayRef _rv)"},
2903 {"CFArrayCreateMutable", (PyCFunction)CF_CFArrayCreateMutable, 1,
2904 "(CFIndex capacity) -> (CFMutableArrayRef _rv)"},
2905 {"CFArrayCreateMutableCopy", (PyCFunction)CF_CFArrayCreateMutableCopy, 1,
2906 "(CFIndex capacity, CFArrayRef srcArray) -> (CFMutableArrayRef _rv)"},
2907 {"CFDataGetTypeID", (PyCFunction)CF_CFDataGetTypeID, 1,
2908 "() -> (CFTypeID _rv)"},
2909 {"CFDataCreate", (PyCFunction)CF_CFDataCreate, 1,
2910 "(Buffer bytes) -> (CFDataRef _rv)"},
2911 {"CFDataCreateWithBytesNoCopy", (PyCFunction)CF_CFDataCreateWithBytesNoCopy, 1,
2912 "(Buffer bytes) -> (CFDataRef _rv)"},
2913 {"CFDataCreateCopy", (PyCFunction)CF_CFDataCreateCopy, 1,
2914 "(CFDataRef data) -> (CFDataRef _rv)"},
2915 {"CFDataCreateMutable", (PyCFunction)CF_CFDataCreateMutable, 1,
2916 "(CFIndex capacity) -> (CFMutableDataRef _rv)"},
2917 {"CFDataCreateMutableCopy", (PyCFunction)CF_CFDataCreateMutableCopy, 1,
2918 "(CFIndex capacity, CFDataRef data) -> (CFMutableDataRef _rv)"},
2919 {"CFDictionaryGetTypeID", (PyCFunction)CF_CFDictionaryGetTypeID, 1,
2920 "() -> (CFTypeID _rv)"},
2921 {"CFDictionaryCreateCopy", (PyCFunction)CF_CFDictionaryCreateCopy, 1,
2922 "(CFDictionaryRef dict) -> (CFDictionaryRef _rv)"},
2923 {"CFDictionaryCreateMutable", (PyCFunction)CF_CFDictionaryCreateMutable, 1,
2924 "(CFIndex capacity) -> (CFMutableDictionaryRef _rv)"},
2925 {"CFDictionaryCreateMutableCopy", (PyCFunction)CF_CFDictionaryCreateMutableCopy, 1,
2926 "(CFIndex capacity, CFDictionaryRef dict) -> (CFMutableDictionaryRef _rv)"},
2927 {"CFStringGetTypeID", (PyCFunction)CF_CFStringGetTypeID, 1,
2928 "() -> (CFTypeID _rv)"},
2929 {"CFStringCreateWithPascalString", (PyCFunction)CF_CFStringCreateWithPascalString, 1,
2930 "(StringPtr pStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
2931 {"CFStringCreateWithCString", (PyCFunction)CF_CFStringCreateWithCString, 1,
2932 "(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
2933 {"CFStringCreateWithPascalStringNoCopy", (PyCFunction)CF_CFStringCreateWithPascalStringNoCopy, 1,
2934 "(StringPtr pStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
2935 {"CFStringCreateWithCStringNoCopy", (PyCFunction)CF_CFStringCreateWithCStringNoCopy, 1,
2936 "(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
2937 {"CFStringCreateWithSubstring", (PyCFunction)CF_CFStringCreateWithSubstring, 1,
2938 "(CFStringRef str, CFRange range) -> (CFStringRef _rv)"},
2939 {"CFStringCreateCopy", (PyCFunction)CF_CFStringCreateCopy, 1,
2940 "(CFStringRef theString) -> (CFStringRef _rv)"},
2941 {"CFStringCreateMutable", (PyCFunction)CF_CFStringCreateMutable, 1,
2942 "(CFIndex maxLength) -> (CFMutableStringRef _rv)"},
2943 {"CFStringCreateMutableCopy", (PyCFunction)CF_CFStringCreateMutableCopy, 1,
2944 "(CFIndex maxLength, CFStringRef theString) -> (CFMutableStringRef _rv)"},
2945 {"CFStringCreateWithBytes", (PyCFunction)CF_CFStringCreateWithBytes, 1,
2946 "(Buffer bytes, CFStringEncoding encoding, Boolean isExternalRepresentation) -> (CFStringRef _rv)"},
2947 {"CFStringCreateFromExternalRepresentation", (PyCFunction)CF_CFStringCreateFromExternalRepresentation, 1,
2948 "(CFDataRef data, CFStringEncoding encoding) -> (CFStringRef _rv)"},
2949 {"CFStringCreateExternalRepresentation", (PyCFunction)CF_CFStringCreateExternalRepresentation, 1,
2950 "(CFStringRef theString, CFStringEncoding encoding, UInt8 lossByte) -> (CFDataRef _rv)"},
2951 {"CFStringGetSystemEncoding", (PyCFunction)CF_CFStringGetSystemEncoding, 1,
2952 "() -> (CFStringEncoding _rv)"},
2953 {"CFStringGetMaximumSizeForEncoding", (PyCFunction)CF_CFStringGetMaximumSizeForEncoding, 1,
2954 "(CFIndex length, CFStringEncoding encoding) -> (CFIndex _rv)"},
2955 {"CFStringCreateArrayWithFindResults", (PyCFunction)CF_CFStringCreateArrayWithFindResults, 1,
2956 "(CFStringRef theString, CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions) -> (CFArrayRef _rv)"},
2957 {"CFStringCreateByCombiningStrings", (PyCFunction)CF_CFStringCreateByCombiningStrings, 1,
2958 "(CFArrayRef theArray, CFStringRef separatorString) -> (CFStringRef _rv)"},
2959 {"CFStringCreateArrayBySeparatingStrings", (PyCFunction)CF_CFStringCreateArrayBySeparatingStrings, 1,
2960 "(CFStringRef theString, CFStringRef separatorString) -> (CFArrayRef _rv)"},
2961 {"CFStringIsEncodingAvailable", (PyCFunction)CF_CFStringIsEncodingAvailable, 1,
2962 "(CFStringEncoding encoding) -> (Boolean _rv)"},
2963 {"CFStringGetNameOfEncoding", (PyCFunction)CF_CFStringGetNameOfEncoding, 1,
2964 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
2965 {"CFStringConvertEncodingToNSStringEncoding", (PyCFunction)CF_CFStringConvertEncodingToNSStringEncoding, 1,
2966 "(CFStringEncoding encoding) -> (UInt32 _rv)"},
2967 {"CFStringConvertNSStringEncodingToEncoding", (PyCFunction)CF_CFStringConvertNSStringEncodingToEncoding, 1,
2968 "(UInt32 encoding) -> (CFStringEncoding _rv)"},
2969 {"CFStringConvertEncodingToWindowsCodepage", (PyCFunction)CF_CFStringConvertEncodingToWindowsCodepage, 1,
2970 "(CFStringEncoding encoding) -> (UInt32 _rv)"},
2971 {"CFStringConvertWindowsCodepageToEncoding", (PyCFunction)CF_CFStringConvertWindowsCodepageToEncoding, 1,
2972 "(UInt32 codepage) -> (CFStringEncoding _rv)"},
2973 {"CFStringConvertEncodingToIANACharSetName", (PyCFunction)CF_CFStringConvertEncodingToIANACharSetName, 1,
2974 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
2975 {"__CFStringMakeConstantString", (PyCFunction)CF___CFStringMakeConstantString, 1,
2976 "(char* cStr) -> (CFStringRef _rv)"},
Jack Jansen7becc912001-06-28 22:08:26 +00002977 {"CFURLGetTypeID", (PyCFunction)CF_CFURLGetTypeID, 1,
2978 "() -> (CFTypeID _rv)"},
2979 {"CFURLCreateWithBytes", (PyCFunction)CF_CFURLCreateWithBytes, 1,
2980 "(Buffer URLBytes, CFStringEncoding encoding, CFURLRef baseURL) -> (CFURLRef _rv)"},
2981 {"CFURLCreateData", (PyCFunction)CF_CFURLCreateData, 1,
2982 "(CFURLRef url, CFStringEncoding encoding, Boolean escapeWhitespace) -> (CFDataRef _rv)"},
2983 {"CFURLCreateWithString", (PyCFunction)CF_CFURLCreateWithString, 1,
2984 "(CFStringRef URLString, CFURLRef baseURL) -> (CFURLRef _rv)"},
2985 {"CFURLCreateStringByReplacingPercentEscapes", (PyCFunction)CF_CFURLCreateStringByReplacingPercentEscapes, 1,
2986 "(CFStringRef originalString, CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
Jack Jansen686f9c32001-06-26 21:51:18 +00002987 {NULL, NULL, 0}
2988};
2989
2990
2991
2992
2993void initCF(void)
2994{
2995 PyObject *m;
2996 PyObject *d;
2997
2998
2999
3000 // PyMac_INIT_TOOLBOX_OBJECT_NEW(Track, TrackObj_New);
3001 // PyMac_INIT_TOOLBOX_OBJECT_CONVERT(Track, TrackObj_Convert);
3002
3003
3004 m = Py_InitModule("CF", CF_methods);
3005 d = PyModule_GetDict(m);
3006 CF_Error = PyMac_GetOSErrException();
3007 if (CF_Error == NULL ||
3008 PyDict_SetItemString(d, "Error", CF_Error) != 0)
3009 return;
3010 CFTypeRef_Type.ob_type = &PyType_Type;
3011 Py_INCREF(&CFTypeRef_Type);
3012 if (PyDict_SetItemString(d, "CFTypeRefType", (PyObject *)&CFTypeRef_Type) != 0)
3013 Py_FatalError("can't initialize CFTypeRefType");
Jack Jansenbc7c8962001-06-27 22:00:55 +00003014 CFArrayRef_Type.ob_type = &PyType_Type;
3015 Py_INCREF(&CFArrayRef_Type);
3016 if (PyDict_SetItemString(d, "CFArrayRefType", (PyObject *)&CFArrayRef_Type) != 0)
3017 Py_FatalError("can't initialize CFArrayRefType");
3018 CFMutableArrayRef_Type.ob_type = &PyType_Type;
3019 Py_INCREF(&CFMutableArrayRef_Type);
3020 if (PyDict_SetItemString(d, "CFMutableArrayRefType", (PyObject *)&CFMutableArrayRef_Type) != 0)
3021 Py_FatalError("can't initialize CFMutableArrayRefType");
3022 CFDictionaryRef_Type.ob_type = &PyType_Type;
3023 Py_INCREF(&CFDictionaryRef_Type);
3024 if (PyDict_SetItemString(d, "CFDictionaryRefType", (PyObject *)&CFDictionaryRef_Type) != 0)
3025 Py_FatalError("can't initialize CFDictionaryRefType");
3026 CFMutableDictionaryRef_Type.ob_type = &PyType_Type;
3027 Py_INCREF(&CFMutableDictionaryRef_Type);
3028 if (PyDict_SetItemString(d, "CFMutableDictionaryRefType", (PyObject *)&CFMutableDictionaryRef_Type) != 0)
3029 Py_FatalError("can't initialize CFMutableDictionaryRefType");
3030 CFDataRef_Type.ob_type = &PyType_Type;
3031 Py_INCREF(&CFDataRef_Type);
3032 if (PyDict_SetItemString(d, "CFDataRefType", (PyObject *)&CFDataRef_Type) != 0)
3033 Py_FatalError("can't initialize CFDataRefType");
3034 CFMutableDataRef_Type.ob_type = &PyType_Type;
3035 Py_INCREF(&CFMutableDataRef_Type);
3036 if (PyDict_SetItemString(d, "CFMutableDataRefType", (PyObject *)&CFMutableDataRef_Type) != 0)
3037 Py_FatalError("can't initialize CFMutableDataRefType");
Jack Jansen686f9c32001-06-26 21:51:18 +00003038 CFStringRef_Type.ob_type = &PyType_Type;
3039 Py_INCREF(&CFStringRef_Type);
3040 if (PyDict_SetItemString(d, "CFStringRefType", (PyObject *)&CFStringRef_Type) != 0)
3041 Py_FatalError("can't initialize CFStringRefType");
Jack Jansenbc7c8962001-06-27 22:00:55 +00003042 CFMutableStringRef_Type.ob_type = &PyType_Type;
3043 Py_INCREF(&CFMutableStringRef_Type);
3044 if (PyDict_SetItemString(d, "CFMutableStringRefType", (PyObject *)&CFMutableStringRef_Type) != 0)
3045 Py_FatalError("can't initialize CFMutableStringRefType");
Jack Jansen7becc912001-06-28 22:08:26 +00003046 CFURLRef_Type.ob_type = &PyType_Type;
3047 Py_INCREF(&CFURLRef_Type);
3048 if (PyDict_SetItemString(d, "CFURLRefType", (PyObject *)&CFURLRef_Type) != 0)
3049 Py_FatalError("can't initialize CFURLRefType");
Jack Jansen686f9c32001-06-26 21:51:18 +00003050}
3051
3052/* ========================= End module CF ========================== */
3053