[Vala] Vala arrays and libraries bindings



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.

As an example: I need to define a javascript function that will return
an js array object:

    public static JSCore.Value js_read_dir (Context ctx,
            JSCore.Object function,
            JSCore.Object thisObject,
            JSCore.Value[] arguments,
            out JSCore.Value exception) {

        JSCore.Value[] dirs = {};
        dirs += new JSCore.Value.string( ctx, new
String.with_utf8_c_string ("a") );
        dirs += new JSCore.Value.string( ctx, new
String.with_utf8_c_string ("b") );
        JSCore.Value err = new JSCore.Value.null( ctx );

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

Here is the method definition from the vapi file:
                [CCode (cname = "JSObjectMakeArray")]
                public Object.array (Context ctx, size_t argument_count,
                                     JSCore.Value[] arguments,
                                     out JSCore.Value exception);

Everything seems ok to me, but valac adds an additional argument to
the method call
for some reason and this prevents the code from compiling. Here is how
the generated
call looks like:

_tmp9_ = JSObjectMakeArray (_tmp8_, (gsize) 2, dirs, dirs_length1, &err);

As you can see, there is an extra argument - dir_length1, which
doesn't exist neither in
bindings nor in vala code. I've searched for some examples and the
only thing I've found
 was that people construct json strings, evaluate them and get
the objects they need from evaluation.

So, where am I wrong? How can I fix my code to use standard bindings?

-- 
Kind regards, Dmitry Petrov



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