[gjs/wip/walters/632938-use-g-irepository-get-object-gtype-interfaces: 337/337] object: Use g_irepository_get_object_gtype_interfaces
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/wip/walters/632938-use-g-irepository-get-object-gtype-interfaces: 337/337] object: Use g_irepository_get_object_gtype_interfaces
- Date: Thu, 20 Jun 2019 06:22:23 +0000 (UTC)
commit 93c11d1a870f54e49985a681b49320852c06b43a
Author: Colin Walters <walters verbum org>
Date: Fri Oct 22 18:09:16 2010 -0400
object: Use g_irepository_get_object_gtype_interfaces
Push the logic for this down into libgirepository, where we
can more easily cache/optimize it.
Closes #55
gi/object.cpp | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 3d0064b5..763a8685 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -641,8 +641,11 @@ bool ObjectPrototype::resolve_no_info(JSContext* cx, JS::HandleObject obj,
JS::HandleId id, bool* resolved,
const char* name,
ResolveWhat resolve_props) {
+ GIInterfaceInfo *interfaces;
guint n_interfaces;
guint i;
+ g_irepository_get_object_gtype_interfaces(nullptr, m_gtype, &n_interfaces,
+ &interfaces);
GjsAutoChar canonical_name;
if (resolve_props == ConsiderMethodsAndProperties) {
@@ -650,24 +653,16 @@ bool ObjectPrototype::resolve_no_info(JSContext* cx, JS::HandleObject obj,
canonicalize_key(canonical_name);
}
- GType *interfaces = g_type_interfaces(m_gtype, &n_interfaces);
for (i = 0; i < n_interfaces; i++) {
- GjsAutoInterfaceInfo iface_info =
- g_irepository_find_by_gtype(nullptr, interfaces[i]);
- if (!iface_info)
- continue;
-
+ GIInterfaceInfo *iface_info = interfaces + i;
GjsAutoFunctionInfo method_info =
g_interface_info_find_method(iface_info, name);
if (method_info) {
if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
- if (!gjs_define_function(cx, obj, m_gtype, method_info)) {
- g_free(interfaces);
+ if (!gjs_define_function(cx, obj, m_gtype, method_info))
return false;
- }
*resolved = true;
- g_free(interfaces);
return true;
}
}
@@ -678,14 +673,11 @@ bool ObjectPrototype::resolve_no_info(JSContext* cx, JS::HandleObject obj,
/* If the name refers to a GObject property, lazily define the property
* in JS as we do below in the real resolve hook. We ignore fields here
* because I don't think interfaces can have fields */
- if (is_ginterface_property_name(iface_info, canonical_name)) {
- g_free(interfaces);
+ if (is_ginterface_property_name(iface_info, canonical_name))
return lazy_define_gobject_property(cx, obj, id, resolved, name);
- }
}
*resolved = false;
- g_free(interfaces);
return true;
}
@@ -831,8 +823,8 @@ bool ObjectPrototype::resolve_impl(JSContext* context, JS::HandleObject obj,
/**
* Search through any interfaces implemented by the GType;
- * this could be done better. See
- * https://bugzilla.gnome.org/show_bug.cgi?id=632922
+ * See https://bugzilla.gnome.org/show_bug.cgi?id=632922
+ * for background on why we need to do this.
*/
if (!method_info)
return resolve_no_info(context, obj, id, resolved, name,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]