MCPcopy Create free account
hub / github.com/GNOME/gjs / invoke

Method invoke

gi/closure.cpp:163–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163bool Closure::invoke(JS::HandleObject this_obj,
164 const JS::HandleValueArray& args,
165 JS::MutableHandleValue retval) {
166 if (!m_callable) {
167 // We were destroyed; become a no-op
168 reset();
169 return false;
170 }
171
172 JSAutoRealm ar{m_cx, m_callable.get()};
173
174 if (gjs_log_exception(m_cx)) {
175 gjs_debug_closure(
176 "Exception was pending before invoking callback??? "
177 "Not expected - closure %p",
178 this);
179 }
180
181 JS::RootedValue v_callable{m_cx, JS::ObjectValue(*m_callable.get())};
182 if (!JS::Call(m_cx, this_obj, v_callable, args, retval)) {
183 gjs_debug_closure(
184 "Closure invocation failed (exception should have been thrown) "
185 "closure %p callable %p",
186 this, m_callable.debug_addr());
187 return false;
188 }
189
190 if (gjs_log_exception_uncaught(m_cx)) {
191 gjs_debug_closure(
192 "Closure invocation succeeded but an exception was set"
193 " - closure %p",
194 m_cx);
195 }
196
197 GjsContextPrivate* gjs = GjsContextPrivate::from_cx(m_cx);
198 gjs->schedule_gc_if_needed();
199 return true;
200}
201
202} // namespace Gjs

Callers 4

intern_gdk_atomFunction · 0.45
release_native_objectMethod · 0.45
constructor_implMethod · 0.45

Calls 5

gjs_log_exceptionFunction · 0.85
debug_addrMethod · 0.80
schedule_gc_if_neededMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected