[Pyobjc-dev] Variadic ObjC methods
Brought to you by:
ronaldoussoren
|
From: Michael M. <mic...@gm...> - 2008-01-29 19:17:25
|
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
I looked at the SVN trunk, and it seems to have support for arguments
passed as null terminated C arrays. I found, eg.,
'PyObjC_kNullTerminatedArray' being handled in a couple of places. Is
this new since the 10.5 release, or am I not triggering that code for
some reason?
As a workaround for NSGradient, this other method works just fine:
import array
aGradient = NSGradient.alloc().initWithColors_atLocations_colorSpace_([NSColor.blackColor(),
NSColor.whiteColor(), NSColor.blackColor()],
array.array('f', [0.0, 0.5, 1.0]),
NSColorSpace.deviceRGBColorSpace())
Mostly I'm just curious.
Thanks,
-mike
--
Michael McCracken
UCSD CSE PhD Candidate
research: http://www.cse.ucsd.edu/~mmccrack/
misc: http://michael-mccracken.net/wp/
|