python27-sys: add missing object types
This commit is contained in:
parent
f6718a271b
commit
a469635eca
|
@ -0,0 +1,41 @@
|
|||
use libc::c_int;
|
||||
use pyport::Py_ssize_t;
|
||||
use object::*;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
struct PyCellObject {
|
||||
#[cfg(py_sys_config="Py_TRACE_REFS")]
|
||||
pub _ob_next: *mut PyObject,
|
||||
#[cfg(py_sys_config="Py_TRACE_REFS")]
|
||||
pub _ob_prev: *mut PyObject,
|
||||
pub ob_refcnt: Py_ssize_t,
|
||||
pub ob_type: *mut PyTypeObject,
|
||||
pub ob_ref: *mut PyObject
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub static mut PyCell_Type: PyTypeObject;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PyCell_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyCell_Type) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn PyCell_New(obj: *mut PyObject) -> *mut PyObject;
|
||||
pub fn PyCell_Get(op: *mut PyObject) -> *mut PyObject;
|
||||
pub fn PyCell_Set(op: *mut PyObject, obj: *mut PyObject) -> c_int;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PyCell_GET(op: *mut PyObject) -> *mut PyObject {
|
||||
(*(op as *mut PyCellObject)).ob_ref
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PyCell_SET(op: *mut PyObject, obj: *mut PyObject) {
|
||||
(*(op as *mut PyCellObject)).ob_ref = obj;
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use libc::{c_void, c_char, c_int};
|
||||
use object::{PyObject, PyTypeObject};
|
||||
use object::{PyObject, PyTypeObject, Py_TYPE};
|
||||
use structmember::PyMemberDef;
|
||||
use methodobject::PyMethodDef;
|
||||
|
||||
|
@ -27,6 +27,32 @@ impl Clone for PyGetSetDef {
|
|||
#[inline] fn clone(&self) -> PyGetSetDef { *self }
|
||||
}
|
||||
|
||||
pub type wrapperfunc =
|
||||
unsafe extern "C" fn(slf: *mut PyObject, args: *mut PyObject,
|
||||
wrapped: *mut c_void) -> *mut PyObject;
|
||||
|
||||
pub type wrapperfunc_kwds =
|
||||
unsafe extern "C" fn(slf: *mut PyObject, args: *mut PyObject,
|
||||
wrapped: *mut c_void, kwds: *mut PyObject) -> *mut PyObject;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy)]
|
||||
pub struct wrapperbase {
|
||||
pub name: *mut c_char,
|
||||
pub offset: c_int,
|
||||
pub function: *mut c_void,
|
||||
pub wrapper: Option<wrapperfunc>,
|
||||
pub doc: *mut c_char,
|
||||
pub flags: c_int,
|
||||
pub name_strobj: *mut PyObject
|
||||
}
|
||||
|
||||
impl Clone for wrapperbase {
|
||||
#[inline] fn clone(&self) -> wrapperbase { *self }
|
||||
}
|
||||
|
||||
pub const PyWrapperFlag_KEYWORDS : c_int = 1;
|
||||
|
||||
extern "C" {
|
||||
pub static mut PyWrapperDescr_Type: PyTypeObject;
|
||||
pub static mut PyDictProxy_Type: PyTypeObject;
|
||||
|
@ -42,11 +68,23 @@ extern "C" {
|
|||
arg2: *mut PyMemberDef) -> *mut PyObject;
|
||||
pub fn PyDescr_NewGetSet(arg1: *mut PyTypeObject,
|
||||
arg2: *mut PyGetSetDef) -> *mut PyObject;
|
||||
//pub fn PyDescr_NewWrapper(arg1: *mut PyTypeObject,
|
||||
// arg2: *mut Struct_wrapperbase,
|
||||
// arg3: *mut c_void) -> *mut PyObject;
|
||||
pub fn PyDescr_NewWrapper(arg1: *mut PyTypeObject,
|
||||
arg2: *mut wrapperbase,
|
||||
arg3: *mut c_void) -> *mut PyObject;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PyDescr_IsData(d: *mut PyObject) -> c_int {
|
||||
(*Py_TYPE(d)).tp_descr_set.is_some() as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
//pub fn PyDictProxy_New(arg1: *mut PyObject) -> *mut PyObject;
|
||||
// PyDictProxy_New is also defined in dictobject.h
|
||||
pub fn PyWrapper_New(arg1: *mut PyObject, arg2: *mut PyObject)
|
||||
-> *mut PyObject;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
use libc::c_int;
|
||||
use pyport::Py_ssize_t;
|
||||
use object::*;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct PyGenObject {
|
||||
#[cfg(py_sys_config="Py_TRACE_REFS")]
|
||||
pub _ob_next: *mut PyObject,
|
||||
#[cfg(py_sys_config="Py_TRACE_REFS")]
|
||||
pub _ob_prev: *mut PyObject,
|
||||
pub ob_refcnt: Py_ssize_t,
|
||||
pub ob_type: *mut PyTypeObject,
|
||||
pub gi_frame: *mut ::PyFrameObject,
|
||||
pub gi_running: c_int,
|
||||
pub gi_code: *mut PyObject,
|
||||
pub gi_weakreflist: *mut PyObject
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub static mut PyGen_Type: PyTypeObject;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PyGen_Check(op: *mut PyObject) -> c_int {
|
||||
PyObject_TypeCheck(op, &mut PyGen_Type)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PyGen_CheckExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyGen_Type) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn PyGen_New(frame: *mut ::PyFrameObject) -> *mut PyObject;
|
||||
pub fn PyGen_NeedsFinalizing(op: *mut PyGenObject) -> c_int;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
use libc::c_int;
|
||||
use object::*;
|
||||
|
||||
extern "C" {
|
||||
pub static mut PySeqIter_Type: PyTypeObject;
|
||||
pub static mut PyCallIter_Type: PyTypeObject;
|
||||
|
||||
pub fn PySeqIter_New(arg1: *mut PyObject) -> *mut PyObject;
|
||||
pub fn PyCallIter_New(arg1: *mut PyObject, arg2: *mut PyObject)
|
||||
-> *mut PyObject;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PySeqIter_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PySeqIter_Type) as c_int
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PyCallIter_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyCallIter_Type) as c_int
|
||||
}
|
||||
|
||||
|
|
@ -35,9 +35,14 @@ pub use classobject::*;
|
|||
pub use fileobject::*;
|
||||
pub use cobject::*;
|
||||
pub use pycapsule::*;
|
||||
|
||||
pub use traceback::*;
|
||||
pub use sliceobject::*;
|
||||
pub use cellobject::*;
|
||||
pub use iterobject::*;
|
||||
pub use genobject::*;
|
||||
pub use descrobject::*;
|
||||
pub use warnings::*;
|
||||
pub use weakrefobject::*;
|
||||
pub use pyarena::*;
|
||||
pub use modsupport::*;
|
||||
pub use pythonrun::*;
|
||||
|
@ -78,14 +83,14 @@ mod classobject;
|
|||
mod fileobject;
|
||||
mod cobject;
|
||||
mod pycapsule;
|
||||
// mod traceback; // TODO: incomplete
|
||||
// mod sliceobject; // TODO: incomplete
|
||||
// mod cellobject; // TODO: incomplete
|
||||
// mod iterobject; // TODO: incomplete
|
||||
// mod genobject; // TODO: incomplete
|
||||
mod descrobject; // TODO: incomplete
|
||||
mod traceback;
|
||||
mod sliceobject;
|
||||
mod cellobject;
|
||||
mod iterobject;
|
||||
mod genobject;
|
||||
mod descrobject;
|
||||
mod warnings;
|
||||
// mod weakrefobject; // TODO: incomplete
|
||||
mod weakrefobject;
|
||||
|
||||
// mod codecs; // TODO: incomplete
|
||||
mod pyerrors;
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
use libc::c_int;
|
||||
use pyport::Py_ssize_t;
|
||||
use object::*;
|
||||
|
||||
extern "C" {
|
||||
static mut _Py_EllipsisObject: PyObject;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn Py_Ellipsis() -> *mut PyObject {
|
||||
&mut _Py_EllipsisObject
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct PySliceObject {
|
||||
#[cfg(py_sys_config="Py_TRACE_REFS")]
|
||||
pub _ob_next: *mut PyObject,
|
||||
#[cfg(py_sys_config="Py_TRACE_REFS")]
|
||||
pub _ob_prev: *mut PyObject,
|
||||
pub ob_refcnt: Py_ssize_t,
|
||||
pub ob_type: *mut PyTypeObject,
|
||||
pub start: *mut PyObject,
|
||||
pub stop: *mut PyObject,
|
||||
pub step: *mut PyObject
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub static mut PySlice_Type: PyTypeObject;
|
||||
pub static mut PyEllipsis_Type: PyTypeObject;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PySlice_Check(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PySlice_Type) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn PySlice_New(start: *mut PyObject, stop: *mut PyObject,
|
||||
step: *mut PyObject) -> *mut PyObject;
|
||||
pub fn PySlice_GetIndices(r: *mut PyObject, length: Py_ssize_t,
|
||||
start: *mut Py_ssize_t, stop: *mut Py_ssize_t,
|
||||
step: *mut Py_ssize_t) -> c_int;
|
||||
pub fn PySlice_GetIndicesEx(r: *mut PyObject, length: Py_ssize_t,
|
||||
start: *mut Py_ssize_t, stop: *mut Py_ssize_t,
|
||||
step: *mut Py_ssize_t,
|
||||
slicelength: *mut Py_ssize_t)
|
||||
-> c_int;
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
use libc::c_int;
|
||||
use object::*;
|
||||
use pyport::Py_ssize_t;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct PyTracebackObject {
|
||||
#[cfg(py_sys_config="Py_TRACE_REFS")]
|
||||
pub _ob_next: *mut PyObject,
|
||||
#[cfg(py_sys_config="Py_TRACE_REFS")]
|
||||
pub _ob_prev: *mut PyObject,
|
||||
pub ob_refcnt: Py_ssize_t,
|
||||
pub ob_type: *mut PyTypeObject,
|
||||
pub tb_next: *mut PyTracebackObject,
|
||||
pub tb_frame: *mut ::PyFrameObject,
|
||||
pub tb_lasti: c_int,
|
||||
pub tb_lineno: c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn PyTraceBack_Here(arg1: *mut ::PyFrameObject) -> c_int;
|
||||
pub fn PyTraceBack_Print(arg1: *mut PyObject, arg2: *mut PyObject)
|
||||
-> c_int;
|
||||
|
||||
pub static mut PyTraceBack_Type: PyTypeObject;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PyTraceBack_Check(op : *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut PyTraceBack_Type) as c_int
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
use libc::{c_int, c_long};
|
||||
use pyport::Py_ssize_t;
|
||||
use object::*;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct PyWeakReference {
|
||||
#[cfg(py_sys_config="Py_TRACE_REFS")]
|
||||
pub _ob_next: *mut PyObject,
|
||||
#[cfg(py_sys_config="Py_TRACE_REFS")]
|
||||
pub _ob_prev: *mut PyObject,
|
||||
pub ob_refcnt: Py_ssize_t,
|
||||
pub ob_type: *mut PyTypeObject,
|
||||
pub wr_object: *mut PyObject,
|
||||
pub wr_callback: *mut PyObject,
|
||||
pub hash: c_long,
|
||||
pub wr_prev: *mut PyWeakReference,
|
||||
pub wr_next: *mut PyWeakReference
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
static mut _PyWeakref_RefType: PyTypeObject;
|
||||
static mut _PyWeakref_ProxyType: PyTypeObject;
|
||||
static mut _PyWeakref_CallableProxyType: PyTypeObject;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PyWeakref_CheckRef(op: *mut PyObject) -> c_int {
|
||||
PyObject_TypeCheck(op, &mut _PyWeakref_RefType)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PyWeakref_CheckRefExact(op: *mut PyObject) -> c_int {
|
||||
(Py_TYPE(op) == &mut _PyWeakref_RefType) as c_int
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PyWeakref_CheckProxy(op: *mut PyObject) -> c_int {
|
||||
((Py_TYPE(op) == &mut _PyWeakref_ProxyType) ||
|
||||
(Py_TYPE(op) == &mut _PyWeakref_CallableProxyType)) as c_int
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PyWeakref_Check(op: *mut PyObject) -> c_int {
|
||||
(PyWeakref_CheckRef(op) != 0 || PyWeakref_CheckProxy(op) != 0) as c_int
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn PyWeakref_NewRef(ob: *mut PyObject, callback: *mut PyObject)
|
||||
-> *mut PyObject;
|
||||
pub fn PyWeakref_NewProxy(ob: *mut PyObject, callback: *mut PyObject)
|
||||
-> *mut PyObject;
|
||||
pub fn PyWeakref_GetObject(_ref: *mut PyObject) -> *mut PyObject;
|
||||
|
||||
pub fn _PyWeakref_GetWeakrefCount(head: *mut PyWeakReference) -> Py_ssize_t;
|
||||
pub fn _PyWeakref_ClearRef(slf: *mut PyWeakReference);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub unsafe fn PyWeakref_GET_OBJECT(_ref: *mut PyObject) -> *mut PyObject {
|
||||
let obj = (*(_ref as *mut PyWeakReference)).wr_object;
|
||||
if Py_REFCNT(obj) > 0 { obj } else { Py_None() }
|
||||
}
|
||||
|
Loading…
Reference in New Issue