Skip to content

Commit d34ef60

Browse files
committed
remove private _Py symbols from pyo3-ffi
1 parent 144b199 commit d34ef60

35 files changed

+298
-439
lines changed

pyo3-ffi/src/abstract_.rs

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use crate::object::*;
22
use crate::pyport::Py_ssize_t;
3+
#[cfg(any(Py_3_12, all(Py_3_9, not(Py_LIMITED_API))))]
4+
use libc::size_t;
35
use std::os::raw::{c_char, c_int};
46
use std::ptr;
57

@@ -53,22 +55,6 @@ extern "C" {
5355
...
5456
) -> *mut PyObject;
5557

56-
#[cfg(not(Py_3_13))]
57-
#[cfg_attr(PyPy, link_name = "_PyPyObject_CallFunction_SizeT")]
58-
pub fn _PyObject_CallFunction_SizeT(
59-
callable_object: *mut PyObject,
60-
format: *const c_char,
61-
...
62-
) -> *mut PyObject;
63-
#[cfg(not(Py_3_13))]
64-
#[cfg_attr(PyPy, link_name = "_PyPyObject_CallMethod_SizeT")]
65-
pub fn _PyObject_CallMethod_SizeT(
66-
o: *mut PyObject,
67-
method: *const c_char,
68-
format: *const c_char,
69-
...
70-
) -> *mut PyObject;
71-
7258
#[cfg_attr(PyPy, link_name = "PyPyObject_CallFunctionObjArgs")]
7359
pub fn PyObject_CallFunctionObjArgs(callable: *mut PyObject, ...) -> *mut PyObject;
7460
#[cfg_attr(PyPy, link_name = "PyPyObject_CallMethodObjArgs")]
@@ -77,6 +63,41 @@ extern "C" {
7763
method: *mut PyObject,
7864
...
7965
) -> *mut PyObject;
66+
67+
#[cfg(all(Py_3_12, Py_LIMITED_API))] // used as a function on the stable abi
68+
pub fn PyVectorcall_NARGS(nargsf: libc::size_t) -> Py_ssize_t;
69+
70+
#[cfg(any(Py_3_12, all(Py_3_9, not(Py_LIMITED_API))))]
71+
#[cfg_attr(PyPy, link_name = "PyPyVectorcall_Call")]
72+
pub fn PyVectorcall_Call(
73+
callable: *mut PyObject,
74+
tuple: *mut PyObject,
75+
dict: *mut PyObject,
76+
) -> *mut PyObject;
77+
}
78+
79+
#[cfg(Py_3_12)]
80+
pub const PY_VECTORCALL_ARGUMENTS_OFFSET: size_t =
81+
1 << (8 * std::mem::size_of::<size_t>() as size_t - 1);
82+
83+
extern "C" {
84+
#[cfg_attr(Py_3_9, link_name = "PyPyObject_Vectorcall")]
85+
#[cfg(any(Py_3_12, all(Py_3_9, not(Py_LIMITED_API))))]
86+
pub fn PyObject_Vectorcall(
87+
callable: *mut PyObject,
88+
args: *const *mut PyObject,
89+
nargsf: size_t,
90+
kwnames: *mut PyObject,
91+
) -> *mut PyObject;
92+
93+
#[cfg(any(Py_3_12, all(Py_3_9, not(any(Py_LIMITED_API, PyPy, GraalPy)))))]
94+
pub fn PyObject_VectorcallMethod(
95+
name: *mut PyObject,
96+
args: *const *mut PyObject,
97+
nargsf: size_t,
98+
kwnames: *mut PyObject,
99+
) -> *mut PyObject;
100+
80101
#[cfg_attr(PyPy, link_name = "PyPyObject_Type")]
81102
pub fn PyObject_Type(o: *mut PyObject) -> *mut PyObject;
82103
#[cfg_attr(PyPy, link_name = "PyPyObject_Size")]

pyo3-ffi/src/ceval.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ extern "C" {
7070
pub fn Py_SetRecursionLimit(arg1: c_int);
7171
#[cfg_attr(PyPy, link_name = "PyPy_GetRecursionLimit")]
7272
pub fn Py_GetRecursionLimit() -> c_int;
73-
fn _Py_CheckRecursiveCall(_where: *mut c_char) -> c_int;
7473
}
7574

7675
extern "C" {

pyo3-ffi/src/codecs.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use crate::object::PyObject;
22
use std::os::raw::{c_char, c_int};
33

4+
#[cfg_attr(windows, link(name = "pythonXY"))]
45
extern "C" {
56
pub fn PyCodec_Register(search_function: *mut PyObject) -> c_int;
67
#[cfg(Py_3_10)]
78
#[cfg(not(PyPy))]
89
pub fn PyCodec_Unregister(search_function: *mut PyObject) -> c_int;
9-
// skipped non-limited _PyCodec_Lookup from Include/codecs.h
10-
// skipped non-limited _PyCodec_Forget from Include/codecs.h
1110
pub fn PyCodec_KnownEncoding(encoding: *const c_char) -> c_int;
1211
pub fn PyCodec_Encode(
1312
object: *mut PyObject,
@@ -19,11 +18,6 @@ extern "C" {
1918
encoding: *const c_char,
2019
errors: *const c_char,
2120
) -> *mut PyObject;
22-
// skipped non-limited _PyCodec_LookupTextEncoding from Include/codecs.h
23-
// skipped non-limited _PyCodec_EncodeText from Include/codecs.h
24-
// skipped non-limited _PyCodec_DecodeText from Include/codecs.h
25-
// skipped non-limited _PyCodecInfo_GetIncrementalDecoder from Include/codecs.h
26-
// skipped non-limited _PyCodecInfo_GetIncrementalEncoder from Include/codecs.h
2721
pub fn PyCodec_Encoder(encoding: *const c_char) -> *mut PyObject;
2822
pub fn PyCodec_Decoder(encoding: *const c_char) -> *mut PyObject;
2923
#[cfg_attr(PyPy, link_name = "PyPyCodec_IncrementalEncoder")]
@@ -53,6 +47,8 @@ extern "C" {
5347
pub fn PyCodec_ReplaceErrors(exc: *mut PyObject) -> *mut PyObject;
5448
pub fn PyCodec_XMLCharRefReplaceErrors(exc: *mut PyObject) -> *mut PyObject;
5549
pub fn PyCodec_BackslashReplaceErrors(exc: *mut PyObject) -> *mut PyObject;
56-
// skipped non-limited PyCodec_NameReplaceErrors from Include/codecs.h
57-
// skipped non-limited Py_hexdigits from Include/codecs.h
50+
pub fn PyCodec_NameReplaceErrors(exc: *mut PyObject) -> *mut PyObject;
51+
52+
#[cfg(not(Py_LIMITED_API))]
53+
pub static mut Py_hexdigits: *const c_char;
5854
}

pyo3-ffi/src/complexobject.rs

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,6 @@ use crate::object::*;
22
use std::os::raw::{c_double, c_int};
33
use std::ptr::addr_of_mut;
44

5-
#[repr(C)]
6-
#[derive(Copy, Clone)]
7-
// non-limited
8-
pub struct Py_complex {
9-
pub real: c_double,
10-
pub imag: c_double,
11-
}
12-
13-
#[cfg(not(Py_LIMITED_API))]
14-
extern "C" {
15-
pub fn _Py_c_sum(left: Py_complex, right: Py_complex) -> Py_complex;
16-
pub fn _Py_c_diff(left: Py_complex, right: Py_complex) -> Py_complex;
17-
pub fn _Py_c_neg(complex: Py_complex) -> Py_complex;
18-
pub fn _Py_c_prod(left: Py_complex, right: Py_complex) -> Py_complex;
19-
pub fn _Py_c_quot(dividend: Py_complex, divisor: Py_complex) -> Py_complex;
20-
pub fn _Py_c_pow(num: Py_complex, exp: Py_complex) -> Py_complex;
21-
pub fn _Py_c_abs(arg: Py_complex) -> c_double;
22-
#[cfg_attr(PyPy, link_name = "PyPyComplex_FromCComplex")]
23-
pub fn PyComplex_FromCComplex(v: Py_complex) -> *mut PyObject;
24-
#[cfg_attr(PyPy, link_name = "PyPyComplex_AsCComplex")]
25-
pub fn PyComplex_AsCComplex(op: *mut PyObject) -> Py_complex;
26-
}
27-
28-
#[repr(C)]
29-
// non-limited
30-
pub struct PyComplexObject {
31-
pub ob_base: PyObject,
32-
#[cfg(not(GraalPy))]
33-
pub cval: Py_complex,
34-
}
35-
365
#[cfg_attr(windows, link(name = "pythonXY"))]
376
extern "C" {
387
#[cfg_attr(PyPy, link_name = "PyPyComplex_Type")]
@@ -53,10 +22,9 @@ extern "C" {
5322
// skipped non-limited PyComplex_FromCComplex
5423
#[cfg_attr(PyPy, link_name = "PyPyComplex_FromDoubles")]
5524
pub fn PyComplex_FromDoubles(real: c_double, imag: c_double) -> *mut PyObject;
25+
5626
#[cfg_attr(PyPy, link_name = "PyPyComplex_RealAsDouble")]
5727
pub fn PyComplex_RealAsDouble(op: *mut PyObject) -> c_double;
5828
#[cfg_attr(PyPy, link_name = "PyPyComplex_ImagAsDouble")]
5929
pub fn PyComplex_ImagAsDouble(op: *mut PyObject) -> c_double;
60-
// skipped non-limited PyComplex_AsCComplex
61-
// skipped non-limited _PyComplex_FormatAdvancedWriter
6230
}

0 commit comments

Comments
 (0)