python3_sys/
structmember.rs

1use libc::{c_char, c_int};
2
3use crate::object::PyObject;
4use crate::pyport::Py_ssize_t;
5
6#[repr(C)]
7#[derive(Copy, Clone)]
8pub struct PyMemberDef {
9    #[cfg(not(Py_3_7))]
10    pub name: *mut c_char,
11    #[cfg(Py_3_7)]
12    pub name: *const c_char,
13    pub type_code: c_int,
14    pub offset: Py_ssize_t,
15    pub flags: c_int,
16    #[cfg(not(Py_3_7))]
17    pub doc: *mut c_char,
18    #[cfg(Py_3_7)]
19    pub doc: *const c_char,
20}
21
22/* Types */
23pub const T_SHORT: c_int = 0;
24pub const T_INT: c_int = 1;
25pub const T_LONG: c_int = 2;
26pub const T_FLOAT: c_int = 3;
27pub const T_DOUBLE: c_int = 4;
28pub const T_STRING: c_int = 5;
29pub const T_OBJECT: c_int = 6;
30/* XXX the ordering here is weird for binary compatibility */
31pub const T_CHAR: c_int = 7; /* 1-character string */
32pub const T_BYTE: c_int = 8; /* 8-bit signed int */
33/* unsigned variants: */
34pub const T_UBYTE: c_int = 9;
35pub const T_USHORT: c_int = 10;
36pub const T_UINT: c_int = 11;
37pub const T_ULONG: c_int = 12;
38
39/* Added by Jack: strings contained in the structure */
40pub const T_STRING_INPLACE: c_int = 13;
41
42/* Added by Lillo: bools contained in the structure (assumed char) */
43pub const T_BOOL: c_int = 14;
44
45pub const T_OBJECT_EX: c_int = 16; /* Like T_OBJECT, but raises AttributeError
46                                   when the value is NULL, instead of
47                                   converting to None. */
48
49pub const T_LONGLONG: c_int = 17;
50pub const T_ULONGLONG: c_int = 18;
51
52pub const T_PYSSIZET: c_int = 19; /* Py_ssize_t */
53pub const T_NONE: c_int = 20; /* Value is always None */
54
55/* Flags */
56pub const READONLY: c_int = 1;
57pub const READ_RESTRICTED: c_int = 2;
58pub const PY_WRITE_RESTRICTED: c_int = 4;
59pub const RESTRICTED: c_int = (READ_RESTRICTED | PY_WRITE_RESTRICTED);
60
61#[cfg_attr(windows, link(name = "pythonXY"))]
62extern "C" {
63    pub fn PyMember_GetOne(addr: *const c_char, l: *mut PyMemberDef) -> *mut PyObject;
64    pub fn PyMember_SetOne(addr: *mut c_char, l: *mut PyMemberDef, value: *mut PyObject) -> c_int;
65}