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