forked from PyO3/pyo3
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update structmember.rs for Python 3.12
- Loading branch information
1 parent
acb1bf7
commit b0f5901
Showing
6 changed files
with
100 additions
and
75 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#include "Python.h" | ||
#include "datetime.h" | ||
#include "frameobject.h" | ||
#include "structmember.h" |
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,70 +1,33 @@ | ||
use crate::object::PyObject; | ||
use crate::pyport::Py_ssize_t; | ||
use std::os::raw::{c_char, c_int}; | ||
use std::ptr; | ||
|
||
#[repr(C)] | ||
#[derive(Copy, Clone, Eq, PartialEq)] | ||
pub struct PyMemberDef { | ||
pub name: *const c_char, | ||
pub type_code: c_int, | ||
pub offset: Py_ssize_t, | ||
pub flags: c_int, | ||
pub doc: *const c_char, | ||
} | ||
|
||
impl Default for PyMemberDef { | ||
fn default() -> PyMemberDef { | ||
PyMemberDef { | ||
name: ptr::null_mut(), | ||
type_code: 0, | ||
offset: 0, | ||
flags: 0, | ||
doc: ptr::null_mut(), | ||
} | ||
} | ||
} | ||
|
||
/* Types */ | ||
pub const T_SHORT: c_int = 0; | ||
pub const T_INT: c_int = 1; | ||
pub const T_LONG: c_int = 2; | ||
pub const T_FLOAT: c_int = 3; | ||
pub const T_DOUBLE: c_int = 4; | ||
pub const T_STRING: c_int = 5; | ||
pub const T_OBJECT: c_int = 6; | ||
/* XXX the ordering here is weird for binary compatibility */ | ||
pub const T_CHAR: c_int = 7; /* 1-character string */ | ||
pub const T_BYTE: c_int = 8; /* 8-bit signed int */ | ||
/* unsigned variants: */ | ||
pub const T_UBYTE: c_int = 9; | ||
pub const T_USHORT: c_int = 10; | ||
pub const T_UINT: c_int = 11; | ||
pub const T_ULONG: c_int = 12; | ||
|
||
/* Added by Jack: strings contained in the structure */ | ||
pub const T_STRING_INPLACE: c_int = 13; | ||
|
||
/* Added by Lillo: bools contained in the structure (assumed char) */ | ||
pub const T_BOOL: c_int = 14; | ||
|
||
pub const T_OBJECT_EX: c_int = 16; /* Like T_OBJECT, but raises AttributeError | ||
when the value is NULL, instead of | ||
converting to None. */ | ||
|
||
pub const T_LONGLONG: c_int = 17; | ||
pub const T_ULONGLONG: c_int = 18; | ||
|
||
pub const T_PYSSIZET: c_int = 19; /* Py_ssize_t */ | ||
pub const T_NONE: c_int = 20; /* Value is always None */ | ||
use std::os::raw::c_int; | ||
|
||
pub use crate::PyMemberDef; | ||
|
||
pub use crate::Py_T_BOOL as T_BOOL; | ||
pub use crate::Py_T_BYTE as T_BYTE; | ||
pub use crate::Py_T_CHAR as T_CHAR; | ||
pub use crate::Py_T_DOUBLE as T_DOUBLE; | ||
pub use crate::Py_T_FLOAT as T_FLOAT; | ||
pub use crate::Py_T_INT as T_INT; | ||
pub use crate::Py_T_LONG as T_LONG; | ||
pub use crate::Py_T_LONGLONG as T_LONGLONG; | ||
pub use crate::Py_T_OBJECT_EX as T_OBJECT_EX; | ||
pub use crate::Py_T_SHORT as T_SHORT; | ||
pub use crate::Py_T_STRING as T_STRING; | ||
pub use crate::Py_T_STRING_INPLACE as T_STRING_INPLACE; | ||
pub use crate::Py_T_UBYTE as T_UBYTE; | ||
pub use crate::Py_T_UINT as T_UINT; | ||
pub use crate::Py_T_ULONG as T_ULONG; | ||
pub use crate::Py_T_ULONGLONG as T_ULONGLONG; | ||
pub use crate::Py_T_USHORT as T_USHORT; | ||
#[allow(deprecated)] | ||
pub use crate::_Py_T_OBJECT as T_OBJECT; | ||
|
||
pub use crate::Py_T_PYSSIZET as T_PYSSIZET; | ||
#[allow(deprecated)] | ||
pub use crate::_Py_T_NONE as T_NONE; | ||
|
||
/* Flags */ | ||
pub const READONLY: c_int = 1; | ||
pub use crate::Py_READONLY as READONLY; | ||
pub const READ_RESTRICTED: c_int = 2; | ||
pub const PY_WRITE_RESTRICTED: c_int = 4; | ||
pub const RESTRICTED: c_int = READ_RESTRICTED | PY_WRITE_RESTRICTED; | ||
|
||
extern "C" { | ||
pub fn PyMember_GetOne(addr: *const c_char, l: *mut PyMemberDef) -> *mut PyObject; | ||
pub fn PyMember_SetOne(addr: *mut c_char, l: *mut PyMemberDef, value: *mut PyObject) -> c_int; | ||
} |