diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2019-10-01 16:21:21 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2019-10-01 17:13:36 +0200 |
commit | 7bfd9a38debb873045134aee5bffb58aa552c967 (patch) | |
tree | 52d1f2892bf6637533a56d080954a35b3a098fce /ccode | |
parent | 67b98ff0419cd5b06744da49e4577539fe6636fa (diff) | |
download | vala-7bfd9a38debb873045134aee5bffb58aa552c967.tar.gz |
ccode: Implicitly register declaration for added CCodeFunction
This will prevent the user's vala source to override implicitly defined
functions of vala's boilerblate for a type.
Diffstat (limited to 'ccode')
-rw-r--r-- | ccode/valaccodefile.vala | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ccode/valaccodefile.vala b/ccode/valaccodefile.vala index adbdb1880..cf4870267 100644 --- a/ccode/valaccodefile.vala +++ b/ccode/valaccodefile.vala @@ -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 (); @@ -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); } |