[Python-checkins] python/dist/src/Mac/Modules/cf _CFmodule.c,1.12,1.13
jackjansen@sourceforge.net
jackjansen@sourceforge.net
Tue, 07 May 2002 15:59:55 -0700
Update of /cvsroot/python/python/dist/src/Mac/Modules/cf
In directory usw-pr-cvs1:/tmp/cvs-serv27449/Python/Mac/Modules/cf
Modified Files:
_CFmodule.c
Log Message:
More support for bridging between Python and CoreFoundation objects. Still untested.
Index: _CFmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/_CFmodule.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** _CFmodule.c 23 Apr 2002 22:45:47 -0000 1.12
--- _CFmodule.c 7 May 2002 22:59:53 -0000 1.13
***************
*** 32,35 ****
--- 32,37 ----
#endif
+ #include "pycfbridge.h"
+
#ifdef USE_TOOLBOX_OBJECT_GLUE
extern PyObject *_CFTypeRefObj_New(CFTypeRef);
***************
*** 288,291 ****
--- 290,301 ----
}
+ static PyObject *CFTypeRefObj_toPython(CFTypeRefObject *_self, PyObject *_args)
+ {
+ PyObject *_res = NULL;
+
+ return PyCF_CF2Python(_self->ob_itself);
+
+ }
+
static PyMethodDef CFTypeRefObj_methods[] = {
{"CFGetTypeID", (PyCFunction)CFTypeRefObj_CFGetTypeID, 1,
***************
*** 305,308 ****
--- 315,320 ----
{"CFShow", (PyCFunction)CFTypeRefObj_CFShow, 1,
"() -> None"},
+ {"toPython", (PyCFunction)CFTypeRefObj_toPython, 1,
+ "() -> (python_object)"},
{NULL, NULL, 0}
};
***************
*** 3696,3699 ****
--- 3708,3735 ----
}
+ static PyObject *CF_toCF(PyObject *_self, PyObject *_args)
+ {
+ PyObject *_res = NULL;
+
+ 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);
+
+ }
+
static PyMethodDef CF_methods[] = {
{"__CFRangeMake", (PyCFunction)CF___CFRangeMake, 1,
***************
*** 3779,3782 ****
--- 3815,3820 ----
{"CFURLCreateFromFSRef", (PyCFunction)CF_CFURLCreateFromFSRef, 1,
"(FSRef fsRef) -> (CFURLRef _rv)"},
+ {"toCF", (PyCFunction)CF_toCF, 1,
+ "(python_object) -> (CF_object)"},
{NULL, NULL, 0}
};