GNOME Bugzilla – Bug 761360
Delegate returning array does not return array length
Last modified: 2016-10-05 06:50:37 UTC
Created attachment 320124 [details] Test case showing the problem I've got a function that returns a delegate that returns an array. When the delegate is invoked the length of the returned array isn't set. Consider the following where I want to pass a number of different function types F1, F2 to something that takes a Func private delegate double[] Func (double[] xs); private delegate double F1 (double x); private delegate double F2 (double x, double y); private delegate double[] Marshal_f1 (F1 f, double[] xs); private delegate double[] Marshal_f2 (F2 f, double[] xs); private Func wrap_f (F f) { Func g = (xs) => { var z = f (xs[0]); double[] ret = { z }; return ret; }; return g; } The C code created for g above does not set the array length static gdouble* ___lambda4__func (gdouble* xs, int xs_length1, int* result_length1, gpointer self) { gdouble* result; result = __lambda4_ (self, xs, xs_length1); return result; } If I use a marshaller instead then the length is returned. I've attached a simple testcase to illustrate the problem.
Created attachment 320127 [details] Test case Sorry I over simplified the other test case and it didn't compile, this one correctly demonstrates the problem.
Created attachment 336756 [details] [review] Fix array length of array returned by lambda
commit 566ff81b821775c6e178c8c90bcac95d08436c91 Author: Simon Werbeck <simon.werbeck@gmail.com> Date: Fri Feb 26 00:28:11 2016 +0100 codegen: Fix array length of array returned by lambda This ensures that the right default values are used for missing ccode attributes.