From d1763bdef177441f8ed373a2fc44e968567329af Mon Sep 17 00:00:00 2001 From: szdytom Date: Fri, 14 Jun 2024 12:21:20 +0800 Subject: [PATCH] replace reinterpret_cast with C-style cast --- include/pocketpy/objects/dict.hpp | 14 +++++++------- src/interpreter/iter.cpp | 2 +- src/pocketpy.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/pocketpy/objects/dict.hpp b/include/pocketpy/objects/dict.hpp index 6c854961..94fe0c12 100644 --- a/include/pocketpy/objects/dict.hpp +++ b/include/pocketpy/objects/dict.hpp @@ -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(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; diff --git a/src/interpreter/iter.cpp b/src/interpreter/iter.cpp index 56d5f1f6..d0fae96a 100644 --- a/src/interpreter/iter.cpp +++ b/src/interpreter/iter.cpp @@ -118,7 +118,7 @@ void DictItemsIter::_register(VM* vm, PyObject* mod, PyObject* type) { vm->bind__next__(type->as(), [](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; diff --git a/src/pocketpy.cpp b/src/pocketpy.cpp index c6a7bb7d..ba1456eb 100644 --- a/src/pocketpy.cpp +++ b/src/pocketpy.cpp @@ -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;