From: Jean Pierre Dudey Date: Sun, 19 Jul 2020 21:48:12 +0000 (-0500) Subject: girwriter: Write c:symbol-prefix on supported elements X-Git-Tag: 0.49.1~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef9c592dac6ee3a6db39e924de423e23e5f4a4ef;p=thirdparty%2Fvala.git girwriter: Write c:symbol-prefix on supported elements This specifies the symbol prefix, e.g.: window in gtk_window_new Fixes https://gitlab.gnome.org/GNOME/vala/issues/1038 --- diff --git a/codegen/valagirwriter.vala b/codegen/valagirwriter.vala index 51a11e8d6..2ae748bf0 100644 --- a/codegen/valagirwriter.vala +++ b/codegen/valagirwriter.vala @@ -349,6 +349,10 @@ public class Vala.GIRWriter : CodeVisitor { buffer.append_printf (" c:prefix=\"%s\"", cprefix); buffer.append_printf (" c:identifier-prefixes=\"%s\"", cprefix); } + string? csymbol_prefix = get_ccode_lower_case_suffix (ns); + if (csymbol_prefix != null) { + buffer.append_printf (" c:symbol-prefix=\"%s\"", csymbol_prefix); + } buffer.append_printf (">\n"); indent++; @@ -398,7 +402,7 @@ public class Vala.GIRWriter : CodeVisitor { write_indent (); buffer.append_printf ("\n"); @@ -647,7 +651,7 @@ public class Vala.GIRWriter : CodeVisitor { write_indent (); buffer.append_printf ("\n"); @@ -1541,12 +1545,15 @@ public class Vala.GIRWriter : CodeVisitor { index++; } - private void write_ctype_attributes (TypeSymbol symbol, string suffix = "") { + private void write_ctype_attributes (TypeSymbol symbol, string suffix = "", bool symbol_prefix = false) { buffer.append_printf (" c:type=\"%s%s\"", get_ccode_name (symbol), suffix); + if (symbol_prefix) { + buffer.append_printf (" c:symbol-prefix=\"%s\"", get_ccode_lower_case_suffix (symbol)); + } } - private void write_gtype_attributes (TypeSymbol symbol) { - write_ctype_attributes(symbol); + private void write_gtype_attributes (TypeSymbol symbol, bool symbol_prefix = false) { + write_ctype_attributes(symbol, "", symbol_prefix); buffer.append_printf (" glib:type-name=\"%s\"", get_ccode_name (symbol)); buffer.append_printf (" glib:get-type=\"%sget_type\"", get_ccode_lower_case_prefix (symbol)); } diff --git a/tests/girwriter/GirTest-1.0.gir-expected b/tests/girwriter/GirTest-1.0.gir-expected index 1059801ec..6977d77e8 100644 --- a/tests/girwriter/GirTest-1.0.gir-expected +++ b/tests/girwriter/GirTest-1.0.gir-expected @@ -4,7 +4,7 @@ - + @@ -31,7 +31,7 @@ - + @@ -68,7 +68,7 @@ - + @@ -104,7 +104,7 @@ - + @@ -871,7 +871,7 @@ - + @@ -1144,7 +1144,7 @@ - + @@ -1177,7 +1177,7 @@ - + @@ -1199,7 +1199,7 @@ - + @@ -1221,7 +1221,7 @@ - + @@ -1322,7 +1322,7 @@ - + @@ -1406,7 +1406,7 @@ - + @@ -1720,14 +1720,14 @@ - + - + @@ -1735,7 +1735,7 @@ - + @@ -1755,7 +1755,7 @@ - + @@ -1775,7 +1775,7 @@ - +