mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
some fix
This commit is contained in:
parent
620c1d2882
commit
37c28e0061
5
docs/1_5_0.md
Normal file
5
docs/1_5_0.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
icon: log
|
||||
title: 'Upgrade to v1.5.0'
|
||||
order: 25
|
||||
---
|
@ -551,13 +551,14 @@ PyObject* VM::register_user_class(PyObject* mod, StrName name, RegisterFunc _reg
|
||||
mod->attr().set(name, type);
|
||||
_cxx_typeid_map[typeid(T)] = PK_OBJ_GET(Type, type);
|
||||
_register(this, mod, type);
|
||||
// check if T is trivially constructible
|
||||
if constexpr(!std::is_default_constructible_v<T>){
|
||||
if(!type->attr().contains(__new__)){
|
||||
if constexpr(std::is_default_constructible_v<T>) {
|
||||
bind_func(type, __new__, -1, [](VM* vm, ArgsView args){
|
||||
vm->NotImplementedError();
|
||||
return vm->None;
|
||||
Type cls_t = PK_OBJ_GET(Type, args[0]);
|
||||
return vm->heap.gcnew<T>(cls_t);
|
||||
});
|
||||
}else{
|
||||
bind_func(type, __new__, -1, PK_ACTION(vm->NotImplementedError()));
|
||||
}
|
||||
}
|
||||
return type;
|
||||
|
@ -27,7 +27,7 @@ PyObject* PyArrayGetItem(VM* vm, PyObject* _0, PyObject* _1){
|
||||
PK_UNREACHABLE()
|
||||
}
|
||||
|
||||
void init_builtins(VM* _vm) {
|
||||
void __init_builtins(VM* _vm) {
|
||||
#define BIND_NUM_ARITH_OPT(name, op) \
|
||||
_vm->bind##name(VM::tp_int, [](VM* vm, PyObject* lhs, PyObject* rhs) { \
|
||||
i64 val; \
|
||||
@ -1511,12 +1511,9 @@ void init_builtins(VM* _vm) {
|
||||
}
|
||||
|
||||
void VM::__post_init_builtin_types(){
|
||||
init_builtins(this);
|
||||
__init_builtins(this);
|
||||
|
||||
bind_func(tp_module, __init__, -1, [](VM* vm, ArgsView args) {
|
||||
vm->NotImplementedError();
|
||||
return vm->None;
|
||||
});
|
||||
bind_func(tp_module, __new__, -1, PK_ACTION(vm->NotImplementedError()));
|
||||
|
||||
_all_types[tp_module].m__getattr__ = [](VM* vm, PyObject* obj, StrName name) -> PyObject*{
|
||||
const Str& path = CAST(Str&, obj->attr(__path__));
|
||||
|
Loading…
x
Reference in New Issue
Block a user