The *resolved out parameter, on success, should be false to indicate that id was not resolved; and true if id was resolved.
| 84 | // The *resolved out parameter, on success, should be false to indicate that |
| 85 | // id was not resolved; and true if id was resolved. |
| 86 | GJS_JSAPI_RETURN_CONVENTION |
| 87 | bool resolve_impl(JSContext* cx, JS::HandleObject obj, JS::HandleId id, |
| 88 | bool* resolved) { |
| 89 | if (!id.isString()) { |
| 90 | *resolved = false; |
| 91 | return true; // not resolved, but no error |
| 92 | } |
| 93 | |
| 94 | // let Object.prototype resolve these |
| 95 | const GjsAtoms& atoms = GjsContextPrivate::atoms(cx); |
| 96 | if (id == atoms.to_string() || id == atoms.value_of()) { |
| 97 | *resolved = false; |
| 98 | return true; |
| 99 | } |
| 100 | |
| 101 | JS::UniqueChars name; |
| 102 | if (!gjs_get_string_id(cx, id, &name)) |
| 103 | return false; |
| 104 | if (!name) { |
| 105 | *resolved = false; |
| 106 | return true; // not resolved, but no error |
| 107 | } |
| 108 | |
| 109 | Maybe<GI::AutoBaseInfo> info{ |
| 110 | GI::Repository{}.find_by_name(get(), name.get())}; |
| 111 | if (!info) { |
| 112 | *resolved = false; // No property defined, but no error either |
| 113 | return true; |
| 114 | } |
| 115 | |
| 116 | gjs_debug(GJS_DEBUG_GNAMESPACE, |
| 117 | "Found info type %s for '%s' in namespace '%s'", |
| 118 | info->type_string(), info->name(), info->ns()); |
| 119 | |
| 120 | #if !GLIB_CHECK_VERSION(2, 87, 3) |
| 121 | if (m_is_glib) { |
| 122 | platform_specific_warning_glib(cx, "Unix", "Unix", name.get()); |
| 123 | platform_specific_warning_glib(cx, "unix_", "Unix", name.get()); |
| 124 | platform_specific_warning_glib(cx, "Win32", "Win32", name.get()); |
| 125 | platform_specific_warning_glib(cx, "win32_", "Win32", name.get()); |
| 126 | } |
| 127 | #endif |
| 128 | |
| 129 | bool defined; |
| 130 | if (!gjs_define_info(cx, obj, info.ref(), &defined)) { |
| 131 | gjs_debug(GJS_DEBUG_GNAMESPACE, "Failed to define info '%s'", |
| 132 | info->name()); |
| 133 | return false; |
| 134 | } |
| 135 | |
| 136 | // we defined the property in this object? |
| 137 | *resolved = defined; |
| 138 | return true; |
| 139 | } |
| 140 | |
| 141 | GJS_JSAPI_RETURN_CONVENTION |
| 142 | bool new_enumerate_impl(JSContext* cx, |
no test coverage detected