From: Rico Tzschichholz Date: Sun, 18 Nov 2018 19:37:38 +0000 (+0100) Subject: girwriter: Write glib-type attributes for Enums/Structs with type_id X-Git-Tag: 0.43.1~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21a2a70abfe3d338e1e64f9b06b0d4f145380493;p=thirdparty%2Fvala.git girwriter: Write glib-type attributes for Enums/Structs with type_id --- diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala index a35036a06..c01912167 100644 --- a/codegen/valagirwriter.vala +++ b/codegen/valagirwriter.vala @@ -474,6 +474,11 @@ public class Vala.GIRWriter : CodeVisitor { write_indent (); buffer.append_printf ("\n"); indent++; @@ -664,7 +669,11 @@ public class Vala.GIRWriter : CodeVisitor { write_indent (); buffer.append_printf ("<%s name=\"%s\"", element_name, get_gir_name (en)); - write_gtype_attributes (en); + if (get_ccode_has_type_id (en)) { + write_gtype_attributes (en); + } else { + write_ctype_attributes (en); + } write_symbol_attributes (en); buffer.append_printf (">\n"); indent++; diff --git a/tests/girwriter/GirTest-1.0.gir-expected b/tests/girwriter/GirTest-1.0.gir-expected index 52be88f50..72705c6fd 100644 --- a/tests/girwriter/GirTest-1.0.gir-expected +++ b/tests/girwriter/GirTest-1.0.gir-expected @@ -16,6 +16,11 @@ + + + + + @@ -928,7 +933,7 @@ - + @@ -948,6 +953,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tests/girwriter/girtest.vala b/tests/girwriter/girtest.vala index 806b3312a..4f04d9296 100644 --- a/tests/girwriter/girtest.vala +++ b/tests/girwriter/girtest.vala @@ -10,6 +10,17 @@ namespace GirTest { } } + [CCode (has_type_id = false)] + public struct Struct { + public int field_name; + + public Struct () { + } + + public void inv () { + } + } + [GIR (visible = false)] public class SkippedStruct { } @@ -30,6 +41,13 @@ namespace GirTest { VALUE3 } + [CCode (has_type_id = false)] + public enum PlainEnumTest { + VALUE1, + VALUE2, + VALUE3 = 4711 + } + [GIR (visible = false)] public enum SkippedEnum { VALUE1 diff --git a/tests/girwriter/girtest.vapi-expected b/tests/girwriter/girtest.vapi-expected index 2b5a9a466..d89338f8e 100644 --- a/tests/girwriter/girtest.vapi-expected +++ b/tests/girwriter/girtest.vapi-expected @@ -93,6 +93,12 @@ namespace GirTest { public BoxedStruct (); public void inv (); } + [CCode (cheader_filename = "girtest.h", has_type_id = false)] + public struct Struct { + public int field_name; + public Struct (); + public void inv (); + } [CCode (cheader_filename = "girtest.h")] public enum EnumTest { VALUE1, @@ -106,6 +112,12 @@ namespace GirTest { VALUE2, VALUE3 } + [CCode (cheader_filename = "girtest.h", has_type_id = false)] + public enum PlainEnumTest { + VALUE1, + VALUE2, + VALUE3 + } [CCode (cheader_filename = "girtest.h")] [GIR (visible = false)] public enum SkippedEnum {