summaryrefslogtreecommitdiffstats
path: root/Include/cpython
diff options
context:
space:
mode:
authorNicholas Sim <nsim@posteo.net>2021-02-19 14:55:46 (GMT)
committerGitHub <noreply@github.com>2021-02-19 14:55:46 (GMT)
commit4a6bf276ed3e6687394afe26b0d9a061ac06fc6b (patch)
tree249bba20a6ee0ca4ae9b2a1661a12443370e5e46 /Include/cpython
parent839184f85cb2d2ad514fff9b431733d1c9607533 (diff)
downloadcpython-4a6bf276ed3e6687394afe26b0d9a061ac06fc6b.zip
cpython-4a6bf276ed3e6687394afe26b0d9a061ac06fc6b.tar.gz
cpython-4a6bf276ed3e6687394afe26b0d9a061ac06fc6b.tar.bz2
bpo-35134: Move non-limited C API files to Include/cpython/ (GH-24561)
Include/{odictobject.h,parser_interface.h,picklebufobject.h,pydebug.h,pyfpe.h} into Include/cpython/. Parser: peg_api: include Python.h instead of parser_interface.h.
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/odictobject.h43
-rw-r--r--Include/cpython/parser_interface.h52
-rw-r--r--Include/cpython/picklebufobject.h31
-rw-r--r--Include/cpython/pydebug.h38
-rw-r--r--Include/cpython/pyfpe.h15
5 files changed, 179 insertions, 0 deletions
diff --git a/Include/cpython/odictobject.h b/Include/cpython/odictobject.h
new file mode 100644
index 0000000..e070413
--- /dev/null
+++ b/Include/cpython/odictobject.h
@@ -0,0 +1,43 @@
+#ifndef Py_ODICTOBJECT_H
+#define Py_ODICTOBJECT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* OrderedDict */
+/* This API is optional and mostly redundant. */
+
+#ifndef Py_LIMITED_API
+
+typedef struct _odictobject PyODictObject;
+
+PyAPI_DATA(PyTypeObject) PyODict_Type;
+PyAPI_DATA(PyTypeObject) PyODictIter_Type;
+PyAPI_DATA(PyTypeObject) PyODictKeys_Type;
+PyAPI_DATA(PyTypeObject) PyODictItems_Type;
+PyAPI_DATA(PyTypeObject) PyODictValues_Type;
+
+#define PyODict_Check(op) PyObject_TypeCheck(op, &PyODict_Type)
+#define PyODict_CheckExact(op) Py_IS_TYPE(op, &PyODict_Type)
+#define PyODict_SIZE(op) PyDict_GET_SIZE((op))
+
+PyAPI_FUNC(PyObject *) PyODict_New(void);
+PyAPI_FUNC(int) PyODict_SetItem(PyObject *od, PyObject *key, PyObject *item);
+PyAPI_FUNC(int) PyODict_DelItem(PyObject *od, PyObject *key);
+
+/* wrappers around PyDict* functions */
+#define PyODict_GetItem(od, key) PyDict_GetItem(_PyObject_CAST(od), key)
+#define PyODict_GetItemWithError(od, key) \
+ PyDict_GetItemWithError(_PyObject_CAST(od), key)
+#define PyODict_Contains(od, key) PyDict_Contains(_PyObject_CAST(od), key)
+#define PyODict_Size(od) PyDict_Size(_PyObject_CAST(od))
+#define PyODict_GetItemString(od, key) \
+ PyDict_GetItemString(_PyObject_CAST(od), key)
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_ODICTOBJECT_H */
diff --git a/Include/cpython/parser_interface.h b/Include/cpython/parser_interface.h
new file mode 100644
index 0000000..1c6576d
--- /dev/null
+++ b/Include/cpython/parser_interface.h
@@ -0,0 +1,52 @@
+#ifndef Py_PEGENINTERFACE
+#define Py_PEGENINTERFACE
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "Python.h"
+
+#ifndef Py_LIMITED_API
+PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(
+ const char *str,
+ const char *filename,
+ int mode,
+ PyCompilerFlags *flags,
+ PyArena *arena);
+PyAPI_FUNC(struct _mod *) PyParser_ASTFromStringObject(
+ const char *str,
+ PyObject* filename,
+ int mode,
+ PyCompilerFlags *flags,
+ PyArena *arena);
+PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(
+ FILE *fp,
+ const char *filename,
+ const char* enc,
+ int mode,
+ const char *ps1,
+ const char *ps2,
+ PyCompilerFlags *flags,
+ int *errcode,
+ PyArena *arena);
+PyAPI_FUNC(struct _mod *) PyParser_ASTFromFileObject(
+ FILE *fp,
+ PyObject *filename_ob,
+ const char *enc,
+ int mode,
+ const char *ps1,
+ const char *ps2,
+ PyCompilerFlags *flags,
+ int *errcode,
+ PyArena *arena);
+PyAPI_FUNC(struct _mod *) PyParser_ASTFromFilename(
+ const char *filename,
+ int mode,
+ PyCompilerFlags *flags,
+ PyArena *arena);
+#endif /* !Py_LIMITED_API */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_PEGENINTERFACE */
diff --git a/Include/cpython/picklebufobject.h b/Include/cpython/picklebufobject.h
new file mode 100644
index 0000000..0df2561
--- /dev/null
+++ b/Include/cpython/picklebufobject.h
@@ -0,0 +1,31 @@
+/* PickleBuffer object. This is built-in for ease of use from third-party
+ * C extensions.
+ */
+
+#ifndef Py_PICKLEBUFOBJECT_H
+#define Py_PICKLEBUFOBJECT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef Py_LIMITED_API
+
+PyAPI_DATA(PyTypeObject) PyPickleBuffer_Type;
+
+#define PyPickleBuffer_Check(op) Py_IS_TYPE(op, &PyPickleBuffer_Type)
+
+/* Create a PickleBuffer redirecting to the given buffer-enabled object */
+PyAPI_FUNC(PyObject *) PyPickleBuffer_FromObject(PyObject *);
+/* Get the PickleBuffer's underlying view to the original object
+ * (NULL if released)
+ */
+PyAPI_FUNC(const Py_buffer *) PyPickleBuffer_GetBuffer(PyObject *);
+/* Release the PickleBuffer. Returns 0 on success, -1 on error. */
+PyAPI_FUNC(int) PyPickleBuffer_Release(PyObject *);
+
+#endif /* !Py_LIMITED_API */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_PICKLEBUFOBJECT_H */
diff --git a/Include/cpython/pydebug.h b/Include/cpython/pydebug.h
new file mode 100644
index 0000000..78bcb11
--- /dev/null
+++ b/Include/cpython/pydebug.h
@@ -0,0 +1,38 @@
+#ifndef Py_LIMITED_API
+#ifndef Py_PYDEBUG_H
+#define Py_PYDEBUG_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+PyAPI_DATA(int) Py_DebugFlag;
+PyAPI_DATA(int) Py_VerboseFlag;
+PyAPI_DATA(int) Py_QuietFlag;
+PyAPI_DATA(int) Py_InteractiveFlag;
+PyAPI_DATA(int) Py_InspectFlag;
+PyAPI_DATA(int) Py_OptimizeFlag;
+PyAPI_DATA(int) Py_NoSiteFlag;
+PyAPI_DATA(int) Py_BytesWarningFlag;
+PyAPI_DATA(int) Py_FrozenFlag;
+PyAPI_DATA(int) Py_IgnoreEnvironmentFlag;
+PyAPI_DATA(int) Py_DontWriteBytecodeFlag;
+PyAPI_DATA(int) Py_NoUserSiteDirectory;
+PyAPI_DATA(int) Py_UnbufferedStdioFlag;
+PyAPI_DATA(int) Py_HashRandomizationFlag;
+PyAPI_DATA(int) Py_IsolatedFlag;
+
+#ifdef MS_WINDOWS
+PyAPI_DATA(int) Py_LegacyWindowsFSEncodingFlag;
+PyAPI_DATA(int) Py_LegacyWindowsStdioFlag;
+#endif
+
+/* this is a wrapper around getenv() that pays attention to
+ Py_IgnoreEnvironmentFlag. It should be used for getting variables like
+ PYTHONPATH and PYTHONHOME from the environment */
+#define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s))
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_PYDEBUG_H */
+#endif /* Py_LIMITED_API */
diff --git a/Include/cpython/pyfpe.h b/Include/cpython/pyfpe.h
new file mode 100644
index 0000000..cc2def6
--- /dev/null
+++ b/Include/cpython/pyfpe.h
@@ -0,0 +1,15 @@
+#ifndef Py_PYFPE_H
+#define Py_PYFPE_H
+/* Header excluded from the stable API */
+#ifndef Py_LIMITED_API
+
+/* These macros used to do something when Python was built with --with-fpectl,
+ * but support for that was dropped in 3.7. We continue to define them though,
+ * to avoid breaking API users.
+ */
+
+#define PyFPE_START_PROTECT(err_string, leave_stmt)
+#define PyFPE_END_PROTECT(v)
+
+#endif /* !defined(Py_LIMITED_API) */
+#endif /* !Py_PYFPE_H */