This commit is contained in:
blueloveTH 2023-04-19 12:25:23 +08:00
parent 08a8a2f252
commit c1b2e3e52b

View File

@ -230,10 +230,12 @@ public:
return call_method(self, callable, args...);
}
PyObject* property(NativeFuncC fget){
PyObject* property(NativeFuncC fget, NativeFuncC fset=nullptr){
PyObject* p = builtins->attr("property");
PyObject* method = heap.gcnew(tp_native_func, NativeFunc(fget, 1, false));
return call(p, method);
PyObject* _0 = heap.gcnew(tp_native_func, NativeFunc(fget, 1, false));
PyObject* _1 = vm->None;
if(fset != nullptr) _1 = heap.gcnew(tp_native_func, NativeFunc(fset, 2, false));
return call(p, _0, _1);
}
PyObject* new_type_object(PyObject* mod, StrName name, Type base){