[gjs] boxed: mark structs with gpointer fields as simple
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] boxed: mark structs with gpointer fields as simple
- Date: Tue, 29 Oct 2019 05:11:19 +0000 (UTC)
commit bb7d42b5273c1d7921d37d57be67042717967295
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Sun May 19 18:39:06 2013 +0200
boxed: mark structs with gpointer fields as simple
Even if we cannot set the field, it's pretty safe to initialize
it to NULL, and then you can use the rest of the structure.
This enables construction of Gtk.TreeIter, even if limited to
stamp.
https://gitlab.gnome.org/GNOME/gjs/issues/71
gi/boxed.cpp | 2 ++
installed-tests/js/testGtk.js | 6 ++++++
2 files changed, 8 insertions(+)
---
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index 9e196abd..d37603ba 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -773,6 +773,8 @@ type_can_be_allocated_directly(GITypeInfo *type_info)
is_simple = type_can_be_allocated_directly(param_info);
g_base_info_unref((GIBaseInfo*)param_info);
+ } else if (g_type_info_get_tag(type_info) == GI_TYPE_TAG_VOID) {
+ return true;
} else {
is_simple = false;
}
diff --git a/installed-tests/js/testGtk.js b/installed-tests/js/testGtk.js
index 667aa50f..475526f5 100644
--- a/installed-tests/js/testGtk.js
+++ b/installed-tests/js/testGtk.js
@@ -215,4 +215,10 @@ describe('Gtk overrides', function () {
s.child_set_property(p, 'name', null);
expect(s.get_child_by_name('foo')).toBeNull();
});
+
+ it('can create a Gtk.TreeIter with accessible stamp field', function () {
+ const iter = new Gtk.TreeIter();
+ iter.stamp = 42;
+ expect(iter.stamp).toEqual(42);
+ });
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]