| 41 | } |
| 42 | |
| 43 | bool InterfacePrototype::new_enumerate_impl( |
| 44 | JSContext* cx, JS::HandleObject, JS::MutableHandleIdVector properties, |
| 45 | bool only_enumerable [[maybe_unused]]) { |
| 46 | if (!info()) |
| 47 | return true; |
| 48 | |
| 49 | GI::InterfaceInfo::MethodsIterator methods = info()->methods(); |
| 50 | int n_methods = methods.size(); |
| 51 | if (!properties.reserve(properties.length() + n_methods)) { |
| 52 | JS_ReportOutOfMemory(cx); |
| 53 | return false; |
| 54 | } |
| 55 | |
| 56 | for (GI::AutoFunctionInfo meth_info : methods) { |
| 57 | if (meth_info.is_method()) { |
| 58 | const char* name = meth_info.name(); |
| 59 | jsid id = gjs_intern_string_to_id(cx, name); |
| 60 | if (id.isVoid()) |
| 61 | return false; |
| 62 | properties.infallibleAppend(id); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | return true; |
| 67 | } |
| 68 | |
| 69 | // See GIWrapperBase::resolve(). |
| 70 | bool InterfacePrototype::resolve_impl(JSContext* cx, JS::HandleObject obj, |