mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
More support for bridging between Python and CoreFoundation objects. Still untested.
This commit is contained in:
parent
cb376460b7
commit
5ad6f7a3a9
3 changed files with 131 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue