hide member of classmethod

This commit is contained in:
Jeong YunWon
2020-01-11 00:21:50 +09:00
parent d31d0c6510
commit 1fe526bb66
2 changed files with 9 additions and 5 deletions

View File

@@ -29,10 +29,16 @@ use crate::vm::VirtualMachine;
#[pyclass]
#[derive(Clone, Debug)]
pub struct PyClassMethod {
pub callable: PyObjectRef,
callable: PyObjectRef,
}
pub type PyClassMethodRef = PyRef<PyClassMethod>;
impl PyClassMethod {
pub fn new(value: PyObjectRef) -> Self {
Self { callable: value }
}
}
impl PyValue for PyClassMethod {
const HAVE_DICT: bool = true;
@@ -73,7 +79,7 @@ impl PyClassMethod {
}
}
pub fn init(context: &PyContext) {
pub(crate) fn init(context: &PyContext) {
PyClassMethod::extend_class(context, &context.types.classmethod_type);
extend_class!(context, context.types.classmethod_type, {
"__get__" => context.new_method(PyClassMethod::get),

View File

@@ -492,9 +492,7 @@ impl PyContext {
F: IntoPyNativeFunc<T, R, VM>,
{
PyObject::new(
PyClassMethod {
callable: self.new_method(f),
},
PyClassMethod::new(self.new_method(f)),
self.classmethod_type(),
None,
)