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 627287 - introspected functions should implement call() and apply()
introspected functions should implement call() and apply()
Status: RESOLVED DUPLICATE of bug 646852
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2010-08-18 17:48 UTC by Dan Winship
Modified: 2011-04-26 15:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gi: Implement call() and apply() methods on introspected functions (2.96 KB, patch)
2011-04-05 12:04 UTC, Dan Winship
needs-work Details | Review
gi: Implement call() and apply() methods on introspected functions (4.23 KB, patch)
2011-04-05 18:38 UTC, Dan Winship
none Details | Review

Description Dan Winship 2010-08-18 17:48:01 UTC
In a discussion on gnome-shell list someone pointed out that you can't call atk_object_get_name() on AtkObjects that implement the AtkAction interface, because foo.get_name() will end up calling atk_action_get_name() instead. I suggested that they could use "Atk.Object.prototype.get_name.call(foo)" instead, but it turns out that this doesn't work because introspected functions don't define call(). Shouldn't be hard to fix.

(Yes, atk is broken.)
Comment 1 Tommi Komulainen 2010-08-18 18:14:19 UTC
IIRC jdahlin had successfully used something equivalent to "Atk.Object.prototype.get_name(foo)"
Comment 2 Dan Winship 2011-04-05 12:04:57 UTC
Created attachment 185190 [details] [review]
gi: Implement call() and apply() methods on introspected functions
Comment 3 Tommi Komulainen 2011-04-05 13:25:31 UTC
Review of attachment 185190 [details] [review]:

Could use some unit tests for both.

::: gi/function.c
@@ +902,3 @@
+    if (success)
+        JS_SET_RVAL(context, vp, retval);
+           uintN      argc,

apply_argv is not freed when we get here

could probably use g_newa here, the number of arguments should be small enough for stack
Comment 4 Dan Winship 2011-04-05 18:38:42 UTC
Created attachment 185224 [details] [review]
gi: Implement call() and apply() methods on introspected functions

now with tests. I couldn't find a Gio method with multiple arguments that
I could use (ie, an object that was constructable from gjs and does not
depend on external state [eg files, dbus] and that has at least one method
with multiple arguments that are all representable from gjs). So I did
two tests, one testing multi-arg functions that don't care about "this",
and one testing single-arg functions that do.
Comment 5 Tommi Komulainen 2011-04-05 19:56:52 UTC
(In reply to comment #4)
Just quickly noting that shouldn't Regress in gobject-introspection have plenty of introspectable functions to test with?
Comment 6 Tommi Komulainen 2011-04-05 20:04:39 UTC
Another quick note, I think it would be good to test how understandable error message you get when call/apply fails when 'this' is an incompatible object.
Comment 7 Dan Winship 2011-04-26 15:30:41 UTC

*** This bug has been marked as a duplicate of bug 646852 ***