2001-09-20 18:45:26 -03:00
|
|
|
/* Descriptors */
|
2002-03-30 04:57:12 -04:00
|
|
|
#ifndef Py_DESCROBJECT_H
|
|
|
|
#define Py_DESCROBJECT_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2001-08-02 01:15:00 -03:00
|
|
|
|
|
|
|
typedef PyObject *(*getter)(PyObject *, void *);
|
|
|
|
typedef int (*setter)(PyObject *, PyObject *, void *);
|
|
|
|
|
2022-02-24 12:07:12 -04:00
|
|
|
struct PyGetSetDef {
|
2016-11-22 01:58:08 -04:00
|
|
|
const char *name;
|
2010-05-09 12:52:27 -03:00
|
|
|
getter get;
|
|
|
|
setter set;
|
2016-11-22 01:58:08 -04:00
|
|
|
const char *doc;
|
2010-05-09 12:52:27 -03:00
|
|
|
void *closure;
|
2022-02-24 12:07:12 -04:00
|
|
|
};
|
2001-08-02 01:15:00 -03:00
|
|
|
|
2007-11-29 18:35:39 -04:00
|
|
|
PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
|
|
|
|
PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
|
|
|
|
PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
|
|
|
|
PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
|
2007-11-29 18:35:39 -04:00
|
|
|
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
|
2022-01-26 12:32:47 -04:00
|
|
|
PyAPI_DATA(PyTypeObject) PyProperty_Type;
|
2001-10-03 09:09:30 -03:00
|
|
|
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
|
2002-12-09 18:56:13 -04:00
|
|
|
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
|
2022-02-24 12:51:59 -04:00
|
|
|
PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, PyMemberDef *);
|
|
|
|
PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, PyGetSetDef *);
|
2001-08-02 01:15:00 -03:00
|
|
|
|
2002-08-12 04:21:58 -03:00
|
|
|
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
|
|
|
|
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
|
2001-08-23 18:40:38 -03:00
|
|
|
|
gh-47146: Soft-deprecate structmember.h, expose its contents via Python.h (GH-99014)
The ``structmember.h`` header is deprecated, though it continues to be available
and there are no plans to remove it. There are no deprecation warnings. Old code
can stay unchanged (unless the extra include and non-namespaced macros bother
you greatly). Specifically, no uses in CPython are updated -- that would just be
unnecessary churn.
The ``structmember.h`` header is deprecated, though it continues to be
available and there are no plans to remove it.
Its contents are now available just by including ``Python.h``,
with a ``Py`` prefix added if it was missing:
- `PyMemberDef`, `PyMember_GetOne` and`PyMember_SetOne`
- Type macros like `Py_T_INT`, `Py_T_DOUBLE`, etc.
(previously ``T_INT``, ``T_DOUBLE``, etc.)
- The flags `Py_READONLY` (previously ``READONLY``) and
`Py_AUDIT_READ` (previously all uppercase)
Several items are not exposed from ``Python.h``:
- `T_OBJECT` (use `Py_T_OBJECT_EX`)
- `T_NONE` (previously undocumented, and pretty quirky)
- The macro ``WRITE_RESTRICTED`` which does nothing.
- The macros ``RESTRICTED`` and ``READ_RESTRICTED``, equivalents of
`Py_AUDIT_READ`.
- In some configurations, ``<stddef.h>`` is not included from ``Python.h``.
It should be included manually when using ``offsetof()``.
The deprecated header continues to provide its original
contents under the original names.
Your old code can stay unchanged, unless the extra include and non-namespaced
macros bother you greatly.
There is discussion on the issue to rename `T_PYSSIZET` to `PY_T_SSIZE` or
similar. I chose not to do that -- users will probably copy/paste that with any
spelling, and not renaming it makes migration docs simpler.
Co-Authored-By: Alexander Belopolsky <abalkin@users.noreply.github.com>
Co-Authored-By: Matthias Braun <MatzeB@users.noreply.github.com>
2022-11-22 03:25:43 -04:00
|
|
|
|
|
|
|
/* An array of PyMemberDef structures defines the name, type and offset
|
|
|
|
of selected members of a C structure. These can be read by
|
|
|
|
PyMember_GetOne() and set by PyMember_SetOne() (except if their READONLY
|
|
|
|
flag is set). The array must be terminated with an entry whose name
|
|
|
|
pointer is NULL. */
|
|
|
|
struct PyMemberDef {
|
|
|
|
const char *name;
|
|
|
|
int type;
|
|
|
|
Py_ssize_t offset;
|
|
|
|
int flags;
|
|
|
|
const char *doc;
|
|
|
|
};
|
|
|
|
|
|
|
|
// These constants used to be in structmember.h, not prefixed by Py_.
|
|
|
|
// (structmember.h now has aliases to the new names.)
|
|
|
|
|
|
|
|
/* Types */
|
|
|
|
#define Py_T_SHORT 0
|
|
|
|
#define Py_T_INT 1
|
|
|
|
#define Py_T_LONG 2
|
|
|
|
#define Py_T_FLOAT 3
|
|
|
|
#define Py_T_DOUBLE 4
|
|
|
|
#define Py_T_STRING 5
|
|
|
|
#define _Py_T_OBJECT 6 // Deprecated, use Py_T_OBJECT_EX instead
|
|
|
|
/* the ordering here is weird for binary compatibility */
|
|
|
|
#define Py_T_CHAR 7 /* 1-character string */
|
|
|
|
#define Py_T_BYTE 8 /* 8-bit signed int */
|
|
|
|
/* unsigned variants: */
|
|
|
|
#define Py_T_UBYTE 9
|
|
|
|
#define Py_T_USHORT 10
|
|
|
|
#define Py_T_UINT 11
|
|
|
|
#define Py_T_ULONG 12
|
|
|
|
|
|
|
|
/* Added by Jack: strings contained in the structure */
|
|
|
|
#define Py_T_STRING_INPLACE 13
|
|
|
|
|
|
|
|
/* Added by Lillo: bools contained in the structure (assumed char) */
|
|
|
|
#define Py_T_BOOL 14
|
|
|
|
|
|
|
|
#define Py_T_OBJECT_EX 16
|
|
|
|
#define Py_T_LONGLONG 17
|
|
|
|
#define Py_T_ULONGLONG 18
|
|
|
|
|
|
|
|
#define Py_T_PYSSIZET 19 /* Py_ssize_t */
|
|
|
|
#define _Py_T_NONE 20 // Deprecated. Value is always None.
|
|
|
|
|
|
|
|
/* Flags */
|
|
|
|
#define Py_READONLY 1
|
|
|
|
#define Py_AUDIT_READ 2 // Added in 3.10, harmless no-op before that
|
|
|
|
#define _Py_WRITE_RESTRICTED 4 // Deprecated, no-op. Do not reuse the value.
|
2023-05-04 04:56:53 -03:00
|
|
|
#define Py_RELATIVE_OFFSET 8
|
gh-47146: Soft-deprecate structmember.h, expose its contents via Python.h (GH-99014)
The ``structmember.h`` header is deprecated, though it continues to be available
and there are no plans to remove it. There are no deprecation warnings. Old code
can stay unchanged (unless the extra include and non-namespaced macros bother
you greatly). Specifically, no uses in CPython are updated -- that would just be
unnecessary churn.
The ``structmember.h`` header is deprecated, though it continues to be
available and there are no plans to remove it.
Its contents are now available just by including ``Python.h``,
with a ``Py`` prefix added if it was missing:
- `PyMemberDef`, `PyMember_GetOne` and`PyMember_SetOne`
- Type macros like `Py_T_INT`, `Py_T_DOUBLE`, etc.
(previously ``T_INT``, ``T_DOUBLE``, etc.)
- The flags `Py_READONLY` (previously ``READONLY``) and
`Py_AUDIT_READ` (previously all uppercase)
Several items are not exposed from ``Python.h``:
- `T_OBJECT` (use `Py_T_OBJECT_EX`)
- `T_NONE` (previously undocumented, and pretty quirky)
- The macro ``WRITE_RESTRICTED`` which does nothing.
- The macros ``RESTRICTED`` and ``READ_RESTRICTED``, equivalents of
`Py_AUDIT_READ`.
- In some configurations, ``<stddef.h>`` is not included from ``Python.h``.
It should be included manually when using ``offsetof()``.
The deprecated header continues to provide its original
contents under the original names.
Your old code can stay unchanged, unless the extra include and non-namespaced
macros bother you greatly.
There is discussion on the issue to rename `T_PYSSIZET` to `PY_T_SSIZE` or
similar. I chose not to do that -- users will probably copy/paste that with any
spelling, and not renaming it makes migration docs simpler.
Co-Authored-By: Alexander Belopolsky <abalkin@users.noreply.github.com>
Co-Authored-By: Matthias Braun <MatzeB@users.noreply.github.com>
2022-11-22 03:25:43 -04:00
|
|
|
|
|
|
|
PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, PyMemberDef *);
|
|
|
|
PyAPI_FUNC(int) PyMember_SetOne(char *, PyMemberDef *, PyObject *);
|
|
|
|
|
2022-01-26 12:32:47 -04:00
|
|
|
#ifndef Py_LIMITED_API
|
|
|
|
# define Py_CPYTHON_DESCROBJECT_H
|
|
|
|
# include "cpython/descrobject.h"
|
|
|
|
# undef Py_CPYTHON_DESCROBJECT_H
|
|
|
|
#endif
|
2001-08-23 18:40:38 -03:00
|
|
|
|
2002-03-30 04:57:12 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !Py_DESCROBJECT_H */
|