[vala] codegen: Fix signature of array_contains for inline arrays



commit 44b721f8a363ec334ce0f7de53b98fd6776a4fe6
Author: Daiki Ueno <ueno unixuser org>
Date:   Thu Mar 15 13:01:03 2012 +0900

    codegen: Fix signature of array_contains for inline arrays
    
    Fixes bug 672116.

 codegen/valaccodebasemodule.vala |    2 +-
 tests/basic-types/arrays.vala    |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 3b1b2ee..9a82e5d 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5292,7 +5292,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		var function = new CCodeFunction (array_contains_func, "gboolean");
 		function.modifiers = CCodeModifiers.STATIC;
 
-		function.add_parameter (new CCodeParameter ("stack", get_ccode_name (array_type)));
+		function.add_parameter (new CCodeParameter ("stack", "%s*".printf (get_ccode_name (array_type.element_type))));
 		function.add_parameter (new CCodeParameter ("stack_length", "int"));
 		if (array_type.element_type is StructValueType) {
 			function.add_parameter (new CCodeParameter ("needle", get_ccode_name (array_type.element_type) + "*"));
diff --git a/tests/basic-types/arrays.vala b/tests/basic-types/arrays.vala
index 5d4d0c4..be0ca23 100644
--- a/tests/basic-types/arrays.vala
+++ b/tests/basic-types/arrays.vala
@@ -107,6 +107,11 @@ void test_length_assignment () {
 	assert (b.length[0] == 5);
 }
 
+void test_inline_array () {
+	const int a[] = { 1, 2, 3 };
+	assert (1 in a);
+}
+
 void main () {
 	test_integer_array ();
 	test_string_array ();
@@ -114,5 +119,6 @@ void main () {
 	test_static_array ();
 	test_reference_transfer ();
 	test_length_assignment ();
+	test_inline_array ();
 }
 



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