* gjs_get_string_id: * @cx: a #JSContext * @id: a jsid that is an object hash key (could be an int or string) * @name_p place to store ASCII string version of key * * If the id is not a string ID, return true and set *name_p to nullptr. * Otherwise, return true and fill in *name_p with ASCII name of id. * * Returns: false on error, otherwise true */
| 411 | * Returns: false on error, otherwise true |
| 412 | */ |
| 413 | bool gjs_get_string_id(JSContext* cx, jsid id, JS::UniqueChars* name_p) { |
| 414 | if (!id.isString()) { |
| 415 | name_p->reset(); |
| 416 | return true; |
| 417 | } |
| 418 | |
| 419 | JSLinearString* lstr = id.toLinearString(); |
| 420 | JS::RootedString s(cx, JS_FORGET_STRING_LINEARNESS(lstr)); |
| 421 | *name_p = JS_EncodeStringToUTF8(cx, s); |
| 422 | return !!*name_p; |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * gjs_unichar_from_string: |
no test coverage detected