Skip to content

Commit c38c666

Browse files
authored
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.
1 parent dbefa88 commit c38c666

File tree

8 files changed

+41
-21
lines changed

8 files changed

+41
-21
lines changed

Include/cpython/complexobject.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ typedef struct {
77
double imag;
88
} Py_complex;
99

10-
/* Operations on complex numbers from complexmodule.c */
11-
12-
PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
13-
PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
14-
PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
15-
PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
16-
PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
17-
PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
18-
PyAPI_FUNC(double) _Py_c_abs(Py_complex);
19-
2010
/* Complex object interface */
2111

2212
/*
@@ -31,14 +21,3 @@ typedef struct {
3121
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
3222

3323
PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
34-
35-
#ifdef Py_BUILD_CORE
36-
/* Format the object based on the format_spec, as defined in PEP 3101
37-
(Advanced String Formatting). */
38-
extern int _PyComplex_FormatAdvancedWriter(
39-
_PyUnicodeWriter *writer,
40-
PyObject *obj,
41-
PyObject *format_spec,
42-
Py_ssize_t start,
43-
Py_ssize_t end);
44-
#endif // Py_BUILD_CORE
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#ifndef Py_INTERNAL_COMPLEXOBJECT_H
2+
#define Py_INTERNAL_COMPLEXOBJECT_H
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
#ifndef Py_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
9+
#endif
10+
11+
/* Operations on complex numbers from complexmodule.c */
12+
13+
PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
14+
PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
15+
PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
16+
PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
17+
PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
18+
PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
19+
PyAPI_FUNC(double) _Py_c_abs(Py_complex);
20+
21+
/* Format the object based on the format_spec, as defined in PEP 3101
22+
(Advanced String Formatting). */
23+
extern int _PyComplex_FormatAdvancedWriter(
24+
_PyUnicodeWriter *writer,
25+
PyObject *obj,
26+
PyObject *format_spec,
27+
Py_ssize_t start,
28+
Py_ssize_t end);
29+
30+
#ifdef __cplusplus
31+
}
32+
#endif
33+
#endif // !Py_INTERNAL_COMPLEXOBJECT_H

Makefile.pre.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,6 +1734,7 @@ PYTHON_HEADERS= \
17341734
$(srcdir)/Include/internal/pycore_code.h \
17351735
$(srcdir)/Include/internal/pycore_codecs.h \
17361736
$(srcdir)/Include/internal/pycore_compile.h \
1737+
$(srcdir)/Include/internal/pycore_complexobject.h \
17371738
$(srcdir)/Include/internal/pycore_condvar.h \
17381739
$(srcdir)/Include/internal/pycore_context.h \
17391740
$(srcdir)/Include/internal/pycore_dict.h \

Modules/cmathmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#endif
88

99
#include "Python.h"
10+
#include "pycore_complexobject.h" // _Py_c_neg()
1011
#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
1112
/* we need DBL_MAX, DBL_MIN, DBL_EPSILON, DBL_MANT_DIG and FLT_RADIX from
1213
float.h. We assume that FLT_RADIX is either 2 or 16. */

Objects/complexobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "Python.h"
99
#include "pycore_call.h" // _PyObject_CallNoArgs()
10+
#include "pycore_complexobject.h" // _PyComplex_FormatAdvancedWriter()
1011
#include "pycore_long.h" // _PyLong_GetZero()
1112
#include "pycore_object.h" // _PyObject_Init()
1213
#include "pycore_pymath.h" // _Py_ADJUST_ERANGE2()

Objects/stringlib/unicode_format.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
unicode_format.h -- implementation of str.format().
33
*/
44

5+
#include "pycore_complexobject.h" // _PyComplex_FormatAdvancedWriter()
56
#include "pycore_floatobject.h" // _PyFloat_FormatAdvancedWriter()
67

78
/************************************************************************/

PCbuild/pythoncore.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@
212212
<ClInclude Include="..\Include\internal\pycore_code.h" />
213213
<ClInclude Include="..\Include\internal\pycore_codecs.h" />
214214
<ClInclude Include="..\Include\internal\pycore_compile.h" />
215+
<ClInclude Include="..\Include\internal\pycore_complexobject.h" />
215216
<ClInclude Include="..\Include\internal\pycore_condvar.h" />
216217
<ClInclude Include="..\Include\internal\pycore_context.h" />
217218
<ClInclude Include="..\Include\internal\pycore_descrobject.h" />

PCbuild/pythoncore.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,9 @@
543543
<ClInclude Include="..\Include\internal\pycore_compile.h">
544544
<Filter>Include\internal</Filter>
545545
</ClInclude>
546+
<ClInclude Include="..\Include\internal\pycore_complexobject.h">
547+
<Filter>Include\internal</Filter>
548+
</ClInclude>
546549
<ClInclude Include="..\Include\internal\pycore_condvar.h">
547550
<Filter>Include\internal</Filter>
548551
</ClInclude>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy