From e281f7d80ce2584a7e6a36acffb5a9cd796a0fe2 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 1 Nov 2018 02:30:36 +0100 Subject: bpo-35081: Move accu.h to Include/internal/pycore_accu.h (GH-10271) The accu.h header is no longer part of the Python C API: it has been moved to the "internal" headers which are restricted to Python itself. Replace #include "accu.h" with #include "pycore_accu.h". --- Include/accu.h | 37 ------------------------------------- Include/internal/pycore_accu.h | 35 +++++++++++++++++++++++++++++++++++ Makefile.pre.in | 2 +- Modules/_io/stringio.c | 2 +- Modules/_json.c | 2 +- Objects/accu.c | 2 +- Objects/listobject.c | 2 +- Objects/tupleobject.c | 2 +- PCbuild/pythoncore.vcxproj | 3 +-- PCbuild/pythoncore.vcxproj.filters | 6 +++--- 10 files changed, 45 insertions(+), 48 deletions(-) delete mode 100644 Include/accu.h create mode 100644 Include/internal/pycore_accu.h diff --git a/Include/accu.h b/Include/accu.h deleted file mode 100644 index 3636ea6..0000000 --- a/Include/accu.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef Py_LIMITED_API -#ifndef Py_ACCU_H -#define Py_ACCU_H - -/*** This is a private API for use by the interpreter and the stdlib. - *** Its definition may be changed or removed at any moment. - ***/ - -/* - * A two-level accumulator of unicode objects that avoids both the overhead - * of keeping a huge number of small separate objects, and the quadratic - * behaviour of using a naive repeated concatenation scheme. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#undef small /* defined by some Windows headers */ - -typedef struct { - PyObject *large; /* A list of previously accumulated large strings */ - PyObject *small; /* Pending small strings */ -} _PyAccu; - -PyAPI_FUNC(int) _PyAccu_Init(_PyAccu *acc); -PyAPI_FUNC(int) _PyAccu_Accumulate(_PyAccu *acc, PyObject *unicode); -PyAPI_FUNC(PyObject *) _PyAccu_FinishAsList(_PyAccu *acc); -PyAPI_FUNC(PyObject *) _PyAccu_Finish(_PyAccu *acc); -PyAPI_FUNC(void) _PyAccu_Destroy(_PyAccu *acc); - -#ifdef __cplusplus -} -#endif - -#endif /* Py_ACCU_H */ -#endif /* Py_LIMITED_API */ diff --git a/Include/internal/pycore_accu.h b/Include/internal/pycore_accu.h new file mode 100644 index 0000000..ab1aad2 --- /dev/null +++ b/Include/internal/pycore_accu.h @@ -0,0 +1,35 @@ +#ifndef Py_LIMITED_API +#ifndef Py_INTERNAL_ACCU_H +#define Py_INTERNAL_ACCU_H +#ifdef __cplusplus +extern "C" { +#endif + +/*** This is a private API for use by the interpreter and the stdlib. + *** Its definition may be changed or removed at any moment. + ***/ + +/* + * A two-level accumulator of unicode objects that avoids both the overhead + * of keeping a huge number of small separate objects, and the quadratic + * behaviour of using a naive repeated concatenation scheme. + */ + +#undef small /* defined by some Windows headers */ + +typedef struct { + PyObject *large; /* A list of previously accumulated large strings */ + PyObject *small; /* Pending small strings */ +} _PyAccu; + +PyAPI_FUNC(int) _PyAccu_Init(_PyAccu *acc); +PyAPI_FUNC(int) _PyAccu_Accumulate(_PyAccu *acc, PyObject *unicode); +PyAPI_FUNC(PyObject *) _PyAccu_FinishAsList(_PyAccu *acc); +PyAPI_FUNC(PyObject *) _PyAccu_Finish(_PyAccu *acc); +PyAPI_FUNC(void) _PyAccu_Destroy(_PyAccu *acc); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTERNAL_ACCU_H */ +#endif /* !Py_LIMITED_API */ diff --git a/Makefile.pre.in b/Makefile.pre.in index 0336290..fc8b1e4 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -935,7 +935,6 @@ regen-typeslots: PYTHON_HEADERS= \ $(srcdir)/Include/Python.h \ $(srcdir)/Include/abstract.h \ - $(srcdir)/Include/accu.h \ $(srcdir)/Include/asdl.h \ $(srcdir)/Include/ast.h \ $(srcdir)/Include/bltinmodule.h \ @@ -1025,6 +1024,7 @@ PYTHON_HEADERS= \ pyconfig.h \ $(PARSER_HEADERS) \ $(srcdir)/Include/Python-ast.h \ + $(srcdir)/Include/internal/pycore_accu.h \ $(srcdir)/Include/internal/pycore_atomic.h \ $(srcdir)/Include/internal/pycore_ceval.h \ $(srcdir)/Include/internal/pycore_context.h \ diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c index 5a03715..793fa1e 100644 --- a/Modules/_io/stringio.c +++ b/Modules/_io/stringio.c @@ -1,7 +1,7 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" #include "structmember.h" -#include "accu.h" +#include "pycore_accu.h" #include "_iomodule.h" /* Implementation note: the buffer is always at least one character longer diff --git a/Modules/_json.c b/Modules/_json.c index ac6e017..53e1e88 100644 --- a/Modules/_json.c +++ b/Modules/_json.c @@ -7,7 +7,7 @@ #include "Python.h" #include "structmember.h" -#include "accu.h" +#include "pycore_accu.h" #ifdef __GNUC__ #define UNUSED __attribute__((__unused__)) diff --git a/Objects/accu.c b/Objects/accu.c index 48fe02d..c8b5d38 100644 --- a/Objects/accu.c +++ b/Objects/accu.c @@ -1,7 +1,7 @@ /* Accumulator struct implementation */ #include "Python.h" -#include "accu.h" +#include "pycore_accu.h" static PyObject * join_list_unicode(PyObject *lst) diff --git a/Objects/listobject.c b/Objects/listobject.c index e38b21f..ffd91a6 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2,7 +2,7 @@ #include "Python.h" #include "pycore_state.h" -#include "accu.h" +#include "pycore_accu.h" #ifdef STDC_HEADERS #include diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index cce266f..c997bc6 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -3,7 +3,7 @@ #include "Python.h" #include "pycore_state.h" -#include "accu.h" +#include "pycore_accu.h" /*[clinic input] class tuple "PyTupleObject *" "&PyTuple_Type" diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index ebc35a7..6becb8a 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -79,7 +79,6 @@ - @@ -112,6 +111,7 @@ + @@ -154,7 +154,6 @@ - diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 052c89c..bc118c6 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -36,9 +36,6 @@ Include - - Include - Include @@ -135,6 +132,9 @@ Include + + Include + Include -- cgit v0.12