Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ca219f6

Browse filesBrowse files
authored
bpo-35134: Add Include/cpython/complexobject.h header (GH-32383)
Move the private _PyComplex_FormatAdvancedWriter() function to the internal C API. This function is no longer exported.
1 parent 612e422 commit ca219f6
Copy full SHA for ca219f6

File tree

Expand file treeCollapse file tree

5 files changed

+52
-42
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+52
-42
lines changed

‎Include/complexobject.h

Copy file name to clipboardExpand all lines: Include/complexobject.h
+3-42Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,22 @@
66
extern "C" {
77
#endif
88

9-
#ifndef Py_LIMITED_API
10-
typedef struct {
11-
double real;
12-
double imag;
13-
} Py_complex;
14-
15-
/* Operations on complex numbers from complexmodule.c */
16-
17-
PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
18-
PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
19-
PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
20-
PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
21-
PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
22-
PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
23-
PyAPI_FUNC(double) _Py_c_abs(Py_complex);
24-
#endif
25-
269
/* Complex object interface */
2710

28-
/*
29-
PyComplexObject represents a complex number with double-precision
30-
real and imaginary parts.
31-
*/
32-
#ifndef Py_LIMITED_API
33-
typedef struct {
34-
PyObject_HEAD
35-
Py_complex cval;
36-
} PyComplexObject;
37-
#endif
38-
3911
PyAPI_DATA(PyTypeObject) PyComplex_Type;
4012

4113
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
4214
#define PyComplex_CheckExact(op) Py_IS_TYPE(op, &PyComplex_Type)
4315

44-
#ifndef Py_LIMITED_API
45-
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
46-
#endif
4716
PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
4817

4918
PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
5019
PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
51-
#ifndef Py_LIMITED_API
52-
PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
53-
#endif
5420

55-
/* Format the object based on the format_spec, as defined in PEP 3101
56-
(Advanced String Formatting). */
5721
#ifndef Py_LIMITED_API
58-
PyAPI_FUNC(int) _PyComplex_FormatAdvancedWriter(
59-
_PyUnicodeWriter *writer,
60-
PyObject *obj,
61-
PyObject *format_spec,
62-
Py_ssize_t start,
63-
Py_ssize_t end);
22+
# define Py_CPYTHON_COMPLEXOBJECT_H
23+
# include "cpython/complexobject.h"
24+
# undef Py_CPYTHON_COMPLEXOBJECT_H
6425
#endif
6526

6627
#ifdef __cplusplus

‎Include/cpython/complexobject.h

Copy file name to clipboard
+44Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#ifndef Py_CPYTHON_COMPLEXOBJECT_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
typedef struct {
6+
double real;
7+
double imag;
8+
} Py_complex;
9+
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+
20+
/* Complex object interface */
21+
22+
/*
23+
PyComplexObject represents a complex number with double-precision
24+
real and imaginary parts.
25+
*/
26+
typedef struct {
27+
PyObject_HEAD
28+
Py_complex cval;
29+
} PyComplexObject;
30+
31+
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
32+
33+
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

‎Makefile.pre.in

Copy file name to clipboardExpand all lines: Makefile.pre.in
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,7 @@ PYTHON_HEADERS= \
15221522
$(srcdir)/Include/cpython/classobject.h \
15231523
$(srcdir)/Include/cpython/code.h \
15241524
$(srcdir)/Include/cpython/compile.h \
1525+
$(srcdir)/Include/cpython/complexobject.h \
15251526
$(srcdir)/Include/cpython/context.h \
15261527
$(srcdir)/Include/cpython/descrobject.h \
15271528
$(srcdir)/Include/cpython/dictobject.h \

‎PCbuild/pythoncore.vcxproj

Copy file name to clipboardExpand all lines: PCbuild/pythoncore.vcxproj
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
<ClInclude Include="..\Include\cpython\classobject.h" />
142142
<ClInclude Include="..\Include\cpython\code.h" />
143143
<ClInclude Include="..\Include\cpython\compile.h" />
144+
<ClInclude Include="..\Include\cpython\complexobject.h" />
144145
<ClInclude Include="..\Include\cpython\context.h" />
145146
<ClInclude Include="..\Include\cpython\descrobject.h" />
146147
<ClInclude Include="..\Include\cpython\dictobject.h" />

‎PCbuild/pythoncore.vcxproj.filters

Copy file name to clipboardExpand all lines: PCbuild/pythoncore.vcxproj.filters
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@
357357
<ClInclude Include="..\Include\cpython\compile.h">
358358
<Filter>Include</Filter>
359359
</ClInclude>
360+
<ClInclude Include="..\Include\cpython\complexobject.h">
361+
<Filter>Include</Filter>
362+
</ClInclude>
360363
<ClInclude Include="..\Include\cpython\context.h">
361364
<Filter>Include\cpython</Filter>
362365
</ClInclude>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.