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