@@ -119,15 +119,15 @@ class Complete(Structure):
119119#
120120
121121# Platform-specific type codes
122- s_bool = { 1 : '?' , 2 : 'H' , 4 : 'L' , 8 : 'Q' }[ sizeof ( c_bool )]
123- s_short = { 2 : 'h' , 4 : 'l' , 8 : 'q' }[ sizeof ( c_short )]
124- s_ushort = { 2 : 'H' , 4 : 'L' , 8 : 'Q' }[ sizeof ( c_ushort )]
125- s_int = { 2 : 'h' , 4 : 'i' , 8 : 'q' }[ sizeof ( c_int )]
126- s_uint = { 2 : 'H' , 4 : 'I' , 8 : 'Q' }[ sizeof ( c_uint )]
127- s_long = { 4 : 'l' , 8 : 'q' }[ sizeof ( c_long )]
128- s_ulong = { 4 : 'L' , 8 : 'Q' }[ sizeof ( c_ulong )]
129- s_longlong = "q"
130- s_ulonglong = "Q"
122+ s_bool = c_bool . _type_
123+ s_short = c_short . _type_
124+ s_ushort = c_ushort . _type_
125+ s_int = c_int . _type_
126+ s_uint = c_uint . _type_
127+ s_long = c_long . _type_
128+ s_ulong = c_ulong . _type_
129+ s_longlong = c_longlong . _type_
130+ s_ulonglong = c_ulonglong . _type_
131131s_float = "f"
132132s_double = "d"
133133s_longdouble = "g"
@@ -194,9 +194,9 @@ class Complete(Structure):
194194 (Point , "T{l:x:l:y:}" .replace ('l' , s_long ), (), Point ),
195195 (PackedPoint , "T{l:x:l:y:}" .replace ('l' , s_long ), (), PackedPoint ),
196196 (PointMidPad , "T{b:x:3xI:y:}" .replace ('I' , s_uint ), (), PointMidPad ),
197- (PackedPointMidPad , "T{b:x:xQ:y:}" , (), PackedPointMidPad ),
197+ (PackedPointMidPad , "T{b:x:xQ:y:}" . replace ( 'Q' , s_ulonglong ) , (), PackedPointMidPad ),
198198 (PointEndPad , "T{I:x:b:y:3x}" .replace ('I' , s_uint ), (), PointEndPad ),
199- (PackedPointEndPad , "T{Q:x:b:y:x}" , (), PackedPointEndPad ),
199+ (PackedPointEndPad , "T{Q:x:b:y:x}" . replace ( 'Q' , s_ulonglong ) , (), PackedPointEndPad ),
200200 (EmptyStruct , "T{}" , (), EmptyStruct ),
201201 # the pep doesn't support unions
202202 (aUnion , "B" , (), aUnion ),
@@ -229,21 +229,24 @@ class LEPoint(LittleEndianStructure):
229229 _fields_ = [("x" , c_long ), ("y" , c_long )]
230230
231231
232+ s_long2 = {4 : 'l' , 8 : 'q' }[sizeof (c_long )]
233+
234+
232235# This table contains format strings as they really look, on both big
233236# and little endian machines.
234237if sys .byteorder == "little" :
235238 endian_types = [
236- (BEPoint , "T{>l:x:>l:y:}" .replace ('l' , s_long ), (), BEPoint ),
237- (LEPoint * 1 , "T{l:x:l:y:}" . replace ( 'l' , s_long ) , (1 ,), LEPoint ),
238- (POINTER (BEPoint ), "&T{>l:x:>l:y:}" .replace ('l' , s_long ), (), POINTER (BEPoint )),
239- (POINTER (LEPoint ), "&T{l:x:l:y:}" . replace ( 'l' , s_long ) , (), POINTER (LEPoint )),
239+ (BEPoint , "T{>l:x:>l:y:}" .replace ('l' , s_long2 ), (), BEPoint ),
240+ (LEPoint * 1 , "T{l:x:l:y:}" , (1 ,), LEPoint ),
241+ (POINTER (BEPoint ), "&T{>l:x:>l:y:}" .replace ('l' , s_long2 ), (), POINTER (BEPoint )),
242+ (POINTER (LEPoint ), "&T{l:x:l:y:}" , (), POINTER (LEPoint )),
240243 ]
241244else :
242245 endian_types = [
243- (BEPoint * 1 , "T{l:x:l:y:}" . replace ( 'l' , s_long ) , (1 ,), BEPoint ),
244- (LEPoint , "T{<l:x:<l:y:}" .replace ('l' , s_long ), (), LEPoint ),
245- (POINTER (BEPoint ), "&T{l:x:l:y:}" . replace ( 'l' , s_long ) , (), POINTER (BEPoint )),
246- (POINTER (LEPoint ), "&T{<l:x:<l:y:}" .replace ('l' , s_long ), (), POINTER (LEPoint )),
246+ (BEPoint * 1 , "T{l:x:l:y:}" , (1 ,), BEPoint ),
247+ (LEPoint , "T{<l:x:<l:y:}" .replace ('l' , s_long2 ), (), LEPoint ),
248+ (POINTER (BEPoint ), "&T{l:x:l:y:}" , (), POINTER (BEPoint )),
249+ (POINTER (LEPoint ), "&T{<l:x:<l:y:}" .replace ('l' , s_long2 ), (), POINTER (LEPoint )),
247250 ]
248251
249252
0 commit comments