@@ -15,7 +15,39 @@ pub unsafe fn PyCFunction_Check(op: *mut PyObject) -> c_int {
15
15
pub type PyCFunction =
16
16
unsafe extern "C" fn ( slf : * mut PyObject , args : * mut PyObject ) -> * mut PyObject ;
17
17
18
- #[ cfg( all( Py_3_6 , not( Py_LIMITED_API ) ) ) ]
18
+ #[ cfg( all( Py_3_8 , not( Py_LIMITED_API ) ) ) ]
19
+ #[ cfg_attr( Py_3_8 , link_name = "_PyObject_Vectorcall" ) ]
20
+ pub type PyObject_Vectorcall = unsafe extern "C" fn (
21
+ slf : * mut PyObject ,
22
+ // positional and keyword arguments
23
+ args : * const * mut PyObject ,
24
+ // number of position arguments in args, after which values are kwargs
25
+ nargs : crate :: ffi:: pyport:: Py_ssize_t ,
26
+ // tuple of kwargs, if given, or null
27
+ kwnames : * mut PyObject ,
28
+ ) -> * mut PyObject ;
29
+
30
+ #[ cfg( all( Py_3_8 , not( Py_LIMITED_API ) ) ) ]
31
+ #[ cfg_attr( Py_3_8 , link_name = "PyVectorcall_Call" ) ]
32
+ pub type PyVectorcall_Call = unsafe extern "C" fn (
33
+ obj : * mut PyObject ,
34
+ tuple : * mut PyObject ,
35
+ dict : * mut PyObject ,
36
+ ) -> * mut PyObject ;
37
+
38
+ #[ cfg( all( Py_3_7 , not( Py_LIMITED_API ) ) ) ]
39
+ const PY_VECTORCALL_ARGUMENTS_OFFSET : crate :: ffi:: pyport:: Py_ssize_t =
40
+ 1 << ( 8 * std:: mem:: size_of :: < usize > ( ) - 1 ) ;
41
+
42
+ #[ cfg( all( Py_3_7 , not( Py_LIMITED_API ) ) ) ]
43
+ #[ inline( always) ]
44
+ pub unsafe fn PyVectorcall_NARGS (
45
+ n : crate :: ffi:: pyport:: Py_ssize_t ,
46
+ ) -> crate :: ffi:: pyport:: Py_ssize_t {
47
+ n & !PY_VECTORCALL_ARGUMENTS_OFFSET
48
+ }
49
+
50
+ #[ cfg( all( Py_3_7 , not( Py_LIMITED_API ) ) ) ]
19
51
pub type _PyCFunctionFast = unsafe extern "C" fn (
20
52
slf : * mut PyObject ,
21
53
args : * mut * mut PyObject ,
@@ -102,8 +134,10 @@ slot like sq_contains. */
102
134
103
135
pub const METH_COEXIST : c_int = 0x0040 ;
104
136
105
- #[ cfg( all( Py_3_6 , not( Py_LIMITED_API ) ) ) ]
106
- pub const METHOD_FASTCALL : c_int = 0x0080 ;
137
+ /* METH_FASTCALL indicates the PEP 590 Vectorcall calling format. It may
138
+ be specified alone or with METH_KEYWORDS. */
139
+ #[ cfg( all( Py_3_7 , not( Py_LIMITED_API ) ) ) ]
140
+ pub const METH_FASTCALL : c_int = 0x0080 ;
107
141
108
142
#[ cfg_attr( windows, link( name = "pythonXY" ) ) ]
109
143
extern "C" {
0 commit comments