Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit55bad19

Browse files
authored
gh-79315: Add Include/cpython/memoryobject.h header (#99723)
Move non-limited C API from Include/memoryobject.h to a newInclude/cpython/memoryobject.h header file.
1 parent81f7359 commit55bad19

File tree

5 files changed

+50
-41
lines changed

5 files changed

+50
-41
lines changed

‎Include/cpython/memoryobject.h‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#ifndefPy_CPYTHON_MEMORYOBJECT_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
PyAPI_DATA(PyTypeObject)_PyManagedBuffer_Type;
6+
7+
/* The structs are declared here so that macros can work, but they shouldn't
8+
be considered public. Don't access their fields directly, use the macros
9+
and functions instead! */
10+
#define_Py_MANAGED_BUFFER_RELEASED 0x001/* access to exporter blocked */
11+
#define_Py_MANAGED_BUFFER_FREE_FORMAT 0x002/* free format */
12+
13+
typedefstruct {
14+
PyObject_HEAD
15+
intflags;/* state flags */
16+
Py_ssize_texports;/* number of direct memoryview exports */
17+
Py_buffermaster;/* snapshot buffer obtained from the original exporter */
18+
}_PyManagedBufferObject;
19+
20+
21+
/* memoryview state flags */
22+
#define_Py_MEMORYVIEW_RELEASED 0x001/* access to master buffer blocked */
23+
#define_Py_MEMORYVIEW_C 0x002/* C-contiguous layout */
24+
#define_Py_MEMORYVIEW_FORTRAN 0x004/* Fortran contiguous layout */
25+
#define_Py_MEMORYVIEW_SCALAR 0x008/* scalar: ndim = 0 */
26+
#define_Py_MEMORYVIEW_PIL 0x010/* PIL-style layout */
27+
28+
typedefstruct {
29+
PyObject_VAR_HEAD
30+
_PyManagedBufferObject*mbuf;/* managed buffer */
31+
Py_hash_thash;/* hash value for read-only views */
32+
intflags;/* state flags */
33+
Py_ssize_texports;/* number of buffer re-exports */
34+
Py_bufferview;/* private copy of the exporter's view */
35+
PyObject*weakreflist;
36+
Py_ssize_tob_array[1];/* shape, strides, suboffsets */
37+
}PyMemoryViewObject;
38+
39+
/* Get a pointer to the memoryview's private copy of the exporter's buffer. */
40+
#definePyMemoryView_GET_BUFFER(op) (&((PyMemoryViewObject *)(op))->view)
41+
/* Get a pointer to the exporting object (this may be NULL!). */
42+
#definePyMemoryView_GET_BASE(op) (((PyMemoryViewObject *)(op))->view.obj)

‎Include/memoryobject.h‎

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,10 @@
66
extern"C" {
77
#endif
88

9-
#ifndefPy_LIMITED_API
10-
PyAPI_DATA(PyTypeObject)_PyManagedBuffer_Type;
11-
#endif
129
PyAPI_DATA(PyTypeObject)PyMemoryView_Type;
1310

1411
#definePyMemoryView_Check(op) Py_IS_TYPE((op), &PyMemoryView_Type)
1512

16-
#ifndefPy_LIMITED_API
17-
/* Get a pointer to the memoryview's private copy of the exporter's buffer. */
18-
#definePyMemoryView_GET_BUFFER(op) (&((PyMemoryViewObject *)(op))->view)
19-
/* Get a pointer to the exporting object (this may be NULL!). */
20-
#definePyMemoryView_GET_BASE(op) (((PyMemoryViewObject *)(op))->view.obj)
21-
#endif
22-
2313
PyAPI_FUNC(PyObject*)PyMemoryView_FromObject(PyObject*base);
2414
#if !defined(Py_LIMITED_API)||Py_LIMITED_API+0 >=0x03030000
2515
PyAPI_FUNC(PyObject*)PyMemoryView_FromMemory(char*mem,Py_ssize_tsize,
@@ -32,38 +22,10 @@ PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base,
3222
intbuffertype,
3323
charorder);
3424

35-
36-
/* The structs are declared here so that macros can work, but they shouldn't
37-
be considered public. Don't access their fields directly, use the macros
38-
and functions instead! */
3925
#ifndefPy_LIMITED_API
40-
#define_Py_MANAGED_BUFFER_RELEASED 0x001/* access to exporter blocked */
41-
#define_Py_MANAGED_BUFFER_FREE_FORMAT 0x002/* free format */
42-
typedefstruct {
43-
PyObject_HEAD
44-
intflags;/* state flags */
45-
Py_ssize_texports;/* number of direct memoryview exports */
46-
Py_buffermaster;/* snapshot buffer obtained from the original exporter */
47-
}_PyManagedBufferObject;
48-
49-
50-
/* memoryview state flags */
51-
#define_Py_MEMORYVIEW_RELEASED 0x001/* access to master buffer blocked */
52-
#define_Py_MEMORYVIEW_C 0x002/* C-contiguous layout */
53-
#define_Py_MEMORYVIEW_FORTRAN 0x004/* Fortran contiguous layout */
54-
#define_Py_MEMORYVIEW_SCALAR 0x008/* scalar: ndim = 0 */
55-
#define_Py_MEMORYVIEW_PIL 0x010/* PIL-style layout */
56-
57-
typedefstruct {
58-
PyObject_VAR_HEAD
59-
_PyManagedBufferObject*mbuf;/* managed buffer */
60-
Py_hash_thash;/* hash value for read-only views */
61-
intflags;/* state flags */
62-
Py_ssize_texports;/* number of buffer re-exports */
63-
Py_bufferview;/* private copy of the exporter's view */
64-
PyObject*weakreflist;
65-
Py_ssize_tob_array[1];/* shape, strides, suboffsets */
66-
}PyMemoryViewObject;
26+
# definePy_CPYTHON_MEMORYOBJECT_H
27+
# include"cpython/memoryobject.h"
28+
# undef Py_CPYTHON_MEMORYOBJECT_H
6729
#endif
6830

6931
#ifdef__cplusplus

‎Makefile.pre.in‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,7 @@ PYTHON_HEADERS= \
15851585
$(srcdir)/Include/cpython/listobject.h \
15861586
$(srcdir)/Include/cpython/longintrepr.h \
15871587
$(srcdir)/Include/cpython/longobject.h \
1588+
$(srcdir)/Include/cpython/memoryobject.h \
15881589
$(srcdir)/Include/cpython/methodobject.h \
15891590
$(srcdir)/Include/cpython/modsupport.h \
15901591
$(srcdir)/Include/cpython/object.h \

‎PCbuild/pythoncore.vcxproj‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
<ClIncludeInclude="..\Include\cpython\listobject.h" />
156156
<ClIncludeInclude="..\Include\cpython\longintrepr.h" />
157157
<ClIncludeInclude="..\Include\cpython\longobject.h" />
158+
<ClIncludeInclude="..\Include\cpython\memoryobject.h" />
158159
<ClIncludeInclude="..\Include\cpython\methodobject.h" />
159160
<ClIncludeInclude="..\Include\cpython\modsupport.h" />
160161
<ClIncludeInclude="..\Include\cpython\object.h" />

‎PCbuild/pythoncore.vcxproj.filters‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@
384384
<ClIncludeInclude="..\Include\cpython\longobject.h">
385385
<Filter>Include</Filter>
386386
</ClInclude>
387+
<ClIncludeInclude="..\Include\cpython\memoryobject.h">
388+
<Filter>Include</Filter>
389+
</ClInclude>
387390
<ClIncludeInclude="..\Include\cpython\odictobject.h">
388391
<Filter>Include</Filter>
389392
</ClInclude>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp