This commit is contained in:
blueloveTH 2024-05-04 16:53:36 +08:00
parent dd734f71dc
commit 634ad16d45
2 changed files with 2 additions and 0 deletions

View File

@ -89,6 +89,7 @@ PyObject* VM::bind(PyObject* obj, const char* sig, const char* docstring, Ret(T:
template<typename T, typename F, bool ReadOnly>
PyObject* VM::bind_field(PyObject* obj, const char* name, F T::*field){
static_assert(!std::is_reference_v<F>);
PK_ASSERT(is_type(obj, tp_type));
std::string_view name_sv(name); int pos = name_sv.find(':');
if(pos > 0) name_sv = name_sv.substr(0, pos);
auto fget = [](VM* vm, ArgsView args) -> PyObject*{

View File

@ -1269,6 +1269,7 @@ PyObject* VM::bind(PyObject* obj, const char* sig, const char* docstring, Native
}
PyObject* VM::bind_property(PyObject* obj, const char* name, NativeFuncC fget, NativeFuncC fset){
PK_ASSERT(is_type(obj, tp_type));
std::string_view name_sv(name); int pos = name_sv.find(':');
if(pos > 0) name_sv = name_sv.substr(0, pos);
PyObject* _0 = heap.gcnew<NativeFunc>(tp_native_func, fget, 1, false);