Re: [Vala] Vala arrays and libraries bindings



Hi,

On Mon, 2012-05-28 at 03:30 +0400, Дмитрий Петров wrote:
Hello everyone,

I'm very new to vala and my current task is to build an application
using webkit-gtk component. One thing that I can't deal with is
how valac translates the arrays, that should be passed to the function.

May be you have already solved the issue, anyway you can control where
vala puts the array length parameter using a CCode attribute [1].

In this specific case you should bind the JSObjectMakeArray in this way:

[CCode (cname = "JSObjectMakeArray")]
public Object.array (
        Context ctx, 
        [CCode(array_length_type="size_t", array_length_pos=1.1)] JSCore.Value[] arguments, 
        out JSCore.Value exception);

And then use in your code in this way (NOTE: I omitted the array length 
parameter since vala do that work for us)

...
        return new JSCore.Object.array( ctx, dirs, out err);
     }

HTH,
Andrea

[1] https://live.gnome.org/Vala/Manual/Attributes





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