Skip to content

Commit

Permalink
Add PyArrayIterObject
Browse files Browse the repository at this point in the history
  • Loading branch information
termoshtt committed Apr 21, 2017
1 parent 00065f6 commit 208e623
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions numpy-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ extern crate libc;
extern crate python3_sys as pyffi;

pub mod pyarray;
pub mod pyarrayiter;
pub mod pyufunc;
6 changes: 2 additions & 4 deletions numpy-sys/src/pyarray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,9 @@ pub struct PyArray_ArrFuncs {
pub argmin: PyArray_ArgFunc,
}

pub type NpyAuxData = NpyAuxData_tag;

#[repr(C)]
#[derive(Copy, Clone)]
pub struct NpyAuxData_tag {
pub struct NpyAuxData {
pub free: NpyAuxData_FreeFunc,
pub clone: NpyAuxData_CloneFunc,
pub reserved: [*mut ::std::os::raw::c_void; 2usize],
Expand Down Expand Up @@ -299,4 +297,4 @@ pub type PyArray_FastTakeFunc =
-> ::std::os::raw::c_int>;
pub type NpyAuxData_FreeFunc = ::std::option::Option<unsafe extern "C" fn(arg1: *mut NpyAuxData)>;
pub type NpyAuxData_CloneFunc =
::std::option::Option<unsafe extern "C" fn(arg1: *mut NpyAuxData) -> *mut NpyAuxData_tag>;
::std::option::Option<unsafe extern "C" fn(arg1: *mut NpyAuxData) -> *mut NpyAuxData>;
32 changes: 32 additions & 0 deletions numpy-sys/src/pyarrayiter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#![allow(non_camel_case_types)]
// FIXME ^ should be removed

use pyffi::*;
use super::pyarray::*;

pub type npy_bool = ::std::os::raw::c_uchar;
pub type npy_iter_get_dataptr_t =
::std::option::Option<unsafe extern "C" fn(iter: *mut PyArrayIterObject,
arg1: *mut npy_intp)
-> *mut ::std::os::raw::c_char>;

#[repr(C)]
#[derive(Clone, Copy)]
pub struct PyArrayIterObject {
pub ob_base: PyObject,
pub nd_m1: ::std::os::raw::c_int,
pub index: npy_intp,
pub size: npy_intp,
pub coordinates: [npy_intp; 32usize],
pub dims_m1: [npy_intp; 32usize],
pub strides: [npy_intp; 32usize],
pub backstrides: [npy_intp; 32usize],
pub factors: [npy_intp; 32usize],
pub ao: *mut PyArrayObject,
pub dataptr: *mut ::std::os::raw::c_char,
pub contiguous: npy_bool,
pub bounds: [[npy_intp; 2usize]; 32usize],
pub limits: [[npy_intp; 2usize]; 32usize],
pub limits_sizes: [npy_intp; 32usize],
pub translate: npy_iter_get_dataptr_t,
}

0 comments on commit 208e623

Please sign in to comment.