]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
ccode: Implicitly register declaration for added CCodeFunction
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 1 Oct 2019 14:21:21 +0000 (16:21 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 5 Oct 2019 11:45:55 +0000 (13:45 +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 6a8ae8ce310ffb3216b582cedbaf0831f77c47a0..08919a71869003c50956dad6b24992b85ac8d84e 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);
        }