Add PyMarshal_* functions to ffi modules.

This commit is contained in:
Maarten de Vries 2019-04-24 00:04:12 +02:00
parent 8399916ea9
commit 0a5edcb74e
2 changed files with 33 additions and 0 deletions

30
src/ffi3/marshal.rs Normal file
View file

@ -0,0 +1,30 @@
use super::PyObject;
use libc::FILE;
use std::os::raw::{c_char, c_int, c_long};
#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
#[cfg_attr(PyPy, link_name = "PyMarshal_WriteLongToFile")]
pub fn PyMarshal_WriteLongToFile(value: c_long, file: *mut FILE, version: c_int);
#[cfg_attr(PyPy, link_name = "PyMarshal_WriteObjectToFile")]
pub fn PyMarshal_WriteObjectToFile(value: *mut PyObject, file: *mut FILE, version: c_int);
#[cfg_attr(PyPy, link_name = "PyMarshal_WriteObjectToString")]
pub fn PyMarshal_WriteObjectToString(object: *mut PyObject, version: c_int) -> *mut PyObject;
#[cfg_attr(PyPy, link_name = "PyMarshal_ReadLongFromFile")]
pub fn PyMarshal_ReadLongFromFile(file: *mut FILE) -> c_long;
#[cfg_attr(PyPy, link_name = "PyMarshal_ReadShortFromFile")]
pub fn PyMarshal_ReadShortFromFile(file: *mut FILE) -> c_int;
#[cfg_attr(PyPy, link_name = "PyMarshal_ReadObjectFromFile")]
pub fn PyMarshal_ReadObjectFromFile(file: *mut FILE) -> *mut PyObject;
#[cfg_attr(PyPy, link_name = "PyMarshal_ReadLastObjectFromFile")]
pub fn PyMarshal_ReadLastObjectFromFile(file: *mut FILE) -> *mut PyObject;
#[cfg_attr(PyPy, link_name = "PyMarshal_ReadObjectFromString")]
pub fn PyMarshal_ReadObjectFromString(data: *const c_char, len: isize) -> *mut PyObject;
}

View file

@ -25,6 +25,7 @@ pub use self::intrcheck::*;
pub use self::iterobject::*;
pub use self::listobject::*;
pub use self::longobject::*;
pub use self::marshal::*;
pub use self::memoryobject::*;
pub use self::methodobject::*;
pub use self::modsupport::*;
@ -145,6 +146,8 @@ mod pystrtod; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and
// Additional headers that are not exported by Python.h
pub mod structmember; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5
pub mod marshal;
#[cfg(not(Py_LIMITED_API))]
pub mod frameobject;
#[cfg(Py_LIMITED_API)]