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

Function get_program_args

modules/system.cpp:265–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263 JS_FS_END};
264
265static bool get_program_args(JSContext* cx, unsigned argc, JS::Value* vp) {
266 static const size_t SLOT_ARGV = 0;
267
268 JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
269 GjsContextPrivate* priv = GjsContextPrivate::from_cx(cx);
270
271 JS::RootedValue v_argv(
272 cx, js::GetFunctionNativeReserved(&args.callee(), SLOT_ARGV));
273
274 if (v_argv.isUndefined()) {
275 // First time this property is accessed, build the array
276 JS::RootedObject argv(cx, priv->build_args_array());
277 if (!argv)
278 return false;
279 js::SetFunctionNativeReserved(&args.callee(), SLOT_ARGV,
280 JS::ObjectValue(*argv));
281 args.rval().setObject(*argv);
282 } else {
283 args.rval().set(v_argv);
284 }
285
286 return true;
287}
288
289bool gjs_js_define_system_stuff(JSContext* cx, JS::MutableHandleObject module) {
290 module.set(JS_NewPlainObject(cx));

Callers

nothing calls this directly

Calls 2

build_args_arrayMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected