From 7bfd9a38debb873045134aee5bffb58aa552c967 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Tue, 1 Oct 2019 16:21:21 +0200 Subject: [PATCH] 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. --- ccode/valaccodefile.vala | 8 ++++++++ 1 file changed, 8 insertions(+) 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 features = new HashSet (str_hash, str_equal); Set declarations = new HashSet (str_hash, str_equal); + Set definitions = new HashSet (str_hash, str_equal); Set includes = new HashSet (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); } -- 2.47.2