After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 615924 - don't include array length in JS API
don't include array length in JS API
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2010-04-16 05:22 UTC by Danielle Madeley
Modified: 2011-07-18 16:10 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Danielle Madeley 2010-04-16 05:22:31 UTC
Say you've got a function like:

void something (guint n_badgers, SomeEnumThusAGuint *badgers) { }

where @badgers: (array length=n_badgers), then gjs requires you to pass n_badgers in your JS method call:

  something(2, [BADGER_1, BADGER_2]);

Whereas it seems like it would be much more useful to pass:

  something([BADGER_1, BADGER_2]);

Like you would do for a NULL-terminated array.
Comment 1 Colin Walters 2010-04-16 12:13:02 UTC
Yes, this was the intent.  gi/function.c will need to be modified.
Comment 2 Dan Winship 2010-04-16 15:15:50 UTC
This will be an ABI break (though if we wanted, we could make it accept both signatures, presumably with a warning in the length-explicitly-provided case.)
Comment 3 Simon McVittie 2010-04-21 11:49:32 UTC
(In reply to comment #2)
> This will be an ABI break

Do you mean an ABI break for gobject-introspection itself, or for bindings generated from it? If you mean the latter, perhaps there could be an option to opt-in to the new ABI?

(telepathy-glib has never had language bindings, and we don't consider the ones Danielle is working on to be part of our API yet, so we'd rather move to a new ABI "early".)
Comment 4 Dan Winship 2010-04-21 13:48:59 UTC
(In reply to comment #3)
> Do you mean an ABI break for gobject-introspection itself, or for bindings
> generated from it?

Uh, neither. This isn't about changing the gir/typelib, it's just changing *gjs*'s interpretation of it. So it would be an ABI break for gjs's wrapping of these libraries.

As for "opting in", that might be more work than people care to put into it. I was just thinking more along the lines of "we need to do something so that old gnome-shell gives an (obvious) error with new gjs, and vice versa"
Comment 5 Colin Walters 2011-07-18 16:10:15 UTC
commit 7ed2e7d8f13376e523bea8ac1bcf4c4068472522
Author: Giovanni Campagna <gcampagna@src.gnome.org>
Date:   Sat May 21 19:52:25 2011 +0200

    Rework how special arguments are marshalled
    
    Introduce an array of param_types for special arguments (callbacks,
    arrays with explicit length). This means that now more than one
    callback is supported for each function, and you don't need to
    specify an explicit length for arrays.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=646632
    
    Conflicts:
    
        test/js/testGIMarshalling.js