diff options
author | Victor Stinner <vstinner@python.org> | 2023-07-02 21:19:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-02 21:19:59 (GMT) |
commit | c38c66687f148991031914f12ebd5c42d6e26b5b (patch) | |
tree | ecd745663c43bb4414930f4a9ffea668d6d726ed | |
parent | dbefa88b27ee1f124f782363b139aee3f1ccf590 (diff) | |
download | cpython-c38c66687f148991031914f12ebd5c42d6e26b5b.zip cpython-c38c66687f148991031914f12ebd5c42d6e26b5b.tar.gz cpython-c38c66687f148991031914f12ebd5c42d6e26b5b.tar.bz2 |
gh-106320: Add pycore_complexobject.h header file (#106339)
Add internal pycore_complexobject.h header file.
Move _Py_c_xxx() functions and _PyComplex_FormatAdvancedWriter()
function to this new header file.
-rw-r--r-- | Include/cpython/complexobject.h | 21 | ||||
-rw-r--r-- | Include/internal/pycore_complexobject.h | 33 | ||||
-rw-r--r-- | Makefile.pre.in | 1 | ||||
-rw-r--r-- | Modules/cmathmodule.c | 1 | ||||
-rw-r--r-- | Objects/complexobject.c | 1 | ||||
-rw-r--r-- | Objects/stringlib/unicode_format.h | 1 | ||||
-rw-r--r-- | PCbuild/pythoncore.vcxproj | 1 | ||||
-rw-r--r-- | PCbuild/pythoncore.vcxproj.filters | 3 |
8 files changed, 41 insertions, 21 deletions
diff --git a/Include/cpython/complexobject.h b/Include/cpython/complexobject.h index b7d7283..b524ec4 100644 --- a/Include/cpython/complexobject.h +++ b/Include/cpython/complexobject.h @@ -7,16 +7,6 @@ typedef struct { double imag; } Py_complex; -/* Operations on complex numbers from complexmodule.c */ - -PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex); -PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex); -PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex); -PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex); -PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex); -PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex); -PyAPI_FUNC(double) _Py_c_abs(Py_complex); - /* Complex object interface */ /* @@ -31,14 +21,3 @@ typedef struct { PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex); PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op); - -#ifdef Py_BUILD_CORE -/* Format the object based on the format_spec, as defined in PEP 3101 - (Advanced String Formatting). */ -extern int _PyComplex_FormatAdvancedWriter( - _PyUnicodeWriter *writer, - PyObject *obj, - PyObject *format_spec, - Py_ssize_t start, - Py_ssize_t end); -#endif // Py_BUILD_CORE diff --git a/Include/internal/pycore_complexobject.h b/Include/internal/pycore_complexobject.h new file mode 100644 index 0000000..fb344b7 --- /dev/null +++ b/Include/internal/pycore_complexobject.h @@ -0,0 +1,33 @@ +#ifndef Py_INTERNAL_COMPLEXOBJECT_H +#define Py_INTERNAL_COMPLEXOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +/* Operations on complex numbers from complexmodule.c */ + +PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex); +PyAPI_FUNC(double) _Py_c_abs(Py_complex); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +extern int _PyComplex_FormatAdvancedWriter( + _PyUnicodeWriter *writer, + PyObject *obj, + PyObject *format_spec, + Py_ssize_t start, + Py_ssize_t end); + +#ifdef __cplusplus +} +#endif +#endif // !Py_INTERNAL_COMPLEXOBJECT_H diff --git a/Makefile.pre.in b/Makefile.pre.in index e788e59..7560d17 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1734,6 +1734,7 @@ PYTHON_HEADERS= \ $(srcdir)/Include/internal/pycore_code.h \ $(srcdir)/Include/internal/pycore_codecs.h \ $(srcdir)/Include/internal/pycore_compile.h \ + $(srcdir)/Include/internal/pycore_complexobject.h \ $(srcdir)/Include/internal/pycore_condvar.h \ $(srcdir)/Include/internal/pycore_context.h \ $(srcdir)/Include/internal/pycore_dict.h \ diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c index 1a31bdc..db8b321 100644 --- a/Modules/cmathmodule.c +++ b/Modules/cmathmodule.c @@ -7,6 +7,7 @@ #endif #include "Python.h" +#include "pycore_complexobject.h" // _Py_c_neg() #include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR /* we need DBL_MAX, DBL_MIN, DBL_EPSILON, DBL_MANT_DIG and FLT_RADIX from float.h. We assume that FLT_RADIX is either 2 or 16. */ diff --git a/Objects/complexobject.c b/Objects/complexobject.c index aee03dd..12968a6 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -7,6 +7,7 @@ #include "Python.h" #include "pycore_call.h" // _PyObject_CallNoArgs() +#include "pycore_complexobject.h" // _PyComplex_FormatAdvancedWriter() #include "pycore_long.h" // _PyLong_GetZero() #include "pycore_object.h" // _PyObject_Init() #include "pycore_pymath.h" // _Py_ADJUST_ERANGE2() diff --git a/Objects/stringlib/unicode_format.h b/Objects/stringlib/unicode_format.h index f4ba0a9..91c71ab 100644 --- a/Objects/stringlib/unicode_format.h +++ b/Objects/stringlib/unicode_format.h @@ -2,6 +2,7 @@ unicode_format.h -- implementation of str.format(). */ +#include "pycore_complexobject.h" // _PyComplex_FormatAdvancedWriter() #include "pycore_floatobject.h" // _PyFloat_FormatAdvancedWriter() /************************************************************************/ diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 436381c..79ce2d3 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -212,6 +212,7 @@ <ClInclude Include="..\Include\internal\pycore_code.h" /> <ClInclude Include="..\Include\internal\pycore_codecs.h" /> <ClInclude Include="..\Include\internal\pycore_compile.h" /> + <ClInclude Include="..\Include\internal\pycore_complexobject.h" /> <ClInclude Include="..\Include\internal\pycore_condvar.h" /> <ClInclude Include="..\Include\internal\pycore_context.h" /> <ClInclude Include="..\Include\internal\pycore_descrobject.h" /> diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 4d9acf4..d47a229 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -543,6 +543,9 @@ <ClInclude Include="..\Include\internal\pycore_compile.h"> <Filter>Include\internal</Filter> </ClInclude> + <ClInclude Include="..\Include\internal\pycore_complexobject.h"> + <Filter>Include\internal</Filter> + </ClInclude> <ClInclude Include="..\Include\internal\pycore_condvar.h"> <Filter>Include\internal</Filter> </ClInclude> |