blueloveTH 3 лет назад
Родитель
Сommit
55f92468c8
4 измененных файлов с 12 добавлено и 12 удалено
  1. 2 2
      src/main.cpp
  2. 1 1
      src/obj.h
  3. 8 8
      src/pocketpy.h
  4. 1 1
      src/vm.h

+ 2 - 2
src/main.cpp

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

+ 1 - 1
src/obj.h

@@ -65,7 +65,7 @@ public:
 };
 
 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);
 

+ 8 - 8
src/pocketpy.h

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

+ 1 - 1
src/vm.h

@@ -786,7 +786,7 @@ public:
     DEF_NATIVE(Tuple, PyVarList, _tp_tuple)
     DEF_NATIVE(Function, _Func, _tp_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(Range, _Range, _tp_range)
     DEF_NATIVE(Slice, _Slice, _tp_slice)