diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2002-05-07 23:00:03 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2002-05-07 23:00:03 (GMT) |
commit | 5ad6f7a3a9190df03583ff9c0426a97e15a63ada (patch) | |
tree | fa1ec9e86aff16e6fd0be841a784f2af9e9934fe /Mac/Modules/cf/cfsupport.py | |
parent | cb376460b76b760f28761150413192402cda6f54 (diff) | |
download | cpython-5ad6f7a3a9190df03583ff9c0426a97e15a63ada.zip cpython-5ad6f7a3a9190df03583ff9c0426a97e15a63ada.tar.gz cpython-5ad6f7a3a9190df03583ff9c0426a97e15a63ada.tar.bz2 |
More support for bridging between Python and CoreFoundation objects. Still untested.
Diffstat (limited to 'Mac/Modules/cf/cfsupport.py')
-rw-r--r-- | Mac/Modules/cf/cfsupport.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Mac/Modules/cf/cfsupport.py b/Mac/Modules/cf/cfsupport.py index fb275c3..d690441 100644 --- a/Mac/Modules/cf/cfsupport.py +++ b/Mac/Modules/cf/cfsupport.py @@ -53,6 +53,8 @@ includestuff = includestuff + """ #include <CoreServices/CoreServices.h> #endif +#include "pycfbridge.h" + #ifdef USE_TOOLBOX_OBJECT_GLUE extern PyObject *_CFTypeRefObj_New(CFTypeRef); extern int _CFTypeRefObj_Convert(PyObject *, CFTypeRef *); @@ -485,6 +487,37 @@ f = ManualGenerator("CFStringGetUnicode", getasunicode_body); f.docstring = lambda: "() -> (unicode _rv)" CFStringRef_object.add(f) +toPython_body = """ +return PyCF_CF2Python(_self->ob_itself); +""" + +f = ManualGenerator("toPython", toPython_body); +f.docstring = lambda: "() -> (python_object)" +CFTypeRef_object.add(f) + +toCF_body = """ +CFTypeRef rv; +CFTypeID typeid; + +if (!PyArg_ParseTuple(_args, "O&", PyCF_Python2CF, &rv)) + return NULL; +typeid = CFGetTypeID(rv); + +if (typeid == CFStringGetTypeID()) + return Py_BuildValue("O&", CFStringRefObj_New, rv); +if (typeid == CFArrayGetTypeID()) + return Py_BuildValue("O&", CFArrayRefObj_New, rv); +if (typeid == CFDictionaryGetTypeID()) + return Py_BuildValue("O&", CFDictionaryRefObj_New, rv); +if (typeid == CFURLGetTypeID()) + return Py_BuildValue("O&", CFURLRefObj_New, rv); + +return Py_BuildValue("O&", CFTypeRefObj_New, rv); +""" +f = ManualGenerator("toCF", toCF_body); +f.docstring = lambda: "(python_object) -> (CF_object)" +module.add(f) + # ADD add forloop here # generate output (open the output file as late as possible) |