Re: [Pyobjc-dev] Passing objects between PyObjc and SWIG
Brought to you by:
ronaldoussoren
|
From: Ronald O. <ron...@ma...> - 2008-03-20 14:06:11
|
On 20 Mar, 2008, at 11:27, Kyle Johnson wrote: > I have a C library (Cairo) which accesses Core Graphics. I've wrapped > it up in a SWIG binding so I can easily access it from Python. > > Everything is great when calling functions in it and passing around > objects from Apple's CoreGraphics Python library (which they generated > with SWIG as well). However, when I switch from using Apple's > CoreGraphics to using PyObjc libraries (AppKit and Quartz) and try to > pass a CGContextRef from a PyObjC lib to the SWIG-wrapped library I > get errors because SWIG doesn't recognize the PyObjc wrapping of the > object. > > So basically, I need to code something which converts the PyObjc > internal type to a SWIG-understandable internal type. > > Here's the problem: I can't figure out where to dig around in PyObjc > to find the representation of "core-foundation class CGContextRef." Is > this something which is being generated automatically and not > hand-coded somewhere? Those types are automaticly generated. You can use the __cobject__() method on all Objective-C or CoreFoundation objects to get a Python CObject that wraps the raw pointer. That might be easier to convert to something that swig might understand. Ronald |