Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1887 from deantvv/ffi-cleanup-0925-a
ffi: cleanup from sysmodule to tupleobject
- Loading branch information
Showing
8 changed files
with
71 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use crate::ffi::object::*; | ||
#[cfg(not(PyPy))] | ||
use crate::ffi::pyport::Py_ssize_t; | ||
|
||
#[repr(C)] | ||
pub struct PyTupleObject { | ||
pub ob_base: PyVarObject, | ||
pub ob_item: [*mut PyObject; 1], | ||
} | ||
|
||
// skipped _PyTuple_Resize | ||
// skipped _PyTuple_MaybeUntrack | ||
|
||
/// Macro, trading safety for speed | ||
|
||
// skipped _PyTuple_CAST | ||
|
||
#[inline] | ||
#[cfg(not(PyPy))] | ||
pub unsafe fn PyTuple_GET_SIZE(op: *mut PyObject) -> Py_ssize_t { | ||
Py_SIZE(op) | ||
} | ||
|
||
#[inline] | ||
#[cfg(not(PyPy))] | ||
pub unsafe fn PyTuple_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject { | ||
*(*(op as *mut PyTupleObject)) | ||
.ob_item | ||
.as_ptr() | ||
.offset(i as isize) | ||
} | ||
|
||
/// Macro, *only* to be used to fill in brand new tuples | ||
#[inline] | ||
#[cfg(not(PyPy))] | ||
pub unsafe fn PyTuple_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) { | ||
*(*(op as *mut PyTupleObject)) | ||
.ob_item | ||
.as_mut_ptr() | ||
.offset(i as isize) = v; | ||
} | ||
|
||
// skipped _PyTuple_DebugMallocStats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use crate::ffi::pyport::Py_ssize_t; | ||
use libc::wchar_t; | ||
use std::os::raw::c_char; | ||
|
||
extern "C" { | ||
pub fn Py_DecodeLocale(arg1: *const c_char, size: *mut Py_ssize_t) -> *mut wchar_t; | ||
|
||
pub fn Py_EncodeLocale(text: *const wchar_t, error_pos: *mut Py_ssize_t) -> *mut c_char; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
use crate::ffi::object::PyObject; | ||
use crate::ffi::pyport::Py_ssize_t; | ||
use libc::wchar_t; | ||
use std::os::raw::{c_char, c_int}; | ||
|
||
extern "C" { | ||
pub fn Py_DecodeLocale(arg1: *const c_char, arg2: *mut Py_ssize_t) -> *mut wchar_t; | ||
#[cfg_attr(PyPy, link_name = "PyPySys_GetObject")] | ||
pub fn PySys_GetObject(arg1: *const c_char) -> *mut PyObject; | ||
#[cfg_attr(PyPy, link_name = "PyPySys_SetObject")] | ||
pub fn PySys_SetObject(arg1: *const c_char, arg2: *mut PyObject) -> c_int; | ||
|
||
pub fn PySys_SetArgv(arg1: c_int, arg2: *mut *mut wchar_t); | ||
pub fn PySys_SetArgvEx(arg1: c_int, arg2: *mut *mut wchar_t, arg3: c_int); | ||
pub fn PySys_SetPath(arg1: *const wchar_t); | ||
|
||
#[cfg_attr(PyPy, link_name = "PyPySys_WriteStdout")] | ||
pub fn PySys_WriteStdout(format: *const c_char, ...); | ||
#[cfg_attr(PyPy, link_name = "PyPySys_WriteStderr")] | ||
pub fn PySys_WriteStderr(format: *const c_char, ...); | ||
pub fn PySys_FormatStdout(format: *const c_char, ...); | ||
pub fn PySys_FormatStderr(format: *const c_char, ...); | ||
|
||
pub fn PySys_ResetWarnOptions(); | ||
#[cfg_attr(Py_3_11, deprecated(note = "Python 3.11"))] | ||
pub fn PySys_AddWarnOption(arg1: *const wchar_t); | ||
#[cfg_attr(Py_3_11, deprecated(note = "Python 3.11"))] | ||
pub fn PySys_AddWarnOptionUnicode(arg1: *mut PyObject); | ||
#[cfg_attr(Py_3_11, deprecated(note = "Python 3.11"))] | ||
pub fn PySys_HasWarnOptions() -> c_int; | ||
|
||
pub fn PySys_AddXOption(arg1: *const wchar_t); | ||
pub fn PySys_GetXOptions() -> *mut PyObject; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters