[Pyobjc-dev] pythonify_c_value oddities
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-02-23 16:11:43
|
I noticed values of type 'char' are translated into integers when going from Objective-C to python. I'd expect a string of length 1. IMHO depythonify_c_value is a bit to strict in the values it accepts. As an example: when translating to an Objective-C int it won't accept a Python long. Should we use PyArg_Parse to convert Python objects to basic C types? This would at least make us consistent with other extension modules, even though PyArg_Parse doesn't deal (yet?) with unsigned types. I've currently dealt with this adding more code: We now accept python longs where we accepts ints (and the other way around). While I was busy I also adding some range-checking code: Conversions to Objective-C only succeed if the Python number is within the range accepted by the C type. The checks are currently very strict, if this proves to be too strict we can relax the rules a little (at least for unsigned native types). There is no range checking for floating point numbers, I'll leave that for someone who's knows more about the issues around floating point calculations. Ronald |