python27_sys/
bufferobject.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use libc::{c_int, c_void};

use crate::object::*;
use crate::pyport::Py_ssize_t;

#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
    pub static mut PyBuffer_Type: PyTypeObject;
}

#[inline(always)]
pub unsafe fn PyBuffer_Check(op: *mut PyObject) -> c_int {
    let u: *mut PyTypeObject = &mut PyBuffer_Type;
    (Py_TYPE(op) == u) as c_int
}

pub const Py_END_OF_BUFFER: Py_ssize_t = -1;

#[cfg_attr(windows, link(name = "pythonXY"))]
extern "C" {
    pub fn PyBuffer_FromObject(
        base: *mut PyObject,
        offset: Py_ssize_t,
        size: Py_ssize_t,
    ) -> *mut PyObject;
    pub fn PyBuffer_FromReadWriteObject(
        base: *mut PyObject,
        offset: Py_ssize_t,
        size: Py_ssize_t,
    ) -> *mut PyObject;
    pub fn PyBuffer_FromMemory(ptr: *mut c_void, size: Py_ssize_t) -> *mut PyObject;
    pub fn PyBuffer_FromReadWriteMemory(ptr: *mut c_void, size: Py_ssize_t) -> *mut PyObject;
    pub fn PyBuffer_New(size: Py_ssize_t) -> *mut PyObject;
}