mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
replace reinterpret_cast with C-style cast
This commit is contained in:
parent
6d938d30bf
commit
d1763bdef1
@ -28,21 +28,21 @@ struct Dict : private pkpy_Dict {
|
||||
int size() const { return count; }
|
||||
|
||||
void set(VM* vm, PyVar key, PyVar val) {
|
||||
pkpy_Dict__set(this, vm, *reinterpret_cast<::pkpy_Var*>(&key), *reinterpret_cast<::pkpy_Var*>(&val));
|
||||
pkpy_Dict__set(this, vm, *(pkpy_Var*)(&key), *(pkpy_Var*)(&val));
|
||||
}
|
||||
|
||||
PyVar try_get(VM* vm, PyVar key) const {
|
||||
auto res = pkpy_Dict__try_get(this, vm, *reinterpret_cast<::pkpy_Var*>(&key));
|
||||
auto res = pkpy_Dict__try_get(this, vm, *(pkpy_Var*)(&key));
|
||||
if (!res) return nullptr;
|
||||
return *reinterpret_cast<const PyVar*>(res);
|
||||
}
|
||||
|
||||
bool contains(VM* vm, PyVar key) const {
|
||||
return pkpy_Dict__contains(this, vm, *reinterpret_cast<::pkpy_Var*>(&key));
|
||||
return pkpy_Dict__contains(this, vm, *(pkpy_Var*)(&key));
|
||||
}
|
||||
|
||||
bool del(VM* vm, PyVar key) {
|
||||
return pkpy_Dict__del(this, vm, *reinterpret_cast<::pkpy_Var*>(&key));
|
||||
return pkpy_Dict__del(this, vm, *(pkpy_Var*)(&key));
|
||||
}
|
||||
|
||||
void update(VM* vm, const Dict& other) {
|
||||
@ -53,7 +53,7 @@ struct Dict : private pkpy_Dict {
|
||||
void apply(__Func f) const {
|
||||
pkpy_DictIter it = iter();
|
||||
PyVar key, val;
|
||||
while(pkpy_DictIter__next(&it, reinterpret_cast<::pkpy_Var*>(&key), reinterpret_cast<::pkpy_Var*>(&val))) {
|
||||
while(pkpy_DictIter__next(&it, (pkpy_Var*)(&key), (pkpy_Var*)(&val))) {
|
||||
f(key, val);
|
||||
}
|
||||
}
|
||||
@ -63,7 +63,7 @@ struct Dict : private pkpy_Dict {
|
||||
pkpy_DictIter it = iter();
|
||||
PyVar key, val;
|
||||
int i = 0;
|
||||
while(pkpy_DictIter__next(&it, reinterpret_cast<::pkpy_Var*>(&key), reinterpret_cast<::pkpy_Var*>(&val))) {
|
||||
while(pkpy_DictIter__next(&it, (pkpy_Var*)(&key), (pkpy_Var*)(&val))) {
|
||||
res[i++] = key;
|
||||
}
|
||||
return res;
|
||||
@ -74,7 +74,7 @@ struct Dict : private pkpy_Dict {
|
||||
pkpy_DictIter it = iter();
|
||||
PyVar key, val;
|
||||
int i = 0;
|
||||
while(pkpy_DictIter__next(&it, reinterpret_cast<::pkpy_Var*>(&key), reinterpret_cast<::pkpy_Var*>(&val))) {
|
||||
while(pkpy_DictIter__next(&it, (pkpy_Var*)(&key), (pkpy_Var*)(&val))) {
|
||||
res[i++] = val;
|
||||
}
|
||||
return res;
|
||||
|
@ -118,7 +118,7 @@ void DictItemsIter::_register(VM* vm, PyObject* mod, PyObject* type) {
|
||||
vm->bind__next__(type->as<Type>(), [](VM* vm, PyVar _0) -> unsigned {
|
||||
DictItemsIter& self = _CAST(DictItemsIter&, _0);
|
||||
PyVar key, val;
|
||||
if (pkpy_DictIter__next(&self.it, reinterpret_cast<::pkpy_Var*>(&key), reinterpret_cast<::pkpy_Var*>(&val))) {
|
||||
if (pkpy_DictIter__next(&self.it, (pkpy_Var*)(&key), (pkpy_Var*)(&val))) {
|
||||
vm->s_data.push(key);
|
||||
vm->s_data.push(val);
|
||||
return 2;
|
||||
|
@ -1495,7 +1495,7 @@ void __init_builtins(VM* _vm) {
|
||||
if(self.size() != other.size()) return vm->False;
|
||||
pkpy_DictIter it = self.iter();
|
||||
PyVar key, val;
|
||||
while(pkpy_DictIter__next(&it, reinterpret_cast<::pkpy_Var*>(&key), reinterpret_cast<::pkpy_Var*>(&val))) {
|
||||
while(pkpy_DictIter__next(&it, (pkpy_Var*)(&key), (pkpy_Var*)(&val))) {
|
||||
PyVar other_val = other.try_get(vm, key);
|
||||
if(other_val == nullptr) return vm->False;
|
||||
if(!vm->py_eq(val, other_val)) return vm->False;
|
||||
|
Loading…
x
Reference in New Issue
Block a user