* CairoSurface::for_js: * @cx: the context * @surface_wrapper: surface wrapper * * Overrides NativeObject::for_js(). * * Returns: the surface attached to the wrapper. */
| 305 | * Returns: the surface attached to the wrapper. |
| 306 | */ |
| 307 | cairo_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 | |
| 328 | GJS_JSAPI_RETURN_CONVENTION |
| 329 | static bool surface_to_gi_argument(JSContext* cx, JS::Value value, |
nothing calls this directly
no test coverage detected