Re: [Pyobjc-dev] Variadic ObjC methods
Brought to you by:
ronaldoussoren
|
From: Michael M. <mic...@gm...> - 2008-02-01 01:21:52
|
This seemed like a good excuse to learn a bit more about the
bridgesupport metadata, so I looked at AppKit's
PyObjCOverrides.bridgesupport file and found this entry for
NSGradient:
<class name='NSGradient'>
<method selector='initWithColors:atLocations:colorSpace:'>
<arg c_array_length_in_arg='0' index='1' type_modifier='n' />
</method>
<method selector='initWithColorsAndLocations:' suggestion='Use
initWithColors:atLocation:colorspace:' variadic='true' />
</class>
Contrast the entry for arrayWithObjects:
<method c_array_delimited_by_null='true' class_method='true'
selector='arrayWithObjects:' variadic='true' />
This seems to explain why I got the error, but I couldn't quite figure
out how that suggestion was being ignored and replaced with the less
helpful one I got.
I found the suggestion I got ("Variadic functions/methods are not
supported") being set in method-signature.m:499, but it seems like it
shouldn't get there for this method, because a suggestion already
exists.
Anyway, I was trying to do some spelunking without actually having
time to check out and build things, so that's as far as I got. I'd be
curious to hear more about what's going on here.
Thanks,
-mike
On Jan 30, 2008 11:57 AM, Barry Wark <bar...@gm...> wrote:
>
> On Jan 30, 2008 11:45 AM, Ronald Oussoren <ron...@ma...> wrote:
> >
> > On 29 Jan, 2008, at 20:17, Michael McCracken wrote:
> >
> > > I was trying to init an NSGradient with the system PyObjC 2.0 in 10.5,
> > > like this:
> > >
> > > aGradient =
> > > NSGradient.alloc().initWithColorsAndLocations_(NSColor.blackColor(),
> > > 0.0, NSColor.whiteColor(), 1.0, None)
> > >
> > > just a straight translation from ObjC. It didn't work:
> > >
> > > File "/Users/mmccrack/Products/Debug/Incoming.app/Contents/
> > > Resources/INAnimActionView.py",
> > > line 199, in drawRect_
> > > aGradient.initWithColorsAndLocations_(NSColor.blackColor(), 0.0,
> > > NSColor.whiteColor(), 1.0, None)
> > > TypeError: Variadic functions/methods are not supported
> >
> > That's annoying, this is supposed to work. I'll have to look more
> > closely to see what's going on, but my first guess is broken metadata.
> >
>
> Broken metadata for the initWithColorsAndLocations: seems likely to me
> too. This does work:
> In [2]: NSArray.arrayWithObjects_('abc',2,None)
> Out[2]:
> (
> abc,
> 2
> )
>
> barry
>
--
Michael McCracken
UCSD CSE PhD Candidate
research: http://www.cse.ucsd.edu/~mmccrack/
misc: http://michael-mccracken.net/wp/
|