rename InstancePtr to AsPyRef

This commit is contained in:
Nikolay Kim 2017-06-20 14:22:49 -07:00
parent 40efa5c955
commit c4ba2b0f2e
6 changed files with 15 additions and 16 deletions

View File

@ -9,7 +9,7 @@ use objects::exc;
use conversion::IntoPyObject;
use ffi::{self, Py_hash_t};
use err::{PyErr, PyResult};
use token::{Py, InstancePtr};
use token::{Py, AsPyRef};
use typeob::PyTypeInfo;

View File

@ -15,7 +15,7 @@ use err::{PyErr, PyResult};
use python::{Python, IntoPyPointer};
use objects::PyObject;
use objects::exc;
use token::{Py, InstancePtr};
use token::{Py, AsPyRef};
use typeob::PyTypeInfo;
use conversion::{FromPyObject, IntoPyObject};
use callback::{PyObjectCallbackConverter, HashConverter, BoolCallbackConverter};

View File

@ -9,7 +9,7 @@ use std::os::raw::{c_int, c_void};
use ffi;
use python::{Python, ToPyPointer};
use callback::AbortOnDrop;
use token::{Py, InstancePtr};
use token::{Py, AsPyRef};
use typeob::PyTypeInfo;
pub struct PyTraverseError(c_int);

View File

@ -10,7 +10,7 @@ macro_rules! py_unary_func {
unsafe extern "C" fn wrap<T>(slf: *mut $crate::ffi::PyObject) -> $ret_type
where T: for<'p> $trait<'p>
{
use token::InstancePtr;
use token::AsPyRef;
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
$crate::callback::cb_pyfunc::<_, _, $res_type>(LOCATION, $conv, |py| {
@ -35,7 +35,7 @@ macro_rules! py_unary_func {
-> *mut $crate::ffi::PyObject
where T: for<'p> $trait<'p>
{
use token::InstancePtr;
use token::AsPyRef;
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
$crate::callback::cb_pyfunc::<_, _, $res_type>(LOCATION, $conv, |py| {
@ -82,7 +82,7 @@ macro_rules! py_binary_func{
arg: *mut ffi::PyObject) -> $return
where T: for<'p> $trait<'p>
{
use token::InstancePtr;
use token::AsPyRef;
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
$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
where T: for<'p> $trait<'p>
{
use token::InstancePtr;
use token::AsPyRef;
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
$crate::callback::cb_meth(LOCATION, |py| {
@ -161,7 +161,7 @@ macro_rules! py_ssizearg_func {
arg: $crate::Py_ssize_t) -> *mut $crate::ffi::PyObject
where T: for<'p> $trait<'p>
{
use token::InstancePtr;
use token::AsPyRef;
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
$crate::callback::cb_meth(LOCATION, |py| {
@ -190,7 +190,7 @@ macro_rules! py_ternary_func{
arg2: *mut $crate::ffi::PyObject) -> $return_type
where T: for<'p> $trait<'p>
{
use token::InstancePtr;
use token::AsPyRef;
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
$crate::callback::cb_pyfunc::<_, _, $res_type>(LOCATION, $conv, |py| {
@ -229,7 +229,7 @@ macro_rules! py_ternary_self_func{
-> *mut $crate::ffi::PyObject
where T: for<'p> $trait<'p>
{
use token::InstancePtr;
use token::AsPyRef;
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
$crate::callback::cb_meth(LOCATION, |py| {
@ -323,7 +323,7 @@ macro_rules! py_func_del{
value: *mut $crate::ffi::PyObject) -> $crate::c_int
where T: for<'p> $trait<'p>
{
use token::InstancePtr;
use token::AsPyRef;
const LOCATION: &'static str = concat!(stringify!($class), ".", stringify!($f), "()");
$crate::callback::cb_pyfunc::<_, _, ()>(
@ -375,7 +375,7 @@ macro_rules! py_func_set_del{
value: *mut $crate::ffi::PyObject) -> $crate::c_int
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), "()");
$crate::callback::cb_pyfunc::<_, _, ()>(

View File

@ -157,7 +157,7 @@ mod pointers;
pub use pointers::PyPtr;
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 objects::*;

View File

@ -24,7 +24,7 @@ pub trait PyObjectWithToken : Sized {
fn token(&self) -> Python;
}
pub trait InstancePtr<T> : Sized {
pub trait AsPyRef<T> : Sized {
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]
fn as_ref(&self, _py: Python) -> &T {
@ -202,7 +202,6 @@ impl<T> ToPyObject for Py<T> {
}
}
impl<T> IntoPyObject for Py<T> {
/// Converts `Py` instance -> PyObject.
/// Consumes `self` without calling `Py_DECREF()`