Skip to content

Commit

Permalink
ccode: Implicitly register declaration for added CCodeFunction
Browse files Browse the repository at this point in the history
This will prevent the user's vala source to override implicitly defined
functions of vala's boilerblate for a type.
  • Loading branch information
ricotz committed Oct 4, 2019
1 parent c47b90b commit f3aefee
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ccode/valaccodefile.vala
Expand Up @@ -28,6 +28,7 @@ public class Vala.CCodeFile {

Set<string> features = new HashSet<string> (str_hash, str_equal);
Set<string> declarations = new HashSet<string> (str_hash, str_equal);
Set<string> definitions = new HashSet<string> (str_hash, str_equal);
Set<string> includes = new HashSet<string> (str_hash, str_equal);
CCodeFragment comments = new CCodeFragment ();
CCodeFragment feature_test_macros = new CCodeFragment ();
Expand Down Expand Up @@ -89,12 +90,19 @@ public class Vala.CCodeFile {
}

public void add_function_declaration (CCodeFunction func) {
declarations.add (func.name);

var decl = func.copy ();
decl.is_declaration = true;
type_member_declaration.append (decl);
}

public void add_function (CCodeFunction func) {
if (!definitions.add (func.name)) {
Report.error (null, "internal: Redefinition of `%s'".printf (func.name));
return;
}

type_member_definition.append (func);
}

Expand Down

0 comments on commit f3aefee

Please sign in to comment.