Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
twistedfall committed Apr 22, 2024
1 parent b9565e7 commit 2336e27
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 24 deletions.
3 changes: 2 additions & 1 deletion binding-generator/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ impl DefaultElement {
| EntityKind::ClassTemplate
| EntityKind::ClassTemplatePartialSpecialization
| EntityKind::FunctionTemplate
| EntityKind::Method => {
| EntityKind::Method
| EntityKind::FunctionDecl => {
// handle anonymous enums inside classes and anonymous namespaces
if let Some(parent_name) = parent.get_name() {
parts.push(parent_name);
Expand Down
2 changes: 1 addition & 1 deletion binding-generator/src/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ impl Element for Func<'_, '_> {
};
is_unavailable
|| settings::FUNC_EXCLUDE.contains(identifier.as_str())
|| (self.is_generic())
|| self.is_generic()
|| self.arguments().iter().any(|a| a.type_ref().exclude_kind().is_ignored())
|| kind.as_operator().map_or(false, |(_, kind)| match kind {
OperatorKind::Unsupported => true,
Expand Down
2 changes: 2 additions & 0 deletions binding-generator/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ pub static PRIMITIVE_TYPEDEFS: Lazy<HashMap<&str, (&str, &str)>> = Lazy::new(||

pub static STATIC_MODULES: Lazy<BTreeSet<&str>> = Lazy::new(|| BTreeSet::from(["core", "sys", "types"]));

/// Types that can be used as `Mat` element
/// cpp_name(Reference)
pub static DATA_TYPES: Lazy<HashSet<&str>> = Lazy::new(|| {
HashSet::from([
"unsigned char",
Expand Down
1 change: 0 additions & 1 deletion ci/msrv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ rustc --version
rustc --print=cfg

cargo update
rm -vf examples/cuda.rs # no CUDA support in CI
cargo check -vv --all-targets --all-features --workspace --tests
2 changes: 0 additions & 2 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ if [[ "${OPENCV_VERSION:-}" != "4.9.0" ]]; then
rm -vf tests/*_only_latest_opencv.rs
rm -vf examples/dnn_face_detect.rs examples/gapi_api_example.rs examples/text_detection.rs
fi
# the following examples don't work in CI
rm -vf examples/cuda.rs

echo "=== Current directory: $(pwd)"
echo "=== Environment variable dump:"
Expand Down
8 changes: 6 additions & 2 deletions examples/cuda.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{env, time};

use opencv::core::{GpuMat, Size};
use opencv::core::Size;
use opencv::prelude::*;
use opencv::{core, cudafilters, cudaimgproc, imgcodecs, imgproc, Result};
use opencv::{core, imgcodecs, imgproc, Result};

const ITERATIONS: usize = 100;

Expand Down Expand Up @@ -36,7 +36,11 @@ fn main() -> Result<()> {
imgproc::canny(&blurred, &mut edges, 0., 50., 3, false)?;
}
println!("{:#?}", start.elapsed());
#[cfg(all(ocvrs_has_module_cudafilters, ocvrs_has_module_cudaimgproc))]
if cuda_available {
use opencv::core::GpuMat;
use opencv::{cudafilters, cudaimgproc};

println!("Timing CUDA implementation... ");
let img = imgcodecs::imread(&img_file, imgcodecs::IMREAD_COLOR)?;
let mut img_gpu = GpuMat::new_def()?;
Expand Down
2 changes: 1 addition & 1 deletion src/manual/core/vector/vector_extern.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::core::Vector;
use crate::platform_types::size_t;
use crate::traits::OpenCVType;
use crate::{extern_arg_send, extern_container_send, extern_receive, extern_send};
use crate::{extern_arg_send, extern_container_send, extern_receive};

/// This trait is implemented by any type that can be stored inside `Vector`.
///
Expand Down
8 changes: 4 additions & 4 deletions src/traits/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@ macro_rules! opencv_type_boxed {
($type: ty) => {
impl $crate::traits::Boxed for $type {
#[inline]
unsafe fn from_raw(ptr: extern_receive!($type)) -> Self {
unsafe fn from_raw(ptr: $crate::extern_receive!($type)) -> Self {
Self { ptr }
}

#[inline]
fn into_raw(self) -> extern_send!(mut $type) {
fn into_raw(self) -> $crate::extern_send!(mut $type) {
::std::mem::ManuallyDrop::new(self).ptr
}

#[inline]
fn as_raw(&self) -> extern_send!($type) {
fn as_raw(&self) -> $crate::extern_send!($type) {
self.ptr
}

#[inline]
fn as_raw_mut(&mut self) -> extern_send!(mut $type) {
fn as_raw_mut(&mut self) -> $crate::extern_send!(mut $type) {
self.ptr
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/traits/opencv_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub trait OpenCVTypeExternContainerMove: OpenCVTypeExternContainer {
#[macro_export]
macro_rules! extern_receive {
($typ: ty) => {
extern_receive!($typ: '_)
$crate::extern_receive!($typ: '_)
};
($typ: ty: $lt: lifetime) => {
<$typ as $crate::traits::OpenCVType<$lt>>::ExternReceive
Expand All @@ -96,16 +96,16 @@ macro_rules! extern_send {
#[macro_export]
macro_rules! extern_container_send {
(mut $typ: ty: $lt: lifetime) => {
extern_send!(mut <$typ as $crate::traits::OpenCVTypeArg<$lt>>::ExternContainer)
$crate::extern_send!(mut <$typ as $crate::traits::OpenCVTypeArg<$lt>>::ExternContainer)
};
($typ: ty: $lt: lifetime) => {
extern_send!(<$typ as $crate::traits::OpenCVTypeArg<$lt>>::ExternContainer)
$crate::extern_send!(<$typ as $crate::traits::OpenCVTypeArg<$lt>>::ExternContainer)
};
(mut $typ: ty) => {
extern_container_send!(mut $typ: '_)
$crate::extern_container_send!(mut $typ: '_)
};
($typ: ty) => {
extern_container_send!($typ: '_)
$crate::extern_container_send!($typ: '_)
};
}

Expand All @@ -114,10 +114,10 @@ macro_rules! extern_container_send {
#[macro_export]
macro_rules! extern_arg_send {
(mut $typ: ty: $lt: lifetime) => {
extern_container_send!(mut <$typ as $crate::traits::OpenCVType<$lt>>::Arg: $lt)
$crate::extern_container_send!(mut <$typ as $crate::traits::OpenCVType<$lt>>::Arg: $lt)
};
($typ: ty: $lt: lifetime) => {
extern_container_send!(<$typ as $crate::traits::OpenCVType<$lt>>::Arg: $lt)
$crate::extern_container_send!(<$typ as $crate::traits::OpenCVType<$lt>>::Arg: $lt)
};
}

Expand Down
8 changes: 3 additions & 5 deletions tests/marshalling_only_latest_opencv.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
//! Tests that will not be run in CI on OpenCV 4.2.0, 4.5.4 and 3.4.16 due to missing classes

use opencv::prelude::*;
use opencv::Result;

/// Setting and getting fields through Ptr
#[test]
fn field_access_on_ptr() -> Result<()> {
#![cfg(all(ocvrs_has_module_aruco, any(ocvrs_opencv_branch_34, ocvrs_opencv_branch_4)))]
#[cfg(all(ocvrs_has_module_aruco, any(ocvrs_opencv_branch_34, ocvrs_opencv_branch_4)))]
fn field_access_on_ptr() -> opencv::Result<()> {
use opencv::aruco::EstimateParameters;
use opencv::prelude::*;
// the location and parameters are wildly different between even the minor release in the OpenCV branches, so for now
// let's just limit to only those fields that are stable
// #[cfg(ocvrs_opencv_branch_34)]
Expand Down

0 comments on commit 2336e27

Please sign in to comment.