|
17 | 17 | // Macro to use C++ static_cast<>, reinterpret_cast<> and const_cast<> |
18 | 18 | // in the Python C API. |
19 | 19 | // |
20 | | -// In C++, _Py_reinterpret_cast(type, expr) converts a constant expression to a |
| 20 | +// In C++, _Py_CAST(type, expr) converts a constant expression to a |
21 | 21 | // non constant type using const_cast<type>. For example, |
22 | | -// _Py_reinterpret_cast(PyObject*, op) can convert a "const PyObject*" to |
| 22 | +// _Py_CAST(PyObject*, op) can convert a "const PyObject*" to |
23 | 23 | // "PyObject*". |
24 | 24 | // |
25 | 25 | // The type argument must not be constant. For example, in C++, |
26 | | -// _Py_reinterpret_cast(const PyObject*, expr) fails with a compiler error. |
| 26 | +// _Py_CAST(const PyObject*, expr) fails with a compiler error. |
27 | 27 | #ifdef __cplusplus |
28 | | -# define _Py_static_cast(type, expr) static_cast<type>(expr) |
29 | | -# define _Py_reinterpret_cast(type, expr) \ |
| 28 | +# define _Py_STATIC_CAST(type, expr) static_cast<type>(expr) |
| 29 | +# define _Py_CAST(type, expr) \ |
30 | 30 | const_cast<type>(reinterpret_cast<const type>(expr)) |
31 | 31 | #else |
32 | | -# define _Py_static_cast(type, expr) ((type)(expr)) |
33 | | -# define _Py_reinterpret_cast(type, expr) ((type)(expr)) |
| 32 | +# define _Py_STATIC_CAST(type, expr) ((type)(expr)) |
| 33 | +# define _Py_CAST(type, expr) ((type)(expr)) |
34 | 34 | #endif |
35 | 35 |
|
36 | 36 |
|
@@ -317,10 +317,10 @@ extern "C" { |
317 | 317 | */ |
318 | 318 | #ifdef Py_DEBUG |
319 | 319 | # define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \ |
320 | | - (assert(_Py_static_cast(WIDE, _Py_static_cast(NARROW, (VALUE))) == (VALUE)), \ |
321 | | - _Py_static_cast(NARROW, (VALUE))) |
| 320 | + (assert(_Py_STATIC_CAST(WIDE, _Py_STATIC_CAST(NARROW, (VALUE))) == (VALUE)), \ |
| 321 | + _Py_STATIC_CAST(NARROW, (VALUE))) |
322 | 322 | #else |
323 | | -# define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) _Py_static_cast(NARROW, (VALUE)) |
| 323 | +# define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) _Py_STATIC_CAST(NARROW, (VALUE)) |
324 | 324 | #endif |
325 | 325 |
|
326 | 326 |
|
|
0 commit comments