diff options
-rw-r--r-- | giscanner/transformer.py | 18 | ||||
-rw-r--r-- | tests/scanner/Regress-1.0-expected.gir | 5 | ||||
-rw-r--r-- | tests/scanner/regress.h | 1 |
3 files changed, 23 insertions, 1 deletions
diff --git a/giscanner/transformer.py b/giscanner/transformer.py index 26c7793b..6afad889 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -723,7 +723,23 @@ raise ValueError.""" typeval = self._create_type_from_base(symbol.base_type) else: typeval = ast.TYPE_INT - value = '%d' % (symbol.const_int, ) + unaliased = typeval + self._resolve_type_from_ctype(unaliased) + if typeval.target_giname and typeval.ctype: + target = self.lookup_giname(typeval.target_giname) + target = self.resolve_aliases(target) + if isinstance(target, ast.Type): + unaliased = target + if unaliased == ast.TYPE_UINT64: + value = str(symbol.const_int % 2**64) + elif unaliased == ast.TYPE_UINT32: + value = str(symbol.const_int % 2**32) + elif unaliased == ast.TYPE_UINT16: + value = str(symbol.const_int % 2**16) + elif unaliased == ast.TYPE_UINT8: + value = str(symbol.const_int % 2**16) + else: + value = str(symbol.const_int) elif symbol.const_double is not None: typeval = ast.TYPE_DOUBLE value = '%f' % (symbol.const_double, ) diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index 43258f2a..9b773fb5 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -44,6 +44,11 @@ and/or use gtk-doc annotations. --> c:type="REGRESS_DOUBLE_CONSTANT"> <type name="gdouble" c:type="gdouble"/> </constant> + <constant name="GUINT64_CONSTANT" + value="18446744073709551615" + c:type="REGRESS_GUINT64_CONSTANT"> + <type name="guint64" c:type="guint64"/> + </constant> <constant name="G_GINT64_CONSTANT" value="1000" c:type="REGRESS_G_GINT64_CONSTANT"> diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index 0c071f51..ce5d1dc2 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -260,6 +260,7 @@ GQuark regress_atest_error_quark (void); #define REGRESS_STRING_CONSTANT "Some String" #define REGRESS_Mixed_Case_Constant 4423 #define REGRESS_G_GINT64_CONSTANT (G_GINT64_CONSTANT (1000)) +#define REGRESS_GUINT64_CONSTANT ((guint64) -1) /* structures */ typedef struct _RegressTestStructA RegressTestStructA; |