| 163 | // clang-format on |
| 164 | |
| 165 | bool gjs_lookup_interface_constructor(JSContext* cx, GType gtype, |
| 166 | JS::MutableHandleValue value_p) { |
| 167 | GI::Repository repo; |
| 168 | Maybe<GI::AutoRegisteredTypeInfo> interface_info{repo.find_by_gtype(gtype)}; |
| 169 | if (!interface_info) { |
| 170 | gjs_throw(cx, "Cannot expose non introspectable interface %s", |
| 171 | g_type_name(gtype)); |
| 172 | return false; |
| 173 | } |
| 174 | |
| 175 | JSObject* constructor = |
| 176 | gjs_lookup_generic_constructor(cx, interface_info.ref()); |
| 177 | if (G_UNLIKELY(!constructor)) |
| 178 | return false; |
| 179 | |
| 180 | value_p.setObject(*constructor); |
| 181 | return true; |
| 182 | } |
no test coverage detected