[gjs] Don't pass the object as the first argument to a vfunc
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] Don't pass the object as the first argument to a vfunc
- Date: Mon, 12 Mar 2012 00:37:53 +0000 (UTC)
commit c0d38f43e4313ed3578c4c86954b704bb2d528cc
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Sun Mar 11 16:40:55 2012 +0100
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
gi/function.c | 7 +++++--
test/js/testGObjectClass.js | 4 +++-
2 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gi/function.c b/gi/function.c
index 96ed0ed..0e3fc7f 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 ec2c79c..99a408c 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]