diff options
author | Colin Walters <walters@verbum.org> | 2012-10-26 16:46:05 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2012-10-30 08:20:36 -0400 |
commit | 383b0bdcc8e295d06035768062389797d3ba9262 (patch) | |
tree | e024519716913823e22abcd46294a3dc48bd9acd /giscanner/giscannermodule.c | |
parent | ce4a25dc640bdb02ff30fc233abb1c468721cbbd (diff) | |
download | gobject-introspection-383b0bdcc8e295d06035768062389797d3ba9262.tar.gz |
scanner: Correctly handle large 64 bit integer constants
In C, positive integer constants are by default unsigned. This means
an expression like 0x8000000000000000 will be "unsigned long long".
In the actual scanner code, we were parsing them as "gint64", and
storing them as gint64. This was incorrect; we need to parse them
as guint64, and store the bits we get from that. This gives us
an equivalent result to what the C compiler does.
However, when we actually return the value as a Python "long"
(arbitrary length integer), we need to treat the value as unsigned if
the result indicated it was.
https://bugzilla.gnome.org/show_bug.cgi?id=685022
Diffstat (limited to 'giscanner/giscannermodule.c')
-rw-r--r-- | giscanner/giscannermodule.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/giscanner/giscannermodule.c b/giscanner/giscannermodule.c index 0f8d6cbb..0ece7f7a 100644 --- a/giscanner/giscannermodule.c +++ b/giscanner/giscannermodule.c @@ -162,7 +162,10 @@ symbol_get_const_int (PyGISourceSymbol *self, return Py_None; } - return PyLong_FromLongLong ((long long)self->symbol->const_int); + if (self->symbol->const_int_is_unsigned) + return PyLong_FromUnsignedLongLong ((unsigned long long)self->symbol->const_int); + else + return PyLong_FromLongLong ((long long)self->symbol->const_int); } static PyObject * |