mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
...
This commit is contained in:
parent
651bf997fc
commit
3fbbd9fb67
File diff suppressed because one or more lines are too long
@ -46,9 +46,9 @@ static bool object__repr__(int argc, py_Ref argv) {
|
|||||||
|
|
||||||
static bool object__dict__getter(int argc, py_Ref argv) {
|
static bool object__dict__getter(int argc, py_Ref argv) {
|
||||||
PY_CHECK_ARGC(1);
|
PY_CHECK_ARGC(1);
|
||||||
if(argv->is_ptr && argv->_obj->slots == -1){
|
if(argv->is_ptr && argv->_obj->slots == -1) {
|
||||||
pk_mappingproxy__namedict(py_retval(), argv);
|
pk_mappingproxy__namedict(py_retval(), argv);
|
||||||
}else{
|
} else {
|
||||||
py_newnone(py_retval());
|
py_newnone(py_retval());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -74,9 +74,9 @@ static bool type__base__getter(int argc, py_Ref argv) {
|
|||||||
PY_CHECK_ARGC(1);
|
PY_CHECK_ARGC(1);
|
||||||
py_Type type = py_totype(argv);
|
py_Type type = py_totype(argv);
|
||||||
py_TypeInfo* ti = c11__at(py_TypeInfo, &pk_current_vm->types, type);
|
py_TypeInfo* ti = c11__at(py_TypeInfo, &pk_current_vm->types, type);
|
||||||
if(ti->base){
|
if(ti->base) {
|
||||||
py_assign(py_retval(), py_tpobject(ti->base));
|
py_assign(py_retval(), py_tpobject(ti->base));
|
||||||
}else{
|
} else {
|
||||||
py_newnone(py_retval());
|
py_newnone(py_retval());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -90,6 +90,11 @@ static bool type__name__getter(int argc, py_Ref argv) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool type__getitem__(int argc, py_Ref argv) {
|
||||||
|
py_assign(py_retval(), argv);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void pk_object__register() {
|
void pk_object__register() {
|
||||||
// TODO: use staticmethod
|
// TODO: use staticmethod
|
||||||
py_bindmagic(tp_object, __new__, object__new__);
|
py_bindmagic(tp_object, __new__, object__new__);
|
||||||
@ -102,6 +107,7 @@ void pk_object__register() {
|
|||||||
|
|
||||||
py_bindmagic(tp_type, __repr__, type__repr__);
|
py_bindmagic(tp_type, __repr__, type__repr__);
|
||||||
py_bindmagic(tp_type, __new__, type__new__);
|
py_bindmagic(tp_type, __new__, type__new__);
|
||||||
|
py_bindmagic(tp_type, __getitem__, type__getitem__);
|
||||||
|
|
||||||
py_bindproperty(tp_type, "__base__", type__base__getter, NULL);
|
py_bindproperty(tp_type, "__base__", type__base__getter, NULL);
|
||||||
py_bindproperty(tp_type, "__name__", type__name__getter, NULL);
|
py_bindproperty(tp_type, "__name__", type__name__getter, NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user