blob: a7488132c994e54bad9f6e3c4ddae36754a6e064 [file] [log] [blame]
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001
2/* =========================== Module _CF =========================== */
3
4#include "Python.h"
5
6
7
Jack Jansen620a7662001-12-18 15:39:38 +00008#ifdef _WIN32
9#include "pywintoolbox.h"
10#else
Jack Jansen50ecb0a2001-08-23 14:02:09 +000011#include "macglue.h"
12#include "pymactoolbox.h"
Jack Jansen620a7662001-12-18 15:39:38 +000013#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +000014
15/* Macro to test whether a weak-loaded CFM function exists */
16#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
17 PyErr_SetString(PyExc_NotImplementedError, \
18 "Not available in this shared library/OS version"); \
19 return NULL; \
20 }} while(0)
21
22
23#ifdef WITHOUT_FRAMEWORKS
24#include <CFBase.h>
25#include <CFArray.h>
26#include <CFData.h>
27#include <CFDictionary.h>
28#include <CFString.h>
29#include <CFURL.h>
30#else
31#include <CoreServices/CoreServices.h>
32#endif
33
Jack Jansen537a69f2001-11-05 14:39:22 +000034#ifdef USE_TOOLBOX_OBJECT_GLUE
35extern PyObject *_CFTypeRefObj_New(CFTypeRef);
36extern int _CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
37#define CFTypeRefObj_New _CFTypeRefObj_New
38#define CFTypeRefObj_Convert _CFTypeRefObj_Convert
Jack Jansen50ecb0a2001-08-23 14:02:09 +000039
Jack Jansen537a69f2001-11-05 14:39:22 +000040extern PyObject *_CFStringRefObj_New(CFStringRef);
41extern int _CFStringRefObj_Convert(PyObject *, CFStringRef *);
42#define CFStringRefObj_New _CFStringRefObj_New
43#define CFStringRefObj_Convert _CFStringRefObj_Convert
Jack Jansen50ecb0a2001-08-23 14:02:09 +000044
Jack Jansen537a69f2001-11-05 14:39:22 +000045extern PyObject *_CFMutableStringRefObj_New(CFMutableStringRef);
46extern int _CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *);
47#define CFMutableStringRefObj_New _CFMutableStringRefObj_New
48#define CFMutableStringRefObj_Convert _CFMutableStringRefObj_Convert
Jack Jansen50ecb0a2001-08-23 14:02:09 +000049
Jack Jansen537a69f2001-11-05 14:39:22 +000050extern PyObject *_CFArrayRefObj_New(CFArrayRef);
51extern int _CFArrayRefObj_Convert(PyObject *, CFArrayRef *);
52#define CFArrayRefObj_New _CFArrayRefObj_New
53#define CFArrayRefObj_Convert _CFArrayRefObj_Convert
54
55extern PyObject *_CFMutableArrayRefObj_New(CFMutableArrayRef);
56extern int _CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *);
57#define CFMutableArrayRefObj_New _CFMutableArrayRefObj_New
58#define CFMutableArrayRefObj_Convert _CFMutableArrayRefObj_Convert
59
60extern PyObject *_CFDataRefObj_New(CFDataRef);
61extern int _CFDataRefObj_Convert(PyObject *, CFDataRef *);
62#define CFDataRefObj_New _CFDataRefObj_New
63#define CFDataRefObj_Convert _CFDataRefObj_Convert
64
65extern PyObject *_CFMutableDataRefObj_New(CFMutableDataRef);
66extern int _CFMutableDataRefObj_Convert(PyObject *, CFMutableDataRef *);
67#define CFMutableDataRefObj_New _CFMutableDataRefObj_New
68#define CFMutableDataRefObj_Convert _CFMutableDataRefObj_Convert
69
70extern PyObject *_CFDictionaryRefObj_New(CFDictionaryRef);
71extern int _CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *);
72#define CFDictionaryRefObj_New _CFDictionaryRefObj_New
73#define CFDictionaryRefObj_Convert _CFDictionaryRefObj_Convert
74
75extern PyObject *_CFMutableDictionaryRefObj_New(CFMutableDictionaryRef);
76extern int _CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *);
77#define CFMutableDictionaryRefObj_New _CFMutableDictionaryRefObj_New
78#define CFMutableDictionaryRefObj_Convert _CFMutableDictionaryRefObj_Convert
79
80extern PyObject *_CFURLRefObj_New(CFURLRef);
81extern int _CFURLRefObj_Convert(PyObject *, CFURLRef *);
82extern int _OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *);
83#define CFURLRefObj_New _CFURLRefObj_New
84#define CFURLRefObj_Convert _CFURLRefObj_Convert
85#define OptionalCFURLRefObj_Convert _OptionalCFURLRefObj_Convert
Jack Jansen50ecb0a2001-08-23 14:02:09 +000086#endif
87
88/*
89** Parse/generate CFRange records
90*/
91PyObject *CFRange_New(CFRange *itself)
92{
93
94 return Py_BuildValue("ll", (long)itself->location, (long)itself->length);
95}
96
Jack Jansen06d2e1a2001-09-04 22:19:18 +000097int
Jack Jansen50ecb0a2001-08-23 14:02:09 +000098CFRange_Convert(PyObject *v, CFRange *p_itself)
99{
100 long location, length;
101
102 if( !PyArg_ParseTuple(v, "ll", &location, &length) )
103 return 0;
104 p_itself->location = (CFIndex)location;
105 p_itself->length = (CFIndex)length;
106 return 1;
107}
108
109/* Optional CFURL argument or None (passed as NULL) */
110int
111OptionalCFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself)
112{
113 if ( v == Py_None ) {
114 p_itself = NULL;
115 return 1;
116 }
117 return CFURLRefObj_Convert(v, p_itself);
118}
119
120
121static PyObject *CF_Error;
122
123/* --------------------- Object type CFTypeRef ---------------------- */
124
125PyTypeObject CFTypeRef_Type;
126
127#define CFTypeRefObj_Check(x) ((x)->ob_type == &CFTypeRef_Type)
128
129typedef struct CFTypeRefObject {
130 PyObject_HEAD
131 CFTypeRef ob_itself;
132 void (*ob_freeit)(CFTypeRef ptr);
133} CFTypeRefObject;
134
135PyObject *CFTypeRefObj_New(CFTypeRef itself)
136{
137 CFTypeRefObject *it;
138 if (itself == NULL) return PyMac_Error(resNotFound);
139 it = PyObject_NEW(CFTypeRefObject, &CFTypeRef_Type);
140 if (it == NULL) return NULL;
141 it->ob_itself = itself;
142 it->ob_freeit = CFRelease;
143 return (PyObject *)it;
144}
Jack Jansen06d2e1a2001-09-04 22:19:18 +0000145int CFTypeRefObj_Convert(PyObject *v, CFTypeRef *p_itself)
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000146{
147
148 if (v == Py_None) { *p_itself = NULL; return 1; }
149 /* Check for other CF objects here */
150
151 if (!CFTypeRefObj_Check(v))
152 {
153 PyErr_SetString(PyExc_TypeError, "CFTypeRef required");
154 return 0;
155 }
156 *p_itself = ((CFTypeRefObject *)v)->ob_itself;
157 return 1;
158}
159
160static void CFTypeRefObj_dealloc(CFTypeRefObject *self)
161{
162 if (self->ob_freeit && self->ob_itself)
163 {
164 self->ob_freeit((CFTypeRef)self->ob_itself);
165 }
166 PyMem_DEL(self);
167}
168
169static PyObject *CFTypeRefObj_CFGetTypeID(CFTypeRefObject *_self, PyObject *_args)
170{
171 PyObject *_res = NULL;
172 CFTypeID _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +0000173#ifndef CFGetTypeID
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000174 PyMac_PRECHECK(CFGetTypeID);
Jack Jansenb3be2162001-11-30 14:16:36 +0000175#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000176 if (!PyArg_ParseTuple(_args, ""))
177 return NULL;
178 _rv = CFGetTypeID(_self->ob_itself);
179 _res = Py_BuildValue("l",
180 _rv);
181 return _res;
182}
183
184static PyObject *CFTypeRefObj_CFRetain(CFTypeRefObject *_self, PyObject *_args)
185{
186 PyObject *_res = NULL;
187 CFTypeRef _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +0000188#ifndef CFRetain
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000189 PyMac_PRECHECK(CFRetain);
Jack Jansenb3be2162001-11-30 14:16:36 +0000190#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000191 if (!PyArg_ParseTuple(_args, ""))
192 return NULL;
193 _rv = CFRetain(_self->ob_itself);
194 _res = Py_BuildValue("O&",
195 CFTypeRefObj_New, _rv);
196 return _res;
197}
198
199static PyObject *CFTypeRefObj_CFRelease(CFTypeRefObject *_self, PyObject *_args)
200{
201 PyObject *_res = NULL;
Jack Jansenb3be2162001-11-30 14:16:36 +0000202#ifndef CFRelease
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000203 PyMac_PRECHECK(CFRelease);
Jack Jansenb3be2162001-11-30 14:16:36 +0000204#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000205 if (!PyArg_ParseTuple(_args, ""))
206 return NULL;
207 CFRelease(_self->ob_itself);
208 Py_INCREF(Py_None);
209 _res = Py_None;
210 return _res;
211}
212
213static PyObject *CFTypeRefObj_CFGetRetainCount(CFTypeRefObject *_self, PyObject *_args)
214{
215 PyObject *_res = NULL;
216 CFIndex _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +0000217#ifndef CFGetRetainCount
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000218 PyMac_PRECHECK(CFGetRetainCount);
Jack Jansenb3be2162001-11-30 14:16:36 +0000219#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000220 if (!PyArg_ParseTuple(_args, ""))
221 return NULL;
222 _rv = CFGetRetainCount(_self->ob_itself);
223 _res = Py_BuildValue("l",
224 _rv);
225 return _res;
226}
227
228static PyObject *CFTypeRefObj_CFEqual(CFTypeRefObject *_self, PyObject *_args)
229{
230 PyObject *_res = NULL;
231 Boolean _rv;
232 CFTypeRef cf2;
Jack Jansenb3be2162001-11-30 14:16:36 +0000233#ifndef CFEqual
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000234 PyMac_PRECHECK(CFEqual);
Jack Jansenb3be2162001-11-30 14:16:36 +0000235#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000236 if (!PyArg_ParseTuple(_args, "O&",
237 CFTypeRefObj_Convert, &cf2))
238 return NULL;
239 _rv = CFEqual(_self->ob_itself,
240 cf2);
241 _res = Py_BuildValue("l",
242 _rv);
243 return _res;
244}
245
246static PyObject *CFTypeRefObj_CFHash(CFTypeRefObject *_self, PyObject *_args)
247{
248 PyObject *_res = NULL;
249 CFHashCode _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +0000250#ifndef CFHash
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000251 PyMac_PRECHECK(CFHash);
Jack Jansenb3be2162001-11-30 14:16:36 +0000252#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000253 if (!PyArg_ParseTuple(_args, ""))
254 return NULL;
255 _rv = CFHash(_self->ob_itself);
256 _res = Py_BuildValue("l",
257 _rv);
258 return _res;
259}
260
261static PyObject *CFTypeRefObj_CFCopyDescription(CFTypeRefObject *_self, PyObject *_args)
262{
263 PyObject *_res = NULL;
264 CFStringRef _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +0000265#ifndef CFCopyDescription
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000266 PyMac_PRECHECK(CFCopyDescription);
Jack Jansenb3be2162001-11-30 14:16:36 +0000267#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000268 if (!PyArg_ParseTuple(_args, ""))
269 return NULL;
270 _rv = CFCopyDescription(_self->ob_itself);
271 _res = Py_BuildValue("O&",
272 CFStringRefObj_New, _rv);
273 return _res;
274}
275
276static PyObject *CFTypeRefObj_CFShow(CFTypeRefObject *_self, PyObject *_args)
277{
278 PyObject *_res = NULL;
Jack Jansenb3be2162001-11-30 14:16:36 +0000279#ifndef CFShow
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000280 PyMac_PRECHECK(CFShow);
Jack Jansenb3be2162001-11-30 14:16:36 +0000281#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000282 if (!PyArg_ParseTuple(_args, ""))
283 return NULL;
284 CFShow(_self->ob_itself);
285 Py_INCREF(Py_None);
286 _res = Py_None;
287 return _res;
288}
289
290static PyMethodDef CFTypeRefObj_methods[] = {
291 {"CFGetTypeID", (PyCFunction)CFTypeRefObj_CFGetTypeID, 1,
292 "() -> (CFTypeID _rv)"},
293 {"CFRetain", (PyCFunction)CFTypeRefObj_CFRetain, 1,
294 "() -> (CFTypeRef _rv)"},
295 {"CFRelease", (PyCFunction)CFTypeRefObj_CFRelease, 1,
296 "() -> None"},
297 {"CFGetRetainCount", (PyCFunction)CFTypeRefObj_CFGetRetainCount, 1,
298 "() -> (CFIndex _rv)"},
299 {"CFEqual", (PyCFunction)CFTypeRefObj_CFEqual, 1,
300 "(CFTypeRef cf2) -> (Boolean _rv)"},
301 {"CFHash", (PyCFunction)CFTypeRefObj_CFHash, 1,
302 "() -> (CFHashCode _rv)"},
303 {"CFCopyDescription", (PyCFunction)CFTypeRefObj_CFCopyDescription, 1,
304 "() -> (CFStringRef _rv)"},
305 {"CFShow", (PyCFunction)CFTypeRefObj_CFShow, 1,
306 "() -> None"},
307 {NULL, NULL, 0}
308};
309
310PyMethodChain CFTypeRefObj_chain = { CFTypeRefObj_methods, NULL };
311
312static PyObject *CFTypeRefObj_getattr(CFTypeRefObject *self, char *name)
313{
314 return Py_FindMethodInChain(&CFTypeRefObj_chain, (PyObject *)self, name);
315}
316
317#define CFTypeRefObj_setattr NULL
318
319static int CFTypeRefObj_compare(CFTypeRefObject *self, CFTypeRefObject *other)
320{
321 /* XXXX Or should we use CFEqual?? */
322 if ( self->ob_itself > other->ob_itself ) return 1;
323 if ( self->ob_itself < other->ob_itself ) return -1;
324 return 0;
325}
326
327static PyObject * CFTypeRefObj_repr(CFTypeRefObject *self)
328{
329 char buf[100];
Jack Jansenfd064862001-09-05 10:31:52 +0000330 sprintf(buf, "<CFTypeRef type-%d object at 0x%8.8x for 0x%8.8x>", CFGetTypeID(self->ob_itself), (unsigned)self, (unsigned)self->ob_itself);
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000331 return PyString_FromString(buf);
332}
333
334static int CFTypeRefObj_hash(CFTypeRefObject *self)
335{
336 /* XXXX Or should we use CFHash?? */
337 return (int)self->ob_itself;
338}
339
340PyTypeObject CFTypeRef_Type = {
Jack Jansenb3be2162001-11-30 14:16:36 +0000341 PyObject_HEAD_INIT(NULL)
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000342 0, /*ob_size*/
Guido van Rossum14648392001-12-08 18:02:58 +0000343 "_CF.CFTypeRef", /*tp_name*/
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000344 sizeof(CFTypeRefObject), /*tp_basicsize*/
345 0, /*tp_itemsize*/
346 /* methods */
347 (destructor) CFTypeRefObj_dealloc, /*tp_dealloc*/
348 0, /*tp_print*/
349 (getattrfunc) CFTypeRefObj_getattr, /*tp_getattr*/
350 (setattrfunc) CFTypeRefObj_setattr, /*tp_setattr*/
351 (cmpfunc) CFTypeRefObj_compare, /*tp_compare*/
352 (reprfunc) CFTypeRefObj_repr, /*tp_repr*/
353 (PyNumberMethods *)0, /* tp_as_number */
354 (PySequenceMethods *)0, /* tp_as_sequence */
355 (PyMappingMethods *)0, /* tp_as_mapping */
356 (hashfunc) CFTypeRefObj_hash, /*tp_hash*/
357};
358
359/* ------------------- End object type CFTypeRef -------------------- */
360
361
362/* --------------------- Object type CFArrayRef --------------------- */
363
364PyTypeObject CFArrayRef_Type;
365
366#define CFArrayRefObj_Check(x) ((x)->ob_type == &CFArrayRef_Type)
367
368typedef struct CFArrayRefObject {
369 PyObject_HEAD
370 CFArrayRef ob_itself;
371 void (*ob_freeit)(CFTypeRef ptr);
372} CFArrayRefObject;
373
374PyObject *CFArrayRefObj_New(CFArrayRef itself)
375{
376 CFArrayRefObject *it;
377 if (itself == NULL) return PyMac_Error(resNotFound);
378 it = PyObject_NEW(CFArrayRefObject, &CFArrayRef_Type);
379 if (it == NULL) return NULL;
380 it->ob_itself = itself;
381 it->ob_freeit = CFRelease;
382 return (PyObject *)it;
383}
Jack Jansen06d2e1a2001-09-04 22:19:18 +0000384int CFArrayRefObj_Convert(PyObject *v, CFArrayRef *p_itself)
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000385{
386
387 if (v == Py_None) { *p_itself = NULL; return 1; }
388 /* Check for other CF objects here */
389
390 if (!CFArrayRefObj_Check(v))
391 {
392 PyErr_SetString(PyExc_TypeError, "CFArrayRef required");
393 return 0;
394 }
395 *p_itself = ((CFArrayRefObject *)v)->ob_itself;
396 return 1;
397}
398
399static void CFArrayRefObj_dealloc(CFArrayRefObject *self)
400{
401 if (self->ob_freeit && self->ob_itself)
402 {
403 self->ob_freeit((CFTypeRef)self->ob_itself);
404 }
405 PyMem_DEL(self);
406}
407
408static PyObject *CFArrayRefObj_CFArrayCreateCopy(CFArrayRefObject *_self, PyObject *_args)
409{
410 PyObject *_res = NULL;
411 CFArrayRef _rv;
412 if (!PyArg_ParseTuple(_args, ""))
413 return NULL;
414 _rv = CFArrayCreateCopy((CFAllocatorRef)NULL,
415 _self->ob_itself);
416 _res = Py_BuildValue("O&",
417 CFArrayRefObj_New, _rv);
418 return _res;
419}
420
421static PyObject *CFArrayRefObj_CFArrayGetCount(CFArrayRefObject *_self, PyObject *_args)
422{
423 PyObject *_res = NULL;
424 CFIndex _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +0000425#ifndef CFArrayGetCount
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000426 PyMac_PRECHECK(CFArrayGetCount);
Jack Jansenb3be2162001-11-30 14:16:36 +0000427#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000428 if (!PyArg_ParseTuple(_args, ""))
429 return NULL;
430 _rv = CFArrayGetCount(_self->ob_itself);
431 _res = Py_BuildValue("l",
432 _rv);
433 return _res;
434}
435
436static PyObject *CFArrayRefObj_CFStringCreateByCombiningStrings(CFArrayRefObject *_self, PyObject *_args)
437{
438 PyObject *_res = NULL;
439 CFStringRef _rv;
440 CFStringRef separatorString;
441 if (!PyArg_ParseTuple(_args, "O&",
442 CFStringRefObj_Convert, &separatorString))
443 return NULL;
444 _rv = CFStringCreateByCombiningStrings((CFAllocatorRef)NULL,
445 _self->ob_itself,
446 separatorString);
447 _res = Py_BuildValue("O&",
448 CFStringRefObj_New, _rv);
449 return _res;
450}
451
452static PyMethodDef CFArrayRefObj_methods[] = {
453 {"CFArrayCreateCopy", (PyCFunction)CFArrayRefObj_CFArrayCreateCopy, 1,
454 "() -> (CFArrayRef _rv)"},
455 {"CFArrayGetCount", (PyCFunction)CFArrayRefObj_CFArrayGetCount, 1,
456 "() -> (CFIndex _rv)"},
457 {"CFStringCreateByCombiningStrings", (PyCFunction)CFArrayRefObj_CFStringCreateByCombiningStrings, 1,
458 "(CFStringRef separatorString) -> (CFStringRef _rv)"},
459 {NULL, NULL, 0}
460};
461
462PyMethodChain CFArrayRefObj_chain = { CFArrayRefObj_methods, &CFTypeRefObj_chain };
463
464static PyObject *CFArrayRefObj_getattr(CFArrayRefObject *self, char *name)
465{
466 return Py_FindMethodInChain(&CFArrayRefObj_chain, (PyObject *)self, name);
467}
468
469#define CFArrayRefObj_setattr NULL
470
471static int CFArrayRefObj_compare(CFArrayRefObject *self, CFArrayRefObject *other)
472{
473 /* XXXX Or should we use CFEqual?? */
474 if ( self->ob_itself > other->ob_itself ) return 1;
475 if ( self->ob_itself < other->ob_itself ) return -1;
476 return 0;
477}
478
479static PyObject * CFArrayRefObj_repr(CFArrayRefObject *self)
480{
481 char buf[100];
Jack Jansenfd064862001-09-05 10:31:52 +0000482 sprintf(buf, "<CFArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000483 return PyString_FromString(buf);
484}
485
486static int CFArrayRefObj_hash(CFArrayRefObject *self)
487{
488 /* XXXX Or should we use CFHash?? */
489 return (int)self->ob_itself;
490}
491
492PyTypeObject CFArrayRef_Type = {
Jack Jansenb3be2162001-11-30 14:16:36 +0000493 PyObject_HEAD_INIT(NULL)
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000494 0, /*ob_size*/
Guido van Rossum14648392001-12-08 18:02:58 +0000495 "_CF.CFArrayRef", /*tp_name*/
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000496 sizeof(CFArrayRefObject), /*tp_basicsize*/
497 0, /*tp_itemsize*/
498 /* methods */
499 (destructor) CFArrayRefObj_dealloc, /*tp_dealloc*/
500 0, /*tp_print*/
501 (getattrfunc) CFArrayRefObj_getattr, /*tp_getattr*/
502 (setattrfunc) CFArrayRefObj_setattr, /*tp_setattr*/
503 (cmpfunc) CFArrayRefObj_compare, /*tp_compare*/
504 (reprfunc) CFArrayRefObj_repr, /*tp_repr*/
505 (PyNumberMethods *)0, /* tp_as_number */
506 (PySequenceMethods *)0, /* tp_as_sequence */
507 (PyMappingMethods *)0, /* tp_as_mapping */
508 (hashfunc) CFArrayRefObj_hash, /*tp_hash*/
509};
510
511/* ------------------- End object type CFArrayRef ------------------- */
512
513
514/* ----------------- Object type CFMutableArrayRef ------------------ */
515
516PyTypeObject CFMutableArrayRef_Type;
517
518#define CFMutableArrayRefObj_Check(x) ((x)->ob_type == &CFMutableArrayRef_Type)
519
520typedef struct CFMutableArrayRefObject {
521 PyObject_HEAD
522 CFMutableArrayRef ob_itself;
523 void (*ob_freeit)(CFTypeRef ptr);
524} CFMutableArrayRefObject;
525
526PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef itself)
527{
528 CFMutableArrayRefObject *it;
529 if (itself == NULL) return PyMac_Error(resNotFound);
530 it = PyObject_NEW(CFMutableArrayRefObject, &CFMutableArrayRef_Type);
531 if (it == NULL) return NULL;
532 it->ob_itself = itself;
533 it->ob_freeit = CFRelease;
534 return (PyObject *)it;
535}
Jack Jansen06d2e1a2001-09-04 22:19:18 +0000536int CFMutableArrayRefObj_Convert(PyObject *v, CFMutableArrayRef *p_itself)
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000537{
538
539 if (v == Py_None) { *p_itself = NULL; return 1; }
540 /* Check for other CF objects here */
541
542 if (!CFMutableArrayRefObj_Check(v))
543 {
544 PyErr_SetString(PyExc_TypeError, "CFMutableArrayRef required");
545 return 0;
546 }
547 *p_itself = ((CFMutableArrayRefObject *)v)->ob_itself;
548 return 1;
549}
550
551static void CFMutableArrayRefObj_dealloc(CFMutableArrayRefObject *self)
552{
553 if (self->ob_freeit && self->ob_itself)
554 {
555 self->ob_freeit((CFTypeRef)self->ob_itself);
556 }
557 PyMem_DEL(self);
558}
559
560static PyObject *CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRefObject *_self, PyObject *_args)
561{
562 PyObject *_res = NULL;
563 CFIndex idx;
Jack Jansenb3be2162001-11-30 14:16:36 +0000564#ifndef CFArrayRemoveValueAtIndex
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000565 PyMac_PRECHECK(CFArrayRemoveValueAtIndex);
Jack Jansenb3be2162001-11-30 14:16:36 +0000566#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000567 if (!PyArg_ParseTuple(_args, "l",
568 &idx))
569 return NULL;
570 CFArrayRemoveValueAtIndex(_self->ob_itself,
571 idx);
572 Py_INCREF(Py_None);
573 _res = Py_None;
574 return _res;
575}
576
577static PyObject *CFMutableArrayRefObj_CFArrayRemoveAllValues(CFMutableArrayRefObject *_self, PyObject *_args)
578{
579 PyObject *_res = NULL;
Jack Jansenb3be2162001-11-30 14:16:36 +0000580#ifndef CFArrayRemoveAllValues
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000581 PyMac_PRECHECK(CFArrayRemoveAllValues);
Jack Jansenb3be2162001-11-30 14:16:36 +0000582#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000583 if (!PyArg_ParseTuple(_args, ""))
584 return NULL;
585 CFArrayRemoveAllValues(_self->ob_itself);
586 Py_INCREF(Py_None);
587 _res = Py_None;
588 return _res;
589}
590
591static PyObject *CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices(CFMutableArrayRefObject *_self, PyObject *_args)
592{
593 PyObject *_res = NULL;
594 CFIndex idx1;
595 CFIndex idx2;
Jack Jansenb3be2162001-11-30 14:16:36 +0000596#ifndef CFArrayExchangeValuesAtIndices
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000597 PyMac_PRECHECK(CFArrayExchangeValuesAtIndices);
Jack Jansenb3be2162001-11-30 14:16:36 +0000598#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000599 if (!PyArg_ParseTuple(_args, "ll",
600 &idx1,
601 &idx2))
602 return NULL;
603 CFArrayExchangeValuesAtIndices(_self->ob_itself,
604 idx1,
605 idx2);
606 Py_INCREF(Py_None);
607 _res = Py_None;
608 return _res;
609}
610
Jack Jansen2168e9d2001-12-16 20:18:40 +0000611static PyObject *CFMutableArrayRefObj_CFArrayAppendArray(CFMutableArrayRefObject *_self, PyObject *_args)
612{
613 PyObject *_res = NULL;
614 CFArrayRef otherArray;
615 CFRange otherRange;
616#ifndef CFArrayAppendArray
617 PyMac_PRECHECK(CFArrayAppendArray);
618#endif
619 if (!PyArg_ParseTuple(_args, "O&O&",
620 CFArrayRefObj_Convert, &otherArray,
621 CFRange_Convert, &otherRange))
622 return NULL;
623 CFArrayAppendArray(_self->ob_itself,
624 otherArray,
625 otherRange);
626 Py_INCREF(Py_None);
627 _res = Py_None;
628 return _res;
629}
630
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000631static PyMethodDef CFMutableArrayRefObj_methods[] = {
632 {"CFArrayRemoveValueAtIndex", (PyCFunction)CFMutableArrayRefObj_CFArrayRemoveValueAtIndex, 1,
633 "(CFIndex idx) -> None"},
634 {"CFArrayRemoveAllValues", (PyCFunction)CFMutableArrayRefObj_CFArrayRemoveAllValues, 1,
635 "() -> None"},
636 {"CFArrayExchangeValuesAtIndices", (PyCFunction)CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices, 1,
637 "(CFIndex idx1, CFIndex idx2) -> None"},
Jack Jansen2168e9d2001-12-16 20:18:40 +0000638 {"CFArrayAppendArray", (PyCFunction)CFMutableArrayRefObj_CFArrayAppendArray, 1,
639 "(CFArrayRef otherArray, CFRange otherRange) -> None"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000640 {NULL, NULL, 0}
641};
642
643PyMethodChain CFMutableArrayRefObj_chain = { CFMutableArrayRefObj_methods, &CFArrayRefObj_chain };
644
645static PyObject *CFMutableArrayRefObj_getattr(CFMutableArrayRefObject *self, char *name)
646{
647 return Py_FindMethodInChain(&CFMutableArrayRefObj_chain, (PyObject *)self, name);
648}
649
650#define CFMutableArrayRefObj_setattr NULL
651
652static int CFMutableArrayRefObj_compare(CFMutableArrayRefObject *self, CFMutableArrayRefObject *other)
653{
654 /* XXXX Or should we use CFEqual?? */
655 if ( self->ob_itself > other->ob_itself ) return 1;
656 if ( self->ob_itself < other->ob_itself ) return -1;
657 return 0;
658}
659
660static PyObject * CFMutableArrayRefObj_repr(CFMutableArrayRefObject *self)
661{
662 char buf[100];
Jack Jansenfd064862001-09-05 10:31:52 +0000663 sprintf(buf, "<CFMutableArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000664 return PyString_FromString(buf);
665}
666
667static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject *self)
668{
669 /* XXXX Or should we use CFHash?? */
670 return (int)self->ob_itself;
671}
672
673PyTypeObject CFMutableArrayRef_Type = {
Jack Jansenb3be2162001-11-30 14:16:36 +0000674 PyObject_HEAD_INIT(NULL)
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000675 0, /*ob_size*/
Guido van Rossum14648392001-12-08 18:02:58 +0000676 "_CF.CFMutableArrayRef", /*tp_name*/
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000677 sizeof(CFMutableArrayRefObject), /*tp_basicsize*/
678 0, /*tp_itemsize*/
679 /* methods */
680 (destructor) CFMutableArrayRefObj_dealloc, /*tp_dealloc*/
681 0, /*tp_print*/
682 (getattrfunc) CFMutableArrayRefObj_getattr, /*tp_getattr*/
683 (setattrfunc) CFMutableArrayRefObj_setattr, /*tp_setattr*/
684 (cmpfunc) CFMutableArrayRefObj_compare, /*tp_compare*/
685 (reprfunc) CFMutableArrayRefObj_repr, /*tp_repr*/
686 (PyNumberMethods *)0, /* tp_as_number */
687 (PySequenceMethods *)0, /* tp_as_sequence */
688 (PyMappingMethods *)0, /* tp_as_mapping */
689 (hashfunc) CFMutableArrayRefObj_hash, /*tp_hash*/
690};
691
692/* --------------- End object type CFMutableArrayRef ---------------- */
693
694
695/* ------------------ Object type CFDictionaryRef ------------------- */
696
697PyTypeObject CFDictionaryRef_Type;
698
699#define CFDictionaryRefObj_Check(x) ((x)->ob_type == &CFDictionaryRef_Type)
700
701typedef struct CFDictionaryRefObject {
702 PyObject_HEAD
703 CFDictionaryRef ob_itself;
704 void (*ob_freeit)(CFTypeRef ptr);
705} CFDictionaryRefObject;
706
707PyObject *CFDictionaryRefObj_New(CFDictionaryRef itself)
708{
709 CFDictionaryRefObject *it;
710 if (itself == NULL) return PyMac_Error(resNotFound);
711 it = PyObject_NEW(CFDictionaryRefObject, &CFDictionaryRef_Type);
712 if (it == NULL) return NULL;
713 it->ob_itself = itself;
714 it->ob_freeit = CFRelease;
715 return (PyObject *)it;
716}
Jack Jansen06d2e1a2001-09-04 22:19:18 +0000717int CFDictionaryRefObj_Convert(PyObject *v, CFDictionaryRef *p_itself)
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000718{
719
720 if (v == Py_None) { *p_itself = NULL; return 1; }
721 /* Check for other CF objects here */
722
723 if (!CFDictionaryRefObj_Check(v))
724 {
725 PyErr_SetString(PyExc_TypeError, "CFDictionaryRef required");
726 return 0;
727 }
728 *p_itself = ((CFDictionaryRefObject *)v)->ob_itself;
729 return 1;
730}
731
732static void CFDictionaryRefObj_dealloc(CFDictionaryRefObject *self)
733{
734 if (self->ob_freeit && self->ob_itself)
735 {
736 self->ob_freeit((CFTypeRef)self->ob_itself);
737 }
738 PyMem_DEL(self);
739}
740
741static PyObject *CFDictionaryRefObj_CFDictionaryCreateCopy(CFDictionaryRefObject *_self, PyObject *_args)
742{
743 PyObject *_res = NULL;
744 CFDictionaryRef _rv;
745 if (!PyArg_ParseTuple(_args, ""))
746 return NULL;
747 _rv = CFDictionaryCreateCopy((CFAllocatorRef)NULL,
748 _self->ob_itself);
749 _res = Py_BuildValue("O&",
750 CFDictionaryRefObj_New, _rv);
751 return _res;
752}
753
754static PyObject *CFDictionaryRefObj_CFDictionaryGetCount(CFDictionaryRefObject *_self, PyObject *_args)
755{
756 PyObject *_res = NULL;
757 CFIndex _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +0000758#ifndef CFDictionaryGetCount
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000759 PyMac_PRECHECK(CFDictionaryGetCount);
Jack Jansenb3be2162001-11-30 14:16:36 +0000760#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000761 if (!PyArg_ParseTuple(_args, ""))
762 return NULL;
763 _rv = CFDictionaryGetCount(_self->ob_itself);
764 _res = Py_BuildValue("l",
765 _rv);
766 return _res;
767}
768
769static PyMethodDef CFDictionaryRefObj_methods[] = {
770 {"CFDictionaryCreateCopy", (PyCFunction)CFDictionaryRefObj_CFDictionaryCreateCopy, 1,
771 "() -> (CFDictionaryRef _rv)"},
772 {"CFDictionaryGetCount", (PyCFunction)CFDictionaryRefObj_CFDictionaryGetCount, 1,
773 "() -> (CFIndex _rv)"},
774 {NULL, NULL, 0}
775};
776
777PyMethodChain CFDictionaryRefObj_chain = { CFDictionaryRefObj_methods, &CFTypeRefObj_chain };
778
779static PyObject *CFDictionaryRefObj_getattr(CFDictionaryRefObject *self, char *name)
780{
781 return Py_FindMethodInChain(&CFDictionaryRefObj_chain, (PyObject *)self, name);
782}
783
784#define CFDictionaryRefObj_setattr NULL
785
786static int CFDictionaryRefObj_compare(CFDictionaryRefObject *self, CFDictionaryRefObject *other)
787{
788 /* XXXX Or should we use CFEqual?? */
789 if ( self->ob_itself > other->ob_itself ) return 1;
790 if ( self->ob_itself < other->ob_itself ) return -1;
791 return 0;
792}
793
794static PyObject * CFDictionaryRefObj_repr(CFDictionaryRefObject *self)
795{
796 char buf[100];
Jack Jansenfd064862001-09-05 10:31:52 +0000797 sprintf(buf, "<CFDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000798 return PyString_FromString(buf);
799}
800
801static int CFDictionaryRefObj_hash(CFDictionaryRefObject *self)
802{
803 /* XXXX Or should we use CFHash?? */
804 return (int)self->ob_itself;
805}
806
807PyTypeObject CFDictionaryRef_Type = {
Jack Jansenb3be2162001-11-30 14:16:36 +0000808 PyObject_HEAD_INIT(NULL)
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000809 0, /*ob_size*/
Guido van Rossum14648392001-12-08 18:02:58 +0000810 "_CF.CFDictionaryRef", /*tp_name*/
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000811 sizeof(CFDictionaryRefObject), /*tp_basicsize*/
812 0, /*tp_itemsize*/
813 /* methods */
814 (destructor) CFDictionaryRefObj_dealloc, /*tp_dealloc*/
815 0, /*tp_print*/
816 (getattrfunc) CFDictionaryRefObj_getattr, /*tp_getattr*/
817 (setattrfunc) CFDictionaryRefObj_setattr, /*tp_setattr*/
818 (cmpfunc) CFDictionaryRefObj_compare, /*tp_compare*/
819 (reprfunc) CFDictionaryRefObj_repr, /*tp_repr*/
820 (PyNumberMethods *)0, /* tp_as_number */
821 (PySequenceMethods *)0, /* tp_as_sequence */
822 (PyMappingMethods *)0, /* tp_as_mapping */
823 (hashfunc) CFDictionaryRefObj_hash, /*tp_hash*/
824};
825
826/* ---------------- End object type CFDictionaryRef ----------------- */
827
828
829/* --------------- Object type CFMutableDictionaryRef --------------- */
830
831PyTypeObject CFMutableDictionaryRef_Type;
832
833#define CFMutableDictionaryRefObj_Check(x) ((x)->ob_type == &CFMutableDictionaryRef_Type)
834
835typedef struct CFMutableDictionaryRefObject {
836 PyObject_HEAD
837 CFMutableDictionaryRef ob_itself;
838 void (*ob_freeit)(CFTypeRef ptr);
839} CFMutableDictionaryRefObject;
840
841PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef itself)
842{
843 CFMutableDictionaryRefObject *it;
844 if (itself == NULL) return PyMac_Error(resNotFound);
845 it = PyObject_NEW(CFMutableDictionaryRefObject, &CFMutableDictionaryRef_Type);
846 if (it == NULL) return NULL;
847 it->ob_itself = itself;
848 it->ob_freeit = CFRelease;
849 return (PyObject *)it;
850}
Jack Jansen06d2e1a2001-09-04 22:19:18 +0000851int CFMutableDictionaryRefObj_Convert(PyObject *v, CFMutableDictionaryRef *p_itself)
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000852{
853
854 if (v == Py_None) { *p_itself = NULL; return 1; }
855 /* Check for other CF objects here */
856
857 if (!CFMutableDictionaryRefObj_Check(v))
858 {
859 PyErr_SetString(PyExc_TypeError, "CFMutableDictionaryRef required");
860 return 0;
861 }
862 *p_itself = ((CFMutableDictionaryRefObject *)v)->ob_itself;
863 return 1;
864}
865
866static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject *self)
867{
868 if (self->ob_freeit && self->ob_itself)
869 {
870 self->ob_freeit((CFTypeRef)self->ob_itself);
871 }
872 PyMem_DEL(self);
873}
874
875static PyObject *CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject *_self, PyObject *_args)
876{
877 PyObject *_res = NULL;
Jack Jansenb3be2162001-11-30 14:16:36 +0000878#ifndef CFDictionaryRemoveAllValues
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000879 PyMac_PRECHECK(CFDictionaryRemoveAllValues);
Jack Jansenb3be2162001-11-30 14:16:36 +0000880#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000881 if (!PyArg_ParseTuple(_args, ""))
882 return NULL;
883 CFDictionaryRemoveAllValues(_self->ob_itself);
884 Py_INCREF(Py_None);
885 _res = Py_None;
886 return _res;
887}
888
889static PyMethodDef CFMutableDictionaryRefObj_methods[] = {
890 {"CFDictionaryRemoveAllValues", (PyCFunction)CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues, 1,
891 "() -> None"},
892 {NULL, NULL, 0}
893};
894
895PyMethodChain CFMutableDictionaryRefObj_chain = { CFMutableDictionaryRefObj_methods, &CFDictionaryRefObj_chain };
896
897static PyObject *CFMutableDictionaryRefObj_getattr(CFMutableDictionaryRefObject *self, char *name)
898{
899 return Py_FindMethodInChain(&CFMutableDictionaryRefObj_chain, (PyObject *)self, name);
900}
901
902#define CFMutableDictionaryRefObj_setattr NULL
903
904static int CFMutableDictionaryRefObj_compare(CFMutableDictionaryRefObject *self, CFMutableDictionaryRefObject *other)
905{
906 /* XXXX Or should we use CFEqual?? */
907 if ( self->ob_itself > other->ob_itself ) return 1;
908 if ( self->ob_itself < other->ob_itself ) return -1;
909 return 0;
910}
911
912static PyObject * CFMutableDictionaryRefObj_repr(CFMutableDictionaryRefObject *self)
913{
914 char buf[100];
Jack Jansenfd064862001-09-05 10:31:52 +0000915 sprintf(buf, "<CFMutableDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000916 return PyString_FromString(buf);
917}
918
919static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject *self)
920{
921 /* XXXX Or should we use CFHash?? */
922 return (int)self->ob_itself;
923}
924
925PyTypeObject CFMutableDictionaryRef_Type = {
Jack Jansenb3be2162001-11-30 14:16:36 +0000926 PyObject_HEAD_INIT(NULL)
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000927 0, /*ob_size*/
Guido van Rossum14648392001-12-08 18:02:58 +0000928 "_CF.CFMutableDictionaryRef", /*tp_name*/
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000929 sizeof(CFMutableDictionaryRefObject), /*tp_basicsize*/
930 0, /*tp_itemsize*/
931 /* methods */
932 (destructor) CFMutableDictionaryRefObj_dealloc, /*tp_dealloc*/
933 0, /*tp_print*/
934 (getattrfunc) CFMutableDictionaryRefObj_getattr, /*tp_getattr*/
935 (setattrfunc) CFMutableDictionaryRefObj_setattr, /*tp_setattr*/
936 (cmpfunc) CFMutableDictionaryRefObj_compare, /*tp_compare*/
937 (reprfunc) CFMutableDictionaryRefObj_repr, /*tp_repr*/
938 (PyNumberMethods *)0, /* tp_as_number */
939 (PySequenceMethods *)0, /* tp_as_sequence */
940 (PyMappingMethods *)0, /* tp_as_mapping */
941 (hashfunc) CFMutableDictionaryRefObj_hash, /*tp_hash*/
942};
943
944/* ------------- End object type CFMutableDictionaryRef ------------- */
945
946
947/* --------------------- Object type CFDataRef ---------------------- */
948
949PyTypeObject CFDataRef_Type;
950
951#define CFDataRefObj_Check(x) ((x)->ob_type == &CFDataRef_Type)
952
953typedef struct CFDataRefObject {
954 PyObject_HEAD
955 CFDataRef ob_itself;
956 void (*ob_freeit)(CFTypeRef ptr);
957} CFDataRefObject;
958
959PyObject *CFDataRefObj_New(CFDataRef itself)
960{
961 CFDataRefObject *it;
962 if (itself == NULL) return PyMac_Error(resNotFound);
963 it = PyObject_NEW(CFDataRefObject, &CFDataRef_Type);
964 if (it == NULL) return NULL;
965 it->ob_itself = itself;
966 it->ob_freeit = CFRelease;
967 return (PyObject *)it;
968}
Jack Jansen06d2e1a2001-09-04 22:19:18 +0000969int CFDataRefObj_Convert(PyObject *v, CFDataRef *p_itself)
Jack Jansen50ecb0a2001-08-23 14:02:09 +0000970{
971
972 if (v == Py_None) { *p_itself = NULL; return 1; }
973 /* Check for other CF objects here */
974
975 if (!CFDataRefObj_Check(v))
976 {
977 PyErr_SetString(PyExc_TypeError, "CFDataRef required");
978 return 0;
979 }
980 *p_itself = ((CFDataRefObject *)v)->ob_itself;
981 return 1;
982}
983
984static void CFDataRefObj_dealloc(CFDataRefObject *self)
985{
986 if (self->ob_freeit && self->ob_itself)
987 {
988 self->ob_freeit((CFTypeRef)self->ob_itself);
989 }
990 PyMem_DEL(self);
991}
992
993static PyObject *CFDataRefObj_CFDataCreateCopy(CFDataRefObject *_self, PyObject *_args)
994{
995 PyObject *_res = NULL;
996 CFDataRef _rv;
997 if (!PyArg_ParseTuple(_args, ""))
998 return NULL;
999 _rv = CFDataCreateCopy((CFAllocatorRef)NULL,
1000 _self->ob_itself);
1001 _res = Py_BuildValue("O&",
1002 CFDataRefObj_New, _rv);
1003 return _res;
1004}
1005
1006static PyObject *CFDataRefObj_CFDataGetLength(CFDataRefObject *_self, PyObject *_args)
1007{
1008 PyObject *_res = NULL;
1009 CFIndex _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00001010#ifndef CFDataGetLength
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001011 PyMac_PRECHECK(CFDataGetLength);
Jack Jansenb3be2162001-11-30 14:16:36 +00001012#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001013 if (!PyArg_ParseTuple(_args, ""))
1014 return NULL;
1015 _rv = CFDataGetLength(_self->ob_itself);
1016 _res = Py_BuildValue("l",
1017 _rv);
1018 return _res;
1019}
1020
1021static PyObject *CFDataRefObj_CFStringCreateFromExternalRepresentation(CFDataRefObject *_self, PyObject *_args)
1022{
1023 PyObject *_res = NULL;
1024 CFStringRef _rv;
1025 CFStringEncoding encoding;
1026 if (!PyArg_ParseTuple(_args, "l",
1027 &encoding))
1028 return NULL;
1029 _rv = CFStringCreateFromExternalRepresentation((CFAllocatorRef)NULL,
1030 _self->ob_itself,
1031 encoding);
1032 _res = Py_BuildValue("O&",
1033 CFStringRefObj_New, _rv);
1034 return _res;
1035}
1036
1037static PyMethodDef CFDataRefObj_methods[] = {
1038 {"CFDataCreateCopy", (PyCFunction)CFDataRefObj_CFDataCreateCopy, 1,
1039 "() -> (CFDataRef _rv)"},
1040 {"CFDataGetLength", (PyCFunction)CFDataRefObj_CFDataGetLength, 1,
1041 "() -> (CFIndex _rv)"},
1042 {"CFStringCreateFromExternalRepresentation", (PyCFunction)CFDataRefObj_CFStringCreateFromExternalRepresentation, 1,
1043 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
1044 {NULL, NULL, 0}
1045};
1046
1047PyMethodChain CFDataRefObj_chain = { CFDataRefObj_methods, &CFTypeRefObj_chain };
1048
1049static PyObject *CFDataRefObj_getattr(CFDataRefObject *self, char *name)
1050{
1051 return Py_FindMethodInChain(&CFDataRefObj_chain, (PyObject *)self, name);
1052}
1053
1054#define CFDataRefObj_setattr NULL
1055
1056static int CFDataRefObj_compare(CFDataRefObject *self, CFDataRefObject *other)
1057{
1058 /* XXXX Or should we use CFEqual?? */
1059 if ( self->ob_itself > other->ob_itself ) return 1;
1060 if ( self->ob_itself < other->ob_itself ) return -1;
1061 return 0;
1062}
1063
1064static PyObject * CFDataRefObj_repr(CFDataRefObject *self)
1065{
1066 char buf[100];
Jack Jansenfd064862001-09-05 10:31:52 +00001067 sprintf(buf, "<CFDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001068 return PyString_FromString(buf);
1069}
1070
1071static int CFDataRefObj_hash(CFDataRefObject *self)
1072{
1073 /* XXXX Or should we use CFHash?? */
1074 return (int)self->ob_itself;
1075}
1076
1077PyTypeObject CFDataRef_Type = {
Jack Jansenb3be2162001-11-30 14:16:36 +00001078 PyObject_HEAD_INIT(NULL)
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001079 0, /*ob_size*/
Guido van Rossum14648392001-12-08 18:02:58 +00001080 "_CF.CFDataRef", /*tp_name*/
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001081 sizeof(CFDataRefObject), /*tp_basicsize*/
1082 0, /*tp_itemsize*/
1083 /* methods */
1084 (destructor) CFDataRefObj_dealloc, /*tp_dealloc*/
1085 0, /*tp_print*/
1086 (getattrfunc) CFDataRefObj_getattr, /*tp_getattr*/
1087 (setattrfunc) CFDataRefObj_setattr, /*tp_setattr*/
1088 (cmpfunc) CFDataRefObj_compare, /*tp_compare*/
1089 (reprfunc) CFDataRefObj_repr, /*tp_repr*/
1090 (PyNumberMethods *)0, /* tp_as_number */
1091 (PySequenceMethods *)0, /* tp_as_sequence */
1092 (PyMappingMethods *)0, /* tp_as_mapping */
1093 (hashfunc) CFDataRefObj_hash, /*tp_hash*/
1094};
1095
1096/* ------------------- End object type CFDataRef -------------------- */
1097
1098
1099/* ------------------ Object type CFMutableDataRef ------------------ */
1100
1101PyTypeObject CFMutableDataRef_Type;
1102
1103#define CFMutableDataRefObj_Check(x) ((x)->ob_type == &CFMutableDataRef_Type)
1104
1105typedef struct CFMutableDataRefObject {
1106 PyObject_HEAD
1107 CFMutableDataRef ob_itself;
1108 void (*ob_freeit)(CFTypeRef ptr);
1109} CFMutableDataRefObject;
1110
1111PyObject *CFMutableDataRefObj_New(CFMutableDataRef itself)
1112{
1113 CFMutableDataRefObject *it;
1114 if (itself == NULL) return PyMac_Error(resNotFound);
1115 it = PyObject_NEW(CFMutableDataRefObject, &CFMutableDataRef_Type);
1116 if (it == NULL) return NULL;
1117 it->ob_itself = itself;
1118 it->ob_freeit = CFRelease;
1119 return (PyObject *)it;
1120}
Jack Jansen06d2e1a2001-09-04 22:19:18 +00001121int CFMutableDataRefObj_Convert(PyObject *v, CFMutableDataRef *p_itself)
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001122{
1123
1124 if (v == Py_None) { *p_itself = NULL; return 1; }
1125 /* Check for other CF objects here */
1126
1127 if (!CFMutableDataRefObj_Check(v))
1128 {
1129 PyErr_SetString(PyExc_TypeError, "CFMutableDataRef required");
1130 return 0;
1131 }
1132 *p_itself = ((CFMutableDataRefObject *)v)->ob_itself;
1133 return 1;
1134}
1135
1136static void CFMutableDataRefObj_dealloc(CFMutableDataRefObject *self)
1137{
1138 if (self->ob_freeit && self->ob_itself)
1139 {
1140 self->ob_freeit((CFTypeRef)self->ob_itself);
1141 }
1142 PyMem_DEL(self);
1143}
1144
1145static PyObject *CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject *_self, PyObject *_args)
1146{
1147 PyObject *_res = NULL;
1148 CFIndex length;
Jack Jansenb3be2162001-11-30 14:16:36 +00001149#ifndef CFDataSetLength
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001150 PyMac_PRECHECK(CFDataSetLength);
Jack Jansenb3be2162001-11-30 14:16:36 +00001151#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001152 if (!PyArg_ParseTuple(_args, "l",
1153 &length))
1154 return NULL;
1155 CFDataSetLength(_self->ob_itself,
1156 length);
1157 Py_INCREF(Py_None);
1158 _res = Py_None;
1159 return _res;
1160}
1161
1162static PyObject *CFMutableDataRefObj_CFDataIncreaseLength(CFMutableDataRefObject *_self, PyObject *_args)
1163{
1164 PyObject *_res = NULL;
1165 CFIndex extraLength;
Jack Jansenb3be2162001-11-30 14:16:36 +00001166#ifndef CFDataIncreaseLength
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001167 PyMac_PRECHECK(CFDataIncreaseLength);
Jack Jansenb3be2162001-11-30 14:16:36 +00001168#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001169 if (!PyArg_ParseTuple(_args, "l",
1170 &extraLength))
1171 return NULL;
1172 CFDataIncreaseLength(_self->ob_itself,
1173 extraLength);
1174 Py_INCREF(Py_None);
1175 _res = Py_None;
1176 return _res;
1177}
1178
1179static PyObject *CFMutableDataRefObj_CFDataAppendBytes(CFMutableDataRefObject *_self, PyObject *_args)
1180{
1181 PyObject *_res = NULL;
1182 unsigned char *bytes__in__;
1183 long bytes__len__;
1184 int bytes__in_len__;
Jack Jansenb3be2162001-11-30 14:16:36 +00001185#ifndef CFDataAppendBytes
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001186 PyMac_PRECHECK(CFDataAppendBytes);
Jack Jansenb3be2162001-11-30 14:16:36 +00001187#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001188 if (!PyArg_ParseTuple(_args, "s#",
1189 &bytes__in__, &bytes__in_len__))
1190 return NULL;
1191 bytes__len__ = bytes__in_len__;
1192 CFDataAppendBytes(_self->ob_itself,
1193 bytes__in__, bytes__len__);
1194 Py_INCREF(Py_None);
1195 _res = Py_None;
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001196 return _res;
1197}
1198
1199static PyObject *CFMutableDataRefObj_CFDataReplaceBytes(CFMutableDataRefObject *_self, PyObject *_args)
1200{
1201 PyObject *_res = NULL;
1202 CFRange range;
1203 unsigned char *newBytes__in__;
1204 long newBytes__len__;
1205 int newBytes__in_len__;
Jack Jansenb3be2162001-11-30 14:16:36 +00001206#ifndef CFDataReplaceBytes
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001207 PyMac_PRECHECK(CFDataReplaceBytes);
Jack Jansenb3be2162001-11-30 14:16:36 +00001208#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001209 if (!PyArg_ParseTuple(_args, "O&s#",
1210 CFRange_Convert, &range,
1211 &newBytes__in__, &newBytes__in_len__))
1212 return NULL;
1213 newBytes__len__ = newBytes__in_len__;
1214 CFDataReplaceBytes(_self->ob_itself,
1215 range,
1216 newBytes__in__, newBytes__len__);
1217 Py_INCREF(Py_None);
1218 _res = Py_None;
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001219 return _res;
1220}
1221
1222static PyObject *CFMutableDataRefObj_CFDataDeleteBytes(CFMutableDataRefObject *_self, PyObject *_args)
1223{
1224 PyObject *_res = NULL;
1225 CFRange range;
Jack Jansenb3be2162001-11-30 14:16:36 +00001226#ifndef CFDataDeleteBytes
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001227 PyMac_PRECHECK(CFDataDeleteBytes);
Jack Jansenb3be2162001-11-30 14:16:36 +00001228#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001229 if (!PyArg_ParseTuple(_args, "O&",
1230 CFRange_Convert, &range))
1231 return NULL;
1232 CFDataDeleteBytes(_self->ob_itself,
1233 range);
1234 Py_INCREF(Py_None);
1235 _res = Py_None;
1236 return _res;
1237}
1238
1239static PyMethodDef CFMutableDataRefObj_methods[] = {
1240 {"CFDataSetLength", (PyCFunction)CFMutableDataRefObj_CFDataSetLength, 1,
1241 "(CFIndex length) -> None"},
1242 {"CFDataIncreaseLength", (PyCFunction)CFMutableDataRefObj_CFDataIncreaseLength, 1,
1243 "(CFIndex extraLength) -> None"},
1244 {"CFDataAppendBytes", (PyCFunction)CFMutableDataRefObj_CFDataAppendBytes, 1,
1245 "(Buffer bytes) -> None"},
1246 {"CFDataReplaceBytes", (PyCFunction)CFMutableDataRefObj_CFDataReplaceBytes, 1,
1247 "(CFRange range, Buffer newBytes) -> None"},
1248 {"CFDataDeleteBytes", (PyCFunction)CFMutableDataRefObj_CFDataDeleteBytes, 1,
1249 "(CFRange range) -> None"},
1250 {NULL, NULL, 0}
1251};
1252
1253PyMethodChain CFMutableDataRefObj_chain = { CFMutableDataRefObj_methods, &CFDataRefObj_chain };
1254
1255static PyObject *CFMutableDataRefObj_getattr(CFMutableDataRefObject *self, char *name)
1256{
1257 return Py_FindMethodInChain(&CFMutableDataRefObj_chain, (PyObject *)self, name);
1258}
1259
1260#define CFMutableDataRefObj_setattr NULL
1261
1262static int CFMutableDataRefObj_compare(CFMutableDataRefObject *self, CFMutableDataRefObject *other)
1263{
1264 /* XXXX Or should we use CFEqual?? */
1265 if ( self->ob_itself > other->ob_itself ) return 1;
1266 if ( self->ob_itself < other->ob_itself ) return -1;
1267 return 0;
1268}
1269
1270static PyObject * CFMutableDataRefObj_repr(CFMutableDataRefObject *self)
1271{
1272 char buf[100];
Jack Jansenfd064862001-09-05 10:31:52 +00001273 sprintf(buf, "<CFMutableDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001274 return PyString_FromString(buf);
1275}
1276
1277static int CFMutableDataRefObj_hash(CFMutableDataRefObject *self)
1278{
1279 /* XXXX Or should we use CFHash?? */
1280 return (int)self->ob_itself;
1281}
1282
1283PyTypeObject CFMutableDataRef_Type = {
Jack Jansenb3be2162001-11-30 14:16:36 +00001284 PyObject_HEAD_INIT(NULL)
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001285 0, /*ob_size*/
Guido van Rossum14648392001-12-08 18:02:58 +00001286 "_CF.CFMutableDataRef", /*tp_name*/
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001287 sizeof(CFMutableDataRefObject), /*tp_basicsize*/
1288 0, /*tp_itemsize*/
1289 /* methods */
1290 (destructor) CFMutableDataRefObj_dealloc, /*tp_dealloc*/
1291 0, /*tp_print*/
1292 (getattrfunc) CFMutableDataRefObj_getattr, /*tp_getattr*/
1293 (setattrfunc) CFMutableDataRefObj_setattr, /*tp_setattr*/
1294 (cmpfunc) CFMutableDataRefObj_compare, /*tp_compare*/
1295 (reprfunc) CFMutableDataRefObj_repr, /*tp_repr*/
1296 (PyNumberMethods *)0, /* tp_as_number */
1297 (PySequenceMethods *)0, /* tp_as_sequence */
1298 (PyMappingMethods *)0, /* tp_as_mapping */
1299 (hashfunc) CFMutableDataRefObj_hash, /*tp_hash*/
1300};
1301
1302/* ---------------- End object type CFMutableDataRef ---------------- */
1303
1304
1305/* -------------------- Object type CFStringRef --------------------- */
1306
1307PyTypeObject CFStringRef_Type;
1308
1309#define CFStringRefObj_Check(x) ((x)->ob_type == &CFStringRef_Type)
1310
1311typedef struct CFStringRefObject {
1312 PyObject_HEAD
1313 CFStringRef ob_itself;
1314 void (*ob_freeit)(CFTypeRef ptr);
1315} CFStringRefObject;
1316
1317PyObject *CFStringRefObj_New(CFStringRef itself)
1318{
1319 CFStringRefObject *it;
1320 if (itself == NULL) return PyMac_Error(resNotFound);
1321 it = PyObject_NEW(CFStringRefObject, &CFStringRef_Type);
1322 if (it == NULL) return NULL;
1323 it->ob_itself = itself;
1324 it->ob_freeit = CFRelease;
1325 return (PyObject *)it;
1326}
Jack Jansen06d2e1a2001-09-04 22:19:18 +00001327int CFStringRefObj_Convert(PyObject *v, CFStringRef *p_itself)
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001328{
1329
1330 if (v == Py_None) { *p_itself = NULL; return 1; }
1331 if (PyString_Check(v)) {
1332 char *cStr = PyString_AsString(v);
1333 *p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, 0);
1334 return 1;
1335 }
1336 if (PyUnicode_Check(v)) {
1337 /* We use the CF types here, if Python was configured differently that will give an error */
1338 CFIndex size = PyUnicode_GetSize(v);
1339 UniChar *unichars = PyUnicode_AsUnicode(v);
1340 if (!unichars) return 0;
1341 *p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size);
1342 return 1;
1343 }
1344
1345
1346 if (!CFStringRefObj_Check(v))
1347 {
1348 PyErr_SetString(PyExc_TypeError, "CFStringRef required");
1349 return 0;
1350 }
1351 *p_itself = ((CFStringRefObject *)v)->ob_itself;
1352 return 1;
1353}
1354
1355static void CFStringRefObj_dealloc(CFStringRefObject *self)
1356{
1357 if (self->ob_freeit && self->ob_itself)
1358 {
1359 self->ob_freeit((CFTypeRef)self->ob_itself);
1360 }
1361 PyMem_DEL(self);
1362}
1363
1364static PyObject *CFStringRefObj_CFStringCreateWithSubstring(CFStringRefObject *_self, PyObject *_args)
1365{
1366 PyObject *_res = NULL;
1367 CFStringRef _rv;
1368 CFRange range;
1369 if (!PyArg_ParseTuple(_args, "O&",
1370 CFRange_Convert, &range))
1371 return NULL;
1372 _rv = CFStringCreateWithSubstring((CFAllocatorRef)NULL,
1373 _self->ob_itself,
1374 range);
1375 _res = Py_BuildValue("O&",
1376 CFStringRefObj_New, _rv);
1377 return _res;
1378}
1379
1380static PyObject *CFStringRefObj_CFStringCreateCopy(CFStringRefObject *_self, PyObject *_args)
1381{
1382 PyObject *_res = NULL;
1383 CFStringRef _rv;
1384 if (!PyArg_ParseTuple(_args, ""))
1385 return NULL;
1386 _rv = CFStringCreateCopy((CFAllocatorRef)NULL,
1387 _self->ob_itself);
1388 _res = Py_BuildValue("O&",
1389 CFStringRefObj_New, _rv);
1390 return _res;
1391}
1392
1393static PyObject *CFStringRefObj_CFStringGetLength(CFStringRefObject *_self, PyObject *_args)
1394{
1395 PyObject *_res = NULL;
1396 CFIndex _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00001397#ifndef CFStringGetLength
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001398 PyMac_PRECHECK(CFStringGetLength);
Jack Jansenb3be2162001-11-30 14:16:36 +00001399#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001400 if (!PyArg_ParseTuple(_args, ""))
1401 return NULL;
1402 _rv = CFStringGetLength(_self->ob_itself);
1403 _res = Py_BuildValue("l",
1404 _rv);
1405 return _res;
1406}
1407
1408static PyObject *CFStringRefObj_CFStringGetBytes(CFStringRefObject *_self, PyObject *_args)
1409{
1410 PyObject *_res = NULL;
1411 CFIndex _rv;
1412 CFRange range;
1413 CFStringEncoding encoding;
1414 UInt8 lossByte;
1415 Boolean isExternalRepresentation;
1416 UInt8 buffer;
1417 CFIndex maxBufLen;
1418 CFIndex usedBufLen;
Jack Jansenb3be2162001-11-30 14:16:36 +00001419#ifndef CFStringGetBytes
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001420 PyMac_PRECHECK(CFStringGetBytes);
Jack Jansenb3be2162001-11-30 14:16:36 +00001421#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001422 if (!PyArg_ParseTuple(_args, "O&lbll",
1423 CFRange_Convert, &range,
1424 &encoding,
1425 &lossByte,
1426 &isExternalRepresentation,
1427 &maxBufLen))
1428 return NULL;
1429 _rv = CFStringGetBytes(_self->ob_itself,
1430 range,
1431 encoding,
1432 lossByte,
1433 isExternalRepresentation,
1434 &buffer,
1435 maxBufLen,
1436 &usedBufLen);
1437 _res = Py_BuildValue("lbl",
1438 _rv,
1439 buffer,
1440 usedBufLen);
1441 return _res;
1442}
1443
1444static PyObject *CFStringRefObj_CFStringCreateExternalRepresentation(CFStringRefObject *_self, PyObject *_args)
1445{
1446 PyObject *_res = NULL;
1447 CFDataRef _rv;
1448 CFStringEncoding encoding;
1449 UInt8 lossByte;
1450 if (!PyArg_ParseTuple(_args, "lb",
1451 &encoding,
1452 &lossByte))
1453 return NULL;
1454 _rv = CFStringCreateExternalRepresentation((CFAllocatorRef)NULL,
1455 _self->ob_itself,
1456 encoding,
1457 lossByte);
1458 _res = Py_BuildValue("O&",
1459 CFDataRefObj_New, _rv);
1460 return _res;
1461}
1462
1463static PyObject *CFStringRefObj_CFStringGetSmallestEncoding(CFStringRefObject *_self, PyObject *_args)
1464{
1465 PyObject *_res = NULL;
1466 CFStringEncoding _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00001467#ifndef CFStringGetSmallestEncoding
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001468 PyMac_PRECHECK(CFStringGetSmallestEncoding);
Jack Jansenb3be2162001-11-30 14:16:36 +00001469#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001470 if (!PyArg_ParseTuple(_args, ""))
1471 return NULL;
1472 _rv = CFStringGetSmallestEncoding(_self->ob_itself);
1473 _res = Py_BuildValue("l",
1474 _rv);
1475 return _res;
1476}
1477
1478static PyObject *CFStringRefObj_CFStringGetFastestEncoding(CFStringRefObject *_self, PyObject *_args)
1479{
1480 PyObject *_res = NULL;
1481 CFStringEncoding _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00001482#ifndef CFStringGetFastestEncoding
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001483 PyMac_PRECHECK(CFStringGetFastestEncoding);
Jack Jansenb3be2162001-11-30 14:16:36 +00001484#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001485 if (!PyArg_ParseTuple(_args, ""))
1486 return NULL;
1487 _rv = CFStringGetFastestEncoding(_self->ob_itself);
1488 _res = Py_BuildValue("l",
1489 _rv);
1490 return _res;
1491}
1492
1493static PyObject *CFStringRefObj_CFStringCompareWithOptions(CFStringRefObject *_self, PyObject *_args)
1494{
1495 PyObject *_res = NULL;
1496 CFComparisonResult _rv;
Jack Jansen2168e9d2001-12-16 20:18:40 +00001497 CFStringRef theString2;
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001498 CFRange rangeToCompare;
1499 CFOptionFlags compareOptions;
Jack Jansenb3be2162001-11-30 14:16:36 +00001500#ifndef CFStringCompareWithOptions
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001501 PyMac_PRECHECK(CFStringCompareWithOptions);
Jack Jansenb3be2162001-11-30 14:16:36 +00001502#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001503 if (!PyArg_ParseTuple(_args, "O&O&l",
Jack Jansen2168e9d2001-12-16 20:18:40 +00001504 CFStringRefObj_Convert, &theString2,
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001505 CFRange_Convert, &rangeToCompare,
1506 &compareOptions))
1507 return NULL;
1508 _rv = CFStringCompareWithOptions(_self->ob_itself,
Jack Jansen2168e9d2001-12-16 20:18:40 +00001509 theString2,
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001510 rangeToCompare,
1511 compareOptions);
1512 _res = Py_BuildValue("l",
1513 _rv);
1514 return _res;
1515}
1516
1517static PyObject *CFStringRefObj_CFStringCompare(CFStringRefObject *_self, PyObject *_args)
1518{
1519 PyObject *_res = NULL;
1520 CFComparisonResult _rv;
Jack Jansen2168e9d2001-12-16 20:18:40 +00001521 CFStringRef theString2;
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001522 CFOptionFlags compareOptions;
Jack Jansenb3be2162001-11-30 14:16:36 +00001523#ifndef CFStringCompare
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001524 PyMac_PRECHECK(CFStringCompare);
Jack Jansenb3be2162001-11-30 14:16:36 +00001525#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001526 if (!PyArg_ParseTuple(_args, "O&l",
Jack Jansen2168e9d2001-12-16 20:18:40 +00001527 CFStringRefObj_Convert, &theString2,
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001528 &compareOptions))
1529 return NULL;
1530 _rv = CFStringCompare(_self->ob_itself,
Jack Jansen2168e9d2001-12-16 20:18:40 +00001531 theString2,
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001532 compareOptions);
1533 _res = Py_BuildValue("l",
1534 _rv);
1535 return _res;
1536}
1537
1538static PyObject *CFStringRefObj_CFStringFindWithOptions(CFStringRefObject *_self, PyObject *_args)
1539{
1540 PyObject *_res = NULL;
1541 Boolean _rv;
1542 CFStringRef stringToFind;
1543 CFRange rangeToSearch;
1544 CFOptionFlags searchOptions;
1545 CFRange result;
Jack Jansenb3be2162001-11-30 14:16:36 +00001546#ifndef CFStringFindWithOptions
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001547 PyMac_PRECHECK(CFStringFindWithOptions);
Jack Jansenb3be2162001-11-30 14:16:36 +00001548#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001549 if (!PyArg_ParseTuple(_args, "O&O&l",
1550 CFStringRefObj_Convert, &stringToFind,
1551 CFRange_Convert, &rangeToSearch,
1552 &searchOptions))
1553 return NULL;
1554 _rv = CFStringFindWithOptions(_self->ob_itself,
1555 stringToFind,
1556 rangeToSearch,
1557 searchOptions,
1558 &result);
1559 _res = Py_BuildValue("lO&",
1560 _rv,
1561 CFRange_New, result);
1562 return _res;
1563}
1564
1565static PyObject *CFStringRefObj_CFStringCreateArrayWithFindResults(CFStringRefObject *_self, PyObject *_args)
1566{
1567 PyObject *_res = NULL;
1568 CFArrayRef _rv;
1569 CFStringRef stringToFind;
1570 CFRange rangeToSearch;
1571 CFOptionFlags compareOptions;
1572 if (!PyArg_ParseTuple(_args, "O&O&l",
1573 CFStringRefObj_Convert, &stringToFind,
1574 CFRange_Convert, &rangeToSearch,
1575 &compareOptions))
1576 return NULL;
1577 _rv = CFStringCreateArrayWithFindResults((CFAllocatorRef)NULL,
1578 _self->ob_itself,
1579 stringToFind,
1580 rangeToSearch,
1581 compareOptions);
1582 _res = Py_BuildValue("O&",
1583 CFArrayRefObj_New, _rv);
1584 return _res;
1585}
1586
1587static PyObject *CFStringRefObj_CFStringFind(CFStringRefObject *_self, PyObject *_args)
1588{
1589 PyObject *_res = NULL;
1590 CFRange _rv;
1591 CFStringRef stringToFind;
1592 CFOptionFlags compareOptions;
Jack Jansenb3be2162001-11-30 14:16:36 +00001593#ifndef CFStringFind
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001594 PyMac_PRECHECK(CFStringFind);
Jack Jansenb3be2162001-11-30 14:16:36 +00001595#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001596 if (!PyArg_ParseTuple(_args, "O&l",
1597 CFStringRefObj_Convert, &stringToFind,
1598 &compareOptions))
1599 return NULL;
1600 _rv = CFStringFind(_self->ob_itself,
1601 stringToFind,
1602 compareOptions);
1603 _res = Py_BuildValue("O&",
1604 CFRange_New, _rv);
1605 return _res;
1606}
1607
1608static PyObject *CFStringRefObj_CFStringHasPrefix(CFStringRefObject *_self, PyObject *_args)
1609{
1610 PyObject *_res = NULL;
1611 Boolean _rv;
1612 CFStringRef prefix;
Jack Jansenb3be2162001-11-30 14:16:36 +00001613#ifndef CFStringHasPrefix
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001614 PyMac_PRECHECK(CFStringHasPrefix);
Jack Jansenb3be2162001-11-30 14:16:36 +00001615#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001616 if (!PyArg_ParseTuple(_args, "O&",
1617 CFStringRefObj_Convert, &prefix))
1618 return NULL;
1619 _rv = CFStringHasPrefix(_self->ob_itself,
1620 prefix);
1621 _res = Py_BuildValue("l",
1622 _rv);
1623 return _res;
1624}
1625
1626static PyObject *CFStringRefObj_CFStringHasSuffix(CFStringRefObject *_self, PyObject *_args)
1627{
1628 PyObject *_res = NULL;
1629 Boolean _rv;
1630 CFStringRef suffix;
Jack Jansenb3be2162001-11-30 14:16:36 +00001631#ifndef CFStringHasSuffix
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001632 PyMac_PRECHECK(CFStringHasSuffix);
Jack Jansenb3be2162001-11-30 14:16:36 +00001633#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001634 if (!PyArg_ParseTuple(_args, "O&",
1635 CFStringRefObj_Convert, &suffix))
1636 return NULL;
1637 _rv = CFStringHasSuffix(_self->ob_itself,
1638 suffix);
1639 _res = Py_BuildValue("l",
1640 _rv);
1641 return _res;
1642}
1643
1644static PyObject *CFStringRefObj_CFStringGetLineBounds(CFStringRefObject *_self, PyObject *_args)
1645{
1646 PyObject *_res = NULL;
1647 CFRange range;
1648 CFIndex lineBeginIndex;
1649 CFIndex lineEndIndex;
1650 CFIndex contentsEndIndex;
Jack Jansenb3be2162001-11-30 14:16:36 +00001651#ifndef CFStringGetLineBounds
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001652 PyMac_PRECHECK(CFStringGetLineBounds);
Jack Jansenb3be2162001-11-30 14:16:36 +00001653#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001654 if (!PyArg_ParseTuple(_args, "O&",
1655 CFRange_Convert, &range))
1656 return NULL;
1657 CFStringGetLineBounds(_self->ob_itself,
1658 range,
1659 &lineBeginIndex,
1660 &lineEndIndex,
1661 &contentsEndIndex);
1662 _res = Py_BuildValue("lll",
1663 lineBeginIndex,
1664 lineEndIndex,
1665 contentsEndIndex);
1666 return _res;
1667}
1668
1669static PyObject *CFStringRefObj_CFStringCreateArrayBySeparatingStrings(CFStringRefObject *_self, PyObject *_args)
1670{
1671 PyObject *_res = NULL;
1672 CFArrayRef _rv;
1673 CFStringRef separatorString;
1674 if (!PyArg_ParseTuple(_args, "O&",
1675 CFStringRefObj_Convert, &separatorString))
1676 return NULL;
1677 _rv = CFStringCreateArrayBySeparatingStrings((CFAllocatorRef)NULL,
1678 _self->ob_itself,
1679 separatorString);
1680 _res = Py_BuildValue("O&",
1681 CFArrayRefObj_New, _rv);
1682 return _res;
1683}
1684
1685static PyObject *CFStringRefObj_CFStringGetIntValue(CFStringRefObject *_self, PyObject *_args)
1686{
1687 PyObject *_res = NULL;
1688 SInt32 _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00001689#ifndef CFStringGetIntValue
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001690 PyMac_PRECHECK(CFStringGetIntValue);
Jack Jansenb3be2162001-11-30 14:16:36 +00001691#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001692 if (!PyArg_ParseTuple(_args, ""))
1693 return NULL;
1694 _rv = CFStringGetIntValue(_self->ob_itself);
1695 _res = Py_BuildValue("l",
1696 _rv);
1697 return _res;
1698}
1699
1700static PyObject *CFStringRefObj_CFStringGetDoubleValue(CFStringRefObject *_self, PyObject *_args)
1701{
1702 PyObject *_res = NULL;
1703 double _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00001704#ifndef CFStringGetDoubleValue
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001705 PyMac_PRECHECK(CFStringGetDoubleValue);
Jack Jansenb3be2162001-11-30 14:16:36 +00001706#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001707 if (!PyArg_ParseTuple(_args, ""))
1708 return NULL;
1709 _rv = CFStringGetDoubleValue(_self->ob_itself);
1710 _res = Py_BuildValue("d",
1711 _rv);
1712 return _res;
1713}
1714
1715static PyObject *CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStringRefObject *_self, PyObject *_args)
1716{
1717 PyObject *_res = NULL;
1718 CFStringEncoding _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00001719#ifndef CFStringConvertIANACharSetNameToEncoding
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001720 PyMac_PRECHECK(CFStringConvertIANACharSetNameToEncoding);
Jack Jansenb3be2162001-11-30 14:16:36 +00001721#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001722 if (!PyArg_ParseTuple(_args, ""))
1723 return NULL;
1724 _rv = CFStringConvertIANACharSetNameToEncoding(_self->ob_itself);
1725 _res = Py_BuildValue("l",
1726 _rv);
1727 return _res;
1728}
1729
1730static PyObject *CFStringRefObj_CFShowStr(CFStringRefObject *_self, PyObject *_args)
1731{
1732 PyObject *_res = NULL;
Jack Jansenb3be2162001-11-30 14:16:36 +00001733#ifndef CFShowStr
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001734 PyMac_PRECHECK(CFShowStr);
Jack Jansenb3be2162001-11-30 14:16:36 +00001735#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001736 if (!PyArg_ParseTuple(_args, ""))
1737 return NULL;
1738 CFShowStr(_self->ob_itself);
1739 Py_INCREF(Py_None);
1740 _res = Py_None;
1741 return _res;
1742}
1743
1744static PyObject *CFStringRefObj_CFURLCreateWithString(CFStringRefObject *_self, PyObject *_args)
1745{
1746 PyObject *_res = NULL;
1747 CFURLRef _rv;
1748 CFURLRef baseURL;
1749 if (!PyArg_ParseTuple(_args, "O&",
1750 OptionalCFURLRefObj_Convert, &baseURL))
1751 return NULL;
1752 _rv = CFURLCreateWithString((CFAllocatorRef)NULL,
1753 _self->ob_itself,
1754 baseURL);
1755 _res = Py_BuildValue("O&",
1756 CFURLRefObj_New, _rv);
1757 return _res;
1758}
1759
1760static PyObject *CFStringRefObj_CFURLCreateWithFileSystemPath(CFStringRefObject *_self, PyObject *_args)
1761{
1762 PyObject *_res = NULL;
1763 CFURLRef _rv;
1764 CFURLPathStyle pathStyle;
1765 Boolean isDirectory;
1766 if (!PyArg_ParseTuple(_args, "ll",
1767 &pathStyle,
1768 &isDirectory))
1769 return NULL;
1770 _rv = CFURLCreateWithFileSystemPath((CFAllocatorRef)NULL,
1771 _self->ob_itself,
1772 pathStyle,
1773 isDirectory);
1774 _res = Py_BuildValue("O&",
1775 CFURLRefObj_New, _rv);
1776 return _res;
1777}
1778
Jack Jansen2168e9d2001-12-16 20:18:40 +00001779static PyObject *CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase(CFStringRefObject *_self, PyObject *_args)
1780{
1781 PyObject *_res = NULL;
1782 CFURLRef _rv;
1783 CFURLPathStyle pathStyle;
1784 Boolean isDirectory;
1785 CFURLRef baseURL;
1786 if (!PyArg_ParseTuple(_args, "llO&",
1787 &pathStyle,
1788 &isDirectory,
1789 OptionalCFURLRefObj_Convert, &baseURL))
1790 return NULL;
1791 _rv = CFURLCreateWithFileSystemPathRelativeToBase((CFAllocatorRef)NULL,
1792 _self->ob_itself,
1793 pathStyle,
1794 isDirectory,
1795 baseURL);
1796 _res = Py_BuildValue("O&",
1797 CFURLRefObj_New, _rv);
1798 return _res;
1799}
1800
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001801static PyObject *CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes(CFStringRefObject *_self, PyObject *_args)
1802{
1803 PyObject *_res = NULL;
1804 CFStringRef _rv;
1805 CFStringRef charactersToLeaveEscaped;
1806 if (!PyArg_ParseTuple(_args, "O&",
1807 CFStringRefObj_Convert, &charactersToLeaveEscaped))
1808 return NULL;
1809 _rv = CFURLCreateStringByReplacingPercentEscapes((CFAllocatorRef)NULL,
1810 _self->ob_itself,
1811 charactersToLeaveEscaped);
1812 _res = Py_BuildValue("O&",
1813 CFStringRefObj_New, _rv);
1814 return _res;
1815}
1816
Jack Jansen2168e9d2001-12-16 20:18:40 +00001817static PyObject *CFStringRefObj_CFURLCreateStringByAddingPercentEscapes(CFStringRefObject *_self, PyObject *_args)
1818{
1819 PyObject *_res = NULL;
1820 CFStringRef _rv;
1821 CFStringRef charactersToLeaveUnescaped;
1822 CFStringRef legalURLCharactersToBeEscaped;
1823 CFStringEncoding encoding;
1824 if (!PyArg_ParseTuple(_args, "O&O&l",
1825 CFStringRefObj_Convert, &charactersToLeaveUnescaped,
1826 CFStringRefObj_Convert, &legalURLCharactersToBeEscaped,
1827 &encoding))
1828 return NULL;
1829 _rv = CFURLCreateStringByAddingPercentEscapes((CFAllocatorRef)NULL,
1830 _self->ob_itself,
1831 charactersToLeaveUnescaped,
1832 legalURLCharactersToBeEscaped,
1833 encoding);
1834 _res = Py_BuildValue("O&",
1835 CFStringRefObj_New, _rv);
1836 return _res;
1837}
1838
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001839static PyObject *CFStringRefObj_CFStringGetString(CFStringRefObject *_self, PyObject *_args)
1840{
1841 PyObject *_res = NULL;
1842
1843 int size = CFStringGetLength(_self->ob_itself)+1;
1844 char *data = malloc(size);
1845
1846 if( data == NULL ) return PyErr_NoMemory();
1847 if ( CFStringGetCString(_self->ob_itself, data, size, 0) ) {
1848 _res = (PyObject *)PyString_FromString(data);
1849 } else {
1850 PyErr_SetString(PyExc_RuntimeError, "CFStringGetCString could not fit the string");
1851 _res = NULL;
1852 }
1853 free(data);
1854 return _res;
1855
1856}
1857
1858static PyObject *CFStringRefObj_CFStringGetUnicode(CFStringRefObject *_self, PyObject *_args)
1859{
1860 PyObject *_res = NULL;
1861
1862 int size = CFStringGetLength(_self->ob_itself)+1;
1863 Py_UNICODE *data = malloc(size*sizeof(Py_UNICODE));
1864 CFRange range;
1865
1866 range.location = 0;
1867 range.length = size;
1868 if( data == NULL ) return PyErr_NoMemory();
1869 CFStringGetCharacters(_self->ob_itself, range, data);
1870 _res = (PyObject *)PyUnicode_FromUnicode(data, size);
1871 free(data);
1872 return _res;
1873
1874}
1875
1876static PyMethodDef CFStringRefObj_methods[] = {
1877 {"CFStringCreateWithSubstring", (PyCFunction)CFStringRefObj_CFStringCreateWithSubstring, 1,
1878 "(CFRange range) -> (CFStringRef _rv)"},
1879 {"CFStringCreateCopy", (PyCFunction)CFStringRefObj_CFStringCreateCopy, 1,
1880 "() -> (CFStringRef _rv)"},
1881 {"CFStringGetLength", (PyCFunction)CFStringRefObj_CFStringGetLength, 1,
1882 "() -> (CFIndex _rv)"},
1883 {"CFStringGetBytes", (PyCFunction)CFStringRefObj_CFStringGetBytes, 1,
1884 "(CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, CFIndex maxBufLen) -> (CFIndex _rv, UInt8 buffer, CFIndex usedBufLen)"},
1885 {"CFStringCreateExternalRepresentation", (PyCFunction)CFStringRefObj_CFStringCreateExternalRepresentation, 1,
1886 "(CFStringEncoding encoding, UInt8 lossByte) -> (CFDataRef _rv)"},
1887 {"CFStringGetSmallestEncoding", (PyCFunction)CFStringRefObj_CFStringGetSmallestEncoding, 1,
1888 "() -> (CFStringEncoding _rv)"},
1889 {"CFStringGetFastestEncoding", (PyCFunction)CFStringRefObj_CFStringGetFastestEncoding, 1,
1890 "() -> (CFStringEncoding _rv)"},
1891 {"CFStringCompareWithOptions", (PyCFunction)CFStringRefObj_CFStringCompareWithOptions, 1,
Jack Jansen2168e9d2001-12-16 20:18:40 +00001892 "(CFStringRef theString2, CFRange rangeToCompare, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001893 {"CFStringCompare", (PyCFunction)CFStringRefObj_CFStringCompare, 1,
Jack Jansen2168e9d2001-12-16 20:18:40 +00001894 "(CFStringRef theString2, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001895 {"CFStringFindWithOptions", (PyCFunction)CFStringRefObj_CFStringFindWithOptions, 1,
1896 "(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags searchOptions) -> (Boolean _rv, CFRange result)"},
1897 {"CFStringCreateArrayWithFindResults", (PyCFunction)CFStringRefObj_CFStringCreateArrayWithFindResults, 1,
1898 "(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions) -> (CFArrayRef _rv)"},
1899 {"CFStringFind", (PyCFunction)CFStringRefObj_CFStringFind, 1,
1900 "(CFStringRef stringToFind, CFOptionFlags compareOptions) -> (CFRange _rv)"},
1901 {"CFStringHasPrefix", (PyCFunction)CFStringRefObj_CFStringHasPrefix, 1,
1902 "(CFStringRef prefix) -> (Boolean _rv)"},
1903 {"CFStringHasSuffix", (PyCFunction)CFStringRefObj_CFStringHasSuffix, 1,
1904 "(CFStringRef suffix) -> (Boolean _rv)"},
1905 {"CFStringGetLineBounds", (PyCFunction)CFStringRefObj_CFStringGetLineBounds, 1,
1906 "(CFRange range) -> (CFIndex lineBeginIndex, CFIndex lineEndIndex, CFIndex contentsEndIndex)"},
1907 {"CFStringCreateArrayBySeparatingStrings", (PyCFunction)CFStringRefObj_CFStringCreateArrayBySeparatingStrings, 1,
1908 "(CFStringRef separatorString) -> (CFArrayRef _rv)"},
1909 {"CFStringGetIntValue", (PyCFunction)CFStringRefObj_CFStringGetIntValue, 1,
1910 "() -> (SInt32 _rv)"},
1911 {"CFStringGetDoubleValue", (PyCFunction)CFStringRefObj_CFStringGetDoubleValue, 1,
1912 "() -> (double _rv)"},
1913 {"CFStringConvertIANACharSetNameToEncoding", (PyCFunction)CFStringRefObj_CFStringConvertIANACharSetNameToEncoding, 1,
1914 "() -> (CFStringEncoding _rv)"},
1915 {"CFShowStr", (PyCFunction)CFStringRefObj_CFShowStr, 1,
1916 "() -> None"},
1917 {"CFURLCreateWithString", (PyCFunction)CFStringRefObj_CFURLCreateWithString, 1,
1918 "(CFURLRef baseURL) -> (CFURLRef _rv)"},
1919 {"CFURLCreateWithFileSystemPath", (PyCFunction)CFStringRefObj_CFURLCreateWithFileSystemPath, 1,
1920 "(CFURLPathStyle pathStyle, Boolean isDirectory) -> (CFURLRef _rv)"},
Jack Jansen2168e9d2001-12-16 20:18:40 +00001921 {"CFURLCreateWithFileSystemPathRelativeToBase", (PyCFunction)CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase, 1,
1922 "(CFURLPathStyle pathStyle, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001923 {"CFURLCreateStringByReplacingPercentEscapes", (PyCFunction)CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes, 1,
1924 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
Jack Jansen2168e9d2001-12-16 20:18:40 +00001925 {"CFURLCreateStringByAddingPercentEscapes", (PyCFunction)CFStringRefObj_CFURLCreateStringByAddingPercentEscapes, 1,
1926 "(CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding) -> (CFStringRef _rv)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001927 {"CFStringGetString", (PyCFunction)CFStringRefObj_CFStringGetString, 1,
1928 "() -> (string _rv)"},
1929 {"CFStringGetUnicode", (PyCFunction)CFStringRefObj_CFStringGetUnicode, 1,
1930 "() -> (unicode _rv)"},
1931 {NULL, NULL, 0}
1932};
1933
1934PyMethodChain CFStringRefObj_chain = { CFStringRefObj_methods, &CFTypeRefObj_chain };
1935
1936static PyObject *CFStringRefObj_getattr(CFStringRefObject *self, char *name)
1937{
1938 return Py_FindMethodInChain(&CFStringRefObj_chain, (PyObject *)self, name);
1939}
1940
1941#define CFStringRefObj_setattr NULL
1942
1943static int CFStringRefObj_compare(CFStringRefObject *self, CFStringRefObject *other)
1944{
1945 /* XXXX Or should we use CFEqual?? */
1946 if ( self->ob_itself > other->ob_itself ) return 1;
1947 if ( self->ob_itself < other->ob_itself ) return -1;
1948 return 0;
1949}
1950
1951static PyObject * CFStringRefObj_repr(CFStringRefObject *self)
1952{
1953 char buf[100];
Jack Jansenfd064862001-09-05 10:31:52 +00001954 sprintf(buf, "<CFStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001955 return PyString_FromString(buf);
1956}
1957
1958static int CFStringRefObj_hash(CFStringRefObject *self)
1959{
1960 /* XXXX Or should we use CFHash?? */
1961 return (int)self->ob_itself;
1962}
1963
1964PyTypeObject CFStringRef_Type = {
Jack Jansenb3be2162001-11-30 14:16:36 +00001965 PyObject_HEAD_INIT(NULL)
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001966 0, /*ob_size*/
Guido van Rossum14648392001-12-08 18:02:58 +00001967 "_CF.CFStringRef", /*tp_name*/
Jack Jansen50ecb0a2001-08-23 14:02:09 +00001968 sizeof(CFStringRefObject), /*tp_basicsize*/
1969 0, /*tp_itemsize*/
1970 /* methods */
1971 (destructor) CFStringRefObj_dealloc, /*tp_dealloc*/
1972 0, /*tp_print*/
1973 (getattrfunc) CFStringRefObj_getattr, /*tp_getattr*/
1974 (setattrfunc) CFStringRefObj_setattr, /*tp_setattr*/
1975 (cmpfunc) CFStringRefObj_compare, /*tp_compare*/
1976 (reprfunc) CFStringRefObj_repr, /*tp_repr*/
1977 (PyNumberMethods *)0, /* tp_as_number */
1978 (PySequenceMethods *)0, /* tp_as_sequence */
1979 (PyMappingMethods *)0, /* tp_as_mapping */
1980 (hashfunc) CFStringRefObj_hash, /*tp_hash*/
1981};
1982
1983/* ------------------ End object type CFStringRef ------------------- */
1984
1985
1986/* ----------------- Object type CFMutableStringRef ----------------- */
1987
1988PyTypeObject CFMutableStringRef_Type;
1989
1990#define CFMutableStringRefObj_Check(x) ((x)->ob_type == &CFMutableStringRef_Type)
1991
1992typedef struct CFMutableStringRefObject {
1993 PyObject_HEAD
1994 CFMutableStringRef ob_itself;
1995 void (*ob_freeit)(CFTypeRef ptr);
1996} CFMutableStringRefObject;
1997
1998PyObject *CFMutableStringRefObj_New(CFMutableStringRef itself)
1999{
2000 CFMutableStringRefObject *it;
2001 if (itself == NULL) return PyMac_Error(resNotFound);
2002 it = PyObject_NEW(CFMutableStringRefObject, &CFMutableStringRef_Type);
2003 if (it == NULL) return NULL;
2004 it->ob_itself = itself;
2005 it->ob_freeit = CFRelease;
2006 return (PyObject *)it;
2007}
Jack Jansen06d2e1a2001-09-04 22:19:18 +00002008int CFMutableStringRefObj_Convert(PyObject *v, CFMutableStringRef *p_itself)
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002009{
2010
2011 if (v == Py_None) { *p_itself = NULL; return 1; }
2012 /* Check for other CF objects here */
2013
2014 if (!CFMutableStringRefObj_Check(v))
2015 {
2016 PyErr_SetString(PyExc_TypeError, "CFMutableStringRef required");
2017 return 0;
2018 }
2019 *p_itself = ((CFMutableStringRefObject *)v)->ob_itself;
2020 return 1;
2021}
2022
2023static void CFMutableStringRefObj_dealloc(CFMutableStringRefObject *self)
2024{
2025 if (self->ob_freeit && self->ob_itself)
2026 {
2027 self->ob_freeit((CFTypeRef)self->ob_itself);
2028 }
2029 PyMem_DEL(self);
2030}
2031
2032static PyObject *CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject *_self, PyObject *_args)
2033{
2034 PyObject *_res = NULL;
2035 CFStringRef appendedString;
Jack Jansenb3be2162001-11-30 14:16:36 +00002036#ifndef CFStringAppend
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002037 PyMac_PRECHECK(CFStringAppend);
Jack Jansenb3be2162001-11-30 14:16:36 +00002038#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002039 if (!PyArg_ParseTuple(_args, "O&",
2040 CFStringRefObj_Convert, &appendedString))
2041 return NULL;
2042 CFStringAppend(_self->ob_itself,
2043 appendedString);
2044 Py_INCREF(Py_None);
2045 _res = Py_None;
2046 return _res;
2047}
2048
2049static PyObject *CFMutableStringRefObj_CFStringAppendPascalString(CFMutableStringRefObject *_self, PyObject *_args)
2050{
2051 PyObject *_res = NULL;
Jack Jansen2168e9d2001-12-16 20:18:40 +00002052 Str255 pStr;
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002053 CFStringEncoding encoding;
Jack Jansenb3be2162001-11-30 14:16:36 +00002054#ifndef CFStringAppendPascalString
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002055 PyMac_PRECHECK(CFStringAppendPascalString);
Jack Jansenb3be2162001-11-30 14:16:36 +00002056#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002057 if (!PyArg_ParseTuple(_args, "O&l",
Jack Jansen2168e9d2001-12-16 20:18:40 +00002058 PyMac_GetStr255, pStr,
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002059 &encoding))
2060 return NULL;
2061 CFStringAppendPascalString(_self->ob_itself,
2062 pStr,
2063 encoding);
2064 Py_INCREF(Py_None);
2065 _res = Py_None;
2066 return _res;
2067}
2068
2069static PyObject *CFMutableStringRefObj_CFStringAppendCString(CFMutableStringRefObject *_self, PyObject *_args)
2070{
2071 PyObject *_res = NULL;
2072 char* cStr;
2073 CFStringEncoding encoding;
Jack Jansenb3be2162001-11-30 14:16:36 +00002074#ifndef CFStringAppendCString
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002075 PyMac_PRECHECK(CFStringAppendCString);
Jack Jansenb3be2162001-11-30 14:16:36 +00002076#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002077 if (!PyArg_ParseTuple(_args, "sl",
2078 &cStr,
2079 &encoding))
2080 return NULL;
2081 CFStringAppendCString(_self->ob_itself,
2082 cStr,
2083 encoding);
2084 Py_INCREF(Py_None);
2085 _res = Py_None;
2086 return _res;
2087}
2088
2089static PyObject *CFMutableStringRefObj_CFStringInsert(CFMutableStringRefObject *_self, PyObject *_args)
2090{
2091 PyObject *_res = NULL;
2092 CFIndex idx;
2093 CFStringRef insertedStr;
Jack Jansenb3be2162001-11-30 14:16:36 +00002094#ifndef CFStringInsert
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002095 PyMac_PRECHECK(CFStringInsert);
Jack Jansenb3be2162001-11-30 14:16:36 +00002096#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002097 if (!PyArg_ParseTuple(_args, "lO&",
2098 &idx,
2099 CFStringRefObj_Convert, &insertedStr))
2100 return NULL;
2101 CFStringInsert(_self->ob_itself,
2102 idx,
2103 insertedStr);
2104 Py_INCREF(Py_None);
2105 _res = Py_None;
2106 return _res;
2107}
2108
2109static PyObject *CFMutableStringRefObj_CFStringDelete(CFMutableStringRefObject *_self, PyObject *_args)
2110{
2111 PyObject *_res = NULL;
2112 CFRange range;
Jack Jansenb3be2162001-11-30 14:16:36 +00002113#ifndef CFStringDelete
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002114 PyMac_PRECHECK(CFStringDelete);
Jack Jansenb3be2162001-11-30 14:16:36 +00002115#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002116 if (!PyArg_ParseTuple(_args, "O&",
2117 CFRange_Convert, &range))
2118 return NULL;
2119 CFStringDelete(_self->ob_itself,
2120 range);
2121 Py_INCREF(Py_None);
2122 _res = Py_None;
2123 return _res;
2124}
2125
2126static PyObject *CFMutableStringRefObj_CFStringReplace(CFMutableStringRefObject *_self, PyObject *_args)
2127{
2128 PyObject *_res = NULL;
2129 CFRange range;
2130 CFStringRef replacement;
Jack Jansenb3be2162001-11-30 14:16:36 +00002131#ifndef CFStringReplace
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002132 PyMac_PRECHECK(CFStringReplace);
Jack Jansenb3be2162001-11-30 14:16:36 +00002133#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002134 if (!PyArg_ParseTuple(_args, "O&O&",
2135 CFRange_Convert, &range,
2136 CFStringRefObj_Convert, &replacement))
2137 return NULL;
2138 CFStringReplace(_self->ob_itself,
2139 range,
2140 replacement);
2141 Py_INCREF(Py_None);
2142 _res = Py_None;
2143 return _res;
2144}
2145
2146static PyObject *CFMutableStringRefObj_CFStringReplaceAll(CFMutableStringRefObject *_self, PyObject *_args)
2147{
2148 PyObject *_res = NULL;
2149 CFStringRef replacement;
Jack Jansenb3be2162001-11-30 14:16:36 +00002150#ifndef CFStringReplaceAll
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002151 PyMac_PRECHECK(CFStringReplaceAll);
Jack Jansenb3be2162001-11-30 14:16:36 +00002152#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002153 if (!PyArg_ParseTuple(_args, "O&",
2154 CFStringRefObj_Convert, &replacement))
2155 return NULL;
2156 CFStringReplaceAll(_self->ob_itself,
2157 replacement);
2158 Py_INCREF(Py_None);
2159 _res = Py_None;
2160 return _res;
2161}
2162
2163static PyObject *CFMutableStringRefObj_CFStringPad(CFMutableStringRefObject *_self, PyObject *_args)
2164{
2165 PyObject *_res = NULL;
2166 CFStringRef padString;
2167 CFIndex length;
2168 CFIndex indexIntoPad;
Jack Jansenb3be2162001-11-30 14:16:36 +00002169#ifndef CFStringPad
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002170 PyMac_PRECHECK(CFStringPad);
Jack Jansenb3be2162001-11-30 14:16:36 +00002171#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002172 if (!PyArg_ParseTuple(_args, "O&ll",
2173 CFStringRefObj_Convert, &padString,
2174 &length,
2175 &indexIntoPad))
2176 return NULL;
2177 CFStringPad(_self->ob_itself,
2178 padString,
2179 length,
2180 indexIntoPad);
2181 Py_INCREF(Py_None);
2182 _res = Py_None;
2183 return _res;
2184}
2185
2186static PyObject *CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject *_self, PyObject *_args)
2187{
2188 PyObject *_res = NULL;
2189 CFStringRef trimString;
Jack Jansenb3be2162001-11-30 14:16:36 +00002190#ifndef CFStringTrim
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002191 PyMac_PRECHECK(CFStringTrim);
Jack Jansenb3be2162001-11-30 14:16:36 +00002192#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002193 if (!PyArg_ParseTuple(_args, "O&",
2194 CFStringRefObj_Convert, &trimString))
2195 return NULL;
2196 CFStringTrim(_self->ob_itself,
2197 trimString);
2198 Py_INCREF(Py_None);
2199 _res = Py_None;
2200 return _res;
2201}
2202
2203static PyObject *CFMutableStringRefObj_CFStringTrimWhitespace(CFMutableStringRefObject *_self, PyObject *_args)
2204{
2205 PyObject *_res = NULL;
Jack Jansenb3be2162001-11-30 14:16:36 +00002206#ifndef CFStringTrimWhitespace
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002207 PyMac_PRECHECK(CFStringTrimWhitespace);
Jack Jansenb3be2162001-11-30 14:16:36 +00002208#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002209 if (!PyArg_ParseTuple(_args, ""))
2210 return NULL;
2211 CFStringTrimWhitespace(_self->ob_itself);
2212 Py_INCREF(Py_None);
2213 _res = Py_None;
2214 return _res;
2215}
2216
2217static PyMethodDef CFMutableStringRefObj_methods[] = {
2218 {"CFStringAppend", (PyCFunction)CFMutableStringRefObj_CFStringAppend, 1,
2219 "(CFStringRef appendedString) -> None"},
2220 {"CFStringAppendPascalString", (PyCFunction)CFMutableStringRefObj_CFStringAppendPascalString, 1,
Jack Jansen2168e9d2001-12-16 20:18:40 +00002221 "(Str255 pStr, CFStringEncoding encoding) -> None"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002222 {"CFStringAppendCString", (PyCFunction)CFMutableStringRefObj_CFStringAppendCString, 1,
2223 "(char* cStr, CFStringEncoding encoding) -> None"},
2224 {"CFStringInsert", (PyCFunction)CFMutableStringRefObj_CFStringInsert, 1,
2225 "(CFIndex idx, CFStringRef insertedStr) -> None"},
2226 {"CFStringDelete", (PyCFunction)CFMutableStringRefObj_CFStringDelete, 1,
2227 "(CFRange range) -> None"},
2228 {"CFStringReplace", (PyCFunction)CFMutableStringRefObj_CFStringReplace, 1,
2229 "(CFRange range, CFStringRef replacement) -> None"},
2230 {"CFStringReplaceAll", (PyCFunction)CFMutableStringRefObj_CFStringReplaceAll, 1,
2231 "(CFStringRef replacement) -> None"},
2232 {"CFStringPad", (PyCFunction)CFMutableStringRefObj_CFStringPad, 1,
2233 "(CFStringRef padString, CFIndex length, CFIndex indexIntoPad) -> None"},
2234 {"CFStringTrim", (PyCFunction)CFMutableStringRefObj_CFStringTrim, 1,
2235 "(CFStringRef trimString) -> None"},
2236 {"CFStringTrimWhitespace", (PyCFunction)CFMutableStringRefObj_CFStringTrimWhitespace, 1,
2237 "() -> None"},
2238 {NULL, NULL, 0}
2239};
2240
2241PyMethodChain CFMutableStringRefObj_chain = { CFMutableStringRefObj_methods, &CFStringRefObj_chain };
2242
2243static PyObject *CFMutableStringRefObj_getattr(CFMutableStringRefObject *self, char *name)
2244{
2245 return Py_FindMethodInChain(&CFMutableStringRefObj_chain, (PyObject *)self, name);
2246}
2247
2248#define CFMutableStringRefObj_setattr NULL
2249
2250static int CFMutableStringRefObj_compare(CFMutableStringRefObject *self, CFMutableStringRefObject *other)
2251{
2252 /* XXXX Or should we use CFEqual?? */
2253 if ( self->ob_itself > other->ob_itself ) return 1;
2254 if ( self->ob_itself < other->ob_itself ) return -1;
2255 return 0;
2256}
2257
2258static PyObject * CFMutableStringRefObj_repr(CFMutableStringRefObject *self)
2259{
2260 char buf[100];
Jack Jansenfd064862001-09-05 10:31:52 +00002261 sprintf(buf, "<CFMutableStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002262 return PyString_FromString(buf);
2263}
2264
2265static int CFMutableStringRefObj_hash(CFMutableStringRefObject *self)
2266{
2267 /* XXXX Or should we use CFHash?? */
2268 return (int)self->ob_itself;
2269}
2270
2271PyTypeObject CFMutableStringRef_Type = {
Jack Jansenb3be2162001-11-30 14:16:36 +00002272 PyObject_HEAD_INIT(NULL)
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002273 0, /*ob_size*/
Guido van Rossum14648392001-12-08 18:02:58 +00002274 "_CF.CFMutableStringRef", /*tp_name*/
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002275 sizeof(CFMutableStringRefObject), /*tp_basicsize*/
2276 0, /*tp_itemsize*/
2277 /* methods */
2278 (destructor) CFMutableStringRefObj_dealloc, /*tp_dealloc*/
2279 0, /*tp_print*/
2280 (getattrfunc) CFMutableStringRefObj_getattr, /*tp_getattr*/
2281 (setattrfunc) CFMutableStringRefObj_setattr, /*tp_setattr*/
2282 (cmpfunc) CFMutableStringRefObj_compare, /*tp_compare*/
2283 (reprfunc) CFMutableStringRefObj_repr, /*tp_repr*/
2284 (PyNumberMethods *)0, /* tp_as_number */
2285 (PySequenceMethods *)0, /* tp_as_sequence */
2286 (PyMappingMethods *)0, /* tp_as_mapping */
2287 (hashfunc) CFMutableStringRefObj_hash, /*tp_hash*/
2288};
2289
2290/* --------------- End object type CFMutableStringRef --------------- */
2291
2292
2293/* ---------------------- Object type CFURLRef ---------------------- */
2294
2295PyTypeObject CFURLRef_Type;
2296
2297#define CFURLRefObj_Check(x) ((x)->ob_type == &CFURLRef_Type)
2298
2299typedef struct CFURLRefObject {
2300 PyObject_HEAD
2301 CFURLRef ob_itself;
2302 void (*ob_freeit)(CFTypeRef ptr);
2303} CFURLRefObject;
2304
2305PyObject *CFURLRefObj_New(CFURLRef itself)
2306{
2307 CFURLRefObject *it;
2308 if (itself == NULL) return PyMac_Error(resNotFound);
2309 it = PyObject_NEW(CFURLRefObject, &CFURLRef_Type);
2310 if (it == NULL) return NULL;
2311 it->ob_itself = itself;
2312 it->ob_freeit = CFRelease;
2313 return (PyObject *)it;
2314}
Jack Jansen06d2e1a2001-09-04 22:19:18 +00002315int CFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself)
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002316{
2317
2318 if (v == Py_None) { *p_itself = NULL; return 1; }
2319 /* Check for other CF objects here */
2320
2321 if (!CFURLRefObj_Check(v))
2322 {
2323 PyErr_SetString(PyExc_TypeError, "CFURLRef required");
2324 return 0;
2325 }
2326 *p_itself = ((CFURLRefObject *)v)->ob_itself;
2327 return 1;
2328}
2329
2330static void CFURLRefObj_dealloc(CFURLRefObject *self)
2331{
2332 if (self->ob_freeit && self->ob_itself)
2333 {
2334 self->ob_freeit((CFTypeRef)self->ob_itself);
2335 }
2336 PyMem_DEL(self);
2337}
2338
2339static PyObject *CFURLRefObj_CFURLCreateData(CFURLRefObject *_self, PyObject *_args)
2340{
2341 PyObject *_res = NULL;
2342 CFDataRef _rv;
2343 CFStringEncoding encoding;
2344 Boolean escapeWhitespace;
2345 if (!PyArg_ParseTuple(_args, "ll",
2346 &encoding,
2347 &escapeWhitespace))
2348 return NULL;
2349 _rv = CFURLCreateData((CFAllocatorRef)NULL,
2350 _self->ob_itself,
2351 encoding,
2352 escapeWhitespace);
2353 _res = Py_BuildValue("O&",
2354 CFDataRefObj_New, _rv);
2355 return _res;
2356}
2357
Jack Jansen2168e9d2001-12-16 20:18:40 +00002358static PyObject *CFURLRefObj_CFURLGetFileSystemRepresentation(CFURLRefObject *_self, PyObject *_args)
2359{
2360 PyObject *_res = NULL;
2361 Boolean _rv;
2362 Boolean resolveAgainstBase;
2363 UInt8 buffer;
2364 CFIndex maxBufLen;
2365#ifndef CFURLGetFileSystemRepresentation
2366 PyMac_PRECHECK(CFURLGetFileSystemRepresentation);
2367#endif
2368 if (!PyArg_ParseTuple(_args, "ll",
2369 &resolveAgainstBase,
2370 &maxBufLen))
2371 return NULL;
2372 _rv = CFURLGetFileSystemRepresentation(_self->ob_itself,
2373 resolveAgainstBase,
2374 &buffer,
2375 maxBufLen);
2376 _res = Py_BuildValue("lb",
2377 _rv,
2378 buffer);
2379 return _res;
2380}
2381
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002382static PyObject *CFURLRefObj_CFURLCopyAbsoluteURL(CFURLRefObject *_self, PyObject *_args)
2383{
2384 PyObject *_res = NULL;
2385 CFURLRef _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002386#ifndef CFURLCopyAbsoluteURL
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002387 PyMac_PRECHECK(CFURLCopyAbsoluteURL);
Jack Jansenb3be2162001-11-30 14:16:36 +00002388#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002389 if (!PyArg_ParseTuple(_args, ""))
2390 return NULL;
2391 _rv = CFURLCopyAbsoluteURL(_self->ob_itself);
2392 _res = Py_BuildValue("O&",
2393 CFURLRefObj_New, _rv);
2394 return _res;
2395}
2396
2397static PyObject *CFURLRefObj_CFURLGetString(CFURLRefObject *_self, PyObject *_args)
2398{
2399 PyObject *_res = NULL;
2400 CFStringRef _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002401#ifndef CFURLGetString
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002402 PyMac_PRECHECK(CFURLGetString);
Jack Jansenb3be2162001-11-30 14:16:36 +00002403#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002404 if (!PyArg_ParseTuple(_args, ""))
2405 return NULL;
2406 _rv = CFURLGetString(_self->ob_itself);
2407 _res = Py_BuildValue("O&",
2408 CFStringRefObj_New, _rv);
2409 return _res;
2410}
2411
2412static PyObject *CFURLRefObj_CFURLGetBaseURL(CFURLRefObject *_self, PyObject *_args)
2413{
2414 PyObject *_res = NULL;
2415 CFURLRef _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002416#ifndef CFURLGetBaseURL
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002417 PyMac_PRECHECK(CFURLGetBaseURL);
Jack Jansenb3be2162001-11-30 14:16:36 +00002418#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002419 if (!PyArg_ParseTuple(_args, ""))
2420 return NULL;
2421 _rv = CFURLGetBaseURL(_self->ob_itself);
2422 _res = Py_BuildValue("O&",
2423 CFURLRefObj_New, _rv);
2424 return _res;
2425}
2426
2427static PyObject *CFURLRefObj_CFURLCanBeDecomposed(CFURLRefObject *_self, PyObject *_args)
2428{
2429 PyObject *_res = NULL;
2430 Boolean _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002431#ifndef CFURLCanBeDecomposed
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002432 PyMac_PRECHECK(CFURLCanBeDecomposed);
Jack Jansenb3be2162001-11-30 14:16:36 +00002433#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002434 if (!PyArg_ParseTuple(_args, ""))
2435 return NULL;
2436 _rv = CFURLCanBeDecomposed(_self->ob_itself);
2437 _res = Py_BuildValue("l",
2438 _rv);
2439 return _res;
2440}
2441
2442static PyObject *CFURLRefObj_CFURLCopyScheme(CFURLRefObject *_self, PyObject *_args)
2443{
2444 PyObject *_res = NULL;
2445 CFStringRef _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002446#ifndef CFURLCopyScheme
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002447 PyMac_PRECHECK(CFURLCopyScheme);
Jack Jansenb3be2162001-11-30 14:16:36 +00002448#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002449 if (!PyArg_ParseTuple(_args, ""))
2450 return NULL;
2451 _rv = CFURLCopyScheme(_self->ob_itself);
2452 _res = Py_BuildValue("O&",
2453 CFStringRefObj_New, _rv);
2454 return _res;
2455}
2456
2457static PyObject *CFURLRefObj_CFURLCopyNetLocation(CFURLRefObject *_self, PyObject *_args)
2458{
2459 PyObject *_res = NULL;
2460 CFStringRef _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002461#ifndef CFURLCopyNetLocation
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002462 PyMac_PRECHECK(CFURLCopyNetLocation);
Jack Jansenb3be2162001-11-30 14:16:36 +00002463#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002464 if (!PyArg_ParseTuple(_args, ""))
2465 return NULL;
2466 _rv = CFURLCopyNetLocation(_self->ob_itself);
2467 _res = Py_BuildValue("O&",
2468 CFStringRefObj_New, _rv);
2469 return _res;
2470}
2471
2472static PyObject *CFURLRefObj_CFURLCopyPath(CFURLRefObject *_self, PyObject *_args)
2473{
2474 PyObject *_res = NULL;
2475 CFStringRef _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002476#ifndef CFURLCopyPath
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002477 PyMac_PRECHECK(CFURLCopyPath);
Jack Jansenb3be2162001-11-30 14:16:36 +00002478#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002479 if (!PyArg_ParseTuple(_args, ""))
2480 return NULL;
2481 _rv = CFURLCopyPath(_self->ob_itself);
2482 _res = Py_BuildValue("O&",
2483 CFStringRefObj_New, _rv);
2484 return _res;
2485}
2486
Jack Jansen2168e9d2001-12-16 20:18:40 +00002487static PyObject *CFURLRefObj_CFURLCopyStrictPath(CFURLRefObject *_self, PyObject *_args)
2488{
2489 PyObject *_res = NULL;
2490 CFStringRef _rv;
2491 Boolean isAbsolute;
2492#ifndef CFURLCopyStrictPath
2493 PyMac_PRECHECK(CFURLCopyStrictPath);
2494#endif
2495 if (!PyArg_ParseTuple(_args, ""))
2496 return NULL;
2497 _rv = CFURLCopyStrictPath(_self->ob_itself,
2498 &isAbsolute);
2499 _res = Py_BuildValue("O&l",
2500 CFStringRefObj_New, _rv,
2501 isAbsolute);
2502 return _res;
2503}
2504
2505static PyObject *CFURLRefObj_CFURLCopyFileSystemPath(CFURLRefObject *_self, PyObject *_args)
2506{
2507 PyObject *_res = NULL;
2508 CFStringRef _rv;
2509 CFURLPathStyle pathStyle;
2510#ifndef CFURLCopyFileSystemPath
2511 PyMac_PRECHECK(CFURLCopyFileSystemPath);
2512#endif
2513 if (!PyArg_ParseTuple(_args, "l",
2514 &pathStyle))
2515 return NULL;
2516 _rv = CFURLCopyFileSystemPath(_self->ob_itself,
2517 pathStyle);
2518 _res = Py_BuildValue("O&",
2519 CFStringRefObj_New, _rv);
2520 return _res;
2521}
2522
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002523static PyObject *CFURLRefObj_CFURLHasDirectoryPath(CFURLRefObject *_self, PyObject *_args)
2524{
2525 PyObject *_res = NULL;
2526 Boolean _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002527#ifndef CFURLHasDirectoryPath
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002528 PyMac_PRECHECK(CFURLHasDirectoryPath);
Jack Jansenb3be2162001-11-30 14:16:36 +00002529#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002530 if (!PyArg_ParseTuple(_args, ""))
2531 return NULL;
2532 _rv = CFURLHasDirectoryPath(_self->ob_itself);
2533 _res = Py_BuildValue("l",
2534 _rv);
2535 return _res;
2536}
2537
2538static PyObject *CFURLRefObj_CFURLCopyResourceSpecifier(CFURLRefObject *_self, PyObject *_args)
2539{
2540 PyObject *_res = NULL;
2541 CFStringRef _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002542#ifndef CFURLCopyResourceSpecifier
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002543 PyMac_PRECHECK(CFURLCopyResourceSpecifier);
Jack Jansenb3be2162001-11-30 14:16:36 +00002544#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002545 if (!PyArg_ParseTuple(_args, ""))
2546 return NULL;
2547 _rv = CFURLCopyResourceSpecifier(_self->ob_itself);
2548 _res = Py_BuildValue("O&",
2549 CFStringRefObj_New, _rv);
2550 return _res;
2551}
2552
2553static PyObject *CFURLRefObj_CFURLCopyHostName(CFURLRefObject *_self, PyObject *_args)
2554{
2555 PyObject *_res = NULL;
2556 CFStringRef _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002557#ifndef CFURLCopyHostName
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002558 PyMac_PRECHECK(CFURLCopyHostName);
Jack Jansenb3be2162001-11-30 14:16:36 +00002559#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002560 if (!PyArg_ParseTuple(_args, ""))
2561 return NULL;
2562 _rv = CFURLCopyHostName(_self->ob_itself);
2563 _res = Py_BuildValue("O&",
2564 CFStringRefObj_New, _rv);
2565 return _res;
2566}
2567
2568static PyObject *CFURLRefObj_CFURLGetPortNumber(CFURLRefObject *_self, PyObject *_args)
2569{
2570 PyObject *_res = NULL;
2571 SInt32 _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002572#ifndef CFURLGetPortNumber
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002573 PyMac_PRECHECK(CFURLGetPortNumber);
Jack Jansenb3be2162001-11-30 14:16:36 +00002574#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002575 if (!PyArg_ParseTuple(_args, ""))
2576 return NULL;
2577 _rv = CFURLGetPortNumber(_self->ob_itself);
2578 _res = Py_BuildValue("l",
2579 _rv);
2580 return _res;
2581}
2582
2583static PyObject *CFURLRefObj_CFURLCopyUserName(CFURLRefObject *_self, PyObject *_args)
2584{
2585 PyObject *_res = NULL;
2586 CFStringRef _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002587#ifndef CFURLCopyUserName
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002588 PyMac_PRECHECK(CFURLCopyUserName);
Jack Jansenb3be2162001-11-30 14:16:36 +00002589#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002590 if (!PyArg_ParseTuple(_args, ""))
2591 return NULL;
2592 _rv = CFURLCopyUserName(_self->ob_itself);
2593 _res = Py_BuildValue("O&",
2594 CFStringRefObj_New, _rv);
2595 return _res;
2596}
2597
2598static PyObject *CFURLRefObj_CFURLCopyPassword(CFURLRefObject *_self, PyObject *_args)
2599{
2600 PyObject *_res = NULL;
2601 CFStringRef _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002602#ifndef CFURLCopyPassword
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002603 PyMac_PRECHECK(CFURLCopyPassword);
Jack Jansenb3be2162001-11-30 14:16:36 +00002604#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002605 if (!PyArg_ParseTuple(_args, ""))
2606 return NULL;
2607 _rv = CFURLCopyPassword(_self->ob_itself);
2608 _res = Py_BuildValue("O&",
2609 CFStringRefObj_New, _rv);
2610 return _res;
2611}
2612
2613static PyObject *CFURLRefObj_CFURLCopyParameterString(CFURLRefObject *_self, PyObject *_args)
2614{
2615 PyObject *_res = NULL;
2616 CFStringRef _rv;
2617 CFStringRef charactersToLeaveEscaped;
Jack Jansenb3be2162001-11-30 14:16:36 +00002618#ifndef CFURLCopyParameterString
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002619 PyMac_PRECHECK(CFURLCopyParameterString);
Jack Jansenb3be2162001-11-30 14:16:36 +00002620#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002621 if (!PyArg_ParseTuple(_args, "O&",
2622 CFStringRefObj_Convert, &charactersToLeaveEscaped))
2623 return NULL;
2624 _rv = CFURLCopyParameterString(_self->ob_itself,
2625 charactersToLeaveEscaped);
2626 _res = Py_BuildValue("O&",
2627 CFStringRefObj_New, _rv);
2628 return _res;
2629}
2630
2631static PyObject *CFURLRefObj_CFURLCopyQueryString(CFURLRefObject *_self, PyObject *_args)
2632{
2633 PyObject *_res = NULL;
2634 CFStringRef _rv;
2635 CFStringRef charactersToLeaveEscaped;
Jack Jansenb3be2162001-11-30 14:16:36 +00002636#ifndef CFURLCopyQueryString
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002637 PyMac_PRECHECK(CFURLCopyQueryString);
Jack Jansenb3be2162001-11-30 14:16:36 +00002638#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002639 if (!PyArg_ParseTuple(_args, "O&",
2640 CFStringRefObj_Convert, &charactersToLeaveEscaped))
2641 return NULL;
2642 _rv = CFURLCopyQueryString(_self->ob_itself,
2643 charactersToLeaveEscaped);
2644 _res = Py_BuildValue("O&",
2645 CFStringRefObj_New, _rv);
2646 return _res;
2647}
2648
2649static PyObject *CFURLRefObj_CFURLCopyFragment(CFURLRefObject *_self, PyObject *_args)
2650{
2651 PyObject *_res = NULL;
2652 CFStringRef _rv;
2653 CFStringRef charactersToLeaveEscaped;
Jack Jansenb3be2162001-11-30 14:16:36 +00002654#ifndef CFURLCopyFragment
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002655 PyMac_PRECHECK(CFURLCopyFragment);
Jack Jansenb3be2162001-11-30 14:16:36 +00002656#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002657 if (!PyArg_ParseTuple(_args, "O&",
2658 CFStringRefObj_Convert, &charactersToLeaveEscaped))
2659 return NULL;
2660 _rv = CFURLCopyFragment(_self->ob_itself,
2661 charactersToLeaveEscaped);
2662 _res = Py_BuildValue("O&",
2663 CFStringRefObj_New, _rv);
2664 return _res;
2665}
2666
Jack Jansen2168e9d2001-12-16 20:18:40 +00002667static PyObject *CFURLRefObj_CFURLCopyLastPathComponent(CFURLRefObject *_self, PyObject *_args)
2668{
2669 PyObject *_res = NULL;
2670 CFStringRef _rv;
2671#ifndef CFURLCopyLastPathComponent
2672 PyMac_PRECHECK(CFURLCopyLastPathComponent);
2673#endif
2674 if (!PyArg_ParseTuple(_args, ""))
2675 return NULL;
2676 _rv = CFURLCopyLastPathComponent(_self->ob_itself);
2677 _res = Py_BuildValue("O&",
2678 CFStringRefObj_New, _rv);
2679 return _res;
2680}
2681
2682static PyObject *CFURLRefObj_CFURLCopyPathExtension(CFURLRefObject *_self, PyObject *_args)
2683{
2684 PyObject *_res = NULL;
2685 CFStringRef _rv;
2686#ifndef CFURLCopyPathExtension
2687 PyMac_PRECHECK(CFURLCopyPathExtension);
2688#endif
2689 if (!PyArg_ParseTuple(_args, ""))
2690 return NULL;
2691 _rv = CFURLCopyPathExtension(_self->ob_itself);
2692 _res = Py_BuildValue("O&",
2693 CFStringRefObj_New, _rv);
2694 return _res;
2695}
2696
2697static PyObject *CFURLRefObj_CFURLCreateCopyAppendingPathComponent(CFURLRefObject *_self, PyObject *_args)
2698{
2699 PyObject *_res = NULL;
2700 CFURLRef _rv;
2701 CFStringRef pathComponent;
2702 Boolean isDirectory;
2703 if (!PyArg_ParseTuple(_args, "O&l",
2704 CFStringRefObj_Convert, &pathComponent,
2705 &isDirectory))
2706 return NULL;
2707 _rv = CFURLCreateCopyAppendingPathComponent((CFAllocatorRef)NULL,
2708 _self->ob_itself,
2709 pathComponent,
2710 isDirectory);
2711 _res = Py_BuildValue("O&",
2712 CFURLRefObj_New, _rv);
2713 return _res;
2714}
2715
2716static PyObject *CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent(CFURLRefObject *_self, PyObject *_args)
2717{
2718 PyObject *_res = NULL;
2719 CFURLRef _rv;
2720 if (!PyArg_ParseTuple(_args, ""))
2721 return NULL;
2722 _rv = CFURLCreateCopyDeletingLastPathComponent((CFAllocatorRef)NULL,
2723 _self->ob_itself);
2724 _res = Py_BuildValue("O&",
2725 CFURLRefObj_New, _rv);
2726 return _res;
2727}
2728
2729static PyObject *CFURLRefObj_CFURLCreateCopyAppendingPathExtension(CFURLRefObject *_self, PyObject *_args)
2730{
2731 PyObject *_res = NULL;
2732 CFURLRef _rv;
2733 CFStringRef extension;
2734 if (!PyArg_ParseTuple(_args, "O&",
2735 CFStringRefObj_Convert, &extension))
2736 return NULL;
2737 _rv = CFURLCreateCopyAppendingPathExtension((CFAllocatorRef)NULL,
2738 _self->ob_itself,
2739 extension);
2740 _res = Py_BuildValue("O&",
2741 CFURLRefObj_New, _rv);
2742 return _res;
2743}
2744
2745static PyObject *CFURLRefObj_CFURLCreateCopyDeletingPathExtension(CFURLRefObject *_self, PyObject *_args)
2746{
2747 PyObject *_res = NULL;
2748 CFURLRef _rv;
2749 if (!PyArg_ParseTuple(_args, ""))
2750 return NULL;
2751 _rv = CFURLCreateCopyDeletingPathExtension((CFAllocatorRef)NULL,
2752 _self->ob_itself);
2753 _res = Py_BuildValue("O&",
2754 CFURLRefObj_New, _rv);
2755 return _res;
2756}
2757
2758static PyObject *CFURLRefObj_CFURLGetFSRef(CFURLRefObject *_self, PyObject *_args)
2759{
2760 PyObject *_res = NULL;
2761 Boolean _rv;
2762 FSRef fsRef;
2763#ifndef CFURLGetFSRef
2764 PyMac_PRECHECK(CFURLGetFSRef);
2765#endif
2766 if (!PyArg_ParseTuple(_args, ""))
2767 return NULL;
2768 _rv = CFURLGetFSRef(_self->ob_itself,
2769 &fsRef);
2770 _res = Py_BuildValue("lO&",
2771 _rv,
2772 PyMac_BuildFSRef, fsRef);
2773 return _res;
2774}
2775
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002776static PyMethodDef CFURLRefObj_methods[] = {
2777 {"CFURLCreateData", (PyCFunction)CFURLRefObj_CFURLCreateData, 1,
2778 "(CFStringEncoding encoding, Boolean escapeWhitespace) -> (CFDataRef _rv)"},
Jack Jansen2168e9d2001-12-16 20:18:40 +00002779 {"CFURLGetFileSystemRepresentation", (PyCFunction)CFURLRefObj_CFURLGetFileSystemRepresentation, 1,
2780 "(Boolean resolveAgainstBase, CFIndex maxBufLen) -> (Boolean _rv, UInt8 buffer)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002781 {"CFURLCopyAbsoluteURL", (PyCFunction)CFURLRefObj_CFURLCopyAbsoluteURL, 1,
2782 "() -> (CFURLRef _rv)"},
2783 {"CFURLGetString", (PyCFunction)CFURLRefObj_CFURLGetString, 1,
2784 "() -> (CFStringRef _rv)"},
2785 {"CFURLGetBaseURL", (PyCFunction)CFURLRefObj_CFURLGetBaseURL, 1,
2786 "() -> (CFURLRef _rv)"},
2787 {"CFURLCanBeDecomposed", (PyCFunction)CFURLRefObj_CFURLCanBeDecomposed, 1,
2788 "() -> (Boolean _rv)"},
2789 {"CFURLCopyScheme", (PyCFunction)CFURLRefObj_CFURLCopyScheme, 1,
2790 "() -> (CFStringRef _rv)"},
2791 {"CFURLCopyNetLocation", (PyCFunction)CFURLRefObj_CFURLCopyNetLocation, 1,
2792 "() -> (CFStringRef _rv)"},
2793 {"CFURLCopyPath", (PyCFunction)CFURLRefObj_CFURLCopyPath, 1,
2794 "() -> (CFStringRef _rv)"},
Jack Jansen2168e9d2001-12-16 20:18:40 +00002795 {"CFURLCopyStrictPath", (PyCFunction)CFURLRefObj_CFURLCopyStrictPath, 1,
2796 "() -> (CFStringRef _rv, Boolean isAbsolute)"},
2797 {"CFURLCopyFileSystemPath", (PyCFunction)CFURLRefObj_CFURLCopyFileSystemPath, 1,
2798 "(CFURLPathStyle pathStyle) -> (CFStringRef _rv)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002799 {"CFURLHasDirectoryPath", (PyCFunction)CFURLRefObj_CFURLHasDirectoryPath, 1,
2800 "() -> (Boolean _rv)"},
2801 {"CFURLCopyResourceSpecifier", (PyCFunction)CFURLRefObj_CFURLCopyResourceSpecifier, 1,
2802 "() -> (CFStringRef _rv)"},
2803 {"CFURLCopyHostName", (PyCFunction)CFURLRefObj_CFURLCopyHostName, 1,
2804 "() -> (CFStringRef _rv)"},
2805 {"CFURLGetPortNumber", (PyCFunction)CFURLRefObj_CFURLGetPortNumber, 1,
2806 "() -> (SInt32 _rv)"},
2807 {"CFURLCopyUserName", (PyCFunction)CFURLRefObj_CFURLCopyUserName, 1,
2808 "() -> (CFStringRef _rv)"},
2809 {"CFURLCopyPassword", (PyCFunction)CFURLRefObj_CFURLCopyPassword, 1,
2810 "() -> (CFStringRef _rv)"},
2811 {"CFURLCopyParameterString", (PyCFunction)CFURLRefObj_CFURLCopyParameterString, 1,
2812 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2813 {"CFURLCopyQueryString", (PyCFunction)CFURLRefObj_CFURLCopyQueryString, 1,
2814 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
2815 {"CFURLCopyFragment", (PyCFunction)CFURLRefObj_CFURLCopyFragment, 1,
2816 "(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)"},
Jack Jansen2168e9d2001-12-16 20:18:40 +00002817 {"CFURLCopyLastPathComponent", (PyCFunction)CFURLRefObj_CFURLCopyLastPathComponent, 1,
2818 "() -> (CFStringRef _rv)"},
2819 {"CFURLCopyPathExtension", (PyCFunction)CFURLRefObj_CFURLCopyPathExtension, 1,
2820 "() -> (CFStringRef _rv)"},
2821 {"CFURLCreateCopyAppendingPathComponent", (PyCFunction)CFURLRefObj_CFURLCreateCopyAppendingPathComponent, 1,
2822 "(CFStringRef pathComponent, Boolean isDirectory) -> (CFURLRef _rv)"},
2823 {"CFURLCreateCopyDeletingLastPathComponent", (PyCFunction)CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent, 1,
2824 "() -> (CFURLRef _rv)"},
2825 {"CFURLCreateCopyAppendingPathExtension", (PyCFunction)CFURLRefObj_CFURLCreateCopyAppendingPathExtension, 1,
2826 "(CFStringRef extension) -> (CFURLRef _rv)"},
2827 {"CFURLCreateCopyDeletingPathExtension", (PyCFunction)CFURLRefObj_CFURLCreateCopyDeletingPathExtension, 1,
2828 "() -> (CFURLRef _rv)"},
2829 {"CFURLGetFSRef", (PyCFunction)CFURLRefObj_CFURLGetFSRef, 1,
2830 "() -> (Boolean _rv, FSRef fsRef)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002831 {NULL, NULL, 0}
2832};
2833
2834PyMethodChain CFURLRefObj_chain = { CFURLRefObj_methods, &CFTypeRefObj_chain };
2835
2836static PyObject *CFURLRefObj_getattr(CFURLRefObject *self, char *name)
2837{
2838 return Py_FindMethodInChain(&CFURLRefObj_chain, (PyObject *)self, name);
2839}
2840
2841#define CFURLRefObj_setattr NULL
2842
2843static int CFURLRefObj_compare(CFURLRefObject *self, CFURLRefObject *other)
2844{
2845 /* XXXX Or should we use CFEqual?? */
2846 if ( self->ob_itself > other->ob_itself ) return 1;
2847 if ( self->ob_itself < other->ob_itself ) return -1;
2848 return 0;
2849}
2850
2851static PyObject * CFURLRefObj_repr(CFURLRefObject *self)
2852{
2853 char buf[100];
Jack Jansenfd064862001-09-05 10:31:52 +00002854 sprintf(buf, "<CFURL object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002855 return PyString_FromString(buf);
2856}
2857
2858static int CFURLRefObj_hash(CFURLRefObject *self)
2859{
2860 /* XXXX Or should we use CFHash?? */
2861 return (int)self->ob_itself;
2862}
2863
2864PyTypeObject CFURLRef_Type = {
Jack Jansenb3be2162001-11-30 14:16:36 +00002865 PyObject_HEAD_INIT(NULL)
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002866 0, /*ob_size*/
Guido van Rossum14648392001-12-08 18:02:58 +00002867 "_CF.CFURLRef", /*tp_name*/
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002868 sizeof(CFURLRefObject), /*tp_basicsize*/
2869 0, /*tp_itemsize*/
2870 /* methods */
2871 (destructor) CFURLRefObj_dealloc, /*tp_dealloc*/
2872 0, /*tp_print*/
2873 (getattrfunc) CFURLRefObj_getattr, /*tp_getattr*/
2874 (setattrfunc) CFURLRefObj_setattr, /*tp_setattr*/
2875 (cmpfunc) CFURLRefObj_compare, /*tp_compare*/
2876 (reprfunc) CFURLRefObj_repr, /*tp_repr*/
2877 (PyNumberMethods *)0, /* tp_as_number */
2878 (PySequenceMethods *)0, /* tp_as_sequence */
2879 (PyMappingMethods *)0, /* tp_as_mapping */
2880 (hashfunc) CFURLRefObj_hash, /*tp_hash*/
2881};
2882
2883/* -------------------- End object type CFURLRef -------------------- */
2884
2885
Jack Jansen2168e9d2001-12-16 20:18:40 +00002886static PyObject *CF___CFRangeMake(PyObject *_self, PyObject *_args)
2887{
2888 PyObject *_res = NULL;
2889 CFRange _rv;
2890 CFIndex loc;
2891 CFIndex len;
2892#ifndef __CFRangeMake
2893 PyMac_PRECHECK(__CFRangeMake);
2894#endif
2895 if (!PyArg_ParseTuple(_args, "ll",
2896 &loc,
2897 &len))
2898 return NULL;
2899 _rv = __CFRangeMake(loc,
2900 len);
2901 _res = Py_BuildValue("O&",
2902 CFRange_New, _rv);
2903 return _res;
2904}
2905
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002906static PyObject *CF_CFAllocatorGetTypeID(PyObject *_self, PyObject *_args)
2907{
2908 PyObject *_res = NULL;
2909 CFTypeID _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002910#ifndef CFAllocatorGetTypeID
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002911 PyMac_PRECHECK(CFAllocatorGetTypeID);
Jack Jansenb3be2162001-11-30 14:16:36 +00002912#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002913 if (!PyArg_ParseTuple(_args, ""))
2914 return NULL;
2915 _rv = CFAllocatorGetTypeID();
2916 _res = Py_BuildValue("l",
2917 _rv);
2918 return _res;
2919}
2920
2921static PyObject *CF_CFAllocatorGetPreferredSizeForSize(PyObject *_self, PyObject *_args)
2922{
2923 PyObject *_res = NULL;
2924 CFIndex _rv;
2925 CFIndex size;
2926 CFOptionFlags hint;
Jack Jansenb3be2162001-11-30 14:16:36 +00002927#ifndef CFAllocatorGetPreferredSizeForSize
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002928 PyMac_PRECHECK(CFAllocatorGetPreferredSizeForSize);
Jack Jansenb3be2162001-11-30 14:16:36 +00002929#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002930 if (!PyArg_ParseTuple(_args, "ll",
2931 &size,
2932 &hint))
2933 return NULL;
2934 _rv = CFAllocatorGetPreferredSizeForSize((CFAllocatorRef)NULL,
2935 size,
2936 hint);
2937 _res = Py_BuildValue("l",
2938 _rv);
2939 return _res;
2940}
2941
2942static PyObject *CF_CFCopyTypeIDDescription(PyObject *_self, PyObject *_args)
2943{
2944 PyObject *_res = NULL;
2945 CFStringRef _rv;
Jack Jansen2168e9d2001-12-16 20:18:40 +00002946 CFTypeID type_id;
Jack Jansenb3be2162001-11-30 14:16:36 +00002947#ifndef CFCopyTypeIDDescription
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002948 PyMac_PRECHECK(CFCopyTypeIDDescription);
Jack Jansenb3be2162001-11-30 14:16:36 +00002949#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002950 if (!PyArg_ParseTuple(_args, "l",
Jack Jansen2168e9d2001-12-16 20:18:40 +00002951 &type_id))
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002952 return NULL;
Jack Jansen2168e9d2001-12-16 20:18:40 +00002953 _rv = CFCopyTypeIDDescription(type_id);
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002954 _res = Py_BuildValue("O&",
2955 CFStringRefObj_New, _rv);
2956 return _res;
2957}
2958
2959static PyObject *CF_CFArrayGetTypeID(PyObject *_self, PyObject *_args)
2960{
2961 PyObject *_res = NULL;
2962 CFTypeID _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00002963#ifndef CFArrayGetTypeID
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002964 PyMac_PRECHECK(CFArrayGetTypeID);
Jack Jansenb3be2162001-11-30 14:16:36 +00002965#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002966 if (!PyArg_ParseTuple(_args, ""))
2967 return NULL;
2968 _rv = CFArrayGetTypeID();
2969 _res = Py_BuildValue("l",
2970 _rv);
2971 return _res;
2972}
2973
2974static PyObject *CF_CFArrayCreateMutable(PyObject *_self, PyObject *_args)
2975{
2976 PyObject *_res = NULL;
2977 CFMutableArrayRef _rv;
2978 CFIndex capacity;
Jack Jansenb3be2162001-11-30 14:16:36 +00002979#ifndef CFArrayCreateMutable
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002980 PyMac_PRECHECK(CFArrayCreateMutable);
Jack Jansenb3be2162001-11-30 14:16:36 +00002981#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00002982 if (!PyArg_ParseTuple(_args, "l",
2983 &capacity))
2984 return NULL;
2985 _rv = CFArrayCreateMutable((CFAllocatorRef)NULL,
2986 capacity,
2987 &kCFTypeArrayCallBacks);
2988 _res = Py_BuildValue("O&",
2989 CFMutableArrayRefObj_New, _rv);
2990 return _res;
2991}
2992
2993static PyObject *CF_CFArrayCreateMutableCopy(PyObject *_self, PyObject *_args)
2994{
2995 PyObject *_res = NULL;
2996 CFMutableArrayRef _rv;
2997 CFIndex capacity;
Jack Jansen2168e9d2001-12-16 20:18:40 +00002998 CFArrayRef theArray;
Jack Jansenb3be2162001-11-30 14:16:36 +00002999#ifndef CFArrayCreateMutableCopy
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003000 PyMac_PRECHECK(CFArrayCreateMutableCopy);
Jack Jansenb3be2162001-11-30 14:16:36 +00003001#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003002 if (!PyArg_ParseTuple(_args, "lO&",
3003 &capacity,
Jack Jansen2168e9d2001-12-16 20:18:40 +00003004 CFArrayRefObj_Convert, &theArray))
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003005 return NULL;
3006 _rv = CFArrayCreateMutableCopy((CFAllocatorRef)NULL,
3007 capacity,
Jack Jansen2168e9d2001-12-16 20:18:40 +00003008 theArray);
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003009 _res = Py_BuildValue("O&",
3010 CFMutableArrayRefObj_New, _rv);
3011 return _res;
3012}
3013
3014static PyObject *CF_CFDataGetTypeID(PyObject *_self, PyObject *_args)
3015{
3016 PyObject *_res = NULL;
3017 CFTypeID _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00003018#ifndef CFDataGetTypeID
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003019 PyMac_PRECHECK(CFDataGetTypeID);
Jack Jansenb3be2162001-11-30 14:16:36 +00003020#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003021 if (!PyArg_ParseTuple(_args, ""))
3022 return NULL;
3023 _rv = CFDataGetTypeID();
3024 _res = Py_BuildValue("l",
3025 _rv);
3026 return _res;
3027}
3028
3029static PyObject *CF_CFDataCreate(PyObject *_self, PyObject *_args)
3030{
3031 PyObject *_res = NULL;
3032 CFDataRef _rv;
3033 unsigned char *bytes__in__;
3034 long bytes__len__;
3035 int bytes__in_len__;
Jack Jansenb3be2162001-11-30 14:16:36 +00003036#ifndef CFDataCreate
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003037 PyMac_PRECHECK(CFDataCreate);
Jack Jansenb3be2162001-11-30 14:16:36 +00003038#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003039 if (!PyArg_ParseTuple(_args, "s#",
3040 &bytes__in__, &bytes__in_len__))
3041 return NULL;
3042 bytes__len__ = bytes__in_len__;
3043 _rv = CFDataCreate((CFAllocatorRef)NULL,
3044 bytes__in__, bytes__len__);
3045 _res = Py_BuildValue("O&",
3046 CFDataRefObj_New, _rv);
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003047 return _res;
3048}
3049
3050static PyObject *CF_CFDataCreateWithBytesNoCopy(PyObject *_self, PyObject *_args)
3051{
3052 PyObject *_res = NULL;
3053 CFDataRef _rv;
3054 unsigned char *bytes__in__;
3055 long bytes__len__;
3056 int bytes__in_len__;
Jack Jansenb3be2162001-11-30 14:16:36 +00003057#ifndef CFDataCreateWithBytesNoCopy
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003058 PyMac_PRECHECK(CFDataCreateWithBytesNoCopy);
Jack Jansenb3be2162001-11-30 14:16:36 +00003059#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003060 if (!PyArg_ParseTuple(_args, "s#",
3061 &bytes__in__, &bytes__in_len__))
3062 return NULL;
3063 bytes__len__ = bytes__in_len__;
3064 _rv = CFDataCreateWithBytesNoCopy((CFAllocatorRef)NULL,
3065 bytes__in__, bytes__len__,
3066 (CFAllocatorRef)NULL);
3067 _res = Py_BuildValue("O&",
3068 CFDataRefObj_New, _rv);
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003069 return _res;
3070}
3071
3072static PyObject *CF_CFDataCreateMutable(PyObject *_self, PyObject *_args)
3073{
3074 PyObject *_res = NULL;
3075 CFMutableDataRef _rv;
3076 CFIndex capacity;
Jack Jansenb3be2162001-11-30 14:16:36 +00003077#ifndef CFDataCreateMutable
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003078 PyMac_PRECHECK(CFDataCreateMutable);
Jack Jansenb3be2162001-11-30 14:16:36 +00003079#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003080 if (!PyArg_ParseTuple(_args, "l",
3081 &capacity))
3082 return NULL;
3083 _rv = CFDataCreateMutable((CFAllocatorRef)NULL,
3084 capacity);
3085 _res = Py_BuildValue("O&",
3086 CFMutableDataRefObj_New, _rv);
3087 return _res;
3088}
3089
3090static PyObject *CF_CFDataCreateMutableCopy(PyObject *_self, PyObject *_args)
3091{
3092 PyObject *_res = NULL;
3093 CFMutableDataRef _rv;
3094 CFIndex capacity;
Jack Jansen2168e9d2001-12-16 20:18:40 +00003095 CFDataRef theData;
Jack Jansenb3be2162001-11-30 14:16:36 +00003096#ifndef CFDataCreateMutableCopy
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003097 PyMac_PRECHECK(CFDataCreateMutableCopy);
Jack Jansenb3be2162001-11-30 14:16:36 +00003098#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003099 if (!PyArg_ParseTuple(_args, "lO&",
3100 &capacity,
Jack Jansen2168e9d2001-12-16 20:18:40 +00003101 CFDataRefObj_Convert, &theData))
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003102 return NULL;
3103 _rv = CFDataCreateMutableCopy((CFAllocatorRef)NULL,
3104 capacity,
Jack Jansen2168e9d2001-12-16 20:18:40 +00003105 theData);
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003106 _res = Py_BuildValue("O&",
3107 CFMutableDataRefObj_New, _rv);
3108 return _res;
3109}
3110
3111static PyObject *CF_CFDictionaryGetTypeID(PyObject *_self, PyObject *_args)
3112{
3113 PyObject *_res = NULL;
3114 CFTypeID _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00003115#ifndef CFDictionaryGetTypeID
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003116 PyMac_PRECHECK(CFDictionaryGetTypeID);
Jack Jansenb3be2162001-11-30 14:16:36 +00003117#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003118 if (!PyArg_ParseTuple(_args, ""))
3119 return NULL;
3120 _rv = CFDictionaryGetTypeID();
3121 _res = Py_BuildValue("l",
3122 _rv);
3123 return _res;
3124}
3125
3126static PyObject *CF_CFDictionaryCreateMutable(PyObject *_self, PyObject *_args)
3127{
3128 PyObject *_res = NULL;
3129 CFMutableDictionaryRef _rv;
3130 CFIndex capacity;
Jack Jansenb3be2162001-11-30 14:16:36 +00003131#ifndef CFDictionaryCreateMutable
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003132 PyMac_PRECHECK(CFDictionaryCreateMutable);
Jack Jansenb3be2162001-11-30 14:16:36 +00003133#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003134 if (!PyArg_ParseTuple(_args, "l",
3135 &capacity))
3136 return NULL;
3137 _rv = CFDictionaryCreateMutable((CFAllocatorRef)NULL,
3138 capacity,
3139 &kCFTypeDictionaryKeyCallBacks,
3140 &kCFTypeDictionaryValueCallBacks);
3141 _res = Py_BuildValue("O&",
3142 CFMutableDictionaryRefObj_New, _rv);
3143 return _res;
3144}
3145
3146static PyObject *CF_CFDictionaryCreateMutableCopy(PyObject *_self, PyObject *_args)
3147{
3148 PyObject *_res = NULL;
3149 CFMutableDictionaryRef _rv;
3150 CFIndex capacity;
Jack Jansen2168e9d2001-12-16 20:18:40 +00003151 CFDictionaryRef theDict;
Jack Jansenb3be2162001-11-30 14:16:36 +00003152#ifndef CFDictionaryCreateMutableCopy
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003153 PyMac_PRECHECK(CFDictionaryCreateMutableCopy);
Jack Jansenb3be2162001-11-30 14:16:36 +00003154#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003155 if (!PyArg_ParseTuple(_args, "lO&",
3156 &capacity,
Jack Jansen2168e9d2001-12-16 20:18:40 +00003157 CFDictionaryRefObj_Convert, &theDict))
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003158 return NULL;
3159 _rv = CFDictionaryCreateMutableCopy((CFAllocatorRef)NULL,
3160 capacity,
Jack Jansen2168e9d2001-12-16 20:18:40 +00003161 theDict);
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003162 _res = Py_BuildValue("O&",
3163 CFMutableDictionaryRefObj_New, _rv);
3164 return _res;
3165}
3166
3167static PyObject *CF_CFStringGetTypeID(PyObject *_self, PyObject *_args)
3168{
3169 PyObject *_res = NULL;
3170 CFTypeID _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00003171#ifndef CFStringGetTypeID
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003172 PyMac_PRECHECK(CFStringGetTypeID);
Jack Jansenb3be2162001-11-30 14:16:36 +00003173#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003174 if (!PyArg_ParseTuple(_args, ""))
3175 return NULL;
3176 _rv = CFStringGetTypeID();
3177 _res = Py_BuildValue("l",
3178 _rv);
3179 return _res;
3180}
3181
3182static PyObject *CF_CFStringCreateWithPascalString(PyObject *_self, PyObject *_args)
3183{
3184 PyObject *_res = NULL;
3185 CFStringRef _rv;
Jack Jansen2168e9d2001-12-16 20:18:40 +00003186 Str255 pStr;
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003187 CFStringEncoding encoding;
Jack Jansenb3be2162001-11-30 14:16:36 +00003188#ifndef CFStringCreateWithPascalString
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003189 PyMac_PRECHECK(CFStringCreateWithPascalString);
Jack Jansenb3be2162001-11-30 14:16:36 +00003190#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003191 if (!PyArg_ParseTuple(_args, "O&l",
Jack Jansen2168e9d2001-12-16 20:18:40 +00003192 PyMac_GetStr255, pStr,
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003193 &encoding))
3194 return NULL;
3195 _rv = CFStringCreateWithPascalString((CFAllocatorRef)NULL,
3196 pStr,
3197 encoding);
3198 _res = Py_BuildValue("O&",
3199 CFStringRefObj_New, _rv);
3200 return _res;
3201}
3202
3203static PyObject *CF_CFStringCreateWithCString(PyObject *_self, PyObject *_args)
3204{
3205 PyObject *_res = NULL;
3206 CFStringRef _rv;
3207 char* cStr;
3208 CFStringEncoding encoding;
Jack Jansenb3be2162001-11-30 14:16:36 +00003209#ifndef CFStringCreateWithCString
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003210 PyMac_PRECHECK(CFStringCreateWithCString);
Jack Jansenb3be2162001-11-30 14:16:36 +00003211#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003212 if (!PyArg_ParseTuple(_args, "sl",
3213 &cStr,
3214 &encoding))
3215 return NULL;
3216 _rv = CFStringCreateWithCString((CFAllocatorRef)NULL,
3217 cStr,
3218 encoding);
3219 _res = Py_BuildValue("O&",
3220 CFStringRefObj_New, _rv);
3221 return _res;
3222}
3223
3224static PyObject *CF_CFStringCreateWithPascalStringNoCopy(PyObject *_self, PyObject *_args)
3225{
3226 PyObject *_res = NULL;
3227 CFStringRef _rv;
Jack Jansen2168e9d2001-12-16 20:18:40 +00003228 Str255 pStr;
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003229 CFStringEncoding encoding;
Jack Jansenb3be2162001-11-30 14:16:36 +00003230#ifndef CFStringCreateWithPascalStringNoCopy
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003231 PyMac_PRECHECK(CFStringCreateWithPascalStringNoCopy);
Jack Jansenb3be2162001-11-30 14:16:36 +00003232#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003233 if (!PyArg_ParseTuple(_args, "O&l",
Jack Jansen2168e9d2001-12-16 20:18:40 +00003234 PyMac_GetStr255, pStr,
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003235 &encoding))
3236 return NULL;
3237 _rv = CFStringCreateWithPascalStringNoCopy((CFAllocatorRef)NULL,
3238 pStr,
3239 encoding,
3240 (CFAllocatorRef)NULL);
3241 _res = Py_BuildValue("O&",
3242 CFStringRefObj_New, _rv);
3243 return _res;
3244}
3245
3246static PyObject *CF_CFStringCreateWithCStringNoCopy(PyObject *_self, PyObject *_args)
3247{
3248 PyObject *_res = NULL;
3249 CFStringRef _rv;
3250 char* cStr;
3251 CFStringEncoding encoding;
Jack Jansenb3be2162001-11-30 14:16:36 +00003252#ifndef CFStringCreateWithCStringNoCopy
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003253 PyMac_PRECHECK(CFStringCreateWithCStringNoCopy);
Jack Jansenb3be2162001-11-30 14:16:36 +00003254#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003255 if (!PyArg_ParseTuple(_args, "sl",
3256 &cStr,
3257 &encoding))
3258 return NULL;
3259 _rv = CFStringCreateWithCStringNoCopy((CFAllocatorRef)NULL,
3260 cStr,
3261 encoding,
3262 (CFAllocatorRef)NULL);
3263 _res = Py_BuildValue("O&",
3264 CFStringRefObj_New, _rv);
3265 return _res;
3266}
3267
3268static PyObject *CF_CFStringCreateMutable(PyObject *_self, PyObject *_args)
3269{
3270 PyObject *_res = NULL;
3271 CFMutableStringRef _rv;
3272 CFIndex maxLength;
Jack Jansenb3be2162001-11-30 14:16:36 +00003273#ifndef CFStringCreateMutable
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003274 PyMac_PRECHECK(CFStringCreateMutable);
Jack Jansenb3be2162001-11-30 14:16:36 +00003275#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003276 if (!PyArg_ParseTuple(_args, "l",
3277 &maxLength))
3278 return NULL;
3279 _rv = CFStringCreateMutable((CFAllocatorRef)NULL,
3280 maxLength);
3281 _res = Py_BuildValue("O&",
3282 CFMutableStringRefObj_New, _rv);
3283 return _res;
3284}
3285
3286static PyObject *CF_CFStringCreateMutableCopy(PyObject *_self, PyObject *_args)
3287{
3288 PyObject *_res = NULL;
3289 CFMutableStringRef _rv;
3290 CFIndex maxLength;
3291 CFStringRef theString;
Jack Jansenb3be2162001-11-30 14:16:36 +00003292#ifndef CFStringCreateMutableCopy
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003293 PyMac_PRECHECK(CFStringCreateMutableCopy);
Jack Jansenb3be2162001-11-30 14:16:36 +00003294#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003295 if (!PyArg_ParseTuple(_args, "lO&",
3296 &maxLength,
3297 CFStringRefObj_Convert, &theString))
3298 return NULL;
3299 _rv = CFStringCreateMutableCopy((CFAllocatorRef)NULL,
3300 maxLength,
3301 theString);
3302 _res = Py_BuildValue("O&",
3303 CFMutableStringRefObj_New, _rv);
3304 return _res;
3305}
3306
3307static PyObject *CF_CFStringCreateWithBytes(PyObject *_self, PyObject *_args)
3308{
3309 PyObject *_res = NULL;
3310 CFStringRef _rv;
3311 unsigned char *bytes__in__;
3312 long bytes__len__;
3313 int bytes__in_len__;
3314 CFStringEncoding encoding;
3315 Boolean isExternalRepresentation;
Jack Jansenb3be2162001-11-30 14:16:36 +00003316#ifndef CFStringCreateWithBytes
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003317 PyMac_PRECHECK(CFStringCreateWithBytes);
Jack Jansenb3be2162001-11-30 14:16:36 +00003318#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003319 if (!PyArg_ParseTuple(_args, "s#ll",
3320 &bytes__in__, &bytes__in_len__,
3321 &encoding,
3322 &isExternalRepresentation))
3323 return NULL;
3324 bytes__len__ = bytes__in_len__;
3325 _rv = CFStringCreateWithBytes((CFAllocatorRef)NULL,
3326 bytes__in__, bytes__len__,
3327 encoding,
3328 isExternalRepresentation);
3329 _res = Py_BuildValue("O&",
3330 CFStringRefObj_New, _rv);
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003331 return _res;
3332}
3333
3334static PyObject *CF_CFStringGetSystemEncoding(PyObject *_self, PyObject *_args)
3335{
3336 PyObject *_res = NULL;
3337 CFStringEncoding _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00003338#ifndef CFStringGetSystemEncoding
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003339 PyMac_PRECHECK(CFStringGetSystemEncoding);
Jack Jansenb3be2162001-11-30 14:16:36 +00003340#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003341 if (!PyArg_ParseTuple(_args, ""))
3342 return NULL;
3343 _rv = CFStringGetSystemEncoding();
3344 _res = Py_BuildValue("l",
3345 _rv);
3346 return _res;
3347}
3348
3349static PyObject *CF_CFStringGetMaximumSizeForEncoding(PyObject *_self, PyObject *_args)
3350{
3351 PyObject *_res = NULL;
3352 CFIndex _rv;
3353 CFIndex length;
3354 CFStringEncoding encoding;
Jack Jansenb3be2162001-11-30 14:16:36 +00003355#ifndef CFStringGetMaximumSizeForEncoding
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003356 PyMac_PRECHECK(CFStringGetMaximumSizeForEncoding);
Jack Jansenb3be2162001-11-30 14:16:36 +00003357#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003358 if (!PyArg_ParseTuple(_args, "ll",
3359 &length,
3360 &encoding))
3361 return NULL;
3362 _rv = CFStringGetMaximumSizeForEncoding(length,
3363 encoding);
3364 _res = Py_BuildValue("l",
3365 _rv);
3366 return _res;
3367}
3368
3369static PyObject *CF_CFStringIsEncodingAvailable(PyObject *_self, PyObject *_args)
3370{
3371 PyObject *_res = NULL;
3372 Boolean _rv;
3373 CFStringEncoding encoding;
Jack Jansenb3be2162001-11-30 14:16:36 +00003374#ifndef CFStringIsEncodingAvailable
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003375 PyMac_PRECHECK(CFStringIsEncodingAvailable);
Jack Jansenb3be2162001-11-30 14:16:36 +00003376#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003377 if (!PyArg_ParseTuple(_args, "l",
3378 &encoding))
3379 return NULL;
3380 _rv = CFStringIsEncodingAvailable(encoding);
3381 _res = Py_BuildValue("l",
3382 _rv);
3383 return _res;
3384}
3385
3386static PyObject *CF_CFStringGetNameOfEncoding(PyObject *_self, PyObject *_args)
3387{
3388 PyObject *_res = NULL;
3389 CFStringRef _rv;
3390 CFStringEncoding encoding;
Jack Jansenb3be2162001-11-30 14:16:36 +00003391#ifndef CFStringGetNameOfEncoding
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003392 PyMac_PRECHECK(CFStringGetNameOfEncoding);
Jack Jansenb3be2162001-11-30 14:16:36 +00003393#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003394 if (!PyArg_ParseTuple(_args, "l",
3395 &encoding))
3396 return NULL;
3397 _rv = CFStringGetNameOfEncoding(encoding);
3398 _res = Py_BuildValue("O&",
3399 CFStringRefObj_New, _rv);
3400 return _res;
3401}
3402
3403static PyObject *CF_CFStringConvertEncodingToNSStringEncoding(PyObject *_self, PyObject *_args)
3404{
3405 PyObject *_res = NULL;
3406 UInt32 _rv;
3407 CFStringEncoding encoding;
Jack Jansenb3be2162001-11-30 14:16:36 +00003408#ifndef CFStringConvertEncodingToNSStringEncoding
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003409 PyMac_PRECHECK(CFStringConvertEncodingToNSStringEncoding);
Jack Jansenb3be2162001-11-30 14:16:36 +00003410#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003411 if (!PyArg_ParseTuple(_args, "l",
3412 &encoding))
3413 return NULL;
3414 _rv = CFStringConvertEncodingToNSStringEncoding(encoding);
3415 _res = Py_BuildValue("l",
3416 _rv);
3417 return _res;
3418}
3419
3420static PyObject *CF_CFStringConvertNSStringEncodingToEncoding(PyObject *_self, PyObject *_args)
3421{
3422 PyObject *_res = NULL;
3423 CFStringEncoding _rv;
3424 UInt32 encoding;
Jack Jansenb3be2162001-11-30 14:16:36 +00003425#ifndef CFStringConvertNSStringEncodingToEncoding
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003426 PyMac_PRECHECK(CFStringConvertNSStringEncodingToEncoding);
Jack Jansenb3be2162001-11-30 14:16:36 +00003427#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003428 if (!PyArg_ParseTuple(_args, "l",
3429 &encoding))
3430 return NULL;
3431 _rv = CFStringConvertNSStringEncodingToEncoding(encoding);
3432 _res = Py_BuildValue("l",
3433 _rv);
3434 return _res;
3435}
3436
3437static PyObject *CF_CFStringConvertEncodingToWindowsCodepage(PyObject *_self, PyObject *_args)
3438{
3439 PyObject *_res = NULL;
3440 UInt32 _rv;
3441 CFStringEncoding encoding;
Jack Jansenb3be2162001-11-30 14:16:36 +00003442#ifndef CFStringConvertEncodingToWindowsCodepage
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003443 PyMac_PRECHECK(CFStringConvertEncodingToWindowsCodepage);
Jack Jansenb3be2162001-11-30 14:16:36 +00003444#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003445 if (!PyArg_ParseTuple(_args, "l",
3446 &encoding))
3447 return NULL;
3448 _rv = CFStringConvertEncodingToWindowsCodepage(encoding);
3449 _res = Py_BuildValue("l",
3450 _rv);
3451 return _res;
3452}
3453
3454static PyObject *CF_CFStringConvertWindowsCodepageToEncoding(PyObject *_self, PyObject *_args)
3455{
3456 PyObject *_res = NULL;
3457 CFStringEncoding _rv;
3458 UInt32 codepage;
Jack Jansenb3be2162001-11-30 14:16:36 +00003459#ifndef CFStringConvertWindowsCodepageToEncoding
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003460 PyMac_PRECHECK(CFStringConvertWindowsCodepageToEncoding);
Jack Jansenb3be2162001-11-30 14:16:36 +00003461#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003462 if (!PyArg_ParseTuple(_args, "l",
3463 &codepage))
3464 return NULL;
3465 _rv = CFStringConvertWindowsCodepageToEncoding(codepage);
3466 _res = Py_BuildValue("l",
3467 _rv);
3468 return _res;
3469}
3470
3471static PyObject *CF_CFStringConvertEncodingToIANACharSetName(PyObject *_self, PyObject *_args)
3472{
3473 PyObject *_res = NULL;
3474 CFStringRef _rv;
3475 CFStringEncoding encoding;
Jack Jansenb3be2162001-11-30 14:16:36 +00003476#ifndef CFStringConvertEncodingToIANACharSetName
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003477 PyMac_PRECHECK(CFStringConvertEncodingToIANACharSetName);
Jack Jansenb3be2162001-11-30 14:16:36 +00003478#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003479 if (!PyArg_ParseTuple(_args, "l",
3480 &encoding))
3481 return NULL;
3482 _rv = CFStringConvertEncodingToIANACharSetName(encoding);
3483 _res = Py_BuildValue("O&",
3484 CFStringRefObj_New, _rv);
3485 return _res;
3486}
3487
Jack Jansen2168e9d2001-12-16 20:18:40 +00003488static PyObject *CF_CFStringGetMostCompatibleMacStringEncoding(PyObject *_self, PyObject *_args)
3489{
3490 PyObject *_res = NULL;
3491 CFStringEncoding _rv;
3492 CFStringEncoding encoding;
3493#ifndef CFStringGetMostCompatibleMacStringEncoding
3494 PyMac_PRECHECK(CFStringGetMostCompatibleMacStringEncoding);
3495#endif
3496 if (!PyArg_ParseTuple(_args, "l",
3497 &encoding))
3498 return NULL;
3499 _rv = CFStringGetMostCompatibleMacStringEncoding(encoding);
3500 _res = Py_BuildValue("l",
3501 _rv);
3502 return _res;
3503}
3504
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003505static PyObject *CF___CFStringMakeConstantString(PyObject *_self, PyObject *_args)
3506{
3507 PyObject *_res = NULL;
3508 CFStringRef _rv;
3509 char* cStr;
Jack Jansenb3be2162001-11-30 14:16:36 +00003510#ifndef __CFStringMakeConstantString
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003511 PyMac_PRECHECK(__CFStringMakeConstantString);
Jack Jansenb3be2162001-11-30 14:16:36 +00003512#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003513 if (!PyArg_ParseTuple(_args, "s",
3514 &cStr))
3515 return NULL;
3516 _rv = __CFStringMakeConstantString(cStr);
3517 _res = Py_BuildValue("O&",
3518 CFStringRefObj_New, _rv);
3519 return _res;
3520}
3521
3522static PyObject *CF_CFURLGetTypeID(PyObject *_self, PyObject *_args)
3523{
3524 PyObject *_res = NULL;
3525 CFTypeID _rv;
Jack Jansenb3be2162001-11-30 14:16:36 +00003526#ifndef CFURLGetTypeID
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003527 PyMac_PRECHECK(CFURLGetTypeID);
Jack Jansenb3be2162001-11-30 14:16:36 +00003528#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003529 if (!PyArg_ParseTuple(_args, ""))
3530 return NULL;
3531 _rv = CFURLGetTypeID();
3532 _res = Py_BuildValue("l",
3533 _rv);
3534 return _res;
3535}
3536
3537static PyObject *CF_CFURLCreateWithBytes(PyObject *_self, PyObject *_args)
3538{
3539 PyObject *_res = NULL;
3540 CFURLRef _rv;
3541 unsigned char *URLBytes__in__;
3542 long URLBytes__len__;
3543 int URLBytes__in_len__;
3544 CFStringEncoding encoding;
3545 CFURLRef baseURL;
Jack Jansenb3be2162001-11-30 14:16:36 +00003546#ifndef CFURLCreateWithBytes
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003547 PyMac_PRECHECK(CFURLCreateWithBytes);
Jack Jansenb3be2162001-11-30 14:16:36 +00003548#endif
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003549 if (!PyArg_ParseTuple(_args, "s#lO&",
3550 &URLBytes__in__, &URLBytes__in_len__,
3551 &encoding,
3552 OptionalCFURLRefObj_Convert, &baseURL))
3553 return NULL;
3554 URLBytes__len__ = URLBytes__in_len__;
3555 _rv = CFURLCreateWithBytes((CFAllocatorRef)NULL,
3556 URLBytes__in__, URLBytes__len__,
3557 encoding,
3558 baseURL);
3559 _res = Py_BuildValue("O&",
3560 CFURLRefObj_New, _rv);
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003561 return _res;
3562}
3563
Jack Jansen2168e9d2001-12-16 20:18:40 +00003564static PyObject *CF_CFURLCreateFromFileSystemRepresentation(PyObject *_self, PyObject *_args)
3565{
3566 PyObject *_res = NULL;
3567 CFURLRef _rv;
3568 unsigned char *buffer__in__;
3569 long buffer__len__;
3570 int buffer__in_len__;
3571 Boolean isDirectory;
3572#ifndef CFURLCreateFromFileSystemRepresentation
3573 PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentation);
3574#endif
3575 if (!PyArg_ParseTuple(_args, "s#l",
3576 &buffer__in__, &buffer__in_len__,
3577 &isDirectory))
3578 return NULL;
3579 buffer__len__ = buffer__in_len__;
3580 _rv = CFURLCreateFromFileSystemRepresentation((CFAllocatorRef)NULL,
3581 buffer__in__, buffer__len__,
3582 isDirectory);
3583 _res = Py_BuildValue("O&",
3584 CFURLRefObj_New, _rv);
3585 return _res;
3586}
3587
3588static PyObject *CF_CFURLCreateFromFileSystemRepresentationRelativeToBase(PyObject *_self, PyObject *_args)
3589{
3590 PyObject *_res = NULL;
3591 CFURLRef _rv;
3592 unsigned char *buffer__in__;
3593 long buffer__len__;
3594 int buffer__in_len__;
3595 Boolean isDirectory;
3596 CFURLRef baseURL;
3597#ifndef CFURLCreateFromFileSystemRepresentationRelativeToBase
3598 PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentationRelativeToBase);
3599#endif
3600 if (!PyArg_ParseTuple(_args, "s#lO&",
3601 &buffer__in__, &buffer__in_len__,
3602 &isDirectory,
3603 OptionalCFURLRefObj_Convert, &baseURL))
3604 return NULL;
3605 buffer__len__ = buffer__in_len__;
3606 _rv = CFURLCreateFromFileSystemRepresentationRelativeToBase((CFAllocatorRef)NULL,
3607 buffer__in__, buffer__len__,
3608 isDirectory,
3609 baseURL);
3610 _res = Py_BuildValue("O&",
3611 CFURLRefObj_New, _rv);
3612 return _res;
3613}
3614
3615static PyObject *CF_CFURLCreateFromFSRef(PyObject *_self, PyObject *_args)
3616{
3617 PyObject *_res = NULL;
3618 CFURLRef _rv;
3619 FSRef fsRef;
3620#ifndef CFURLCreateFromFSRef
3621 PyMac_PRECHECK(CFURLCreateFromFSRef);
3622#endif
3623 if (!PyArg_ParseTuple(_args, "O&",
3624 PyMac_GetFSRef, &fsRef))
3625 return NULL;
3626 _rv = CFURLCreateFromFSRef((CFAllocatorRef)NULL,
3627 &fsRef);
3628 _res = Py_BuildValue("O&",
3629 CFURLRefObj_New, _rv);
3630 return _res;
3631}
3632
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003633static PyMethodDef CF_methods[] = {
Jack Jansen2168e9d2001-12-16 20:18:40 +00003634 {"__CFRangeMake", (PyCFunction)CF___CFRangeMake, 1,
3635 "(CFIndex loc, CFIndex len) -> (CFRange _rv)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003636 {"CFAllocatorGetTypeID", (PyCFunction)CF_CFAllocatorGetTypeID, 1,
3637 "() -> (CFTypeID _rv)"},
3638 {"CFAllocatorGetPreferredSizeForSize", (PyCFunction)CF_CFAllocatorGetPreferredSizeForSize, 1,
3639 "(CFIndex size, CFOptionFlags hint) -> (CFIndex _rv)"},
3640 {"CFCopyTypeIDDescription", (PyCFunction)CF_CFCopyTypeIDDescription, 1,
Jack Jansen2168e9d2001-12-16 20:18:40 +00003641 "(CFTypeID type_id) -> (CFStringRef _rv)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003642 {"CFArrayGetTypeID", (PyCFunction)CF_CFArrayGetTypeID, 1,
3643 "() -> (CFTypeID _rv)"},
3644 {"CFArrayCreateMutable", (PyCFunction)CF_CFArrayCreateMutable, 1,
3645 "(CFIndex capacity) -> (CFMutableArrayRef _rv)"},
3646 {"CFArrayCreateMutableCopy", (PyCFunction)CF_CFArrayCreateMutableCopy, 1,
Jack Jansen2168e9d2001-12-16 20:18:40 +00003647 "(CFIndex capacity, CFArrayRef theArray) -> (CFMutableArrayRef _rv)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003648 {"CFDataGetTypeID", (PyCFunction)CF_CFDataGetTypeID, 1,
3649 "() -> (CFTypeID _rv)"},
3650 {"CFDataCreate", (PyCFunction)CF_CFDataCreate, 1,
3651 "(Buffer bytes) -> (CFDataRef _rv)"},
3652 {"CFDataCreateWithBytesNoCopy", (PyCFunction)CF_CFDataCreateWithBytesNoCopy, 1,
3653 "(Buffer bytes) -> (CFDataRef _rv)"},
3654 {"CFDataCreateMutable", (PyCFunction)CF_CFDataCreateMutable, 1,
3655 "(CFIndex capacity) -> (CFMutableDataRef _rv)"},
3656 {"CFDataCreateMutableCopy", (PyCFunction)CF_CFDataCreateMutableCopy, 1,
Jack Jansen2168e9d2001-12-16 20:18:40 +00003657 "(CFIndex capacity, CFDataRef theData) -> (CFMutableDataRef _rv)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003658 {"CFDictionaryGetTypeID", (PyCFunction)CF_CFDictionaryGetTypeID, 1,
3659 "() -> (CFTypeID _rv)"},
3660 {"CFDictionaryCreateMutable", (PyCFunction)CF_CFDictionaryCreateMutable, 1,
3661 "(CFIndex capacity) -> (CFMutableDictionaryRef _rv)"},
3662 {"CFDictionaryCreateMutableCopy", (PyCFunction)CF_CFDictionaryCreateMutableCopy, 1,
Jack Jansen2168e9d2001-12-16 20:18:40 +00003663 "(CFIndex capacity, CFDictionaryRef theDict) -> (CFMutableDictionaryRef _rv)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003664 {"CFStringGetTypeID", (PyCFunction)CF_CFStringGetTypeID, 1,
3665 "() -> (CFTypeID _rv)"},
3666 {"CFStringCreateWithPascalString", (PyCFunction)CF_CFStringCreateWithPascalString, 1,
Jack Jansen2168e9d2001-12-16 20:18:40 +00003667 "(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003668 {"CFStringCreateWithCString", (PyCFunction)CF_CFStringCreateWithCString, 1,
3669 "(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
3670 {"CFStringCreateWithPascalStringNoCopy", (PyCFunction)CF_CFStringCreateWithPascalStringNoCopy, 1,
Jack Jansen2168e9d2001-12-16 20:18:40 +00003671 "(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003672 {"CFStringCreateWithCStringNoCopy", (PyCFunction)CF_CFStringCreateWithCStringNoCopy, 1,
3673 "(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
3674 {"CFStringCreateMutable", (PyCFunction)CF_CFStringCreateMutable, 1,
3675 "(CFIndex maxLength) -> (CFMutableStringRef _rv)"},
3676 {"CFStringCreateMutableCopy", (PyCFunction)CF_CFStringCreateMutableCopy, 1,
3677 "(CFIndex maxLength, CFStringRef theString) -> (CFMutableStringRef _rv)"},
3678 {"CFStringCreateWithBytes", (PyCFunction)CF_CFStringCreateWithBytes, 1,
3679 "(Buffer bytes, CFStringEncoding encoding, Boolean isExternalRepresentation) -> (CFStringRef _rv)"},
3680 {"CFStringGetSystemEncoding", (PyCFunction)CF_CFStringGetSystemEncoding, 1,
3681 "() -> (CFStringEncoding _rv)"},
3682 {"CFStringGetMaximumSizeForEncoding", (PyCFunction)CF_CFStringGetMaximumSizeForEncoding, 1,
3683 "(CFIndex length, CFStringEncoding encoding) -> (CFIndex _rv)"},
3684 {"CFStringIsEncodingAvailable", (PyCFunction)CF_CFStringIsEncodingAvailable, 1,
3685 "(CFStringEncoding encoding) -> (Boolean _rv)"},
3686 {"CFStringGetNameOfEncoding", (PyCFunction)CF_CFStringGetNameOfEncoding, 1,
3687 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
3688 {"CFStringConvertEncodingToNSStringEncoding", (PyCFunction)CF_CFStringConvertEncodingToNSStringEncoding, 1,
3689 "(CFStringEncoding encoding) -> (UInt32 _rv)"},
3690 {"CFStringConvertNSStringEncodingToEncoding", (PyCFunction)CF_CFStringConvertNSStringEncodingToEncoding, 1,
3691 "(UInt32 encoding) -> (CFStringEncoding _rv)"},
3692 {"CFStringConvertEncodingToWindowsCodepage", (PyCFunction)CF_CFStringConvertEncodingToWindowsCodepage, 1,
3693 "(CFStringEncoding encoding) -> (UInt32 _rv)"},
3694 {"CFStringConvertWindowsCodepageToEncoding", (PyCFunction)CF_CFStringConvertWindowsCodepageToEncoding, 1,
3695 "(UInt32 codepage) -> (CFStringEncoding _rv)"},
3696 {"CFStringConvertEncodingToIANACharSetName", (PyCFunction)CF_CFStringConvertEncodingToIANACharSetName, 1,
3697 "(CFStringEncoding encoding) -> (CFStringRef _rv)"},
Jack Jansen2168e9d2001-12-16 20:18:40 +00003698 {"CFStringGetMostCompatibleMacStringEncoding", (PyCFunction)CF_CFStringGetMostCompatibleMacStringEncoding, 1,
3699 "(CFStringEncoding encoding) -> (CFStringEncoding _rv)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003700 {"__CFStringMakeConstantString", (PyCFunction)CF___CFStringMakeConstantString, 1,
3701 "(char* cStr) -> (CFStringRef _rv)"},
3702 {"CFURLGetTypeID", (PyCFunction)CF_CFURLGetTypeID, 1,
3703 "() -> (CFTypeID _rv)"},
3704 {"CFURLCreateWithBytes", (PyCFunction)CF_CFURLCreateWithBytes, 1,
3705 "(Buffer URLBytes, CFStringEncoding encoding, CFURLRef baseURL) -> (CFURLRef _rv)"},
Jack Jansen2168e9d2001-12-16 20:18:40 +00003706 {"CFURLCreateFromFileSystemRepresentation", (PyCFunction)CF_CFURLCreateFromFileSystemRepresentation, 1,
3707 "(Buffer buffer, Boolean isDirectory) -> (CFURLRef _rv)"},
3708 {"CFURLCreateFromFileSystemRepresentationRelativeToBase", (PyCFunction)CF_CFURLCreateFromFileSystemRepresentationRelativeToBase, 1,
3709 "(Buffer buffer, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)"},
3710 {"CFURLCreateFromFSRef", (PyCFunction)CF_CFURLCreateFromFSRef, 1,
3711 "(FSRef fsRef) -> (CFURLRef _rv)"},
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003712 {NULL, NULL, 0}
3713};
3714
3715
3716
3717
3718void init_CF(void)
3719{
3720 PyObject *m;
3721 PyObject *d;
3722
3723
3724
Jack Jansen537a69f2001-11-05 14:39:22 +00003725 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFTypeRef, CFTypeRefObj_New);
3726 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFTypeRef, CFTypeRefObj_Convert);
3727 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFStringRef, CFStringRefObj_New);
3728 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFStringRef, CFStringRefObj_Convert);
3729 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableStringRef, CFMutableStringRefObj_New);
3730 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableStringRef, CFMutableStringRefObj_Convert);
3731
3732 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFArrayRef, CFArrayRefObj_New);
3733 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFArrayRef, CFArrayRefObj_Convert);
3734 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableArrayRef, CFMutableArrayRefObj_New);
3735 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableArrayRef, CFMutableArrayRefObj_Convert);
3736 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFDictionaryRef, CFDictionaryRefObj_New);
3737 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFDictionaryRef, CFDictionaryRefObj_Convert);
3738 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableDictionaryRef, CFMutableDictionaryRefObj_New);
3739 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableDictionaryRef, CFMutableDictionaryRefObj_Convert);
3740 PyMac_INIT_TOOLBOX_OBJECT_NEW(CFURLRef, CFURLRefObj_New);
3741 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef, CFURLRefObj_Convert);
3742 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef, CFURLRefObj_Convert);
Jack Jansen50ecb0a2001-08-23 14:02:09 +00003743
3744
3745 m = Py_InitModule("_CF", CF_methods);
3746 d = PyModule_GetDict(m);
3747 CF_Error = PyMac_GetOSErrException();
3748 if (CF_Error == NULL ||
3749 PyDict_SetItemString(d, "Error", CF_Error) != 0)
3750 return;
3751 CFTypeRef_Type.ob_type = &PyType_Type;
3752 Py_INCREF(&CFTypeRef_Type);
3753 if (PyDict_SetItemString(d, "CFTypeRefType", (PyObject *)&CFTypeRef_Type) != 0)
3754 Py_FatalError("can't initialize CFTypeRefType");
3755 CFArrayRef_Type.ob_type = &PyType_Type;
3756 Py_INCREF(&CFArrayRef_Type);
3757 if (PyDict_SetItemString(d, "CFArrayRefType", (PyObject *)&CFArrayRef_Type) != 0)
3758 Py_FatalError("can't initialize CFArrayRefType");
3759 CFMutableArrayRef_Type.ob_type = &PyType_Type;
3760 Py_INCREF(&CFMutableArrayRef_Type);
3761 if (PyDict_SetItemString(d, "CFMutableArrayRefType", (PyObject *)&CFMutableArrayRef_Type) != 0)
3762 Py_FatalError("can't initialize CFMutableArrayRefType");
3763 CFDictionaryRef_Type.ob_type = &PyType_Type;
3764 Py_INCREF(&CFDictionaryRef_Type);
3765 if (PyDict_SetItemString(d, "CFDictionaryRefType", (PyObject *)&CFDictionaryRef_Type) != 0)
3766 Py_FatalError("can't initialize CFDictionaryRefType");
3767 CFMutableDictionaryRef_Type.ob_type = &PyType_Type;
3768 Py_INCREF(&CFMutableDictionaryRef_Type);
3769 if (PyDict_SetItemString(d, "CFMutableDictionaryRefType", (PyObject *)&CFMutableDictionaryRef_Type) != 0)
3770 Py_FatalError("can't initialize CFMutableDictionaryRefType");
3771 CFDataRef_Type.ob_type = &PyType_Type;
3772 Py_INCREF(&CFDataRef_Type);
3773 if (PyDict_SetItemString(d, "CFDataRefType", (PyObject *)&CFDataRef_Type) != 0)
3774 Py_FatalError("can't initialize CFDataRefType");
3775 CFMutableDataRef_Type.ob_type = &PyType_Type;
3776 Py_INCREF(&CFMutableDataRef_Type);
3777 if (PyDict_SetItemString(d, "CFMutableDataRefType", (PyObject *)&CFMutableDataRef_Type) != 0)
3778 Py_FatalError("can't initialize CFMutableDataRefType");
3779 CFStringRef_Type.ob_type = &PyType_Type;
3780 Py_INCREF(&CFStringRef_Type);
3781 if (PyDict_SetItemString(d, "CFStringRefType", (PyObject *)&CFStringRef_Type) != 0)
3782 Py_FatalError("can't initialize CFStringRefType");
3783 CFMutableStringRef_Type.ob_type = &PyType_Type;
3784 Py_INCREF(&CFMutableStringRef_Type);
3785 if (PyDict_SetItemString(d, "CFMutableStringRefType", (PyObject *)&CFMutableStringRef_Type) != 0)
3786 Py_FatalError("can't initialize CFMutableStringRefType");
3787 CFURLRef_Type.ob_type = &PyType_Type;
3788 Py_INCREF(&CFURLRef_Type);
3789 if (PyDict_SetItemString(d, "CFURLRefType", (PyObject *)&CFURLRef_Type) != 0)
3790 Py_FatalError("can't initialize CFURLRefType");
3791}
3792
3793/* ========================= End module _CF ========================= */
3794