]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106320: Add pycore_complexobject.h header file (#106339)
authorVictor Stinner <vstinner@python.org>
Sun, 2 Jul 2023 21:19:59 +0000 (23:19 +0200)
committerGitHub <noreply@github.com>
Sun, 2 Jul 2023 21:19:59 +0000 (21:19 +0000)
Add internal pycore_complexobject.h header file.

Move _Py_c_xxx() functions and _PyComplex_FormatAdvancedWriter()
function to this new header file.

Include/cpython/complexobject.h
Include/internal/pycore_complexobject.h [new file with mode: 0644]
Makefile.pre.in
Modules/cmathmodule.c
Objects/complexobject.c
Objects/stringlib/unicode_format.h
PCbuild/pythoncore.vcxproj
PCbuild/pythoncore.vcxproj.filters

index b7d7283ae8896503defd94ee9a4798b426ca0e3e..b524ec42c24371cbd10a938664d0811fe89c48d6 100644 (file)
@@ -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 (file)
index 0000000..fb344b7
--- /dev/null
@@ -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
index e788e590dcbb43a9bdb02ebaf7b6f6ea291b245d..7560d17e3796f067fc403499df34480053f59c18 100644 (file)
@@ -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 \
index 1a31bdc824bb03888235499e172b2da280697b19..db8b321e72e8cefff3b4360c5de49ac351bf535b 100644 (file)
@@ -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. */
index aee03ddfb07aec8f4c3e2cd3aa1c80c36345b671..12968a63cd6fdd3d169af62fa6590e4bb92a50be 100644 (file)
@@ -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()
index f4ba0a92776a97e3fb95661e03495759110bdc33..91c71ab5736c2547590a99fa6a81b82438900a80 100644 (file)
@@ -2,6 +2,7 @@
     unicode_format.h -- implementation of str.format().
 */
 
+#include "pycore_complexobject.h" // _PyComplex_FormatAdvancedWriter()
 #include "pycore_floatobject.h"   // _PyFloat_FormatAdvancedWriter()
 
 /************************************************************************/
index 436381c3ea5db46582af8045b70406a15635d0ea..79ce2d3d14017ef35c620818167a589c39a69022 100644 (file)
     <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" />
index 4d9acf4893872dbb42109c89fb685795b4c54d25..d47a22909e1e3aa78fcc01419752ee86bb7995f0 100644 (file)
     <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>