]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Use given dup_function for structs
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 22 Aug 2017 13:31:54 +0000 (15:31 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 27 Aug 2017 11:27:27 +0000 (13:27 +0200)
codegen/valaccodeattribute.vala
codegen/valaccodebasemodule.vala

index d3a97d520a1d97dbfb517671a097aae969f1a59c..815ec1104008bc3cb017087b62d6db626f3d366b 100644 (file)
@@ -222,6 +222,21 @@ public class Vala.CCodeAttribute : AttributeCache {
                }
        }
 
+       public string dup_function {
+               get {
+                       if (!dup_function_set) {
+                               if (ccode != null) {
+                                       _dup_function = ccode.get_string ("dup_function");
+                               }
+                               if (_dup_function == null && !sym.external_package && sym is Struct) {
+                                       _dup_function = "%sdup".printf (lower_case_prefix);
+                               }
+                               dup_function_set = true;
+                       }
+                       return _dup_function;
+               }
+       }
+
        public string free_function {
                get {
                        if (!free_function_set) {
@@ -541,6 +556,8 @@ public class Vala.CCodeAttribute : AttributeCache {
        private bool copy_function_set;
        private string? _destroy_function;
        private bool destroy_function_set;
+       private string? _dup_function;
+       private bool dup_function_set;
        private string? _free_function;
        private bool free_function_set;
        private bool? _free_function_address_of;
index 1d0610cb443e22a8c612391acaeff6937b9d7903..cd5ae3d2152a67db4acda7520cb8221a17783fe9 100644 (file)
@@ -6240,11 +6240,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
        public static string? get_ccode_dup_function (TypeSymbol sym) {
                if (sym is Struct) {
-                       if (sym.external_package) {
-                               return null;
-                       } else {
-                               return get_ccode_lower_case_prefix (sym) + "dup";
-                       }
+                       return get_ccode_attribute (sym).dup_function;
                }
                return get_ccode_copy_function (sym);
        }