| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#include "Python.h" |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include "pymactoolbox.h" |
| 9 |
|
| 10 |
|
| 11 |
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ |
| 12 |
PyErr_SetString(PyExc_NotImplementedError, \ |
| 13 |
"Not available in this shared library/OS version"); \ |
| 14 |
return NULL; \ |
| 15 |
}} while(0) |
| 16 |
|
| 17 |
|
| 18 |
#include <CoreServices/CoreServices.h> |
| 19 |
|
| 20 |
#include "pycfbridge.h" |
| 21 |
|
| 22 |
#ifdef USE_TOOLBOX_OBJECT_GLUE |
| 23 |
extern PyObject *_CFObj_New(CFTypeRef); |
| 24 |
extern int _CFObj_Convert(PyObject *, CFTypeRef *); |
| 25 |
#define CFObj_New _CFObj_New |
| 26 |
#define CFObj_Convert _CFObj_Convert |
| 27 |
|
| 28 |
extern PyObject *_CFTypeRefObj_New(CFTypeRef); |
| 29 |
extern int _CFTypeRefObj_Convert(PyObject *, CFTypeRef *); |
| 30 |
#define CFTypeRefObj_New _CFTypeRefObj_New |
| 31 |
#define CFTypeRefObj_Convert _CFTypeRefObj_Convert |
| 32 |
|
| 33 |
extern PyObject *_CFStringRefObj_New(CFStringRef); |
| 34 |
extern int _CFStringRefObj_Convert(PyObject *, CFStringRef *); |
| 35 |
#define CFStringRefObj_New _CFStringRefObj_New |
| 36 |
#define CFStringRefObj_Convert _CFStringRefObj_Convert |
| 37 |
|
| 38 |
extern PyObject *_CFMutableStringRefObj_New(CFMutableStringRef); |
| 39 |
extern int _CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *); |
| 40 |
#define CFMutableStringRefObj_New _CFMutableStringRefObj_New |
| 41 |
#define CFMutableStringRefObj_Convert _CFMutableStringRefObj_Convert |
| 42 |
|
| 43 |
extern PyObject *_CFArrayRefObj_New(CFArrayRef); |
| 44 |
extern int _CFArrayRefObj_Convert(PyObject *, CFArrayRef *); |
| 45 |
#define CFArrayRefObj_New _CFArrayRefObj_New |
| 46 |
#define CFArrayRefObj_Convert _CFArrayRefObj_Convert |
| 47 |
|
| 48 |
extern PyObject *_CFMutableArrayRefObj_New(CFMutableArrayRef); |
| 49 |
extern int _CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *); |
| 50 |
#define CFMutableArrayRefObj_New _CFMutableArrayRefObj_New |
| 51 |
#define CFMutableArrayRefObj_Convert _CFMutableArrayRefObj_Convert |
| 52 |
|
| 53 |
extern PyObject *_CFDataRefObj_New(CFDataRef); |
| 54 |
extern int _CFDataRefObj_Convert(PyObject *, CFDataRef *); |
| 55 |
#define CFDataRefObj_New _CFDataRefObj_New |
| 56 |
#define CFDataRefObj_Convert _CFDataRefObj_Convert |
| 57 |
|
| 58 |
extern PyObject *_CFMutableDataRefObj_New(CFMutableDataRef); |
| 59 |
extern int _CFMutableDataRefObj_Convert(PyObject *, CFMutableDataRef *); |
| 60 |
#define CFMutableDataRefObj_New _CFMutableDataRefObj_New |
| 61 |
#define CFMutableDataRefObj_Convert _CFMutableDataRefObj_Convert |
| 62 |
|
| 63 |
extern PyObject *_CFDictionaryRefObj_New(CFDictionaryRef); |
| 64 |
extern int _CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *); |
| 65 |
#define CFDictionaryRefObj_New _CFDictionaryRefObj_New |
| 66 |
#define CFDictionaryRefObj_Convert _CFDictionaryRefObj_Convert |
| 67 |
|
| 68 |
extern PyObject *_CFMutableDictionaryRefObj_New(CFMutableDictionaryRef); |
| 69 |
extern int _CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *); |
| 70 |
#define CFMutableDictionaryRefObj_New _CFMutableDictionaryRefObj_New |
| 71 |
#define CFMutableDictionaryRefObj_Convert _CFMutableDictionaryRefObj_Convert |
| 72 |
|
| 73 |
extern PyObject *_CFURLRefObj_New(CFURLRef); |
| 74 |
extern int _CFURLRefObj_Convert(PyObject *, CFURLRef *); |
| 75 |
extern int _OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *); |
| 76 |
#define CFURLRefObj_New _CFURLRefObj_New |
| 77 |
#define CFURLRefObj_Convert _CFURLRefObj_Convert |
| 78 |
#define OptionalCFURLRefObj_Convert _OptionalCFURLRefObj_Convert |
| 79 |
#endif |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
PyObject *CFRange_New(CFRange *itself) |
| 85 |
{ |
| 86 |
return Py_BuildValue("ll", (long)itself->location, (long)itself->length); |
| 87 |
} |
| 88 |
|
| 89 |
int |
| 90 |
CFRange_Convert(PyObject *v, CFRange *p_itself) |
| 91 |
{ |
| 92 |
long location, length; |
| 93 |
|
| 94 |
if( !PyArg_ParseTuple(v, "ll", &location, &length) ) |
| 95 |
return 0; |
| 96 |
p_itself->location = (CFIndex)location; |
| 97 |
p_itself->length = (CFIndex)length; |
| 98 |
return 1; |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
int |
| 103 |
OptionalCFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself) |
| 104 |
{ |
| 105 |
if ( v == Py_None ) { |
| 106 |
p_itself = NULL; |
| 107 |
return 1; |
| 108 |
} |
| 109 |
return CFURLRefObj_Convert(v, p_itself); |
| 110 |
} |
| 111 |
|
| 112 |
static PyObject *CF_Error; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
PyTypeObject CFTypeRef_Type; |
| 117 |
|
| 118 |
#define CFTypeRefObj_Check(x) ((x)->ob_type == &CFTypeRef_Type || PyObject_TypeCheck((x), &CFTypeRef_Type)) |
| 119 |
|
| 120 |
typedef struct CFTypeRefObject { |
| 121 |
PyObject_HEAD |
| 122 |
CFTypeRef ob_itself; |
| 123 |
void (*ob_freeit)(CFTypeRef ptr); |
| 124 |
} CFTypeRefObject; |
| 125 |
|
| 126 |
PyObject *CFTypeRefObj_New(CFTypeRef itself) |
| 127 |
{ |
| 128 |
CFTypeRefObject *it; |
| 129 |
if (itself == NULL) |
| 130 |
{ |
| 131 |
PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); |
| 132 |
return NULL; |
| 133 |
} |
| 134 |
it = PyObject_NEW(CFTypeRefObject, &CFTypeRef_Type); |
| 135 |
if (it == NULL) return NULL; |
| 136 |
it->ob_itself = itself; |
| 137 |
it->ob_freeit = CFRelease; |
| 138 |
return (PyObject *)it; |
| 139 |
} |
| 140 |
|
| 141 |
int CFTypeRefObj_Convert(PyObject *v, CFTypeRef *p_itself) |
| 142 |
{ |
| 143 |
|
| 144 |
if (v == Py_None) { *p_itself = NULL; return 1; } |
| 145 |
|
| 146 |
|
| 147 |
if (!CFTypeRefObj_Check(v)) |
| 148 |
{ |
| 149 |
PyErr_SetString(PyExc_TypeError, "CFTypeRef required"); |
| 150 |
return 0; |
| 151 |
} |
| 152 |
*p_itself = ((CFTypeRefObject *)v)->ob_itself; |
| 153 |
return 1; |
| 154 |
} |
| 155 |
|
| 156 |
static void CFTypeRefObj_dealloc(CFTypeRefObject *self) |
| 157 |
{ |
| 158 |
if (self->ob_freeit && self->ob_itself) |
| 159 |
{ |
| 160 |
self->ob_freeit((CFTypeRef)self->ob_itself); |
| 161 |
self->ob_itself = NULL; |
| 162 |
} |
| 163 |
self->ob_type->tp_free((PyObject *)self); |
| 164 |
} |
| 165 |
|
| 166 |
static PyObject *CFTypeRefObj_CFGetTypeID(CFTypeRefObject *_self, PyObject *_args) |
| 167 |
{ |
| 168 |
PyObject *_res = NULL; |
| 169 |
CFTypeID _rv; |
| 170 |
#ifndef CFGetTypeID |
| 171 |
PyMac_PRECHECK(CFGetTypeID); |
| 172 |
#endif |
| 173 |
if (!PyArg_ParseTuple(_args, "")) |
| 174 |
return NULL; |
| 175 |
_rv = CFGetTypeID(_self->ob_itself); |
| 176 |
_res = Py_BuildValue("l", |
| 177 |
_rv); |
| 178 |
return _res; |
| 179 |
} |
| 180 |
|
| 181 |
static PyObject *CFTypeRefObj_CFRetain(CFTypeRefObject *_self, PyObject *_args) |
| 182 |
{ |
| 183 |
PyObject *_res = NULL; |
| 184 |
CFTypeRef _rv; |
| 185 |
#ifndef CFRetain |
| 186 |
PyMac_PRECHECK(CFRetain); |
| 187 |
#endif |
| 188 |
if (!PyArg_ParseTuple(_args, "")) |
| 189 |
return NULL; |
| 190 |
_rv = CFRetain(_self->ob_itself); |
| 191 |
_res = Py_BuildValue("O&", |
| 192 |
CFTypeRefObj_New, _rv); |
| 193 |
return _res; |
| 194 |
} |
| 195 |
|
| 196 |
static PyObject *CFTypeRefObj_CFRelease(CFTypeRefObject *_self, PyObject *_args) |
| 197 |
{ |
| 198 |
PyObject *_res = NULL; |
| 199 |
#ifndef CFRelease |
| 200 |
PyMac_PRECHECK(CFRelease); |
| 201 |
#endif |
| 202 |
if (!PyArg_ParseTuple(_args, "")) |
| 203 |
return NULL; |
| 204 |
CFRelease(_self->ob_itself); |
| 205 |
Py_INCREF(Py_None); |
| 206 |
_res = Py_None; |
| 207 |
return _res; |
| 208 |
} |
| 209 |
|
| 210 |
static PyObject *CFTypeRefObj_CFGetRetainCount(CFTypeRefObject *_self, PyObject *_args) |
| 211 |
{ |
| 212 |
PyObject *_res = NULL; |
| 213 |
CFIndex _rv; |
| 214 |
#ifndef CFGetRetainCount |
| 215 |
PyMac_PRECHECK(CFGetRetainCount); |
| 216 |
#endif |
| 217 |
if (!PyArg_ParseTuple(_args, "")) |
| 218 |
return NULL; |
| 219 |
_rv = CFGetRetainCount(_self->ob_itself); |
| 220 |
_res = Py_BuildValue("l", |
| 221 |
_rv); |
| 222 |
return _res; |
| 223 |
} |
| 224 |
|
| 225 |
static PyObject *CFTypeRefObj_CFEqual(CFTypeRefObject *_self, PyObject *_args) |
| 226 |
{ |
| 227 |
PyObject *_res = NULL; |
| 228 |
Boolean _rv; |
| 229 |
CFTypeRef cf2; |
| 230 |
#ifndef CFEqual |
| 231 |
PyMac_PRECHECK(CFEqual); |
| 232 |
#endif |
| 233 |
if (!PyArg_ParseTuple(_args, "O&", |
| 234 |
CFTypeRefObj_Convert, &cf2)) |
| 235 |
return NULL; |
| 236 |
_rv = CFEqual(_self->ob_itself, |
| 237 |
cf2); |
| 238 |
_res = Py_BuildValue("l", |
| 239 |
_rv); |
| 240 |
return _res; |
| 241 |
} |
| 242 |
|
| 243 |
static PyObject *CFTypeRefObj_CFHash(CFTypeRefObject *_self, PyObject *_args) |
| 244 |
{ |
| 245 |
PyObject *_res = NULL; |
| 246 |
CFHashCode _rv; |
| 247 |
#ifndef CFHash |
| 248 |
PyMac_PRECHECK(CFHash); |
| 249 |
#endif |
| 250 |
if (!PyArg_ParseTuple(_args, "")) |
| 251 |
return NULL; |
| 252 |
_rv = CFHash(_self->ob_itself); |
| 253 |
_res = Py_BuildValue("l", |
| 254 |
_rv); |
| 255 |
return _res; |
| 256 |
} |
| 257 |
|
| 258 |
static PyObject *CFTypeRefObj_CFCopyDescription(CFTypeRefObject *_self, PyObject *_args) |
| 259 |
{ |
| 260 |
PyObject *_res = NULL; |
| 261 |
CFStringRef _rv; |
| 262 |
#ifndef CFCopyDescription |
| 263 |
PyMac_PRECHECK(CFCopyDescription); |
| 264 |
#endif |
| 265 |
if (!PyArg_ParseTuple(_args, "")) |
| 266 |
return NULL; |
| 267 |
_rv = CFCopyDescription(_self->ob_itself); |
| 268 |
_res = Py_BuildValue("O&", |
| 269 |
CFStringRefObj_New, _rv); |
| 270 |
return _res; |
| 271 |
} |
| 272 |
|
| 273 |
static PyObject *CFTypeRefObj_CFPropertyListCreateXMLData(CFTypeRefObject *_self, PyObject *_args) |
| 274 |
{ |
| 275 |
PyObject *_res = NULL; |
| 276 |
CFDataRef _rv; |
| 277 |
if (!PyArg_ParseTuple(_args, "")) |
| 278 |
return NULL; |
| 279 |
_rv = CFPropertyListCreateXMLData((CFAllocatorRef)NULL, |
| 280 |
_self->ob_itself); |
| 281 |
_res = Py_BuildValue("O&", |
| 282 |
CFDataRefObj_New, _rv); |
| 283 |
return _res; |
| 284 |
} |
| 285 |
|
| 286 |
static PyObject *CFTypeRefObj_CFPropertyListCreateDeepCopy(CFTypeRefObject *_self, PyObject *_args) |
| 287 |
{ |
| 288 |
PyObject *_res = NULL; |
| 289 |
CFTypeRef _rv; |
| 290 |
CFOptionFlags mutabilityOption; |
| 291 |
if (!PyArg_ParseTuple(_args, "l", |
| 292 |
&mutabilityOption)) |
| 293 |
return NULL; |
| 294 |
_rv = CFPropertyListCreateDeepCopy((CFAllocatorRef)NULL, |
| 295 |
_self->ob_itself, |
| 296 |
mutabilityOption); |
| 297 |
_res = Py_BuildValue("O&", |
| 298 |
CFTypeRefObj_New, _rv); |
| 299 |
return _res; |
| 300 |
} |
| 301 |
|
| 302 |
static PyObject *CFTypeRefObj_CFShow(CFTypeRefObject *_self, PyObject *_args) |
| 303 |
{ |
| 304 |
PyObject *_res = NULL; |
| 305 |
#ifndef CFShow |
| 306 |
PyMac_PRECHECK(CFShow); |
| 307 |
#endif |
| 308 |
if (!PyArg_ParseTuple(_args, "")) |
| 309 |
return NULL; |
| 310 |
CFShow(_self->ob_itself); |
| 311 |
Py_INCREF(Py_None); |
| 312 |
_res = Py_None; |
| 313 |
return _res; |
| 314 |
} |
| 315 |
|
| 316 |
static PyObject *CFTypeRefObj_CFPropertyListCreateFromXMLData(CFTypeRefObject *_self, PyObject *_args) |
| 317 |
{ |
| 318 |
PyObject *_res = NULL; |
| 319 |
|
| 320 |
CFTypeRef _rv; |
| 321 |
CFOptionFlags mutabilityOption; |
| 322 |
CFStringRef errorString; |
| 323 |
if (!PyArg_ParseTuple(_args, "l", |
| 324 |
&mutabilityOption)) |
| 325 |
return NULL; |
| 326 |
_rv = CFPropertyListCreateFromXMLData((CFAllocatorRef)NULL, |
| 327 |
_self->ob_itself, |
| 328 |
mutabilityOption, |
| 329 |
&errorString); |
| 330 |
if (errorString) |
| 331 |
CFRelease(errorString); |
| 332 |
if (_rv == NULL) { |
| 333 |
PyErr_SetString(PyExc_RuntimeError, "Parse error in XML data"); |
| 334 |
return NULL; |
| 335 |
} |
| 336 |
_res = Py_BuildValue("O&", |
| 337 |
CFTypeRefObj_New, _rv); |
| 338 |
return _res; |
| 339 |
|
| 340 |
} |
| 341 |
|
| 342 |
static PyObject *CFTypeRefObj_toPython(CFTypeRefObject *_self, PyObject *_args) |
| 343 |
{ |
| 344 |
PyObject *_res = NULL; |
| 345 |
|
| 346 |
_res = PyCF_CF2Python(_self->ob_itself); |
| 347 |
return _res; |
| 348 |
|
| 349 |
} |
| 350 |
|
| 351 |
static PyMethodDef CFTypeRefObj_methods[] = { |
| 352 |
{"CFGetTypeID", (PyCFunction)CFTypeRefObj_CFGetTypeID, 1, |
| 353 |
PyDoc_STR("() -> (CFTypeID _rv)")}, |
| 354 |
{"CFRetain", (PyCFunction)CFTypeRefObj_CFRetain, 1, |
| 355 |
PyDoc_STR("() -> (CFTypeRef _rv)")}, |
| 356 |
{"CFRelease", (PyCFunction)CFTypeRefObj_CFRelease, 1, |
| 357 |
PyDoc_STR("() -> None")}, |
| 358 |
{"CFGetRetainCount", (PyCFunction)CFTypeRefObj_CFGetRetainCount, 1, |
| 359 |
PyDoc_STR("() -> (CFIndex _rv)")}, |
| 360 |
{"CFEqual", (PyCFunction)CFTypeRefObj_CFEqual, 1, |
| 361 |
PyDoc_STR("(CFTypeRef cf2) -> (Boolean _rv)")}, |
| 362 |
{"CFHash", (PyCFunction)CFTypeRefObj_CFHash, 1, |
| 363 |
PyDoc_STR("() -> (CFHashCode _rv)")}, |
| 364 |
{"CFCopyDescription", (PyCFunction)CFTypeRefObj_CFCopyDescription, 1, |
| 365 |
PyDoc_STR("() -> (CFStringRef _rv)")}, |
| 366 |
{"CFPropertyListCreateXMLData", (PyCFunction)CFTypeRefObj_CFPropertyListCreateXMLData, 1, |
| 367 |
PyDoc_STR("() -> (CFDataRef _rv)")}, |
| 368 |
{"CFPropertyListCreateDeepCopy", (PyCFunction)CFTypeRefObj_CFPropertyListCreateDeepCopy, 1, |
| 369 |
PyDoc_STR("(CFOptionFlags mutabilityOption) -> (CFTypeRef _rv)")}, |
| 370 |
{"CFShow", (PyCFunction)CFTypeRefObj_CFShow, 1, |
| 371 |
PyDoc_STR("() -> None")}, |
| 372 |
{"CFPropertyListCreateFromXMLData", (PyCFunction)CFTypeRefObj_CFPropertyListCreateFromXMLData, 1, |
| 373 |
PyDoc_STR("(CFOptionFlags mutabilityOption) -> (CFTypeRefObj)")}, |
| 374 |
{"toPython", (PyCFunction)CFTypeRefObj_toPython, 1, |
| 375 |
PyDoc_STR("() -> (python_object)")}, |
| 376 |
{NULL, NULL, 0} |
| 377 |
}; |
| 378 |
|
| 379 |
#define CFTypeRefObj_getsetlist NULL |
| 380 |
|
| 381 |
|
| 382 |
static int CFTypeRefObj_compare(CFTypeRefObject *self, CFTypeRefObject *other) |
| 383 |
{ |
| 384 |
|
| 385 |
if ( self->ob_itself > other->ob_itself ) return 1; |
| 386 |
if ( self->ob_itself < other->ob_itself ) return -1; |
| 387 |
return 0; |
| 388 |
} |
| 389 |
|
| 390 |
static PyObject * CFTypeRefObj_repr(CFTypeRefObject *self) |
| 391 |
{ |
| 392 |
char buf[100]; |
| 393 |
sprintf(buf, "<CFTypeRef type-%d object at 0x%8.8x for 0x%8.8x>", (int)CFGetTypeID(self->ob_itself), (unsigned)self, (unsigned)self->ob_itself); |
| 394 |
return PyString_FromString(buf); |
| 395 |
} |
| 396 |
|
| 397 |
static int CFTypeRefObj_hash(CFTypeRefObject *self) |
| 398 |
{ |
| 399 |
|
| 400 |
return (int)self->ob_itself; |
| 401 |
} |
| 402 |
static int CFTypeRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
| 403 |
{ |
| 404 |
CFTypeRef itself; |
| 405 |
char *kw[] = {"itself", 0}; |
| 406 |
|
| 407 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) |
| 408 |
{ |
| 409 |
((CFTypeRefObject *)_self)->ob_itself = itself; |
| 410 |
return 0; |
| 411 |
} |
| 412 |
return -1; |
| 413 |
} |
| 414 |
|
| 415 |
#define CFTypeRefObj_tp_alloc PyType_GenericAlloc |
| 416 |
|
| 417 |
static PyObject *CFTypeRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 418 |
{ |
| 419 |
PyObject *self; |
| 420 |
if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 421 |
((CFTypeRefObject *)self)->ob_itself = NULL; |
| 422 |
((CFTypeRefObject *)self)->ob_freeit = CFRelease; |
| 423 |
return self; |
| 424 |
} |
| 425 |
|
| 426 |
#define CFTypeRefObj_tp_free PyObject_Del |
| 427 |
|
| 428 |
|
| 429 |
PyTypeObject CFTypeRef_Type = { |
| 430 |
PyObject_HEAD_INIT(NULL) |
| 431 |
0, |
| 432 |
"_CF.CFTypeRef", |
| 433 |
sizeof(CFTypeRefObject), |
| 434 |
0, |
| 435 |
|
| 436 |
(destructor) CFTypeRefObj_dealloc, |
| 437 |
0, |
| 438 |
(getattrfunc)0, |
| 439 |
(setattrfunc)0, |
| 440 |
(cmpfunc) CFTypeRefObj_compare, |
| 441 |
(reprfunc) CFTypeRefObj_repr, |
| 442 |
(PyNumberMethods *)0, |
| 443 |
(PySequenceMethods *)0, |
| 444 |
(PyMappingMethods *)0, |
| 445 |
(hashfunc) CFTypeRefObj_hash, |
| 446 |
0, |
| 447 |
0, |
| 448 |
PyObject_GenericGetAttr, |
| 449 |
PyObject_GenericSetAttr, |
| 450 |
0, |
| 451 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 452 |
0, |
| 453 |
0, |
| 454 |
0, |
| 455 |
0, |
| 456 |
0, |
| 457 |
0, |
| 458 |
0, |
| 459 |
CFTypeRefObj_methods, |
| 460 |
0, |
| 461 |
CFTypeRefObj_getsetlist, |
| 462 |
0, |
| 463 |
0, |
| 464 |
0, |
| 465 |
0, |
| 466 |
0, |
| 467 |
CFTypeRefObj_tp_init, |
| 468 |
CFTypeRefObj_tp_alloc, |
| 469 |
CFTypeRefObj_tp_new, |
| 470 |
CFTypeRefObj_tp_free, |
| 471 |
}; |
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
PyTypeObject CFArrayRef_Type; |
| 479 |
|
| 480 |
#define CFArrayRefObj_Check(x) ((x)->ob_type == &CFArrayRef_Type || PyObject_TypeCheck((x), &CFArrayRef_Type)) |
| 481 |
|
| 482 |
typedef struct CFArrayRefObject { |
| 483 |
PyObject_HEAD |
| 484 |
CFArrayRef ob_itself; |
| 485 |
void (*ob_freeit)(CFTypeRef ptr); |
| 486 |
} CFArrayRefObject; |
| 487 |
|
| 488 |
PyObject *CFArrayRefObj_New(CFArrayRef itself) |
| 489 |
{ |
| 490 |
CFArrayRefObject *it; |
| 491 |
if (itself == NULL) |
| 492 |
{ |
| 493 |
PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); |
| 494 |
return NULL; |
| 495 |
} |
| 496 |
it = PyObject_NEW(CFArrayRefObject, &CFArrayRef_Type); |
| 497 |
if (it == NULL) return NULL; |
| 498 |
|
| 499 |
it->ob_itself = itself; |
| 500 |
it->ob_freeit = CFRelease; |
| 501 |
return (PyObject *)it; |
| 502 |
} |
| 503 |
|
| 504 |
int CFArrayRefObj_Convert(PyObject *v, CFArrayRef *p_itself) |
| 505 |
{ |
| 506 |
|
| 507 |
if (v == Py_None) { *p_itself = NULL; return 1; } |
| 508 |
|
| 509 |
|
| 510 |
if (!CFArrayRefObj_Check(v)) |
| 511 |
{ |
| 512 |
PyErr_SetString(PyExc_TypeError, "CFArrayRef required"); |
| 513 |
return 0; |
| 514 |
} |
| 515 |
*p_itself = ((CFArrayRefObject *)v)->ob_itself; |
| 516 |
return 1; |
| 517 |
} |
| 518 |
|
| 519 |
static void CFArrayRefObj_dealloc(CFArrayRefObject *self) |
| 520 |
{ |
| 521 |
if (self->ob_freeit && self->ob_itself) |
| 522 |
{ |
| 523 |
self->ob_freeit((CFTypeRef)self->ob_itself); |
| 524 |
self->ob_itself = NULL; |
| 525 |
} |
| 526 |
CFTypeRef_Type.tp_dealloc((PyObject *)self); |
| 527 |
} |
| 528 |
|
| 529 |
static PyObject *CFArrayRefObj_CFArrayCreateCopy(CFArrayRefObject *_self, PyObject *_args) |
| 530 |
{ |
| 531 |
PyObject *_res = NULL; |
| 532 |
CFArrayRef _rv; |
| 533 |
if (!PyArg_ParseTuple(_args, "")) |
| 534 |
return NULL; |
| 535 |
_rv = CFArrayCreateCopy((CFAllocatorRef)NULL, |
| 536 |
_self->ob_itself); |
| 537 |
_res = Py_BuildValue("O&", |
| 538 |
CFArrayRefObj_New, _rv); |
| 539 |
return _res; |
| 540 |
} |
| 541 |
|
| 542 |
static PyObject *CFArrayRefObj_CFArrayGetCount(CFArrayRefObject *_self, PyObject *_args) |
| 543 |
{ |
| 544 |
PyObject *_res = NULL; |
| 545 |
CFIndex _rv; |
| 546 |
#ifndef CFArrayGetCount |
| 547 |
PyMac_PRECHECK(CFArrayGetCount); |
| 548 |
#endif |
| 549 |
if (!PyArg_ParseTuple(_args, "")) |
| 550 |
return NULL; |
| 551 |
_rv = CFArrayGetCount(_self->ob_itself); |
| 552 |
_res = Py_BuildValue("l", |
| 553 |
_rv); |
| 554 |
return _res; |
| 555 |
} |
| 556 |
|
| 557 |
static PyObject *CFArrayRefObj_CFStringCreateByCombiningStrings(CFArrayRefObject *_self, PyObject *_args) |
| 558 |
{ |
| 559 |
PyObject *_res = NULL; |
| 560 |
CFStringRef _rv; |
| 561 |
CFStringRef separatorString; |
| 562 |
if (!PyArg_ParseTuple(_args, "O&", |
| 563 |
CFStringRefObj_Convert, &separatorString)) |
| 564 |
return NULL; |
| 565 |
_rv = CFStringCreateByCombiningStrings((CFAllocatorRef)NULL, |
| 566 |
_self->ob_itself, |
| 567 |
separatorString); |
| 568 |
_res = Py_BuildValue("O&", |
| 569 |
CFStringRefObj_New, _rv); |
| 570 |
return _res; |
| 571 |
} |
| 572 |
|
| 573 |
static PyMethodDef CFArrayRefObj_methods[] = { |
| 574 |
{"CFArrayCreateCopy", (PyCFunction)CFArrayRefObj_CFArrayCreateCopy, 1, |
| 575 |
PyDoc_STR("() -> (CFArrayRef _rv)")}, |
| 576 |
{"CFArrayGetCount", (PyCFunction)CFArrayRefObj_CFArrayGetCount, 1, |
| 577 |
PyDoc_STR("() -> (CFIndex _rv)")}, |
| 578 |
{"CFStringCreateByCombiningStrings", (PyCFunction)CFArrayRefObj_CFStringCreateByCombiningStrings, 1, |
| 579 |
PyDoc_STR("(CFStringRef separatorString) -> (CFStringRef _rv)")}, |
| 580 |
{NULL, NULL, 0} |
| 581 |
}; |
| 582 |
|
| 583 |
#define CFArrayRefObj_getsetlist NULL |
| 584 |
|
| 585 |
|
| 586 |
static int CFArrayRefObj_compare(CFArrayRefObject *self, CFArrayRefObject *other) |
| 587 |
{ |
| 588 |
|
| 589 |
if ( self->ob_itself > other->ob_itself ) return 1; |
| 590 |
if ( self->ob_itself < other->ob_itself ) return -1; |
| 591 |
return 0; |
| 592 |
} |
| 593 |
|
| 594 |
static PyObject * CFArrayRefObj_repr(CFArrayRefObject *self) |
| 595 |
{ |
| 596 |
char buf[100]; |
| 597 |
sprintf(buf, "<CFArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself); |
| 598 |
return PyString_FromString(buf); |
| 599 |
} |
| 600 |
|
| 601 |
static int CFArrayRefObj_hash(CFArrayRefObject *self) |
| 602 |
{ |
| 603 |
|
| 604 |
return (int)self->ob_itself; |
| 605 |
} |
| 606 |
static int CFArrayRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
| 607 |
{ |
| 608 |
CFArrayRef itself; |
| 609 |
char *kw[] = {"itself", 0}; |
| 610 |
|
| 611 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFArrayRefObj_Convert, &itself)) |
| 612 |
{ |
| 613 |
((CFArrayRefObject *)_self)->ob_itself = itself; |
| 614 |
return 0; |
| 615 |
} |
| 616 |
|
| 617 |
|
| 618 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) |
| 619 |
{ |
| 620 |
((CFArrayRefObject *)_self)->ob_itself = itself; |
| 621 |
return 0; |
| 622 |
} |
| 623 |
return -1; |
| 624 |
} |
| 625 |
|
| 626 |
#define CFArrayRefObj_tp_alloc PyType_GenericAlloc |
| 627 |
|
| 628 |
static PyObject *CFArrayRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 629 |
{ |
| 630 |
PyObject *self; |
| 631 |
if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 632 |
((CFArrayRefObject *)self)->ob_itself = NULL; |
| 633 |
((CFArrayRefObject *)self)->ob_freeit = CFRelease; |
| 634 |
return self; |
| 635 |
} |
| 636 |
|
| 637 |
#define CFArrayRefObj_tp_free PyObject_Del |
| 638 |
|
| 639 |
|
| 640 |
PyTypeObject CFArrayRef_Type = { |
| 641 |
PyObject_HEAD_INIT(NULL) |
| 642 |
0, |
| 643 |
"_CF.CFArrayRef", |
| 644 |
sizeof(CFArrayRefObject), |
| 645 |
0, |
| 646 |
|
| 647 |
(destructor) CFArrayRefObj_dealloc, |
| 648 |
0, |
| 649 |
(getattrfunc)0, |
| 650 |
(setattrfunc)0, |
| 651 |
(cmpfunc) CFArrayRefObj_compare, |
| 652 |
(reprfunc) CFArrayRefObj_repr, |
| 653 |
(PyNumberMethods *)0, |
| 654 |
(PySequenceMethods *)0, |
| 655 |
(PyMappingMethods *)0, |
| 656 |
(hashfunc) CFArrayRefObj_hash, |
| 657 |
0, |
| 658 |
0, |
| 659 |
PyObject_GenericGetAttr, |
| 660 |
PyObject_GenericSetAttr, |
| 661 |
0, |
| 662 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 663 |
0, |
| 664 |
0, |
| 665 |
0, |
| 666 |
0, |
| 667 |
0, |
| 668 |
0, |
| 669 |
0, |
| 670 |
CFArrayRefObj_methods, |
| 671 |
0, |
| 672 |
CFArrayRefObj_getsetlist, |
| 673 |
0, |
| 674 |
0, |
| 675 |
0, |
| 676 |
0, |
| 677 |
0, |
| 678 |
CFArrayRefObj_tp_init, |
| 679 |
CFArrayRefObj_tp_alloc, |
| 680 |
CFArrayRefObj_tp_new, |
| 681 |
CFArrayRefObj_tp_free, |
| 682 |
}; |
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
PyTypeObject CFMutableArrayRef_Type; |
| 690 |
|
| 691 |
#define CFMutableArrayRefObj_Check(x) ((x)->ob_type == &CFMutableArrayRef_Type || PyObject_TypeCheck((x), &CFMutableArrayRef_Type)) |
| 692 |
|
| 693 |
typedef struct CFMutableArrayRefObject { |
| 694 |
PyObject_HEAD |
| 695 |
CFMutableArrayRef ob_itself; |
| 696 |
void (*ob_freeit)(CFTypeRef ptr); |
| 697 |
} CFMutableArrayRefObject; |
| 698 |
|
| 699 |
PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef itself) |
| 700 |
{ |
| 701 |
CFMutableArrayRefObject *it; |
| 702 |
if (itself == NULL) |
| 703 |
{ |
| 704 |
PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); |
| 705 |
return NULL; |
| 706 |
} |
| 707 |
it = PyObject_NEW(CFMutableArrayRefObject, &CFMutableArrayRef_Type); |
| 708 |
if (it == NULL) return NULL; |
| 709 |
|
| 710 |
it->ob_itself = itself; |
| 711 |
it->ob_freeit = CFRelease; |
| 712 |
return (PyObject *)it; |
| 713 |
} |
| 714 |
|
| 715 |
int CFMutableArrayRefObj_Convert(PyObject *v, CFMutableArrayRef *p_itself) |
| 716 |
{ |
| 717 |
|
| 718 |
if (v == Py_None) { *p_itself = NULL; return 1; } |
| 719 |
|
| 720 |
|
| 721 |
if (!CFMutableArrayRefObj_Check(v)) |
| 722 |
{ |
| 723 |
PyErr_SetString(PyExc_TypeError, "CFMutableArrayRef required"); |
| 724 |
return 0; |
| 725 |
} |
| 726 |
*p_itself = ((CFMutableArrayRefObject *)v)->ob_itself; |
| 727 |
return 1; |
| 728 |
} |
| 729 |
|
| 730 |
static void CFMutableArrayRefObj_dealloc(CFMutableArrayRefObject *self) |
| 731 |
{ |
| 732 |
if (self->ob_freeit && self->ob_itself) |
| 733 |
{ |
| 734 |
self->ob_freeit((CFTypeRef)self->ob_itself); |
| 735 |
self->ob_itself = NULL; |
| 736 |
} |
| 737 |
CFArrayRef_Type.tp_dealloc((PyObject *)self); |
| 738 |
} |
| 739 |
|
| 740 |
static PyObject *CFMutableArrayRefObj_CFArrayRemoveValueAtIndex(CFMutableArrayRefObject *_self, PyObject *_args) |
| 741 |
{ |
| 742 |
PyObject *_res = NULL; |
| 743 |
CFIndex idx; |
| 744 |
#ifndef CFArrayRemoveValueAtIndex |
| 745 |
PyMac_PRECHECK(CFArrayRemoveValueAtIndex); |
| 746 |
#endif |
| 747 |
if (!PyArg_ParseTuple(_args, "l", |
| 748 |
&idx)) |
| 749 |
return NULL; |
| 750 |
CFArrayRemoveValueAtIndex(_self->ob_itself, |
| 751 |
idx); |
| 752 |
Py_INCREF(Py_None); |
| 753 |
_res = Py_None; |
| 754 |
return _res; |
| 755 |
} |
| 756 |
|
| 757 |
static PyObject *CFMutableArrayRefObj_CFArrayRemoveAllValues(CFMutableArrayRefObject *_self, PyObject *_args) |
| 758 |
{ |
| 759 |
PyObject *_res = NULL; |
| 760 |
#ifndef CFArrayRemoveAllValues |
| 761 |
PyMac_PRECHECK(CFArrayRemoveAllValues); |
| 762 |
#endif |
| 763 |
if (!PyArg_ParseTuple(_args, "")) |
| 764 |
return NULL; |
| 765 |
CFArrayRemoveAllValues(_self->ob_itself); |
| 766 |
Py_INCREF(Py_None); |
| 767 |
_res = Py_None; |
| 768 |
return _res; |
| 769 |
} |
| 770 |
|
| 771 |
static PyObject *CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices(CFMutableArrayRefObject *_self, PyObject *_args) |
| 772 |
{ |
| 773 |
PyObject *_res = NULL; |
| 774 |
CFIndex idx1; |
| 775 |
CFIndex idx2; |
| 776 |
#ifndef CFArrayExchangeValuesAtIndices |
| 777 |
PyMac_PRECHECK(CFArrayExchangeValuesAtIndices); |
| 778 |
#endif |
| 779 |
if (!PyArg_ParseTuple(_args, "ll", |
| 780 |
&idx1, |
| 781 |
&idx2)) |
| 782 |
return NULL; |
| 783 |
CFArrayExchangeValuesAtIndices(_self->ob_itself, |
| 784 |
idx1, |
| 785 |
idx2); |
| 786 |
Py_INCREF(Py_None); |
| 787 |
_res = Py_None; |
| 788 |
return _res; |
| 789 |
} |
| 790 |
|
| 791 |
static PyObject *CFMutableArrayRefObj_CFArrayAppendArray(CFMutableArrayRefObject *_self, PyObject *_args) |
| 792 |
{ |
| 793 |
PyObject *_res = NULL; |
| 794 |
CFArrayRef otherArray; |
| 795 |
CFRange otherRange; |
| 796 |
#ifndef CFArrayAppendArray |
| 797 |
PyMac_PRECHECK(CFArrayAppendArray); |
| 798 |
#endif |
| 799 |
if (!PyArg_ParseTuple(_args, "O&O&", |
| 800 |
CFArrayRefObj_Convert, &otherArray, |
| 801 |
CFRange_Convert, &otherRange)) |
| 802 |
return NULL; |
| 803 |
CFArrayAppendArray(_self->ob_itself, |
| 804 |
otherArray, |
| 805 |
otherRange); |
| 806 |
Py_INCREF(Py_None); |
| 807 |
_res = Py_None; |
| 808 |
return _res; |
| 809 |
} |
| 810 |
|
| 811 |
static PyMethodDef CFMutableArrayRefObj_methods[] = { |
| 812 |
{"CFArrayRemoveValueAtIndex", (PyCFunction)CFMutableArrayRefObj_CFArrayRemoveValueAtIndex, 1, |
| 813 |
PyDoc_STR("(CFIndex idx) -> None")}, |
| 814 |
{"CFArrayRemoveAllValues", (PyCFunction)CFMutableArrayRefObj_CFArrayRemoveAllValues, 1, |
| 815 |
PyDoc_STR("() -> None")}, |
| 816 |
{"CFArrayExchangeValuesAtIndices", (PyCFunction)CFMutableArrayRefObj_CFArrayExchangeValuesAtIndices, 1, |
| 817 |
PyDoc_STR("(CFIndex idx1, CFIndex idx2) -> None")}, |
| 818 |
{"CFArrayAppendArray", (PyCFunction)CFMutableArrayRefObj_CFArrayAppendArray, 1, |
| 819 |
PyDoc_STR("(CFArrayRef otherArray, CFRange otherRange) -> None")}, |
| 820 |
{NULL, NULL, 0} |
| 821 |
}; |
| 822 |
|
| 823 |
#define CFMutableArrayRefObj_getsetlist NULL |
| 824 |
|
| 825 |
|
| 826 |
static int CFMutableArrayRefObj_compare(CFMutableArrayRefObject *self, CFMutableArrayRefObject *other) |
| 827 |
{ |
| 828 |
|
| 829 |
if ( self->ob_itself > other->ob_itself ) return 1; |
| 830 |
if ( self->ob_itself < other->ob_itself ) return -1; |
| 831 |
return 0; |
| 832 |
} |
| 833 |
|
| 834 |
static PyObject * CFMutableArrayRefObj_repr(CFMutableArrayRefObject *self) |
| 835 |
{ |
| 836 |
char buf[100]; |
| 837 |
sprintf(buf, "<CFMutableArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself); |
| 838 |
return PyString_FromString(buf); |
| 839 |
} |
| 840 |
|
| 841 |
static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject *self) |
| 842 |
{ |
| 843 |
|
| 844 |
return (int)self->ob_itself; |
| 845 |
} |
| 846 |
static int CFMutableArrayRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
| 847 |
{ |
| 848 |
CFMutableArrayRef itself; |
| 849 |
char *kw[] = {"itself", 0}; |
| 850 |
|
| 851 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFMutableArrayRefObj_Convert, &itself)) |
| 852 |
{ |
| 853 |
((CFMutableArrayRefObject *)_self)->ob_itself = itself; |
| 854 |
return 0; |
| 855 |
} |
| 856 |
|
| 857 |
|
| 858 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) |
| 859 |
{ |
| 860 |
((CFMutableArrayRefObject *)_self)->ob_itself = itself; |
| 861 |
return 0; |
| 862 |
} |
| 863 |
return -1; |
| 864 |
} |
| 865 |
|
| 866 |
#define CFMutableArrayRefObj_tp_alloc PyType_GenericAlloc |
| 867 |
|
| 868 |
static PyObject *CFMutableArrayRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 869 |
{ |
| 870 |
PyObject *self; |
| 871 |
if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 872 |
((CFMutableArrayRefObject *)self)->ob_itself = NULL; |
| 873 |
((CFMutableArrayRefObject *)self)->ob_freeit = CFRelease; |
| 874 |
return self; |
| 875 |
} |
| 876 |
|
| 877 |
#define CFMutableArrayRefObj_tp_free PyObject_Del |
| 878 |
|
| 879 |
|
| 880 |
PyTypeObject CFMutableArrayRef_Type = { |
| 881 |
PyObject_HEAD_INIT(NULL) |
| 882 |
0, |
| 883 |
"_CF.CFMutableArrayRef", |
| 884 |
sizeof(CFMutableArrayRefObject), |
| 885 |
0, |
| 886 |
|
| 887 |
(destructor) CFMutableArrayRefObj_dealloc, |
| 888 |
0, |
| 889 |
(getattrfunc)0, |
| 890 |
(setattrfunc)0, |
| 891 |
(cmpfunc) CFMutableArrayRefObj_compare, |
| 892 |
(reprfunc) CFMutableArrayRefObj_repr, |
| 893 |
(PyNumberMethods *)0, |
| 894 |
(PySequenceMethods *)0, |
| 895 |
(PyMappingMethods *)0, |
| 896 |
(hashfunc) CFMutableArrayRefObj_hash, |
| 897 |
0, |
| 898 |
0, |
| 899 |
PyObject_GenericGetAttr, |
| 900 |
PyObject_GenericSetAttr, |
| 901 |
0, |
| 902 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 903 |
0, |
| 904 |
0, |
| 905 |
0, |
| 906 |
0, |
| 907 |
0, |
| 908 |
0, |
| 909 |
0, |
| 910 |
CFMutableArrayRefObj_methods, |
| 911 |
0, |
| 912 |
CFMutableArrayRefObj_getsetlist, |
| 913 |
0, |
| 914 |
0, |
| 915 |
0, |
| 916 |
0, |
| 917 |
0, |
| 918 |
CFMutableArrayRefObj_tp_init, |
| 919 |
CFMutableArrayRefObj_tp_alloc, |
| 920 |
CFMutableArrayRefObj_tp_new, |
| 921 |
CFMutableArrayRefObj_tp_free, |
| 922 |
}; |
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
PyTypeObject CFDictionaryRef_Type; |
| 930 |
|
| 931 |
#define CFDictionaryRefObj_Check(x) ((x)->ob_type == &CFDictionaryRef_Type || PyObject_TypeCheck((x), &CFDictionaryRef_Type)) |
| 932 |
|
| 933 |
typedef struct CFDictionaryRefObject { |
| 934 |
PyObject_HEAD |
| 935 |
CFDictionaryRef ob_itself; |
| 936 |
void (*ob_freeit)(CFTypeRef ptr); |
| 937 |
} CFDictionaryRefObject; |
| 938 |
|
| 939 |
PyObject *CFDictionaryRefObj_New(CFDictionaryRef itself) |
| 940 |
{ |
| 941 |
CFDictionaryRefObject *it; |
| 942 |
if (itself == NULL) |
| 943 |
{ |
| 944 |
PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); |
| 945 |
return NULL; |
| 946 |
} |
| 947 |
it = PyObject_NEW(CFDictionaryRefObject, &CFDictionaryRef_Type); |
| 948 |
if (it == NULL) return NULL; |
| 949 |
|
| 950 |
it->ob_itself = itself; |
| 951 |
it->ob_freeit = CFRelease; |
| 952 |
return (PyObject *)it; |
| 953 |
} |
| 954 |
|
| 955 |
int CFDictionaryRefObj_Convert(PyObject *v, CFDictionaryRef *p_itself) |
| 956 |
{ |
| 957 |
|
| 958 |
if (v == Py_None) { *p_itself = NULL; return 1; } |
| 959 |
|
| 960 |
|
| 961 |
if (!CFDictionaryRefObj_Check(v)) |
| 962 |
{ |
| 963 |
PyErr_SetString(PyExc_TypeError, "CFDictionaryRef required"); |
| 964 |
return 0; |
| 965 |
} |
| 966 |
*p_itself = ((CFDictionaryRefObject *)v)->ob_itself; |
| 967 |
return 1; |
| 968 |
} |
| 969 |
|
| 970 |
static void CFDictionaryRefObj_dealloc(CFDictionaryRefObject *self) |
| 971 |
{ |
| 972 |
if (self->ob_freeit && self->ob_itself) |
| 973 |
{ |
| 974 |
self->ob_freeit((CFTypeRef)self->ob_itself); |
| 975 |
self->ob_itself = NULL; |
| 976 |
} |
| 977 |
CFTypeRef_Type.tp_dealloc((PyObject *)self); |
| 978 |
} |
| 979 |
|
| 980 |
static PyObject *CFDictionaryRefObj_CFDictionaryCreateCopy(CFDictionaryRefObject *_self, PyObject *_args) |
| 981 |
{ |
| 982 |
PyObject *_res = NULL; |
| 983 |
CFDictionaryRef _rv; |
| 984 |
if (!PyArg_ParseTuple(_args, "")) |
| 985 |
return NULL; |
| 986 |
_rv = CFDictionaryCreateCopy((CFAllocatorRef)NULL, |
| 987 |
_self->ob_itself); |
| 988 |
_res = Py_BuildValue("O&", |
| 989 |
CFDictionaryRefObj_New, _rv); |
| 990 |
return _res; |
| 991 |
} |
| 992 |
|
| 993 |
static PyObject *CFDictionaryRefObj_CFDictionaryGetCount(CFDictionaryRefObject *_self, PyObject *_args) |
| 994 |
{ |
| 995 |
PyObject *_res = NULL; |
| 996 |
CFIndex _rv; |
| 997 |
#ifndef CFDictionaryGetCount |
| 998 |
PyMac_PRECHECK(CFDictionaryGetCount); |
| 999 |
#endif |
| 1000 |
if (!PyArg_ParseTuple(_args, "")) |
| 1001 |
return NULL; |
| 1002 |
_rv = CFDictionaryGetCount(_self->ob_itself); |
| 1003 |
_res = Py_BuildValue("l", |
| 1004 |
_rv); |
| 1005 |
return _res; |
| 1006 |
} |
| 1007 |
|
| 1008 |
static PyMethodDef CFDictionaryRefObj_methods[] = { |
| 1009 |
{"CFDictionaryCreateCopy", (PyCFunction)CFDictionaryRefObj_CFDictionaryCreateCopy, 1, |
| 1010 |
PyDoc_STR("() -> (CFDictionaryRef _rv)")}, |
| 1011 |
{"CFDictionaryGetCount", (PyCFunction)CFDictionaryRefObj_CFDictionaryGetCount, 1, |
| 1012 |
PyDoc_STR("() -> (CFIndex _rv)")}, |
| 1013 |
{NULL, NULL, 0} |
| 1014 |
}; |
| 1015 |
|
| 1016 |
#define CFDictionaryRefObj_getsetlist NULL |
| 1017 |
|
| 1018 |
|
| 1019 |
static int CFDictionaryRefObj_compare(CFDictionaryRefObject *self, CFDictionaryRefObject *other) |
| 1020 |
{ |
| 1021 |
|
| 1022 |
if ( self->ob_itself > other->ob_itself ) return 1; |
| 1023 |
if ( self->ob_itself < other->ob_itself ) return -1; |
| 1024 |
return 0; |
| 1025 |
} |
| 1026 |
|
| 1027 |
static PyObject * CFDictionaryRefObj_repr(CFDictionaryRefObject *self) |
| 1028 |
{ |
| 1029 |
char buf[100]; |
| 1030 |
sprintf(buf, "<CFDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself); |
| 1031 |
return PyString_FromString(buf); |
| 1032 |
} |
| 1033 |
|
| 1034 |
static int CFDictionaryRefObj_hash(CFDictionaryRefObject *self) |
| 1035 |
{ |
| 1036 |
|
| 1037 |
return (int)self->ob_itself; |
| 1038 |
} |
| 1039 |
static int CFDictionaryRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
| 1040 |
{ |
| 1041 |
CFDictionaryRef itself; |
| 1042 |
char *kw[] = {"itself", 0}; |
| 1043 |
|
| 1044 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFDictionaryRefObj_Convert, &itself)) |
| 1045 |
{ |
| 1046 |
((CFDictionaryRefObject *)_self)->ob_itself = itself; |
| 1047 |
return 0; |
| 1048 |
} |
| 1049 |
|
| 1050 |
|
| 1051 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) |
| 1052 |
{ |
| 1053 |
((CFDictionaryRefObject *)_self)->ob_itself = itself; |
| 1054 |
return 0; |
| 1055 |
} |
| 1056 |
return -1; |
| 1057 |
} |
| 1058 |
|
| 1059 |
#define CFDictionaryRefObj_tp_alloc PyType_GenericAlloc |
| 1060 |
|
| 1061 |
static PyObject *CFDictionaryRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 1062 |
{ |
| 1063 |
PyObject *self; |
| 1064 |
if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 1065 |
((CFDictionaryRefObject *)self)->ob_itself = NULL; |
| 1066 |
((CFDictionaryRefObject *)self)->ob_freeit = CFRelease; |
| 1067 |
return self; |
| 1068 |
} |
| 1069 |
|
| 1070 |
#define CFDictionaryRefObj_tp_free PyObject_Del |
| 1071 |
|
| 1072 |
|
| 1073 |
PyTypeObject CFDictionaryRef_Type = { |
| 1074 |
PyObject_HEAD_INIT(NULL) |
| 1075 |
0, |
| 1076 |
"_CF.CFDictionaryRef", |
| 1077 |
sizeof(CFDictionaryRefObject), |
| 1078 |
0, |
| 1079 |
|
| 1080 |
(destructor) CFDictionaryRefObj_dealloc, |
| 1081 |
0, |
| 1082 |
(getattrfunc)0, |
| 1083 |
(setattrfunc)0, |
| 1084 |
(cmpfunc) CFDictionaryRefObj_compare, |
| 1085 |
(reprfunc) CFDictionaryRefObj_repr, |
| 1086 |
(PyNumberMethods *)0, |
| 1087 |
(PySequenceMethods *)0, |
| 1088 |
(PyMappingMethods *)0, |
| 1089 |
(hashfunc) CFDictionaryRefObj_hash, |
| 1090 |
0, |
| 1091 |
0, |
| 1092 |
PyObject_GenericGetAttr, |
| 1093 |
PyObject_GenericSetAttr, |
| 1094 |
0, |
| 1095 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 1096 |
0, |
| 1097 |
0, |
| 1098 |
0, |
| 1099 |
0, |
| 1100 |
0, |
| 1101 |
0, |
| 1102 |
0, |
| 1103 |
CFDictionaryRefObj_methods, |
| 1104 |
0, |
| 1105 |
CFDictionaryRefObj_getsetlist, |
| 1106 |
0, |
| 1107 |
0, |
| 1108 |
0, |
| 1109 |
0, |
| 1110 |
0, |
| 1111 |
CFDictionaryRefObj_tp_init, |
| 1112 |
CFDictionaryRefObj_tp_alloc, |
| 1113 |
CFDictionaryRefObj_tp_new, |
| 1114 |
CFDictionaryRefObj_tp_free, |
| 1115 |
}; |
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
PyTypeObject CFMutableDictionaryRef_Type; |
| 1123 |
|
| 1124 |
#define CFMutableDictionaryRefObj_Check(x) ((x)->ob_type == &CFMutableDictionaryRef_Type || PyObject_TypeCheck((x), &CFMutableDictionaryRef_Type)) |
| 1125 |
|
| 1126 |
typedef struct CFMutableDictionaryRefObject { |
| 1127 |
PyObject_HEAD |
| 1128 |
CFMutableDictionaryRef ob_itself; |
| 1129 |
void (*ob_freeit)(CFTypeRef ptr); |
| 1130 |
} CFMutableDictionaryRefObject; |
| 1131 |
|
| 1132 |
PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef itself) |
| 1133 |
{ |
| 1134 |
CFMutableDictionaryRefObject *it; |
| 1135 |
if (itself == NULL) |
| 1136 |
{ |
| 1137 |
PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); |
| 1138 |
return NULL; |
| 1139 |
} |
| 1140 |
it = PyObject_NEW(CFMutableDictionaryRefObject, &CFMutableDictionaryRef_Type); |
| 1141 |
if (it == NULL) return NULL; |
| 1142 |
|
| 1143 |
it->ob_itself = itself; |
| 1144 |
it->ob_freeit = CFRelease; |
| 1145 |
return (PyObject *)it; |
| 1146 |
} |
| 1147 |
|
| 1148 |
int CFMutableDictionaryRefObj_Convert(PyObject *v, CFMutableDictionaryRef *p_itself) |
| 1149 |
{ |
| 1150 |
|
| 1151 |
if (v == Py_None) { *p_itself = NULL; return 1; } |
| 1152 |
|
| 1153 |
|
| 1154 |
if (!CFMutableDictionaryRefObj_Check(v)) |
| 1155 |
{ |
| 1156 |
PyErr_SetString(PyExc_TypeError, "CFMutableDictionaryRef required"); |
| 1157 |
return 0; |
| 1158 |
} |
| 1159 |
*p_itself = ((CFMutableDictionaryRefObject *)v)->ob_itself; |
| 1160 |
return 1; |
| 1161 |
} |
| 1162 |
|
| 1163 |
static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject *self) |
| 1164 |
{ |
| 1165 |
if (self->ob_freeit && self->ob_itself) |
| 1166 |
{ |
| 1167 |
self->ob_freeit((CFTypeRef)self->ob_itself); |
| 1168 |
self->ob_itself = NULL; |
| 1169 |
} |
| 1170 |
CFDictionaryRef_Type.tp_dealloc((PyObject *)self); |
| 1171 |
} |
| 1172 |
|
| 1173 |
static PyObject *CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues(CFMutableDictionaryRefObject *_self, PyObject *_args) |
| 1174 |
{ |
| 1175 |
PyObject *_res = NULL; |
| 1176 |
#ifndef CFDictionaryRemoveAllValues |
| 1177 |
PyMac_PRECHECK(CFDictionaryRemoveAllValues); |
| 1178 |
#endif |
| 1179 |
if (!PyArg_ParseTuple(_args, "")) |
| 1180 |
return NULL; |
| 1181 |
CFDictionaryRemoveAllValues(_self->ob_itself); |
| 1182 |
Py_INCREF(Py_None); |
| 1183 |
_res = Py_None; |
| 1184 |
return _res; |
| 1185 |
} |
| 1186 |
|
| 1187 |
static PyMethodDef CFMutableDictionaryRefObj_methods[] = { |
| 1188 |
{"CFDictionaryRemoveAllValues", (PyCFunction)CFMutableDictionaryRefObj_CFDictionaryRemoveAllValues, 1, |
| 1189 |
PyDoc_STR("() -> None")}, |
| 1190 |
{NULL, NULL, 0} |
| 1191 |
}; |
| 1192 |
|
| 1193 |
#define CFMutableDictionaryRefObj_getsetlist NULL |
| 1194 |
|
| 1195 |
|
| 1196 |
static int CFMutableDictionaryRefObj_compare(CFMutableDictionaryRefObject *self, CFMutableDictionaryRefObject *other) |
| 1197 |
{ |
| 1198 |
|
| 1199 |
if ( self->ob_itself > other->ob_itself ) return 1; |
| 1200 |
if ( self->ob_itself < other->ob_itself ) return -1; |
| 1201 |
return 0; |
| 1202 |
} |
| 1203 |
|
| 1204 |
static PyObject * CFMutableDictionaryRefObj_repr(CFMutableDictionaryRefObject *self) |
| 1205 |
{ |
| 1206 |
char buf[100]; |
| 1207 |
sprintf(buf, "<CFMutableDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself); |
| 1208 |
return PyString_FromString(buf); |
| 1209 |
} |
| 1210 |
|
| 1211 |
static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject *self) |
| 1212 |
{ |
| 1213 |
|
| 1214 |
return (int)self->ob_itself; |
| 1215 |
} |
| 1216 |
static int CFMutableDictionaryRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
| 1217 |
{ |
| 1218 |
CFMutableDictionaryRef itself; |
| 1219 |
char *kw[] = {"itself", 0}; |
| 1220 |
|
| 1221 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFMutableDictionaryRefObj_Convert, &itself)) |
| 1222 |
{ |
| 1223 |
((CFMutableDictionaryRefObject *)_self)->ob_itself = itself; |
| 1224 |
return 0; |
| 1225 |
} |
| 1226 |
|
| 1227 |
|
| 1228 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) |
| 1229 |
{ |
| 1230 |
((CFMutableDictionaryRefObject *)_self)->ob_itself = itself; |
| 1231 |
return 0; |
| 1232 |
} |
| 1233 |
return -1; |
| 1234 |
} |
| 1235 |
|
| 1236 |
#define CFMutableDictionaryRefObj_tp_alloc PyType_GenericAlloc |
| 1237 |
|
| 1238 |
static PyObject *CFMutableDictionaryRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 1239 |
{ |
| 1240 |
PyObject *self; |
| 1241 |
if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 1242 |
((CFMutableDictionaryRefObject *)self)->ob_itself = NULL; |
| 1243 |
((CFMutableDictionaryRefObject *)self)->ob_freeit = CFRelease; |
| 1244 |
return self; |
| 1245 |
} |
| 1246 |
|
| 1247 |
#define CFMutableDictionaryRefObj_tp_free PyObject_Del |
| 1248 |
|
| 1249 |
|
| 1250 |
PyTypeObject CFMutableDictionaryRef_Type = { |
| 1251 |
PyObject_HEAD_INIT(NULL) |
| 1252 |
0, |
| 1253 |
"_CF.CFMutableDictionaryRef", |
| 1254 |
sizeof(CFMutableDictionaryRefObject), |
| 1255 |
0, |
| 1256 |
|
| 1257 |
(destructor) CFMutableDictionaryRefObj_dealloc, |
| 1258 |
0, |
| 1259 |
(getattrfunc)0, |
| 1260 |
(setattrfunc)0, |
| 1261 |
(cmpfunc) CFMutableDictionaryRefObj_compare, |
| 1262 |
(reprfunc) CFMutableDictionaryRefObj_repr, |
| 1263 |
(PyNumberMethods *)0, |
| 1264 |
(PySequenceMethods *)0, |
| 1265 |
(PyMappingMethods *)0, |
| 1266 |
(hashfunc) CFMutableDictionaryRefObj_hash, |
| 1267 |
0, |
| 1268 |
0, |
| 1269 |
PyObject_GenericGetAttr, |
| 1270 |
PyObject_GenericSetAttr, |
| 1271 |
0, |
| 1272 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 1273 |
0, |
| 1274 |
0, |
| 1275 |
0, |
| 1276 |
0, |
| 1277 |
0, |
| 1278 |
0, |
| 1279 |
0, |
| 1280 |
CFMutableDictionaryRefObj_methods, |
| 1281 |
0, |
| 1282 |
CFMutableDictionaryRefObj_getsetlist, |
| 1283 |
0, |
| 1284 |
0, |
| 1285 |
0, |
| 1286 |
0, |
| 1287 |
0, |
| 1288 |
CFMutableDictionaryRefObj_tp_init, |
| 1289 |
CFMutableDictionaryRefObj_tp_alloc, |
| 1290 |
CFMutableDictionaryRefObj_tp_new, |
| 1291 |
CFMutableDictionaryRefObj_tp_free, |
| 1292 |
}; |
| 1293 |
|
| 1294 |
|
| 1295 |
|
| 1296 |
|
| 1297 |
|
| 1298 |
|
| 1299 |
PyTypeObject CFDataRef_Type; |
| 1300 |
|
| 1301 |
#define CFDataRefObj_Check(x) ((x)->ob_type == &CFDataRef_Type || PyObject_TypeCheck((x), &CFDataRef_Type)) |
| 1302 |
|
| 1303 |
typedef struct CFDataRefObject { |
| 1304 |
PyObject_HEAD |
| 1305 |
CFDataRef ob_itself; |
| 1306 |
void (*ob_freeit)(CFTypeRef ptr); |
| 1307 |
} CFDataRefObject; |
| 1308 |
|
| 1309 |
PyObject *CFDataRefObj_New(CFDataRef itself) |
| 1310 |
{ |
| 1311 |
CFDataRefObject *it; |
| 1312 |
if (itself == NULL) |
| 1313 |
{ |
| 1314 |
PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); |
| 1315 |
return NULL; |
| 1316 |
} |
| 1317 |
it = PyObject_NEW(CFDataRefObject, &CFDataRef_Type); |
| 1318 |
if (it == NULL) return NULL; |
| 1319 |
|
| 1320 |
it->ob_itself = itself; |
| 1321 |
it->ob_freeit = CFRelease; |
| 1322 |
return (PyObject *)it; |
| 1323 |
} |
| 1324 |
|
| 1325 |
int CFDataRefObj_Convert(PyObject *v, CFDataRef *p_itself) |
| 1326 |
{ |
| 1327 |
|
| 1328 |
if (v == Py_None) { *p_itself = NULL; return 1; } |
| 1329 |
if (PyString_Check(v)) { |
| 1330 |
char *cStr; |
| 1331 |
Py_ssize_t cLen; |
| 1332 |
if( PyString_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0; |
| 1333 |
*p_itself = CFDataCreate((CFAllocatorRef)NULL, (unsigned char *)cStr, cLen); |
| 1334 |
return 1; |
| 1335 |
} |
| 1336 |
|
| 1337 |
if (!CFDataRefObj_Check(v)) |
| 1338 |
{ |
| 1339 |
PyErr_SetString(PyExc_TypeError, "CFDataRef required"); |
| 1340 |
return 0; |
| 1341 |
} |
| 1342 |
*p_itself = ((CFDataRefObject *)v)->ob_itself; |
| 1343 |
return 1; |
| 1344 |
} |
| 1345 |
|
| 1346 |
static void CFDataRefObj_dealloc(CFDataRefObject *self) |
| 1347 |
{ |
| 1348 |
if (self->ob_freeit && self->ob_itself) |
| 1349 |
{ |
| 1350 |
self->ob_freeit((CFTypeRef)self->ob_itself); |
| 1351 |
self->ob_itself = NULL; |
| 1352 |
} |
| 1353 |
CFTypeRef_Type.tp_dealloc((PyObject *)self); |
| 1354 |
} |
| 1355 |
|
| 1356 |
static PyObject *CFDataRefObj_CFDataCreateCopy(CFDataRefObject *_self, PyObject *_args) |
| 1357 |
{ |
| 1358 |
PyObject *_res = NULL; |
| 1359 |
CFDataRef _rv; |
| 1360 |
if (!PyArg_ParseTuple(_args, "")) |
| 1361 |
return NULL; |
| 1362 |
_rv = CFDataCreateCopy((CFAllocatorRef)NULL, |
| 1363 |
_self->ob_itself); |
| 1364 |
_res = Py_BuildValue("O&", |
| 1365 |
CFDataRefObj_New, _rv); |
| 1366 |
return _res; |
| 1367 |
} |
| 1368 |
|
| 1369 |
static PyObject *CFDataRefObj_CFDataGetLength(CFDataRefObject *_self, PyObject *_args) |
| 1370 |
{ |
| 1371 |
PyObject *_res = NULL; |
| 1372 |
CFIndex _rv; |
| 1373 |
#ifndef CFDataGetLength |
| 1374 |
PyMac_PRECHECK(CFDataGetLength); |
| 1375 |
#endif |
| 1376 |
if (!PyArg_ParseTuple(_args, "")) |
| 1377 |
return NULL; |
| 1378 |
_rv = CFDataGetLength(_self->ob_itself); |
| 1379 |
_res = Py_BuildValue("l", |
| 1380 |
_rv); |
| 1381 |
return _res; |
| 1382 |
} |
| 1383 |
|
| 1384 |
static PyObject *CFDataRefObj_CFStringCreateFromExternalRepresentation(CFDataRefObject *_self, PyObject *_args) |
| 1385 |
{ |
| 1386 |
PyObject *_res = NULL; |
| 1387 |
CFStringRef _rv; |
| 1388 |
CFStringEncoding encoding; |
| 1389 |
if (!PyArg_ParseTuple(_args, "l", |
| 1390 |
&encoding)) |
| 1391 |
return NULL; |
| 1392 |
_rv = CFStringCreateFromExternalRepresentation((CFAllocatorRef)NULL, |
| 1393 |
_self->ob_itself, |
| 1394 |
encoding); |
| 1395 |
_res = Py_BuildValue("O&", |
| 1396 |
CFStringRefObj_New, _rv); |
| 1397 |
return _res; |
| 1398 |
} |
| 1399 |
|
| 1400 |
static PyObject *CFDataRefObj_CFDataGetData(CFDataRefObject *_self, PyObject *_args) |
| 1401 |
{ |
| 1402 |
PyObject *_res = NULL; |
| 1403 |
|
| 1404 |
int size = CFDataGetLength(_self->ob_itself); |
| 1405 |
char *data = (char *)CFDataGetBytePtr(_self->ob_itself); |
| 1406 |
|
| 1407 |
_res = (PyObject *)PyString_FromStringAndSize(data, size); |
| 1408 |
return _res; |
| 1409 |
|
| 1410 |
} |
| 1411 |
|
| 1412 |
static PyMethodDef CFDataRefObj_methods[] = { |
| 1413 |
{"CFDataCreateCopy", (PyCFunction)CFDataRefObj_CFDataCreateCopy, 1, |
| 1414 |
PyDoc_STR("() -> (CFDataRef _rv)")}, |
| 1415 |
{"CFDataGetLength", (PyCFunction)CFDataRefObj_CFDataGetLength, 1, |
| 1416 |
PyDoc_STR("() -> (CFIndex _rv)")}, |
| 1417 |
{"CFStringCreateFromExternalRepresentation", (PyCFunction)CFDataRefObj_CFStringCreateFromExternalRepresentation, 1, |
| 1418 |
PyDoc_STR("(CFStringEncoding encoding) -> (CFStringRef _rv)")}, |
| 1419 |
{"CFDataGetData", (PyCFunction)CFDataRefObj_CFDataGetData, 1, |
| 1420 |
PyDoc_STR("() -> (string _rv)")}, |
| 1421 |
{NULL, NULL, 0} |
| 1422 |
}; |
| 1423 |
|
| 1424 |
#define CFDataRefObj_getsetlist NULL |
| 1425 |
|
| 1426 |
|
| 1427 |
static int CFDataRefObj_compare(CFDataRefObject *self, CFDataRefObject *other) |
| 1428 |
{ |
| 1429 |
|
| 1430 |
if ( self->ob_itself > other->ob_itself ) return 1; |
| 1431 |
if ( self->ob_itself < other->ob_itself ) return -1; |
| 1432 |
return 0; |
| 1433 |
} |
| 1434 |
|
| 1435 |
static PyObject * CFDataRefObj_repr(CFDataRefObject *self) |
| 1436 |
{ |
| 1437 |
char buf[100]; |
| 1438 |
sprintf(buf, "<CFDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself); |
| 1439 |
return PyString_FromString(buf); |
| 1440 |
} |
| 1441 |
|
| 1442 |
static int CFDataRefObj_hash(CFDataRefObject *self) |
| 1443 |
{ |
| 1444 |
|
| 1445 |
return (int)self->ob_itself; |
| 1446 |
} |
| 1447 |
static int CFDataRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
| 1448 |
{ |
| 1449 |
CFDataRef itself; |
| 1450 |
char *kw[] = {"itself", 0}; |
| 1451 |
|
| 1452 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFDataRefObj_Convert, &itself)) |
| 1453 |
{ |
| 1454 |
((CFDataRefObject *)_self)->ob_itself = itself; |
| 1455 |
return 0; |
| 1456 |
} |
| 1457 |
|
| 1458 |
|
| 1459 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) |
| 1460 |
{ |
| 1461 |
((CFDataRefObject *)_self)->ob_itself = itself; |
| 1462 |
return 0; |
| 1463 |
} |
| 1464 |
return -1; |
| 1465 |
} |
| 1466 |
|
| 1467 |
#define CFDataRefObj_tp_alloc PyType_GenericAlloc |
| 1468 |
|
| 1469 |
static PyObject *CFDataRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 1470 |
{ |
| 1471 |
PyObject *self; |
| 1472 |
if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 1473 |
((CFDataRefObject *)self)->ob_itself = NULL; |
| 1474 |
((CFDataRefObject *)self)->ob_freeit = CFRelease; |
| 1475 |
return self; |
| 1476 |
} |
| 1477 |
|
| 1478 |
#define CFDataRefObj_tp_free PyObject_Del |
| 1479 |
|
| 1480 |
|
| 1481 |
PyTypeObject CFDataRef_Type = { |
| 1482 |
PyObject_HEAD_INIT(NULL) |
| 1483 |
0, |
| 1484 |
"_CF.CFDataRef", |
| 1485 |
sizeof(CFDataRefObject), |
| 1486 |
0, |
| 1487 |
|
| 1488 |
(destructor) CFDataRefObj_dealloc, |
| 1489 |
0, |
| 1490 |
(getattrfunc)0, |
| 1491 |
(setattrfunc)0, |
| 1492 |
(cmpfunc) CFDataRefObj_compare, |
| 1493 |
(reprfunc) CFDataRefObj_repr, |
| 1494 |
(PyNumberMethods *)0, |
| 1495 |
(PySequenceMethods *)0, |
| 1496 |
(PyMappingMethods *)0, |
| 1497 |
(hashfunc) CFDataRefObj_hash, |
| 1498 |
0, |
| 1499 |
0, |
| 1500 |
PyObject_GenericGetAttr, |
| 1501 |
PyObject_GenericSetAttr, |
| 1502 |
0, |
| 1503 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 1504 |
0, |
| 1505 |
0, |
| 1506 |
0, |
| 1507 |
0, |
| 1508 |
0, |
| 1509 |
0, |
| 1510 |
0, |
| 1511 |
CFDataRefObj_methods, |
| 1512 |
0, |
| 1513 |
CFDataRefObj_getsetlist, |
| 1514 |
0, |
| 1515 |
0, |
| 1516 |
0, |
| 1517 |
0, |
| 1518 |
0, |
| 1519 |
CFDataRefObj_tp_init, |
| 1520 |
CFDataRefObj_tp_alloc, |
| 1521 |
CFDataRefObj_tp_new, |
| 1522 |
CFDataRefObj_tp_free, |
| 1523 |
}; |
| 1524 |
|
| 1525 |
|
| 1526 |
|
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
PyTypeObject CFMutableDataRef_Type; |
| 1531 |
|
| 1532 |
#define CFMutableDataRefObj_Check(x) ((x)->ob_type == &CFMutableDataRef_Type || PyObject_TypeCheck((x), &CFMutableDataRef_Type)) |
| 1533 |
|
| 1534 |
typedef struct CFMutableDataRefObject { |
| 1535 |
PyObject_HEAD |
| 1536 |
CFMutableDataRef ob_itself; |
| 1537 |
void (*ob_freeit)(CFTypeRef ptr); |
| 1538 |
} CFMutableDataRefObject; |
| 1539 |
|
| 1540 |
PyObject *CFMutableDataRefObj_New(CFMutableDataRef itself) |
| 1541 |
{ |
| 1542 |
CFMutableDataRefObject *it; |
| 1543 |
if (itself == NULL) |
| 1544 |
{ |
| 1545 |
PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); |
| 1546 |
return NULL; |
| 1547 |
} |
| 1548 |
it = PyObject_NEW(CFMutableDataRefObject, &CFMutableDataRef_Type); |
| 1549 |
if (it == NULL) return NULL; |
| 1550 |
|
| 1551 |
it->ob_itself = itself; |
| 1552 |
it->ob_freeit = CFRelease; |
| 1553 |
return (PyObject *)it; |
| 1554 |
} |
| 1555 |
|
| 1556 |
int CFMutableDataRefObj_Convert(PyObject *v, CFMutableDataRef *p_itself) |
| 1557 |
{ |
| 1558 |
|
| 1559 |
if (v == Py_None) { *p_itself = NULL; return 1; } |
| 1560 |
|
| 1561 |
|
| 1562 |
if (!CFMutableDataRefObj_Check(v)) |
| 1563 |
{ |
| 1564 |
PyErr_SetString(PyExc_TypeError, "CFMutableDataRef required"); |
| 1565 |
return 0; |
| 1566 |
} |
| 1567 |
*p_itself = ((CFMutableDataRefObject *)v)->ob_itself; |
| 1568 |
return 1; |
| 1569 |
} |
| 1570 |
|
| 1571 |
static void CFMutableDataRefObj_dealloc(CFMutableDataRefObject *self) |
| 1572 |
{ |
| 1573 |
if (self->ob_freeit && self->ob_itself) |
| 1574 |
{ |
| 1575 |
self->ob_freeit((CFTypeRef)self->ob_itself); |
| 1576 |
self->ob_itself = NULL; |
| 1577 |
} |
| 1578 |
CFDataRef_Type.tp_dealloc((PyObject *)self); |
| 1579 |
} |
| 1580 |
|
| 1581 |
static PyObject *CFMutableDataRefObj_CFDataSetLength(CFMutableDataRefObject *_self, PyObject *_args) |
| 1582 |
{ |
| 1583 |
PyObject *_res = NULL; |
| 1584 |
CFIndex length; |
| 1585 |
#ifndef CFDataSetLength |
| 1586 |
PyMac_PRECHECK(CFDataSetLength); |
| 1587 |
#endif |
| 1588 |
if (!PyArg_ParseTuple(_args, "l", |
| 1589 |
&length)) |
| 1590 |
return NULL; |
| 1591 |
CFDataSetLength(_self->ob_itself, |
| 1592 |
length); |
| 1593 |
Py_INCREF(Py_None); |
| 1594 |
_res = Py_None; |
| 1595 |
return _res; |
| 1596 |
} |
| 1597 |
|
| 1598 |
static PyObject *CFMutableDataRefObj_CFDataIncreaseLength(CFMutableDataRefObject *_self, PyObject *_args) |
| 1599 |
{ |
| 1600 |
PyObject *_res = NULL; |
| 1601 |
CFIndex extraLength; |
| 1602 |
#ifndef CFDataIncreaseLength |
| 1603 |
PyMac_PRECHECK(CFDataIncreaseLength); |
| 1604 |
#endif |
| 1605 |
if (!PyArg_ParseTuple(_args, "l", |
| 1606 |
&extraLength)) |
| 1607 |
return NULL; |
| 1608 |
CFDataIncreaseLength(_self->ob_itself, |
| 1609 |
extraLength); |
| 1610 |
Py_INCREF(Py_None); |
| 1611 |
_res = Py_None; |
| 1612 |
return _res; |
| 1613 |
} |
| 1614 |
|
| 1615 |
static PyObject *CFMutableDataRefObj_CFDataAppendBytes(CFMutableDataRefObject *_self, PyObject *_args) |
| 1616 |
{ |
| 1617 |
PyObject *_res = NULL; |
| 1618 |
unsigned char *bytes__in__; |
| 1619 |
long bytes__len__; |
| 1620 |
int bytes__in_len__; |
| 1621 |
#ifndef CFDataAppendBytes |
| 1622 |
PyMac_PRECHECK(CFDataAppendBytes); |
| 1623 |
#endif |
| 1624 |
if (!PyArg_ParseTuple(_args, "s#", |
| 1625 |
&bytes__in__, &bytes__in_len__)) |
| 1626 |
return NULL; |
| 1627 |
bytes__len__ = bytes__in_len__; |
| 1628 |
CFDataAppendBytes(_self->ob_itself, |
| 1629 |
bytes__in__, bytes__len__); |
| 1630 |
Py_INCREF(Py_None); |
| 1631 |
_res = Py_None; |
| 1632 |
return _res; |
| 1633 |
} |
| 1634 |
|
| 1635 |
static PyObject *CFMutableDataRefObj_CFDataReplaceBytes(CFMutableDataRefObject *_self, PyObject *_args) |
| 1636 |
{ |
| 1637 |
PyObject *_res = NULL; |
| 1638 |
CFRange range; |
| 1639 |
unsigned char *newBytes__in__; |
| 1640 |
long newBytes__len__; |
| 1641 |
int newBytes__in_len__; |
| 1642 |
#ifndef CFDataReplaceBytes |
| 1643 |
PyMac_PRECHECK(CFDataReplaceBytes); |
| 1644 |
#endif |
| 1645 |
if (!PyArg_ParseTuple(_args, "O&s#", |
| 1646 |
CFRange_Convert, &range, |
| 1647 |
&newBytes__in__, &newBytes__in_len__)) |
| 1648 |
return NULL; |
| 1649 |
newBytes__len__ = newBytes__in_len__; |
| 1650 |
CFDataReplaceBytes(_self->ob_itself, |
| 1651 |
range, |
| 1652 |
newBytes__in__, newBytes__len__); |
| 1653 |
Py_INCREF(Py_None); |
| 1654 |
_res = Py_None; |
| 1655 |
return _res; |
| 1656 |
} |
| 1657 |
|
| 1658 |
static PyObject *CFMutableDataRefObj_CFDataDeleteBytes(CFMutableDataRefObject *_self, PyObject *_args) |
| 1659 |
{ |
| 1660 |
PyObject *_res = NULL; |
| 1661 |
CFRange range; |
| 1662 |
#ifndef CFDataDeleteBytes |
| 1663 |
PyMac_PRECHECK(CFDataDeleteBytes); |
| 1664 |
#endif |
| 1665 |
if (!PyArg_ParseTuple(_args, "O&", |
| 1666 |
CFRange_Convert, &range)) |
| 1667 |
return NULL; |
| 1668 |
CFDataDeleteBytes(_self->ob_itself, |
| 1669 |
range); |
| 1670 |
Py_INCREF(Py_None); |
| 1671 |
_res = Py_None; |
| 1672 |
return _res; |
| 1673 |
} |
| 1674 |
|
| 1675 |
static PyMethodDef CFMutableDataRefObj_methods[] = { |
| 1676 |
{"CFDataSetLength", (PyCFunction)CFMutableDataRefObj_CFDataSetLength, 1, |
| 1677 |
PyDoc_STR("(CFIndex length) -> None")}, |
| 1678 |
{"CFDataIncreaseLength", (PyCFunction)CFMutableDataRefObj_CFDataIncreaseLength, 1, |
| 1679 |
PyDoc_STR("(CFIndex extraLength) -> None")}, |
| 1680 |
{"CFDataAppendBytes", (PyCFunction)CFMutableDataRefObj_CFDataAppendBytes, 1, |
| 1681 |
PyDoc_STR("(Buffer bytes) -> None")}, |
| 1682 |
{"CFDataReplaceBytes", (PyCFunction)CFMutableDataRefObj_CFDataReplaceBytes, 1, |
| 1683 |
PyDoc_STR("(CFRange range, Buffer newBytes) -> None")}, |
| 1684 |
{"CFDataDeleteBytes", (PyCFunction)CFMutableDataRefObj_CFDataDeleteBytes, 1, |
| 1685 |
PyDoc_STR("(CFRange range) -> None")}, |
| 1686 |
{NULL, NULL, 0} |
| 1687 |
}; |
| 1688 |
|
| 1689 |
#define CFMutableDataRefObj_getsetlist NULL |
| 1690 |
|
| 1691 |
|
| 1692 |
static int CFMutableDataRefObj_compare(CFMutableDataRefObject *self, CFMutableDataRefObject *other) |
| 1693 |
{ |
| 1694 |
|
| 1695 |
if ( self->ob_itself > other->ob_itself ) return 1; |
| 1696 |
if ( self->ob_itself < other->ob_itself ) return -1; |
| 1697 |
return 0; |
| 1698 |
} |
| 1699 |
|
| 1700 |
static PyObject * CFMutableDataRefObj_repr(CFMutableDataRefObject *self) |
| 1701 |
{ |
| 1702 |
char buf[100]; |
| 1703 |
sprintf(buf, "<CFMutableDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself); |
| 1704 |
return PyString_FromString(buf); |
| 1705 |
} |
| 1706 |
|
| 1707 |
static int CFMutableDataRefObj_hash(CFMutableDataRefObject *self) |
| 1708 |
{ |
| 1709 |
|
| 1710 |
return (int)self->ob_itself; |
| 1711 |
} |
| 1712 |
static int CFMutableDataRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
| 1713 |
{ |
| 1714 |
CFMutableDataRef itself; |
| 1715 |
char *kw[] = {"itself", 0}; |
| 1716 |
|
| 1717 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFMutableDataRefObj_Convert, &itself)) |
| 1718 |
{ |
| 1719 |
((CFMutableDataRefObject *)_self)->ob_itself = itself; |
| 1720 |
return 0; |
| 1721 |
} |
| 1722 |
|
| 1723 |
|
| 1724 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) |
| 1725 |
{ |
| 1726 |
((CFMutableDataRefObject *)_self)->ob_itself = itself; |
| 1727 |
return 0; |
| 1728 |
} |
| 1729 |
return -1; |
| 1730 |
} |
| 1731 |
|
| 1732 |
#define CFMutableDataRefObj_tp_alloc PyType_GenericAlloc |
| 1733 |
|
| 1734 |
static PyObject *CFMutableDataRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 1735 |
{ |
| 1736 |
PyObject *self; |
| 1737 |
if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 1738 |
((CFMutableDataRefObject *)self)->ob_itself = NULL; |
| 1739 |
((CFMutableDataRefObject *)self)->ob_freeit = CFRelease; |
| 1740 |
return self; |
| 1741 |
} |
| 1742 |
|
| 1743 |
#define CFMutableDataRefObj_tp_free PyObject_Del |
| 1744 |
|
| 1745 |
|
| 1746 |
PyTypeObject CFMutableDataRef_Type = { |
| 1747 |
PyObject_HEAD_INIT(NULL) |
| 1748 |
0, |
| 1749 |
"_CF.CFMutableDataRef", |
| 1750 |
sizeof(CFMutableDataRefObject), |
| 1751 |
0, |
| 1752 |
|
| 1753 |
(destructor) CFMutableDataRefObj_dealloc, |
| 1754 |
0, |
| 1755 |
(getattrfunc)0, |
| 1756 |
(setattrfunc)0, |
| 1757 |
(cmpfunc) CFMutableDataRefObj_compare, |
| 1758 |
(reprfunc) CFMutableDataRefObj_repr, |
| 1759 |
(PyNumberMethods *)0, |
| 1760 |
(PySequenceMethods *)0, |
| 1761 |
(PyMappingMethods *)0, |
| 1762 |
(hashfunc) CFMutableDataRefObj_hash, |
| 1763 |
0, |
| 1764 |
0, |
| 1765 |
PyObject_GenericGetAttr, |
| 1766 |
PyObject_GenericSetAttr, |
| 1767 |
0, |
| 1768 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 1769 |
0, |
| 1770 |
0, |
| 1771 |
0, |
| 1772 |
0, |
| 1773 |
0, |
| 1774 |
0, |
| 1775 |
0, |
| 1776 |
CFMutableDataRefObj_methods, |
| 1777 |
0, |
| 1778 |
CFMutableDataRefObj_getsetlist, |
| 1779 |
0, |
| 1780 |
0, |
| 1781 |
0, |
| 1782 |
0, |
| 1783 |
0, |
| 1784 |
CFMutableDataRefObj_tp_init, |
| 1785 |
CFMutableDataRefObj_tp_alloc, |
| 1786 |
CFMutableDataRefObj_tp_new, |
| 1787 |
CFMutableDataRefObj_tp_free, |
| 1788 |
}; |
| 1789 |
|
| 1790 |
|
| 1791 |
|
| 1792 |
|
| 1793 |
|
| 1794 |
|
| 1795 |
PyTypeObject CFStringRef_Type; |
| 1796 |
|
| 1797 |
#define CFStringRefObj_Check(x) ((x)->ob_type == &CFStringRef_Type || PyObject_TypeCheck((x), &CFStringRef_Type)) |
| 1798 |
|
| 1799 |
typedef struct CFStringRefObject { |
| 1800 |
PyObject_HEAD |
| 1801 |
CFStringRef ob_itself; |
| 1802 |
void (*ob_freeit)(CFTypeRef ptr); |
| 1803 |
} CFStringRefObject; |
| 1804 |
|
| 1805 |
PyObject *CFStringRefObj_New(CFStringRef itself) |
| 1806 |
{ |
| 1807 |
CFStringRefObject *it; |
| 1808 |
if (itself == NULL) |
| 1809 |
{ |
| 1810 |
PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); |
| 1811 |
return NULL; |
| 1812 |
} |
| 1813 |
it = PyObject_NEW(CFStringRefObject, &CFStringRef_Type); |
| 1814 |
if (it == NULL) return NULL; |
| 1815 |
|
| 1816 |
it->ob_itself = itself; |
| 1817 |
it->ob_freeit = CFRelease; |
| 1818 |
return (PyObject *)it; |
| 1819 |
} |
| 1820 |
|
| 1821 |
int CFStringRefObj_Convert(PyObject *v, CFStringRef *p_itself) |
| 1822 |
{ |
| 1823 |
|
| 1824 |
if (v == Py_None) { *p_itself = NULL; return 1; } |
| 1825 |
if (PyString_Check(v)) { |
| 1826 |
char *cStr; |
| 1827 |
if (!PyArg_Parse(v, "es", "ascii", &cStr)) |
| 1828 |
return 0; |
| 1829 |
*p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, kCFStringEncodingASCII); |
| 1830 |
PyMem_Free(cStr); |
| 1831 |
return 1; |
| 1832 |
} |
| 1833 |
if (PyUnicode_Check(v)) { |
| 1834 |
|
| 1835 |
CFIndex size = PyUnicode_GetSize(v); |
| 1836 |
UniChar *unichars = PyUnicode_AsUnicode(v); |
| 1837 |
if (!unichars) return 0; |
| 1838 |
*p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size); |
| 1839 |
return 1; |
| 1840 |
} |
| 1841 |
|
| 1842 |
|
| 1843 |
if (!CFStringRefObj_Check(v)) |
| 1844 |
{ |
| 1845 |
PyErr_SetString(PyExc_TypeError, "CFStringRef required"); |
| 1846 |
return 0; |
| 1847 |
} |
| 1848 |
*p_itself = ((CFStringRefObject *)v)->ob_itself; |
| 1849 |
return 1; |
| 1850 |
} |
| 1851 |
|
| 1852 |
static void CFStringRefObj_dealloc(CFStringRefObject *self) |
| 1853 |
{ |
| 1854 |
if (self->ob_freeit && self->ob_itself) |
| 1855 |
{ |
| 1856 |
self->ob_freeit((CFTypeRef)self->ob_itself); |
| 1857 |
self->ob_itself = NULL; |
| 1858 |
} |
| 1859 |
CFTypeRef_Type.tp_dealloc((PyObject *)self); |
| 1860 |
} |
| 1861 |
|
| 1862 |
static PyObject *CFStringRefObj_CFStringCreateWithSubstring(CFStringRefObject *_self, PyObject *_args) |
| 1863 |
{ |
| 1864 |
PyObject *_res = NULL; |
| 1865 |
CFStringRef _rv; |
| 1866 |
CFRange range; |
| 1867 |
if (!PyArg_ParseTuple(_args, "O&", |
| 1868 |
CFRange_Convert, &range)) |
| 1869 |
return NULL; |
| 1870 |
_rv = CFStringCreateWithSubstring((CFAllocatorRef)NULL, |
| 1871 |
_self->ob_itself, |
| 1872 |
range); |
| 1873 |
_res = Py_BuildValue("O&", |
| 1874 |
CFStringRefObj_New, _rv); |
| 1875 |
return _res; |
| 1876 |
} |
| 1877 |
|
| 1878 |
static PyObject *CFStringRefObj_CFStringCreateCopy(CFStringRefObject *_self, PyObject *_args) |
| 1879 |
{ |
| 1880 |
PyObject *_res = NULL; |
| 1881 |
CFStringRef _rv; |
| 1882 |
if (!PyArg_ParseTuple(_args, "")) |
| 1883 |
return NULL; |
| 1884 |
_rv = CFStringCreateCopy((CFAllocatorRef)NULL, |
| 1885 |
_self->ob_itself); |
| 1886 |
_res = Py_BuildValue("O&", |
| 1887 |
CFStringRefObj_New, _rv); |
| 1888 |
return _res; |
| 1889 |
} |
| 1890 |
|
| 1891 |
static PyObject *CFStringRefObj_CFStringGetLength(CFStringRefObject *_self, PyObject *_args) |
| 1892 |
{ |
| 1893 |
PyObject *_res = NULL; |
| 1894 |
CFIndex _rv; |
| 1895 |
#ifndef CFStringGetLength |
| 1896 |
PyMac_PRECHECK(CFStringGetLength); |
| 1897 |
#endif |
| 1898 |
if (!PyArg_ParseTuple(_args, "")) |
| 1899 |
return NULL; |
| 1900 |
_rv = CFStringGetLength(_self->ob_itself); |
| 1901 |
_res = Py_BuildValue("l", |
| 1902 |
_rv); |
| 1903 |
return _res; |
| 1904 |
} |
| 1905 |
|
| 1906 |
static PyObject *CFStringRefObj_CFStringGetBytes(CFStringRefObject *_self, PyObject *_args) |
| 1907 |
{ |
| 1908 |
PyObject *_res = NULL; |
| 1909 |
CFIndex _rv; |
| 1910 |
CFRange range; |
| 1911 |
CFStringEncoding encoding; |
| 1912 |
UInt8 lossByte; |
| 1913 |
Boolean isExternalRepresentation; |
| 1914 |
UInt8 buffer; |
| 1915 |
CFIndex maxBufLen; |
| 1916 |
CFIndex usedBufLen; |
| 1917 |
#ifndef CFStringGetBytes |
| 1918 |
PyMac_PRECHECK(CFStringGetBytes); |
| 1919 |
#endif |
| 1920 |
if (!PyArg_ParseTuple(_args, "O&lbll", |
| 1921 |
CFRange_Convert, &range, |
| 1922 |
&encoding, |
| 1923 |
&lossByte, |
| 1924 |
&isExternalRepresentation, |
| 1925 |
&maxBufLen)) |
| 1926 |
return NULL; |
| 1927 |
_rv = CFStringGetBytes(_self->ob_itself, |
| 1928 |
range, |
| 1929 |
encoding, |
| 1930 |
lossByte, |
| 1931 |
isExternalRepresentation, |
| 1932 |
&buffer, |
| 1933 |
maxBufLen, |
| 1934 |
&usedBufLen); |
| 1935 |
_res = Py_BuildValue("lbl", |
| 1936 |
_rv, |
| 1937 |
buffer, |
| 1938 |
usedBufLen); |
| 1939 |
return _res; |
| 1940 |
} |
| 1941 |
|
| 1942 |
static PyObject *CFStringRefObj_CFStringCreateExternalRepresentation(CFStringRefObject *_self, PyObject *_args) |
| 1943 |
{ |
| 1944 |
PyObject *_res = NULL; |
| 1945 |
CFDataRef _rv; |
| 1946 |
CFStringEncoding encoding; |
| 1947 |
UInt8 lossByte; |
| 1948 |
if (!PyArg_ParseTuple(_args, "lb", |
| 1949 |
&encoding, |
| 1950 |
&lossByte)) |
| 1951 |
return NULL; |
| 1952 |
_rv = CFStringCreateExternalRepresentation((CFAllocatorRef)NULL, |
| 1953 |
_self->ob_itself, |
| 1954 |
encoding, |
| 1955 |
lossByte); |
| 1956 |
_res = Py_BuildValue("O&", |
| 1957 |
CFDataRefObj_New, _rv); |
| 1958 |
return _res; |
| 1959 |
} |
| 1960 |
|
| 1961 |
static PyObject *CFStringRefObj_CFStringGetSmallestEncoding(CFStringRefObject *_self, PyObject *_args) |
| 1962 |
{ |
| 1963 |
PyObject *_res = NULL; |
| 1964 |
CFStringEncoding _rv; |
| 1965 |
#ifndef CFStringGetSmallestEncoding |
| 1966 |
PyMac_PRECHECK(CFStringGetSmallestEncoding); |
| 1967 |
#endif |
| 1968 |
if (!PyArg_ParseTuple(_args, "")) |
| 1969 |
return NULL; |
| 1970 |
_rv = CFStringGetSmallestEncoding(_self->ob_itself); |
| 1971 |
_res = Py_BuildValue("l", |
| 1972 |
_rv); |
| 1973 |
return _res; |
| 1974 |
} |
| 1975 |
|
| 1976 |
static PyObject *CFStringRefObj_CFStringGetFastestEncoding(CFStringRefObject *_self, PyObject *_args) |
| 1977 |
{ |
| 1978 |
PyObject *_res = NULL; |
| 1979 |
CFStringEncoding _rv; |
| 1980 |
#ifndef CFStringGetFastestEncoding |
| 1981 |
PyMac_PRECHECK(CFStringGetFastestEncoding); |
| 1982 |
#endif |
| 1983 |
if (!PyArg_ParseTuple(_args, "")) |
| 1984 |
return NULL; |
| 1985 |
_rv = CFStringGetFastestEncoding(_self->ob_itself); |
| 1986 |
_res = Py_BuildValue("l", |
| 1987 |
_rv); |
| 1988 |
return _res; |
| 1989 |
} |
| 1990 |
|
| 1991 |
static PyObject *CFStringRefObj_CFStringCompareWithOptions(CFStringRefObject *_self, PyObject *_args) |
| 1992 |
{ |
| 1993 |
PyObject *_res = NULL; |
| 1994 |
CFComparisonResult _rv; |
| 1995 |
CFStringRef theString2; |
| 1996 |
CFRange rangeToCompare; |
| 1997 |
CFOptionFlags compareOptions; |
| 1998 |
#ifndef CFStringCompareWithOptions |
| 1999 |
PyMac_PRECHECK(CFStringCompareWithOptions); |
| 2000 |
#endif |
| 2001 |
if (!PyArg_ParseTuple(_args, "O&O&l", |
| 2002 |
CFStringRefObj_Convert, &theString2, |
| 2003 |
CFRange_Convert, &rangeToCompare, |
| 2004 |
&compareOptions)) |
| 2005 |
return NULL; |
| 2006 |
_rv = CFStringCompareWithOptions(_self->ob_itself, |
| 2007 |
theString2, |
| 2008 |
rangeToCompare, |
| 2009 |
compareOptions); |
| 2010 |
_res = Py_BuildValue("l", |
| 2011 |
_rv); |
| 2012 |
return _res; |
| 2013 |
} |
| 2014 |
|
| 2015 |
static PyObject *CFStringRefObj_CFStringCompare(CFStringRefObject *_self, PyObject *_args) |
| 2016 |
{ |
| 2017 |
PyObject *_res = NULL; |
| 2018 |
CFComparisonResult _rv; |
| 2019 |
CFStringRef theString2; |
| 2020 |
CFOptionFlags compareOptions; |
| 2021 |
#ifndef CFStringCompare |
| 2022 |
PyMac_PRECHECK(CFStringCompare); |
| 2023 |
#endif |
| 2024 |
if (!PyArg_ParseTuple(_args, "O&l", |
| 2025 |
CFStringRefObj_Convert, &theString2, |
| 2026 |
&compareOptions)) |
| 2027 |
return NULL; |
| 2028 |
_rv = CFStringCompare(_self->ob_itself, |
| 2029 |
theString2, |
| 2030 |
compareOptions); |
| 2031 |
_res = Py_BuildValue("l", |
| 2032 |
_rv); |
| 2033 |
return _res; |
| 2034 |
} |
| 2035 |
|
| 2036 |
static PyObject *CFStringRefObj_CFStringFindWithOptions(CFStringRefObject *_self, PyObject *_args) |
| 2037 |
{ |
| 2038 |
PyObject *_res = NULL; |
| 2039 |
Boolean _rv; |
| 2040 |
CFStringRef stringToFind; |
| 2041 |
CFRange rangeToSearch; |
| 2042 |
CFOptionFlags searchOptions; |
| 2043 |
CFRange result; |
| 2044 |
#ifndef CFStringFindWithOptions |
| 2045 |
PyMac_PRECHECK(CFStringFindWithOptions); |
| 2046 |
#endif |
| 2047 |
if (!PyArg_ParseTuple(_args, "O&O&l", |
| 2048 |
CFStringRefObj_Convert, &stringToFind, |
| 2049 |
CFRange_Convert, &rangeToSearch, |
| 2050 |
&searchOptions)) |
| 2051 |
return NULL; |
| 2052 |
_rv = CFStringFindWithOptions(_self->ob_itself, |
| 2053 |
stringToFind, |
| 2054 |
rangeToSearch, |
| 2055 |
searchOptions, |
| 2056 |
&result); |
| 2057 |
_res = Py_BuildValue("lO&", |
| 2058 |
_rv, |
| 2059 |
CFRange_New, result); |
| 2060 |
return _res; |
| 2061 |
} |
| 2062 |
|
| 2063 |
static PyObject *CFStringRefObj_CFStringCreateArrayWithFindResults(CFStringRefObject *_self, PyObject *_args) |
| 2064 |
{ |
| 2065 |
PyObject *_res = NULL; |
| 2066 |
CFArrayRef _rv; |
| 2067 |
CFStringRef stringToFind; |
| 2068 |
CFRange rangeToSearch; |
| 2069 |
CFOptionFlags compareOptions; |
| 2070 |
if (!PyArg_ParseTuple(_args, "O&O&l", |
| 2071 |
CFStringRefObj_Convert, &stringToFind, |
| 2072 |
CFRange_Convert, &rangeToSearch, |
| 2073 |
&compareOptions)) |
| 2074 |
return NULL; |
| 2075 |
_rv = CFStringCreateArrayWithFindResults((CFAllocatorRef)NULL, |
| 2076 |
_self->ob_itself, |
| 2077 |
stringToFind, |
| 2078 |
rangeToSearch, |
| 2079 |
compareOptions); |
| 2080 |
_res = Py_BuildValue("O&", |
| 2081 |
CFArrayRefObj_New, _rv); |
| 2082 |
return _res; |
| 2083 |
} |
| 2084 |
|
| 2085 |
static PyObject *CFStringRefObj_CFStringFind(CFStringRefObject *_self, PyObject *_args) |
| 2086 |
{ |
| 2087 |
PyObject *_res = NULL; |
| 2088 |
CFRange _rv; |
| 2089 |
CFStringRef stringToFind; |
| 2090 |
CFOptionFlags compareOptions; |
| 2091 |
#ifndef CFStringFind |
| 2092 |
PyMac_PRECHECK(CFStringFind); |
| 2093 |
#endif |
| 2094 |
if (!PyArg_ParseTuple(_args, "O&l", |
| 2095 |
CFStringRefObj_Convert, &stringToFind, |
| 2096 |
&compareOptions)) |
| 2097 |
return NULL; |
| 2098 |
_rv = CFStringFind(_self->ob_itself, |
| 2099 |
stringToFind, |
| 2100 |
compareOptions); |
| 2101 |
_res = Py_BuildValue("O&", |
| 2102 |
CFRange_New, _rv); |
| 2103 |
return _res; |
| 2104 |
} |
| 2105 |
|
| 2106 |
static PyObject *CFStringRefObj_CFStringHasPrefix(CFStringRefObject *_self, PyObject *_args) |
| 2107 |
{ |
| 2108 |
PyObject *_res = NULL; |
| 2109 |
Boolean _rv; |
| 2110 |
CFStringRef prefix; |
| 2111 |
#ifndef CFStringHasPrefix |
| 2112 |
PyMac_PRECHECK(CFStringHasPrefix); |
| 2113 |
#endif |
| 2114 |
if (!PyArg_ParseTuple(_args, "O&", |
| 2115 |
CFStringRefObj_Convert, &prefix)) |
| 2116 |
return NULL; |
| 2117 |
_rv = CFStringHasPrefix(_self->ob_itself, |
| 2118 |
prefix); |
| 2119 |
_res = Py_BuildValue("l", |
| 2120 |
_rv); |
| 2121 |
return _res; |
| 2122 |
} |
| 2123 |
|
| 2124 |
static PyObject *CFStringRefObj_CFStringHasSuffix(CFStringRefObject *_self, PyObject *_args) |
| 2125 |
{ |
| 2126 |
PyObject *_res = NULL; |
| 2127 |
Boolean _rv; |
| 2128 |
CFStringRef suffix; |
| 2129 |
#ifndef CFStringHasSuffix |
| 2130 |
PyMac_PRECHECK(CFStringHasSuffix); |
| 2131 |
#endif |
| 2132 |
if (!PyArg_ParseTuple(_args, "O&", |
| 2133 |
CFStringRefObj_Convert, &suffix)) |
| 2134 |
return NULL; |
| 2135 |
_rv = CFStringHasSuffix(_self->ob_itself, |
| 2136 |
suffix); |
| 2137 |
_res = Py_BuildValue("l", |
| 2138 |
_rv); |
| 2139 |
return _res; |
| 2140 |
} |
| 2141 |
|
| 2142 |
static PyObject *CFStringRefObj_CFStringGetLineBounds(CFStringRefObject *_self, PyObject *_args) |
| 2143 |
{ |
| 2144 |
PyObject *_res = NULL; |
| 2145 |
CFRange range; |
| 2146 |
CFIndex lineBeginIndex; |
| 2147 |
CFIndex lineEndIndex; |
| 2148 |
CFIndex contentsEndIndex; |
| 2149 |
#ifndef CFStringGetLineBounds |
| 2150 |
PyMac_PRECHECK(CFStringGetLineBounds); |
| 2151 |
#endif |
| 2152 |
if (!PyArg_ParseTuple(_args, "O&", |
| 2153 |
CFRange_Convert, &range)) |
| 2154 |
return NULL; |
| 2155 |
CFStringGetLineBounds(_self->ob_itself, |
| 2156 |
range, |
| 2157 |
&lineBeginIndex, |
| 2158 |
&lineEndIndex, |
| 2159 |
&contentsEndIndex); |
| 2160 |
_res = Py_BuildValue("lll", |
| 2161 |
lineBeginIndex, |
| 2162 |
lineEndIndex, |
| 2163 |
contentsEndIndex); |
| 2164 |
return _res; |
| 2165 |
} |
| 2166 |
|
| 2167 |
static PyObject *CFStringRefObj_CFStringCreateArrayBySeparatingStrings(CFStringRefObject *_self, PyObject *_args) |
| 2168 |
{ |
| 2169 |
PyObject *_res = NULL; |
| 2170 |
CFArrayRef _rv; |
| 2171 |
CFStringRef separatorString; |
| 2172 |
if (!PyArg_ParseTuple(_args, "O&", |
| 2173 |
CFStringRefObj_Convert, &separatorString)) |
| 2174 |
return NULL; |
| 2175 |
_rv = CFStringCreateArrayBySeparatingStrings((CFAllocatorRef)NULL, |
| 2176 |
_self->ob_itself, |
| 2177 |
separatorString); |
| 2178 |
_res = Py_BuildValue("O&", |
| 2179 |
CFArrayRefObj_New, _rv); |
| 2180 |
return _res; |
| 2181 |
} |
| 2182 |
|
| 2183 |
static PyObject *CFStringRefObj_CFStringGetIntValue(CFStringRefObject *_self, PyObject *_args) |
| 2184 |
{ |
| 2185 |
PyObject *_res = NULL; |
| 2186 |
SInt32 _rv; |
| 2187 |
#ifndef CFStringGetIntValue |
| 2188 |
PyMac_PRECHECK(CFStringGetIntValue); |
| 2189 |
#endif |
| 2190 |
if (!PyArg_ParseTuple(_args, "")) |
| 2191 |
return NULL; |
| 2192 |
_rv = CFStringGetIntValue(_self->ob_itself); |
| 2193 |
_res = Py_BuildValue("l", |
| 2194 |
_rv); |
| 2195 |
return _res; |
| 2196 |
} |
| 2197 |
|
| 2198 |
static PyObject *CFStringRefObj_CFStringGetDoubleValue(CFStringRefObject *_self, PyObject *_args) |
| 2199 |
{ |
| 2200 |
PyObject *_res = NULL; |
| 2201 |
double _rv; |
| 2202 |
#ifndef CFStringGetDoubleValue |
| 2203 |
PyMac_PRECHECK(CFStringGetDoubleValue); |
| 2204 |
#endif |
| 2205 |
if (!PyArg_ParseTuple(_args, "")) |
| 2206 |
return NULL; |
| 2207 |
_rv = CFStringGetDoubleValue(_self->ob_itself); |
| 2208 |
_res = Py_BuildValue("d", |
| 2209 |
_rv); |
| 2210 |
return _res; |
| 2211 |
} |
| 2212 |
|
| 2213 |
static PyObject *CFStringRefObj_CFStringConvertIANACharSetNameToEncoding(CFStringRefObject *_self, PyObject *_args) |
| 2214 |
{ |
| 2215 |
PyObject *_res = NULL; |
| 2216 |
CFStringEncoding _rv; |
| 2217 |
#ifndef CFStringConvertIANACharSetNameToEncoding |
| 2218 |
PyMac_PRECHECK(CFStringConvertIANACharSetNameToEncoding); |
| 2219 |
#endif |
| 2220 |
if (!PyArg_ParseTuple(_args, "")) |
| 2221 |
return NULL; |
| 2222 |
_rv = CFStringConvertIANACharSetNameToEncoding(_self->ob_itself); |
| 2223 |
_res = Py_BuildValue("l", |
| 2224 |
_rv); |
| 2225 |
return _res; |
| 2226 |
} |
| 2227 |
|
| 2228 |
static PyObject *CFStringRefObj_CFShowStr(CFStringRefObject *_self, PyObject *_args) |
| 2229 |
{ |
| 2230 |
PyObject *_res = NULL; |
| 2231 |
#ifndef CFShowStr |
| 2232 |
PyMac_PRECHECK(CFShowStr); |
| 2233 |
#endif |
| 2234 |
if (!PyArg_ParseTuple(_args, "")) |
| 2235 |
return NULL; |
| 2236 |
CFShowStr(_self->ob_itself); |
| 2237 |
Py_INCREF(Py_None); |
| 2238 |
_res = Py_None; |
| 2239 |
return _res; |
| 2240 |
} |
| 2241 |
|
| 2242 |
static PyObject *CFStringRefObj_CFURLCreateWithString(CFStringRefObject *_self, PyObject *_args) |
| 2243 |
{ |
| 2244 |
PyObject *_res = NULL; |
| 2245 |
CFURLRef _rv; |
| 2246 |
CFURLRef baseURL; |
| 2247 |
if (!PyArg_ParseTuple(_args, "O&", |
| 2248 |
OptionalCFURLRefObj_Convert, &baseURL)) |
| 2249 |
return NULL; |
| 2250 |
_rv = CFURLCreateWithString((CFAllocatorRef)NULL, |
| 2251 |
_self->ob_itself, |
| 2252 |
baseURL); |
| 2253 |
_res = Py_BuildValue("O&", |
| 2254 |
CFURLRefObj_New, _rv); |
| 2255 |
return _res; |
| 2256 |
} |
| 2257 |
|
| 2258 |
static PyObject *CFStringRefObj_CFURLCreateWithFileSystemPath(CFStringRefObject *_self, PyObject *_args) |
| 2259 |
{ |
| 2260 |
PyObject *_res = NULL; |
| 2261 |
CFURLRef _rv; |
| 2262 |
CFURLPathStyle pathStyle; |
| 2263 |
Boolean isDirectory; |
| 2264 |
if (!PyArg_ParseTuple(_args, "ll", |
| 2265 |
&pathStyle, |
| 2266 |
&isDirectory)) |
| 2267 |
return NULL; |
| 2268 |
_rv = CFURLCreateWithFileSystemPath((CFAllocatorRef)NULL, |
| 2269 |
_self->ob_itself, |
| 2270 |
pathStyle, |
| 2271 |
isDirectory); |
| 2272 |
_res = Py_BuildValue("O&", |
| 2273 |
CFURLRefObj_New, _rv); |
| 2274 |
return _res; |
| 2275 |
} |
| 2276 |
|
| 2277 |
static PyObject *CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase(CFStringRefObject *_self, PyObject *_args) |
| 2278 |
{ |
| 2279 |
PyObject *_res = NULL; |
| 2280 |
CFURLRef _rv; |
| 2281 |
CFURLPathStyle pathStyle; |
| 2282 |
Boolean isDirectory; |
| 2283 |
CFURLRef baseURL; |
| 2284 |
if (!PyArg_ParseTuple(_args, "llO&", |
| 2285 |
&pathStyle, |
| 2286 |
&isDirectory, |
| 2287 |
OptionalCFURLRefObj_Convert, &baseURL)) |
| 2288 |
return NULL; |
| 2289 |
_rv = CFURLCreateWithFileSystemPathRelativeToBase((CFAllocatorRef)NULL, |
| 2290 |
_self->ob_itself, |
| 2291 |
pathStyle, |
| 2292 |
isDirectory, |
| 2293 |
baseURL); |
| 2294 |
_res = Py_BuildValue("O&", |
| 2295 |
CFURLRefObj_New, _rv); |
| 2296 |
return _res; |
| 2297 |
} |
| 2298 |
|
| 2299 |
static PyObject *CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes(CFStringRefObject *_self, PyObject *_args) |
| 2300 |
{ |
| 2301 |
PyObject *_res = NULL; |
| 2302 |
CFStringRef _rv; |
| 2303 |
CFStringRef charactersToLeaveEscaped; |
| 2304 |
if (!PyArg_ParseTuple(_args, "O&", |
| 2305 |
CFStringRefObj_Convert, &charactersToLeaveEscaped)) |
| 2306 |
return NULL; |
| 2307 |
_rv = CFURLCreateStringByReplacingPercentEscapes((CFAllocatorRef)NULL, |
| 2308 |
_self->ob_itself, |
| 2309 |
charactersToLeaveEscaped); |
| 2310 |
_res = Py_BuildValue("O&", |
| 2311 |
CFStringRefObj_New, _rv); |
| 2312 |
return _res; |
| 2313 |
} |
| 2314 |
|
| 2315 |
static PyObject *CFStringRefObj_CFURLCreateStringByAddingPercentEscapes(CFStringRefObject *_self, PyObject *_args) |
| 2316 |
{ |
| 2317 |
PyObject *_res = NULL; |
| 2318 |
CFStringRef _rv; |
| 2319 |
CFStringRef charactersToLeaveUnescaped; |
| 2320 |
CFStringRef legalURLCharactersToBeEscaped; |
| 2321 |
CFStringEncoding encoding; |
| 2322 |
if (!PyArg_ParseTuple(_args, "O&O&l", |
| 2323 |
CFStringRefObj_Convert, &charactersToLeaveUnescaped, |
| 2324 |
CFStringRefObj_Convert, &legalURLCharactersToBeEscaped, |
| 2325 |
&encoding)) |
| 2326 |
return NULL; |
| 2327 |
_rv = CFURLCreateStringByAddingPercentEscapes((CFAllocatorRef)NULL, |
| 2328 |
_self->ob_itself, |
| 2329 |
charactersToLeaveUnescaped, |
| 2330 |
legalURLCharactersToBeEscaped, |
| 2331 |
encoding); |
| 2332 |
_res = Py_BuildValue("O&", |
| 2333 |
CFStringRefObj_New, _rv); |
| 2334 |
return _res; |
| 2335 |
} |
| 2336 |
|
| 2337 |
static PyObject *CFStringRefObj_CFStringGetString(CFStringRefObject *_self, PyObject *_args) |
| 2338 |
{ |
| 2339 |
PyObject *_res = NULL; |
| 2340 |
|
| 2341 |
int size = CFStringGetLength(_self->ob_itself)+1; |
| 2342 |
char *data = malloc(size); |
| 2343 |
|
| 2344 |
if( data == NULL ) return PyErr_NoMemory(); |
| 2345 |
if ( CFStringGetCString(_self->ob_itself, data, size, 0) ) { |
| 2346 |
_res = (PyObject *)PyString_FromString(data); |
| 2347 |
} else { |
| 2348 |
PyErr_SetString(PyExc_RuntimeError, "CFStringGetCString could not fit the string"); |
| 2349 |
_res = NULL; |
| 2350 |
} |
| 2351 |
free(data); |
| 2352 |
return _res; |
| 2353 |
|
| 2354 |
} |
| 2355 |
|
| 2356 |
static PyObject *CFStringRefObj_CFStringGetUnicode(CFStringRefObject *_self, PyObject *_args) |
| 2357 |
{ |
| 2358 |
PyObject *_res = NULL; |
| 2359 |
|
| 2360 |
int size = CFStringGetLength(_self->ob_itself)+1; |
| 2361 |
Py_UNICODE *data = malloc(size*sizeof(Py_UNICODE)); |
| 2362 |
CFRange range; |
| 2363 |
|
| 2364 |
range.location = 0; |
| 2365 |
range.length = size; |
| 2366 |
if( data == NULL ) return PyErr_NoMemory(); |
| 2367 |
CFStringGetCharacters(_self->ob_itself, range, data); |
| 2368 |
_res = (PyObject *)PyUnicode_FromUnicode(data, size-1); |
| 2369 |
free(data); |
| 2370 |
return _res; |
| 2371 |
|
| 2372 |
} |
| 2373 |
|
| 2374 |
static PyMethodDef CFStringRefObj_methods[] = { |
| 2375 |
{"CFStringCreateWithSubstring", (PyCFunction)CFStringRefObj_CFStringCreateWithSubstring, 1, |
| 2376 |
PyDoc_STR("(CFRange range) -> (CFStringRef _rv)")}, |
| 2377 |
{"CFStringCreateCopy", (PyCFunction)CFStringRefObj_CFStringCreateCopy, 1, |
| 2378 |
PyDoc_STR("() -> (CFStringRef _rv)")}, |
| 2379 |
{"CFStringGetLength", (PyCFunction)CFStringRefObj_CFStringGetLength, 1, |
| 2380 |
PyDoc_STR("() -> (CFIndex _rv)")}, |
| 2381 |
{"CFStringGetBytes", (PyCFunction)CFStringRefObj_CFStringGetBytes, 1, |
| 2382 |
PyDoc_STR("(CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, CFIndex maxBufLen) -> (CFIndex _rv, UInt8 buffer, CFIndex usedBufLen)")}, |
| 2383 |
{"CFStringCreateExternalRepresentation", (PyCFunction)CFStringRefObj_CFStringCreateExternalRepresentation, 1, |
| 2384 |
PyDoc_STR("(CFStringEncoding encoding, UInt8 lossByte) -> (CFDataRef _rv)")}, |
| 2385 |
{"CFStringGetSmallestEncoding", (PyCFunction)CFStringRefObj_CFStringGetSmallestEncoding, 1, |
| 2386 |
PyDoc_STR("() -> (CFStringEncoding _rv)")}, |
| 2387 |
{"CFStringGetFastestEncoding", (PyCFunction)CFStringRefObj_CFStringGetFastestEncoding, 1, |
| 2388 |
PyDoc_STR("() -> (CFStringEncoding _rv)")}, |
| 2389 |
{"CFStringCompareWithOptions", (PyCFunction)CFStringRefObj_CFStringCompareWithOptions, 1, |
| 2390 |
PyDoc_STR("(CFStringRef theString2, CFRange rangeToCompare, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)")}, |
| 2391 |
{"CFStringCompare", (PyCFunction)CFStringRefObj_CFStringCompare, 1, |
| 2392 |
PyDoc_STR("(CFStringRef theString2, CFOptionFlags compareOptions) -> (CFComparisonResult _rv)")}, |
| 2393 |
{"CFStringFindWithOptions", (PyCFunction)CFStringRefObj_CFStringFindWithOptions, 1, |
| 2394 |
PyDoc_STR("(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags searchOptions) -> (Boolean _rv, CFRange result)")}, |
| 2395 |
{"CFStringCreateArrayWithFindResults", (PyCFunction)CFStringRefObj_CFStringCreateArrayWithFindResults, 1, |
| 2396 |
PyDoc_STR("(CFStringRef stringToFind, CFRange rangeToSearch, CFOptionFlags compareOptions) -> (CFArrayRef _rv)")}, |
| 2397 |
{"CFStringFind", (PyCFunction)CFStringRefObj_CFStringFind, 1, |
| 2398 |
PyDoc_STR("(CFStringRef stringToFind, CFOptionFlags compareOptions) -> (CFRange _rv)")}, |
| 2399 |
{"CFStringHasPrefix", (PyCFunction)CFStringRefObj_CFStringHasPrefix, 1, |
| 2400 |
PyDoc_STR("(CFStringRef prefix) -> (Boolean _rv)")}, |
| 2401 |
{"CFStringHasSuffix", (PyCFunction)CFStringRefObj_CFStringHasSuffix, 1, |
| 2402 |
PyDoc_STR("(CFStringRef suffix) -> (Boolean _rv)")}, |
| 2403 |
{"CFStringGetLineBounds", (PyCFunction)CFStringRefObj_CFStringGetLineBounds, 1, |
| 2404 |
PyDoc_STR("(CFRange range) -> (CFIndex lineBeginIndex, CFIndex lineEndIndex, CFIndex contentsEndIndex)")}, |
| 2405 |
{"CFStringCreateArrayBySeparatingStrings", (PyCFunction)CFStringRefObj_CFStringCreateArrayBySeparatingStrings, 1, |
| 2406 |
PyDoc_STR("(CFStringRef separatorString) -> (CFArrayRef _rv)")}, |
| 2407 |
{"CFStringGetIntValue", (PyCFunction)CFStringRefObj_CFStringGetIntValue, 1, |
| 2408 |
PyDoc_STR("() -> (SInt32 _rv)")}, |
| 2409 |
{"CFStringGetDoubleValue", (PyCFunction)CFStringRefObj_CFStringGetDoubleValue, 1, |
| 2410 |
PyDoc_STR("() -> (double _rv)")}, |
| 2411 |
{"CFStringConvertIANACharSetNameToEncoding", (PyCFunction)CFStringRefObj_CFStringConvertIANACharSetNameToEncoding, 1, |
| 2412 |
PyDoc_STR("() -> (CFStringEncoding _rv)")}, |
| 2413 |
{"CFShowStr", (PyCFunction)CFStringRefObj_CFShowStr, 1, |
| 2414 |
PyDoc_STR("() -> None")}, |
| 2415 |
{"CFURLCreateWithString", (PyCFunction)CFStringRefObj_CFURLCreateWithString, 1, |
| 2416 |
PyDoc_STR("(CFURLRef baseURL) -> (CFURLRef _rv)")}, |
| 2417 |
{"CFURLCreateWithFileSystemPath", (PyCFunction)CFStringRefObj_CFURLCreateWithFileSystemPath, 1, |
| 2418 |
PyDoc_STR("(CFURLPathStyle pathStyle, Boolean isDirectory) -> (CFURLRef _rv)")}, |
| 2419 |
{"CFURLCreateWithFileSystemPathRelativeToBase", (PyCFunction)CFStringRefObj_CFURLCreateWithFileSystemPathRelativeToBase, 1, |
| 2420 |
PyDoc_STR("(CFURLPathStyle pathStyle, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)")}, |
| 2421 |
{"CFURLCreateStringByReplacingPercentEscapes", (PyCFunction)CFStringRefObj_CFURLCreateStringByReplacingPercentEscapes, 1, |
| 2422 |
PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")}, |
| 2423 |
{"CFURLCreateStringByAddingPercentEscapes", (PyCFunction)CFStringRefObj_CFURLCreateStringByAddingPercentEscapes, 1, |
| 2424 |
PyDoc_STR("(CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding) -> (CFStringRef _rv)")}, |
| 2425 |
{"CFStringGetString", (PyCFunction)CFStringRefObj_CFStringGetString, 1, |
| 2426 |
PyDoc_STR("() -> (string _rv)")}, |
| 2427 |
{"CFStringGetUnicode", (PyCFunction)CFStringRefObj_CFStringGetUnicode, 1, |
| 2428 |
PyDoc_STR("() -> (unicode _rv)")}, |
| 2429 |
{NULL, NULL, 0} |
| 2430 |
}; |
| 2431 |
|
| 2432 |
#define CFStringRefObj_getsetlist NULL |
| 2433 |
|
| 2434 |
|
| 2435 |
static int CFStringRefObj_compare(CFStringRefObject *self, CFStringRefObject *other) |
| 2436 |
{ |
| 2437 |
|
| 2438 |
if ( self->ob_itself > other->ob_itself ) return 1; |
| 2439 |
if ( self->ob_itself < other->ob_itself ) return -1; |
| 2440 |
return 0; |
| 2441 |
} |
| 2442 |
|
| 2443 |
static PyObject * CFStringRefObj_repr(CFStringRefObject *self) |
| 2444 |
{ |
| 2445 |
char buf[100]; |
| 2446 |
sprintf(buf, "<CFStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself); |
| 2447 |
return PyString_FromString(buf); |
| 2448 |
} |
| 2449 |
|
| 2450 |
static int CFStringRefObj_hash(CFStringRefObject *self) |
| 2451 |
{ |
| 2452 |
|
| 2453 |
return (int)self->ob_itself; |
| 2454 |
} |
| 2455 |
static int CFStringRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
| 2456 |
{ |
| 2457 |
CFStringRef itself; |
| 2458 |
char *kw[] = {"itself", 0}; |
| 2459 |
|
| 2460 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFStringRefObj_Convert, &itself)) |
| 2461 |
{ |
| 2462 |
((CFStringRefObject *)_self)->ob_itself = itself; |
| 2463 |
return 0; |
| 2464 |
} |
| 2465 |
|
| 2466 |
|
| 2467 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) |
| 2468 |
{ |
| 2469 |
((CFStringRefObject *)_self)->ob_itself = itself; |
| 2470 |
return 0; |
| 2471 |
} |
| 2472 |
return -1; |
| 2473 |
} |
| 2474 |
|
| 2475 |
#define CFStringRefObj_tp_alloc PyType_GenericAlloc |
| 2476 |
|
| 2477 |
static PyObject *CFStringRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 2478 |
{ |
| 2479 |
PyObject *self; |
| 2480 |
if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 2481 |
((CFStringRefObject *)self)->ob_itself = NULL; |
| 2482 |
((CFStringRefObject *)self)->ob_freeit = CFRelease; |
| 2483 |
return self; |
| 2484 |
} |
| 2485 |
|
| 2486 |
#define CFStringRefObj_tp_free PyObject_Del |
| 2487 |
|
| 2488 |
|
| 2489 |
PyTypeObject CFStringRef_Type = { |
| 2490 |
PyObject_HEAD_INIT(NULL) |
| 2491 |
0, |
| 2492 |
"_CF.CFStringRef", |
| 2493 |
sizeof(CFStringRefObject), |
| 2494 |
0, |
| 2495 |
|
| 2496 |
(destructor) CFStringRefObj_dealloc, |
| 2497 |
0, |
| 2498 |
(getattrfunc)0, |
| 2499 |
(setattrfunc)0, |
| 2500 |
(cmpfunc) CFStringRefObj_compare, |
| 2501 |
(reprfunc) CFStringRefObj_repr, |
| 2502 |
(PyNumberMethods *)0, |
| 2503 |
(PySequenceMethods *)0, |
| 2504 |
(PyMappingMethods *)0, |
| 2505 |
(hashfunc) CFStringRefObj_hash, |
| 2506 |
0, |
| 2507 |
0, |
| 2508 |
PyObject_GenericGetAttr, |
| 2509 |
PyObject_GenericSetAttr, |
| 2510 |
0, |
| 2511 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 2512 |
0, |
| 2513 |
0, |
| 2514 |
0, |
| 2515 |
0, |
| 2516 |
0, |
| 2517 |
0, |
| 2518 |
0, |
| 2519 |
CFStringRefObj_methods, |
| 2520 |
0, |
| 2521 |
CFStringRefObj_getsetlist, |
| 2522 |
0, |
| 2523 |
0, |
| 2524 |
0, |
| 2525 |
0, |
| 2526 |
0, |
| 2527 |
CFStringRefObj_tp_init, |
| 2528 |
CFStringRefObj_tp_alloc, |
| 2529 |
CFStringRefObj_tp_new, |
| 2530 |
CFStringRefObj_tp_free, |
| 2531 |
}; |
| 2532 |
|
| 2533 |
|
| 2534 |
|
| 2535 |
|
| 2536 |
|
| 2537 |
|
| 2538 |
PyTypeObject CFMutableStringRef_Type; |
| 2539 |
|
| 2540 |
#define CFMutableStringRefObj_Check(x) ((x)->ob_type == &CFMutableStringRef_Type || PyObject_TypeCheck((x), &CFMutableStringRef_Type)) |
| 2541 |
|
| 2542 |
typedef struct CFMutableStringRefObject { |
| 2543 |
PyObject_HEAD |
| 2544 |
CFMutableStringRef ob_itself; |
| 2545 |
void (*ob_freeit)(CFTypeRef ptr); |
| 2546 |
} CFMutableStringRefObject; |
| 2547 |
|
| 2548 |
PyObject *CFMutableStringRefObj_New(CFMutableStringRef itself) |
| 2549 |
{ |
| 2550 |
CFMutableStringRefObject *it; |
| 2551 |
if (itself == NULL) |
| 2552 |
{ |
| 2553 |
PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); |
| 2554 |
return NULL; |
| 2555 |
} |
| 2556 |
it = PyObject_NEW(CFMutableStringRefObject, &CFMutableStringRef_Type); |
| 2557 |
if (it == NULL) return NULL; |
| 2558 |
|
| 2559 |
it->ob_itself = itself; |
| 2560 |
it->ob_freeit = CFRelease; |
| 2561 |
return (PyObject *)it; |
| 2562 |
} |
| 2563 |
|
| 2564 |
int CFMutableStringRefObj_Convert(PyObject *v, CFMutableStringRef *p_itself) |
| 2565 |
{ |
| 2566 |
|
| 2567 |
if (v == Py_None) { *p_itself = NULL; return 1; } |
| 2568 |
|
| 2569 |
|
| 2570 |
if (!CFMutableStringRefObj_Check(v)) |
| 2571 |
{ |
| 2572 |
PyErr_SetString(PyExc_TypeError, "CFMutableStringRef required"); |
| 2573 |
return 0; |
| 2574 |
} |
| 2575 |
*p_itself = ((CFMutableStringRefObject *)v)->ob_itself; |
| 2576 |
return 1; |
| 2577 |
} |
| 2578 |
|
| 2579 |
static void CFMutableStringRefObj_dealloc(CFMutableStringRefObject *self) |
| 2580 |
{ |
| 2581 |
if (self->ob_freeit && self->ob_itself) |
| 2582 |
{ |
| 2583 |
self->ob_freeit((CFTypeRef)self->ob_itself); |
| 2584 |
self->ob_itself = NULL; |
| 2585 |
} |
| 2586 |
CFStringRef_Type.tp_dealloc((PyObject *)self); |
| 2587 |
} |
| 2588 |
|
| 2589 |
static PyObject *CFMutableStringRefObj_CFStringAppend(CFMutableStringRefObject *_self, PyObject *_args) |
| 2590 |
{ |
| 2591 |
PyObject *_res = NULL; |
| 2592 |
CFStringRef appendedString; |
| 2593 |
#ifndef CFStringAppend |
| 2594 |
PyMac_PRECHECK(CFStringAppend); |
| 2595 |
#endif |
| 2596 |
if (!PyArg_ParseTuple(_args, "O&", |
| 2597 |
CFStringRefObj_Convert, &appendedString)) |
| 2598 |
return NULL; |
| 2599 |
CFStringAppend(_self->ob_itself, |
| 2600 |
appendedString); |
| 2601 |
Py_INCREF(Py_None); |
| 2602 |
_res = Py_None; |
| 2603 |
return _res; |
| 2604 |
} |
| 2605 |
|
| 2606 |
static PyObject *CFMutableStringRefObj_CFStringAppendCharacters(CFMutableStringRefObject *_self, PyObject *_args) |
| 2607 |
{ |
| 2608 |
PyObject *_res = NULL; |
| 2609 |
UniChar *chars__in__; |
| 2610 |
UniCharCount chars__len__; |
| 2611 |
int chars__in_len__; |
| 2612 |
#ifndef CFStringAppendCharacters |
| 2613 |
PyMac_PRECHECK(CFStringAppendCharacters); |
| 2614 |
#endif |
| 2615 |
if (!PyArg_ParseTuple(_args, "u#", |
| 2616 |
&chars__in__, &chars__in_len__)) |
| 2617 |
return NULL; |
| 2618 |
chars__len__ = chars__in_len__; |
| 2619 |
CFStringAppendCharacters(_self->ob_itself, |
| 2620 |
chars__in__, chars__len__); |
| 2621 |
Py_INCREF(Py_None); |
| 2622 |
_res = Py_None; |
| 2623 |
return _res; |
| 2624 |
} |
| 2625 |
|
| 2626 |
static PyObject *CFMutableStringRefObj_CFStringAppendPascalString(CFMutableStringRefObject *_self, PyObject *_args) |
| 2627 |
{ |
| 2628 |
PyObject *_res = NULL; |
| 2629 |
Str255 pStr; |
| 2630 |
CFStringEncoding encoding; |
| 2631 |
#ifndef CFStringAppendPascalString |
| 2632 |
PyMac_PRECHECK(CFStringAppendPascalString); |
| 2633 |
#endif |
| 2634 |
if (!PyArg_ParseTuple(_args, "O&l", |
| 2635 |
PyMac_GetStr255, pStr, |
| 2636 |
&encoding)) |
| 2637 |
return NULL; |
| 2638 |
CFStringAppendPascalString(_self->ob_itself, |
| 2639 |
pStr, |
| 2640 |
encoding); |
| 2641 |
Py_INCREF(Py_None); |
| 2642 |
_res = Py_None; |
| 2643 |
return _res; |
| 2644 |
} |
| 2645 |
|
| 2646 |
static PyObject *CFMutableStringRefObj_CFStringAppendCString(CFMutableStringRefObject *_self, PyObject *_args) |
| 2647 |
{ |
| 2648 |
PyObject *_res = NULL; |
| 2649 |
char* cStr; |
| 2650 |
CFStringEncoding encoding; |
| 2651 |
#ifndef CFStringAppendCString |
| 2652 |
PyMac_PRECHECK(CFStringAppendCString); |
| 2653 |
#endif |
| 2654 |
if (!PyArg_ParseTuple(_args, "sl", |
| 2655 |
&cStr, |
| 2656 |
&encoding)) |
| 2657 |
return NULL; |
| 2658 |
CFStringAppendCString(_self->ob_itself, |
| 2659 |
cStr, |
| 2660 |
encoding); |
| 2661 |
Py_INCREF(Py_None); |
| 2662 |
_res = Py_None; |
| 2663 |
return _res; |
| 2664 |
} |
| 2665 |
|
| 2666 |
static PyObject *CFMutableStringRefObj_CFStringInsert(CFMutableStringRefObject *_self, PyObject *_args) |
| 2667 |
{ |
| 2668 |
PyObject *_res = NULL; |
| 2669 |
CFIndex idx; |
| 2670 |
CFStringRef insertedStr; |
| 2671 |
#ifndef CFStringInsert |
| 2672 |
PyMac_PRECHECK(CFStringInsert); |
| 2673 |
#endif |
| 2674 |
if (!PyArg_ParseTuple(_args, "lO&", |
| 2675 |
&idx, |
| 2676 |
CFStringRefObj_Convert, &insertedStr)) |
| 2677 |
return NULL; |
| 2678 |
CFStringInsert(_self->ob_itself, |
| 2679 |
idx, |
| 2680 |
insertedStr); |
| 2681 |
Py_INCREF(Py_None); |
| 2682 |
_res = Py_None; |
| 2683 |
return _res; |
| 2684 |
} |
| 2685 |
|
| 2686 |
static PyObject *CFMutableStringRefObj_CFStringDelete(CFMutableStringRefObject *_self, PyObject *_args) |
| 2687 |
{ |
| 2688 |
PyObject *_res = NULL; |
| 2689 |
CFRange range; |
| 2690 |
#ifndef CFStringDelete |
| 2691 |
PyMac_PRECHECK(CFStringDelete); |
| 2692 |
#endif |
| 2693 |
if (!PyArg_ParseTuple(_args, "O&", |
| 2694 |
CFRange_Convert, &range)) |
| 2695 |
return NULL; |
| 2696 |
CFStringDelete(_self->ob_itself, |
| 2697 |
range); |
| 2698 |
Py_INCREF(Py_None); |
| 2699 |
_res = Py_None; |
| 2700 |
return _res; |
| 2701 |
} |
| 2702 |
|
| 2703 |
static PyObject *CFMutableStringRefObj_CFStringReplace(CFMutableStringRefObject *_self, PyObject *_args) |
| 2704 |
{ |
| 2705 |
PyObject *_res = NULL; |
| 2706 |
CFRange range; |
| 2707 |
CFStringRef replacement; |
| 2708 |
#ifndef CFStringReplace |
| 2709 |
PyMac_PRECHECK(CFStringReplace); |
| 2710 |
#endif |
| 2711 |
if (!PyArg_ParseTuple(_args, "O&O&", |
| 2712 |
CFRange_Convert, &range, |
| 2713 |
CFStringRefObj_Convert, &replacement)) |
| 2714 |
return NULL; |
| 2715 |
CFStringReplace(_self->ob_itself, |
| 2716 |
range, |
| 2717 |
replacement); |
| 2718 |
Py_INCREF(Py_None); |
| 2719 |
_res = Py_None; |
| 2720 |
return _res; |
| 2721 |
} |
| 2722 |
|
| 2723 |
static PyObject *CFMutableStringRefObj_CFStringReplaceAll(CFMutableStringRefObject *_self, PyObject *_args) |
| 2724 |
{ |
| 2725 |
PyObject *_res = NULL; |
| 2726 |
CFStringRef replacement; |
| 2727 |
#ifndef CFStringReplaceAll |
| 2728 |
PyMac_PRECHECK(CFStringReplaceAll); |
| 2729 |
#endif |
| 2730 |
if (!PyArg_ParseTuple(_args, "O&", |
| 2731 |
CFStringRefObj_Convert, &replacement)) |
| 2732 |
return NULL; |
| 2733 |
CFStringReplaceAll(_self->ob_itself, |
| 2734 |
replacement); |
| 2735 |
Py_INCREF(Py_None); |
| 2736 |
_res = Py_None; |
| 2737 |
return _res; |
| 2738 |
} |
| 2739 |
|
| 2740 |
static PyObject *CFMutableStringRefObj_CFStringPad(CFMutableStringRefObject *_self, PyObject *_args) |
| 2741 |
{ |
| 2742 |
PyObject *_res = NULL; |
| 2743 |
CFStringRef padString; |
| 2744 |
CFIndex length; |
| 2745 |
CFIndex indexIntoPad; |
| 2746 |
#ifndef CFStringPad |
| 2747 |
PyMac_PRECHECK(CFStringPad); |
| 2748 |
#endif |
| 2749 |
if (!PyArg_ParseTuple(_args, "O&ll", |
| 2750 |
CFStringRefObj_Convert, &padString, |
| 2751 |
&length, |
| 2752 |
&indexIntoPad)) |
| 2753 |
return NULL; |
| 2754 |
CFStringPad(_self->ob_itself, |
| 2755 |
padString, |
| 2756 |
length, |
| 2757 |
indexIntoPad); |
| 2758 |
Py_INCREF(Py_None); |
| 2759 |
_res = Py_None; |
| 2760 |
return _res; |
| 2761 |
} |
| 2762 |
|
| 2763 |
static PyObject *CFMutableStringRefObj_CFStringTrim(CFMutableStringRefObject *_self, PyObject *_args) |
| 2764 |
{ |
| 2765 |
PyObject *_res = NULL; |
| 2766 |
CFStringRef trimString; |
| 2767 |
#ifndef CFStringTrim |
| 2768 |
PyMac_PRECHECK(CFStringTrim); |
| 2769 |
#endif |
| 2770 |
if (!PyArg_ParseTuple(_args, "O&", |
| 2771 |
CFStringRefObj_Convert, &trimString)) |
| 2772 |
return NULL; |
| 2773 |
CFStringTrim(_self->ob_itself, |
| 2774 |
trimString); |
| 2775 |
Py_INCREF(Py_None); |
| 2776 |
_res = Py_None; |
| 2777 |
return _res; |
| 2778 |
} |
| 2779 |
|
| 2780 |
static PyObject *CFMutableStringRefObj_CFStringTrimWhitespace(CFMutableStringRefObject *_self, PyObject *_args) |
| 2781 |
{ |
| 2782 |
PyObject *_res = NULL; |
| 2783 |
#ifndef CFStringTrimWhitespace |
| 2784 |
PyMac_PRECHECK(CFStringTrimWhitespace); |
| 2785 |
#endif |
| 2786 |
if (!PyArg_ParseTuple(_args, "")) |
| 2787 |
return NULL; |
| 2788 |
CFStringTrimWhitespace(_self->ob_itself); |
| 2789 |
Py_INCREF(Py_None); |
| 2790 |
_res = Py_None; |
| 2791 |
return _res; |
| 2792 |
} |
| 2793 |
|
| 2794 |
static PyMethodDef CFMutableStringRefObj_methods[] = { |
| 2795 |
{"CFStringAppend", (PyCFunction)CFMutableStringRefObj_CFStringAppend, 1, |
| 2796 |
PyDoc_STR("(CFStringRef appendedString) -> None")}, |
| 2797 |
{"CFStringAppendCharacters", (PyCFunction)CFMutableStringRefObj_CFStringAppendCharacters, 1, |
| 2798 |
PyDoc_STR("(Buffer chars) -> None")}, |
| 2799 |
{"CFStringAppendPascalString", (PyCFunction)CFMutableStringRefObj_CFStringAppendPascalString, 1, |
| 2800 |
PyDoc_STR("(Str255 pStr, CFStringEncoding encoding) -> None")}, |
| 2801 |
{"CFStringAppendCString", (PyCFunction)CFMutableStringRefObj_CFStringAppendCString, 1, |
| 2802 |
PyDoc_STR("(char* cStr, CFStringEncoding encoding) -> None")}, |
| 2803 |
{"CFStringInsert", (PyCFunction)CFMutableStringRefObj_CFStringInsert, 1, |
| 2804 |
PyDoc_STR("(CFIndex idx, CFStringRef insertedStr) -> None")}, |
| 2805 |
{"CFStringDelete", (PyCFunction)CFMutableStringRefObj_CFStringDelete, 1, |
| 2806 |
PyDoc_STR("(CFRange range) -> None")}, |
| 2807 |
{"CFStringReplace", (PyCFunction)CFMutableStringRefObj_CFStringReplace, 1, |
| 2808 |
PyDoc_STR("(CFRange range, CFStringRef replacement) -> None")}, |
| 2809 |
{"CFStringReplaceAll", (PyCFunction)CFMutableStringRefObj_CFStringReplaceAll, 1, |
| 2810 |
PyDoc_STR("(CFStringRef replacement) -> None")}, |
| 2811 |
{"CFStringPad", (PyCFunction)CFMutableStringRefObj_CFStringPad, 1, |
| 2812 |
PyDoc_STR("(CFStringRef padString, CFIndex length, CFIndex indexIntoPad) -> None")}, |
| 2813 |
{"CFStringTrim", (PyCFunction)CFMutableStringRefObj_CFStringTrim, 1, |
| 2814 |
PyDoc_STR("(CFStringRef trimString) -> None")}, |
| 2815 |
{"CFStringTrimWhitespace", (PyCFunction)CFMutableStringRefObj_CFStringTrimWhitespace, 1, |
| 2816 |
PyDoc_STR("() -> None")}, |
| 2817 |
{NULL, NULL, 0} |
| 2818 |
}; |
| 2819 |
|
| 2820 |
#define CFMutableStringRefObj_getsetlist NULL |
| 2821 |
|
| 2822 |
|
| 2823 |
static int CFMutableStringRefObj_compare(CFMutableStringRefObject *self, CFMutableStringRefObject *other) |
| 2824 |
{ |
| 2825 |
|
| 2826 |
if ( self->ob_itself > other->ob_itself ) return 1; |
| 2827 |
if ( self->ob_itself < other->ob_itself ) return -1; |
| 2828 |
return 0; |
| 2829 |
} |
| 2830 |
|
| 2831 |
static PyObject * CFMutableStringRefObj_repr(CFMutableStringRefObject *self) |
| 2832 |
{ |
| 2833 |
char buf[100]; |
| 2834 |
sprintf(buf, "<CFMutableStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself); |
| 2835 |
return PyString_FromString(buf); |
| 2836 |
} |
| 2837 |
|
| 2838 |
static int CFMutableStringRefObj_hash(CFMutableStringRefObject *self) |
| 2839 |
{ |
| 2840 |
|
| 2841 |
return (int)self->ob_itself; |
| 2842 |
} |
| 2843 |
static int CFMutableStringRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
| 2844 |
{ |
| 2845 |
CFMutableStringRef itself; |
| 2846 |
char *kw[] = {"itself", 0}; |
| 2847 |
|
| 2848 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFMutableStringRefObj_Convert, &itself)) |
| 2849 |
{ |
| 2850 |
((CFMutableStringRefObject *)_self)->ob_itself = itself; |
| 2851 |
return 0; |
| 2852 |
} |
| 2853 |
|
| 2854 |
|
| 2855 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) |
| 2856 |
{ |
| 2857 |
((CFMutableStringRefObject *)_self)->ob_itself = itself; |
| 2858 |
return 0; |
| 2859 |
} |
| 2860 |
return -1; |
| 2861 |
} |
| 2862 |
|
| 2863 |
#define CFMutableStringRefObj_tp_alloc PyType_GenericAlloc |
| 2864 |
|
| 2865 |
static PyObject *CFMutableStringRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 2866 |
{ |
| 2867 |
PyObject *self; |
| 2868 |
if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 2869 |
((CFMutableStringRefObject *)self)->ob_itself = NULL; |
| 2870 |
((CFMutableStringRefObject *)self)->ob_freeit = CFRelease; |
| 2871 |
return self; |
| 2872 |
} |
| 2873 |
|
| 2874 |
#define CFMutableStringRefObj_tp_free PyObject_Del |
| 2875 |
|
| 2876 |
|
| 2877 |
PyTypeObject CFMutableStringRef_Type = { |
| 2878 |
PyObject_HEAD_INIT(NULL) |
| 2879 |
0, |
| 2880 |
"_CF.CFMutableStringRef", |
| 2881 |
sizeof(CFMutableStringRefObject), |
| 2882 |
0, |
| 2883 |
|
| 2884 |
(destructor) CFMutableStringRefObj_dealloc, |
| 2885 |
0, |
| 2886 |
(getattrfunc)0, |
| 2887 |
(setattrfunc)0, |
| 2888 |
(cmpfunc) CFMutableStringRefObj_compare, |
| 2889 |
(reprfunc) CFMutableStringRefObj_repr, |
| 2890 |
(PyNumberMethods *)0, |
| 2891 |
(PySequenceMethods *)0, |
| 2892 |
(PyMappingMethods *)0, |
| 2893 |
(hashfunc) CFMutableStringRefObj_hash, |
| 2894 |
0, |
| 2895 |
0, |
| 2896 |
PyObject_GenericGetAttr, |
| 2897 |
PyObject_GenericSetAttr, |
| 2898 |
0, |
| 2899 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 2900 |
0, |
| 2901 |
0, |
| 2902 |
0, |
| 2903 |
0, |
| 2904 |
0, |
| 2905 |
0, |
| 2906 |
0, |
| 2907 |
CFMutableStringRefObj_methods, |
| 2908 |
0, |
| 2909 |
CFMutableStringRefObj_getsetlist, |
| 2910 |
0, |
| 2911 |
0, |
| 2912 |
0, |
| 2913 |
0, |
| 2914 |
0, |
| 2915 |
CFMutableStringRefObj_tp_init, |
| 2916 |
CFMutableStringRefObj_tp_alloc, |
| 2917 |
CFMutableStringRefObj_tp_new, |
| 2918 |
CFMutableStringRefObj_tp_free, |
| 2919 |
}; |
| 2920 |
|
| 2921 |
|
| 2922 |
|
| 2923 |
|
| 2924 |
|
| 2925 |
|
| 2926 |
PyTypeObject CFURLRef_Type; |
| 2927 |
|
| 2928 |
#define CFURLRefObj_Check(x) ((x)->ob_type == &CFURLRef_Type || PyObject_TypeCheck((x), &CFURLRef_Type)) |
| 2929 |
|
| 2930 |
typedef struct CFURLRefObject { |
| 2931 |
PyObject_HEAD |
| 2932 |
CFURLRef ob_itself; |
| 2933 |
void (*ob_freeit)(CFTypeRef ptr); |
| 2934 |
} CFURLRefObject; |
| 2935 |
|
| 2936 |
PyObject *CFURLRefObj_New(CFURLRef itself) |
| 2937 |
{ |
| 2938 |
CFURLRefObject *it; |
| 2939 |
if (itself == NULL) |
| 2940 |
{ |
| 2941 |
PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); |
| 2942 |
return NULL; |
| 2943 |
} |
| 2944 |
it = PyObject_NEW(CFURLRefObject, &CFURLRef_Type); |
| 2945 |
if (it == NULL) return NULL; |
| 2946 |
|
| 2947 |
it->ob_itself = itself; |
| 2948 |
it->ob_freeit = CFRelease; |
| 2949 |
return (PyObject *)it; |
| 2950 |
} |
| 2951 |
|
| 2952 |
int CFURLRefObj_Convert(PyObject *v, CFURLRef *p_itself) |
| 2953 |
{ |
| 2954 |
|
| 2955 |
if (v == Py_None) { *p_itself = NULL; return 1; } |
| 2956 |
|
| 2957 |
|
| 2958 |
if (!CFURLRefObj_Check(v)) |
| 2959 |
{ |
| 2960 |
PyErr_SetString(PyExc_TypeError, "CFURLRef required"); |
| 2961 |
return 0; |
| 2962 |
} |
| 2963 |
*p_itself = ((CFURLRefObject *)v)->ob_itself; |
| 2964 |
return 1; |
| 2965 |
} |
| 2966 |
|
| 2967 |
static void CFURLRefObj_dealloc(CFURLRefObject *self) |
| 2968 |
{ |
| 2969 |
if (self->ob_freeit && self->ob_itself) |
| 2970 |
{ |
| 2971 |
self->ob_freeit((CFTypeRef)self->ob_itself); |
| 2972 |
self->ob_itself = NULL; |
| 2973 |
} |
| 2974 |
CFTypeRef_Type.tp_dealloc((PyObject *)self); |
| 2975 |
} |
| 2976 |
|
| 2977 |
static PyObject *CFURLRefObj_CFURLCreateData(CFURLRefObject *_self, PyObject *_args) |
| 2978 |
{ |
| 2979 |
PyObject *_res = NULL; |
| 2980 |
CFDataRef _rv; |
| 2981 |
CFStringEncoding encoding; |
| 2982 |
Boolean escapeWhitespace; |
| 2983 |
if (!PyArg_ParseTuple(_args, "ll", |
| 2984 |
&encoding, |
| 2985 |
&escapeWhitespace)) |
| 2986 |
return NULL; |
| 2987 |
_rv = CFURLCreateData((CFAllocatorRef)NULL, |
| 2988 |
_self->ob_itself, |
| 2989 |
encoding, |
| 2990 |
escapeWhitespace); |
| 2991 |
_res = Py_BuildValue("O&", |
| 2992 |
CFDataRefObj_New, _rv); |
| 2993 |
return _res; |
| 2994 |
} |
| 2995 |
|
| 2996 |
static PyObject *CFURLRefObj_CFURLGetFileSystemRepresentation(CFURLRefObject *_self, PyObject *_args) |
| 2997 |
{ |
| 2998 |
PyObject *_res = NULL; |
| 2999 |
Boolean _rv; |
| 3000 |
Boolean resolveAgainstBase; |
| 3001 |
UInt8 buffer; |
| 3002 |
CFIndex maxBufLen; |
| 3003 |
#ifndef CFURLGetFileSystemRepresentation |
| 3004 |
PyMac_PRECHECK(CFURLGetFileSystemRepresentation); |
| 3005 |
#endif |
| 3006 |
if (!PyArg_ParseTuple(_args, "ll", |
| 3007 |
&resolveAgainstBase, |
| 3008 |
&maxBufLen)) |
| 3009 |
return NULL; |
| 3010 |
_rv = CFURLGetFileSystemRepresentation(_self->ob_itself, |
| 3011 |
resolveAgainstBase, |
| 3012 |
&buffer, |
| 3013 |
maxBufLen); |
| 3014 |
_res = Py_BuildValue("lb", |
| 3015 |
_rv, |
| 3016 |
buffer); |
| 3017 |
return _res; |
| 3018 |
} |
| 3019 |
|
| 3020 |
static PyObject *CFURLRefObj_CFURLCopyAbsoluteURL(CFURLRefObject *_self, PyObject *_args) |
| 3021 |
{ |
| 3022 |
PyObject *_res = NULL; |
| 3023 |
CFURLRef _rv; |
| 3024 |
#ifndef CFURLCopyAbsoluteURL |
| 3025 |
PyMac_PRECHECK(CFURLCopyAbsoluteURL); |
| 3026 |
#endif |
| 3027 |
if (!PyArg_ParseTuple(_args, "")) |
| 3028 |
return NULL; |
| 3029 |
_rv = CFURLCopyAbsoluteURL(_self->ob_itself); |
| 3030 |
_res = Py_BuildValue("O&", |
| 3031 |
CFURLRefObj_New, _rv); |
| 3032 |
return _res; |
| 3033 |
} |
| 3034 |
|
| 3035 |
static PyObject *CFURLRefObj_CFURLGetString(CFURLRefObject *_self, PyObject *_args) |
| 3036 |
{ |
| 3037 |
PyObject *_res = NULL; |
| 3038 |
CFStringRef _rv; |
| 3039 |
#ifndef CFURLGetString |
| 3040 |
PyMac_PRECHECK(CFURLGetString); |
| 3041 |
#endif |
| 3042 |
if (!PyArg_ParseTuple(_args, "")) |
| 3043 |
return NULL; |
| 3044 |
_rv = CFURLGetString(_self->ob_itself); |
| 3045 |
_res = Py_BuildValue("O&", |
| 3046 |
CFStringRefObj_New, _rv); |
| 3047 |
return _res; |
| 3048 |
} |
| 3049 |
|
| 3050 |
static PyObject *CFURLRefObj_CFURLGetBaseURL(CFURLRefObject *_self, PyObject *_args) |
| 3051 |
{ |
| 3052 |
PyObject *_res = NULL; |
| 3053 |
CFURLRef _rv; |
| 3054 |
#ifndef CFURLGetBaseURL |
| 3055 |
PyMac_PRECHECK(CFURLGetBaseURL); |
| 3056 |
#endif |
| 3057 |
if (!PyArg_ParseTuple(_args, "")) |
| 3058 |
return NULL; |
| 3059 |
_rv = CFURLGetBaseURL(_self->ob_itself); |
| 3060 |
_res = Py_BuildValue("O&", |
| 3061 |
CFURLRefObj_New, _rv); |
| 3062 |
return _res; |
| 3063 |
} |
| 3064 |
|
| 3065 |
static PyObject *CFURLRefObj_CFURLCanBeDecomposed(CFURLRefObject *_self, PyObject *_args) |
| 3066 |
{ |
| 3067 |
PyObject *_res = NULL; |
| 3068 |
Boolean _rv; |
| 3069 |
#ifndef CFURLCanBeDecomposed |
| 3070 |
PyMac_PRECHECK(CFURLCanBeDecomposed); |
| 3071 |
#endif |
| 3072 |
if (!PyArg_ParseTuple(_args, "")) |
| 3073 |
return NULL; |
| 3074 |
_rv = CFURLCanBeDecomposed(_self->ob_itself); |
| 3075 |
_res = Py_BuildValue("l", |
| 3076 |
_rv); |
| 3077 |
return _res; |
| 3078 |
} |
| 3079 |
|
| 3080 |
static PyObject *CFURLRefObj_CFURLCopyScheme(CFURLRefObject *_self, PyObject *_args) |
| 3081 |
{ |
| 3082 |
PyObject *_res = NULL; |
| 3083 |
CFStringRef _rv; |
| 3084 |
#ifndef CFURLCopyScheme |
| 3085 |
PyMac_PRECHECK(CFURLCopyScheme); |
| 3086 |
#endif |
| 3087 |
if (!PyArg_ParseTuple(_args, "")) |
| 3088 |
return NULL; |
| 3089 |
_rv = CFURLCopyScheme(_self->ob_itself); |
| 3090 |
_res = Py_BuildValue("O&", |
| 3091 |
CFStringRefObj_New, _rv); |
| 3092 |
return _res; |
| 3093 |
} |
| 3094 |
|
| 3095 |
static PyObject *CFURLRefObj_CFURLCopyNetLocation(CFURLRefObject *_self, PyObject *_args) |
| 3096 |
{ |
| 3097 |
PyObject *_res = NULL; |
| 3098 |
CFStringRef _rv; |
| 3099 |
#ifndef CFURLCopyNetLocation |
| 3100 |
PyMac_PRECHECK(CFURLCopyNetLocation); |
| 3101 |
#endif |
| 3102 |
if (!PyArg_ParseTuple(_args, "")) |
| 3103 |
return NULL; |
| 3104 |
_rv = CFURLCopyNetLocation(_self->ob_itself); |
| 3105 |
_res = Py_BuildValue("O&", |
| 3106 |
CFStringRefObj_New, _rv); |
| 3107 |
return _res; |
| 3108 |
} |
| 3109 |
|
| 3110 |
static PyObject *CFURLRefObj_CFURLCopyPath(CFURLRefObject *_self, PyObject *_args) |
| 3111 |
{ |
| 3112 |
PyObject *_res = NULL; |
| 3113 |
CFStringRef _rv; |
| 3114 |
#ifndef CFURLCopyPath |
| 3115 |
PyMac_PRECHECK(CFURLCopyPath); |
| 3116 |
#endif |
| 3117 |
if (!PyArg_ParseTuple(_args, "")) |
| 3118 |
return NULL; |
| 3119 |
_rv = CFURLCopyPath(_self->ob_itself); |
| 3120 |
_res = Py_BuildValue("O&", |
| 3121 |
CFStringRefObj_New, _rv); |
| 3122 |
return _res; |
| 3123 |
} |
| 3124 |
|
| 3125 |
static PyObject *CFURLRefObj_CFURLCopyStrictPath(CFURLRefObject *_self, PyObject *_args) |
| 3126 |
{ |
| 3127 |
PyObject *_res = NULL; |
| 3128 |
CFStringRef _rv; |
| 3129 |
Boolean isAbsolute; |
| 3130 |
#ifndef CFURLCopyStrictPath |
| 3131 |
PyMac_PRECHECK(CFURLCopyStrictPath); |
| 3132 |
#endif |
| 3133 |
if (!PyArg_ParseTuple(_args, "")) |
| 3134 |
return NULL; |
| 3135 |
_rv = CFURLCopyStrictPath(_self->ob_itself, |
| 3136 |
&isAbsolute); |
| 3137 |
_res = Py_BuildValue("O&l", |
| 3138 |
CFStringRefObj_New, _rv, |
| 3139 |
isAbsolute); |
| 3140 |
return _res; |
| 3141 |
} |
| 3142 |
|
| 3143 |
static PyObject *CFURLRefObj_CFURLCopyFileSystemPath(CFURLRefObject *_self, PyObject *_args) |
| 3144 |
{ |
| 3145 |
PyObject *_res = NULL; |
| 3146 |
CFStringRef _rv; |
| 3147 |
CFURLPathStyle pathStyle; |
| 3148 |
#ifndef CFURLCopyFileSystemPath |
| 3149 |
PyMac_PRECHECK(CFURLCopyFileSystemPath); |
| 3150 |
#endif |
| 3151 |
if (!PyArg_ParseTuple(_args, "l", |
| 3152 |
&pathStyle)) |
| 3153 |
return NULL; |
| 3154 |
_rv = CFURLCopyFileSystemPath(_self->ob_itself, |
| 3155 |
pathStyle); |
| 3156 |
_res = Py_BuildValue("O&", |
| 3157 |
CFStringRefObj_New, _rv); |
| 3158 |
return _res; |
| 3159 |
} |
| 3160 |
|
| 3161 |
static PyObject *CFURLRefObj_CFURLHasDirectoryPath(CFURLRefObject *_self, PyObject *_args) |
| 3162 |
{ |
| 3163 |
PyObject *_res = NULL; |
| 3164 |
Boolean _rv; |
| 3165 |
#ifndef CFURLHasDirectoryPath |
| 3166 |
PyMac_PRECHECK(CFURLHasDirectoryPath); |
| 3167 |
#endif |
| 3168 |
if (!PyArg_ParseTuple(_args, "")) |
| 3169 |
return NULL; |
| 3170 |
_rv = CFURLHasDirectoryPath(_self->ob_itself); |
| 3171 |
_res = Py_BuildValue("l", |
| 3172 |
_rv); |
| 3173 |
return _res; |
| 3174 |
} |
| 3175 |
|
| 3176 |
static PyObject *CFURLRefObj_CFURLCopyResourceSpecifier(CFURLRefObject *_self, PyObject *_args) |
| 3177 |
{ |
| 3178 |
PyObject *_res = NULL; |
| 3179 |
CFStringRef _rv; |
| 3180 |
#ifndef CFURLCopyResourceSpecifier |
| 3181 |
PyMac_PRECHECK(CFURLCopyResourceSpecifier); |
| 3182 |
#endif |
| 3183 |
if (!PyArg_ParseTuple(_args, "")) |
| 3184 |
return NULL; |
| 3185 |
_rv = CFURLCopyResourceSpecifier(_self->ob_itself); |
| 3186 |
_res = Py_BuildValue("O&", |
| 3187 |
CFStringRefObj_New, _rv); |
| 3188 |
return _res; |
| 3189 |
} |
| 3190 |
|
| 3191 |
static PyObject *CFURLRefObj_CFURLCopyHostName(CFURLRefObject *_self, PyObject *_args) |
| 3192 |
{ |
| 3193 |
PyObject *_res = NULL; |
| 3194 |
CFStringRef _rv; |
| 3195 |
#ifndef CFURLCopyHostName |
| 3196 |
PyMac_PRECHECK(CFURLCopyHostName); |
| 3197 |
#endif |
| 3198 |
if (!PyArg_ParseTuple(_args, "")) |
| 3199 |
return NULL; |
| 3200 |
_rv = CFURLCopyHostName(_self->ob_itself); |
| 3201 |
_res = Py_BuildValue("O&", |
| 3202 |
CFStringRefObj_New, _rv); |
| 3203 |
return _res; |
| 3204 |
} |
| 3205 |
|
| 3206 |
static PyObject *CFURLRefObj_CFURLGetPortNumber(CFURLRefObject *_self, PyObject *_args) |
| 3207 |
{ |
| 3208 |
PyObject *_res = NULL; |
| 3209 |
SInt32 _rv; |
| 3210 |
#ifndef CFURLGetPortNumber |
| 3211 |
PyMac_PRECHECK(CFURLGetPortNumber); |
| 3212 |
#endif |
| 3213 |
if (!PyArg_ParseTuple(_args, "")) |
| 3214 |
return NULL; |
| 3215 |
_rv = CFURLGetPortNumber(_self->ob_itself); |
| 3216 |
_res = Py_BuildValue("l", |
| 3217 |
_rv); |
| 3218 |
return _res; |
| 3219 |
} |
| 3220 |
|
| 3221 |
static PyObject *CFURLRefObj_CFURLCopyUserName(CFURLRefObject *_self, PyObject *_args) |
| 3222 |
{ |
| 3223 |
PyObject *_res = NULL; |
| 3224 |
CFStringRef _rv; |
| 3225 |
#ifndef CFURLCopyUserName |
| 3226 |
PyMac_PRECHECK(CFURLCopyUserName); |
| 3227 |
#endif |
| 3228 |
if (!PyArg_ParseTuple(_args, "")) |
| 3229 |
return NULL; |
| 3230 |
_rv = CFURLCopyUserName(_self->ob_itself); |
| 3231 |
_res = Py_BuildValue("O&", |
| 3232 |
CFStringRefObj_New, _rv); |
| 3233 |
return _res; |
| 3234 |
} |
| 3235 |
|
| 3236 |
static PyObject *CFURLRefObj_CFURLCopyPassword(CFURLRefObject *_self, PyObject *_args) |
| 3237 |
{ |
| 3238 |
PyObject *_res = NULL; |
| 3239 |
CFStringRef _rv; |
| 3240 |
#ifndef CFURLCopyPassword |
| 3241 |
PyMac_PRECHECK(CFURLCopyPassword); |
| 3242 |
#endif |
| 3243 |
if (!PyArg_ParseTuple(_args, "")) |
| 3244 |
return NULL; |
| 3245 |
_rv = CFURLCopyPassword(_self->ob_itself); |
| 3246 |
_res = Py_BuildValue("O&", |
| 3247 |
CFStringRefObj_New, _rv); |
| 3248 |
return _res; |
| 3249 |
} |
| 3250 |
|
| 3251 |
static PyObject *CFURLRefObj_CFURLCopyParameterString(CFURLRefObject *_self, PyObject *_args) |
| 3252 |
{ |
| 3253 |
PyObject *_res = NULL; |
| 3254 |
CFStringRef _rv; |
| 3255 |
CFStringRef charactersToLeaveEscaped; |
| 3256 |
#ifndef CFURLCopyParameterString |
| 3257 |
PyMac_PRECHECK(CFURLCopyParameterString); |
| 3258 |
#endif |
| 3259 |
if (!PyArg_ParseTuple(_args, "O&", |
| 3260 |
CFStringRefObj_Convert, &charactersToLeaveEscaped)) |
| 3261 |
return NULL; |
| 3262 |
_rv = CFURLCopyParameterString(_self->ob_itself, |
| 3263 |
charactersToLeaveEscaped); |
| 3264 |
_res = Py_BuildValue("O&", |
| 3265 |
CFStringRefObj_New, _rv); |
| 3266 |
return _res; |
| 3267 |
} |
| 3268 |
|
| 3269 |
static PyObject *CFURLRefObj_CFURLCopyQueryString(CFURLRefObject *_self, PyObject *_args) |
| 3270 |
{ |
| 3271 |
PyObject *_res = NULL; |
| 3272 |
CFStringRef _rv; |
| 3273 |
CFStringRef charactersToLeaveEscaped; |
| 3274 |
#ifndef CFURLCopyQueryString |
| 3275 |
PyMac_PRECHECK(CFURLCopyQueryString); |
| 3276 |
#endif |
| 3277 |
if (!PyArg_ParseTuple(_args, "O&", |
| 3278 |
CFStringRefObj_Convert, &charactersToLeaveEscaped)) |
| 3279 |
return NULL; |
| 3280 |
_rv = CFURLCopyQueryString(_self->ob_itself, |
| 3281 |
charactersToLeaveEscaped); |
| 3282 |
_res = Py_BuildValue("O&", |
| 3283 |
CFStringRefObj_New, _rv); |
| 3284 |
return _res; |
| 3285 |
} |
| 3286 |
|
| 3287 |
static PyObject *CFURLRefObj_CFURLCopyFragment(CFURLRefObject *_self, PyObject *_args) |
| 3288 |
{ |
| 3289 |
PyObject *_res = NULL; |
| 3290 |
CFStringRef _rv; |
| 3291 |
CFStringRef charactersToLeaveEscaped; |
| 3292 |
#ifndef CFURLCopyFragment |
| 3293 |
PyMac_PRECHECK(CFURLCopyFragment); |
| 3294 |
#endif |
| 3295 |
if (!PyArg_ParseTuple(_args, "O&", |
| 3296 |
CFStringRefObj_Convert, &charactersToLeaveEscaped)) |
| 3297 |
return NULL; |
| 3298 |
_rv = CFURLCopyFragment(_self->ob_itself, |
| 3299 |
charactersToLeaveEscaped); |
| 3300 |
_res = Py_BuildValue("O&", |
| 3301 |
CFStringRefObj_New, _rv); |
| 3302 |
return _res; |
| 3303 |
} |
| 3304 |
|
| 3305 |
static PyObject *CFURLRefObj_CFURLCopyLastPathComponent(CFURLRefObject *_self, PyObject *_args) |
| 3306 |
{ |
| 3307 |
PyObject *_res = NULL; |
| 3308 |
CFStringRef _rv; |
| 3309 |
#ifndef CFURLCopyLastPathComponent |
| 3310 |
PyMac_PRECHECK(CFURLCopyLastPathComponent); |
| 3311 |
#endif |
| 3312 |
if (!PyArg_ParseTuple(_args, "")) |
| 3313 |
return NULL; |
| 3314 |
_rv = CFURLCopyLastPathComponent(_self->ob_itself); |
| 3315 |
_res = Py_BuildValue("O&", |
| 3316 |
CFStringRefObj_New, _rv); |
| 3317 |
return _res; |
| 3318 |
} |
| 3319 |
|
| 3320 |
static PyObject *CFURLRefObj_CFURLCopyPathExtension(CFURLRefObject *_self, PyObject *_args) |
| 3321 |
{ |
| 3322 |
PyObject *_res = NULL; |
| 3323 |
CFStringRef _rv; |
| 3324 |
#ifndef CFURLCopyPathExtension |
| 3325 |
PyMac_PRECHECK(CFURLCopyPathExtension); |
| 3326 |
#endif |
| 3327 |
if (!PyArg_ParseTuple(_args, "")) |
| 3328 |
return NULL; |
| 3329 |
_rv = CFURLCopyPathExtension(_self->ob_itself); |
| 3330 |
_res = Py_BuildValue("O&", |
| 3331 |
CFStringRefObj_New, _rv); |
| 3332 |
return _res; |
| 3333 |
} |
| 3334 |
|
| 3335 |
static PyObject *CFURLRefObj_CFURLCreateCopyAppendingPathComponent(CFURLRefObject *_self, PyObject *_args) |
| 3336 |
{ |
| 3337 |
PyObject *_res = NULL; |
| 3338 |
CFURLRef _rv; |
| 3339 |
CFStringRef pathComponent; |
| 3340 |
Boolean isDirectory; |
| 3341 |
if (!PyArg_ParseTuple(_args, "O&l", |
| 3342 |
CFStringRefObj_Convert, &pathComponent, |
| 3343 |
&isDirectory)) |
| 3344 |
return NULL; |
| 3345 |
_rv = CFURLCreateCopyAppendingPathComponent((CFAllocatorRef)NULL, |
| 3346 |
_self->ob_itself, |
| 3347 |
pathComponent, |
| 3348 |
isDirectory); |
| 3349 |
_res = Py_BuildValue("O&", |
| 3350 |
CFURLRefObj_New, _rv); |
| 3351 |
return _res; |
| 3352 |
} |
| 3353 |
|
| 3354 |
static PyObject *CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent(CFURLRefObject *_self, PyObject *_args) |
| 3355 |
{ |
| 3356 |
PyObject *_res = NULL; |
| 3357 |
CFURLRef _rv; |
| 3358 |
if (!PyArg_ParseTuple(_args, "")) |
| 3359 |
return NULL; |
| 3360 |
_rv = CFURLCreateCopyDeletingLastPathComponent((CFAllocatorRef)NULL, |
| 3361 |
_self->ob_itself); |
| 3362 |
_res = Py_BuildValue("O&", |
| 3363 |
CFURLRefObj_New, _rv); |
| 3364 |
return _res; |
| 3365 |
} |
| 3366 |
|
| 3367 |
static PyObject *CFURLRefObj_CFURLCreateCopyAppendingPathExtension(CFURLRefObject *_self, PyObject *_args) |
| 3368 |
{ |
| 3369 |
PyObject *_res = NULL; |
| 3370 |
CFURLRef _rv; |
| 3371 |
CFStringRef extension; |
| 3372 |
if (!PyArg_ParseTuple(_args, "O&", |
| 3373 |
CFStringRefObj_Convert, &extension)) |
| 3374 |
return NULL; |
| 3375 |
_rv = CFURLCreateCopyAppendingPathExtension((CFAllocatorRef)NULL, |
| 3376 |
_self->ob_itself, |
| 3377 |
extension); |
| 3378 |
_res = Py_BuildValue("O&", |
| 3379 |
CFURLRefObj_New, _rv); |
| 3380 |
return _res; |
| 3381 |
} |
| 3382 |
|
| 3383 |
static PyObject *CFURLRefObj_CFURLCreateCopyDeletingPathExtension(CFURLRefObject *_self, PyObject *_args) |
| 3384 |
{ |
| 3385 |
PyObject *_res = NULL; |
| 3386 |
CFURLRef _rv; |
| 3387 |
if (!PyArg_ParseTuple(_args, "")) |
| 3388 |
return NULL; |
| 3389 |
_rv = CFURLCreateCopyDeletingPathExtension((CFAllocatorRef)NULL, |
| 3390 |
_self->ob_itself); |
| 3391 |
_res = Py_BuildValue("O&", |
| 3392 |
CFURLRefObj_New, _rv); |
| 3393 |
return _res; |
| 3394 |
} |
| 3395 |
|
| 3396 |
static PyObject *CFURLRefObj_CFURLGetFSRef(CFURLRefObject *_self, PyObject *_args) |
| 3397 |
{ |
| 3398 |
PyObject *_res = NULL; |
| 3399 |
Boolean _rv; |
| 3400 |
FSRef fsRef; |
| 3401 |
#ifndef CFURLGetFSRef |
| 3402 |
PyMac_PRECHECK(CFURLGetFSRef); |
| 3403 |
#endif |
| 3404 |
if (!PyArg_ParseTuple(_args, "")) |
| 3405 |
return NULL; |
| 3406 |
_rv = CFURLGetFSRef(_self->ob_itself, |
| 3407 |
&fsRef); |
| 3408 |
_res = Py_BuildValue("lO&", |
| 3409 |
_rv, |
| 3410 |
PyMac_BuildFSRef, &fsRef); |
| 3411 |
return _res; |
| 3412 |
} |
| 3413 |
|
| 3414 |
static PyMethodDef CFURLRefObj_methods[] = { |
| 3415 |
{"CFURLCreateData", (PyCFunction)CFURLRefObj_CFURLCreateData, 1, |
| 3416 |
PyDoc_STR("(CFStringEncoding encoding, Boolean escapeWhitespace) -> (CFDataRef _rv)")}, |
| 3417 |
{"CFURLGetFileSystemRepresentation", (PyCFunction)CFURLRefObj_CFURLGetFileSystemRepresentation, 1, |
| 3418 |
PyDoc_STR("(Boolean resolveAgainstBase, CFIndex maxBufLen) -> (Boolean _rv, UInt8 buffer)")}, |
| 3419 |
{"CFURLCopyAbsoluteURL", (PyCFunction)CFURLRefObj_CFURLCopyAbsoluteURL, 1, |
| 3420 |
PyDoc_STR("() -> (CFURLRef _rv)")}, |
| 3421 |
{"CFURLGetString", (PyCFunction)CFURLRefObj_CFURLGetString, 1, |
| 3422 |
PyDoc_STR("() -> (CFStringRef _rv)")}, |
| 3423 |
{"CFURLGetBaseURL", (PyCFunction)CFURLRefObj_CFURLGetBaseURL, 1, |
| 3424 |
PyDoc_STR("() -> (CFURLRef _rv)")}, |
| 3425 |
{"CFURLCanBeDecomposed", (PyCFunction)CFURLRefObj_CFURLCanBeDecomposed, 1, |
| 3426 |
PyDoc_STR("() -> (Boolean _rv)")}, |
| 3427 |
{"CFURLCopyScheme", (PyCFunction)CFURLRefObj_CFURLCopyScheme, 1, |
| 3428 |
PyDoc_STR("() -> (CFStringRef _rv)")}, |
| 3429 |
{"CFURLCopyNetLocation", (PyCFunction)CFURLRefObj_CFURLCopyNetLocation, 1, |
| 3430 |
PyDoc_STR("() -> (CFStringRef _rv)")}, |
| 3431 |
{"CFURLCopyPath", (PyCFunction)CFURLRefObj_CFURLCopyPath, 1, |
| 3432 |
PyDoc_STR("() -> (CFStringRef _rv)")}, |
| 3433 |
{"CFURLCopyStrictPath", (PyCFunction)CFURLRefObj_CFURLCopyStrictPath, 1, |
| 3434 |
PyDoc_STR("() -> (CFStringRef _rv, Boolean isAbsolute)")}, |
| 3435 |
{"CFURLCopyFileSystemPath", (PyCFunction)CFURLRefObj_CFURLCopyFileSystemPath, 1, |
| 3436 |
PyDoc_STR("(CFURLPathStyle pathStyle) -> (CFStringRef _rv)")}, |
| 3437 |
{"CFURLHasDirectoryPath", (PyCFunction)CFURLRefObj_CFURLHasDirectoryPath, 1, |
| 3438 |
PyDoc_STR("() -> (Boolean _rv)")}, |
| 3439 |
{"CFURLCopyResourceSpecifier", (PyCFunction)CFURLRefObj_CFURLCopyResourceSpecifier, 1, |
| 3440 |
PyDoc_STR("() -> (CFStringRef _rv)")}, |
| 3441 |
{"CFURLCopyHostName", (PyCFunction)CFURLRefObj_CFURLCopyHostName, 1, |
| 3442 |
PyDoc_STR("() -> (CFStringRef _rv)")}, |
| 3443 |
{"CFURLGetPortNumber", (PyCFunction)CFURLRefObj_CFURLGetPortNumber, 1, |
| 3444 |
PyDoc_STR("() -> (SInt32 _rv)")}, |
| 3445 |
{"CFURLCopyUserName", (PyCFunction)CFURLRefObj_CFURLCopyUserName, 1, |
| 3446 |
PyDoc_STR("() -> (CFStringRef _rv)")}, |
| 3447 |
{"CFURLCopyPassword", (PyCFunction)CFURLRefObj_CFURLCopyPassword, 1, |
| 3448 |
PyDoc_STR("() -> (CFStringRef _rv)")}, |
| 3449 |
{"CFURLCopyParameterString", (PyCFunction)CFURLRefObj_CFURLCopyParameterString, 1, |
| 3450 |
PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")}, |
| 3451 |
{"CFURLCopyQueryString", (PyCFunction)CFURLRefObj_CFURLCopyQueryString, 1, |
| 3452 |
PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")}, |
| 3453 |
{"CFURLCopyFragment", (PyCFunction)CFURLRefObj_CFURLCopyFragment, 1, |
| 3454 |
PyDoc_STR("(CFStringRef charactersToLeaveEscaped) -> (CFStringRef _rv)")}, |
| 3455 |
{"CFURLCopyLastPathComponent", (PyCFunction)CFURLRefObj_CFURLCopyLastPathComponent, 1, |
| 3456 |
PyDoc_STR("() -> (CFStringRef _rv)")}, |
| 3457 |
{"CFURLCopyPathExtension", (PyCFunction)CFURLRefObj_CFURLCopyPathExtension, 1, |
| 3458 |
PyDoc_STR("() -> (CFStringRef _rv)")}, |
| 3459 |
{"CFURLCreateCopyAppendingPathComponent", (PyCFunction)CFURLRefObj_CFURLCreateCopyAppendingPathComponent, 1, |
| 3460 |
PyDoc_STR("(CFStringRef pathComponent, Boolean isDirectory) -> (CFURLRef _rv)")}, |
| 3461 |
{"CFURLCreateCopyDeletingLastPathComponent", (PyCFunction)CFURLRefObj_CFURLCreateCopyDeletingLastPathComponent, 1, |
| 3462 |
PyDoc_STR("() -> (CFURLRef _rv)")}, |
| 3463 |
{"CFURLCreateCopyAppendingPathExtension", (PyCFunction)CFURLRefObj_CFURLCreateCopyAppendingPathExtension, 1, |
| 3464 |
PyDoc_STR("(CFStringRef extension) -> (CFURLRef _rv)")}, |
| 3465 |
{"CFURLCreateCopyDeletingPathExtension", (PyCFunction)CFURLRefObj_CFURLCreateCopyDeletingPathExtension, 1, |
| 3466 |
PyDoc_STR("() -> (CFURLRef _rv)")}, |
| 3467 |
{"CFURLGetFSRef", (PyCFunction)CFURLRefObj_CFURLGetFSRef, 1, |
| 3468 |
PyDoc_STR("() -> (Boolean _rv, FSRef fsRef)")}, |
| 3469 |
{NULL, NULL, 0} |
| 3470 |
}; |
| 3471 |
|
| 3472 |
#define CFURLRefObj_getsetlist NULL |
| 3473 |
|
| 3474 |
|
| 3475 |
static int CFURLRefObj_compare(CFURLRefObject *self, CFURLRefObject *other) |
| 3476 |
{ |
| 3477 |
|
| 3478 |
if ( self->ob_itself > other->ob_itself ) return 1; |
| 3479 |
if ( self->ob_itself < other->ob_itself ) return -1; |
| 3480 |
return 0; |
| 3481 |
} |
| 3482 |
|
| 3483 |
static PyObject * CFURLRefObj_repr(CFURLRefObject *self) |
| 3484 |
{ |
| 3485 |
char buf[100]; |
| 3486 |
sprintf(buf, "<CFURL object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself); |
| 3487 |
return PyString_FromString(buf); |
| 3488 |
} |
| 3489 |
|
| 3490 |
static int CFURLRefObj_hash(CFURLRefObject *self) |
| 3491 |
{ |
| 3492 |
|
| 3493 |
return (int)self->ob_itself; |
| 3494 |
} |
| 3495 |
static int CFURLRefObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds) |
| 3496 |
{ |
| 3497 |
CFURLRef itself; |
| 3498 |
char *kw[] = {"itself", 0}; |
| 3499 |
|
| 3500 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFURLRefObj_Convert, &itself)) |
| 3501 |
{ |
| 3502 |
((CFURLRefObject *)_self)->ob_itself = itself; |
| 3503 |
return 0; |
| 3504 |
} |
| 3505 |
|
| 3506 |
|
| 3507 |
if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, CFTypeRefObj_Convert, &itself)) |
| 3508 |
{ |
| 3509 |
((CFURLRefObject *)_self)->ob_itself = itself; |
| 3510 |
return 0; |
| 3511 |
} |
| 3512 |
return -1; |
| 3513 |
} |
| 3514 |
|
| 3515 |
#define CFURLRefObj_tp_alloc PyType_GenericAlloc |
| 3516 |
|
| 3517 |
static PyObject *CFURLRefObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 3518 |
{ |
| 3519 |
PyObject *self; |
| 3520 |
if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 3521 |
((CFURLRefObject *)self)->ob_itself = NULL; |
| 3522 |
((CFURLRefObject *)self)->ob_freeit = CFRelease; |
| 3523 |
return self; |
| 3524 |
} |
| 3525 |
|
| 3526 |
#define CFURLRefObj_tp_free PyObject_Del |
| 3527 |
|
| 3528 |
|
| 3529 |
PyTypeObject CFURLRef_Type = { |
| 3530 |
PyObject_HEAD_INIT(NULL) |
| 3531 |
0, |
| 3532 |
"_CF.CFURLRef", |
| 3533 |
sizeof(CFURLRefObject), |
| 3534 |
0, |
| 3535 |
|
| 3536 |
(destructor) CFURLRefObj_dealloc, |
| 3537 |
0, |
| 3538 |
(getattrfunc)0, |
| 3539 |
(setattrfunc)0, |
| 3540 |
(cmpfunc) CFURLRefObj_compare, |
| 3541 |
(reprfunc) CFURLRefObj_repr, |
| 3542 |
(PyNumberMethods *)0, |
| 3543 |
(PySequenceMethods *)0, |
| 3544 |
(PyMappingMethods *)0, |
| 3545 |
(hashfunc) CFURLRefObj_hash, |
| 3546 |
0, |
| 3547 |
0, |
| 3548 |
PyObject_GenericGetAttr, |
| 3549 |
PyObject_GenericSetAttr, |
| 3550 |
0, |
| 3551 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 3552 |
0, |
| 3553 |
0, |
| 3554 |
0, |
| 3555 |
0, |
| 3556 |
0, |
| 3557 |
0, |
| 3558 |
0, |
| 3559 |
CFURLRefObj_methods, |
| 3560 |
0, |
| 3561 |
CFURLRefObj_getsetlist, |
| 3562 |
0, |
| 3563 |
0, |
| 3564 |
0, |
| 3565 |
0, |
| 3566 |
0, |
| 3567 |
CFURLRefObj_tp_init, |
| 3568 |
CFURLRefObj_tp_alloc, |
| 3569 |
CFURLRefObj_tp_new, |
| 3570 |
CFURLRefObj_tp_free, |
| 3571 |
}; |
| 3572 |
|
| 3573 |
|
| 3574 |
|
| 3575 |
|
| 3576 |
static PyObject *CF___CFRangeMake(PyObject *_self, PyObject *_args) |
| 3577 |
{ |
| 3578 |
PyObject *_res = NULL; |
| 3579 |
CFRange _rv; |
| 3580 |
CFIndex loc; |
| 3581 |
CFIndex len; |
| 3582 |
#ifndef __CFRangeMake |
| 3583 |
PyMac_PRECHECK(__CFRangeMake); |
| 3584 |
#endif |
| 3585 |
if (!PyArg_ParseTuple(_args, "ll", |
| 3586 |
&loc, |
| 3587 |
&len)) |
| 3588 |
return NULL; |
| 3589 |
_rv = __CFRangeMake(loc, |
| 3590 |
len); |
| 3591 |
_res = Py_BuildValue("O&", |
| 3592 |
CFRange_New, _rv); |
| 3593 |
return _res; |
| 3594 |
} |
| 3595 |
|
| 3596 |
static PyObject *CF_CFAllocatorGetTypeID(PyObject *_self, PyObject *_args) |
| 3597 |
{ |
| 3598 |
PyObject *_res = NULL; |
| 3599 |
CFTypeID _rv; |
| 3600 |
#ifndef CFAllocatorGetTypeID |
| 3601 |
PyMac_PRECHECK(CFAllocatorGetTypeID); |
| 3602 |
#endif |
| 3603 |
if (!PyArg_ParseTuple(_args, "")) |
| 3604 |
return NULL; |
| 3605 |
_rv = CFAllocatorGetTypeID(); |
| 3606 |
_res = Py_BuildValue("l", |
| 3607 |
_rv); |
| 3608 |
return _res; |
| 3609 |
} |
| 3610 |
|
| 3611 |
static PyObject *CF_CFAllocatorGetPreferredSizeForSize(PyObject *_self, PyObject *_args) |
| 3612 |
{ |
| 3613 |
PyObject *_res = NULL; |
| 3614 |
CFIndex _rv; |
| 3615 |
CFIndex size; |
| 3616 |
CFOptionFlags hint; |
| 3617 |
#ifndef CFAllocatorGetPreferredSizeForSize |
| 3618 |
PyMac_PRECHECK(CFAllocatorGetPreferredSizeForSize); |
| 3619 |
#endif |
| 3620 |
if (!PyArg_ParseTuple(_args, "ll", |
| 3621 |
&size, |
| 3622 |
&hint)) |
| 3623 |
return NULL; |
| 3624 |
_rv = CFAllocatorGetPreferredSizeForSize((CFAllocatorRef)NULL, |
| 3625 |
size, |
| 3626 |
hint); |
| 3627 |
_res = Py_BuildValue("l", |
| 3628 |
_rv); |
| 3629 |
return _res; |
| 3630 |
} |
| 3631 |
|
| 3632 |
static PyObject *CF_CFCopyTypeIDDescription(PyObject *_self, PyObject *_args) |
| 3633 |
{ |
| 3634 |
PyObject *_res = NULL; |
| 3635 |
CFStringRef _rv; |
| 3636 |
CFTypeID type_id; |
| 3637 |
#ifndef CFCopyTypeIDDescription |
| 3638 |
PyMac_PRECHECK(CFCopyTypeIDDescription); |
| 3639 |
#endif |
| 3640 |
if (!PyArg_ParseTuple(_args, "l", |
| 3641 |
&type_id)) |
| 3642 |
return NULL; |
| 3643 |
_rv = CFCopyTypeIDDescription(type_id); |
| 3644 |
_res = Py_BuildValue("O&", |
| 3645 |
CFStringRefObj_New, _rv); |
| 3646 |
return _res; |
| 3647 |
} |
| 3648 |
|
| 3649 |
static PyObject *CF_CFArrayGetTypeID(PyObject *_self, PyObject *_args) |
| 3650 |
{ |
| 3651 |
PyObject *_res = NULL; |
| 3652 |
CFTypeID _rv; |
| 3653 |
#ifndef CFArrayGetTypeID |
| 3654 |
PyMac_PRECHECK(CFArrayGetTypeID); |
| 3655 |
#endif |
| 3656 |
if (!PyArg_ParseTuple(_args, "")) |
| 3657 |
return NULL; |
| 3658 |
_rv = CFArrayGetTypeID(); |
| 3659 |
_res = Py_BuildValue("l", |
| 3660 |
_rv); |
| 3661 |
return _res; |
| 3662 |
} |
| 3663 |
|
| 3664 |
static PyObject *CF_CFArrayCreateMutable(PyObject *_self, PyObject *_args) |
| 3665 |
{ |
| 3666 |
PyObject *_res = NULL; |
| 3667 |
CFMutableArrayRef _rv; |
| 3668 |
CFIndex capacity; |
| 3669 |
#ifndef CFArrayCreateMutable |
| 3670 |
PyMac_PRECHECK(CFArrayCreateMutable); |
| 3671 |
#endif |
| 3672 |
if (!PyArg_ParseTuple(_args, "l", |
| 3673 |
&capacity)) |
| 3674 |
return NULL; |
| 3675 |
_rv = CFArrayCreateMutable((CFAllocatorRef)NULL, |
| 3676 |
capacity, |
| 3677 |
&kCFTypeArrayCallBacks); |
| 3678 |
_res = Py_BuildValue("O&", |
| 3679 |
CFMutableArrayRefObj_New, _rv); |
| 3680 |
return _res; |
| 3681 |
} |
| 3682 |
|
| 3683 |
static PyObject *CF_CFArrayCreateMutableCopy(PyObject *_self, PyObject *_args) |
| 3684 |
{ |
| 3685 |
PyObject *_res = NULL; |
| 3686 |
CFMutableArrayRef _rv; |
| 3687 |
CFIndex capacity; |
| 3688 |
CFArrayRef theArray; |
| 3689 |
#ifndef CFArrayCreateMutableCopy |
| 3690 |
PyMac_PRECHECK(CFArrayCreateMutableCopy); |
| 3691 |
#endif |
| 3692 |
if (!PyArg_ParseTuple(_args, "lO&", |
| 3693 |
&capacity, |
| 3694 |
CFArrayRefObj_Convert, &theArray)) |
| 3695 |
return NULL; |
| 3696 |
_rv = CFArrayCreateMutableCopy((CFAllocatorRef)NULL, |
| 3697 |
capacity, |
| 3698 |
theArray); |
| 3699 |
_res = Py_BuildValue("O&", |
| 3700 |
CFMutableArrayRefObj_New, _rv); |
| 3701 |
return _res; |
| 3702 |
} |
| 3703 |
|
| 3704 |
static PyObject *CF_CFDataGetTypeID(PyObject *_self, PyObject *_args) |
| 3705 |
{ |
| 3706 |
PyObject *_res = NULL; |
| 3707 |
CFTypeID _rv; |
| 3708 |
#ifndef CFDataGetTypeID |
| 3709 |
PyMac_PRECHECK(CFDataGetTypeID); |
| 3710 |
#endif |
| 3711 |
if (!PyArg_ParseTuple(_args, "")) |
| 3712 |
return NULL; |
| 3713 |
_rv = CFDataGetTypeID(); |
| 3714 |
_res = Py_BuildValue("l", |
| 3715 |
_rv); |
| 3716 |
return _res; |
| 3717 |
} |
| 3718 |
|
| 3719 |
static PyObject *CF_CFDataCreate(PyObject *_self, PyObject *_args) |
| 3720 |
{ |
| 3721 |
PyObject *_res = NULL; |
| 3722 |
CFDataRef _rv; |
| 3723 |
unsigned char *bytes__in__; |
| 3724 |
long bytes__len__; |
| 3725 |
int bytes__in_len__; |
| 3726 |
#ifndef CFDataCreate |
| 3727 |
PyMac_PRECHECK(CFDataCreate); |
| 3728 |
#endif |
| 3729 |
if (!PyArg_ParseTuple(_args, "s#", |
| 3730 |
&bytes__in__, &bytes__in_len__)) |
| 3731 |
return NULL; |
| 3732 |
bytes__len__ = bytes__in_len__; |
| 3733 |
_rv = CFDataCreate((CFAllocatorRef)NULL, |
| 3734 |
bytes__in__, bytes__len__); |
| 3735 |
_res = Py_BuildValue("O&", |
| 3736 |
CFDataRefObj_New, _rv); |
| 3737 |
return _res; |
| 3738 |
} |
| 3739 |
|
| 3740 |
static PyObject *CF_CFDataCreateWithBytesNoCopy(PyObject *_self, PyObject *_args) |
| 3741 |
{ |
| 3742 |
PyObject *_res = NULL; |
| 3743 |
CFDataRef _rv; |
| 3744 |
unsigned char *bytes__in__; |
| 3745 |
long bytes__len__; |
| 3746 |
int bytes__in_len__; |
| 3747 |
#ifndef CFDataCreateWithBytesNoCopy |
| 3748 |
PyMac_PRECHECK(CFDataCreateWithBytesNoCopy); |
| 3749 |
#endif |
| 3750 |
if (!PyArg_ParseTuple(_args, "s#", |
| 3751 |
&bytes__in__, &bytes__in_len__)) |
| 3752 |
return NULL; |
| 3753 |
bytes__len__ = bytes__in_len__; |
| 3754 |
_rv = CFDataCreateWithBytesNoCopy((CFAllocatorRef)NULL, |
| 3755 |
bytes__in__, bytes__len__, |
| 3756 |
(CFAllocatorRef)NULL); |
| 3757 |
_res = Py_BuildValue("O&", |
| 3758 |
CFDataRefObj_New, _rv); |
| 3759 |
return _res; |
| 3760 |
} |
| 3761 |
|
| 3762 |
static PyObject *CF_CFDataCreateMutable(PyObject *_self, PyObject *_args) |
| 3763 |
{ |
| 3764 |
PyObject *_res = NULL; |
| 3765 |
CFMutableDataRef _rv; |
| 3766 |
CFIndex capacity; |
| 3767 |
#ifndef CFDataCreateMutable |
| 3768 |
PyMac_PRECHECK(CFDataCreateMutable); |
| 3769 |
#endif |
| 3770 |
if (!PyArg_ParseTuple(_args, "l", |
| 3771 |
&capacity)) |
| 3772 |
return NULL; |
| 3773 |
_rv = CFDataCreateMutable((CFAllocatorRef)NULL, |
| 3774 |
capacity); |
| 3775 |
_res = Py_BuildValue("O&", |
| 3776 |
CFMutableDataRefObj_New, _rv); |
| 3777 |
return _res; |
| 3778 |
} |
| 3779 |
|
| 3780 |
static PyObject *CF_CFDataCreateMutableCopy(PyObject *_self, PyObject *_args) |
| 3781 |
{ |
| 3782 |
PyObject *_res = NULL; |
| 3783 |
CFMutableDataRef _rv; |
| 3784 |
CFIndex capacity; |
| 3785 |
CFDataRef theData; |
| 3786 |
#ifndef CFDataCreateMutableCopy |
| 3787 |
PyMac_PRECHECK(CFDataCreateMutableCopy); |
| 3788 |
#endif |
| 3789 |
if (!PyArg_ParseTuple(_args, "lO&", |
| 3790 |
&capacity, |
| 3791 |
CFDataRefObj_Convert, &theData)) |
| 3792 |
return NULL; |
| 3793 |
_rv = CFDataCreateMutableCopy((CFAllocatorRef)NULL, |
| 3794 |
capacity, |
| 3795 |
theData); |
| 3796 |
_res = Py_BuildValue("O&", |
| 3797 |
CFMutableDataRefObj_New, _rv); |
| 3798 |
return _res; |
| 3799 |
} |
| 3800 |
|
| 3801 |
static PyObject *CF_CFDictionaryGetTypeID(PyObject *_self, PyObject *_args) |
| 3802 |
{ |
| 3803 |
PyObject *_res = NULL; |
| 3804 |
CFTypeID _rv; |
| 3805 |
#ifndef CFDictionaryGetTypeID |
| 3806 |
PyMac_PRECHECK(CFDictionaryGetTypeID); |
| 3807 |
#endif |
| 3808 |
if (!PyArg_ParseTuple(_args, "")) |
| 3809 |
return NULL; |
| 3810 |
_rv = CFDictionaryGetTypeID(); |
| 3811 |
_res = Py_BuildValue("l", |
| 3812 |
_rv); |
| 3813 |
return _res; |
| 3814 |
} |
| 3815 |
|
| 3816 |
static PyObject *CF_CFDictionaryCreateMutable(PyObject *_self, PyObject *_args) |
| 3817 |
{ |
| 3818 |
PyObject *_res = NULL; |
| 3819 |
CFMutableDictionaryRef _rv; |
| 3820 |
CFIndex capacity; |
| 3821 |
#ifndef CFDictionaryCreateMutable |
| 3822 |
PyMac_PRECHECK(CFDictionaryCreateMutable); |
| 3823 |
#endif |
| 3824 |
if (!PyArg_ParseTuple(_args, "l", |
| 3825 |
&capacity)) |
| 3826 |
return NULL; |
| 3827 |
_rv = CFDictionaryCreateMutable((CFAllocatorRef)NULL, |
| 3828 |
capacity, |
| 3829 |
&kCFTypeDictionaryKeyCallBacks, |
| 3830 |
&kCFTypeDictionaryValueCallBacks); |
| 3831 |
_res = Py_BuildValue("O&", |
| 3832 |
CFMutableDictionaryRefObj_New, _rv); |
| 3833 |
return _res; |
| 3834 |
} |
| 3835 |
|
| 3836 |
static PyObject *CF_CFDictionaryCreateMutableCopy(PyObject *_self, PyObject *_args) |
| 3837 |
{ |
| 3838 |
PyObject *_res = NULL; |
| 3839 |
CFMutableDictionaryRef _rv; |
| 3840 |
CFIndex capacity; |
| 3841 |
CFDictionaryRef theDict; |
| 3842 |
#ifndef CFDictionaryCreateMutableCopy |
| 3843 |
PyMac_PRECHECK(CFDictionaryCreateMutableCopy); |
| 3844 |
#endif |
| 3845 |
if (!PyArg_ParseTuple(_args, "lO&", |
| 3846 |
&capacity, |
| 3847 |
CFDictionaryRefObj_Convert, &theDict)) |
| 3848 |
return NULL; |
| 3849 |
_rv = CFDictionaryCreateMutableCopy((CFAllocatorRef)NULL, |
| 3850 |
capacity, |
| 3851 |
theDict); |
| 3852 |
_res = Py_BuildValue("O&", |
| 3853 |
CFMutableDictionaryRefObj_New, _rv); |
| 3854 |
return _res; |
| 3855 |
} |
| 3856 |
|
| 3857 |
static PyObject *CF_CFPreferencesCopyAppValue(PyObject *_self, PyObject *_args) |
| 3858 |
{ |
| 3859 |
PyObject *_res = NULL; |
| 3860 |
CFTypeRef _rv; |
| 3861 |
CFStringRef key; |
| 3862 |
CFStringRef applicationID; |
| 3863 |
#ifndef CFPreferencesCopyAppValue |
| 3864 |
PyMac_PRECHECK(CFPreferencesCopyAppValue); |
| 3865 |
#endif |
| 3866 |
if (!PyArg_ParseTuple(_args, "O&O&", |
| 3867 |
CFStringRefObj_Convert, &key, |
| 3868 |
CFStringRefObj_Convert, &applicationID)) |
| 3869 |
return NULL; |
| 3870 |
_rv = CFPreferencesCopyAppValue(key, |
| 3871 |
applicationID); |
| 3872 |
_res = Py_BuildValue("O&", |
| 3873 |
CFTypeRefObj_New, _rv); |
| 3874 |
return _res; |
| 3875 |
} |
| 3876 |
|
| 3877 |
static PyObject *CF_CFPreferencesGetAppBooleanValue(PyObject *_self, PyObject *_args) |
| 3878 |
{ |
| 3879 |
PyObject *_res = NULL; |
| 3880 |
Boolean _rv; |
| 3881 |
CFStringRef key; |
| 3882 |
CFStringRef applicationID; |
| 3883 |
Boolean keyExistsAndHasValidFormat; |
| 3884 |
#ifndef CFPreferencesGetAppBooleanValue |
| 3885 |
PyMac_PRECHECK(CFPreferencesGetAppBooleanValue); |
| 3886 |
#endif |
| 3887 |
if (!PyArg_ParseTuple(_args, "O&O&", |
| 3888 |
CFStringRefObj_Convert, &key, |
| 3889 |
CFStringRefObj_Convert, &applicationID)) |
| 3890 |
return NULL; |
| 3891 |
_rv = CFPreferencesGetAppBooleanValue(key, |
| 3892 |
applicationID, |
| 3893 |
&keyExistsAndHasValidFormat); |
| 3894 |
_res = Py_BuildValue("ll", |
| 3895 |
_rv, |
| 3896 |
keyExistsAndHasValidFormat); |
| 3897 |
return _res; |
| 3898 |
} |
| 3899 |
|
| 3900 |
static PyObject *CF_CFPreferencesGetAppIntegerValue(PyObject *_self, PyObject *_args) |
| 3901 |
{ |
| 3902 |
PyObject *_res = NULL; |
| 3903 |
CFIndex _rv; |
| 3904 |
CFStringRef key; |
| 3905 |
CFStringRef applicationID; |
| 3906 |
Boolean keyExistsAndHasValidFormat; |
| 3907 |
#ifndef CFPreferencesGetAppIntegerValue |
| 3908 |
PyMac_PRECHECK(CFPreferencesGetAppIntegerValue); |
| 3909 |
#endif |
| 3910 |
if (!PyArg_ParseTuple(_args, "O&O&", |
| 3911 |
CFStringRefObj_Convert, &key, |
| 3912 |
CFStringRefObj_Convert, &applicationID)) |
| 3913 |
return NULL; |
| 3914 |
_rv = CFPreferencesGetAppIntegerValue(key, |
| 3915 |
applicationID, |
| 3916 |
&keyExistsAndHasValidFormat); |
| 3917 |
_res = Py_BuildValue("ll", |
| 3918 |
_rv, |
| 3919 |
keyExistsAndHasValidFormat); |
| 3920 |
return _res; |
| 3921 |
} |
| 3922 |
|
| 3923 |
static PyObject *CF_CFPreferencesSetAppValue(PyObject *_self, PyObject *_args) |
| 3924 |
{ |
| 3925 |
PyObject *_res = NULL; |
| 3926 |
CFStringRef key; |
| 3927 |
CFTypeRef value; |
| 3928 |
CFStringRef applicationID; |
| 3929 |
#ifndef CFPreferencesSetAppValue |
| 3930 |
PyMac_PRECHECK(CFPreferencesSetAppValue); |
| 3931 |
#endif |
| 3932 |
if (!PyArg_ParseTuple(_args, "O&O&O&", |
| 3933 |
CFStringRefObj_Convert, &key, |
| 3934 |
CFTypeRefObj_Convert, &value, |
| 3935 |
CFStringRefObj_Convert, &applicationID)) |
| 3936 |
return NULL; |
| 3937 |
CFPreferencesSetAppValue(key, |
| 3938 |
value, |
| 3939 |
applicationID); |
| 3940 |
Py_INCREF(Py_None); |
| 3941 |
_res = Py_None; |
| 3942 |
return _res; |
| 3943 |
} |
| 3944 |
|
| 3945 |
static PyObject *CF_CFPreferencesAddSuitePreferencesToApp(PyObject *_self, PyObject *_args) |
| 3946 |
{ |
| 3947 |
PyObject *_res = NULL; |
| 3948 |
CFStringRef applicationID; |
| 3949 |
CFStringRef suiteID; |
| 3950 |
#ifndef CFPreferencesAddSuitePreferencesToApp |
| 3951 |
PyMac_PRECHECK(CFPreferencesAddSuitePreferencesToApp); |
| 3952 |
#endif |
| 3953 |
if (!PyArg_ParseTuple(_args, "O&O&", |
| 3954 |
CFStringRefObj_Convert, &applicationID, |
| 3955 |
CFStringRefObj_Convert, &suiteID)) |
| 3956 |
return NULL; |
| 3957 |
CFPreferencesAddSuitePreferencesToApp(applicationID, |
| 3958 |
suiteID); |
| 3959 |
Py_INCREF(Py_None); |
| 3960 |
_res = Py_None; |
| 3961 |
return _res; |
| 3962 |
} |
| 3963 |
|
| 3964 |
static PyObject *CF_CFPreferencesRemoveSuitePreferencesFromApp(PyObject *_self, PyObject *_args) |
| 3965 |
{ |
| 3966 |
PyObject *_res = NULL; |
| 3967 |
CFStringRef applicationID; |
| 3968 |
CFStringRef suiteID; |
| 3969 |
#ifndef CFPreferencesRemoveSuitePreferencesFromApp |
| 3970 |
PyMac_PRECHECK(CFPreferencesRemoveSuitePreferencesFromApp); |
| 3971 |
#endif |
| 3972 |
if (!PyArg_ParseTuple(_args, "O&O&", |
| 3973 |
CFStringRefObj_Convert, &applicationID, |
| 3974 |
CFStringRefObj_Convert, &suiteID)) |
| 3975 |
return NULL; |
| 3976 |
CFPreferencesRemoveSuitePreferencesFromApp(applicationID, |
| 3977 |
suiteID); |
| 3978 |
Py_INCREF(Py_None); |
| 3979 |
_res = Py_None; |
| 3980 |
return _res; |
| 3981 |
} |
| 3982 |
|
| 3983 |
static PyObject *CF_CFPreferencesAppSynchronize(PyObject *_self, PyObject *_args) |
| 3984 |
{ |
| 3985 |
PyObject *_res = NULL; |
| 3986 |
Boolean _rv; |
| 3987 |
CFStringRef applicationID; |
| 3988 |
#ifndef CFPreferencesAppSynchronize |
| 3989 |
PyMac_PRECHECK(CFPreferencesAppSynchronize); |
| 3990 |
#endif |
| 3991 |
if (!PyArg_ParseTuple(_args, "O&", |
| 3992 |
CFStringRefObj_Convert, &applicationID)) |
| 3993 |
return NULL; |
| 3994 |
_rv = CFPreferencesAppSynchronize(applicationID); |
| 3995 |
_res = Py_BuildValue("l", |
| 3996 |
_rv); |
| 3997 |
return _res; |
| 3998 |
} |
| 3999 |
|
| 4000 |
static PyObject *CF_CFPreferencesCopyValue(PyObject *_self, PyObject *_args) |
| 4001 |
{ |
| 4002 |
PyObject *_res = NULL; |
| 4003 |
CFTypeRef _rv; |
| 4004 |
CFStringRef key; |
| 4005 |
CFStringRef applicationID; |
| 4006 |
CFStringRef userName; |
| 4007 |
CFStringRef hostName; |
| 4008 |
#ifndef CFPreferencesCopyValue |
| 4009 |
PyMac_PRECHECK(CFPreferencesCopyValue); |
| 4010 |
#endif |
| 4011 |
if (!PyArg_ParseTuple(_args, "O&O&O&O&", |
| 4012 |
CFStringRefObj_Convert, &key, |
| 4013 |
CFStringRefObj_Convert, &applicationID, |
| 4014 |
CFStringRefObj_Convert, &userName, |
| 4015 |
CFStringRefObj_Convert, &hostName)) |
| 4016 |
return NULL; |
| 4017 |
_rv = CFPreferencesCopyValue(key, |
| 4018 |
applicationID, |
| 4019 |
userName, |
| 4020 |
hostName); |
| 4021 |
_res = Py_BuildValue("O&", |
| 4022 |
CFTypeRefObj_New, _rv); |
| 4023 |
return _res; |
| 4024 |
} |
| 4025 |
|
| 4026 |
static PyObject *CF_CFPreferencesCopyMultiple(PyObject *_self, PyObject *_args) |
| 4027 |
{ |
| 4028 |
PyObject *_res = NULL; |
| 4029 |
CFDictionaryRef _rv; |
| 4030 |
CFArrayRef keysToFetch; |
| 4031 |
CFStringRef applicationID; |
| 4032 |
CFStringRef userName; |
| 4033 |
CFStringRef hostName; |
| 4034 |
#ifndef CFPreferencesCopyMultiple |
| 4035 |
PyMac_PRECHECK(CFPreferencesCopyMultiple); |
| 4036 |
#endif |
| 4037 |
if (!PyArg_ParseTuple(_args, "O&O&O&O&", |
| 4038 |
CFArrayRefObj_Convert, &keysToFetch, |
| 4039 |
CFStringRefObj_Convert, &applicationID, |
| 4040 |
CFStringRefObj_Convert, &userName, |
| 4041 |
CFStringRefObj_Convert, &hostName)) |
| 4042 |
return NULL; |
| 4043 |
_rv = CFPreferencesCopyMultiple(keysToFetch, |
| 4044 |
applicationID, |
| 4045 |
userName, |
| 4046 |
hostName); |
| 4047 |
_res = Py_BuildValue("O&", |
| 4048 |
CFDictionaryRefObj_New, _rv); |
| 4049 |
return _res; |
| 4050 |
} |
| 4051 |
|
| 4052 |
static PyObject *CF_CFPreferencesSetValue(PyObject *_self, PyObject *_args) |
| 4053 |
{ |
| 4054 |
PyObject *_res = NULL; |
| 4055 |
CFStringRef key; |
| 4056 |
CFTypeRef value; |
| 4057 |
CFStringRef applicationID; |
| 4058 |
CFStringRef userName; |
| 4059 |
CFStringRef hostName; |
| 4060 |
#ifndef CFPreferencesSetValue |
| 4061 |
PyMac_PRECHECK(CFPreferencesSetValue); |
| 4062 |
#endif |
| 4063 |
if (!PyArg_ParseTuple(_args, "O&O&O&O&O&", |
| 4064 |
CFStringRefObj_Convert, &key, |
| 4065 |
CFTypeRefObj_Convert, &value, |
| 4066 |
CFStringRefObj_Convert, &applicationID, |
| 4067 |
CFStringRefObj_Convert, &userName, |
| 4068 |
CFStringRefObj_Convert, &hostName)) |
| 4069 |
return NULL; |
| 4070 |
CFPreferencesSetValue(key, |
| 4071 |
value, |
| 4072 |
applicationID, |
| 4073 |
userName, |
| 4074 |
hostName); |
| 4075 |
Py_INCREF(Py_None); |
| 4076 |
_res = Py_None; |
| 4077 |
return _res; |
| 4078 |
} |
| 4079 |
|
| 4080 |
static PyObject *CF_CFPreferencesSetMultiple(PyObject *_self, PyObject *_args) |
| 4081 |
{ |
| 4082 |
PyObject *_res = NULL; |
| 4083 |
CFDictionaryRef keysToSet; |
| 4084 |
CFArrayRef keysToRemove; |
| 4085 |
CFStringRef applicationID; |
| 4086 |
CFStringRef userName; |
| 4087 |
CFStringRef hostName; |
| 4088 |
#ifndef CFPreferencesSetMultiple |
| 4089 |
PyMac_PRECHECK(CFPreferencesSetMultiple); |
| 4090 |
#endif |
| 4091 |
if (!PyArg_ParseTuple(_args, "O&O&O&O&O&", |
| 4092 |
CFDictionaryRefObj_Convert, &keysToSet, |
| 4093 |
CFArrayRefObj_Convert, &keysToRemove, |
| 4094 |
CFStringRefObj_Convert, &applicationID, |
| 4095 |
CFStringRefObj_Convert, &userName, |
| 4096 |
CFStringRefObj_Convert, &hostName)) |
| 4097 |
return NULL; |
| 4098 |
CFPreferencesSetMultiple(keysToSet, |
| 4099 |
keysToRemove, |
| 4100 |
applicationID, |
| 4101 |
userName, |
| 4102 |
hostName); |
| 4103 |
Py_INCREF(Py_None); |
| 4104 |
_res = Py_None; |
| 4105 |
return _res; |
| 4106 |
} |
| 4107 |
|
| 4108 |
static PyObject *CF_CFPreferencesSynchronize(PyObject *_self, PyObject *_args) |
| 4109 |
{ |
| 4110 |
PyObject *_res = NULL; |
| 4111 |
Boolean _rv; |
| 4112 |
CFStringRef applicationID; |
| 4113 |
CFStringRef userName; |
| 4114 |
CFStringRef hostName; |
| 4115 |
#ifndef CFPreferencesSynchronize |
| 4116 |
PyMac_PRECHECK(CFPreferencesSynchronize); |
| 4117 |
#endif |
| 4118 |
if (!PyArg_ParseTuple(_args, "O&O&O&", |
| 4119 |
CFStringRefObj_Convert, &applicationID, |
| 4120 |
CFStringRefObj_Convert, &userName, |
| 4121 |
CFStringRefObj_Convert, &hostName)) |
| 4122 |
return NULL; |
| 4123 |
_rv = CFPreferencesSynchronize(applicationID, |
| 4124 |
userName, |
| 4125 |
hostName); |
| 4126 |
_res = Py_BuildValue("l", |
| 4127 |
_rv); |
| 4128 |
return _res; |
| 4129 |
} |
| 4130 |
|
| 4131 |
static PyObject *CF_CFPreferencesCopyApplicationList(PyObject *_self, PyObject *_args) |
| 4132 |
{ |
| 4133 |
PyObject *_res = NULL; |
| 4134 |
CFArrayRef _rv; |
| 4135 |
CFStringRef userName; |
| 4136 |
CFStringRef hostName; |
| 4137 |
#ifndef CFPreferencesCopyApplicationList |
| 4138 |
PyMac_PRECHECK(CFPreferencesCopyApplicationList); |
| 4139 |
#endif |
| 4140 |
if (!PyArg_ParseTuple(_args, "O&O&", |
| 4141 |
CFStringRefObj_Convert, &userName, |
| 4142 |
CFStringRefObj_Convert, &hostName)) |
| 4143 |
return NULL; |
| 4144 |
_rv = CFPreferencesCopyApplicationList(userName, |
| 4145 |
hostName); |
| 4146 |
_res = Py_BuildValue("O&", |
| 4147 |
CFArrayRefObj_New, _rv); |
| 4148 |
return _res; |
| 4149 |
} |
| 4150 |
|
| 4151 |
static PyObject *CF_CFPreferencesCopyKeyList(PyObject *_self, PyObject *_args) |
| 4152 |
{ |
| 4153 |
PyObject *_res = NULL; |
| 4154 |
CFArrayRef _rv; |
| 4155 |
CFStringRef applicationID; |
| 4156 |
CFStringRef userName; |
| 4157 |
CFStringRef hostName; |
| 4158 |
#ifndef CFPreferencesCopyKeyList |
| 4159 |
PyMac_PRECHECK(CFPreferencesCopyKeyList); |
| 4160 |
#endif |
| 4161 |
if (!PyArg_ParseTuple(_args, "O&O&O&", |
| 4162 |
CFStringRefObj_Convert, &applicationID, |
| 4163 |
CFStringRefObj_Convert, &userName, |
| 4164 |
CFStringRefObj_Convert, &hostName)) |
| 4165 |
return NULL; |
| 4166 |
_rv = CFPreferencesCopyKeyList(applicationID, |
| 4167 |
userName, |
| 4168 |
hostName); |
| 4169 |
_res = Py_BuildValue("O&", |
| 4170 |
CFArrayRefObj_New, _rv); |
| 4171 |
return _res; |
| 4172 |
} |
| 4173 |
|
| 4174 |
static PyObject *CF_CFStringGetTypeID(PyObject *_self, PyObject *_args) |
| 4175 |
{ |
| 4176 |
PyObject *_res = NULL; |
| 4177 |
CFTypeID _rv; |
| 4178 |
#ifndef CFStringGetTypeID |
| 4179 |
PyMac_PRECHECK(CFStringGetTypeID); |
| 4180 |
#endif |
| 4181 |
if (!PyArg_ParseTuple(_args, "")) |
| 4182 |
return NULL; |
| 4183 |
_rv = CFStringGetTypeID(); |
| 4184 |
_res = Py_BuildValue("l", |
| 4185 |
_rv); |
| 4186 |
return _res; |
| 4187 |
} |
| 4188 |
|
| 4189 |
static PyObject *CF_CFStringCreateWithPascalString(PyObject *_self, PyObject *_args) |
| 4190 |
{ |
| 4191 |
PyObject *_res = NULL; |
| 4192 |
CFStringRef _rv; |
| 4193 |
Str255 pStr; |
| 4194 |
CFStringEncoding encoding; |
| 4195 |
#ifndef CFStringCreateWithPascalString |
| 4196 |
PyMac_PRECHECK(CFStringCreateWithPascalString); |
| 4197 |
#endif |
| 4198 |
if (!PyArg_ParseTuple(_args, "O&l", |
| 4199 |
PyMac_GetStr255, pStr, |
| 4200 |
&encoding)) |
| 4201 |
return NULL; |
| 4202 |
_rv = CFStringCreateWithPascalString((CFAllocatorRef)NULL, |
| 4203 |
pStr, |
| 4204 |
encoding); |
| 4205 |
_res = Py_BuildValue("O&", |
| 4206 |
CFStringRefObj_New, _rv); |
| 4207 |
return _res; |
| 4208 |
} |
| 4209 |
|
| 4210 |
static PyObject *CF_CFStringCreateWithCString(PyObject *_self, PyObject *_args) |
| 4211 |
{ |
| 4212 |
PyObject *_res = NULL; |
| 4213 |
CFStringRef _rv; |
| 4214 |
char* cStr; |
| 4215 |
CFStringEncoding encoding; |
| 4216 |
#ifndef CFStringCreateWithCString |
| 4217 |
PyMac_PRECHECK(CFStringCreateWithCString); |
| 4218 |
#endif |
| 4219 |
if (!PyArg_ParseTuple(_args, "sl", |
| 4220 |
&cStr, |
| 4221 |
&encoding)) |
| 4222 |
return NULL; |
| 4223 |
_rv = CFStringCreateWithCString((CFAllocatorRef)NULL, |
| 4224 |
cStr, |
| 4225 |
encoding); |
| 4226 |
_res = Py_BuildValue("O&", |
| 4227 |
CFStringRefObj_New, _rv); |
| 4228 |
return _res; |
| 4229 |
} |
| 4230 |
|
| 4231 |
static PyObject *CF_CFStringCreateWithCharacters(PyObject *_self, PyObject *_args) |
| 4232 |
{ |
| 4233 |
PyObject *_res = NULL; |
| 4234 |
CFStringRef _rv; |
| 4235 |
UniChar *chars__in__; |
| 4236 |
UniCharCount chars__len__; |
| 4237 |
int chars__in_len__; |
| 4238 |
#ifndef CFStringCreateWithCharacters |
| 4239 |
PyMac_PRECHECK(CFStringCreateWithCharacters); |
| 4240 |
#endif |
| 4241 |
if (!PyArg_ParseTuple(_args, "u#", |
| 4242 |
&chars__in__, &chars__in_len__)) |
| 4243 |
return NULL; |
| 4244 |
chars__len__ = chars__in_len__; |
| 4245 |
_rv = CFStringCreateWithCharacters((CFAllocatorRef)NULL, |
| 4246 |
chars__in__, chars__len__); |
| 4247 |
_res = Py_BuildValue("O&", |
| 4248 |
CFStringRefObj_New, _rv); |
| 4249 |
return _res; |
| 4250 |
} |
| 4251 |
|
| 4252 |
static PyObject *CF_CFStringCreateWithPascalStringNoCopy(PyObject *_self, PyObject *_args) |
| 4253 |
{ |
| 4254 |
PyObject *_res = NULL; |
| 4255 |
CFStringRef _rv; |
| 4256 |
Str255 pStr; |
| 4257 |
CFStringEncoding encoding; |
| 4258 |
#ifndef CFStringCreateWithPascalStringNoCopy |
| 4259 |
PyMac_PRECHECK(CFStringCreateWithPascalStringNoCopy); |
| 4260 |
#endif |
| 4261 |
if (!PyArg_ParseTuple(_args, "O&l", |
| 4262 |
PyMac_GetStr255, pStr, |
| 4263 |
&encoding)) |
| 4264 |
return NULL; |
| 4265 |
_rv = CFStringCreateWithPascalStringNoCopy((CFAllocatorRef)NULL, |
| 4266 |
pStr, |
| 4267 |
encoding, |
| 4268 |
(CFAllocatorRef)NULL); |
| 4269 |
_res = Py_BuildValue("O&", |
| 4270 |
CFStringRefObj_New, _rv); |
| 4271 |
return _res; |
| 4272 |
} |
| 4273 |
|
| 4274 |
static PyObject *CF_CFStringCreateWithCStringNoCopy(PyObject *_self, PyObject *_args) |
| 4275 |
{ |
| 4276 |
PyObject *_res = NULL; |
| 4277 |
CFStringRef _rv; |
| 4278 |
char* cStr; |
| 4279 |
CFStringEncoding encoding; |
| 4280 |
#ifndef CFStringCreateWithCStringNoCopy |
| 4281 |
PyMac_PRECHECK(CFStringCreateWithCStringNoCopy); |
| 4282 |
#endif |
| 4283 |
if (!PyArg_ParseTuple(_args, "sl", |
| 4284 |
&cStr, |
| 4285 |
&encoding)) |
| 4286 |
return NULL; |
| 4287 |
_rv = CFStringCreateWithCStringNoCopy((CFAllocatorRef)NULL, |
| 4288 |
cStr, |
| 4289 |
encoding, |
| 4290 |
(CFAllocatorRef)NULL); |
| 4291 |
_res = Py_BuildValue("O&", |
| 4292 |
CFStringRefObj_New, _rv); |
| 4293 |
return _res; |
| 4294 |
} |
| 4295 |
|
| 4296 |
static PyObject *CF_CFStringCreateWithCharactersNoCopy(PyObject *_self, PyObject *_args) |
| 4297 |
{ |
| 4298 |
PyObject *_res = NULL; |
| 4299 |
CFStringRef _rv; |
| 4300 |
UniChar *chars__in__; |
| 4301 |
UniCharCount chars__len__; |
| 4302 |
int chars__in_len__; |
| 4303 |
#ifndef CFStringCreateWithCharactersNoCopy |
| 4304 |
PyMac_PRECHECK(CFStringCreateWithCharactersNoCopy); |
| 4305 |
#endif |
| 4306 |
if (!PyArg_ParseTuple(_args, "u#", |
| 4307 |
&chars__in__, &chars__in_len__)) |
| 4308 |
return NULL; |
| 4309 |
chars__len__ = chars__in_len__; |
| 4310 |
_rv = CFStringCreateWithCharactersNoCopy((CFAllocatorRef)NULL, |
| 4311 |
chars__in__, chars__len__, |
| 4312 |
(CFAllocatorRef)NULL); |
| 4313 |
_res = Py_BuildValue("O&", |
| 4314 |
CFStringRefObj_New, _rv); |
| 4315 |
return _res; |
| 4316 |
} |
| 4317 |
|
| 4318 |
static PyObject *CF_CFStringCreateMutable(PyObject *_self, PyObject *_args) |
| 4319 |
{ |
| 4320 |
PyObject *_res = NULL; |
| 4321 |
CFMutableStringRef _rv; |
| 4322 |
CFIndex maxLength; |
| 4323 |
#ifndef CFStringCreateMutable |
| 4324 |
PyMac_PRECHECK(CFStringCreateMutable); |
| 4325 |
#endif |
| 4326 |
if (!PyArg_ParseTuple(_args, "l", |
| 4327 |
&maxLength)) |
| 4328 |
return NULL; |
| 4329 |
_rv = CFStringCreateMutable((CFAllocatorRef)NULL, |
| 4330 |
maxLength); |
| 4331 |
_res = Py_BuildValue("O&", |
| 4332 |
CFMutableStringRefObj_New, _rv); |
| 4333 |
return _res; |
| 4334 |
} |
| 4335 |
|
| 4336 |
static PyObject *CF_CFStringCreateMutableCopy(PyObject *_self, PyObject *_args) |
| 4337 |
{ |
| 4338 |
PyObject *_res = NULL; |
| 4339 |
CFMutableStringRef _rv; |
| 4340 |
CFIndex maxLength; |
| 4341 |
CFStringRef theString; |
| 4342 |
#ifndef CFStringCreateMutableCopy |
| 4343 |
PyMac_PRECHECK(CFStringCreateMutableCopy); |
| 4344 |
#endif |
| 4345 |
if (!PyArg_ParseTuple(_args, "lO&", |
| 4346 |
&maxLength, |
| 4347 |
CFStringRefObj_Convert, &theString)) |
| 4348 |
return NULL; |
| 4349 |
_rv = CFStringCreateMutableCopy((CFAllocatorRef)NULL, |
| 4350 |
maxLength, |
| 4351 |
theString); |
| 4352 |
_res = Py_BuildValue("O&", |
| 4353 |
CFMutableStringRefObj_New, _rv); |
| 4354 |
return _res; |
| 4355 |
} |
| 4356 |
|
| 4357 |
static PyObject *CF_CFStringCreateWithBytes(PyObject *_self, PyObject *_args) |
| 4358 |
{ |
| 4359 |
PyObject *_res = NULL; |
| 4360 |
CFStringRef _rv; |
| 4361 |
unsigned char *bytes__in__; |
| 4362 |
long bytes__len__; |
| 4363 |
int bytes__in_len__; |
| 4364 |
CFStringEncoding encoding; |
| 4365 |
Boolean isExternalRepresentation; |
| 4366 |
#ifndef CFStringCreateWithBytes |
| 4367 |
PyMac_PRECHECK(CFStringCreateWithBytes); |
| 4368 |
#endif |
| 4369 |
if (!PyArg_ParseTuple(_args, "s#ll", |
| 4370 |
&bytes__in__, &bytes__in_len__, |
| 4371 |
&encoding, |
| 4372 |
&isExternalRepresentation)) |
| 4373 |
return NULL; |
| 4374 |
bytes__len__ = bytes__in_len__; |
| 4375 |
_rv = CFStringCreateWithBytes((CFAllocatorRef)NULL, |
| 4376 |
bytes__in__, bytes__len__, |
| 4377 |
encoding, |
| 4378 |
isExternalRepresentation); |
| 4379 |
_res = Py_BuildValue("O&", |
| 4380 |
CFStringRefObj_New, _rv); |
| 4381 |
return _res; |
| 4382 |
} |
| 4383 |
|
| 4384 |
static PyObject *CF_CFStringGetSystemEncoding(PyObject *_self, PyObject *_args) |
| 4385 |
{ |
| 4386 |
PyObject *_res = NULL; |
| 4387 |
CFStringEncoding _rv; |
| 4388 |
#ifndef CFStringGetSystemEncoding |
| 4389 |
PyMac_PRECHECK(CFStringGetSystemEncoding); |
| 4390 |
#endif |
| 4391 |
if (!PyArg_ParseTuple(_args, "")) |
| 4392 |
return NULL; |
| 4393 |
_rv = CFStringGetSystemEncoding(); |
| 4394 |
_res = Py_BuildValue("l", |
| 4395 |
_rv); |
| 4396 |
return _res; |
| 4397 |
} |
| 4398 |
|
| 4399 |
static PyObject *CF_CFStringGetMaximumSizeForEncoding(PyObject *_self, PyObject *_args) |
| 4400 |
{ |
| 4401 |
PyObject *_res = NULL; |
| 4402 |
CFIndex _rv; |
| 4403 |
CFIndex length; |
| 4404 |
CFStringEncoding encoding; |
| 4405 |
#ifndef CFStringGetMaximumSizeForEncoding |
| 4406 |
PyMac_PRECHECK(CFStringGetMaximumSizeForEncoding); |
| 4407 |
#endif |
| 4408 |
if (!PyArg_ParseTuple(_args, "ll", |
| 4409 |
&length, |
| 4410 |
&encoding)) |
| 4411 |
return NULL; |
| 4412 |
_rv = CFStringGetMaximumSizeForEncoding(length, |
| 4413 |
encoding); |
| 4414 |
_res = Py_BuildValue("l", |
| 4415 |
_rv); |
| 4416 |
return _res; |
| 4417 |
} |
| 4418 |
|
| 4419 |
static PyObject *CF_CFStringIsEncodingAvailable(PyObject *_self, PyObject *_args) |
| 4420 |
{ |
| 4421 |
PyObject *_res = NULL; |
| 4422 |
Boolean _rv; |
| 4423 |
CFStringEncoding encoding; |
| 4424 |
#ifndef CFStringIsEncodingAvailable |
| 4425 |
PyMac_PRECHECK(CFStringIsEncodingAvailable); |
| 4426 |
#endif |
| 4427 |
if (!PyArg_ParseTuple(_args, "l", |
| 4428 |
&encoding)) |
| 4429 |
return NULL; |
| 4430 |
_rv = CFStringIsEncodingAvailable(encoding); |
| 4431 |
_res = Py_BuildValue("l", |
| 4432 |
_rv); |
| 4433 |
return _res; |
| 4434 |
} |
| 4435 |
|
| 4436 |
static PyObject *CF_CFStringGetNameOfEncoding(PyObject *_self, PyObject *_args) |
| 4437 |
{ |
| 4438 |
PyObject *_res = NULL; |
| 4439 |
CFStringRef _rv; |
| 4440 |
CFStringEncoding encoding; |
| 4441 |
#ifndef CFStringGetNameOfEncoding |
| 4442 |
PyMac_PRECHECK(CFStringGetNameOfEncoding); |
| 4443 |
#endif |
| 4444 |
if (!PyArg_ParseTuple(_args, "l", |
| 4445 |
&encoding)) |
| 4446 |
return NULL; |
| 4447 |
_rv = CFStringGetNameOfEncoding(encoding); |
| 4448 |
_res = Py_BuildValue("O&", |
| 4449 |
CFStringRefObj_New, _rv); |
| 4450 |
return _res; |
| 4451 |
} |
| 4452 |
|
| 4453 |
static PyObject *CF_CFStringConvertEncodingToNSStringEncoding(PyObject *_self, PyObject *_args) |
| 4454 |
{ |
| 4455 |
PyObject *_res = NULL; |
| 4456 |
UInt32 _rv; |
| 4457 |
CFStringEncoding encoding; |
| 4458 |
#ifndef CFStringConvertEncodingToNSStringEncoding |
| 4459 |
PyMac_PRECHECK(CFStringConvertEncodingToNSStringEncoding); |
| 4460 |
#endif |
| 4461 |
if (!PyArg_ParseTuple(_args, "l", |
| 4462 |
&encoding)) |
| 4463 |
return NULL; |
| 4464 |
_rv = CFStringConvertEncodingToNSStringEncoding(encoding); |
| 4465 |
_res = Py_BuildValue("l", |
| 4466 |
_rv); |
| 4467 |
return _res; |
| 4468 |
} |
| 4469 |
|
| 4470 |
static PyObject *CF_CFStringConvertNSStringEncodingToEncoding(PyObject *_self, PyObject *_args) |
| 4471 |
{ |
| 4472 |
PyObject *_res = NULL; |
| 4473 |
CFStringEncoding _rv; |
| 4474 |
UInt32 encoding; |
| 4475 |
#ifndef CFStringConvertNSStringEncodingToEncoding |
| 4476 |
PyMac_PRECHECK(CFStringConvertNSStringEncodingToEncoding); |
| 4477 |
#endif |
| 4478 |
if (!PyArg_ParseTuple(_args, "l", |
| 4479 |
&encoding)) |
| 4480 |
return NULL; |
| 4481 |
_rv = CFStringConvertNSStringEncodingToEncoding(encoding); |
| 4482 |
_res = Py_BuildValue("l", |
| 4483 |
_rv); |
| 4484 |
return _res; |
| 4485 |
} |
| 4486 |
|
| 4487 |
static PyObject *CF_CFStringConvertEncodingToWindowsCodepage(PyObject *_self, PyObject *_args) |
| 4488 |
{ |
| 4489 |
PyObject *_res = NULL; |
| 4490 |
UInt32 _rv; |
| 4491 |
CFStringEncoding encoding; |
| 4492 |
#ifndef CFStringConvertEncodingToWindowsCodepage |
| 4493 |
PyMac_PRECHECK(CFStringConvertEncodingToWindowsCodepage); |
| 4494 |
#endif |
| 4495 |
if (!PyArg_ParseTuple(_args, "l", |
| 4496 |
&encoding)) |
| 4497 |
return NULL; |
| 4498 |
_rv = CFStringConvertEncodingToWindowsCodepage(encoding); |
| 4499 |
_res = Py_BuildValue("l", |
| 4500 |
_rv); |
| 4501 |
return _res; |
| 4502 |
} |
| 4503 |
|
| 4504 |
static PyObject *CF_CFStringConvertWindowsCodepageToEncoding(PyObject *_self, PyObject *_args) |
| 4505 |
{ |
| 4506 |
PyObject *_res = NULL; |
| 4507 |
CFStringEncoding _rv; |
| 4508 |
UInt32 codepage; |
| 4509 |
#ifndef CFStringConvertWindowsCodepageToEncoding |
| 4510 |
PyMac_PRECHECK(CFStringConvertWindowsCodepageToEncoding); |
| 4511 |
#endif |
| 4512 |
if (!PyArg_ParseTuple(_args, "l", |
| 4513 |
&codepage)) |
| 4514 |
return NULL; |
| 4515 |
_rv = CFStringConvertWindowsCodepageToEncoding(codepage); |
| 4516 |
_res = Py_BuildValue("l", |
| 4517 |
_rv); |
| 4518 |
return _res; |
| 4519 |
} |
| 4520 |
|
| 4521 |
static PyObject *CF_CFStringConvertEncodingToIANACharSetName(PyObject *_self, PyObject *_args) |
| 4522 |
{ |
| 4523 |
PyObject *_res = NULL; |
| 4524 |
CFStringRef _rv; |
| 4525 |
CFStringEncoding encoding; |
| 4526 |
#ifndef CFStringConvertEncodingToIANACharSetName |
| 4527 |
PyMac_PRECHECK(CFStringConvertEncodingToIANACharSetName); |
| 4528 |
#endif |
| 4529 |
if (!PyArg_ParseTuple(_args, "l", |
| 4530 |
&encoding)) |
| 4531 |
return NULL; |
| 4532 |
_rv = CFStringConvertEncodingToIANACharSetName(encoding); |
| 4533 |
_res = Py_BuildValue("O&", |
| 4534 |
CFStringRefObj_New, _rv); |
| 4535 |
return _res; |
| 4536 |
} |
| 4537 |
|
| 4538 |
static PyObject *CF_CFStringGetMostCompatibleMacStringEncoding(PyObject *_self, PyObject *_args) |
| 4539 |
{ |
| 4540 |
PyObject *_res = NULL; |
| 4541 |
CFStringEncoding _rv; |
| 4542 |
CFStringEncoding encoding; |
| 4543 |
#ifndef CFStringGetMostCompatibleMacStringEncoding |
| 4544 |
PyMac_PRECHECK(CFStringGetMostCompatibleMacStringEncoding); |
| 4545 |
#endif |
| 4546 |
if (!PyArg_ParseTuple(_args, "l", |
| 4547 |
&encoding)) |
| 4548 |
return NULL; |
| 4549 |
_rv = CFStringGetMostCompatibleMacStringEncoding(encoding); |
| 4550 |
_res = Py_BuildValue("l", |
| 4551 |
_rv); |
| 4552 |
return _res; |
| 4553 |
} |
| 4554 |
|
| 4555 |
static PyObject *CF___CFStringMakeConstantString(PyObject *_self, PyObject *_args) |
| 4556 |
{ |
| 4557 |
PyObject *_res = NULL; |
| 4558 |
CFStringRef _rv; |
| 4559 |
char* cStr; |
| 4560 |
#ifndef __CFStringMakeConstantString |
| 4561 |
PyMac_PRECHECK(__CFStringMakeConstantString); |
| 4562 |
#endif |
| 4563 |
if (!PyArg_ParseTuple(_args, "s", |
| 4564 |
&cStr)) |
| 4565 |
return NULL; |
| 4566 |
_rv = __CFStringMakeConstantString(cStr); |
| 4567 |
_res = Py_BuildValue("O&", |
| 4568 |
CFStringRefObj_New, _rv); |
| 4569 |
return _res; |
| 4570 |
} |
| 4571 |
|
| 4572 |
static PyObject *CF_CFURLGetTypeID(PyObject *_self, PyObject *_args) |
| 4573 |
{ |
| 4574 |
PyObject *_res = NULL; |
| 4575 |
CFTypeID _rv; |
| 4576 |
#ifndef CFURLGetTypeID |
| 4577 |
PyMac_PRECHECK(CFURLGetTypeID); |
| 4578 |
#endif |
| 4579 |
if (!PyArg_ParseTuple(_args, "")) |
| 4580 |
return NULL; |
| 4581 |
_rv = CFURLGetTypeID(); |
| 4582 |
_res = Py_BuildValue("l", |
| 4583 |
_rv); |
| 4584 |
return _res; |
| 4585 |
} |
| 4586 |
|
| 4587 |
static PyObject *CF_CFURLCreateWithBytes(PyObject *_self, PyObject *_args) |
| 4588 |
{ |
| 4589 |
PyObject *_res = NULL; |
| 4590 |
CFURLRef _rv; |
| 4591 |
unsigned char *URLBytes__in__; |
| 4592 |
long URLBytes__len__; |
| 4593 |
int URLBytes__in_len__; |
| 4594 |
CFStringEncoding encoding; |
| 4595 |
CFURLRef baseURL; |
| 4596 |
#ifndef CFURLCreateWithBytes |
| 4597 |
PyMac_PRECHECK(CFURLCreateWithBytes); |
| 4598 |
#endif |
| 4599 |
if (!PyArg_ParseTuple(_args, "s#lO&", |
| 4600 |
&URLBytes__in__, &URLBytes__in_len__, |
| 4601 |
&encoding, |
| 4602 |
OptionalCFURLRefObj_Convert, &baseURL)) |
| 4603 |
return NULL; |
| 4604 |
URLBytes__len__ = URLBytes__in_len__; |
| 4605 |
_rv = CFURLCreateWithBytes((CFAllocatorRef)NULL, |
| 4606 |
URLBytes__in__, URLBytes__len__, |
| 4607 |
encoding, |
| 4608 |
baseURL); |
| 4609 |
_res = Py_BuildValue("O&", |
| 4610 |
CFURLRefObj_New, _rv); |
| 4611 |
return _res; |
| 4612 |
} |
| 4613 |
|
| 4614 |
static PyObject *CF_CFURLCreateFromFileSystemRepresentation(PyObject *_self, PyObject *_args) |
| 4615 |
{ |
| 4616 |
PyObject *_res = NULL; |
| 4617 |
CFURLRef _rv; |
| 4618 |
unsigned char *buffer__in__; |
| 4619 |
long buffer__len__; |
| 4620 |
int buffer__in_len__; |
| 4621 |
Boolean isDirectory; |
| 4622 |
#ifndef CFURLCreateFromFileSystemRepresentation |
| 4623 |
PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentation); |
| 4624 |
#endif |
| 4625 |
if (!PyArg_ParseTuple(_args, "s#l", |
| 4626 |
&buffer__in__, &buffer__in_len__, |
| 4627 |
&isDirectory)) |
| 4628 |
return NULL; |
| 4629 |
buffer__len__ = buffer__in_len__; |
| 4630 |
_rv = CFURLCreateFromFileSystemRepresentation((CFAllocatorRef)NULL, |
| 4631 |
buffer__in__, buffer__len__, |
| 4632 |
isDirectory); |
| 4633 |
_res = Py_BuildValue("O&", |
| 4634 |
CFURLRefObj_New, _rv); |
| 4635 |
return _res; |
| 4636 |
} |
| 4637 |
|
| 4638 |
static PyObject *CF_CFURLCreateFromFileSystemRepresentationRelativeToBase(PyObject *_self, PyObject *_args) |
| 4639 |
{ |
| 4640 |
PyObject *_res = NULL; |
| 4641 |
CFURLRef _rv; |
| 4642 |
unsigned char *buffer__in__; |
| 4643 |
long buffer__len__; |
| 4644 |
int buffer__in_len__; |
| 4645 |
Boolean isDirectory; |
| 4646 |
CFURLRef baseURL; |
| 4647 |
#ifndef CFURLCreateFromFileSystemRepresentationRelativeToBase |
| 4648 |
PyMac_PRECHECK(CFURLCreateFromFileSystemRepresentationRelativeToBase); |
| 4649 |
#endif |
| 4650 |
if (!PyArg_ParseTuple(_args, "s#lO&", |
| 4651 |
&buffer__in__, &buffer__in_len__, |
| 4652 |
&isDirectory, |
| 4653 |
OptionalCFURLRefObj_Convert, &baseURL)) |
| 4654 |
return NULL; |
| 4655 |
buffer__len__ = buffer__in_len__; |
| 4656 |
_rv = CFURLCreateFromFileSystemRepresentationRelativeToBase((CFAllocatorRef)NULL, |
| 4657 |
buffer__in__, buffer__len__, |
| 4658 |
isDirectory, |
| 4659 |
baseURL); |
| 4660 |
_res = Py_BuildValue("O&", |
| 4661 |
CFURLRefObj_New, _rv); |
| 4662 |
return _res; |
| 4663 |
} |
| 4664 |
|
| 4665 |
static PyObject *CF_CFURLCreateFromFSRef(PyObject *_self, PyObject *_args) |
| 4666 |
{ |
| 4667 |
PyObject *_res = NULL; |
| 4668 |
CFURLRef _rv; |
| 4669 |
FSRef fsRef; |
| 4670 |
#ifndef CFURLCreateFromFSRef |
| 4671 |
PyMac_PRECHECK(CFURLCreateFromFSRef); |
| 4672 |
#endif |
| 4673 |
if (!PyArg_ParseTuple(_args, "O&", |
| 4674 |
PyMac_GetFSRef, &fsRef)) |
| 4675 |
return NULL; |
| 4676 |
_rv = CFURLCreateFromFSRef((CFAllocatorRef)NULL, |
| 4677 |
&fsRef); |
| 4678 |
_res = Py_BuildValue("O&", |
| 4679 |
CFURLRefObj_New, _rv); |
| 4680 |
return _res; |
| 4681 |
} |
| 4682 |
|
| 4683 |
static PyObject *CF_toCF(PyObject *_self, PyObject *_args) |
| 4684 |
{ |
| 4685 |
PyObject *_res = NULL; |
| 4686 |
|
| 4687 |
CFTypeRef rv; |
| 4688 |
CFTypeID typeid; |
| 4689 |
|
| 4690 |
if (!PyArg_ParseTuple(_args, "O&", PyCF_Python2CF, &rv)) |
| 4691 |
return NULL; |
| 4692 |
typeid = CFGetTypeID(rv); |
| 4693 |
|
| 4694 |
if (typeid == CFStringGetTypeID()) |
| 4695 |
return Py_BuildValue("O&", CFStringRefObj_New, rv); |
| 4696 |
if (typeid == CFArrayGetTypeID()) |
| 4697 |
return Py_BuildValue("O&", CFArrayRefObj_New, rv); |
| 4698 |
if (typeid == CFDictionaryGetTypeID()) |
| 4699 |
return Py_BuildValue("O&", CFDictionaryRefObj_New, rv); |
| 4700 |
if (typeid == CFURLGetTypeID()) |
| 4701 |
return Py_BuildValue("O&", CFURLRefObj_New, rv); |
| 4702 |
|
| 4703 |
_res = Py_BuildValue("O&", CFTypeRefObj_New, rv); |
| 4704 |
return _res; |
| 4705 |
|
| 4706 |
} |
| 4707 |
|
| 4708 |
static PyMethodDef CF_methods[] = { |
| 4709 |
{"__CFRangeMake", (PyCFunction)CF___CFRangeMake, 1, |
| 4710 |
PyDoc_STR("(CFIndex loc, CFIndex len) -> (CFRange _rv)")}, |
| 4711 |
{"CFAllocatorGetTypeID", (PyCFunction)CF_CFAllocatorGetTypeID, 1, |
| 4712 |
PyDoc_STR("() -> (CFTypeID _rv)")}, |
| 4713 |
{"CFAllocatorGetPreferredSizeForSize", (PyCFunction)CF_CFAllocatorGetPreferredSizeForSize, 1, |
| 4714 |
PyDoc_STR("(CFIndex size, CFOptionFlags hint) -> (CFIndex _rv)")}, |
| 4715 |
{"CFCopyTypeIDDescription", (PyCFunction)CF_CFCopyTypeIDDescription, 1, |
| 4716 |
PyDoc_STR("(CFTypeID type_id) -> (CFStringRef _rv)")}, |
| 4717 |
{"CFArrayGetTypeID", (PyCFunction)CF_CFArrayGetTypeID, 1, |
| 4718 |
PyDoc_STR("() -> (CFTypeID _rv)")}, |
| 4719 |
{"CFArrayCreateMutable", (PyCFunction)CF_CFArrayCreateMutable, 1, |
| 4720 |
PyDoc_STR("(CFIndex capacity) -> (CFMutableArrayRef _rv)")}, |
| 4721 |
{"CFArrayCreateMutableCopy", (PyCFunction)CF_CFArrayCreateMutableCopy, 1, |
| 4722 |
PyDoc_STR("(CFIndex capacity, CFArrayRef theArray) -> (CFMutableArrayRef _rv)")}, |
| 4723 |
{"CFDataGetTypeID", (PyCFunction)CF_CFDataGetTypeID, 1, |
| 4724 |
PyDoc_STR("() -> (CFTypeID _rv)")}, |
| 4725 |
{"CFDataCreate", (PyCFunction)CF_CFDataCreate, 1, |
| 4726 |
PyDoc_STR("(Buffer bytes) -> (CFDataRef _rv)")}, |
| 4727 |
{"CFDataCreateWithBytesNoCopy", (PyCFunction)CF_CFDataCreateWithBytesNoCopy, 1, |
| 4728 |
PyDoc_STR("(Buffer bytes) -> (CFDataRef _rv)")}, |
| 4729 |
{"CFDataCreateMutable", (PyCFunction)CF_CFDataCreateMutable, 1, |
| 4730 |
PyDoc_STR("(CFIndex capacity) -> (CFMutableDataRef _rv)")}, |
| 4731 |
{"CFDataCreateMutableCopy", (PyCFunction)CF_CFDataCreateMutableCopy, 1, |
| 4732 |
PyDoc_STR("(CFIndex capacity, CFDataRef theData) -> (CFMutableDataRef _rv)")}, |
| 4733 |
{"CFDictionaryGetTypeID", (PyCFunction)CF_CFDictionaryGetTypeID, 1, |
| 4734 |
PyDoc_STR("() -> (CFTypeID _rv)")}, |
| 4735 |
{"CFDictionaryCreateMutable", (PyCFunction)CF_CFDictionaryCreateMutable, 1, |
| 4736 |
PyDoc_STR("(CFIndex capacity) -> (CFMutableDictionaryRef _rv)")}, |
| 4737 |
{"CFDictionaryCreateMutableCopy", (PyCFunction)CF_CFDictionaryCreateMutableCopy, 1, |
| 4738 |
PyDoc_STR("(CFIndex capacity, CFDictionaryRef theDict) -> (CFMutableDictionaryRef _rv)")}, |
| 4739 |
{"CFPreferencesCopyAppValue", (PyCFunction)CF_CFPreferencesCopyAppValue, 1, |
| 4740 |
PyDoc_STR("(CFStringRef key, CFStringRef applicationID) -> (CFTypeRef _rv)")}, |
| 4741 |
{"CFPreferencesGetAppBooleanValue", (PyCFunction)CF_CFPreferencesGetAppBooleanValue, 1, |
| 4742 |
PyDoc_STR("(CFStringRef key, CFStringRef applicationID) -> (Boolean _rv, Boolean keyExistsAndHasValidFormat)")}, |
| 4743 |
{"CFPreferencesGetAppIntegerValue", (PyCFunction)CF_CFPreferencesGetAppIntegerValue, 1, |
| 4744 |
PyDoc_STR("(CFStringRef key, CFStringRef applicationID) -> (CFIndex _rv, Boolean keyExistsAndHasValidFormat)")}, |
| 4745 |
{"CFPreferencesSetAppValue", (PyCFunction)CF_CFPreferencesSetAppValue, 1, |
| 4746 |
PyDoc_STR("(CFStringRef key, CFTypeRef value, CFStringRef applicationID) -> None")}, |
| 4747 |
{"CFPreferencesAddSuitePreferencesToApp", (PyCFunction)CF_CFPreferencesAddSuitePreferencesToApp, 1, |
| 4748 |
PyDoc_STR("(CFStringRef applicationID, CFStringRef suiteID) -> None")}, |
| 4749 |
{"CFPreferencesRemoveSuitePreferencesFromApp", (PyCFunction)CF_CFPreferencesRemoveSuitePreferencesFromApp, 1, |
| 4750 |
PyDoc_STR("(CFStringRef applicationID, CFStringRef suiteID) -> None")}, |
| 4751 |
{"CFPreferencesAppSynchronize", (PyCFunction)CF_CFPreferencesAppSynchronize, 1, |
| 4752 |
PyDoc_STR("(CFStringRef applicationID) -> (Boolean _rv)")}, |
| 4753 |
{"CFPreferencesCopyValue", (PyCFunction)CF_CFPreferencesCopyValue, 1, |
| 4754 |
PyDoc_STR("(CFStringRef key, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFTypeRef _rv)")}, |
| 4755 |
{"CFPreferencesCopyMultiple", (PyCFunction)CF_CFPreferencesCopyMultiple, 1, |
| 4756 |
PyDoc_STR("(CFArrayRef keysToFetch, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFDictionaryRef _rv)")}, |
| 4757 |
{"CFPreferencesSetValue", (PyCFunction)CF_CFPreferencesSetValue, 1, |
| 4758 |
PyDoc_STR("(CFStringRef key, CFTypeRef value, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None")}, |
| 4759 |
{"CFPreferencesSetMultiple", (PyCFunction)CF_CFPreferencesSetMultiple, 1, |
| 4760 |
PyDoc_STR("(CFDictionaryRef keysToSet, CFArrayRef keysToRemove, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None")}, |
| 4761 |
{"CFPreferencesSynchronize", (PyCFunction)CF_CFPreferencesSynchronize, 1, |
| 4762 |
PyDoc_STR("(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (Boolean _rv)")}, |
| 4763 |
{"CFPreferencesCopyApplicationList", (PyCFunction)CF_CFPreferencesCopyApplicationList, 1, |
| 4764 |
PyDoc_STR("(CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)")}, |
| 4765 |
{"CFPreferencesCopyKeyList", (PyCFunction)CF_CFPreferencesCopyKeyList, 1, |
| 4766 |
PyDoc_STR("(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)")}, |
| 4767 |
{"CFStringGetTypeID", (PyCFunction)CF_CFStringGetTypeID, 1, |
| 4768 |
PyDoc_STR("() -> (CFTypeID _rv)")}, |
| 4769 |
{"CFStringCreateWithPascalString", (PyCFunction)CF_CFStringCreateWithPascalString, 1, |
| 4770 |
PyDoc_STR("(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)")}, |
| 4771 |
{"CFStringCreateWithCString", (PyCFunction)CF_CFStringCreateWithCString, 1, |
| 4772 |
PyDoc_STR("(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)")}, |
| 4773 |
{"CFStringCreateWithCharacters", (PyCFunction)CF_CFStringCreateWithCharacters, 1, |
| 4774 |
PyDoc_STR("(Buffer chars) -> (CFStringRef _rv)")}, |
| 4775 |
{"CFStringCreateWithPascalStringNoCopy", (PyCFunction)CF_CFStringCreateWithPascalStringNoCopy, 1, |
| 4776 |
PyDoc_STR("(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)")}, |
| 4777 |
{"CFStringCreateWithCStringNoCopy", (PyCFunction)CF_CFStringCreateWithCStringNoCopy, 1, |
| 4778 |
PyDoc_STR("(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)")}, |
| 4779 |
{"CFStringCreateWithCharactersNoCopy", (PyCFunction)CF_CFStringCreateWithCharactersNoCopy, 1, |
| 4780 |
PyDoc_STR("(Buffer chars) -> (CFStringRef _rv)")}, |
| 4781 |
{"CFStringCreateMutable", (PyCFunction)CF_CFStringCreateMutable, 1, |
| 4782 |
PyDoc_STR("(CFIndex maxLength) -> (CFMutableStringRef _rv)")}, |
| 4783 |
{"CFStringCreateMutableCopy", (PyCFunction)CF_CFStringCreateMutableCopy, 1, |
| 4784 |
PyDoc_STR("(CFIndex maxLength, CFStringRef theString) -> (CFMutableStringRef _rv)")}, |
| 4785 |
{"CFStringCreateWithBytes", (PyCFunction)CF_CFStringCreateWithBytes, 1, |
| 4786 |
PyDoc_STR("(Buffer bytes, CFStringEncoding encoding, Boolean isExternalRepresentation) -> (CFStringRef _rv)")}, |
| 4787 |
{"CFStringGetSystemEncoding", (PyCFunction)CF_CFStringGetSystemEncoding, 1, |
| 4788 |
PyDoc_STR("() -> (CFStringEncoding _rv)")}, |
| 4789 |
{"CFStringGetMaximumSizeForEncoding", (PyCFunction)CF_CFStringGetMaximumSizeForEncoding, 1, |
| 4790 |
PyDoc_STR("(CFIndex length, CFStringEncoding encoding) -> (CFIndex _rv)")}, |
| 4791 |
{"CFStringIsEncodingAvailable", (PyCFunction)CF_CFStringIsEncodingAvailable, 1, |
| 4792 |
PyDoc_STR("(CFStringEncoding encoding) -> (Boolean _rv)")}, |
| 4793 |
{"CFStringGetNameOfEncoding", (PyCFunction)CF_CFStringGetNameOfEncoding, 1, |
| 4794 |
PyDoc_STR("(CFStringEncoding encoding) -> (CFStringRef _rv)")}, |
| 4795 |
{"CFStringConvertEncodingToNSStringEncoding", (PyCFunction)CF_CFStringConvertEncodingToNSStringEncoding, 1, |
| 4796 |
PyDoc_STR("(CFStringEncoding encoding) -> (UInt32 _rv)")}, |
| 4797 |
{"CFStringConvertNSStringEncodingToEncoding", (PyCFunction)CF_CFStringConvertNSStringEncodingToEncoding, 1, |
| 4798 |
PyDoc_STR("(UInt32 encoding) -> (CFStringEncoding _rv)")}, |
| 4799 |
{"CFStringConvertEncodingToWindowsCodepage", (PyCFunction)CF_CFStringConvertEncodingToWindowsCodepage, 1, |
| 4800 |
PyDoc_STR("(CFStringEncoding encoding) -> (UInt32 _rv)")}, |
| 4801 |
{"CFStringConvertWindowsCodepageToEncoding", (PyCFunction)CF_CFStringConvertWindowsCodepageToEncoding, 1, |
| 4802 |
PyDoc_STR("(UInt32 codepage) -> (CFStringEncoding _rv)")}, |
| 4803 |
{"CFStringConvertEncodingToIANACharSetName", (PyCFunction)CF_CFStringConvertEncodingToIANACharSetName, 1, |
| 4804 |
PyDoc_STR("(CFStringEncoding encoding) -> (CFStringRef _rv)")}, |
| 4805 |
{"CFStringGetMostCompatibleMacStringEncoding", (PyCFunction)CF_CFStringGetMostCompatibleMacStringEncoding, 1, |
| 4806 |
PyDoc_STR("(CFStringEncoding encoding) -> (CFStringEncoding _rv)")}, |
| 4807 |
{"__CFStringMakeConstantString", (PyCFunction)CF___CFStringMakeConstantString, 1, |
| 4808 |
PyDoc_STR("(char* cStr) -> (CFStringRef _rv)")}, |
| 4809 |
{"CFURLGetTypeID", (PyCFunction)CF_CFURLGetTypeID, 1, |
| 4810 |
PyDoc_STR("() -> (CFTypeID _rv)")}, |
| 4811 |
{"CFURLCreateWithBytes", (PyCFunction)CF_CFURLCreateWithBytes, 1, |
| 4812 |
PyDoc_STR("(Buffer URLBytes, CFStringEncoding encoding, CFURLRef baseURL) -> (CFURLRef _rv)")}, |
| 4813 |
{"CFURLCreateFromFileSystemRepresentation", (PyCFunction)CF_CFURLCreateFromFileSystemRepresentation, 1, |
| 4814 |
PyDoc_STR("(Buffer buffer, Boolean isDirectory) -> (CFURLRef _rv)")}, |
| 4815 |
{"CFURLCreateFromFileSystemRepresentationRelativeToBase", (PyCFunction)CF_CFURLCreateFromFileSystemRepresentationRelativeToBase, 1, |
| 4816 |
PyDoc_STR("(Buffer buffer, Boolean isDirectory, CFURLRef baseURL) -> (CFURLRef _rv)")}, |
| 4817 |
{"CFURLCreateFromFSRef", (PyCFunction)CF_CFURLCreateFromFSRef, 1, |
| 4818 |
PyDoc_STR("(FSRef fsRef) -> (CFURLRef _rv)")}, |
| 4819 |
{"toCF", (PyCFunction)CF_toCF, 1, |
| 4820 |
PyDoc_STR("(python_object) -> (CF_object)")}, |
| 4821 |
{NULL, NULL, 0} |
| 4822 |
}; |
| 4823 |
|
| 4824 |
|
| 4825 |
|
| 4826 |
|
| 4827 |
|
| 4828 |
PyObject *CFObj_New(CFTypeRef itself) |
| 4829 |
{ |
| 4830 |
if (itself == NULL) |
| 4831 |
{ |
| 4832 |
PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); |
| 4833 |
return NULL; |
| 4834 |
} |
| 4835 |
if (CFGetTypeID(itself) == CFArrayGetTypeID()) return CFArrayRefObj_New((CFArrayRef)itself); |
| 4836 |
if (CFGetTypeID(itself) == CFDictionaryGetTypeID()) return CFDictionaryRefObj_New((CFDictionaryRef)itself); |
| 4837 |
if (CFGetTypeID(itself) == CFDataGetTypeID()) return CFDataRefObj_New((CFDataRef)itself); |
| 4838 |
if (CFGetTypeID(itself) == CFStringGetTypeID()) return CFStringRefObj_New((CFStringRef)itself); |
| 4839 |
if (CFGetTypeID(itself) == CFURLGetTypeID()) return CFURLRefObj_New((CFURLRef)itself); |
| 4840 |
|
| 4841 |
return CFTypeRefObj_New(itself); |
| 4842 |
} |
| 4843 |
int CFObj_Convert(PyObject *v, CFTypeRef *p_itself) |
| 4844 |
{ |
| 4845 |
|
| 4846 |
if (v == Py_None) { *p_itself = NULL; return 1; } |
| 4847 |
|
| 4848 |
|
| 4849 |
if (!CFTypeRefObj_Check(v) && |
| 4850 |
!CFArrayRefObj_Check(v) && |
| 4851 |
!CFMutableArrayRefObj_Check(v) && |
| 4852 |
!CFDictionaryRefObj_Check(v) && |
| 4853 |
!CFMutableDictionaryRefObj_Check(v) && |
| 4854 |
!CFDataRefObj_Check(v) && |
| 4855 |
!CFMutableDataRefObj_Check(v) && |
| 4856 |
!CFStringRefObj_Check(v) && |
| 4857 |
!CFMutableStringRefObj_Check(v) && |
| 4858 |
!CFURLRefObj_Check(v) ) |
| 4859 |
{ |
| 4860 |
|
| 4861 |
PyErr_SetString(PyExc_TypeError, "CF object required"); |
| 4862 |
return 0; |
| 4863 |
} |
| 4864 |
*p_itself = ((CFTypeRefObject *)v)->ob_itself; |
| 4865 |
return 1; |
| 4866 |
} |
| 4867 |
|
| 4868 |
|
| 4869 |
void init_CF(void) |
| 4870 |
{ |
| 4871 |
PyObject *m; |
| 4872 |
PyObject *d; |
| 4873 |
|
| 4874 |
|
| 4875 |
|
| 4876 |
PyMac_INIT_TOOLBOX_OBJECT_NEW(CFTypeRef, CFObj_New); |
| 4877 |
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFTypeRef, CFObj_Convert); |
| 4878 |
PyMac_INIT_TOOLBOX_OBJECT_NEW(CFTypeRef, CFTypeRefObj_New); |
| 4879 |
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFTypeRef, CFTypeRefObj_Convert); |
| 4880 |
PyMac_INIT_TOOLBOX_OBJECT_NEW(CFStringRef, CFStringRefObj_New); |
| 4881 |
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFStringRef, CFStringRefObj_Convert); |
| 4882 |
PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableStringRef, CFMutableStringRefObj_New); |
| 4883 |
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableStringRef, CFMutableStringRefObj_Convert); |
| 4884 |
PyMac_INIT_TOOLBOX_OBJECT_NEW(CFArrayRef, CFArrayRefObj_New); |
| 4885 |
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFArrayRef, CFArrayRefObj_Convert); |
| 4886 |
PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableArrayRef, CFMutableArrayRefObj_New); |
| 4887 |
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableArrayRef, CFMutableArrayRefObj_Convert); |
| 4888 |
PyMac_INIT_TOOLBOX_OBJECT_NEW(CFDictionaryRef, CFDictionaryRefObj_New); |
| 4889 |
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFDictionaryRef, CFDictionaryRefObj_Convert); |
| 4890 |
PyMac_INIT_TOOLBOX_OBJECT_NEW(CFMutableDictionaryRef, CFMutableDictionaryRefObj_New); |
| 4891 |
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFMutableDictionaryRef, CFMutableDictionaryRefObj_Convert); |
| 4892 |
PyMac_INIT_TOOLBOX_OBJECT_NEW(CFURLRef, CFURLRefObj_New); |
| 4893 |
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef, CFURLRefObj_Convert); |
| 4894 |
|
| 4895 |
|
| 4896 |
m = Py_InitModule("_CF", CF_methods); |
| 4897 |
d = PyModule_GetDict(m); |
| 4898 |
CF_Error = PyMac_GetOSErrException(); |
| 4899 |
if (CF_Error == NULL || |
| 4900 |
PyDict_SetItemString(d, "Error", CF_Error) != 0) |
| 4901 |
return; |
| 4902 |
CFTypeRef_Type.ob_type = &PyType_Type; |
| 4903 |
if (PyType_Ready(&CFTypeRef_Type) < 0) return; |
| 4904 |
Py_INCREF(&CFTypeRef_Type); |
| 4905 |
PyModule_AddObject(m, "CFTypeRef", (PyObject *)&CFTypeRef_Type); |
| 4906 |
|
| 4907 |
Py_INCREF(&CFTypeRef_Type); |
| 4908 |
PyModule_AddObject(m, "CFTypeRefType", (PyObject *)&CFTypeRef_Type); |
| 4909 |
CFArrayRef_Type.ob_type = &PyType_Type; |
| 4910 |
CFArrayRef_Type.tp_base = &CFTypeRef_Type; |
| 4911 |
if (PyType_Ready(&CFArrayRef_Type) < 0) return; |
| 4912 |
Py_INCREF(&CFArrayRef_Type); |
| 4913 |
PyModule_AddObject(m, "CFArrayRef", (PyObject *)&CFArrayRef_Type); |
| 4914 |
|
| 4915 |
Py_INCREF(&CFArrayRef_Type); |
| 4916 |
PyModule_AddObject(m, "CFArrayRefType", (PyObject *)&CFArrayRef_Type); |
| 4917 |
CFMutableArrayRef_Type.ob_type = &PyType_Type; |
| 4918 |
CFMutableArrayRef_Type.tp_base = &CFArrayRef_Type; |
| 4919 |
if (PyType_Ready(&CFMutableArrayRef_Type) < 0) return; |
| 4920 |
Py_INCREF(&CFMutableArrayRef_Type); |
| 4921 |
PyModule_AddObject(m, "CFMutableArrayRef", (PyObject *)&CFMutableArrayRef_Type); |
| 4922 |
|
| 4923 |
Py_INCREF(&CFMutableArrayRef_Type); |
| 4924 |
PyModule_AddObject(m, "CFMutableArrayRefType", (PyObject *)&CFMutableArrayRef_Type); |
| 4925 |
CFDictionaryRef_Type.ob_type = &PyType_Type; |
| 4926 |
CFDictionaryRef_Type.tp_base = &CFTypeRef_Type; |
| 4927 |
if (PyType_Ready(&CFDictionaryRef_Type) < 0) return; |
| 4928 |
Py_INCREF(&CFDictionaryRef_Type); |
| 4929 |
PyModule_AddObject(m, "CFDictionaryRef", (PyObject *)&CFDictionaryRef_Type); |
| 4930 |
|
| 4931 |
Py_INCREF(&CFDictionaryRef_Type); |
| 4932 |
PyModule_AddObject(m, "CFDictionaryRefType", (PyObject *)&CFDictionaryRef_Type); |
| 4933 |
CFMutableDictionaryRef_Type.ob_type = &PyType_Type; |
| 4934 |
CFMutableDictionaryRef_Type.tp_base = &CFDictionaryRef_Type; |
| 4935 |
if (PyType_Ready(&CFMutableDictionaryRef_Type) < 0) return; |
| 4936 |
Py_INCREF(&CFMutableDictionaryRef_Type); |
| 4937 |
PyModule_AddObject(m, "CFMutableDictionaryRef", (PyObject *)&CFMutableDictionaryRef_Type); |
| 4938 |
|
| 4939 |
Py_INCREF(&CFMutableDictionaryRef_Type); |
| 4940 |
PyModule_AddObject(m, "CFMutableDictionaryRefType", (PyObject *)&CFMutableDictionaryRef_Type); |
| 4941 |
CFDataRef_Type.ob_type = &PyType_Type; |
| 4942 |
CFDataRef_Type.tp_base = &CFTypeRef_Type; |
| 4943 |
if (PyType_Ready(&CFDataRef_Type) < 0) return; |
| 4944 |
Py_INCREF(&CFDataRef_Type); |
| 4945 |
PyModule_AddObject(m, "CFDataRef", (PyObject *)&CFDataRef_Type); |
| 4946 |
|
| 4947 |
Py_INCREF(&CFDataRef_Type); |
| 4948 |
PyModule_AddObject(m, "CFDataRefType", (PyObject *)&CFDataRef_Type); |
| 4949 |
CFMutableDataRef_Type.ob_type = &PyType_Type; |
| 4950 |
CFMutableDataRef_Type.tp_base = &CFDataRef_Type; |
| 4951 |
if (PyType_Ready(&CFMutableDataRef_Type) < 0) return; |
| 4952 |
Py_INCREF(&CFMutableDataRef_Type); |
| 4953 |
PyModule_AddObject(m, "CFMutableDataRef", (PyObject *)&CFMutableDataRef_Type); |
| 4954 |
|
| 4955 |
Py_INCREF(&CFMutableDataRef_Type); |
| 4956 |
PyModule_AddObject(m, "CFMutableDataRefType", (PyObject *)&CFMutableDataRef_Type); |
| 4957 |
CFStringRef_Type.ob_type = &PyType_Type; |
| 4958 |
CFStringRef_Type.tp_base = &CFTypeRef_Type; |
| 4959 |
if (PyType_Ready(&CFStringRef_Type) < 0) return; |
| 4960 |
Py_INCREF(&CFStringRef_Type); |
| 4961 |
PyModule_AddObject(m, "CFStringRef", (PyObject *)&CFStringRef_Type); |
| 4962 |
|
| 4963 |
Py_INCREF(&CFStringRef_Type); |
| 4964 |
PyModule_AddObject(m, "CFStringRefType", (PyObject *)&CFStringRef_Type); |
| 4965 |
CFMutableStringRef_Type.ob_type = &PyType_Type; |
| 4966 |
CFMutableStringRef_Type.tp_base = &CFStringRef_Type; |
| 4967 |
if (PyType_Ready(&CFMutableStringRef_Type) < 0) return; |
| 4968 |
Py_INCREF(&CFMutableStringRef_Type); |
| 4969 |
PyModule_AddObject(m, "CFMutableStringRef", (PyObject *)&CFMutableStringRef_Type); |
| 4970 |
|
| 4971 |
Py_INCREF(&CFMutableStringRef_Type); |
| 4972 |
PyModule_AddObject(m, "CFMutableStringRefType", (PyObject *)&CFMutableStringRef_Type); |
| 4973 |
CFURLRef_Type.ob_type = &PyType_Type; |
| 4974 |
CFURLRef_Type.tp_base = &CFTypeRef_Type; |
| 4975 |
if (PyType_Ready(&CFURLRef_Type) < 0) return; |
| 4976 |
Py_INCREF(&CFURLRef_Type); |
| 4977 |
PyModule_AddObject(m, "CFURLRef", (PyObject *)&CFURLRef_Type); |
| 4978 |
|
| 4979 |
Py_INCREF(&CFURLRef_Type); |
| 4980 |
PyModule_AddObject(m, "CFURLRefType", (PyObject *)&CFURLRef_Type); |
| 4981 |
|
| 4982 |
#define _STRINGCONST(name) PyModule_AddObject(m, #name, CFStringRefObj_New(name)) |
| 4983 |
_STRINGCONST(kCFPreferencesAnyApplication); |
| 4984 |
_STRINGCONST(kCFPreferencesCurrentApplication); |
| 4985 |
_STRINGCONST(kCFPreferencesAnyHost); |
| 4986 |
_STRINGCONST(kCFPreferencesCurrentHost); |
| 4987 |
_STRINGCONST(kCFPreferencesAnyUser); |
| 4988 |
_STRINGCONST(kCFPreferencesCurrentUser); |
| 4989 |
|
| 4990 |
|
| 4991 |
|
| 4992 |
} |
| 4993 |
|
| 4994 |
|
| 4995 |
|