| 60 | } |
| 61 | |
| 62 | GJS_JSAPI_RETURN_CONVENTION static bool path_to_gi_argument( |
| 63 | JSContext* cx, JS::Value value, const char* arg_name, |
| 64 | GjsArgumentType argument_type, GITransfer transfer, GjsArgumentFlags flags, |
| 65 | GIArgument* arg) { |
| 66 | if (value.isNull()) { |
| 67 | if (!(flags & GjsArgumentFlags::MAY_BE_NULL)) { |
| 68 | Gjs::AutoChar display_name{ |
| 69 | gjs_argument_display_name(arg_name, argument_type)}; |
| 70 | gjs_throw(cx, "%s may not be null", display_name.get()); |
| 71 | return false; |
| 72 | } |
| 73 | |
| 74 | gjs_arg_unset(arg); |
| 75 | return true; |
| 76 | } |
| 77 | |
| 78 | if (!value.isObject()) { |
| 79 | Gjs::AutoChar display_name{ |
| 80 | gjs_argument_display_name(arg_name, argument_type)}; |
| 81 | gjs_throw(cx, "%s is not a Cairo.Path", display_name.get()); |
| 82 | return false; |
| 83 | } |
| 84 | |
| 85 | JS::RootedObject path_wrapper{cx, &value.toObject()}; |
| 86 | cairo_path_t* s = CairoPath::for_js(cx, path_wrapper); |
| 87 | if (!s) |
| 88 | return false; |
| 89 | if (transfer == GI_TRANSFER_EVERYTHING) |
| 90 | s = CairoPath::copy_ptr(s); |
| 91 | |
| 92 | gjs_arg_set(arg, s); |
| 93 | return true; |
| 94 | } |
| 95 | |
| 96 | GJS_JSAPI_RETURN_CONVENTION |
| 97 | static bool path_from_gi_argument(JSContext* cx, JS::MutableHandleValue value_p, |
nothing calls this directly
no test coverage detected