Re: [Pyobjc-dev] caution with BOOL parameters
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-03-01 20:19:16
|
On Saturday, Mar 1, 2003, at 20:56 Europe/Amsterdam, Bob Pasker wrote: > this begs the question: in pyobjc, is the 'c' in a method signature > ONLY used for BOOL types? Nope, 'c' is used for 'char', hence the _C_CHR ;-) ;-). > if so, then maybe the right answer is to > put the test in obj_support.m, ie, change > > case _C_CHR: case _C_SHT: > return pythonify_c_value(intType, datum); > > to something like: > > case _C_SHT: > return pythonify_c_value(intType, datum); > case _C_CHR: > return (pythonify_c_value(intType, datum) != 0); > > in general, the programmer should return an expression that evaluates > to > 0 or 1 for objc bool parameters. but most languages without a true > boolean type permit integer types to be used as boolean > expression without a boolean operator operators. python falls into > this category, and using the bridge should not require a special > idiom for booleans ("always return/pass a boolean expression, not > an int"). I'm afraid this is one of the places where the bridge cannot be completely transparent. In Python you can use any object as a boolean (most are evaluated as true, some are false), but with PyObjC you'll have to use small integers. Let's hope someone sees this as his/her cue to come up with a very clever solution. Ronald |