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);
--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)
public struct TestSubStruct : TestStruct {
public static int static_field_name;
}
+
+ public const int CONSTANT_TWO = CONSTANT;
+
+ public enum EnumTestTwo {
+ VALUE = 3,
+ VALUE_TWO = VALUE,
+ }
}
[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)]
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;
}
--- /dev/null
+void main () {
+ assert (FastVapi.CONSTANT == 42);
+ assert (FastVapi.CONSTANT_TWO == 42);
+
+ assert (FastVapi.EnumTestTwo.VALUE == 3);
+ assert (FastVapi.EnumTestTwo.VALUE_TWO == 3);
+}
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;