Skip to content

Commit 819ee06

Browse files
committed
[WIP] Some layouts for FFI
1 parent 8175d6f commit 819ee06

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

src/ffi/bytearrayobject.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ extern "C" {
1010
pub static mut PyByteArrayIter_Type: PyTypeObject;
1111
}
1212

13+
#[repr(C)]
14+
pub struct PyByteArraybject {
15+
pub ob_base: PyVarObject,
16+
pub ob_alloc: Py_ssize_t,
17+
pub ob_bytes: *mut c_char,
18+
pub ob_start: *mut c_char,
19+
pub ob_exports: Py_ssize_t,
20+
}
21+
1322
#[inline]
1423
pub unsafe fn PyByteArray_Check(op: *mut PyObject) -> c_int {
1524
PyObject_TypeCheck(op, &mut PyByteArray_Type)

src/ffi/bytesobject.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::ffi::object::*;
2-
use crate::ffi::pyport::Py_ssize_t;
2+
use crate::ffi::pyport::{Py_hash_t, Py_ssize_t};
33
use std::os::raw::{c_char, c_int};
44

55
#[cfg_attr(windows, link(name = "pythonXY"))]
@@ -9,6 +9,13 @@ extern "C" {
99
pub static mut PyBytesIter_Type: PyTypeObject;
1010
}
1111

12+
#[repr(C)]
13+
pub struct PyBytesObject {
14+
pub ob_base: PyVarObject,
15+
pub ob_shash: Py_hash_t,
16+
pub ob_sval: [c_char; 1],
17+
}
18+
1219
#[inline]
1320
pub unsafe fn PyBytes_Check(op: *mut PyObject) -> c_int {
1421
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS)

src/ffi/code.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ pub struct PyCodeObject {
3131
pub co_extra: *mut c_void,
3232
}
3333

34-
impl Default for PyCodeObject {
35-
#[inline]
36-
fn default() -> Self {
37-
unsafe { ::std::mem::zeroed() }
38-
}
39-
}
40-
4134
/* Masks for co_flags */
4235
pub const CO_OPTIMIZED: c_int = 0x0001;
4336
pub const CO_NEWLOCALS: c_int = 0x0002;

0 commit comments

Comments
 (0)