| 361 | } |
| 362 | |
| 363 | GJS_JSAPI_RETURN_CONVENTION |
| 364 | static bool gjs_decode(JSContext* cx, unsigned argc, JS::Value* vp) { |
| 365 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
| 366 | |
| 367 | JS::RootedObject byte_array(cx); |
| 368 | JS::UniqueChars encoding; |
| 369 | bool fatal = false; |
| 370 | if (!gjs_parse_call_args(cx, "decode", args, "os|b", "byteArray", |
| 371 | &byte_array, "encoding", &encoding, "fatal", |
| 372 | &fatal)) |
| 373 | return false; |
| 374 | |
| 375 | JS::RootedString decoded( |
| 376 | cx, gjs_decode_from_uint8array(cx, byte_array, encoding.get(), |
| 377 | GjsStringTermination::EXPLICIT_LENGTH, |
| 378 | fatal)); |
| 379 | if (!decoded) |
| 380 | return false; |
| 381 | |
| 382 | args.rval().setString(decoded); |
| 383 | return true; |
| 384 | } |
| 385 | |
| 386 | // encode() function implementation |
| 387 | JSObject* gjs_encode_to_uint8array(JSContext* cx, JS::HandleString str, |
nothing calls this directly
no test coverage detected