Remove public field from PyBuiltinFunction

This commit is contained in:
Jeong YunWon
2020-01-09 23:32:49 +09:00
parent 24289964d3
commit 5c87571863
2 changed files with 7 additions and 4 deletions

View File

@@ -6,8 +6,7 @@ use crate::pyobject::PyValue;
use crate::vm::VirtualMachine;
pub struct PyBuiltinFunction {
// TODO: shouldn't be public
pub value: PyNativeFunc,
value: PyNativeFunc,
}
impl PyValue for PyBuiltinFunction {
@@ -26,4 +25,8 @@ impl PyBuiltinFunction {
pub fn new(value: PyNativeFunc) -> Self {
Self { value }
}
pub fn as_func(&self) -> &PyNativeFunc {
&self.value
}
}

View File

@@ -673,8 +673,8 @@ impl VirtualMachine {
args
};
self.invoke(&function, args)
} else if let Some(PyBuiltinFunction { ref value }) = func_ref.payload() {
value(self, args)
} else if let Some(builtin_func) = func_ref.payload::<PyBuiltinFunction>() {
builtin_func.as_func()(self, args)
} else if self.is_callable(&func_ref) {
self.call_method(&func_ref, "__call__", args)
} else {