Skip to content

Commit 5fcd1e5

Browse files
authored
Merge pull request #109 from 9prady9/reorg_style_fixes
Reorganisation of type aliases and style fixes
2 parents 3f58888 + 30e76e1 commit 5fcd1e5

File tree

18 files changed

+38
-100
lines changed

18 files changed

+38
-100
lines changed

src/algorithm/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ use array::Array;
44
use defines::{AfError, BinaryOp};
55
use error::HANDLE_ERROR;
66
use self::libc::{c_int, uint8_t, c_uint, c_double};
7-
8-
type MutAfArray = *mut self::libc::c_longlong;
9-
type MutDouble = *mut self::libc::c_double;
10-
type MutUint = *mut self::libc::c_uint;
11-
type AfArray = self::libc::c_longlong;
7+
use util::{AfArray, MutAfArray, MutDouble, MutUint};
128

139
#[allow(dead_code)]
1410
extern {

src/arith/mod.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,8 @@ use error::HANDLE_ERROR;
88
use self::libc::{c_int};
99
use data::{constant, constant_t, tile};
1010
use self::num::Complex;
11-
11+
use util::{AfArray, Complex32, Complex64, MutAfArray};
1212
use std::ops::Neg;
13-
14-
type Complex32 = Complex<f32>;
15-
type Complex64 = Complex<f64>;
16-
type MutAfArray = *mut self::libc::c_longlong;
17-
type MutDouble = *mut self::libc::c_double;
18-
type MutUint = *mut self::libc::c_uint;
19-
type AfArray = self::libc::c_longlong;
20-
2113
use std::ops::{Add, Sub, Div, Mul, BitAnd, BitOr, BitXor, Not, Rem, Shl, Shr};
2214

2315
#[allow(dead_code)]

src/array.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,10 @@ extern crate libc;
33
use dim4::Dim4;
44
use defines::{AfError, DType, Backend};
55
use error::HANDLE_ERROR;
6-
use util::HasAfEnum;
6+
use util::{AfArray, DimT, HasAfEnum, MutAfArray, MutVoidPtr};
77
use self::libc::{uint8_t, c_void, c_int, c_uint, c_longlong, c_char};
88
use std::ffi::CString;
99

10-
type MutAfArray = *mut self::libc::c_longlong;
11-
type MutDouble = *mut self::libc::c_double;
12-
type MutUint = *mut self::libc::c_uint;
13-
type AfArray = self::libc::c_longlong;
14-
type DimT = self::libc::c_longlong;
15-
type MutVoidPtr = *mut self::libc::c_ulonglong;
16-
type VoidPtr = self::libc::c_ulonglong;
17-
1810
// Some unused functions from array.h in C-API of ArrayFire
1911
// af_create_handle
2012
// af_copy_array

src/blas/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ use defines::AfError;
55
use defines::MatProp;
66
use error::HANDLE_ERROR;
77
use self::libc::{c_uint, c_int};
8-
use util::to_u32;
9-
10-
type MutAfArray = *mut self::libc::c_longlong;
11-
type AfArray = self::libc::c_longlong;
8+
use util::{AfArray, MutAfArray, to_u32};
129

1310
#[allow(dead_code)]
1411
extern {

src/data/mod.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,9 @@ use defines::{AfError, DType, Scalar};
77
use error::HANDLE_ERROR;
88
use self::libc::{uint8_t, c_int, c_uint, c_double};
99
use self::num::Complex;
10-
use util::HasAfEnum;
10+
use util::{AfArray, DimT, HasAfEnum, Intl, MutAfArray, Uintl};
1111
use std::vec::Vec;
1212

13-
type MutAfArray = *mut self::libc::c_longlong;
14-
type MutDouble = *mut self::libc::c_double;
15-
type MutUint = *mut self::libc::c_uint;
16-
type AfArray = self::libc::c_longlong;
17-
type DimT = self::libc::c_longlong;
18-
type Intl = self::libc::c_longlong;
19-
type Uintl = self::libc::c_ulonglong;
20-
2113
#[allow(dead_code)]
2214
extern {
2315
fn af_constant(out: MutAfArray, val: c_double,

src/device/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
extern crate libc;
22

3-
use defines::{AfError, DType};
3+
use defines::{AfError};
44
use error::HANDLE_ERROR;
5-
use self::libc::{c_int, size_t, c_char, c_void};
5+
use self::libc::{c_int, size_t, c_char};
66
use std::ffi::{CStr, CString};
77
use std::borrow::Cow;
88
use util::free_host;

src/error.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,27 @@ use std::error::Error;
44
use std::marker::{Send, Sync};
55
use std::sync::RwLock;
66

7-
87
pub type ErrorCallback = Fn(AfError);
98

10-
119
/// Wrap ErrorCallback function pointer inside a structure
1210
/// to enable implementing Send, Sync traits on it.
1311
pub struct Callback<'cblifetime> {
1412
pub cb: &'cblifetime ErrorCallback,
1513
}
1614

17-
1815
// Implement Send, Sync traits for Callback structure to
1916
// enable the user of Callback function pointer in conjunction
2017
// with threads using a mutex.
2118
unsafe impl<'cblifetime> Send for Callback<'cblifetime> {}
2219
unsafe impl<'cblifetime> Sync for Callback<'cblifetime> {}
2320

24-
2521
pub const DEFAULT_HANDLE_ERROR: Callback<'static> = Callback{cb: &handle_error_general};
2622

27-
2823
lazy_static! {
2924
static ref ERROR_HANDLER_LOCK: RwLock< Callback<'static> > =
3025
RwLock::new(DEFAULT_HANDLE_ERROR);
3126
}
3227

33-
3428
/// Register user provided error handler
3529
///
3630
/// # Examples

src/graphics.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ use error::HANDLE_ERROR;
77
use self::libc::{c_int, c_uint, c_float, c_double, c_char};
88
use std::ffi::CString;
99
use std::ptr;
10-
11-
type MutWndHandle = *mut self::libc::c_ulonglong;
12-
type WndHandle = self::libc::c_ulonglong;
13-
type AfArray = self::libc::c_longlong;
14-
type CellPtr = *const self::libc::c_void;
10+
use util::{AfArray, CellPtr, MutWndHandle, WndHandle};
1511

1612
#[allow(dead_code)]
1713
extern {

src/image/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@ extern crate libc;
33
use array::Array;
44
use defines::{AfError, BorderType, ColorSpace, Connectivity, InterpType, YCCStd, MomentType};
55
use error::HANDLE_ERROR;
6-
use util::HasAfEnum;
6+
use util::{AfArray, DimT, HasAfEnum, MutAfArray};
77
use self::libc::{uint8_t, c_uint, c_int, c_float, c_double};
88

9-
type MutAfArray = *mut self::libc::c_longlong;
10-
type AfArray = self::libc::c_longlong;
11-
type DimT = self::libc::c_longlong;
12-
139
// unused functions from image.h header
1410
// af_load_image_memory
1511
// af_save_image_memory

src/index.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ use defines::AfError;
55
use error::HANDLE_ERROR;
66
use seq::Seq;
77
use self::libc::{c_double, c_int, c_uint};
8-
9-
type MutAfIndex = *mut self::libc::c_longlong;
10-
type MutAfArray = *mut self::libc::c_longlong;
11-
type AfArray = self::libc::c_longlong;
12-
type DimT = self::libc::c_longlong;
13-
type IndexT = self::libc::c_longlong;
8+
use util::{AfArray, DimT, IndexT, MutAfArray, MutAfIndex};
149

1510
#[allow(dead_code)]
1611
extern {

0 commit comments

Comments
 (0)