[vala/0.46] vala: Don't require constant initializer in fast-vapi
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.46] vala: Don't require constant initializer in fast-vapi
- Date: Fri, 15 Nov 2019 12:52:22 +0000 (UTC)
commit 0244bd32521e4d483c44b165b30e79f2b73faff7
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Nov 14 21:04:42 2019 +0100
vala: Don't require constant initializer in fast-vapi
Regression of 984c034256de3830d6daa0ab6f5eff108dea09bb
Extend --fast-vapi test by using --use-fast-vapi
See https://github.com/dino/dino/issues/646
and https://gitlab.gnome.org/GNOME/vala/issues/461
codegen/valaccodebasemodule.vala | 2 +-
tests/fastvapi/Makefile.am | 10 +++++++++-
tests/fastvapi/fastvapitest.vala | 7 +++++++
tests/fastvapi/fastvapitest.vapi-expected | 9 +++++++++
tests/fastvapi/usefastvapitest.vala | 7 +++++++
vala/valaconstant.vala | 7 +++++--
6 files changed, 38 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 8009967b5..5cbc88e6a 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -961,7 +961,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return;
}
- if (!c.external) {
+ if (!c.external || (c.source_type == SourceFileType.FAST && c.value != null)) {
generate_type_declaration (c.type_reference, decl_space);
c.value.emit (this);
diff --git a/tests/fastvapi/Makefile.am b/tests/fastvapi/Makefile.am
index b960ac4b1..cc0025654 100644
--- a/tests/fastvapi/Makefile.am
+++ b/tests/fastvapi/Makefile.am
@@ -8,16 +8,24 @@ check-fastvapi: $(top_builddir)/compiler/valac
--basedir $(srcdir) \
$(srcdir)/fastvapitest.vala; \
tail -n +3 fastvapitest.vapi | diff -wu $(srcdir)/fastvapitest.vapi-expected - || exit 1; \
- rm -f fastvapitest.vapi fastvapitest.c
+ G_DEBUG=fatal-warnings $(top_builddir)/compiler/valac \
+ -C \
+ --disable-version-header \
+ --use-fast-vapi fastvapitest.vapi \
+ --basedir $(srcdir) \
+ $(srcdir)/usefastvapitest.vala; \
+ rm -f fastvapitest.vapi fastvapitest.c usefastvapitest.c
check: check-fastvapi
EXTRA_DIST = \
fastvapitest.vala \
fastvapitest.vapi-expected \
+ usefastvapitest.vala \
$(NULL)
CLEANFILES = \
fastvapitest.c \
fastvapitest.vapi \
+ usefastvapitest.c \
$(NULL)
diff --git a/tests/fastvapi/fastvapitest.vala b/tests/fastvapi/fastvapitest.vala
index bfbd371c6..37229660b 100644
--- a/tests/fastvapi/fastvapitest.vala
+++ b/tests/fastvapi/fastvapitest.vala
@@ -41,4 +41,11 @@ namespace FastVapi {
public struct TestSubStruct : TestStruct {
public static int static_field_name;
}
+
+ public const int CONSTANT_TWO = CONSTANT;
+
+ public enum EnumTestTwo {
+ VALUE = 3,
+ VALUE_TWO = VALUE,
+ }
}
diff --git a/tests/fastvapi/fastvapitest.vapi-expected b/tests/fastvapi/fastvapitest.vapi-expected
index 3a8ab23b5..5530facc1 100644
--- a/tests/fastvapi/fastvapitest.vapi-expected
+++ b/tests/fastvapi/fastvapitest.vapi-expected
@@ -41,6 +41,13 @@ namespace FastVapi {
[Source (filename = "fastvapitest.vala", line = 5, column = 3)]
VALUE
}
+ [Source (filename = "fastvapitest.vala", line = 47, column = 2)]
+ public enum EnumTestTwo {
+ [Source (filename = "fastvapitest.vala", line = 48, column = 3)]
+ VALUE = 3,
+ [Source (filename = "fastvapitest.vala", line = 49, column = 3)]
+ VALUE_TWO
+ }
[Source (filename = "fastvapitest.vala", line = 8, column = 2)]
public errordomain ErrorTest {
[Source (filename = "fastvapitest.vala", line = 9, column = 3)]
@@ -50,4 +57,6 @@ namespace FastVapi {
public delegate bool DelegateTest (int param);
[Source (filename = "fastvapitest.vala", line = 2, column = 2)]
public const int CONSTANT = 42;
+ [Source (filename = "fastvapitest.vala", line = 45, column = 2)]
+ public const int CONSTANT_TWO;
}
diff --git a/tests/fastvapi/usefastvapitest.vala b/tests/fastvapi/usefastvapitest.vala
new file mode 100644
index 000000000..46f9ddaa1
--- /dev/null
+++ b/tests/fastvapi/usefastvapitest.vala
@@ -0,0 +1,7 @@
+void main () {
+ assert (FastVapi.CONSTANT == 42);
+ assert (FastVapi.CONSTANT_TWO == 42);
+
+ assert (FastVapi.EnumTestTwo.VALUE == 3);
+ assert (FastVapi.EnumTestTwo.VALUE_TWO == 3);
+}
diff --git a/vala/valaconstant.vala b/vala/valaconstant.vala
index 0a9266cf1..b98568f33 100644
--- a/vala/valaconstant.vala
+++ b/vala/valaconstant.vala
@@ -123,8 +123,11 @@ public class Vala.Constant : Symbol {
if (!external) {
if (value == null) {
- error = true;
- Report.error (source_reference, "A const field requires a value to be
provided");
+ // constants from fast-vapi files are special
+ if (source_type != SourceFileType.FAST) {
+ error = true;
+ Report.error (source_reference, "A const field requires a value to be
provided");
+ }
} else {
value.target_type = type_reference;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]