-
Notifications
You must be signed in to change notification settings - Fork 784
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 #1387 from nw0/ffi-4
ffi module cleanup: listobject.h to memoryobject.h
- Loading branch information
Showing
9 changed files
with
124 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use crate::ffi::object::*; | ||
use crate::ffi::pyport::Py_ssize_t; | ||
|
||
#[repr(C)] | ||
#[derive(Copy, Clone)] | ||
pub struct PyListObject { | ||
pub ob_base: PyVarObject, | ||
pub ob_item: *mut *mut PyObject, | ||
pub allocated: Py_ssize_t, | ||
} | ||
|
||
// skipped _PyList_Extend | ||
// skipped _PyList_DebugMallocStats | ||
// skipped _PyList_CAST (used inline below) | ||
|
||
/// Macro, trading safety for speed | ||
#[inline] | ||
pub unsafe fn PyList_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject { | ||
*(*(op as *mut PyListObject)).ob_item.offset(i as isize) | ||
} | ||
|
||
/// Macro, *only* to be used to fill in brand new lists | ||
#[inline] | ||
pub unsafe fn PyList_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) { | ||
*(*(op as *mut PyListObject)).ob_item.offset(i as isize) = v; | ||
} | ||
|
||
#[inline] | ||
pub unsafe fn PyList_GET_SIZE(op: *mut PyObject) -> Py_ssize_t { | ||
Py_SIZE(op) | ||
} |
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
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,11 +1,19 @@ | ||
use super::PyObject; | ||
use super::{PyObject, Py_ssize_t}; | ||
use std::os::raw::{c_char, c_int}; | ||
|
||
#[cfg(not(Py_LIMITED_API))] | ||
// skipped Py_MARSHAL_VERSION | ||
// skipped PyMarshal_WriteLongToFile | ||
// skipped PyMarshal_WriteObjectToFile | ||
|
||
extern "C" { | ||
#[cfg_attr(PyPy, link_name = "PyPyMarshal_WriteObjectToString")] | ||
pub fn PyMarshal_WriteObjectToString(object: *mut PyObject, version: c_int) -> *mut PyObject; | ||
|
||
// skipped non-limited PyMarshal_ReadLongFromFile | ||
// skipped non-limited PyMarshal_ReadShortFromFile | ||
// skipped non-limited PyMarshal_ReadObjectFromFile | ||
// skipped non-limited PyMarshal_ReadLastObjectFromFile | ||
|
||
#[cfg_attr(PyPy, link_name = "PyPyMarshal_ReadObjectFromString")] | ||
pub fn PyMarshal_ReadObjectFromString(data: *const c_char, len: isize) -> *mut PyObject; | ||
pub fn PyMarshal_ReadObjectFromString(data: *const c_char, len: Py_ssize_t) -> *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
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