Skip to content

Commit 788a9f0

Browse files
committed
remove private _Py symbols from pyo3-ffi
1 parent 454529d commit 788a9f0

33 files changed

+286
-422
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

57
#[inline]
@@ -47,22 +49,6 @@ extern "C" {
4749
...
4850
) -> *mut PyObject;
4951

50-
#[cfg(not(Py_3_13))]
51-
#[cfg_attr(PyPy, link_name = "_PyPyObject_CallFunction_SizeT")]
52-
pub fn _PyObject_CallFunction_SizeT(
53-
callable_object: *mut PyObject,
54-
format: *const c_char,
55-
...
56-
) -> *mut PyObject;
57-
#[cfg(not(Py_3_13))]
58-
#[cfg_attr(PyPy, link_name = "_PyPyObject_CallMethod_SizeT")]
59-
pub fn _PyObject_CallMethod_SizeT(
60-
o: *mut PyObject,
61-
method: *const c_char,
62-
format: *const c_char,
63-
...
64-
) -> *mut PyObject;
65-
6652
#[cfg_attr(PyPy, link_name = "PyPyObject_CallFunctionObjArgs")]
6753
pub fn PyObject_CallFunctionObjArgs(callable: *mut PyObject, ...) -> *mut PyObject;
6854
#[cfg_attr(PyPy, link_name = "PyPyObject_CallMethodObjArgs")]
@@ -71,6 +57,41 @@ extern "C" {
7157
method: *mut PyObject,
7258
...
7359
) -> *mut PyObject;
60+
61+
#[cfg(all(Py_3_12, Py_LIMITED_API))] // used as a function on the stable abi
62+
pub fn PyVectorcall_NARGS(nargsf: libc::size_t) -> Py_ssize_t;
63+
64+
#[cfg(any(Py_3_12, all(Py_3_9, not(Py_LIMITED_API))))]
65+
#[cfg_attr(PyPy, link_name = "PyPyVectorcall_Call")]
66+
pub fn PyVectorcall_Call(
67+
callable: *mut PyObject,
68+
tuple: *mut PyObject,
69+
dict: *mut PyObject,
70+
) -> *mut PyObject;
71+
}
72+
73+
#[cfg(Py_3_12)]
74+
pub const PY_VECTORCALL_ARGUMENTS_OFFSET: size_t =
75+
1 << (8 * std::mem::size_of::<size_t>() as size_t - 1);
76+
77+
extern "C" {
78+
#[cfg_attr(Py_3_9, link_name = "PyPyObject_Vectorcall")]
79+
#[cfg(any(Py_3_12, all(Py_3_9, not(Py_LIMITED_API))))]
80+
pub fn PyObject_Vectorcall(
81+
callable: *mut PyObject,
82+
args: *const *mut PyObject,
83+
nargsf: size_t,
84+
kwnames: *mut PyObject,
85+
) -> *mut PyObject;
86+
87+
#[cfg(any(Py_3_12, all(Py_3_9, not(any(Py_LIMITED_API, PyPy, GraalPy)))))]
88+
pub fn PyObject_VectorcallMethod(
89+
name: *mut PyObject,
90+
args: *const *mut PyObject,
91+
nargsf: size_t,
92+
kwnames: *mut PyObject,
93+
) -> *mut PyObject;
94+
7495
#[cfg_attr(PyPy, link_name = "PyPyObject_Type")]
7596
pub fn PyObject_Type(o: *mut PyObject) -> *mut PyObject;
7697
#[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)