[Xcb] c_client.py: enumerator values generation

Litvinenko, Evgeny EVLitvinenko at luxoft.com
Tue Jan 17 08:17:27 UTC 2017


>From 2a9446c38f7f1977b32f85dcf4857db8c676799c Mon Sep 17 00:00:00 2001
From: Evgeny Litvinenko <evgeny.v.litvinenko at gmail.com>
Date: Tue, 17 Jan 2017 09:32:27 +0300
Subject: [PATCH] Convert enumerator values to the range of C 'int'

This fixes warning like the following (when gcc runs with -pedantic-errors)

In file included from xinput.c:14:0:
xinput.h:3079:35: error: ISO C restricts enumerator values to range of 'int' [-Wpedantic]
     XCB_INPUT_MODIFIER_MASK_ANY = 2147483648
                                   ^

In C99 standard (ISO/IEC 9899:1999)
...
6.7.2.2 Enumeration specifiers
The expression that defines the value of an enumeration constant
shall be an integer constant expression
that has a value representable as an int.
...
---
You can use this patch or any parts of it
as you consider it necessary.

 xcbgen/xtypes.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xcbgen/xtypes.py b/xcbgen/xtypes.py
index b83b119..93db2ad 100644
--- a/xcbgen/xtypes.py
+++ b/xcbgen/xtypes.py
@@ -3,6 +3,7 @@ This module contains the classes which represent XCB data types.
 '''
 from xcbgen.expr import Field, Expression
 from xcbgen.align import Alignment, AlignmentLog
+from ctypes import c_int
 import __main__

 verbose_align_log = False
@@ -243,7 +244,7 @@ class Enum(SimpleType):
             if value.tag == 'value':
                 self.values.append((item.get('name'), value.text))
             elif value.tag == 'bit':
-                self.values.append((item.get('name'), '%u' % (1 << int(value.text, 0))))
+                self.values.append((item.get('name'), '%i' % c_int(1 <<  int(value.text, 0)).value))
                 self.bits.append((item.get('name'), value.text))

     def resolve(self, module):
--
2.11.0



Thanks,
Evgeny.

________________________________

This e-mail and any attachment(s) are intended only for the recipient(s) named above and others who have been specifically authorized to receive them. They may contain confidential information. If you are not the intended recipient, please do not read this email or its attachment(s). Furthermore, you are hereby notified that any dissemination, distribution or copying of this e-mail and any attachment(s) is strictly prohibited. If you have received this e-mail in error, please immediately notify the sender by replying to this e-mail and then delete this e-mail and any attachment(s) or copies thereof from your system. Thank you.


More information about the Xcb mailing list