[Pyobjc-dev] caution with BOOL parameters
Brought to you by:
ronaldoussoren
From: <bo...@pa...> - 2003-03-01 18:36:15
|
if you try to pass an int whose magnitude is greater than can be stored in a char (-256/+255), then you will get objc.error: depythonifying 'char', got int of wrong magnitude for example, with a table with greater than 255 rows, the following will fail: self.theButton.setEnabled_(self.theTableView.numberOfRows()) but self.theButton.setEnabled_(self.theTableView.numberOfRows() != 0) works as expected. i assume (but haven't tested), that (say) delegate methods which return a BOOL will also fail if the return value is outside the range. also, one things i've done in my version of obj_support.m is to change identical messages to different ones, e.g., changing 'depythonifying' to 'depythonifyingN' so i can tell which constraint failed: ObjCErr_Set(ObjCExc_error, "depythonifying3 'char', got %s of " "wrong magnitude", argument->ob_type->tp_name); since python doesnt have a char datatype, one alternative is to relax the constraint (in obj_support.m) that _C_CHR parameters must be within range, and instead mask off all but the bottom 8 bits. --bob pasker bo...@pa... |