[vala/0.40] ccode: Implicitly register declaration for added CCodeFunction



commit d23d0175fbd9915638665feab444ae8f5c132391
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Oct 1 16:21:21 2019 +0200

    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 e98d84bd0..f13b7b0ba 100644
--- a/ccode/valaccodefile.vala
+++ b/ccode/valaccodefile.vala
@@ -26,6 +26,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 ();
@@ -83,12 +84,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);
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]