[vala] Move custom_return_type_cname CCode attribute down to Method



commit c183c0992f9c6fbaff0f61431dd73ecc347c7e22
Author: Luca Bruno <lucabru src gnome org>
Date:   Sat Jun 4 18:21:08 2011 +0200

    Move custom_return_type_cname CCode attribute down to Method

 codegen/valaccodemethodmodule.vala |    9 +--------
 vala/valacodewriter.vala           |    9 +++++----
 vala/valacreationmethod.vala       |    8 --------
 vala/valamethod.vala               |    8 ++++++++
 vapigen/valagidlparser.vala        |    2 +-
 5 files changed, 15 insertions(+), 21 deletions(-)
---
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 879fe32..e2f0985 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -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) {
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index 01cb8ef..ff5b413 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -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 = ", ";
diff --git a/vala/valacreationmethod.vala b/vala/valacreationmethod.vala
index 7958ec6..7ece293 100644
--- a/vala/valacreationmethod.vala
+++ b/vala/valacreationmethod.vala
@@ -34,14 +34,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.
 	 */
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index cd935a2..9664072 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -181,6 +181,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.
 	 */
 	public bool printf_format { get; set; }
@@ -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");
+		}
 	}
 	
 	/**
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala
index 6fe0dc5..a1aa1ad 100644
--- a/vapigen/valagidlparser.vala
+++ b/vapigen/valagidlparser.vala
@@ -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 {



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