]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
ccode: Implicitly register declaration for added CCodeFunction 7bfd9a38debb873045134aee5bffb58aa552c967
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 1 Oct 2019 14:21:21 +0000 (16:21 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 1 Oct 2019 15:13:36 +0000 (17:13 +0200)
This will prevent the user's vala source to override implicitly defined
functions of vala's boilerblate for a type.

ccode/valaccodefile.vala

index adbdb188067ba9d0d4212ed5820f32993eb91dc9..cf4870267170ec4b6cc74ecad235035137a917ae 100644 (file)
@@ -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);
        }