[vala/wip/attributes: 29/121] codegen: Add get_ccode_array_length_type



commit 774c543389ab03c54650b2429fddb3f4a300e6ef
Author: Luca Bruno <lucabru src gnome org>
Date:   Tue Jun 28 17:48:34 2011 +0200

    codegen: Add get_ccode_array_length_type

 codegen/valaccodearraymodule.vala        |    4 ++--
 codegen/valaccodebasemodule.vala         |    6 ++++++
 codegen/valaccodedelegatemodule.vala     |    4 ++--
 codegen/valaccodememberaccessmodule.vala |    2 +-
 codegen/valaccodemethodcallmodule.vala   |   12 ++++++------
 codegen/valaccodemethodmodule.vala       |    2 +-
 6 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index 1f2dd56..83b4d1e 100644
--- a/codegen/valaccodearraymodule.vala
+++ b/codegen/valaccodearraymodule.vala
@@ -734,8 +734,8 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 
 		if (!get_ccode_no_array_length (param)) {
 			string length_ctype = "int";
-			if (param.array_length_type != null) {
-				length_ctype = param.array_length_type;
+			if (get_ccode_array_length_type (param) != null) {
+				length_ctype = get_ccode_array_length_type (param);
 			}
 			if (param.direction != ParameterDirection.IN) {
 				length_ctype = "%s*".printf (length_ctype);
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 0e5b0f2..4e0ad95 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5721,6 +5721,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		return get_ccode_attribute(sym).no_array_length;
 	}
 
+	public static string? get_ccode_array_length_type (CodeNode node) {
+		return get_ccode_attribute(sym).array_length_type;
+	}
+
 	public override void visit_class (Class cl) {
 	}
 
@@ -6265,6 +6269,7 @@ public class Vala.CCodeAttribute : AttributeCache {
 	}
 
 	public bool no_array_length { get; private set; }
+	public string? array_length_type { get; private set; }
 
 	private string _name;
 	private string _const_name;
@@ -6327,6 +6332,7 @@ public class Vala.CCodeAttribute : AttributeCache {
 			if (attr.has_argument ("array_length")) {
 				no_array_length = !attr.get_bool ("array_length");
 			}
+			array_length_type = attr.get_string ("array_length_type");
 		}
 	}
 
diff --git a/codegen/valaccodedelegatemodule.vala b/codegen/valaccodedelegatemodule.vala
index 26f1897..0875007 100644
--- a/codegen/valaccodedelegatemodule.vala
+++ b/codegen/valaccodedelegatemodule.vala
@@ -83,7 +83,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
 		if (!get_ccode_no_array_length (d) && d.return_type is ArrayType) {
 			// return array length if appropriate
 			var array_type = (ArrayType) d.return_type;
-			var array_length_type = d.array_length_type != null ? d.array_length_type : "int";
+			var array_length_type = get_ccode_array_length_type (d) != null ? get_ccode_array_length_type (d) : "int";
 			array_length_type += "*";
 
 			for (int dim = 1; dim <= array_type.rank; dim++) {
@@ -239,7 +239,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
 		if (!get_ccode_no_array_length (d) && d.return_type is ArrayType) {
 			// return array length if appropriate
 			var array_type = (ArrayType) d.return_type;
-			var array_length_type = d.array_length_type != null ? d.array_length_type : "int";
+			var array_length_type = get_ccode_array_length_type (d) != null ? get_ccode_array_length_type (d) : "int";
 			array_length_type += "*";
 
 			for (int dim = 1; dim <= array_type.rank; dim++) {
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index c56af5e..6df007e 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -683,7 +683,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 				for (int dim = 1; dim <= array_type.rank; dim++) {
 					result.append_array_length_cvalue (new CCodeConstant ("-1"));
 				}
-			} else if (variable.array_length_type != null) {
+			} else if (get_ccode_array_length_type (variable) != null) {
 				for (int dim = 1; dim <= array_type.rank; dim++) {
 					// cast if variable does not use int for array length
 					result.array_length_cvalues[dim - 1] = new CCodeCastExpression (result.array_length_cvalues[dim - 1], "gint");
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 011a689..ffa30cb 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -337,8 +337,8 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 							var array_type = (ArrayType) param.variable_type;
 							for (int dim = 1; dim <= array_type.rank; dim++) {
 								CCodeExpression? array_length_expr = null;
-								if (param.array_length_type != null) {
-									array_length_expr = new CCodeCastExpression (get_array_length_cexpression (arg, dim), param.array_length_type);
+								if (get_ccode_array_length_type (param) != null) {
+									array_length_expr = new CCodeCastExpression (get_array_length_cexpression (arg, dim), get_ccode_array_length_type (param));
 								} else {
 									array_length_expr = get_array_length_cexpression (arg, dim);
 								}
@@ -399,8 +399,8 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 						if (!get_ccode_no_array_length (param) && param.variable_type is ArrayType) {
 							var array_type = (ArrayType) param.variable_type;
 							var array_length_type = int_type;
-							if (param.array_length_type != null) {
-								array_length_type = new CType (param.array_length_type);
+							if (get_ccode_array_length_type (param) != null) {
+								array_length_type = new CType (get_ccode_array_length_type (param));
 							}
 							for (int dim = 1; dim <= array_type.rank; dim++) {
 								var temp_array_length = get_temp_variable (array_length_type);
@@ -481,10 +481,10 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 				} else if (!get_ccode_no_array_length (m)) {
 					LocalVariable temp_var;
 
-					if (m.array_length_type == null) {
+					if (get_ccode_array_length_type (m) == null) {
 						temp_var = get_temp_variable (int_type);
 					} else {
-						temp_var = get_temp_variable (new CType (m.array_length_type));
+						temp_var = get_temp_variable (new CType (get_ccode_array_length_type (m)));
 					}
 					var temp_ref = get_variable_cexpression (temp_var.name);
 
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 44beb73..d29c47b 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -81,7 +81,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
 		} else if (!get_ccode_no_array_length (m) && m.return_type is ArrayType) {
 			// return array length if appropriate
 			var array_type = (ArrayType) m.return_type;
-			var array_length_type = m.array_length_type != null ? m.array_length_type : "int";
+			var array_length_type = get_ccode_array_length_type (m) != null ? get_ccode_array_length_type (m) : "int";
 			array_length_type += "*";
 
 			for (int dim = 1; dim <= array_type.rank; dim++) {



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