Move opencv_type_simple_generic to opencv_type module
MODIFY
src/manual/core.rs
src/manual/core.rs
@@ -29,36 +29,6 @@ macro_rules! valid_types {
};
}
-macro_rules! opencv_type_simple_generic {
- ($type: ident<$trait: ident>) => {
- impl<T: $trait> $crate::traits::OpenCVType<'_> for $type<T> {
- type Arg = Self;
- type ExternReceive = Self;
- type ExternContainer = Self;
-
- #[inline] fn opencv_into_extern_container(self) -> $crate::Result<Self> { Ok(self) }
- #[inline] fn opencv_into_extern_container_nofail(self) -> Self { self }
- #[inline] unsafe fn opencv_from_extern(s: Self) -> Self { s }
- }
-
- impl<T: $trait> $crate::traits::OpenCVTypeArg<'_> for $type<T> {
- type ExternContainer = Self;
-
- #[inline] fn opencv_into_extern_container(self) -> $crate::Result<Self> { Ok(self) }
- #[inline] fn opencv_into_extern_container_nofail(self) -> Self { self }
- }
-
- impl<T: $trait> $crate::traits::OpenCVTypeExternContainer for $type<T> {
- type ExternSend = *const Self;
- type ExternSendMut = *mut Self;
-
- #[inline] fn opencv_as_extern(&self) -> Self::ExternSend { self }
- #[inline] fn opencv_as_extern_mut(&mut self) -> Self::ExternSendMut { self }
- #[inline] fn opencv_into_extern(self) -> Self::ExternSendMut { &mut *std::mem::ManuallyDrop::new(self) as _ }
- }
- };
-}
-
mod affine3;
mod gpumat;
mod input_output_array;

MODIFY
src/manual/core/affine3.rs
src/manual/core/affine3.rs
-use crate::core::{Matx44, ValidMatxType, MatxTrait};
+use crate::{
+ core::{Matx44, MatxTrait, ValidMatxType},
+ opencv_type_simple_generic,
+};
/// [docs.opencv.org](https://docs.opencv.org/master/dd/d99/classcv_1_1Affine3.html)
#[repr(C)]

MODIFY
src/manual/core/point.rs
src/manual/core/point.rs
@@ -2,7 +2,10 @@ use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
use num_traits::{NumCast, ToPrimitive};
-use crate::core::{Rect_, Size_, ValidRectType, ValidSizeType, ValidVecType, Vec2};
+use crate::{
+ core::{Rect_, Size_, ValidRectType, ValidSizeType, ValidVecType, Vec2},
+ opencv_type_simple_generic,
+};
valid_types!(ValidPointType: i32, i64, f32, f64);

MODIFY
src/manual/core/point3.rs
src/manual/core/point3.rs
@@ -2,7 +2,10 @@ use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
use num_traits::{NumCast, ToPrimitive, Zero};
-use crate::core::{Point_, ValidPointType, ValidVecType, Vec3};
+use crate::{
+ core::{Point_, ValidPointType, ValidVecType, Vec3},
+ opencv_type_simple_generic,
+};
valid_types!(ValidPoint3Type: i32, f32, f64);

MODIFY
src/manual/core/rect.rs
src/manual/core/rect.rs
@@ -6,7 +6,10 @@ use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign};
use num_traits::{NumCast, ToPrimitive};
-use crate::core::{Point_, prelude::*, RotatedRect, Size_, ValidPointType, ValidSizeType};
+use crate::{
+ core::{Point_, prelude::*, RotatedRect, Size_, ValidPointType, ValidSizeType},
+ opencv_type_simple_generic,
+};
valid_types!(ValidRectType: i32, f32, f64);

MODIFY
src/manual/core/size.rs
src/manual/core/size.rs
@@ -2,7 +2,10 @@ use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
use num_traits::{NumCast, ToPrimitive};
-use crate::core::{Point_, ValidPointType};
+use crate::{
+ core::{Point_, ValidPointType},
+ opencv_type_simple_generic,
+};
valid_types!(ValidSizeType: i32, i64, f32, f64);

MODIFY
src/manual/core/vec.rs
src/manual/core/vec.rs
@@ -2,6 +2,7 @@ use std::ffi::c_void;
use crate::{
core::{_InputArray, ToInputArray},
+ opencv_type_simple_generic,
Result,
sys,
traits::Boxed,

MODIFY
src/traits/opencv_type.rs
src/traits/opencv_type.rs
@@ -140,6 +140,37 @@ macro_rules! opencv_type_simple {
};
}
+#[macro_export]
+macro_rules! opencv_type_simple_generic {
+ ($type: ident<$trait: ident>) => {
+ impl<T: $trait> $crate::traits::OpenCVType<'_> for $type<T> {
+ type Arg = Self;
+ type ExternReceive = Self;
+ type ExternContainer = Self;
+
+ #[inline] fn opencv_into_extern_container(self) -> $crate::Result<Self> { Ok(self) }
+ #[inline] fn opencv_into_extern_container_nofail(self) -> Self { self }
+ #[inline] unsafe fn opencv_from_extern(s: Self) -> Self { s }
+ }
+
+ impl<T: $trait> $crate::traits::OpenCVTypeArg<'_> for $type<T> {
+ type ExternContainer = Self;
+
+ #[inline] fn opencv_into_extern_container(self) -> $crate::Result<Self> { Ok(self) }
+ #[inline] fn opencv_into_extern_container_nofail(self) -> Self { self }
+ }
+
+ impl<T: $trait> $crate::traits::OpenCVTypeExternContainer for $type<T> {
+ type ExternSend = *const Self;
+ type ExternSendMut = *mut Self;
+
+ #[inline] fn opencv_as_extern(&self) -> Self::ExternSend { self }
+ #[inline] fn opencv_as_extern_mut(&mut self) -> Self::ExternSendMut { self }
+ #[inline] fn opencv_into_extern(self) -> Self::ExternSendMut { &mut *std::mem::ManuallyDrop::new(self) as _ }
+ }
+ };
+}
+
pub fn cstring_new_nofail(bytes: impl Into<Vec<u8>>) -> CString {
match CString::new(bytes) {
Ok(s) => {

Move opencv_type_simple_generic to opencv_type module