MCPcopy Index your code
hub / github.com/RustPython/RustPython / call

Method call

crates/wasm/src/js_module.rs:175–191  ·  view source on GitHub ↗
(
            &self,
            args: PosArgs<PyJsValueRef>,
            opts: CallOptions,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

173
174 #[pymethod]
175 fn call(
176 &self,
177 args: PosArgs<PyJsValueRef>,
178 opts: CallOptions,
179 vm: &VirtualMachine,
180 ) -> PyResult<PyJsValue> {
181 let func = self
182 .value
183 .dyn_ref::<js_sys::Function>()
184 .ok_or_else(|| vm.new_type_error("JS value is not callable"))?;
185 let js_args = args.iter().map(|x| -> &PyJsValue { x }).collect::<Array>();
186 let res = match opts.this {
187 Some(this) => Reflect::apply(func, &this.value, &js_args),
188 None => call_func(func, &js_args),
189 };
190 res.map(PyJsValue::new).map_err(|err| new_js_error(vm, err))
191 }
192
193 #[pymethod]
194 fn call_method(

Callers 8

timeoutFunction · 0.45
alertFunction · 0.45
confirmFunction · 0.45
promptFunction · 0.45
newMethod · 0.45
as_jsMethod · 0.45
thenMethod · 0.45
py_to_jsFunction · 0.45

Calls 5

call_funcFunction · 0.85
new_js_errorFunction · 0.85
ok_or_elseMethod · 0.80
mapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected