diff options
author | Giovanni Campagna <gcampagna@src.gnome.org> | 2012-03-11 16:40:55 +0100 |
---|---|---|
committer | Giovanni Campagna <gcampagna@src.gnome.org> | 2012-03-12 01:37:19 +0100 |
commit | c0d38f43e4313ed3578c4c86954b704bb2d528cc (patch) | |
tree | 73625dd2001ab8ca45ec6a37ce32350f3d0dc4d8 | |
parent | 3c2af8c4c7f3081def07ff93fe87bd3af4d92a5c (diff) | |
download | gjs-c0d38f43e4313ed3578c4c86954b704bb2d528cc.tar.gz |
Don't pass the object as the first argument to a vfunc
The object is already passed as this, there is no need to pass it
as the first argument, and it actually breaks expectations from
API users.
https://bugzilla.gnome.org/show_bug.cgi?id=671833
-rw-r--r-- | gi/function.c | 7 | ||||
-rw-r--r-- | test/js/testGObjectClass.js | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/gi/function.c b/gi/function.c index 96ed0ed1..0e3fc7f0 100644 --- a/gi/function.c +++ b/gi/function.c @@ -279,10 +279,13 @@ gjs_callback_closure(ffi_cif *cif, } } - if (trampoline->is_vfunc) + if (trampoline->is_vfunc) { this_object = JSVAL_TO_OBJECT(jsargs[0]); - else + jsargs++; + n_jsargs--; + } else { this_object = NULL; + } if (!JS_CallFunctionValue(context, this_object, diff --git a/test/js/testGObjectClass.js b/test/js/testGObjectClass.js index ec2c79ce..99a408c1 100644 --- a/test/js/testGObjectClass.js +++ b/test/js/testGObjectClass.js @@ -142,6 +142,8 @@ const MyInitable = new Lang.Class({ }, vfunc_init: function(cancellable) { // error? + assertTrue(cancellable instanceof Gio.Cancellable); + this.inited = true; } }); @@ -252,7 +254,7 @@ function testInterface() { let instance = new MyInitable(); assertEquals(false, instance.inited); - instance.init(null); + instance.init(new Gio.Cancellable); assertEquals(true, instance.inited); // assertTrue(instance instanceof Gio.Initable) |