]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Move custom_return_type_cname CCode attribute down to Method
authorLuca Bruno <lucabru@src.gnome.org>
Sat, 4 Jun 2011 16:21:08 +0000 (18:21 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Sat, 4 Jun 2011 16:21:08 +0000 (18:21 +0200)
codegen/valaccodemethodmodule.vala
vala/valacodewriter.vala
vala/valacreationmethod.vala
vala/valamethod.vala
vapigen/valagidlparser.vala

index 879fe329ef5322789f9984b609d19d433d0b6984..e2f09851642a75ab3bf11a7f5119ef611017de2e 100644 (file)
@@ -32,14 +32,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
        }
 
        public override string? get_custom_creturn_type (Method m) {
-               var attr = m.get_attribute ("CCode");
-               if (attr != null) {
-                       string type = attr.get_string ("type");
-                       if (type != null) {
-                               return type;
-                       }
-               }
-               return null;
+               return m.custom_return_type_cname;
        }
 
        string get_creturn_type (Method m, string default_value) {
index 01cb8ef707e26fb79fd0d37ace802f3a6200726f..ff5b413a8b3f3d428c89af9b82271f09351baa5d 100644 (file)
@@ -1138,12 +1138,13 @@ public class Vala.CodeWriter : CodeVisitor {
                        ccode_params.append_printf ("%ssentinel = \"%s\"", separator, m.sentinel);
                        separator = ", ";
                }
+               if (m.custom_return_type_cname != null) {
+                       ccode_params.append_printf ("%stype = \"%s\"", separator, m.custom_return_type_cname);
+                       separator = ", ";
+               }
+
                var cm = m as CreationMethod;
                if (cm != null) {
-                       if (cm.custom_return_type_cname != null) {
-                               ccode_params.append_printf ("%stype = \"%s\"", separator, cm.custom_return_type_cname);
-                               separator = ", ";
-                       }
                        if (!m.has_new_function) {
                                ccode_params.append_printf ("%shas_new_function = false", separator);
                                separator = ", ";
index 7958ec65b9f564c2af2c00dc3560c640411e1d7b..7ece293caa80146f8597a6254b92d3c4ed98f86b 100644 (file)
@@ -33,14 +33,6 @@ public class Vala.CreationMethod : Method {
         */
        public string class_name { get; set; }
 
-       /**
-        * Specifies a custom C return type for that creation method.
-        * Only the idl parser and the interface writer should use this.
-        * FIXME: remove this as soon the compiler has a decent attribute
-        * handling.
-        */
-       public string? custom_return_type_cname { get; set; }
-
        /**
         * Specifies whether this constructor chains up to a base
         * constructor or a different constructor of the same class.
index cd935a20ed8787b6b4fd3277ceebfbde1a34b0f0..966407240eb44beecd624d57f6806e5b4e728eb3 100644 (file)
@@ -180,6 +180,11 @@ public class Vala.Method : Subroutine {
         */
        public string? array_length_type { get; set; default = null; }
 
+       /**
+        * Specifies a custom C return type for this method.
+        */
+       public string? custom_return_type_cname { get; set; }
+
        /**
         * Specifies whether this method expects printf-style format arguments.
         */
@@ -471,6 +476,9 @@ public class Vala.Method : Subroutine {
                if (a.has_argument ("returns_floating_reference")) {
                        returns_floating_reference = a.get_bool ("returns_floating_reference");
                }
+               if (a.has_argument ("type")) {
+                       custom_return_type_cname = a.get_string ("type");
+               }
        }
        
        /**
index 6fe0dc5d56ab040f1e2108b063c614a16f8d92f8..a1aa1ad51150424512bb1fb297b74091ce12ce97 100644 (file)
@@ -2018,7 +2018,7 @@ public class Vala.GIdlParser : CodeVisitor {
                        // return type.
                        if (current_data_type is Class && res != null) {
                                if ("%s*".printf (current_data_type.get_cname()) != res.type.unparsed) {
-                                       ((CreationMethod)m).custom_return_type_cname = res.type.unparsed;
+                                       m.custom_return_type_cname = res.type.unparsed;
                                }
                        }
                } else {