From 68c3208d35d5105a4f6656494d07c532b9445fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Niederb=C3=BChl?= Date: Sat, 7 Sep 2019 00:29:50 +0200 Subject: [PATCH] Move files from ffi3 into ffi Since Python 2 is no longer supported, one folder should be enough. --- src/{ffi3 => ffi}/LICENSE | 0 src/{ffi3 => ffi}/README.md | 0 src/{ffi3 => ffi}/bltinmodule.rs | 2 +- src/{ffi3 => ffi}/boolobject.rs | 4 +- src/{ffi3 => ffi}/bytearrayobject.rs | 4 +- src/{ffi3 => ffi}/bytesobject.rs | 4 +- src/{ffi3 => ffi}/ceval.rs | 16 +-- src/{ffi3 => ffi}/code.rs | 6 +- src/{ffi3 => ffi}/codecs.rs | 2 +- src/{ffi3 => ffi}/compile.rs | 8 +- src/{ffi3 => ffi}/complexobject.rs | 2 +- src/{ffi3 => ffi}/descrobject.rs | 8 +- src/{ffi3 => ffi}/dictobject.rs | 4 +- src/{ffi3 => ffi}/enumobject.rs | 2 +- src/{ffi3 => ffi}/eval.rs | 2 +- src/{ffi3 => ffi}/fileobject.rs | 2 +- src/{ffi3 => ffi}/floatobject.rs | 2 +- src/{ffi3 => ffi}/frameobject.rs | 6 +- src/{ffi3 => ffi}/genobject.rs | 6 +- src/{ffi3 => ffi}/import.rs | 2 +- src/{ffi3 => ffi}/intrcheck.rs | 0 src/{ffi3 => ffi}/iterobject.rs | 2 +- src/{ffi3 => ffi}/listobject.rs | 4 +- src/{ffi3 => ffi}/longobject.rs | 4 +- src/{ffi3 => ffi}/memoryobject.rs | 4 +- src/{ffi3 => ffi}/methodobject.rs | 4 +- src/ffi/mod.rs | 154 ++++++++++++++++++++++++++- src/{ffi3 => ffi}/modsupport.rs | 8 +- src/{ffi3 => ffi}/moduleobject.rs | 6 +- src/{ffi3 => ffi}/object.rs | 72 ++++++------- src/{ffi3 => ffi}/objectabstract.rs | 6 +- src/{ffi3 => ffi}/objimpl.rs | 4 +- src/{ffi3 => ffi}/osmodule.rs | 2 +- src/{ffi3 => ffi}/pyarena.rs | 0 src/{ffi3 => ffi}/pycapsule.rs | 2 +- src/{ffi3 => ffi}/pydebug.rs | 0 src/{ffi3 => ffi}/pyerrors.rs | 6 +- src/{ffi3 => ffi}/pyhash.rs | 2 +- src/{ffi3 => ffi}/pymem.rs | 0 src/{ffi3 => ffi}/pyport.rs | 0 src/{ffi3 => ffi}/pystate.rs | 6 +- src/{ffi3 => ffi}/pystrtod.rs | 2 +- src/{ffi3 => ffi}/pythonrun.rs | 6 +- src/{ffi3 => ffi}/rangeobject.rs | 2 +- src/{ffi3 => ffi}/setobject.rs | 4 +- src/{ffi3 => ffi}/sliceobject.rs | 4 +- src/{ffi3 => ffi}/structmember.rs | 4 +- src/{ffi3 => ffi}/structseq.rs | 4 +- src/{ffi3 => ffi}/sysmodule.rs | 4 +- src/{ffi3 => ffi}/traceback.rs | 4 +- src/{ffi3 => ffi}/tupleobject.rs | 4 +- src/{ffi3 => ffi}/typeslots.rs | 0 src/{ffi3 => ffi}/unicodeobject.rs | 4 +- src/{ffi3 => ffi}/warnings.rs | 4 +- src/{ffi3 => ffi}/weakrefobject.rs | 2 +- src/ffi3/mod.rs | 153 -------------------------- src/lib.rs | 2 - 57 files changed, 282 insertions(+), 289 deletions(-) rename src/{ffi3 => ffi}/LICENSE (100%) rename src/{ffi3 => ffi}/README.md (100%) rename src/{ffi3 => ffi}/bltinmodule.rs (83%) rename src/{ffi3 => ffi}/boolobject.rs (92%) rename src/{ffi3 => ffi}/bytearrayobject.rs (95%) rename src/{ffi3 => ffi}/bytesobject.rs (97%) rename src/{ffi3 => ffi}/ceval.rs (87%) rename src/{ffi3 => ffi}/code.rs (96%) rename src/{ffi3 => ffi}/codecs.rs (98%) rename src/{ffi3 => ffi}/compile.rs (94%) rename src/{ffi3 => ffi}/complexobject.rs (98%) rename src/{ffi3 => ffi}/descrobject.rs (92%) rename src/{ffi3 => ffi}/dictobject.rs (98%) rename src/{ffi3 => ffi}/enumobject.rs (80%) rename src/{ffi3 => ffi}/eval.rs (94%) rename src/{ffi3 => ffi}/fileobject.rs (96%) rename src/{ffi3 => ffi}/floatobject.rs (97%) rename src/{ffi3 => ffi}/frameobject.rs (96%) rename src/{ffi3 => ffi}/genobject.rs (94%) rename src/{ffi3 => ffi}/import.rs (98%) rename src/{ffi3 => ffi}/intrcheck.rs (100%) rename src/{ffi3 => ffi}/iterobject.rs (96%) rename src/{ffi3 => ffi}/listobject.rs (97%) rename src/{ffi3 => ffi}/longobject.rs (98%) rename src/{ffi3 => ffi}/memoryobject.rs (93%) rename src/{ffi3 => ffi}/methodobject.rs (96%) rename src/{ffi3 => ffi}/modsupport.rs (96%) rename src/{ffi3 => ffi}/moduleobject.rs (96%) rename src/{ffi3 => ffi}/object.rs (94%) rename src/{ffi3 => ffi}/objectabstract.rs (99%) rename src/{ffi3 => ffi}/objimpl.rs (98%) rename src/{ffi3 => ffi}/osmodule.rs (82%) rename src/{ffi3 => ffi}/pyarena.rs (100%) rename src/{ffi3 => ffi}/pycapsule.rs (98%) rename src/{ffi3 => ffi}/pydebug.rs (100%) rename src/{ffi3 => ffi}/pyerrors.rs (99%) rename src/{ffi3 => ffi}/pyhash.rs (91%) rename src/{ffi3 => ffi}/pymem.rs (100%) rename src/{ffi3 => ffi}/pyport.rs (100%) rename src/{ffi3 => ffi}/pystate.rs (95%) rename src/{ffi3 => ffi}/pystrtod.rs (96%) rename src/{ffi3 => ffi}/pythonrun.rs (98%) rename src/{ffi3 => ffi}/rangeobject.rs (93%) rename src/{ffi3 => ffi}/setobject.rs (97%) rename src/{ffi3 => ffi}/sliceobject.rs (95%) rename src/{ffi3 => ffi}/structmember.rs (96%) rename src/{ffi3 => ffi}/structseq.rs (90%) rename src/{ffi3 => ffi}/sysmodule.rs (94%) rename src/{ffi3 => ffi}/traceback.rs (84%) rename src/{ffi3 => ffi}/tupleobject.rs (97%) rename src/{ffi3 => ffi}/typeslots.rs (100%) rename src/{ffi3 => ffi}/unicodeobject.rs (99%) rename src/{ffi3 => ffi}/warnings.rs (92%) rename src/{ffi3 => ffi}/weakrefobject.rs (98%) delete mode 100644 src/ffi3/mod.rs diff --git a/src/ffi3/LICENSE b/src/ffi/LICENSE similarity index 100% rename from src/ffi3/LICENSE rename to src/ffi/LICENSE diff --git a/src/ffi3/README.md b/src/ffi/README.md similarity index 100% rename from src/ffi3/README.md rename to src/ffi/README.md diff --git a/src/ffi3/bltinmodule.rs b/src/ffi/bltinmodule.rs similarity index 83% rename from src/ffi3/bltinmodule.rs rename to src/ffi/bltinmodule.rs index eb268dfa..f7069178 100644 --- a/src/ffi3/bltinmodule.rs +++ b/src/ffi/bltinmodule.rs @@ -1,4 +1,4 @@ -use crate::ffi3::object::PyTypeObject; +use crate::ffi::object::PyTypeObject; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { diff --git a/src/ffi3/boolobject.rs b/src/ffi/boolobject.rs similarity index 92% rename from src/ffi3/boolobject.rs rename to src/ffi/boolobject.rs index 947d9ab0..d0b41d57 100644 --- a/src/ffi3/boolobject.rs +++ b/src/ffi/boolobject.rs @@ -1,5 +1,5 @@ -use crate::ffi3::longobject::PyLongObject; -use crate::ffi3::object::*; +use crate::ffi::longobject::PyLongObject; +use crate::ffi::object::*; use std::os::raw::{c_int, c_long}; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/bytearrayobject.rs b/src/ffi/bytearrayobject.rs similarity index 95% rename from src/ffi3/bytearrayobject.rs rename to src/ffi/bytearrayobject.rs index 2b661109..f383ade9 100644 --- a/src/ffi3/bytearrayobject.rs +++ b/src/ffi/bytearrayobject.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/bytesobject.rs b/src/ffi/bytesobject.rs similarity index 97% rename from src/ffi3/bytesobject.rs rename to src/ffi/bytesobject.rs index c91055af..f3566d57 100644 --- a/src/ffi3/bytesobject.rs +++ b/src/ffi/bytesobject.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/ceval.rs b/src/ffi/ceval.rs similarity index 87% rename from src/ffi3/ceval.rs rename to src/ffi/ceval.rs index 3c77de60..34238292 100644 --- a/src/ffi3/ceval.rs +++ b/src/ffi/ceval.rs @@ -1,7 +1,7 @@ #[cfg(Py_3_6)] -use crate::ffi3::code::FreeFunc; -use crate::ffi3::object::PyObject; -use crate::ffi3::pystate::PyThreadState; +use crate::ffi::code::FreeFunc; +use crate::ffi::object::PyObject; +use crate::ffi::pystate::PyThreadState; use std::os::raw::{c_char, c_int, c_void}; #[cfg_attr(windows, link(name = "pythonXY"))] @@ -36,7 +36,7 @@ extern "C" { pub fn PyEval_GetGlobals() -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyEval_GetLocals")] pub fn PyEval_GetLocals() -> *mut PyObject; - pub fn PyEval_GetFrame() -> *mut crate::ffi3::PyFrameObject; + pub fn PyEval_GetFrame() -> *mut crate::ffi::PyFrameObject; #[cfg_attr(PyPy, link_name = "PyPy_AddPendingCall")] pub fn Py_AddPendingCall( func: Option c_int>, @@ -55,22 +55,22 @@ extern "C" { // TODO: Py_EnterRecursiveCall etc. #[cfg(Py_3_6)] pub type _PyFrameEvalFunction = - extern "C" fn(*mut crate::ffi3::PyFrameObject, c_int) -> *mut PyObject; + extern "C" fn(*mut crate::ffi::PyFrameObject, c_int) -> *mut PyObject; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { pub fn PyEval_GetFuncName(arg1: *mut PyObject) -> *const c_char; pub fn PyEval_GetFuncDesc(arg1: *mut PyObject) -> *const c_char; pub fn PyEval_GetCallStats(arg1: *mut PyObject) -> *mut PyObject; - pub fn PyEval_EvalFrame(arg1: *mut crate::ffi3::PyFrameObject) -> *mut PyObject; + pub fn PyEval_EvalFrame(arg1: *mut crate::ffi::PyFrameObject) -> *mut PyObject; #[cfg(Py_3_6)] pub fn _PyEval_EvalFrameDefault( - arg1: *mut crate::ffi3::PyFrameObject, + arg1: *mut crate::ffi::PyFrameObject, exc: c_int, ) -> *mut PyObject; #[cfg(Py_3_6)] pub fn _PyEval_RequestCodeExtraIndex(func: FreeFunc) -> c_int; - pub fn PyEval_EvalFrameEx(f: *mut crate::ffi3::PyFrameObject, exc: c_int) -> *mut PyObject; + pub fn PyEval_EvalFrameEx(f: *mut crate::ffi::PyFrameObject, exc: c_int) -> *mut PyObject; #[cfg_attr(PyPy, link_name = "PyPyEval_SaveThread")] pub fn PyEval_SaveThread() -> *mut PyThreadState; #[cfg_attr(PyPy, link_name = "PyPyEval_RestoreThread")] diff --git a/src/ffi3/code.rs b/src/ffi/code.rs similarity index 96% rename from src/ffi3/code.rs rename to src/ffi/code.rs index 71ad0376..310cb307 100644 --- a/src/ffi3/code.rs +++ b/src/ffi/code.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int, c_uchar, c_void}; #[repr(C)] @@ -124,5 +124,5 @@ pub unsafe fn PyCode_Check(op: *mut PyObject) -> c_int { #[inline] #[cfg_attr(PyPy, link_name = "PyPyCode_GetNumFree")] pub unsafe fn PyCode_GetNumFree(op: *mut PyCodeObject) -> Py_ssize_t { - crate::ffi3::tupleobject::PyTuple_GET_SIZE((*op).co_freevars) + crate::ffi::tupleobject::PyTuple_GET_SIZE((*op).co_freevars) } diff --git a/src/ffi3/codecs.rs b/src/ffi/codecs.rs similarity index 98% rename from src/ffi3/codecs.rs rename to src/ffi/codecs.rs index d8241da0..b94cdd48 100644 --- a/src/ffi3/codecs.rs +++ b/src/ffi/codecs.rs @@ -1,4 +1,4 @@ -use crate::ffi3::object::PyObject; +use crate::ffi::object::PyObject; use std::os::raw::{c_char, c_int}; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/compile.rs b/src/ffi/compile.rs similarity index 94% rename from src/ffi3/compile.rs rename to src/ffi/compile.rs index a55a301c..11386762 100644 --- a/src/ffi3/compile.rs +++ b/src/ffi/compile.rs @@ -1,7 +1,7 @@ -use crate::ffi3::code::*; -use crate::ffi3::object::PyObject; -use crate::ffi3::pyarena::*; -use crate::ffi3::pythonrun::*; +use crate::ffi::code::*; +use crate::ffi::object::PyObject; +use crate::ffi::pyarena::*; +use crate::ffi::pythonrun::*; use std::os::raw::{c_char, c_int}; #[repr(C)] diff --git a/src/ffi3/complexobject.rs b/src/ffi/complexobject.rs similarity index 98% rename from src/ffi3/complexobject.rs rename to src/ffi/complexobject.rs index 62fc2004..024c93f9 100644 --- a/src/ffi3/complexobject.rs +++ b/src/ffi/complexobject.rs @@ -1,4 +1,4 @@ -use crate::ffi3::object::*; +use crate::ffi::object::*; use std::os::raw::{c_double, c_int}; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/descrobject.rs b/src/ffi/descrobject.rs similarity index 92% rename from src/ffi3/descrobject.rs rename to src/ffi/descrobject.rs index 05af23b0..9d3a0544 100644 --- a/src/ffi3/descrobject.rs +++ b/src/ffi/descrobject.rs @@ -1,8 +1,8 @@ -use crate::ffi3::methodobject::PyMethodDef; -use crate::ffi3::object::{PyObject, PyTypeObject}; +use crate::ffi::methodobject::PyMethodDef; +use crate::ffi::object::{PyObject, PyTypeObject}; #[cfg(not(PyPy))] -use crate::ffi3::object::{PyObject_GenericGetDict, PyObject_GenericSetDict}; -use crate::ffi3::structmember::PyMemberDef; +use crate::ffi::object::{PyObject_GenericGetDict, PyObject_GenericSetDict}; +use crate::ffi::structmember::PyMemberDef; use std::os::raw::{c_char, c_int, c_void}; use std::ptr; diff --git a/src/ffi3/dictobject.rs b/src/ffi/dictobject.rs similarity index 98% rename from src/ffi3/dictobject.rs rename to src/ffi/dictobject.rs index e6a40af3..6982f8f5 100644 --- a/src/ffi3/dictobject.rs +++ b/src/ffi/dictobject.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/enumobject.rs b/src/ffi/enumobject.rs similarity index 80% rename from src/ffi3/enumobject.rs rename to src/ffi/enumobject.rs index b036370d..6be7f1f3 100644 --- a/src/ffi3/enumobject.rs +++ b/src/ffi/enumobject.rs @@ -1,4 +1,4 @@ -use crate::ffi3::object::PyTypeObject; +use crate::ffi::object::PyTypeObject; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { diff --git a/src/ffi3/eval.rs b/src/ffi/eval.rs similarity index 94% rename from src/ffi3/eval.rs rename to src/ffi/eval.rs index abf276b7..bb2839b6 100644 --- a/src/ffi3/eval.rs +++ b/src/ffi/eval.rs @@ -1,4 +1,4 @@ -use crate::ffi3::object::PyObject; +use crate::ffi::object::PyObject; use std::os::raw::c_int; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/fileobject.rs b/src/ffi/fileobject.rs similarity index 96% rename from src/ffi3/fileobject.rs rename to src/ffi/fileobject.rs index 36152677..d5cb6eeb 100644 --- a/src/ffi3/fileobject.rs +++ b/src/ffi/fileobject.rs @@ -1,4 +1,4 @@ -use crate::ffi3::object::PyObject; +use crate::ffi::object::PyObject; use std::os::raw::{c_char, c_int}; pub const PY_STDIOTEXTMODE: &str = "b"; diff --git a/src/ffi3/floatobject.rs b/src/ffi/floatobject.rs similarity index 97% rename from src/ffi3/floatobject.rs rename to src/ffi/floatobject.rs index 89824862..f5d8edd3 100644 --- a/src/ffi3/floatobject.rs +++ b/src/ffi/floatobject.rs @@ -1,4 +1,4 @@ -use crate::ffi3::object::*; +use crate::ffi::object::*; use std::os::raw::{c_double, c_int}; #[cfg(not(Py_LIMITED_API))] diff --git a/src/ffi3/frameobject.rs b/src/ffi/frameobject.rs similarity index 96% rename from src/ffi3/frameobject.rs rename to src/ffi/frameobject.rs index c71212b4..ff564977 100644 --- a/src/ffi3/frameobject.rs +++ b/src/ffi/frameobject.rs @@ -1,6 +1,6 @@ -use crate::ffi3::code::{PyCodeObject, CO_MAXBLOCKS}; -use crate::ffi3::object::*; -use crate::ffi3::pystate::PyThreadState; +use crate::ffi::code::{PyCodeObject, CO_MAXBLOCKS}; +use crate::ffi::object::*; +use crate::ffi::pystate::PyThreadState; use std::os::raw::{c_char, c_int}; #[repr(C)] diff --git a/src/ffi3/genobject.rs b/src/ffi/genobject.rs similarity index 94% rename from src/ffi3/genobject.rs rename to src/ffi/genobject.rs index d36b5942..036b039d 100644 --- a/src/ffi3/genobject.rs +++ b/src/ffi/genobject.rs @@ -1,6 +1,6 @@ -use crate::ffi3::frameobject::PyFrameObject; -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::frameobject::PyFrameObject; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::c_int; #[repr(C)] diff --git a/src/ffi3/import.rs b/src/ffi/import.rs similarity index 98% rename from src/ffi3/import.rs rename to src/ffi/import.rs index 6a1ec2da..b72c6526 100644 --- a/src/ffi3/import.rs +++ b/src/ffi/import.rs @@ -1,4 +1,4 @@ -use crate::ffi3::object::PyObject; +use crate::ffi::object::PyObject; use std::os::raw::{c_char, c_int, c_long}; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/intrcheck.rs b/src/ffi/intrcheck.rs similarity index 100% rename from src/ffi3/intrcheck.rs rename to src/ffi/intrcheck.rs diff --git a/src/ffi3/iterobject.rs b/src/ffi/iterobject.rs similarity index 96% rename from src/ffi3/iterobject.rs rename to src/ffi/iterobject.rs index dde0df0d..b084f34a 100644 --- a/src/ffi3/iterobject.rs +++ b/src/ffi/iterobject.rs @@ -1,4 +1,4 @@ -use crate::ffi3::object::*; +use crate::ffi::object::*; use std::os::raw::c_int; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/listobject.rs b/src/ffi/listobject.rs similarity index 97% rename from src/ffi3/listobject.rs rename to src/ffi/listobject.rs index 1fb339cf..c504ae4b 100644 --- a/src/ffi3/listobject.rs +++ b/src/ffi/listobject.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::c_int; #[repr(C)] diff --git a/src/ffi3/longobject.rs b/src/ffi/longobject.rs similarity index 98% rename from src/ffi3/longobject.rs rename to src/ffi/longobject.rs index 1bd3076e..0419d510 100644 --- a/src/ffi3/longobject.rs +++ b/src/ffi/longobject.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use libc::size_t; use std::os::raw::{ c_char, c_double, c_int, c_long, c_longlong, c_uchar, c_ulong, c_ulonglong, c_void, diff --git a/src/ffi3/memoryobject.rs b/src/ffi/memoryobject.rs similarity index 93% rename from src/ffi3/memoryobject.rs rename to src/ffi/memoryobject.rs index e4879128..e3941457 100644 --- a/src/ffi3/memoryobject.rs +++ b/src/ffi/memoryobject.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/methodobject.rs b/src/ffi/methodobject.rs similarity index 96% rename from src/ffi3/methodobject.rs rename to src/ffi/methodobject.rs index 2a949ff2..d23cfbed 100644 --- a/src/ffi3/methodobject.rs +++ b/src/ffi/methodobject.rs @@ -1,4 +1,4 @@ -use crate::ffi3::object::{PyObject, PyTypeObject, Py_TYPE}; +use crate::ffi::object::{PyObject, PyTypeObject, Py_TYPE}; use std::os::raw::{c_char, c_int}; use std::{mem, ptr}; @@ -19,7 +19,7 @@ pub type PyCFunction = pub type _PyCFunctionFast = unsafe extern "C" fn( slf: *mut PyObject, args: *mut *mut PyObject, - nargs: crate::ffi3::pyport::Py_ssize_t, + nargs: crate::ffi::pyport::Py_ssize_t, kwnames: *mut PyObject, ) -> *mut PyObject; diff --git a/src/ffi/mod.rs b/src/ffi/mod.rs index c2ecbafd..7fa6d1b5 100644 --- a/src/ffi/mod.rs +++ b/src/ffi/mod.rs @@ -1,9 +1,157 @@ -#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] - -pub use crate::ffi3::*; +#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)] +#![cfg_attr(Py_LIMITED_API, allow(unused_imports))] +#![cfg_attr(feature="cargo-clippy", allow(clippy::inline_always))] +pub use self::bltinmodule::*; +pub use self::boolobject::*; +pub use self::bytearrayobject::*; +pub use self::bytesobject::*; +pub use self::ceval::*; +pub use self::code::*; +pub use self::codecs::*; +pub use self::compile::*; +pub use self::complexobject::*; pub use self::datetime::*; +pub use self::descrobject::*; +pub use self::dictobject::*; +pub use self::enumobject::*; +pub use self::eval::*; +pub use self::fileobject::*; +pub use self::floatobject::*; +pub use self::frameobject::PyFrameObject; +pub use self::genobject::*; +pub use self::import::*; +pub use self::intrcheck::*; +pub use self::iterobject::*; +pub use self::listobject::*; +pub use self::longobject::*; pub use self::marshal::*; +pub use self::memoryobject::*; +pub use self::methodobject::*; +pub use self::modsupport::*; +pub use self::moduleobject::*; +pub use self::object::*; +pub use self::objectabstract::*; +pub use self::objimpl::*; +#[cfg(Py_3_6)] +pub use self::osmodule::*; +pub use self::pyarena::*; +pub use self::pycapsule::*; +pub use self::pydebug::*; +pub use self::pyerrors::*; +pub use self::pyhash::*; +pub use self::pymem::*; +pub use self::pyport::*; +pub use self::pystate::*; +pub use self::pystrtod::*; +pub use self::pythonrun::*; +pub use self::rangeobject::*; +pub use self::setobject::*; +pub use self::sliceobject::*; +pub use self::structseq::*; +pub use self::sysmodule::*; +pub use self::traceback::*; +pub use self::tupleobject::*; +pub use self::typeslots::*; +pub use self::unicodeobject::*; +pub use self::warnings::*; +pub use self::weakrefobject::*; + +mod pyport; +// mod pymacro; contains nothing of interest for Rust +// mod pyatomic; contains nothing of interest for Rust +// mod pymath; contains nothing of interest for Rust + +// [cfg(not(Py_LIMITED_API))] +// mod pytime; contains nothing of interest + +mod pymem; + +mod object; +mod objimpl; +mod pydebug; +mod pyhash; +mod typeslots; + +mod bytearrayobject; +mod bytesobject; +mod longobject; +mod unicodeobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 + // mod longintrepr; TODO excluded by PEP-384 +mod boolobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod complexobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod dictobject; +mod floatobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod listobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod memoryobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod rangeobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod tupleobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 + // mod odictobject; TODO new in 3.5 +mod enumobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod methodobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod moduleobject; +mod setobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 + // mod funcobject; TODO excluded by PEP-384 + // mod classobject; TODO excluded by PEP-384 +mod fileobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod pycapsule; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod sliceobject; +mod traceback; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 + // mod cellobject; TODO excluded by PEP-384 +mod descrobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod genobject; // TODO excluded by PEP-384 +mod iterobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod structseq; +mod warnings; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod weakrefobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 + // mod namespaceobject; TODO + +mod codecs; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod pyerrors; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 + +mod pystate; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 + +#[cfg(Py_LIMITED_API)] +mod pyarena {} +mod modsupport; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +#[cfg(not(Py_LIMITED_API))] +mod pyarena; // TODO: incomplete +mod pythonrun; // TODO some functions need to be moved to pylifecycle + //mod pylifecycle; // TODO new in 3.5 +mod ceval; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +mod import; +mod intrcheck; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 +#[cfg(Py_3_6)] +mod osmodule; +mod sysmodule; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 + +mod bltinmodule; +mod objectabstract; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 + +#[cfg(Py_LIMITED_API)] +mod code {} +#[cfg(not(Py_LIMITED_API))] +mod code; + +mod compile; // TODO: incomplete +mod eval; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 + +// mod pyctype; TODO excluded by PEP-384 +mod pystrtod; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 + // mod pystrcmp; TODO nothing interesting for Rust? + // mod dtoa; TODO excluded by PEP-384 + // mod fileutils; TODO no public functions? + // mod pyfpe; TODO probably not interesting for rust + +// Additional headers that are not exported by Python.h +pub mod structmember; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 + +#[cfg(not(Py_LIMITED_API))] +pub mod frameobject; +#[cfg(Py_LIMITED_API)] +pub mod frameobject { + pub enum PyFrameObject {} +} pub(crate) mod datetime; pub(crate) mod marshal; diff --git a/src/ffi3/modsupport.rs b/src/ffi/modsupport.rs similarity index 96% rename from src/ffi3/modsupport.rs rename to src/ffi/modsupport.rs index 19bfebfe..7aeff5b8 100644 --- a/src/ffi3/modsupport.rs +++ b/src/ffi/modsupport.rs @@ -1,7 +1,7 @@ -use crate::ffi3::methodobject::PyMethodDef; -use crate::ffi3::moduleobject::PyModuleDef; -use crate::ffi3::object::PyObject; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::methodobject::PyMethodDef; +use crate::ffi::moduleobject::PyModuleDef; +use crate::ffi::object::PyObject; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int, c_long}; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/moduleobject.rs b/src/ffi/moduleobject.rs similarity index 96% rename from src/ffi3/moduleobject.rs rename to src/ffi/moduleobject.rs index f1f49887..2a5f9fd4 100644 --- a/src/ffi3/moduleobject.rs +++ b/src/ffi/moduleobject.rs @@ -1,6 +1,6 @@ -use crate::ffi3::methodobject::PyMethodDef; -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::methodobject::PyMethodDef; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int, c_void}; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/object.rs b/src/ffi/object.rs similarity index 94% rename from src/ffi3/object.rs rename to src/ffi/object.rs index 1fd32c19..69f5ed0b 100644 --- a/src/ffi3/object.rs +++ b/src/ffi/object.rs @@ -1,4 +1,4 @@ -use crate::ffi3::pyport::{Py_hash_t, Py_ssize_t}; +use crate::ffi::pyport::{Py_hash_t, Py_ssize_t}; #[cfg(PyPy)] use std::ffi::CStr; use std::mem; @@ -77,8 +77,8 @@ pub unsafe fn Py_REFCNT(ob: *mut PyObject) -> Py_ssize_t { #[cfg(PyPy)] pub unsafe fn _PyObject_NextNotImplemented(arg1: *mut PyObject) -> *mut PyObject { - return crate::ffi3::pyerrors::PyErr_Format( - crate::ffi3::pyerrors::PyExc_TypeError, + return crate::ffi::pyerrors::PyErr_Format( + crate::ffi::pyerrors::PyExc_TypeError, CStr::from_bytes_with_nul(b"'%.200s' object is not iterable\0") .unwrap() .as_ptr(), @@ -132,7 +132,7 @@ pub type objobjargproc = #[cfg(not(Py_LIMITED_API))] mod bufferinfo { - use crate::ffi3::pyport::Py_ssize_t; + use crate::ffi::pyport::Py_ssize_t; use std::mem; use std::os::raw::{c_char, c_int, c_void}; @@ -140,7 +140,7 @@ mod bufferinfo { #[derive(Copy, Clone)] pub struct Py_buffer { pub buf: *mut c_void, - pub obj: *mut crate::ffi3::PyObject, + pub obj: *mut crate::ffi::PyObject, pub len: Py_ssize_t, pub itemsize: Py_ssize_t, pub readonly: c_int, @@ -160,12 +160,12 @@ mod bufferinfo { } pub type getbufferproc = unsafe extern "C" fn( - arg1: *mut crate::ffi3::PyObject, + arg1: *mut crate::ffi::PyObject, arg2: *mut Py_buffer, arg3: c_int, ) -> c_int; pub type releasebufferproc = - unsafe extern "C" fn(arg1: *mut crate::ffi3::PyObject, arg2: *mut Py_buffer) -> (); + unsafe extern "C" fn(arg1: *mut crate::ffi::PyObject, arg2: *mut Py_buffer) -> (); /// Maximum number of dimensions pub const PyBUF_MAX_NDIM: c_int = 64; @@ -249,8 +249,8 @@ mod typeobject { #[cfg(not(Py_LIMITED_API))] mod typeobject { - use crate::ffi3::pyport::Py_ssize_t; - use crate::ffi3::{self, object}; + use crate::ffi::pyport::Py_ssize_t; + use crate::ffi::{self, object}; use std::mem; use std::os::raw::{c_char, c_uint, c_ulong, c_void}; use std::ptr; @@ -485,27 +485,27 @@ mod typeobject { pub tp_weaklistoffset: Py_ssize_t, pub tp_iter: Option, pub tp_iternext: Option, - pub tp_methods: *mut ffi3::methodobject::PyMethodDef, - pub tp_members: *mut ffi3::structmember::PyMemberDef, - pub tp_getset: *mut ffi3::descrobject::PyGetSetDef, + pub tp_methods: *mut ffi::methodobject::PyMethodDef, + pub tp_members: *mut ffi::structmember::PyMemberDef, + pub tp_getset: *mut ffi::descrobject::PyGetSetDef, pub tp_base: *mut PyTypeObject, - pub tp_dict: *mut ffi3::object::PyObject, - pub tp_descr_get: Option, - pub tp_descr_set: Option, + pub tp_dict: *mut ffi::object::PyObject, + pub tp_descr_get: Option, + pub tp_descr_set: Option, pub tp_dictoffset: Py_ssize_t, - pub tp_init: Option, - pub tp_alloc: Option, - pub tp_new: Option, - pub tp_free: Option, - pub tp_is_gc: Option, - pub tp_bases: *mut ffi3::object::PyObject, - pub tp_mro: *mut ffi3::object::PyObject, - pub tp_cache: *mut ffi3::object::PyObject, - pub tp_subclasses: *mut ffi3::object::PyObject, - pub tp_weaklist: *mut ffi3::object::PyObject, - pub tp_del: Option, + pub tp_init: Option, + pub tp_alloc: Option, + pub tp_new: Option, + pub tp_free: Option, + pub tp_is_gc: Option, + pub tp_bases: *mut ffi::object::PyObject, + pub tp_mro: *mut ffi::object::PyObject, + pub tp_cache: *mut ffi::object::PyObject, + pub tp_subclasses: *mut ffi::object::PyObject, + pub tp_weaklist: *mut ffi::object::PyObject, + pub tp_del: Option, pub tp_version_tag: c_uint, - pub tp_finalize: Option, + pub tp_finalize: Option, #[cfg(PyPy)] pub tp_pypy_flags: ::std::os::raw::c_long, #[cfg(py_sys_config = "COUNT_ALLOCS")] @@ -543,7 +543,7 @@ mod typeobject { tp_getattro: None, tp_setattro: None, tp_as_buffer: ptr::null_mut(), - tp_flags: ffi3::object::Py_TPFLAGS_DEFAULT, + tp_flags: ffi::object::Py_TPFLAGS_DEFAULT, tp_doc: ptr::null(), tp_traverse: None, tp_clear: None, @@ -597,8 +597,8 @@ mod typeobject { macro_rules! py_type_object_init { ($tp_as_async:ident, $($tail:tt)*) => { _type_object_init!({ - ob_base: ffi3::object::PyVarObject { - ob_base: ffi3::object::PyObject_HEAD_INIT, + ob_base: ffi::object::PyVarObject { + ob_base: ffi::object::PyObject_HEAD_INIT, ob_size: 0 },} $tp_as_async, @@ -640,9 +640,9 @@ mod typeobject { pub as_mapping: PyMappingMethods, pub as_sequence: PySequenceMethods, pub as_buffer: PyBufferProcs, - pub ht_name: *mut ffi3::object::PyObject, - pub ht_slots: *mut ffi3::object::PyObject, - pub ht_qualname: *mut ffi3::object::PyObject, + pub ht_name: *mut ffi::object::PyObject, + pub ht_slots: *mut ffi::object::PyObject, + pub ht_qualname: *mut ffi::object::PyObject, pub ht_cached_keys: *mut c_void, } @@ -656,10 +656,10 @@ mod typeobject { #[inline] pub unsafe fn PyHeapType_GET_MEMBERS( etype: *mut PyHeapTypeObject, - ) -> *mut ffi3::structmember::PyMemberDef { - let py_type = ffi3::object::Py_TYPE(etype as *mut ffi3::object::PyObject); + ) -> *mut ffi::structmember::PyMemberDef { + let py_type = ffi::object::Py_TYPE(etype as *mut ffi::object::PyObject); let ptr = etype.offset((*py_type).tp_basicsize); - ptr as *mut ffi3::structmember::PyMemberDef + ptr as *mut ffi::structmember::PyMemberDef } } diff --git a/src/ffi3/objectabstract.rs b/src/ffi/objectabstract.rs similarity index 99% rename from src/ffi3/objectabstract.rs rename to src/ffi/objectabstract.rs index a95bc6e3..a1fb403f 100644 --- a/src/ffi3/objectabstract.rs +++ b/src/ffi/objectabstract.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int, c_void}; use std::ptr; @@ -161,7 +161,7 @@ pub unsafe fn PyIter_Check(o: *mut PyObject) -> c_int { (match (*(*o).ob_type).tp_iternext { Some(tp_iternext) => { tp_iternext as *const c_void - != crate::ffi3::object::_PyObject_NextNotImplemented as *const c_void + != crate::ffi::object::_PyObject_NextNotImplemented as *const c_void } None => false, }) as c_int diff --git a/src/ffi3/objimpl.rs b/src/ffi/objimpl.rs similarity index 98% rename from src/ffi3/objimpl.rs rename to src/ffi/objimpl.rs index 9aa9437d..60f192a5 100644 --- a/src/ffi3/objimpl.rs +++ b/src/ffi/objimpl.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use libc::size_t; use std::os::raw::{c_int, c_void}; diff --git a/src/ffi3/osmodule.rs b/src/ffi/osmodule.rs similarity index 82% rename from src/ffi3/osmodule.rs rename to src/ffi/osmodule.rs index 19348aec..06621436 100644 --- a/src/ffi3/osmodule.rs +++ b/src/ffi/osmodule.rs @@ -1,5 +1,5 @@ // This header is new in Python 3.6 -use crate::ffi3::object::PyObject; +use crate::ffi::object::PyObject; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { diff --git a/src/ffi3/pyarena.rs b/src/ffi/pyarena.rs similarity index 100% rename from src/ffi3/pyarena.rs rename to src/ffi/pyarena.rs diff --git a/src/ffi3/pycapsule.rs b/src/ffi/pycapsule.rs similarity index 98% rename from src/ffi3/pycapsule.rs rename to src/ffi/pycapsule.rs index a0fcee9f..2865ec75 100644 --- a/src/ffi3/pycapsule.rs +++ b/src/ffi/pycapsule.rs @@ -1,4 +1,4 @@ -use crate::ffi3::object::*; +use crate::ffi::object::*; use std::os::raw::{c_char, c_int, c_void}; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/pydebug.rs b/src/ffi/pydebug.rs similarity index 100% rename from src/ffi3/pydebug.rs rename to src/ffi/pydebug.rs diff --git a/src/ffi3/pyerrors.rs b/src/ffi/pyerrors.rs similarity index 99% rename from src/ffi3/pyerrors.rs rename to src/ffi/pyerrors.rs index bc12572e..1e81a2e4 100644 --- a/src/ffi3/pyerrors.rs +++ b/src/ffi/pyerrors.rs @@ -1,7 +1,7 @@ -use crate::ffi3::object::*; +use crate::ffi::object::*; #[cfg(PyPy)] -use crate::ffi3::objectabstract::PyObject_CallFunction; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::objectabstract::PyObject_CallFunction; +use crate::ffi::pyport::Py_ssize_t; #[cfg(PyPy)] use std::ffi::CStr; use std::os::raw::{c_char, c_int}; diff --git a/src/ffi3/pyhash.rs b/src/ffi/pyhash.rs similarity index 91% rename from src/ffi3/pyhash.rs rename to src/ffi/pyhash.rs index 69d43296..3a57bf2a 100644 --- a/src/ffi3/pyhash.rs +++ b/src/ffi/pyhash.rs @@ -1,4 +1,4 @@ -use crate::ffi3::pyport::{Py_hash_t, Py_ssize_t}; +use crate::ffi::pyport::{Py_hash_t, Py_ssize_t}; use std::os::raw::{c_char, c_int, c_void}; #[repr(C)] diff --git a/src/ffi3/pymem.rs b/src/ffi/pymem.rs similarity index 100% rename from src/ffi3/pymem.rs rename to src/ffi/pymem.rs diff --git a/src/ffi3/pyport.rs b/src/ffi/pyport.rs similarity index 100% rename from src/ffi3/pyport.rs rename to src/ffi/pyport.rs diff --git a/src/ffi3/pystate.rs b/src/ffi/pystate.rs similarity index 95% rename from src/ffi3/pystate.rs rename to src/ffi/pystate.rs index 19afac0a..92c43422 100644 --- a/src/ffi3/pystate.rs +++ b/src/ffi/pystate.rs @@ -1,7 +1,7 @@ #[cfg(Py_3_6)] -use crate::ffi3::ceval::_PyFrameEvalFunction; -use crate::ffi3::moduleobject::PyModuleDef; -use crate::ffi3::object::PyObject; +use crate::ffi::ceval::_PyFrameEvalFunction; +use crate::ffi::moduleobject::PyModuleDef; +use crate::ffi::object::PyObject; use std::os::raw::{c_int, c_long}; #[cfg(Py_3_6)] diff --git a/src/ffi3/pystrtod.rs b/src/ffi/pystrtod.rs similarity index 96% rename from src/ffi3/pystrtod.rs rename to src/ffi/pystrtod.rs index 0fc2e2f8..18d8b23d 100644 --- a/src/ffi3/pystrtod.rs +++ b/src/ffi/pystrtod.rs @@ -1,4 +1,4 @@ -use crate::ffi3::object::PyObject; +use crate::ffi::object::PyObject; use std::os::raw::{c_char, c_double, c_int}; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/pythonrun.rs b/src/ffi/pythonrun.rs similarity index 98% rename from src/ffi3/pythonrun.rs rename to src/ffi/pythonrun.rs index 2ee8e2a5..03041b53 100644 --- a/src/ffi3/pythonrun.rs +++ b/src/ffi/pythonrun.rs @@ -1,7 +1,7 @@ -use crate::ffi3::object::*; +use crate::ffi::object::*; #[cfg(not(Py_LIMITED_API))] -use crate::ffi3::pyarena::PyArena; -use crate::ffi3::pystate::PyThreadState; +use crate::ffi::pyarena::PyArena; +use crate::ffi::pystate::PyThreadState; use libc::{wchar_t, FILE}; use std::os::raw::{c_char, c_int}; use std::ptr; diff --git a/src/ffi3/rangeobject.rs b/src/ffi/rangeobject.rs similarity index 93% rename from src/ffi3/rangeobject.rs rename to src/ffi/rangeobject.rs index 65c6529b..1f2195bb 100644 --- a/src/ffi3/rangeobject.rs +++ b/src/ffi/rangeobject.rs @@ -1,4 +1,4 @@ -use crate::ffi3::object::*; +use crate::ffi::object::*; use std::os::raw::c_int; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/setobject.rs b/src/ffi/setobject.rs similarity index 97% rename from src/ffi3/setobject.rs rename to src/ffi/setobject.rs index ea06fd75..d1e4dbd7 100644 --- a/src/ffi3/setobject.rs +++ b/src/ffi/setobject.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::c_int; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/sliceobject.rs b/src/ffi/sliceobject.rs similarity index 95% rename from src/ffi3/sliceobject.rs rename to src/ffi/sliceobject.rs index 02d23071..9068a887 100644 --- a/src/ffi3/sliceobject.rs +++ b/src/ffi/sliceobject.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::c_int; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/structmember.rs b/src/ffi/structmember.rs similarity index 96% rename from src/ffi3/structmember.rs rename to src/ffi/structmember.rs index a0816792..b5749ae6 100644 --- a/src/ffi3/structmember.rs +++ b/src/ffi/structmember.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::PyObject; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::PyObject; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; #[repr(C)] diff --git a/src/ffi3/structseq.rs b/src/ffi/structseq.rs similarity index 90% rename from src/ffi3/structseq.rs rename to src/ffi/structseq.rs index c99a0f04..96857a4c 100644 --- a/src/ffi3/structseq.rs +++ b/src/ffi/structseq.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::{PyObject, PyTypeObject}; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::{PyObject, PyTypeObject}; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; #[repr(C)] diff --git a/src/ffi3/sysmodule.rs b/src/ffi/sysmodule.rs similarity index 94% rename from src/ffi3/sysmodule.rs rename to src/ffi/sysmodule.rs index f52e1b37..3af451c2 100644 --- a/src/ffi3/sysmodule.rs +++ b/src/ffi/sysmodule.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::PyObject; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::PyObject; +use crate::ffi::pyport::Py_ssize_t; use libc::wchar_t; use std::os::raw::{c_char, c_int}; diff --git a/src/ffi3/traceback.rs b/src/ffi/traceback.rs similarity index 84% rename from src/ffi3/traceback.rs rename to src/ffi/traceback.rs index 8bd12bf3..0e3fc959 100644 --- a/src/ffi3/traceback.rs +++ b/src/ffi/traceback.rs @@ -1,10 +1,10 @@ -use crate::ffi3::object::*; +use crate::ffi::object::*; use std::os::raw::c_int; #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { #[cfg_attr(PyPy, link_name = "PyPyTraceBack_Here")] - pub fn PyTraceBack_Here(arg1: *mut crate::ffi3::PyFrameObject) -> c_int; + pub fn PyTraceBack_Here(arg1: *mut crate::ffi::PyFrameObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyTraceBack_Print")] pub fn PyTraceBack_Print(arg1: *mut PyObject, arg2: *mut PyObject) -> c_int; #[cfg_attr(PyPy, link_name = "PyPyTraceBack_Type")] diff --git a/src/ffi3/tupleobject.rs b/src/ffi/tupleobject.rs similarity index 97% rename from src/ffi3/tupleobject.rs rename to src/ffi/tupleobject.rs index d626e07c..191016a6 100644 --- a/src/ffi3/tupleobject.rs +++ b/src/ffi/tupleobject.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::c_int; #[repr(C)] diff --git a/src/ffi3/typeslots.rs b/src/ffi/typeslots.rs similarity index 100% rename from src/ffi3/typeslots.rs rename to src/ffi/typeslots.rs diff --git a/src/ffi3/unicodeobject.rs b/src/ffi/unicodeobject.rs similarity index 99% rename from src/ffi3/unicodeobject.rs rename to src/ffi/unicodeobject.rs index b50dd00b..2b8e5dec 100644 --- a/src/ffi3/unicodeobject.rs +++ b/src/ffi/unicodeobject.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::*; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::*; +use crate::ffi::pyport::Py_ssize_t; use libc::wchar_t; use std::os::raw::{c_char, c_int, c_void}; diff --git a/src/ffi3/warnings.rs b/src/ffi/warnings.rs similarity index 92% rename from src/ffi3/warnings.rs rename to src/ffi/warnings.rs index c26a493f..331c1ed4 100644 --- a/src/ffi3/warnings.rs +++ b/src/ffi/warnings.rs @@ -1,5 +1,5 @@ -use crate::ffi3::object::PyObject; -use crate::ffi3::pyport::Py_ssize_t; +use crate::ffi::object::PyObject; +use crate::ffi::pyport::Py_ssize_t; use std::os::raw::{c_char, c_int}; #[cfg_attr(windows, link(name = "pythonXY"))] diff --git a/src/ffi3/weakrefobject.rs b/src/ffi/weakrefobject.rs similarity index 98% rename from src/ffi3/weakrefobject.rs rename to src/ffi/weakrefobject.rs index 0c8a0baa..1cacfcbf 100644 --- a/src/ffi3/weakrefobject.rs +++ b/src/ffi/weakrefobject.rs @@ -1,4 +1,4 @@ -use crate::ffi3::object::*; +use crate::ffi::object::*; use std::os::raw::c_int; pub enum PyWeakReference {} diff --git a/src/ffi3/mod.rs b/src/ffi3/mod.rs deleted file mode 100644 index b3d537fe..00000000 --- a/src/ffi3/mod.rs +++ /dev/null @@ -1,153 +0,0 @@ -//! Rust FFI declarations for Python 3 -#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)] -#![cfg_attr(Py_LIMITED_API, allow(unused_imports))] -#![cfg_attr(feature="cargo-clippy", allow(clippy::inline_always))] - -pub use self::bltinmodule::*; -pub use self::boolobject::*; -pub use self::bytearrayobject::*; -pub use self::bytesobject::*; -pub use self::ceval::*; -pub use self::code::*; -pub use self::codecs::*; -pub use self::compile::*; -pub use self::complexobject::*; -pub use self::descrobject::*; -pub use self::dictobject::*; -pub use self::enumobject::*; -pub use self::eval::*; -pub use self::fileobject::*; -pub use self::floatobject::*; -pub use self::frameobject::PyFrameObject; -pub use self::genobject::*; -pub use self::import::*; -pub use self::intrcheck::*; -pub use self::iterobject::*; -pub use self::listobject::*; -pub use self::longobject::*; -pub use self::memoryobject::*; -pub use self::methodobject::*; -pub use self::modsupport::*; -pub use self::moduleobject::*; -pub use self::object::*; -pub use self::objectabstract::*; -pub use self::objimpl::*; -#[cfg(Py_3_6)] -pub use self::osmodule::*; -pub use self::pyarena::*; -pub use self::pycapsule::*; -pub use self::pydebug::*; -pub use self::pyerrors::*; -pub use self::pyhash::*; -pub use self::pymem::*; -pub use self::pyport::*; -pub use self::pystate::*; -pub use self::pystrtod::*; -pub use self::pythonrun::*; -pub use self::rangeobject::*; -pub use self::setobject::*; -pub use self::sliceobject::*; -pub use self::structseq::*; -pub use self::sysmodule::*; -pub use self::traceback::*; -pub use self::tupleobject::*; -pub use self::typeslots::*; -pub use self::unicodeobject::*; -pub use self::warnings::*; -pub use self::weakrefobject::*; - -mod pyport; -// mod pymacro; contains nothing of interest for Rust -// mod pyatomic; contains nothing of interest for Rust -// mod pymath; contains nothing of interest for Rust - -// [cfg(not(Py_LIMITED_API))] -// mod pytime; contains nothing of interest - -mod pymem; - -mod object; -mod objimpl; -mod pydebug; -mod pyhash; -mod typeslots; - -mod bytearrayobject; -mod bytesobject; -mod longobject; -mod unicodeobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 - // mod longintrepr; TODO excluded by PEP-384 -mod boolobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod complexobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod dictobject; -mod floatobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod listobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod memoryobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod rangeobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod tupleobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 - // mod odictobject; TODO new in 3.5 -mod enumobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod methodobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod moduleobject; -mod setobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 - // mod funcobject; TODO excluded by PEP-384 - // mod classobject; TODO excluded by PEP-384 -mod fileobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod pycapsule; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod sliceobject; -mod traceback; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 - // mod cellobject; TODO excluded by PEP-384 -mod descrobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod genobject; // TODO excluded by PEP-384 -mod iterobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod structseq; -mod warnings; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod weakrefobject; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 - // mod namespaceobject; TODO - -mod codecs; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod pyerrors; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 - -mod pystate; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 - -#[cfg(Py_LIMITED_API)] -mod pyarena {} -mod modsupport; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -#[cfg(not(Py_LIMITED_API))] -mod pyarena; // TODO: incomplete -mod pythonrun; // TODO some functions need to be moved to pylifecycle - //mod pylifecycle; // TODO new in 3.5 -mod ceval; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -mod import; -mod intrcheck; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 -#[cfg(Py_3_6)] -mod osmodule; -mod sysmodule; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 - -mod bltinmodule; -mod objectabstract; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 - -#[cfg(Py_LIMITED_API)] -mod code {} -#[cfg(not(Py_LIMITED_API))] -mod code; - -mod compile; // TODO: incomplete -mod eval; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 - -// mod pyctype; TODO excluded by PEP-384 -mod pystrtod; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 - // mod pystrcmp; TODO nothing interesting for Rust? - // mod dtoa; TODO excluded by PEP-384 - // mod fileutils; TODO no public functions? - // mod pyfpe; TODO probably not interesting for rust - -// Additional headers that are not exported by Python.h -pub mod structmember; // TODO supports PEP-384 only; needs adjustment for Python 3.3 and 3.5 - -#[cfg(not(Py_LIMITED_API))] -pub mod frameobject; -#[cfg(Py_LIMITED_API)] -pub mod frameobject { - pub enum PyFrameObject {} -} diff --git a/src/lib.rs b/src/lib.rs index 788ccd81..b98d69b5 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -149,8 +149,6 @@ pub use unindent; /// Raw ffi declarations for the c interface of python pub mod ffi; -mod ffi3; - pub mod buffer; #[doc(hidden)] pub mod callback;