[vala/staging] codegen: Emit delegate/enum typedefs to type-declaration section
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Emit delegate/enum typedefs to type-declaration section
- Date: Fri, 7 Dec 2018 06:59:15 +0000 (UTC)
commit 02d53c93735ae52d53fe13fba3daa29b297699d8
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Dec 6 22:41:43 2018 +0100
codegen: Emit delegate/enum typedefs to type-declaration section
This fixes compilation of circular dependency of delegates with enums,
structs, classes and interfaces.
Fixes https://gitlab.gnome.org/GNOME/vala/issues/318
codegen/valaccodebasemodule.vala | 4 ++--
codegen/valaccodedelegatemodule.vala | 2 +-
tests/Makefile.am | 1 +
tests/delegates/circular-depends.vala | 21 +++++++++++++++++++++
4 files changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 879d4fb23..c4d00aba5 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -847,8 +847,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
cfile = current_cfile;
- decl_space.add_type_definition (cenum);
- decl_space.add_type_definition (new CCodeNewline ());
+ decl_space.add_type_declaration (cenum);
+ decl_space.add_type_declaration (new CCodeNewline ());
if (context.profile != Profile.GOBJECT || !get_ccode_has_type_id (en)) {
return true;
diff --git a/codegen/valaccodedelegatemodule.vala b/codegen/valaccodedelegatemodule.vala
index fe1d6f6ce..71c63e92a 100644
--- a/codegen/valaccodedelegatemodule.vala
+++ b/codegen/valaccodedelegatemodule.vala
@@ -124,7 +124,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
var ctypedef = new CCodeTypeDefinition (return_type_cname, cfundecl);
ctypedef.modifiers |= (d.version.deprecated ? CCodeModifiers.DEPRECATED : 0);
- decl_space.add_type_definition (ctypedef);
+ decl_space.add_type_declaration (ctypedef);
}
public override void visit_delegate (Delegate d) {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6f276d659..8154540ae 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -227,6 +227,7 @@ TESTS = \
structs/bug775761.vala \
structs/bug777194.vala \
delegates/casting.vala \
+ delegates/circular-depends.vala \
delegates/compatible.vala \
delegates/delegate_only.vala \
delegates/delegates.vala \
diff --git a/tests/delegates/circular-depends.vala b/tests/delegates/circular-depends.vala
new file mode 100644
index 000000000..b9e9142e1
--- /dev/null
+++ b/tests/delegates/circular-depends.vala
@@ -0,0 +1,21 @@
+[CCode (has_target = false)]
+delegate void Func (FooStruct s, FooEnum e, IFoo i, Foo c);
+
+struct FooStruct {
+ public Func f;
+}
+
+enum FooEnum {
+ BAR;
+}
+
+interface IFoo {
+ public abstract void foo (Func f);
+}
+
+class Foo {
+ public Func f;
+}
+
+void main () {
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]