This commit is contained in:
blueloveTH 2023-01-28 03:19:26 +08:00
parent b2a64c47b8
commit 30798f101c
3 changed files with 21 additions and 7 deletions

View File

@ -1,8 +1,11 @@
import os
import sys
def test_file(filepath):
if sys.platform == 'win32':
return os.system("pocketpy.exe " + filepath) == 0
else:
return os.system("./pocketpy " + filepath) == 0
#return os.system("python3 " + filepath) == 0
def test_dir(path):
has_error = False

View File

@ -128,6 +128,15 @@ namespace pkpy {
return ret;
}
ArgList move_extended_self(const PyVar& self){
static_assert(std::is_standard_layout_v<PyVar>);
pkpy::ArgList ret(size()+1);
ret[0] = self;
memcpy(ret._args+1, _args, sizeof(PyVar)*size());
memset(_args, 0, sizeof(PyVar)*size());
return ret;
}
~ArgList(){
__tryRelease();
}

View File

@ -449,12 +449,14 @@ public:
const PyVar* callable = &_callable;
if((*callable)->is_type(_tp_bounded_method)){
auto& bm = PyBoundedMethod_AS_C((*callable));
callable = &bm.method; // get unbound method
// TODO: avoid insertion here, bad performance
pkpy::ArgList new_args(args.size()+1);
new_args[0] = bm.obj;
for(int i=0; i<args.size(); i++) new_args[i+1] = args[i];
callable = &bm.method;
args = std::move(new_args);
// pkpy::ArgList new_args(args.size()+1);
// new_args[0] = bm.obj;
// for(int i=0; i<args.size(); i++) new_args[i+1] = args[i];
// args = std::move(new_args);
args = args.move_extended_self(bm.obj);
}
if((*callable)->is_type(_tp_native_function)){