Skip to content

Commit

Permalink
codegen: Fix get_ccode_name() for properties
Browse files Browse the repository at this point in the history
Handle them the same way as signals and hold the canonical representation
as ccode name.
  • Loading branch information
ricotz committed Nov 14, 2018
1 parent a336d75 commit d549257
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions codegen/valaccodeattribute.vala
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,8 @@ public class Vala.CCodeAttribute : AttributeCache {
} else {
return "%s%s".printf (get_ccode_lower_case_prefix (sym.parent_symbol), sym.name);
}
} else if (sym is Property) {
return sym.name.replace ("_", "-");
} else if (sym is PropertyAccessor) {
unowned PropertyAccessor acc = (PropertyAccessor) sym;
var t = (TypeSymbol) acc.prop.parent_symbol;
Expand Down
4 changes: 2 additions & 2 deletions codegen/valaccodebasemodule.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3893,7 +3893,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}

public string get_symbol_lock_name (string symname) {
return "__lock_%s".printf (symname);
return "__lock_%s".printf (symname.replace ("-", "_"));
}

private CCodeExpression get_lock_expression (Statement stmt, Expression resource) {
Expand Down Expand Up @@ -6356,7 +6356,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}

public CCodeConstant get_property_canonical_cconstant (Property prop) {
return new CCodeConstant ("\"%s\"".printf (prop.name.replace ("_", "-")));
return new CCodeConstant ("\"%s\"".printf (get_ccode_name (prop)));
}

public override void visit_class (Class cl) {
Expand Down
2 changes: 1 addition & 1 deletion codegen/valagirwriter.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ public class Vala.GIRWriter : CodeVisitor {
}

write_indent ();
buffer.append_printf ("<property name=\"%s\"", prop.name.replace ("_", "-"));
buffer.append_printf ("<property name=\"%s\"", get_ccode_name (prop));
if (prop.get_accessor == null) {
buffer.append_printf (" readable=\"0\"");
}
Expand Down

0 comments on commit d549257

Please sign in to comment.