]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Write CCode attributes for property accessors in VAPI files
authorMarc-André Lureau <marcandre.lureau@gmail.com>
Sun, 28 Mar 2010 23:20:33 +0000 (01:20 +0200)
committerJürg Billeter <j@bitron.ch>
Wed, 4 Aug 2010 13:13:42 +0000 (15:13 +0200)
Fixes bug 614206.

vala/valacodewriter.vala
vala/valapropertyaccessor.vala

index 89d848fdc579eac9ac774929790ba7d5857581d1..75963fb92594002e8ccdc873bc338c3191f151a9 100644 (file)
@@ -1134,6 +1134,18 @@ public class Vala.CodeWriter : CodeVisitor {
                write_identifier (prop.name);
                write_string (" {");
                if (prop.get_accessor != null) {
+                       var ccode_params = new StringBuilder ();
+                       var separator = "";
+
+                       if (prop.get_accessor.get_cname () != prop.get_accessor.get_default_cname ()) {
+                               ccode_params.append_printf ("%scname = \"%s\"", separator, prop.get_accessor.get_cname ());
+                               separator = ", ";
+                       }
+                       if (ccode_params.len > 0) {
+                               write_indent ();
+                               write_string ("[CCode (%s)]".printf (ccode_params.str));
+                       }
+
                        if (context.profile != Profile.DOVA && prop.get_accessor.value_type.is_disposable ()) {
                                write_string (" owned");
                        }
@@ -1142,6 +1154,18 @@ public class Vala.CodeWriter : CodeVisitor {
                        write_code_block (prop.get_accessor.body);
                }
                if (prop.set_accessor != null) {
+                       var ccode_params = new StringBuilder ();
+                       var separator = "";
+
+                       if (prop.set_accessor.get_cname () != prop.set_accessor.get_default_cname ()) {
+                               ccode_params.append_printf ("%scname = \"%s\"", separator, prop.set_accessor.get_cname ());
+                               separator = ", ";
+                       }
+                       if (ccode_params.len > 0) {
+                               write_indent ();
+                               write_string ("[CCode (%s)]".printf (ccode_params.str));
+                       }
+
                        if (context.profile != Profile.DOVA && prop.set_accessor.value_type.value_owned) {
                                write_string (" owned");
                        }
index ca0a1c5a6f466263db4f26cebed185bbaa7da592..ee65a99f858588617c1ff5b4f0c98f2ea94ef890 100644 (file)
@@ -96,6 +96,16 @@ public class Vala.PropertyAccessor : Symbol {
         */
        public LocalVariable? result_var { get; set; }
 
+       public virtual string get_default_cname () {
+               var t = (TypeSymbol) prop.parent_symbol;
+
+               if (readable) {
+                       return "%sget_%s".printf (t.get_lower_case_cprefix (), prop.name);
+               } else {
+                       return "%sset_%s".printf (t.get_lower_case_cprefix (), prop.name);
+               }
+       }
+
        /**
         * The publicly accessible name of the function that performs the
         * access in C code.
@@ -104,14 +114,7 @@ public class Vala.PropertyAccessor : Symbol {
                if (_cname != null) {
                        return _cname;
                }
-
-               var t = (TypeSymbol) prop.parent_symbol;
-
-               if (readable) {
-                       return "%sget_%s".printf (t.get_lower_case_cprefix (), prop.name);
-               } else {
-                       return "%sset_%s".printf (t.get_lower_case_cprefix (), prop.name);
-               }
+               return get_default_cname ();
        }
 
        private DataType _value_type;