Commit d6abc579 authored by Colin Walters's avatar Colin Walters Committed by Philip Chimento

object: Use g_irepository_get_object_gtype_interfaces

Push the logic for this down into libgirepository, where we
can more easily cache/optimize it.

[skip ci] - Won't compile until corresponding patch is merged into

Closes #55
parent 4ab70efb
Pipeline #35861 skipped
......@@ -725,8 +725,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,
GjsAutoChar canonical_name;
if (resolve_props == ConsiderMethodsAndProperties) {
......@@ -734,24 +737,16 @@ bool ObjectPrototype::resolve_no_info(JSContext* cx, JS::HandleObject obj,
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)
GIInterfaceInfo *iface_info = interfaces + i;
GjsAutoFunctionInfo method_info =
g_interface_info_find_method(iface_info, name);
if (method_info != NULL) {
if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
if (!gjs_define_function(cx, obj, m_gtype, method_info)) {
if (!gjs_define_function(cx, obj, m_gtype, method_info))
return false;
*resolved = true;
return true;
......@@ -762,14 +757,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)) {
if (is_ginterface_property_name(iface_info, canonical_name))
return lazy_define_gobject_property(cx, obj, id, resolved, name);
*resolved = false;
return true;
......@@ -934,8 +926,8 @@ bool ObjectPrototype::resolve_impl(JSContext* context, JS::HandleObject obj,
* Search through any interfaces implemented by the GType;
* this could be done better. See
* See
* for background on why we need to do this.
if (!method_info)
return resolve_no_info(context, obj, id, resolved, name.get(),
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment