MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / create_env_module

Function create_env_module

aiscript-vm/src/stdlib/env.rs:10–24  ·  view source on GitHub ↗
(ctx: Context)

Source from the content-addressed store, hash-verified

8};
9
10pub fn create_env_module(ctx: Context) -> ModuleKind {
11 let name = ctx.intern(b"std.env");
12
13 let exports = [
14 ("args", Value::NativeFunction(NativeFn(env_args))),
15 ("vars", Value::NativeFunction(NativeFn(env_vars))),
16 ("get_env", Value::NativeFunction(NativeFn(env_get))),
17 ("set_env", Value::NativeFunction(NativeFn(env_set))),
18 ]
19 .into_iter()
20 .map(|(name, f)| (ctx.intern_static(name), f))
21 .collect();
22
23 ModuleKind::Native { name, exports }
24}
25
26// Returns command-line arguments as an array of strings
27fn env_args<'gc>(state: &mut State<'gc>, _args: Vec<Value<'gc>>) -> Result<Value<'gc>, VmError> {

Callers 1

init_stdlibMethod · 0.85

Calls 3

NativeFnClass · 0.85
internMethod · 0.45
intern_staticMethod · 0.45

Tested by

no test coverage detected