From 1fe526bb66db8f469b16324384f2851124e75edc Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sat, 11 Jan 2020 00:21:50 +0900 Subject: [PATCH] hide member of classmethod --- vm/src/obj/objclassmethod.rs | 10 ++++++++-- vm/src/pyobject.rs | 4 +--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/vm/src/obj/objclassmethod.rs b/vm/src/obj/objclassmethod.rs index c3368da27c..c61b0965e7 100644 --- a/vm/src/obj/objclassmethod.rs +++ b/vm/src/obj/objclassmethod.rs @@ -29,10 +29,16 @@ use crate::vm::VirtualMachine; #[pyclass] #[derive(Clone, Debug)] pub struct PyClassMethod { - pub callable: PyObjectRef, + callable: PyObjectRef, } pub type PyClassMethodRef = PyRef; +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), diff --git a/vm/src/pyobject.rs b/vm/src/pyobject.rs index 3dbd96f708..9f38e43281 100644 --- a/vm/src/pyobject.rs +++ b/vm/src/pyobject.rs @@ -492,9 +492,7 @@ impl PyContext { F: IntoPyNativeFunc, { PyObject::new( - PyClassMethod { - callable: self.new_method(f), - }, + PyClassMethod::new(self.new_method(f)), self.classmethod_type(), None, )