Re: [Pyobjc-dev] Explicit conversion from ObjC to PyObject?
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2009-08-11 09:55:04
|
On 1 Aug, 2009, at 2:08, Greg Abbas wrote: > FWIW I think I figured out how to do this: pyobjc-api.h defines > several macros including PyObjC_ObjCToPython and PyObjC_PythonToObjC. > The only wrinkle is that you need to make sure you call > PyObjC_ImportAPI first (and be a little clever because of how it > stores a function table pointer in a static variable), but it seems to > work great. > > Well actually, there's sort of another wrinkle which is that as far as > I can tell PyObjC_ImportAPI isn't an official or supported API. So > caveat emptor, but hopefully it's pretty stable at this point. The API is unsupported, but is used by the framework wrappers as well. I might clean up the API in a future release, but that should be doable while retaining backward compatibility for the bits of interface that are retained. Using PyObjC_ObjCToPython and PyObjC_PythonToObjC will definitely be retained in future editions of the API. Ronald > > On Jul 27, 2009, at 10:29 PM, Greg Abbas wrote: > >> Hi, >> >> Is it feasible to mix the "old-fashioned" Python C API with PyObjC? >> Specifically, I'm exposing some C++ classes to Python using >> PyType_Ready and all of that, but some of those methods are actually >> Objective-C++ code and return Objective C instances such as >> NSColor. I >> could manually wrap them too, but that seems wasteful considering all >> the excellent work that's gone into creating PyObjC. Is there a way >> to >> explicitly ask PyObjC to wrap an Objective C object and turn it >> into a >> PyObject* proxy that I can return to the Python interpreter? >> >> All the PyObjC examples that I've found so far assume that you're not >> using any other low-level interface, and so everything is magically >> wrapped & unwrapped whenever it crosses the Python<->ObjC boundary. >> But what if I want to participate in that boundary manually? Is there >> a "PyObject * convertObjCToPython(id)" function that I can call? (Or >> convertPythonToObjC, for that matter?) >> >> Thanks very much in advance for any insights. >> >> -greg abbas. >> >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> 30-Day >> trial. Simplify your report design, integration and deployment - and >> focus on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and > focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |