[vala/staging] codegen: Include "glib-object.h" for typeof expression
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Include "glib-object.h" for typeof expression
- Date: Fri, 1 Mar 2019 11:27:04 +0000 (UTC)
commit fd487e0292f4e17f54a4adbf4d6bb37c1359620e
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Fri Mar 1 09:45:56 2019 +0100
codegen: Include "glib-object.h" for typeof expression
codegen/valaccodebasemodule.vala | 2 ++
tests/Makefile.am | 3 +++
tests/enums/default-gtype.vala | 15 +++++++++++++++
tests/errors/default-gtype.vala | 7 +++++++
tests/structs/default-gtype.vala | 11 +++++++++++
5 files changed, 38 insertions(+)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index b7d0de010..acbb763ce 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5192,6 +5192,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
public override void visit_typeof_expression (TypeofExpression expr) {
+ cfile.add_include ("glib-object.h");
+
set_cvalue (expr, get_type_id_expression (expr.type_reference));
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 89c878d47..f28a168e8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -187,6 +187,7 @@ TESTS = \
control-semantic/printf-too-few.test \
control-semantic/printf-too-many.test \
control-semantic/variadic-argument-invalid.test \
+ enums/default-gtype.vala \
enums/enum_only.vala \
enums/enum-no-gtype.vala \
enums/enums.vala \
@@ -205,6 +206,7 @@ TESTS = \
structs/struct-static-field-initializer.test \
structs/struct-static-property-initializer.test \
structs/structs.vala \
+ structs/default-gtype.vala \
structs/gvalue.vala \
structs/bug530605.vala \
structs/bug572091.vala \
@@ -378,6 +380,7 @@ TESTS = \
objects/bug795521.vala \
errors/catch-error-code.vala \
errors/catch-in-finally.vala \
+ errors/default-gtype.vala \
errors/errors.vala \
errors/errorcode.vala \
errors/errordomain.vala \
diff --git a/tests/enums/default-gtype.vala b/tests/enums/default-gtype.vala
new file mode 100644
index 000000000..152f72372
--- /dev/null
+++ b/tests/enums/default-gtype.vala
@@ -0,0 +1,15 @@
+[CCode (has_type_id = false)]
+enum Foo {
+ MANAM
+}
+
+[CCode (has_type_id = false)]
+[Flags]
+enum Bar {
+ MANAM
+}
+
+void main () {
+ assert (typeof (Foo) == typeof (int));
+ assert (typeof (Bar) == typeof (uint));
+}
diff --git a/tests/errors/default-gtype.vala b/tests/errors/default-gtype.vala
new file mode 100644
index 000000000..e5fc98ea7
--- /dev/null
+++ b/tests/errors/default-gtype.vala
@@ -0,0 +1,7 @@
+errordomain Foo {
+ MANAM
+}
+
+void main () {
+ assert (typeof (Foo) == typeof (GLib.Error));
+}
diff --git a/tests/structs/default-gtype.vala b/tests/structs/default-gtype.vala
new file mode 100644
index 000000000..93b245b64
--- /dev/null
+++ b/tests/structs/default-gtype.vala
@@ -0,0 +1,11 @@
+struct Foo {
+ public int field;
+}
+
+[CCode (has_type_id = false)]
+struct Bar : Foo {
+}
+
+void main () {
+ assert (typeof (Bar) == typeof (Foo));
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]