diff --git a/include/pocketpy/gc.h b/include/pocketpy/gc.h index 13ac14ce..2f5d4eee 100644 --- a/include/pocketpy/gc.h +++ b/include/pocketpy/gc.h @@ -41,7 +41,7 @@ struct ManagedHeap{ template PyVar gcnew(Type type, Args&&... args){ using __T = Py_>; - static_assert(!is_sso_v<__T>, "gcnew cannot be used with SSO types"); + static_assert(!is_sso_v>, "gcnew cannot be used with SSO types"); // https://github.com/pocketpy/pocketpy/issues/94#issuecomment-1594784476 PyObject* p = new(pool128_alloc<__T>()) Py_>(std::forward(args)...); PyVar obj(type, p); @@ -53,7 +53,7 @@ struct ManagedHeap{ template PyVar _new(Type type, Args&&... args){ using __T = Py_>; - static_assert(!is_sso_v<__T>); + static_assert(!is_sso_v>); PyObject* p = new(pool128_alloc<__T>()) Py_>(std::forward(args)...); PyVar obj(type, p); obj->gc_enabled = false; diff --git a/include/pocketpy/obj.h b/include/pocketpy/obj.h index 394630ea..7a67a712 100644 --- a/include/pocketpy/obj.h +++ b/include/pocketpy/obj.h @@ -166,7 +166,7 @@ template T to_void_p(VM*, PyVar); PyVar from_void_p(VM*, void*); -#define PK_OBJ_GET(T, obj) (obj.is_sso ? obj.as() : (((Py_*)(obj.get()))->_value)) +#define PK_OBJ_GET(T, obj) (is_sso_v ? obj.as() : (((Py_*)(obj.get()))->_value)) #define PK_OBJ_MARK(obj) \ if(!is_tagged(obj) && !(obj)->gc_marked) { \ diff --git a/include/pocketpy/vm.h b/include/pocketpy/vm.h index 93940f91..0f204cb5 100644 --- a/include/pocketpy/vm.h +++ b/include/pocketpy/vm.h @@ -582,7 +582,7 @@ PyVar VM::register_user_class(PyVar mod, StrName name, RegisterFunc _register, T if constexpr(std::is_default_constructible_v) { bind_func(type, __new__, -1, [](VM* vm, ArgsView args){ Type cls_t = PK_OBJ_GET(Type, args[0]); - return vm->heap.gcnew(cls_t); + return vm->new_object(cls_t); }); }else{ bind_func(type, __new__, -1, PK_ACTION(vm->NotImplementedError())); diff --git a/tests/80_linalg.py b/tests/80_linalg.py index 7cc7f188..5076039a 100644 --- a/tests/80_linalg.py +++ b/tests/80_linalg.py @@ -3,6 +3,10 @@ import random import sys import math +a = vec2(1, 2) +assert a.x == 1 +assert a.y == 2 + assert repr(math) == "" # 出于对精度转换的考虑,在本测试中具体将采用str(floating_num)[:6]来比较两个浮点数是否相等