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