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.40.24~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f34f607c19f64717c49521d84b1cdd49940ce76;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 28063d248..7ea4a39a7 100644 --- a/codegen/valagirwriter.vala +++ b/codegen/valagirwriter.vala @@ -344,6 +344,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++; @@ -393,7 +397,7 @@ public class Vala.GIRWriter : CodeVisitor { write_indent (); buffer.append_printf ("\n"); @@ -629,7 +633,7 @@ public class Vala.GIRWriter : CodeVisitor { write_indent (); buffer.append_printf ("\n"); @@ -1525,12 +1529,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)); }