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

Function gjs_build_string_array

gjs/jsapi-util.cpp:198–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198JSObject* gjs_build_string_array(JSContext* cx,
199 const std::vector<std::string>& strings) {
200 JS::RootedValueVector elems{cx};
201 if (!elems.reserve(strings.size())) {
202 JS_ReportOutOfMemory(cx);
203 return nullptr;
204 }
205
206 for (const std::string& string : strings) {
207 JS::ConstUTF8CharsZ chars(string.c_str(), string.size());
208 JS::RootedValue element{
209 cx, JS::StringValue(JS_NewStringCopyUTF8Z(cx, chars))};
210 elems.infallibleAppend(element);
211 }
212
213 return JS::NewArrayObject(cx, elems);
214}
215
216JSObject* gjs_define_string_array(JSContext* cx, JS::HandleObject in_object,
217 const char* array_name,

Callers 2

build_args_arrayMethod · 0.85
gjs_define_string_arrayFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected