BLUELOVETH 2023-06-20 19:24:37 +08:00 committed by GitHub
parent ae4057e457
commit 3148dab556
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,7 +40,12 @@ struct ManagedHeap{
template<typename T> template<typename T>
PyObject* gcnew(Type type, T&& val){ PyObject* gcnew(Type type, T&& val){
using __T = Py_<std::decay_t<T>>; using __T = Py_<std::decay_t<T>>;
#if _WIN32
// https://github.com/blueloveTH/pocketpy/issues/94#issuecomment-1594784476
PyObject* obj = new(pool64.alloc<__T>()) Py_<std::decay_t<T>>(type, std::forward<T>(val));
#else
PyObject* obj = new(pool64.alloc<__T>()) __T(type, std::forward<T>(val)); PyObject* obj = new(pool64.alloc<__T>()) __T(type, std::forward<T>(val));
#endif
gen.push_back(obj); gen.push_back(obj);
gc_counter++; gc_counter++;
return obj; return obj;
@ -49,7 +54,12 @@ struct ManagedHeap{
template<typename T> template<typename T>
PyObject* _new(Type type, T&& val){ PyObject* _new(Type type, T&& val){
using __T = Py_<std::decay_t<T>>; using __T = Py_<std::decay_t<T>>;
#if _WIN32
// https://github.com/blueloveTH/pocketpy/issues/94#issuecomment-1594784476
PyObject* obj = new(pool64.alloc<__T>()) Py_<std::decay_t<T>>(type, std::forward<T>(val));
#else
PyObject* obj = new(pool64.alloc<__T>()) __T(type, std::forward<T>(val)); PyObject* obj = new(pool64.alloc<__T>()) __T(type, std::forward<T>(val));
#endif
obj->gc.enabled = false; obj->gc.enabled = false;
_no_gc.push_back(obj); _no_gc.push_back(obj);
return obj; return obj;