[gobject-introspection: 2/3] Convert _Bool to gboolean for backward compatibility.
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection: 2/3] Convert _Bool to gboolean for backward compatibility.
- Date: Tue, 3 Jul 2018 13:16:00 +0000 (UTC)
commit 2e1913227118d043cd076ffb2c0ed1c21cfccd7f
Author: Tomasz Miąsko <tomasz miasko gmail com>
Date: Mon Apr 2 00:00:00 2018 +0000
Convert _Bool to gboolean for backward compatibility.
See !24 for the discussion
giscanner/transformer.py | 9 +++++++++
tests/warn/unresolved-type.h | 26 +++++++++++++-------------
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]