| 214 | } |
| 215 | |
| 216 | JSObject* gjs_define_string_array(JSContext* cx, JS::HandleObject in_object, |
| 217 | const char* array_name, |
| 218 | const std::vector<std::string>& strings, |
| 219 | unsigned attrs) { |
| 220 | JS::RootedObject array{cx, gjs_build_string_array(cx, strings)}; |
| 221 | if (!array) |
| 222 | return nullptr; |
| 223 | |
| 224 | if (!JS_DefineProperty(cx, in_object, array_name, array, attrs)) |
| 225 | return nullptr; |
| 226 | |
| 227 | return array; |
| 228 | } |
| 229 | |
| 230 | // Helper function: perform ToString on an exception (which may not even be an |
| 231 | // object), except if it is an InternalError, which would throw in ToString. |
no test coverage detected