rename InstancePtr to AsPyRef
This commit is contained in:
parent
40efa5c955
commit
c4ba2b0f2e
|
@ -9,7 +9,7 @@ use objects::exc;
|
||||||
use conversion::IntoPyObject;
|
use conversion::IntoPyObject;
|
||||||
use ffi::{self, Py_hash_t};
|
use ffi::{self, Py_hash_t};
|
||||||
use err::{PyErr, PyResult};
|
use err::{PyErr, PyResult};
|
||||||
use token::{Py, InstancePtr};
|
use token::{Py, AsPyRef};
|
||||||
use typeob::PyTypeInfo;
|
use typeob::PyTypeInfo;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ use err::{PyErr, PyResult};
|
||||||
use python::{Python, IntoPyPointer};
|
use python::{Python, IntoPyPointer};
|
||||||
use objects::PyObject;
|
use objects::PyObject;
|
||||||
use objects::exc;
|
use objects::exc;
|
||||||
use token::{Py, InstancePtr};
|
use token::{Py, AsPyRef};
|
||||||
use typeob::PyTypeInfo;
|
use typeob::PyTypeInfo;
|
||||||
use conversion::{FromPyObject, IntoPyObject};
|
use conversion::{FromPyObject, IntoPyObject};
|
||||||
use callback::{PyObjectCallbackConverter, HashConverter, BoolCallbackConverter};
|
use callback::{PyObjectCallbackConverter, HashConverter, BoolCallbackConverter};
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std::os::raw::{c_int, c_void};
|
||||||
use ffi;
|
use ffi;
|
||||||
use python::{Python, ToPyPointer};
|
use python::{Python, ToPyPointer};
|
||||||
use callback::AbortOnDrop;
|
use callback::AbortOnDrop;
|
||||||
use token::{Py, InstancePtr};
|
use token::{Py, AsPyRef};
|
||||||
use typeob::PyTypeInfo;
|
use typeob::PyTypeInfo;
|
||||||
|
|
||||||
pub struct PyTraverseError(c_int);
|
pub struct PyTraverseError(c_int);
|
||||||
|
|
|
@ -10,7 +10,7 @@ macro_rules! py_unary_func {
|
||||||
unsafe extern "C" fn wrap<T>(slf: *mut $crate::ffi::PyObject) -> $ret_type
|
unsafe extern "C" fn wrap<T>(slf: *mut $crate::ffi::PyObject) -> $ret_type
|
||||||
where T: for<'p> $trait<'p>
|
where T: for<'p> $trait<'p>
|
||||||
{
|
{
|
||||||
use token::InstancePtr;
|
use token::AsPyRef;
|
||||||
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
||||||
|
|
||||||
$crate::callback::cb_pyfunc::<_, _, $res_type>(LOCATION, $conv, |py| {
|
$crate::callback::cb_pyfunc::<_, _, $res_type>(LOCATION, $conv, |py| {
|
||||||
|
@ -35,7 +35,7 @@ macro_rules! py_unary_func {
|
||||||
-> *mut $crate::ffi::PyObject
|
-> *mut $crate::ffi::PyObject
|
||||||
where T: for<'p> $trait<'p>
|
where T: for<'p> $trait<'p>
|
||||||
{
|
{
|
||||||
use token::InstancePtr;
|
use token::AsPyRef;
|
||||||
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
||||||
|
|
||||||
$crate::callback::cb_pyfunc::<_, _, $res_type>(LOCATION, $conv, |py| {
|
$crate::callback::cb_pyfunc::<_, _, $res_type>(LOCATION, $conv, |py| {
|
||||||
|
@ -82,7 +82,7 @@ macro_rules! py_binary_func{
|
||||||
arg: *mut ffi::PyObject) -> $return
|
arg: *mut ffi::PyObject) -> $return
|
||||||
where T: for<'p> $trait<'p>
|
where T: for<'p> $trait<'p>
|
||||||
{
|
{
|
||||||
use token::InstancePtr;
|
use token::AsPyRef;
|
||||||
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
||||||
|
|
||||||
$crate::callback::cb_pyfunc::<_, _, $res_type>(LOCATION, $conv, |py| {
|
$crate::callback::cb_pyfunc::<_, _, $res_type>(LOCATION, $conv, |py| {
|
||||||
|
@ -116,7 +116,7 @@ macro_rules! py_binary_self_func{
|
||||||
arg: *mut ffi::PyObject) -> *mut $crate::ffi::PyObject
|
arg: *mut ffi::PyObject) -> *mut $crate::ffi::PyObject
|
||||||
where T: for<'p> $trait<'p>
|
where T: for<'p> $trait<'p>
|
||||||
{
|
{
|
||||||
use token::InstancePtr;
|
use token::AsPyRef;
|
||||||
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
||||||
|
|
||||||
$crate::callback::cb_meth(LOCATION, |py| {
|
$crate::callback::cb_meth(LOCATION, |py| {
|
||||||
|
@ -161,7 +161,7 @@ macro_rules! py_ssizearg_func {
|
||||||
arg: $crate::Py_ssize_t) -> *mut $crate::ffi::PyObject
|
arg: $crate::Py_ssize_t) -> *mut $crate::ffi::PyObject
|
||||||
where T: for<'p> $trait<'p>
|
where T: for<'p> $trait<'p>
|
||||||
{
|
{
|
||||||
use token::InstancePtr;
|
use token::AsPyRef;
|
||||||
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
||||||
|
|
||||||
$crate::callback::cb_meth(LOCATION, |py| {
|
$crate::callback::cb_meth(LOCATION, |py| {
|
||||||
|
@ -190,7 +190,7 @@ macro_rules! py_ternary_func{
|
||||||
arg2: *mut $crate::ffi::PyObject) -> $return_type
|
arg2: *mut $crate::ffi::PyObject) -> $return_type
|
||||||
where T: for<'p> $trait<'p>
|
where T: for<'p> $trait<'p>
|
||||||
{
|
{
|
||||||
use token::InstancePtr;
|
use token::AsPyRef;
|
||||||
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
||||||
|
|
||||||
$crate::callback::cb_pyfunc::<_, _, $res_type>(LOCATION, $conv, |py| {
|
$crate::callback::cb_pyfunc::<_, _, $res_type>(LOCATION, $conv, |py| {
|
||||||
|
@ -229,7 +229,7 @@ macro_rules! py_ternary_self_func{
|
||||||
-> *mut $crate::ffi::PyObject
|
-> *mut $crate::ffi::PyObject
|
||||||
where T: for<'p> $trait<'p>
|
where T: for<'p> $trait<'p>
|
||||||
{
|
{
|
||||||
use token::InstancePtr;
|
use token::AsPyRef;
|
||||||
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
||||||
|
|
||||||
$crate::callback::cb_meth(LOCATION, |py| {
|
$crate::callback::cb_meth(LOCATION, |py| {
|
||||||
|
@ -323,7 +323,7 @@ macro_rules! py_func_del{
|
||||||
value: *mut $crate::ffi::PyObject) -> $crate::c_int
|
value: *mut $crate::ffi::PyObject) -> $crate::c_int
|
||||||
where T: for<'p> $trait<'p>
|
where T: for<'p> $trait<'p>
|
||||||
{
|
{
|
||||||
use token::InstancePtr;
|
use token::AsPyRef;
|
||||||
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
||||||
|
|
||||||
$crate::callback::cb_pyfunc::<_, _, ()>(
|
$crate::callback::cb_pyfunc::<_, _, ()>(
|
||||||
|
@ -375,7 +375,7 @@ macro_rules! py_func_set_del{
|
||||||
value: *mut $crate::ffi::PyObject) -> $crate::c_int
|
value: *mut $crate::ffi::PyObject) -> $crate::c_int
|
||||||
where T: for<'p> $trait<'p> + for<'p> $trait2<'p>
|
where T: for<'p> $trait<'p> + for<'p> $trait2<'p>
|
||||||
{
|
{
|
||||||
use token::InstancePtr;
|
use token::AsPyRef;
|
||||||
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
|
||||||
|
|
||||||
$crate::callback::cb_pyfunc::<_, _, ()>(
|
$crate::callback::cb_pyfunc::<_, _, ()>(
|
||||||
|
|
|
@ -157,7 +157,7 @@ mod pointers;
|
||||||
pub use pointers::PyPtr;
|
pub use pointers::PyPtr;
|
||||||
|
|
||||||
pub mod token;
|
pub mod token;
|
||||||
pub use token::{PyToken, PyObjectWithToken, InstancePtr, Py};
|
pub use token::{PyToken, PyObjectWithToken, Py, AsPyRef};
|
||||||
|
|
||||||
pub use err::{PyErr, PyResult, PyDowncastError, ToPyErr};
|
pub use err::{PyErr, PyResult, PyDowncastError, ToPyErr};
|
||||||
pub use objects::*;
|
pub use objects::*;
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub trait PyObjectWithToken : Sized {
|
||||||
fn token(&self) -> Python;
|
fn token(&self) -> Python;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait InstancePtr<T> : Sized {
|
pub trait AsPyRef<T> : Sized {
|
||||||
|
|
||||||
fn as_ref(&self, py: Python) -> &T;
|
fn as_ref(&self, py: Python) -> &T;
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ impl<T> Py<T> where T: PyTypeInfo,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> InstancePtr<T> for Py<T> where T: PyTypeInfo {
|
impl<T> AsPyRef<T> for Py<T> where T: PyTypeInfo {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_ref(&self, _py: Python) -> &T {
|
fn as_ref(&self, _py: Python) -> &T {
|
||||||
|
@ -202,7 +202,6 @@ impl<T> ToPyObject for Py<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl<T> IntoPyObject for Py<T> {
|
impl<T> IntoPyObject for Py<T> {
|
||||||
/// Converts `Py` instance -> PyObject.
|
/// Converts `Py` instance -> PyObject.
|
||||||
/// Consumes `self` without calling `Py_DECREF()`
|
/// Consumes `self` without calling `Py_DECREF()`
|
||||||
|
|
Loading…
Reference in New Issue