mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Add builtinfunc.__call__
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::function::{Args, KwArgs};
|
||||
use crate::function::PyFuncArgs;
|
||||
use crate::obj::objcode::PyCodeRef;
|
||||
use crate::obj::objdict::PyDictRef;
|
||||
use crate::obj::objtuple::PyTupleRef;
|
||||
@@ -44,8 +44,8 @@ impl PyValue for PyFunction {
|
||||
}
|
||||
|
||||
impl PyFunctionRef {
|
||||
fn call(self, args: Args, kwargs: KwArgs, vm: &VirtualMachine) -> PyResult {
|
||||
vm.invoke(&self.into_object(), (&args, &kwargs))
|
||||
fn call(func: PyObjectRef, args: PyFuncArgs, vm: &VirtualMachine) -> PyResult {
|
||||
vm.invoke(&func, args)
|
||||
}
|
||||
|
||||
fn code(self, _vm: &VirtualMachine) -> PyCodeRef {
|
||||
@@ -92,7 +92,8 @@ pub fn init(context: &PyContext) {
|
||||
|
||||
let builtin_function_or_method_type = &context.types.builtin_function_or_method_type;
|
||||
extend_class!(context, builtin_function_or_method_type, {
|
||||
"__get__" => context.new_rustfunc(bind_method)
|
||||
"__get__" => context.new_rustfunc(bind_method),
|
||||
"__call__" => context.new_rustfunc(PyFunctionRef::call),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user