GNOME Bugzilla – Bug 627287
introspected functions should implement call() and apply()
Last modified: 2011-04-26 15:30:41 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.)
IIRC jdahlin had successfully used something equivalent to "Atk.Object.prototype.get_name(foo)"
Created attachment 185190 [details] [review] gi: Implement call() and apply() methods on introspected functions
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
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.
(In reply to comment #4) Just quickly noting that shouldn't Regress in gobject-introspection have plenty of introspectable functions to test with?
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.
*** This bug has been marked as a duplicate of bug 646852 ***