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