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 603754 - Make arguments annotated as 'closure' optional
Make arguments annotated as 'closure' optional
Status: RESOLVED OBSOLETE
Product: gjs
Classification: Bindings
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2009-12-04 02:04 UTC by Florian Müllner
Modified: 2010-02-19 16:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Make arguments annotated as 'closure' optional (3.79 KB, patch)
2009-12-04 02:04 UTC, Florian Müllner
needs-work Details | Review
Make arguments annotated as 'closure' optional (4.81 KB, patch)
2009-12-04 19:55 UTC, Florian Müllner
none Details | Review

Description Florian Müllner 2009-12-04 02:04:19 UTC
The user_data argument to methods with callback parameter should hardly be used in the binding - allow for omission in this case rather than enforcing to pass in null.
Comment 1 Florian Müllner 2009-12-04 02:04:22 UTC
Created attachment 149064 [details] [review]
Make arguments annotated as 'closure' optional

With this change, methods with callback parameters follow the same syntax as Mainloop.timeout_add or Signal.connect.
Comment 2 Johan (not receiving bugmail) Dahlin 2009-12-04 11:20:15 UTC
Comment on attachment 149064 [details] [review]
Make arguments annotated as 'closure' optional

This will need additional tests.

Can internal_argc be merged with argc?
Comment 3 Florian Müllner 2009-12-04 19:55:38 UTC
Created attachment 149115 [details] [review]
Make arguments annotated as 'closure' optional

Added a test case for a callback with omitted user_data parameter.

A simple merge of internal_argc with argc results in a failed assertion in line 678, I'll keep looking into it though.
Comment 4 Colin Walters 2009-12-09 19:38:39 UTC
Hmm; this inherently assumes that functions only have user_datas at the end of the function, but I'm pretty sure there are functions somewhere in the stack that take multiple callbacks, like:

void foo (GFoo *self, FooSomeCallback callback, gpointer user_data,  FooOtherCallback, gpointer other_data, GDestroyNotify destroy_notify).

Maybe we could detect this case though and make them mandatory.

Personally though, I'd rather we always deleted user_data arguments, and fixed e.g. Lang.bind to allow currying, like:

  foo.connect('changed', Lang.bind(this, this._onChanged, someData, otherData));

where someData and otherData are passed to onChanged too.
Comment 5 Havoc Pennington 2009-12-09 19:42:27 UTC
Lang.bind already does allow that
Comment 6 Colin Walters 2009-12-09 20:18:40 UTC
Ok; so what are the thoughts on deleting the user_data params?
Comment 7 Havoc Pennington 2009-12-09 20:19:41 UTC
I don't know why/how you'd use user data from JS
Comment 8 Florian Müllner 2010-02-19 16:31:33 UTC
Comment on attachment 149115 [details] [review]
Make arguments annotated as 'closure' optional

Patch does no longer apply to master, and as it makes much more sense deleting user_data arguments altogether i'm marking this obsolete