remove std::shared_ptr

This commit is contained in:
blueloveTH 2022-12-05 02:49:54 +08:00
parent 3f5842092f
commit 55f92468c8
4 changed files with 12 additions and 12 deletions

View File

@ -2,8 +2,8 @@
#include "pocketpy.h" #include "pocketpy.h"
#define PK_DEBUG_TIME //#define PK_DEBUG_TIME
//#define PK_DEBUG_THREADED #define PK_DEBUG_THREADED
struct Timer{ struct Timer{
const char* title; const char* title;

View File

@ -65,7 +65,7 @@ public:
}; };
typedef pkpy::shared_ptr<Function> _Func; typedef pkpy::shared_ptr<Function> _Func;
typedef std::variant<PyVar,_Int,_Float,bool,_Str,PyVarList,_CppFunc,_Func,std::shared_ptr<_Iterator>,_BoundedMethod,_Range,_Slice,_Pointer> _Value; typedef std::variant<PyVar,_Int,_Float,bool,_Str,PyVarList,_CppFunc,_Func,pkpy::shared_ptr<_Iterator>,_BoundedMethod,_Range,_Slice,_Pointer> _Value;
const int _SIZEOF_VALUE = sizeof(_Value); const int _SIZEOF_VALUE = sizeof(_Value);

View File

@ -148,8 +148,8 @@ void __initializeBuiltinFunctions(VM* _vm) {
_vm->bindMethod("range", "__iter__", [](VM* vm, const pkpy::ArgList& args) { _vm->bindMethod("range", "__iter__", [](VM* vm, const pkpy::ArgList& args) {
vm->__checkType(args[0], vm->_tp_range); vm->__checkType(args[0], vm->_tp_range);
auto iter = std::make_shared<RangeIterator>(vm, args[0]); _Iterator* iter = new RangeIterator(vm, args[0]);
return vm->PyIter(iter); return vm->PyIter(pkpy::shared_ptr<_Iterator>(iter));
}); });
_vm->bindMethod("NoneType", "__repr__", [](VM* vm, const pkpy::ArgList& args) { _vm->bindMethod("NoneType", "__repr__", [](VM* vm, const pkpy::ArgList& args) {
@ -313,8 +313,8 @@ void __initializeBuiltinFunctions(VM* _vm) {
}); });
_vm->bindMethod("str", "__iter__", [](VM* vm, const pkpy::ArgList& args) { _vm->bindMethod("str", "__iter__", [](VM* vm, const pkpy::ArgList& args) {
auto it = std::make_shared<StringIterator>(vm, args[0]); _Iterator* iter = new StringIterator(vm, args[0]);
return vm->PyIter(it); return vm->PyIter(pkpy::shared_ptr<_Iterator>(iter));
}); });
_vm->bindMethod("str", "__repr__", [](VM* vm, const pkpy::ArgList& args) { _vm->bindMethod("str", "__repr__", [](VM* vm, const pkpy::ArgList& args) {
@ -426,8 +426,8 @@ void __initializeBuiltinFunctions(VM* _vm) {
/************ PyList ************/ /************ PyList ************/
_vm->bindMethod("list", "__iter__", [](VM* vm, const pkpy::ArgList& args) { _vm->bindMethod("list", "__iter__", [](VM* vm, const pkpy::ArgList& args) {
vm->__checkType(args[0], vm->_tp_list); vm->__checkType(args[0], vm->_tp_list);
auto iter = std::make_shared<VectorIterator>(vm, args[0]); _Iterator* iter = new VectorIterator(vm, args[0]);
return vm->PyIter(iter); return vm->PyIter(pkpy::shared_ptr<_Iterator>(iter));
}); });
_vm->bindMethod("list", "append", [](VM* vm, const pkpy::ArgList& args) { _vm->bindMethod("list", "append", [](VM* vm, const pkpy::ArgList& args) {
@ -523,8 +523,8 @@ void __initializeBuiltinFunctions(VM* _vm) {
_vm->bindMethod("tuple", "__iter__", [](VM* vm, const pkpy::ArgList& args) { _vm->bindMethod("tuple", "__iter__", [](VM* vm, const pkpy::ArgList& args) {
vm->__checkType(args[0], vm->_tp_tuple); vm->__checkType(args[0], vm->_tp_tuple);
auto iter = std::make_shared<VectorIterator>(vm, args[0]); _Iterator* iter = new VectorIterator(vm, args[0]);
return vm->PyIter(iter); return vm->PyIter(pkpy::shared_ptr<_Iterator>(iter));
}); });
_vm->bindMethod("tuple", "__len__", [](VM* vm, const pkpy::ArgList& args) { _vm->bindMethod("tuple", "__len__", [](VM* vm, const pkpy::ArgList& args) {

View File

@ -786,7 +786,7 @@ public:
DEF_NATIVE(Tuple, PyVarList, _tp_tuple) DEF_NATIVE(Tuple, PyVarList, _tp_tuple)
DEF_NATIVE(Function, _Func, _tp_function) DEF_NATIVE(Function, _Func, _tp_function)
DEF_NATIVE(NativeFunction, _CppFunc, _tp_native_function) DEF_NATIVE(NativeFunction, _CppFunc, _tp_native_function)
DEF_NATIVE(Iter, std::shared_ptr<_Iterator>, _tp_native_iterator) DEF_NATIVE(Iter, pkpy::shared_ptr<_Iterator>, _tp_native_iterator)
DEF_NATIVE(BoundedMethod, _BoundedMethod, _tp_bounded_method) DEF_NATIVE(BoundedMethod, _BoundedMethod, _tp_bounded_method)
DEF_NATIVE(Range, _Range, _tp_range) DEF_NATIVE(Range, _Range, _tp_range)
DEF_NATIVE(Slice, _Slice, _tp_slice) DEF_NATIVE(Slice, _Slice, _tp_slice)