-
Notifications
You must be signed in to change notification settings - Fork 948
Add c_variadic bindings to pyo3-ffi
#5789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add `c_variadic` bindings to `pyo3-ffi` on `nightly`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,16 +11,32 @@ extern "C" { | |
| pub fn PyArg_ParseTuple(arg1: *mut PyObject, arg2: *const c_char, ...) -> c_int; | ||
| #[cfg_attr(PyPy, link_name = "PyPyArg_ParseTupleAndKeywords")] | ||
| pub fn PyArg_ParseTupleAndKeywords( | ||
| arg1: *mut PyObject, | ||
| arg2: *mut PyObject, | ||
| arg3: *const c_char, | ||
| #[cfg(not(Py_3_13))] arg4: *mut *mut c_char, | ||
| #[cfg(Py_3_13)] arg4: *const *const c_char, | ||
| args: *mut PyObject, | ||
| kw: *mut PyObject, | ||
| format: *const c_char, | ||
| #[cfg(not(Py_3_13))] keywords: *mut *mut c_char, | ||
| #[cfg(Py_3_13)] keywords: *const *const c_char, | ||
| ... | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm now confused, isn't this a variadic function declared on stable Rust? 😖
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused as well, but there is a clear difference in the signature. I'm not 100% fluent on this part of C I'm afraid.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are currently no plans for an api to create
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like you are correct, so I think we should unconditionally skip all FFI declarations taking It looks like this MR cleans up some names on the variadic (I wonder if we should add a |
||
| ) -> c_int; | ||
|
|
||
| // skipped PyArg_VaParse | ||
| // skipped PyArg_VaParseTupleAndKeywords | ||
| #[cfg(feature = "nightly")] | ||
| #[cfg_attr(PyPy, link_name = "PyPyArg_VaParse")] | ||
| pub fn PyArg_VaParse( | ||
| args: *mut PyObject, | ||
| format: *const c_char, | ||
| vargs: std::ffi::VaList<'_>, | ||
| ) -> c_int; | ||
|
|
||
| #[cfg(feature = "nightly")] | ||
| #[cfg_attr(PyPy, link_name = "PyPyArg_VaParseTupleAndKeywords")] | ||
| pub fn PyArg_VaParseTupleAndKeywords( | ||
| args: *mut PyObject, | ||
| kw: *mut PyObject, | ||
| format: *const c_char, | ||
| #[cfg(not(Py_3_13))] keywords: *mut *mut c_char, | ||
| #[cfg(Py_3_13)] keywords: *const *const c_char, | ||
| vargs: std::ffi::VaList<'_>, | ||
| ) -> c_int; | ||
|
|
||
| pub fn PyArg_ValidateKeywordArguments(arg1: *mut PyObject) -> c_int; | ||
| #[cfg_attr(PyPy, link_name = "PyPyArg_UnpackTuple")] | ||
|
|
@@ -33,8 +49,10 @@ extern "C" { | |
| ) -> c_int; | ||
|
|
||
| #[cfg_attr(PyPy, link_name = "PyPy_BuildValue")] | ||
| pub fn Py_BuildValue(arg1: *const c_char, ...) -> *mut PyObject; | ||
| // skipped Py_VaBuildValue | ||
| pub fn Py_BuildValue(format: *const c_char, ...) -> *mut PyObject; | ||
| #[cfg(feature = "nightly")] | ||
| #[cfg_attr(PyPy, link_name = "PyPy_VaBuildValue")] | ||
| pub fn Py_VaBuildValue(format: *const c_char, vargs: std::ffi::VaList<'_>) -> *mut PyObject; | ||
|
|
||
| #[cfg(Py_3_13)] | ||
| pub fn PyModule_Add(module: *mut PyObject, name: *const c_char, value: *mut PyObject) -> c_int; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is now well out of date, let's re-write this to just link to https://pyo3.rs/latest/features#nightly
At the same time, please can we update the description of the nightly feature in
features.mdto include this? It is also possible there are other features innightlymissing from that description, I am not sure either way.