Skip to content

Commit

Permalink
Use pyobject_native_type macro exposed in PyO3/pyo3#155
Browse files Browse the repository at this point in the history
  • Loading branch information
termoshtt committed May 13, 2018
1 parent 1958ae1 commit 2e1b069
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ license-file = "LICENSE"
libc = "0.2"
num-complex = "0.1"
ndarray = "0.10"
pyo3 = "0.2"

[dependencies.pyo3]
git = "http://github.com/termoshtt/pyo3"
branch = "pyobject_macros"
version = "0.2"
6 changes: 1 addition & 5 deletions src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ use super::*;
/// Untyped safe interface for NumPy ndarray.
pub struct PyArray(PyObject);

impl ToPyPointer for PyArray {
fn as_ptr(&self) -> *mut ffi::PyObject {
self.0.as_ptr()
}
}
pyobject_native_type!(PyArray, npyffi::PyArray_Type, npyffi::PyArray_Check);

impl PyArray {
pub fn as_array_ptr(&self) -> *mut npyffi::PyArrayObject {
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#![feature(specialization)]

extern crate libc;
extern crate ndarray;
extern crate num_complex;
#[macro_use]
extern crate pyo3;

pub mod array;
Expand Down

0 comments on commit 2e1b069

Please sign in to comment.