python3_sys/
marshal.rs

1use libc::{c_char, c_int, c_long, FILE};
2
3use crate::object::PyObject;
4use crate::pyport::Py_ssize_t;
5
6// 1 -> 2 in df88846ebca9186514e86bc2067242233ade4608 (Python 2.5)
7// 2 -> 3 in d7009c69136a3809282804f460902ab42e9972f6 (Python 3.4)
8// 3 -> 4 in 1164dfcb86757ebaeb68276e4b8f6ee266c9968d (Python 3.4)
9#[cfg(all(Py_3_3, not(Py_3_4)))]
10pub const Py_MARSHAL_VERSION: c_int = 2;
11
12#[cfg(Py_3_4)]
13pub const Py_MARSHAL_VERSION: c_int = 4;
14
15#[cfg(any(not(Py_3_11), not(Py_LIMITED_API)))] // moved to limited ABI in 3.11
16#[cfg_attr(windows, link(name = "pythonXY"))]
17extern "C" {
18    pub fn PyMarshal_WriteLongToFile(arg1: c_long, arg2: *mut FILE, arg3: c_int);
19    pub fn PyMarshal_WriteObjectToFile(arg1: *mut PyObject, arg2: *mut FILE, arg3: c_int);
20    pub fn PyMarshal_WriteObjectToString(arg1: *mut PyObject, arg2: c_int) -> *mut PyObject;
21    pub fn PyMarshal_ReadObjectFromString(arg1: *const c_char, arg2: Py_ssize_t) -> *mut PyObject;
22}
23
24#[cfg(not(Py_LIMITED_API))]
25#[cfg_attr(windows, link(name = "pythonXY"))]
26extern "C" {
27    pub fn PyMarshal_ReadLongFromFile(arg1: *mut FILE) -> c_long;
28    pub fn PyMarshal_ReadShortFromFile(arg1: *mut FILE) -> c_int;
29    pub fn PyMarshal_ReadObjectFromFile(arg1: *mut FILE) -> *mut PyObject;
30    pub fn PyMarshal_ReadLastObjectFromFile(arg1: *mut FILE) -> *mut PyObject;
31}