From dac441bea1657081605834f10935315d45465f04 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 28 Apr 2024 00:22:54 +0800 Subject: [PATCH] some fix --- cmake_build.py | 10 ++++++---- src/array2d.cpp | 4 ++-- tests/83_array2d.py | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/cmake_build.py b/cmake_build.py index 8cb2b375..2653b8ea 100644 --- a/cmake_build.py +++ b/cmake_build.py @@ -7,16 +7,18 @@ assert os.system("python prebuild.py") == 0 if not os.path.exists("build"): os.mkdir("build") +config = 'Release' + os.chdir("build") -code = os.system("cmake .. -DPK_USE_CJSON=ON -DPK_ENABLE_OS=ON -DCMAKE_BUILD_TYPE=Release") +code = os.system(f"cmake .. -DPK_USE_CJSON=ON -DPK_ENABLE_OS=ON -DCMAKE_BUILD_TYPE={config}") assert code == 0 -code = os.system("cmake --build . --config Release") +code = os.system(f"cmake --build . --config {config}") assert code == 0 if sys.platform == "win32": - shutil.copy("Release/main.exe", "../main.exe") - shutil.copy("Release/pocketpy.dll", "../pocketpy.dll") + shutil.copy(f"{config}/main.exe", "../main.exe") + shutil.copy(f"{config}/pocketpy.dll", "../pocketpy.dll") elif sys.platform == "darwin": shutil.copy("main", "../main") shutil.copy("libpocketpy.dylib", "../libpocketpy.dylib") diff --git a/src/array2d.cpp b/src/array2d.cpp index a613ac1e..fb931e1d 100644 --- a/src/array2d.cpp +++ b/src/array2d.cpp @@ -385,8 +385,8 @@ void add_module_array2d(VM* vm){ Array2d::register_class(vm, mod); Array2dIter::register_class(vm, mod); - vm->bind__iter__(Array2d::_type(vm), [](VM* vm, PyObject* obj){ - return VAR_T(Array2dIter, obj); + vm->bind__iter__(Array2d::_type(vm), [](VM* vm, PyObject* _0){ + return VAR_T(Array2dIter, _0); }); } diff --git a/tests/83_array2d.py b/tests/83_array2d.py index 577da838..e1cdb214 100644 --- a/tests/83_array2d.py +++ b/tests/83_array2d.py @@ -177,3 +177,23 @@ for i, j, x in a: assert a[i, j] == x assert len(a) == a.numel + +# stackoverflow bug due to recursive mark-and-sweep +# class Cell: +# neighbors: list['Cell'] + +# cells: array2d[Cell] = array2d(192, 108, default=Cell) +# OutOfBounds = Cell() +# for x, y, cell in cells: +# cell.neighbors = [ +# cells.get(x-1, y-1, OutOfBounds), +# cells.get(x , y-1, OutOfBounds), +# cells.get(x+1, y-1, OutOfBounds), +# cells.get(x-1, y , OutOfBounds), +# cells.get(x+1, y , OutOfBounds), +# cells.get(x , y+1, OutOfBounds), +# cells.get(x+1, y+1, OutOfBounds), +# ] + +# import gc +# gc.collect() \ No newline at end of file