[vala/0.8] vapigen: Support is_array attribute for delegate parameters



commit 6ea1037eb51e139fa269e525d96d9e6761ebc90b
Author: Travis Reitter <treitter gmail com>
Date:   Tue Apr 20 20:55:35 2010 +0200

    vapigen: Support is_array attribute for delegate parameters
    
    Fixes bug 615971.

 vapigen/valagidlparser.vala |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala
index 9e8ddcb..dd40d40 100644
--- a/vapigen/valagidlparser.vala
+++ b/vapigen/valagidlparser.vala
@@ -352,6 +352,8 @@ public class Vala.GIdlParser : CodeVisitor {
 
 				bool hide_param = false;
 				bool show_param = false;
+				bool array_requested = false;
+				bool out_requested = false;
 				attributes = get_attributes ("%s.%s".printf (node.name, param_node.name));
 				if (attributes != null) {
 					foreach (string attr in attributes) {
@@ -362,13 +364,33 @@ public class Vala.GIdlParser : CodeVisitor {
 							} else if (eval (nv[1]) == "0") {
 								show_param = true;
 							}
+						} else if (nv[0] == "is_array") {
+							if (eval (nv[1]) == "1") {
+								param_type = new ArrayType (param_type, 1, param_type.source_reference);
+								p.parameter_type = param_type;
+								if (!out_requested) {
+									p.direction = ParameterDirection.IN;
+								}
+								array_requested = true;
+							}
 						} else if (nv[0] == "is_out") {
 							if (eval (nv[1]) == "1") {
 								p.direction = ParameterDirection.OUT;
+								out_requested = true;
+								if (!array_requested && param_type is ArrayType) {
+									var array_type = (ArrayType) param_type;
+									param_type = array_type.element_type;
+									p.parameter_type = param_type;
+								}
 							}
 						} else if (nv[0] == "is_ref") {
 							if (eval (nv[1]) == "1") {
 								p.direction = ParameterDirection.REF;
+								if (!array_requested && param_type is ArrayType) {
+									var array_type = (ArrayType) param_type;
+									param_type = array_type.element_type;
+									p.parameter_type = param_type;
+								}
 							}
 						} else if (nv[0] == "takes_ownership") {
 							if (eval (nv[1]) == "1") {



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