This commit is contained in:
blueloveTH 2024-04-28 00:22:54 +08:00
parent aa8360cc22
commit dac441bea1
3 changed files with 28 additions and 6 deletions

View File

@ -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")

View File

@ -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);
});
}

View File

@ -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()