From: Rico Tzschichholz Date: Tue, 1 Oct 2019 14:21:21 +0000 (+0200) Subject: ccode: Implicitly register declaration for added CCodeFunction X-Git-Tag: 0.44.9~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=048726e5b68d7febe1418b8c33cca009597a4e99;p=thirdparty%2Fvala.git 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. --- diff --git a/ccode/valaccodefile.vala b/ccode/valaccodefile.vala index 6a8ae8ce3..08919a718 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); }