Returns all environment variables as an object
(state: &mut State<'gc>, _args: Vec<Value<'gc>>)
| 36 | |
| 37 | // Returns all environment variables as an object |
| 38 | fn env_vars<'gc>(state: &mut State<'gc>, _args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> { |
| 39 | let ctx = state.get_context(); |
| 40 | let mut env_vars = Object::default(); |
| 41 | |
| 42 | for (key, value) in std::env::vars() { |
| 43 | let key = ctx.intern(key.as_bytes()); |
| 44 | let value = Value::String(ctx.intern(value.as_bytes())); |
| 45 | env_vars.fields.insert(key, value); |
| 46 | } |
| 47 | |
| 48 | Ok(Value::Object(Gc::new(&ctx, RefLock::new(env_vars)))) |
| 49 | } |
| 50 | |
| 51 | // Gets the value of an environment variable |
| 52 | fn env_get<'gc>(state: &mut State<'gc>, args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> { |
nothing calls this directly
no test coverage detected