[Pyobjc-dev] Re: NSAnyEventMask as unsigned?
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-10-29 17:51:33
|
On 29 okt 2003, at 18:39, Bob Ippolito wrote: > On Oct 29, 2003, at 12:28 PM, Ronald Oussoren wrote: > >> Why is it a problem that NSAnyEventMask is -1? It is also -1 in ObjC >> and therefore I suppose the conversion from Python to ObjC for >> ``unsigned int`` values is too strict and doesn't accept -1 as a >> valid value. > > It is 0xffffffffU in ObjC -- the fact that it has the same binary > representation as the signed -1 is just a side effect. The conversion > from Python to ObjC is indeed too strict for this kind of conversion, > but rightly so, if you agree with the direction that Python itself is > moving. For example, in Python 2.4, 0xffffffff without the L > qualifier will become 0xffffffffL, instead of the current -1. You read the header file :-). The 'U' is bogus, it is inside an enum definition and enums are signed integers. The following program should make this clear: #include <stdio.h> #import <AppKit/AppKit.h> int main(void) { printf("%s\n", @encode(__typeof__(NSAnyEventMask))); return 0; } This prints 'i', which is the type-code for 'int'. I don't like the hand-coded list, and therefore tried to be smart by adding the type encoding for constants to the inttable structure which didn't work because of the signedness of enums :-(. I'll update the CodeGenerator scripts to detect '*Mask' as unsigned integers instead of plain integers. Ronald |