| 154 | } |
| 155 | |
| 156 | GJS_JSAPI_RETURN_CONVENTION |
| 157 | static bool pattern_to_gi_argument(JSContext* cx, JS::Value value, |
| 158 | const char* arg_name, |
| 159 | GjsArgumentType argument_type, |
| 160 | GITransfer transfer, GjsArgumentFlags flags, |
| 161 | GIArgument* arg) { |
| 162 | if (value.isNull()) { |
| 163 | if (!(flags & GjsArgumentFlags::MAY_BE_NULL)) { |
| 164 | Gjs::AutoChar display_name{ |
| 165 | gjs_argument_display_name(arg_name, argument_type)}; |
| 166 | gjs_throw(cx, "%s may not be null", display_name.get()); |
| 167 | return false; |
| 168 | } |
| 169 | |
| 170 | gjs_arg_unset(arg); |
| 171 | return true; |
| 172 | } |
| 173 | |
| 174 | if (!value.isObject()) { |
| 175 | Gjs::AutoChar display_name{ |
| 176 | gjs_argument_display_name(arg_name, argument_type)}; |
| 177 | gjs_throw(cx, "%s is not a Cairo.Pattern", display_name.get()); |
| 178 | return false; |
| 179 | } |
| 180 | |
| 181 | JS::RootedObject pattern_wrapper{cx, &value.toObject()}; |
| 182 | cairo_pattern_t* s = CairoPattern::for_js(cx, pattern_wrapper); |
| 183 | if (!s) |
| 184 | return false; |
| 185 | if (transfer == GI_TRANSFER_EVERYTHING) |
| 186 | cairo_pattern_reference(s); |
| 187 | |
| 188 | gjs_arg_set(arg, s); |
| 189 | return true; |
| 190 | } |
| 191 | |
| 192 | GJS_JSAPI_RETURN_CONVENTION |
| 193 | static bool pattern_from_gi_argument(JSContext* cx, |
nothing calls this directly
no test coverage detected