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 606258 - remove user_data arguments
remove user_data arguments
Status: RESOLVED FIXED
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks: 600276
 
 
Reported: 2010-01-06 20:22 UTC by Colin Walters
Modified: 2010-03-18 17:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Remove user_data arguments for callbacks (8.45 KB, patch)
2010-02-21 00:31 UTC, Florian Müllner
none Details | Review
Remove user_data arguments for callbacks (8.62 KB, patch)
2010-03-08 13:12 UTC, Florian Müllner
reviewed Details | Review
Remove user_data arguments for callbacks (8.31 KB, patch)
2010-03-12 01:01 UTC, Florian Müllner
committed Details | Review

Description Colin Walters 2010-01-06 20:22:23 UTC
We should delete the user_data arguments for callbacks from the GScript API, because it's trivial to create closures in GScript, and passing "null" is annoying.

This change needs to be made sooner rather than later, otherwise it will never happen; it is an API breaking change.

Agreement?  Would a patch for this be accepted?
Comment 1 Johan (not receiving bugmail) Dahlin 2010-01-06 20:24:03 UTC
Yes, user_data arguments should be removed. There are many ways to pass in user arguments, Lang.bind() is one of them.
Comment 2 Florian Müllner 2010-02-21 00:31:47 UTC
Created attachment 154286 [details] [review]
Remove user_data arguments for callbacks

We already remove user_data arguments to the timeout/idle and
signal functions - this change does the same for generic callbacks
(assuming correct gi-annotations of course).

Note that this change constitutes an API break - although I'd expect the impact on existing code rather low, because of one notable exception where code will continue to work:

1) the user_data argument is unused (read: null)
2) user_data is the last argument

If both conditions are met, code will continue to work as excess arguments on the JS side are simply ignored. I'd expect 1) to be usually the case (I've never stumbled upon code like the callback unit tests), and 2) not being met is something I'll yet have to encounter.

With that said, additional arguments after the user_data parameter might still be a corner case worth adding to Everything-1.0.
Comment 3 Colin Walters 2010-02-22 15:48:56 UTC
Gjs maintainers, any opinions on when/how to land API-breaking changes like this?
Comment 4 Havoc Pennington 2010-02-22 16:29:46 UTC
I would expect that while this is technically an API break, in practice it barely breaks anything - unless we do throw an error if someone's provided an extra "null" arg? (Don't know if our g-i invocation stuff ignores extra args in the way JS normally does. if not it probably should.)

If nobody is really going to break I think we can just put this in. It's not like gjs is in stable locked-down release mode.
Comment 5 Florian Müllner 2010-02-22 17:12:45 UTC
(In reply to comment #4)
> I would expect that while this is technically an API break, in practice it
> barely breaks anything - unless we do throw an error if someone's provided an
> extra "null" arg? (Don't know if our g-i invocation stuff ignores extra args in
> the way JS normally does. if not it probably should.)

Extra arguments are ignored, so providing an extra "null" is fine as long as the user_data argument is the last one - as already pointed out above, I think it's more realistic to expect code breakage because of the user_data argument being actually used...
Comment 6 Florian Müllner 2010-03-08 13:12:01 UTC
Created attachment 155556 [details] [review]
Remove user_data arguments for callbacks

Rebased to master
Comment 7 Colin Walters 2010-03-11 22:45:56 UTC
Review of attachment 155556 [details] [review]:

Looks like you didn't modify gi/function.c:gjs_callback_closure ?  That means user_data will still come through in the callback, but not really a big deal.  I'm actually not sure offhand if introspection even marks that.  Don't worry about this.

The changes to function.c look reasonable to me.

::: test/js/testEverythingBasic.js
@@ +218,3 @@
+                                     testObj.userData.foo.length);
+                                               testObj.callbackUserData)),
+                                     Lang.bind(testObj,

I don't understand what's going on this test. Is this just trying to test the JavaScript GC?  There's no way that Everything.test_callback_user_data can change testObj.userData now.

I think this test should just be deleted, basically.
Comment 8 Florian Müllner 2010-03-12 01:01:14 UTC
Created attachment 155911 [details] [review]
Remove user_data arguments for callbacks

Remove test_callback_user_data()
Comment 9 Colin Walters 2010-03-16 14:43:24 UTC
Review of attachment 155911 [details] [review]:

This looks right to me.  Note I'd like a bit more test coverage here, so review of https://bugzilla.gnome.org/show_bug.cgi?id=611811 would be appreciated.
Comment 10 Florian Müllner 2010-03-18 17:33:28 UTC
Attachment 155911 [details] pushed as 906ad5a - Remove user_data arguments for callbacks