From df20a26253aa5cd2bbad19e2edfb3baf33f38b00 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sun, 9 Aug 2020 23:42:04 +0900 Subject: [PATCH] vm.new_pyobj --- vm/src/vm.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vm/src/vm.rs b/vm/src/vm.rs index 2f9efc7dd..90e92c3b2 100644 --- a/vm/src/vm.rs +++ b/vm/src/vm.rs @@ -40,8 +40,8 @@ use crate::obj::objstr::{PyString, PyStringRef}; use crate::obj::objtuple::PyTuple; use crate::obj::objtype::{self, PyClassRef}; use crate::pyobject::{ - BorrowValue, IdProtocol, ItemProtocol, PyContext, PyObject, PyObjectRef, PyRef, PyResult, - PyValue, TryFromObject, TryIntoRef, TypeProtocol, + BorrowValue, IdProtocol, IntoPyObject, ItemProtocol, PyContext, PyObject, PyObjectRef, PyRef, + PyResult, PyValue, TryFromObject, TryIntoRef, TypeProtocol, }; use crate::scope::Scope; use crate::stdlib; @@ -379,6 +379,11 @@ impl VirtualMachine { class.downcast().expect("not a class") } + /// Create a new python object + pub fn new_pyobj(&self, value: T) -> PyObjectRef { + value.into_pyobject(self) + } + /// Create a new python string object. pub fn new_str(&self, s: String) -> PyObjectRef { self.ctx.new_str(s)