[vala/0.36] codegen: Fix casting of length for "ref" array parameters
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.36] codegen: Fix casting of length for "ref" array parameters
- Date: Mon, 21 May 2018 16:47:33 +0000 (UTC)
commit 89d652ece751dc06410e3a7e2ca0f3df7bac23f9
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun May 20 17:07:59 2018 +0200
codegen: Fix casting of length for "ref" array parameters
codegen/valaccodemethodcallmodule.vala | 6 +++++-
tests/Makefile.am | 1 +
tests/methods/bug634753.vala | 8 ++++++++
3 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 87da66b..7c0f122 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -363,7 +363,11 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
for (int dim = 1; dim <= array_type.rank; dim++) {
CCodeExpression? array_length_expr = null;
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));
+ string length_ctype =
get_ccode_array_length_type (param);
+ if (unary.operator ==
UnaryOperator.REF) {
+ length_ctype = "%s*".printf
(length_ctype);
+ }
+ array_length_expr = new
CCodeCastExpression (get_array_length_cexpression (arg, dim), length_ctype);
} else {
array_length_expr =
get_array_length_cexpression (arg, dim);
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a309eda..849be7e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -84,6 +84,7 @@ TESTS = \
methods/bug620673.vala \
methods/bug622570.vala \
methods/bug626783.vala \
+ methods/bug634753.vala \
methods/bug639054.vala \
methods/bug642350.vala \
methods/bug642885.vala \
diff --git a/tests/methods/bug634753.vala b/tests/methods/bug634753.vala
new file mode 100644
index 0000000..fdee042
--- /dev/null
+++ b/tests/methods/bug634753.vala
@@ -0,0 +1,8 @@
+void foo ([CCode (array_length_type = "gsize")] ref uint8[] a) {
+ assert (a.length == 32);
+}
+
+void main () {
+ uint8[] a = new uint8[32];
+ foo (ref a);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]