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

Method for_js

modules/cairo-surface.cpp:307–326  ·  view source on GitHub ↗

* CairoSurface::for_js: * @cx: the context * @surface_wrapper: surface wrapper * * Overrides NativeObject::for_js(). * * Returns: the surface attached to the wrapper. */

Source from the content-addressed store, hash-verified

305 * Returns: the surface attached to the wrapper.
306 */
307cairo_surface_t* CairoSurface::for_js(JSContext* cx,
308 JS::HandleObject surface_wrapper) {
309 g_return_val_if_fail(cx, nullptr);
310 g_return_val_if_fail(surface_wrapper, nullptr);
311
312 JS::RootedObject proto(cx, CairoSurface::prototype(cx));
313
314 bool is_surface_subclass = false;
315 if (!gjs_object_in_prototype_chain(cx, proto, surface_wrapper,
316 &is_surface_subclass))
317 return nullptr;
318 if (!is_surface_subclass) {
319 gjs_throw(cx, "Expected Cairo.Surface but got %s",
320 JS::GetClass(surface_wrapper)->name);
321 return nullptr;
322 }
323
324 return JS::GetMaybePtrFromReservedSlot<cairo_surface_t>(
325 surface_wrapper, CairoSurface::POINTER);
326}
327
328GJS_JSAPI_RETURN_CONVENTION
329static bool surface_to_gi_argument(JSContext* cx, JS::Value value,

Callers

nothing calls this directly

Calls 2

gjs_throwFunction · 0.85

Tested by

no test coverage detected