blueloveTH 1 год назад
Родитель
Сommit
f1c969fe76

+ 1 - 0
include/pocketpy/interpreter/vm.h

@@ -126,6 +126,7 @@ py_Type pk_array_iterator__register();
 py_Type pk_slice__register();
 py_Type pk_function__register();
 py_Type pk_nativefunc__register();
+py_Type pk_boundmethod__register();
 py_Type pk_range__register();
 py_Type pk_range_iterator__register();
 py_Type pk_BaseException__register();

+ 1 - 1
src/interpreter/vm.c

@@ -108,7 +108,7 @@ void VM__ctor(VM* self) {
 
     validate(tp_function, pk_function__register());
     validate(tp_nativefunc, pk_nativefunc__register());
-    validate(tp_boundmethod, pk_newtype("boundmethod", tp_object, NULL, NULL, false, true));
+    validate(tp_boundmethod, pk_boundmethod__register());
 
     validate(tp_super, pk_super__register());
     validate(tp_BaseException, pk_BaseException__register());

+ 2 - 2
src/public/modules.c

@@ -613,7 +613,7 @@ static void function__gc_mark(void* ud) {
     CodeObject__gc_mark(&func->decl->code);
 }
 
-static bool function__doc__getter(int argc, py_Ref argv) {
+static bool function__doc__(int argc, py_Ref argv) {
     PY_CHECK_ARGC(1);
     Function* func = py_touserdata(py_arg(0));
     if(func->decl->docstring){
@@ -630,7 +630,7 @@ py_Type pk_function__register() {
 
     pk__tp_set_marker(type, function__gc_mark);
 
-    py_bindproperty(type, "__doc__", function__doc__getter, NULL);
+    py_bindproperty(type, "__doc__", function__doc__, NULL);
     return type;
 }
 

+ 8 - 9
src/public/py_method.c

@@ -13,9 +13,9 @@ static bool staticmethod__new__(int argc, py_Ref argv) {
     return true;
 }
 
-py_Type pk_staticmethod__register(){
+py_Type pk_staticmethod__register() {
     py_Type type = pk_newtype("staticmethod", tp_object, NULL, NULL, false, true);
-    
+
     py_bindmagic(type, __new__, staticmethod__new__);
     return type;
 }
@@ -28,7 +28,7 @@ static bool classmethod__new__(int argc, py_Ref argv) {
     return true;
 }
 
-py_Type pk_classmethod__register(){
+py_Type pk_classmethod__register() {
     py_Type type = pk_newtype("classmethod", tp_object, NULL, NULL, false, true);
 
     py_bindmagic(type, __new__, classmethod__new__);
@@ -36,22 +36,21 @@ py_Type pk_classmethod__register(){
 }
 
 /* boundmethod */
-static bool boundmethod__self__getter(int argc, py_Ref argv) {
+static bool boundmethod__self__(int argc, py_Ref argv) {
     PY_CHECK_ARGC(1);
     py_assign(py_retval(), py_getslot(argv, 0));
     return true;
 }
 
-static bool boundmethod__func__getter(int argc, py_Ref argv) {
+static bool boundmethod__func__(int argc, py_Ref argv) {
     PY_CHECK_ARGC(1);
     py_assign(py_retval(), py_getslot(argv, 1));
     return true;
 }
 
-py_Type pk_boundmethod__register(){
+py_Type pk_boundmethod__register() {
     py_Type type = pk_newtype("boundmethod", tp_object, NULL, NULL, false, true);
-
-    py_bindproperty(type, "__self__", boundmethod__self__getter, NULL);
-    py_bindproperty(type, "__func__", boundmethod__func__getter, NULL);
+    py_bindproperty(type, "__self__", boundmethod__self__, NULL);
+    py_bindproperty(type, "__func__", boundmethod__func__, NULL);
     return type;
 }

+ 8 - 8
src/public/py_object.c

@@ -44,7 +44,7 @@ static bool object__repr__(int argc, py_Ref argv) {
     return true;
 }
 
-static bool object__dict__getter(int argc, py_Ref argv) {
+static bool object__dict__(int argc, py_Ref argv) {
     PY_CHECK_ARGC(1);
     if(argv->is_ptr && argv->_obj->slots == -1) {
         pk_mappingproxy__namedict(py_retval(), argv);
@@ -70,7 +70,7 @@ static bool type__new__(int argc, py_Ref argv) {
     return true;
 }
 
-static bool type__base__getter(int argc, py_Ref argv) {
+static bool type__base__(int argc, py_Ref argv) {
     PY_CHECK_ARGC(1);
     py_Type type = py_totype(argv);
     py_TypeInfo* ti = c11__at(py_TypeInfo, &pk_current_vm->types, type);
@@ -82,7 +82,7 @@ static bool type__base__getter(int argc, py_Ref argv) {
     return true;
 }
 
-static bool type__name__getter(int argc, py_Ref argv) {
+static bool type__name__(int argc, py_Ref argv) {
     PY_CHECK_ARGC(1);
     py_Type type = py_totype(argv);
     py_TypeInfo* ti = c11__at(py_TypeInfo, &pk_current_vm->types, type);
@@ -95,7 +95,7 @@ static bool type__getitem__(int argc, py_Ref argv) {
     return true;
 }
 
-static bool type__module__getter(int argc, py_Ref argv) {
+static bool type__module__(int argc, py_Ref argv) {
     PY_CHECK_ARGC(1);
     py_Type type = py_totype(argv);
     py_TypeInfo* ti = c11__at(py_TypeInfo, &pk_current_vm->types, type);
@@ -116,13 +116,13 @@ void pk_object__register() {
     py_bindmagic(tp_object, __eq__, object__eq__);
     py_bindmagic(tp_object, __ne__, object__ne__);
     py_bindmagic(tp_object, __repr__, object__repr__);
-    py_bindproperty(tp_object, "__dict__", object__dict__getter, NULL);
+    py_bindproperty(tp_object, "__dict__", object__dict__, NULL);
 
     py_bindmagic(tp_type, __repr__, type__repr__);
     py_bindmagic(tp_type, __new__, type__new__);
     py_bindmagic(tp_type, __getitem__, type__getitem__);
-    py_bindproperty(tp_type, "__module__", type__module__getter, NULL);
+    py_bindproperty(tp_type, "__module__", type__module__, NULL);
 
-    py_bindproperty(tp_type, "__base__", type__base__getter, NULL);
-    py_bindproperty(tp_type, "__name__", type__name__getter, NULL);
+    py_bindproperty(tp_type, "__base__", type__base__, NULL);
+    py_bindproperty(tp_type, "__name__", type__name__, NULL);
 }

+ 4 - 4
src/public/py_property.c

@@ -25,14 +25,14 @@ static bool property_setter(int argc, py_Ref argv) {
     return true;
 }
 
-static bool property_fget__getter(int argc, py_Ref argv) {
+static bool property_fget(int argc, py_Ref argv) {
     PY_CHECK_ARGC(1);
     py_Ref fget = py_getslot(argv, 0);
     py_assign(py_retval(), fget);
     return true;
 }
 
-static bool property_fset__getter(int argc, py_Ref argv) {
+static bool property_fset(int argc, py_Ref argv) {
     PY_CHECK_ARGC(1);
     py_Ref fset = py_getslot(argv, 1);
     py_assign(py_retval(), fset);
@@ -45,7 +45,7 @@ py_Type pk_property__register() {
     py_bindmagic(type, __new__, property__new__);
     py_bindmethod(type, "setter", property_setter);
 
-    py_bindproperty(type, "fget", property_fget__getter, NULL);
-    py_bindproperty(type, "fset", property_fset__getter, NULL);
+    py_bindproperty(type, "fget", property_fget, NULL);
+    py_bindproperty(type, "fset", property_fset, NULL);
     return type;
 }

+ 6 - 6
src/public/py_slice.c

@@ -42,21 +42,21 @@ static bool slice__repr__(int argc, py_Ref argv) {
     return true;
 }
 
-static bool slice_start__getter(int argc, py_Ref argv) {
+static bool slice_start(int argc, py_Ref argv) {
     py_Ref self = py_arg(0);
     py_TValue* val = py_getslot(self, 0);
     py_assign(py_retval(), val);
     return true;
 }
 
-static bool slice_stop__getter(int argc, py_Ref argv) {
+static bool slice_stop(int argc, py_Ref argv) {
     py_Ref self = py_arg(0);
     py_TValue* val = py_getslot(self, 1);
     py_assign(py_retval(), val);
     return true;
 }
 
-static bool slice_step__getter(int argc, py_Ref argv) {
+static bool slice_step(int argc, py_Ref argv) {
     py_Ref self = py_arg(0);
     py_TValue* val = py_getslot(self, 2);
     py_assign(py_retval(), val);
@@ -69,8 +69,8 @@ py_Type pk_slice__register() {
     py_bindmagic(type, __new__, slice__new__);
     py_bindmagic(type, __repr__, slice__repr__);
 
-    py_bindproperty(type, "start", slice_start__getter, NULL);
-    py_bindproperty(type, "stop", slice_stop__getter, NULL);
-    py_bindproperty(type, "step", slice_step__getter, NULL);
+    py_bindproperty(type, "start", slice_start, NULL);
+    py_bindproperty(type, "stop", slice_stop, NULL);
+    py_bindproperty(type, "step", slice_step, NULL);
     return type;
 }