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

Function gjs_decode

gjs/text-encoding.cpp:363–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361}
362
363GJS_JSAPI_RETURN_CONVENTION
364static 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
387JSObject* gjs_encode_to_uint8array(JSContext* cx, JS::HandleString str,

Callers

nothing calls this directly

Calls 3

gjs_parse_call_argsFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected