Re: [Pyobjc-dev] using PyObjCPointers (howto?)
Brought to you by:
ronaldoussoren
|
From: Ronald O. <ron...@ma...> - 2008-02-01 07:10:32
|
On 31 Jan, 2008, at 17:55, scott herzinger wrote:
> I'm working with PyObjC version 2.0 per the Leopard distribution.
> QTTrack.quickTimeMovie and QTMedia.quickTimeMovie both return
> PyObjCPointers. For example, suppose movie is a QTMovie:
>
> >>> track = movie.tracks()[0]
> track = movie.tracks()[0]
> >>> media = track.media()
> media = track.media()
> >>> pprint((movie, track, media))
> pprint((movie, track, media))
> (<QTMovie: 0x1a6bc30 time scale = 600, duration = 52049, rate =
> 0.000000, tracks = { 0x1bf0c30 0x1bf0ec0 }>,
> <QTTrack: 0x1bf0c30 Size = { 240, 320 }, QTMedia = 0x1f97a00>,
> <QTMedia: 0x1f97a00 type = 'vide', time scale = 1500, duration =
> 130000>)
> >>> qtm = media.quickTimeMedia()
> qtm = media.quickTimeMedia()
> 2008-01-31 11:19:37.248 Python[7943:613] PyObjCPointer created: at
> 0xcbef4 of type ^{MediaType}
> >>> qtm
> qtm
> <PyObjCPointer object at 0x27601c0>
> >>>
That's rather annoying. I've added this to my todo list for pyobjc 2.1.
>
>
> FWIW there are other indications that QTKit is not completely
> wrapped. For example, none of the QTMovie.movieWith... class methods
> appear to be available in PyObjC (e.g. movieWithFile, movieWithURL).
> Instance methods like initWithFile are available, so the absence of
> class methods is not a showstopper.
The class methods are available, even if introspection doesn't show
them:
:>>>QTKit.QTMovie.movieWithFile_(None)
2008-02-01 08:03:20.907 Python[2971:613] *** WARNING: Method
movieWithFile: in class QTMovie is obsolete ***
>
The introspection issue is caused by the way class methods are
implemented: they are methods on the metaclass (just like in Objective-
C) and Python's standard introspection tools (and PyObjC's
classbrowser samples) don't know how to deal with that.
This implementation method is needed to be able to use class and
instance methods that have the same name, the trivial example of that:
>>> from Foundation import NSObject
>>> NSObject.description()
u'NSObject'
>>> NSObject.new().description()
u'<NSObject: 0x1a6aed0>'
>>>
There are more interesting methods like this though, including some
where the instance method is undocumented and PyObjC 1.x would
unexpectly call the instance method when a user wanted to use the
documented class method.
>
> I'm targeting 10.5 and beyond. QTKit doesn't yet let me get at the
> media bits in ways that I need in my application. AudioUnits may be
> applicable, but I haven't had a chance to come up to speed with them.
Have you filed a bug at Apple for that? As I said, Carbon Quicktime
isn't available in 64-bit mode and I'm sure Apple would be interested
to hear about usecases that cannot fully use QTKit.
Ronald
>
>
> Thanks,
> Scott
>
>
>
> On Jan 31, 2008, at 4:33 AM, Ronald Oussoren wrote:
>
>>
>> On 30 Jan, 2008, at 23:33, Scott Herzinger wrote:
>>
>>> I'm looking for an idiom by which I can use a given PyObjCPointer,
>>> that I get back from some Cocoa API, as a Carbon object (or
>>> pointer thereto). My specific requirement currently is to take a
>>> PyObjCPointer that I get back from a QTKit API, and use its
>>> referent as a Carbon.Qt.Media object.
>>
>> PyObjCPointer objects are an indication of an incomplete wrapping
>> of a framework. Which method returns a PyObjCPointer and in which
>> version of PyObjC?
>>
>> In PyObjC2 a PyObjCPointer has an "pointerAsInteger" atrribute that
>> returns the numeric value of the pointer, I don't remember if
>> PyObjC1 has the same attribute. With that value and ctypes you can
>> contruct a Carbon.QT object.
>>
>> BTW. What OS release are you targetting? Apple is clearly stearing
>> away from the Carbon QuickTime API's in favour of QTKit (no 64-bit
>> support in the Carbon API, no new development as well).
>>
>> Ronald
>
|