From 7ca97f03a7a0afb761262b8a0fcca09aca6a9f89 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 5 Aug 2024 22:36:26 +0800 Subject: [PATCH] ... --- include/pocketpy/pocketpy.h | 38 ++++++++++++++++----------------- src/compiler/compiler.c | 2 +- src/interpreter/ceval.c | 16 +++++++------- src/interpreter/vm.c | 8 +++---- src/modules/math.c | 8 +++---- src/objects/codeobject.c | 4 ++-- src/public/modules.c | 8 +++---- src/public/py_array.c | 6 +++--- src/public/py_dict.c | 30 +++++++++++++------------- src/public/py_list.c | 42 ++++++++++++++++++------------------- src/public/py_str.c | 10 ++++----- src/public/py_tuple.c | 32 ++++++++++++++-------------- 12 files changed, 102 insertions(+), 102 deletions(-) diff --git a/include/pocketpy/pocketpy.h b/include/pocketpy/pocketpy.h index 31af9558..e8024b19 100644 --- a/include/pocketpy/pocketpy.h +++ b/include/pocketpy/pocketpy.h @@ -430,27 +430,27 @@ bool py_len(py_Ref val) PY_RAISE; /************* Unchecked Functions *************/ -py_ObjectRef py_tuple__data(py_Ref self); -py_ObjectRef py_tuple__getitem(py_Ref self, int i); -void py_tuple__setitem(py_Ref self, int i, py_Ref val); -int py_tuple__len(py_Ref self); +py_ObjectRef py_tuple_data(py_Ref self); +py_ObjectRef py_tuple_getitem(py_Ref self, int i); +void py_tuple_setitem(py_Ref self, int i, py_Ref val); +int py_tuple_len(py_Ref self); -py_TmpRef py_list__data(py_Ref self); -py_TmpRef py_list__getitem(py_Ref self, int i); -void py_list__setitem(py_Ref self, int i, py_Ref val); -void py_list__delitem(py_Ref self, int i); -int py_list__len(py_Ref self); -void py_list__append(py_Ref self, py_Ref val); -void py_list__clear(py_Ref self); -void py_list__insert(py_Ref self, int i, py_Ref val); -void py_list__reverse(py_Ref self); +py_TmpRef py_list_data(py_Ref self); +py_TmpRef py_list_getitem(py_Ref self, int i); +void py_list_setitem(py_Ref self, int i, py_Ref val); +void py_list_delitem(py_Ref self, int i); +int py_list_len(py_Ref self); +void py_list_append(py_Ref self, py_Ref val); +void py_list_clear(py_Ref self); +void py_list_insert(py_Ref self, int i, py_Ref val); +void py_list_reverse(py_Ref self); -py_TmpRef py_dict__getitem(py_Ref self, py_Ref key) PY_RAISE; -void py_dict__setitem(py_Ref self, py_Ref key, py_Ref val) PY_RAISE; -void py_dict__delitem(py_Ref self, py_Ref key) PY_RAISE; -bool py_dict__contains(py_Ref self, py_Ref key) PY_RAISE; -int py_dict__len(py_Ref self); -bool py_dict__apply(py_Ref self, bool (*f)(py_Ref key, py_Ref val, void* ctx), void* ctx) PY_RAISE; +py_TmpRef py_dict_getitem(py_Ref self, py_Ref key) PY_RAISE; +void py_dict_setitem(py_Ref self, py_Ref key, py_Ref val) PY_RAISE; +void py_dict_delitem(py_Ref self, py_Ref key) PY_RAISE; +bool py_dict_contains(py_Ref self, py_Ref key) PY_RAISE; +int py_dict_len(py_Ref self); +bool py_dict_apply(py_Ref self, bool (*f)(py_Ref key, py_Ref val, void* ctx), void* ctx) PY_RAISE; /************* Others *************/ diff --git a/src/compiler/compiler.c b/src/compiler/compiler.c index 77eb3425..f14209f1 100644 --- a/src/compiler/compiler.c +++ b/src/compiler/compiler.c @@ -2262,7 +2262,7 @@ static Error* read_literal(Compiler* self, py_Ref out) { consume(TK_RPAREN); py_newtuple(out, count); for(int i = 0; i < count; i++) { - py_tuple__setitem(out, i, &cpnts[i]); + py_tuple_setitem(out, i, &cpnts[i]); } return NULL; } diff --git a/src/interpreter/ceval.c b/src/interpreter/ceval.c index 6a6af3bd..5cea6b78 100644 --- a/src/interpreter/ceval.c +++ b/src/interpreter/ceval.c @@ -438,7 +438,7 @@ FrameResult VM__run_top_frame(VM* self) { py_newtuple(&tmp, byte.arg); py_TValue* begin = SP() - byte.arg; for(int i = 0; i < byte.arg; i++) { - py_tuple__setitem(&tmp, i, begin + i); + py_tuple_setitem(&tmp, i, begin + i); } SP() = begin; PUSH(&tmp); @@ -449,7 +449,7 @@ FrameResult VM__run_top_frame(VM* self) { py_newlistn(&tmp, byte.arg); py_TValue* begin = SP() - byte.arg; for(int i = 0; i < byte.arg; i++) { - py_list__setitem(&tmp, i, begin + i); + py_list_setitem(&tmp, i, begin + i); } SP() = begin; PUSH(&tmp); @@ -460,7 +460,7 @@ FrameResult VM__run_top_frame(VM* self) { py_Ref tmp = py_pushtmp(); py_newdict(tmp); for(int i = 0; i < byte.arg * 2; i += 2) { - py_dict__setitem(tmp, begin + i, begin + i + 1); + py_dict_setitem(tmp, begin + i, begin + i + 1); if(py_checkexc()) goto __ERROR; } SP() = begin; @@ -668,9 +668,9 @@ FrameResult VM__run_top_frame(VM* self) { py_TValue* kwargs = py_getslot(&curr[1], 0); if(kwargs->type == tp_dict) { py_TValue* p = buf + n; - if(!py_dict__apply(kwargs, unpack_dict_to_buffer, &p)) goto __ERROR; + if(!py_dict_apply(kwargs, unpack_dict_to_buffer, &p)) goto __ERROR; n = p - buf; - kwargc += py_dict__len(kwargs) - 1; + kwargc += py_dict_len(kwargs) - 1; } else { TypeError("**kwargs must be a dict, got '%t'", kwargs->type); goto __ERROR; @@ -706,13 +706,13 @@ FrameResult VM__run_top_frame(VM* self) { ///////// case OP_LIST_APPEND: { // [list, iter, value] - py_list__append(THIRD(), TOP()); + py_list_append(THIRD(), TOP()); POP(); DISPATCH(); } case OP_DICT_ADD: { // [dict, iter, key, value] - py_dict__setitem(FOURTH(), SECOND(), TOP()); + py_dict_setitem(FOURTH(), SECOND(), TOP()); if(py_checkexc()) goto __ERROR; STACK_SHRINK(2); DISPATCH(); @@ -838,7 +838,7 @@ FrameResult VM__run_top_frame(VM* self) { } py_newlistn(SP()++, exceed); for(int i = 0; i < exceed; i++) { - py_list__setitem(TOP(), i, p + byte.arg + i); + py_list_setitem(TOP(), i, p + byte.arg + i); } DISPATCH(); } diff --git a/src/interpreter/vm.c b/src/interpreter/vm.c index 3d99263e..cfb0c4d3 100644 --- a/src/interpreter/vm.c +++ b/src/interpreter/vm.c @@ -328,7 +328,7 @@ static bool py_Ref vargs = &buffer[decl->starred_arg]; py_newtuple(vargs, exceed_argc); for(int j = 0; j < exceed_argc; j++) { - py_tuple__setitem(vargs, j, t++); + py_tuple_setitem(vargs, j, t++); } } else { // kwdefaults override @@ -361,7 +361,7 @@ static bool py_Ref tmp = py_pushtmp(); c11_sv key_sv = py_name2sv(key); py_newstrn(tmp, key_sv.data, key_sv.size); - py_dict__setitem(&buffer[decl->starred_kwarg], tmp, &p1[2 * j + 1]); + py_dict_setitem(&buffer[decl->starred_kwarg], tmp, &p1[2 * j + 1]); py_pop(); if(py_checkexc()) return false; } @@ -584,11 +584,11 @@ void pk_print_stack(VM* self, Frame* frame, Bytecode byte) { case tp_bool: c11_sbuf__write_cstr(&buf, p->_bool ? "True" : "False"); break; case tp_NoneType: c11_sbuf__write_cstr(&buf, "None"); break; case tp_list: { - pk_sprintf(&buf, "list(%d)", py_list__len(p)); + pk_sprintf(&buf, "list(%d)", py_list_len(p)); break; } case tp_tuple: { - pk_sprintf(&buf, "tuple(%d)", py_tuple__len(p)); + pk_sprintf(&buf, "tuple(%d)", py_tuple_len(p)); break; } case tp_function: { diff --git a/src/modules/math.c b/src/modules/math.c index c07fe0d2..7236e9a3 100644 --- a/src/modules/math.c +++ b/src/modules/math.c @@ -37,8 +37,8 @@ static bool math_fsum(int argc, py_Ref argv) { py_Ref list = py_arg(0); double sum = 0; double c = 0; - for(int i = 0; i < py_list__len(list); i++) { - py_Ref item = py_list__getitem(list, i); + for(int i = 0; i < py_list_len(list); i++) { + py_Ref item = py_list_getitem(list, i); double x; if(!py_castfloat(item, &x)) return false; double y = x - c; @@ -136,8 +136,8 @@ static bool math_modf(int argc, py_Ref argv) { double i; double f = modf(py_tofloat(py_arg(0)), &i); py_newtuple(py_retval(), 2); - py_Ref _0 = py_tuple__getitem(py_retval(), 0); - py_Ref _1 = py_tuple__getitem(py_retval(), 1); + py_Ref _0 = py_tuple_getitem(py_retval(), 0); + py_Ref _1 = py_tuple_getitem(py_retval(), 1); py_newfloat(_0, f); py_newfloat(_1, i); return true; diff --git a/src/objects/codeobject.c b/src/objects/codeobject.c index 7862f1ba..fcccb3d0 100644 --- a/src/objects/codeobject.c +++ b/src/objects/codeobject.c @@ -101,9 +101,9 @@ FuncDecl_ FuncDecl__build(c11_sv name, } if(starred_arg.size) { FuncDecl__add_starred_arg(decl, py_namev(starred_arg)); } assert(py_istype(kwdefaults, tp_tuple)); - assert(py_tuple__len(kwdefaults) == kwargc); + assert(py_tuple_len(kwdefaults) == kwargc); for(int i = 0; i < kwargc; i++) { - FuncDecl__add_kwarg(decl, py_namev(kwargs[i]), py_tuple__getitem(kwdefaults, i)); + FuncDecl__add_kwarg(decl, py_namev(kwargs[i]), py_tuple_getitem(kwdefaults, i)); } if(starred_kwarg.size) FuncDecl__add_starred_kwarg(decl, py_namev(starred_kwarg)); decl->docstring = docstring; diff --git a/src/public/modules.c b/src/public/modules.c index db471cc3..ef9fc3e4 100644 --- a/src/public/modules.c +++ b/src/public/modules.c @@ -174,7 +174,7 @@ static bool builtins_reversed(int argc, py_Ref argv) { PY_CHECK_ARGC(1); // convert _0 to list object if(!py_tpcall(tp_list, 1, argv)) return false; - py_list__reverse(py_retval()); + py_list_reverse(py_retval()); return true; } @@ -329,9 +329,9 @@ static bool builtins_eval(int argc, py_Ref argv) { static bool builtins_isinstance(int argc, py_Ref argv) { PY_CHECK_ARGC(2); if(py_istuple(py_arg(1))) { - int length = py_tuple__len(py_arg(1)); + int length = py_tuple_len(py_arg(1)); for(int i = 0; i < length; i++) { - py_Ref item = py_tuple__getitem(py_arg(1), i); + py_Ref item = py_tuple_getitem(py_arg(1), i); if(!py_checktype(item, tp_type)) return false; if(py_isinstance(py_arg(0), py_totype(item))) { py_newbool(py_retval(), true); @@ -452,7 +452,7 @@ static bool function__closure__getter(int argc, py_Ref argv) { c11__foreach(NameDict_KV, ud->closure, it) { // printf("%s -> %s\n", py_name2str(it->key), py_tpname(it->value.type)); py_newstr(r0, py_name2str(it->key)); - py_dict__setitem(retval, r0, &it->value); + py_dict_setitem(retval, r0, &it->value); if(py_checkexc()) { py_shrink(2); return false; diff --git a/src/public/py_array.c b/src/public/py_array.c index 0e0c0c03..cd2d5228 100644 --- a/src/public/py_array.c +++ b/src/public/py_array.c @@ -13,11 +13,11 @@ typedef struct array_iterator { py_TValue* pk_arrayview(py_Ref self, int* length) { if(self->type == tp_list) { - *length = py_list__len(self); - return py_list__data(self); + *length = py_list_len(self); + return py_list_data(self); } if(self->type == tp_tuple) { - *length = py_tuple__len(self); + *length = py_tuple_len(self); return PyObject__slots(self->_obj); } return NULL; diff --git a/src/public/py_dict.c b/src/public/py_dict.c index bca84093..6250f82e 100644 --- a/src/public/py_dict.c +++ b/src/public/py_dict.c @@ -217,13 +217,13 @@ static bool dict__init__(int argc, py_Ref argv) { PY_CHECK_ARG_TYPE(1, tp_list); Dict* self = py_touserdata(argv); py_Ref list = py_arg(1); - for(int i = 0; i < py_list__len(list); i++) { - py_Ref tuple = py_list__getitem(list, i); - if(!py_istuple(tuple) || py_tuple__len(tuple) != 2) { + for(int i = 0; i < py_list_len(list); i++) { + py_Ref tuple = py_list_getitem(list, i); + if(!py_istuple(tuple) || py_tuple_len(tuple) != 2) { return TypeError("dict.__init__() argument must be a list of tuple-2"); } - py_Ref key = py_tuple__getitem(tuple, 0); - py_Ref val = py_tuple__getitem(tuple, 1); + py_Ref key = py_tuple_getitem(tuple, 0); + py_Ref val = py_tuple_getitem(tuple, 1); if(!Dict__set(self, key, val)) return false; } return true; @@ -407,7 +407,7 @@ static bool dict_keys(int argc, py_Ref argv) { while(1) { DictEntry* entry = DictIterator__next(&iter); if(!entry) break; - py_tuple__setitem(py_retval(), i++, &entry->key); + py_tuple_setitem(py_retval(), i++, &entry->key); } assert(i == self->length); return true; @@ -423,7 +423,7 @@ static bool dict_values(int argc, py_Ref argv) { while(1) { DictEntry* entry = DictIterator__next(&iter); if(!entry) break; - py_tuple__setitem(py_retval(), i++, &entry->val); + py_tuple_setitem(py_retval(), i++, &entry->val); } assert(i == self->length); return true; @@ -469,8 +469,8 @@ static bool dict_items__next__(int argc, py_Ref argv) { DictEntry* entry = (DictIterator__next(iter)); if(entry) { py_newtuple(py_retval(), 2); - py_tuple__setitem(py_retval(), 0, &entry->key); - py_tuple__setitem(py_retval(), 1, &entry->val); + py_tuple_setitem(py_retval(), 0, &entry->key); + py_tuple_setitem(py_retval(), 1, &entry->val); return true; } return StopIteration(); @@ -490,7 +490,7 @@ void py_newdict(py_Ref out) { Dict__ctor(ud, 8); } -py_Ref py_dict__getitem(py_Ref self, py_Ref key) { +py_Ref py_dict_getitem(py_Ref self, py_Ref key) { assert(py_isdict(self)); Dict* ud = py_touserdata(self); DictEntry* entry; @@ -499,19 +499,19 @@ py_Ref py_dict__getitem(py_Ref self, py_Ref key) { return NULL; } -void py_dict__delitem(py_Ref self, py_Ref key) { +void py_dict_delitem(py_Ref self, py_Ref key) { assert(py_isdict(self)); Dict* ud = py_touserdata(self); Dict__pop(ud, key); } -void py_dict__setitem(py_Ref self, py_Ref key, py_Ref val) { +void py_dict_setitem(py_Ref self, py_Ref key, py_Ref val) { assert(py_isdict(self)); Dict* ud = py_touserdata(self); Dict__set(ud, key, val); } -bool py_dict__contains(py_Ref self, py_Ref key) { +bool py_dict_contains(py_Ref self, py_Ref key) { assert(py_isdict(self)); Dict* ud = py_touserdata(self); DictEntry* entry; @@ -519,13 +519,13 @@ bool py_dict__contains(py_Ref self, py_Ref key) { return ok && entry != NULL; } -int py_dict__len(py_Ref self) { +int py_dict_len(py_Ref self) { assert(py_isdict(self)); Dict* ud = py_touserdata(self); return ud->length; } -bool py_dict__apply(py_Ref self, bool (*f)(py_Ref, py_Ref, void*), void* ctx) { +bool py_dict_apply(py_Ref self, bool (*f)(py_Ref, py_Ref, void*), void* ctx) { Dict* ud = py_touserdata(self); for(int i = 0; i < ud->entries.count; i++) { DictEntry* entry = c11__at(DictEntry, &ud->entries, i); diff --git a/src/public/py_list.c b/src/public/py_list.c index 8e54c6a5..e44b555b 100644 --- a/src/public/py_list.c +++ b/src/public/py_list.c @@ -19,47 +19,47 @@ void py_newlistn(py_Ref out, int n) { userdata->count = n; } -py_Ref py_list__data(py_Ref self) { +py_Ref py_list_data(py_Ref self) { List* userdata = py_touserdata(self); return userdata->data; } -py_Ref py_list__getitem(py_Ref self, int i) { +py_Ref py_list_getitem(py_Ref self, int i) { List* userdata = py_touserdata(self); return c11__at(py_TValue, userdata, i); } -void py_list__setitem(py_Ref self, int i, py_Ref val) { +void py_list_setitem(py_Ref self, int i, py_Ref val) { List* userdata = py_touserdata(self); c11__setitem(py_TValue, userdata, i, *val); } -void py_list__delitem(py_Ref self, int i) { +void py_list_delitem(py_Ref self, int i) { List* userdata = py_touserdata(self); c11_vector__erase(py_TValue, userdata, i); } -int py_list__len(py_Ref self) { +int py_list_len(py_Ref self) { List* userdata = py_touserdata(self); return userdata->count; } -void py_list__append(py_Ref self, py_Ref val) { +void py_list_append(py_Ref self, py_Ref val) { List* userdata = py_touserdata(self); c11_vector__push(py_TValue, userdata, *val); } -void py_list__clear(py_Ref self) { +void py_list_clear(py_Ref self) { List* userdata = py_touserdata(self); c11_vector__clear(userdata); } -void py_list__insert(py_Ref self, int i, py_Ref val) { +void py_list_insert(py_Ref self, int i, py_Ref val) { List* userdata = py_touserdata(self); c11_vector__insert(py_TValue, userdata, i, *val); } -void py_list__reverse(py_Ref self) { +void py_list_reverse(py_Ref self) { List* userdata = py_touserdata(self); c11__reverse(py_TValue, userdata); } @@ -67,7 +67,7 @@ void py_list__reverse(py_Ref self) { //////////////////////////////// static bool list__len__(int argc, py_Ref argv) { PY_CHECK_ARGC(1); - py_i64 res = py_list__len(py_arg(0)); + py_i64 res = py_list_len(py_arg(0)); py_newint(py_retval(), res); return true; } @@ -107,7 +107,7 @@ static bool list__new__(int argc, py_Ref argv) { if(p) { py_newlistn(py_retval(), length); for(int i = 0; i < length; i++) { - py_list__setitem(py_retval(), i, p + i); + py_list_setitem(py_retval(), i, p + i); } return true; } @@ -125,7 +125,7 @@ static bool list__new__(int argc, py_Ref argv) { return false; } if(!res) break; - py_list__append(list, py_retval()); + py_list_append(list, py_retval()); } *py_retval() = *list; py_shrink(2); @@ -218,7 +218,7 @@ static bool list__rmul__(int argc, py_Ref argv) { return list__mul__(argc, argv) static bool list_append(int argc, py_Ref argv) { PY_CHECK_ARGC(2); - py_list__append(py_arg(0), py_arg(1)); + py_list_append(py_arg(0), py_arg(1)); py_newnone(py_retval()); return true; } @@ -256,8 +256,8 @@ static bool list_extend(int argc, py_Ref argv) { static bool list_count(int argc, py_Ref argv) { PY_CHECK_ARGC(2); int count = 0; - for(int i = 0; i < py_list__len(py_arg(0)); i++) { - int res = py_equal(py_list__getitem(py_arg(0), i), py_arg(1)); + for(int i = 0; i < py_list_len(py_arg(0)); i++) { + int res = py_equal(py_list_getitem(py_arg(0), i), py_arg(1)); if(res == -1) return false; if(res) count++; } @@ -267,7 +267,7 @@ static bool list_count(int argc, py_Ref argv) { static bool list_clear(int argc, py_Ref argv) { PY_CHECK_ARGC(1); - py_list__clear(py_arg(0)); + py_list_clear(py_arg(0)); py_newnone(py_retval()); return true; } @@ -288,8 +288,8 @@ static bool list_index(int argc, py_Ref argv) { PY_CHECK_ARG_TYPE(2, tp_int); start = py_toint(py_arg(2)); } - for(int i = start; i < py_list__len(py_arg(0)); i++) { - int res = py_equal(py_list__getitem(py_arg(0), i), py_arg(1)); + for(int i = start; i < py_list_len(py_arg(0)); i++) { + int res = py_equal(py_list_getitem(py_arg(0), i), py_arg(1)); if(res == -1) return false; if(res) { py_newint(py_retval(), i); @@ -309,11 +309,11 @@ static bool list_reverse(int argc, py_Ref argv) { static bool list_remove(int argc, py_Ref argv) { PY_CHECK_ARGC(2); - for(int i = 0; i < py_list__len(py_arg(0)); i++) { - int res = py_equal(py_list__getitem(py_arg(0), i), py_arg(1)); + for(int i = 0; i < py_list_len(py_arg(0)); i++) { + int res = py_equal(py_list_getitem(py_arg(0), i), py_arg(1)); if(res == -1) return false; if(res) { - py_list__delitem(py_arg(0), i); + py_list_delitem(py_arg(0), i); py_newnone(py_retval()); return true; } diff --git a/src/public/py_str.c b/src/public/py_str.c index 28e086ce..0f68144a 100644 --- a/src/public/py_str.c +++ b/src/public/py_str.c @@ -268,11 +268,11 @@ static bool str_join(int argc, py_Ref argv) { py_TValue* p; int length; if(py_istype(_1, tp_list)) { - p = py_list__getitem(_1, 0); - length = py_list__len(_1); + p = py_list_getitem(_1, 0); + length = py_list_len(_1); } else if(py_istype(_1, tp_tuple)) { - p = py_tuple__getitem(_1, 0); - length = py_tuple__len(_1); + p = py_tuple_getitem(_1, 0); + length = py_tuple_len(_1); } else { return TypeError("join() argument must be a list or tuple"); } @@ -323,7 +323,7 @@ static bool str_split(int argc, py_Ref argv) { py_newlistn(py_retval(), res.count); for(int i = 0; i < res.count; i++) { c11_sv item = c11__getitem(c11_sv, &res, i); - py_newstrn(py_list__getitem(py_retval(), i), item.data, item.size); + py_newstrn(py_list_getitem(py_retval(), i), item.data, item.size); } c11_vector__dtor(&res); return true; diff --git a/src/public/py_tuple.c b/src/public/py_tuple.c index 4c381147..19e28500 100644 --- a/src/public/py_tuple.c +++ b/src/public/py_tuple.c @@ -13,17 +13,17 @@ void py_newtuple(py_Ref out, int n) { out->_obj = obj; } -py_Ref py_tuple__getitem(py_Ref self, int i) { return py_getslot(self, i); } +py_Ref py_tuple_getitem(py_Ref self, int i) { return py_getslot(self, i); } -py_Ref py_tuple__data(py_Ref self) { return PyObject__slots(self->_obj); } +py_Ref py_tuple_data(py_Ref self) { return PyObject__slots(self->_obj); } -void py_tuple__setitem(py_Ref self, int i, py_Ref val) { py_setslot(self, i, val); } +void py_tuple_setitem(py_Ref self, int i, py_Ref val) { py_setslot(self, i, val); } -int py_tuple__len(py_Ref self) { return self->_obj->slots; } +int py_tuple_len(py_Ref self) { return self->_obj->slots; } ////////////// static bool tuple__len__(int argc, py_Ref argv) { - py_newint(py_retval(), py_tuple__len(argv)); + py_newint(py_retval(), py_tuple_len(argv)); return true; } @@ -31,7 +31,7 @@ static bool tuple__repr__(int argc, py_Ref argv) { c11_sbuf buf; c11_sbuf__ctor(&buf); c11_sbuf__write_char(&buf, '('); - int length = py_tuple__len(argv); + int length = py_tuple_len(argv); for(int i = 0; i < length; i++) { py_TValue* val = py_getslot(argv, i); bool ok = py_repr(val); @@ -58,10 +58,10 @@ static bool tuple__new__(int argc, py_Ref argv) { if(!ok) return false; py_Ref tmp = py_pushtmp(); *tmp = *py_retval(); // backup the list - int length = py_list__len(tmp); + int length = py_list_len(tmp); py_newtuple(py_retval(), length); - for(int i = 0; i < py_tuple__len(py_retval()); i++) { - py_tuple__setitem(py_retval(), i, py_list__getitem(tmp, i)); + for(int i = 0; i < py_tuple_len(py_retval()); i++) { + py_tuple_setitem(py_retval(), i, py_list_getitem(tmp, i)); } py_pop(); return true; @@ -71,7 +71,7 @@ static bool tuple__new__(int argc, py_Ref argv) { static bool tuple__getitem__(int argc, py_Ref argv) { PY_CHECK_ARGC(2); - int length = py_tuple__len(argv); + int length = py_tuple_len(argv); py_Ref _1 = py_arg(1); if(_1->type == tp_int) { int index = py_toint(py_arg(1)); @@ -84,11 +84,11 @@ static bool tuple__getitem__(int argc, py_Ref argv) { if(!ok) return false; py_Ref tmp = py_pushtmp(); py_newlist(tmp); - PK_SLICE_LOOP(i, start, stop, step) py_list__append(tmp, py_getslot(argv, i)); + PK_SLICE_LOOP(i, start, stop, step) py_list_append(tmp, py_getslot(argv, i)); // convert list to tuple - py_newtuple(py_retval(), py_list__len(tmp)); - for(int i = 0; i < py_tuple__len(py_retval()); i++) { - py_tuple__setitem(py_retval(), i, py_list__getitem(tmp, i)); + py_newtuple(py_retval(), py_list_len(tmp)); + for(int i = 0; i < py_tuple_len(py_retval()); i++) { + py_tuple_setitem(py_retval(), i, py_list_getitem(tmp, i)); } py_pop(); return true; @@ -133,8 +133,8 @@ static bool tuple__contains__(int argc, py_Ref argv) { static bool tuple__hash__(int argc, py_Ref argv) { PY_CHECK_ARGC(1); - int length = py_tuple__len(argv); - py_TValue* data = py_tuple__data(argv); + int length = py_tuple_len(argv); + py_TValue* data = py_tuple_data(argv); uint64_t x = 1000003; for(int i = 0; i < length; i++) { py_i64 y;