summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2018-04-02 00:00:00 +0000
committerChristoph Reiter <reiter.christoph@gmail.com>2018-06-23 11:32:47 +0200
commit2e1913227118d043cd076ffb2c0ed1c21cfccd7f (patch)
tree41ff8b5ce9b02615f803e6d3765549feda36f616
parentda426f7672b9c88658685aaf5cef948e02eb8c01 (diff)
downloadgobject-introspection-2e1913227118d043cd076ffb2c0ed1c21cfccd7f.tar.gz
Convert _Bool to gboolean for backward compatibility.
See !24 for the discussion
-rw-r--r--giscanner/transformer.py9
-rw-r--r--tests/warn/unresolved-type.h26
2 files changed, 22 insertions, 13 deletions
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index b7d1facc..f5a2f477 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -699,6 +699,15 @@ raise ValueError."""
canonical = self._canonicalize_ctype(ctype)
base = canonical.replace('*', '')
+ # While gboolean and _Bool are distinct types, they used to be treated
+ # by scanner as exactly the same one. In general this is incorrect
+ # because of different ABI, but this usually works fine,
+ # so for backward compatibility lets continue for now:
+ # https://gitlab.gnome.org/GNOME/gobject-introspection/merge_requests/24#note_92792
+ if canonical == '_Bool':
+ canonical = 'gboolean'
+ base = canonical
+
# Special default: char ** -> ast.Array, same for GStrv
if (is_return and canonical == 'utf8*') or base == 'GStrv':
bare_utf8 = ast.TYPE_STRING.clone()
diff --git a/tests/warn/unresolved-type.h b/tests/warn/unresolved-type.h
index 7265753c..7588dff7 100644
--- a/tests/warn/unresolved-type.h
+++ b/tests/warn/unresolved-type.h
@@ -19,32 +19,32 @@ typedef enum {
// EXPECT:18: Warning: Test: symbol='TestMyEnum2': Unknown namespace for symbol 'MY_ENUM_A'
-void test_bool1 (_Bool b);
-// EXPECT:22: Warning: Test: test_bool1: argument b: Unresolved type: '_Bool'
-
-void test_bool2 (bool b);
-// EXPECT:25: Warning: Test: test_bool2: argument b: Unresolved type: '_Bool'
-
void test_bool3 (gboolean b);
void test_f16 (_Float16 f);
-// EXPECT:30: Warning: Test: test_f16: argument f: Unresolved type: '_Float16'
+// EXPECT:24: Warning: Test: test_f16: argument f: Unresolved type: '_Float16'
void test_f32 (_Float32 f);
-// EXPECT:33: Warning: Test: test_f32: argument f: Unresolved type: '_Float32'
+// EXPECT:27: Warning: Test: test_f32: argument f: Unresolved type: '_Float32'
void test_f64 (_Float64 f);
-// EXPECT:36: Warning: Test: test_f64: argument f: Unresolved type: '_Float64'
+// EXPECT:30: Warning: Test: test_f64: argument f: Unresolved type: '_Float64'
void test_f128 (_Float128 f);
-// EXPECT:39: Warning: Test: test_f128: argument f: Unresolved type: '_Float128'
+// EXPECT:33: Warning: Test: test_f128: argument f: Unresolved type: '_Float128'
void test_f32x (_Float32x f);
-// EXPECT:42: Warning: Test: test_f32x: argument f: Unresolved type: '_Float32x'
+// EXPECT:36: Warning: Test: test_f32x: argument f: Unresolved type: '_Float32x'
void test_f64x (_Float64x f);
-// EXPECT:45: Warning: Test: test_f64x: argument f: Unresolved type: '_Float64x'
+// EXPECT:39: Warning: Test: test_f64x: argument f: Unresolved type: '_Float64x'
void test_f128x (_Float128x f);
-// EXPECT:48: Warning: Test: test_f128x: argument f: Unresolved type: '_Float128x'
+// EXPECT:42: Warning: Test: test_f128x: argument f: Unresolved type: '_Float128x'
+// For backward compatibility we don't warn about _Bool
+_Bool test_ret_bool1 ();
+bool test_ret_bool2 ();
+gboolean test_ret_bool3 ();
+void test_bool2 (bool b);
+void test_bool1 (_Bool b);