Skip to content

Commit 0e2d0e6

Browse files
committed
Enable legacy trackers in tracker module
1 parent 2af361e commit 0e2d0e6

File tree

8 files changed

+37
-30
lines changed

8 files changed

+37
-30
lines changed

binding-generator/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ exclude = ["release.toml"]
1313
[lib]
1414

1515
[dependencies]
16-
clang = { version = "2", features = ["clang_6_0"] }
17-
clang-sys = { version = "1", features = ["clang_6_0"] }
16+
clang = { version = "2", features = ["clang_9_0"] }
17+
clang-sys = { version = "1", features = ["clang_9_0"] }
1818
dunce = "1"
1919
percent-encoding = { version = "2", default-features = false }
2020
regex = "1"

binding-generator/src/element.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,28 @@ impl DefaultElement {
4444
let mut entity = entity;
4545
let mut parts = vec![];
4646
while let Some(parent) = entity.get_semantic_parent() {
47-
match parent.get_kind() {
47+
let is_namespace_element = match parent.get_kind() {
48+
EntityKind::Namespace => !parent.is_inline_namespace(),
4849
EntityKind::ClassDecl
49-
| EntityKind::Namespace
5050
| EntityKind::StructDecl
5151
| EntityKind::EnumDecl
5252
| EntityKind::UnionDecl
5353
| EntityKind::ClassTemplate
5454
| EntityKind::ClassTemplatePartialSpecialization
5555
| EntityKind::FunctionTemplate
5656
| EntityKind::Method
57-
| EntityKind::FunctionDecl => {
58-
// handle anonymous enums inside classes and anonymous namespaces
59-
if let Some(parent_name) = parent.get_name() {
60-
parts.push(parent_name);
61-
}
62-
}
57+
| EntityKind::FunctionDecl => true,
6358
EntityKind::TranslationUnit
6459
| EntityKind::UnexposedDecl
6560
| EntityKind::LinkageSpec
6661
| EntityKind::NotImplemented
67-
| EntityKind::Constructor => {}
68-
_ => {
69-
unreachable!("Can't get kind of parent for cpp namespace: {:#?}", parent)
62+
| EntityKind::Constructor => false,
63+
_ => unreachable!("Can't get kind of parent for cpp namespace: {:#?}", parent),
64+
};
65+
if is_namespace_element {
66+
// handle anonymous enums inside classes and anonymous namespaces
67+
if let Some(parent_name) = parent.get_name() {
68+
parts.push(parent_name);
7069
}
7170
}
7271
entity = parent;

binding-generator/src/generator.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,7 @@ impl<'tu, V: GeneratorVisitor<'tu>> EntityWalkerVisitor<'tu> for OpenCvWalker<'t
152152
unreachable!("Unsupported VarDecl: {:#?}", entity)
153153
}
154154
}
155-
_ => {
156-
unreachable!("Unsupported entity: {:#?}", entity)
157-
}
155+
_ => unreachable!("Unsupported entity: {:#?}", entity),
158156
}
159157
ControlFlow::Continue(())
160158
}

binding-generator/src/settings.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ pub static NO_SKIP_NAMESPACE_IN_LOCALNAME: LazyLock<HashMap<Option<SupportedModu
284284
),
285285
(Some(SupportedModule::Stitching), HashMap::from([("fisheye", "Fisheye")])),
286286
(Some(SupportedModule::SuperRes), HashMap::from([("superres", "SuperRes")])),
287+
(Some(SupportedModule::Tracking), HashMap::from([("legacy", "Legacy")])),
287288
])
288289
});
289290

binding-generator/src/walker.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ impl<'tu> EntityWalkerExt<'tu> for Entity<'tu> {
5757
| EntityKind::Destructor
5858
| EntityKind::LinkageSpec
5959
| EntityKind::VarDecl => ControlFlow::Continue(()),
60-
_ => {
61-
unreachable!("Unsupported decl for file: {:#?}", root_decl)
62-
}
60+
_ => unreachable!("Unsupported decl for file: {:#?}", root_decl),
6361
}
6462
.into_entity_visit_result()
6563
} else {
@@ -96,9 +94,7 @@ fn visit_cv_namespace<'tu>(ns: Entity<'tu>, visitor: &mut impl EntityWalkerVisit
9694
/* ignoring */
9795
ControlFlow::Continue(())
9896
}
99-
_ => {
100-
unreachable!("Unsupported decl for OpenCV namespace: {:#?}", decl)
101-
}
97+
_ => unreachable!("Unsupported decl for OpenCV namespace: {:#?}", decl),
10298
}
10399
.into_entity_visit_result()
104100
});

binding-generator/src/writer/rust_native/element.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ impl DefaultRustNativeElement {
5555
parts.push(parent.get_name().expect("Can't get parent name").into());
5656
}
5757
}
58-
EntityKind::TranslationUnit | EntityKind::UnexposedDecl | EntityKind::FunctionTemplate => {
59-
break;
60-
}
58+
EntityKind::TranslationUnit | EntityKind::UnexposedDecl | EntityKind::FunctionTemplate => break,
6159
EntityKind::Namespace => {
6260
let parent_namespace = parent.get_name().expect("Can't get parent name");
6361
let no_skip_prefix = settings::NO_SKIP_NAMESPACE_IN_LOCALNAME
@@ -70,14 +68,10 @@ impl DefaultRustNativeElement {
7068
});
7169
if let Some(&prefix) = no_skip_prefix {
7270
parts.push(prefix.into());
73-
} else {
74-
break;
7571
}
7672
}
7773
EntityKind::Constructor | EntityKind::FunctionDecl | EntityKind::Method | EntityKind::NotImplemented => {}
78-
_ => {
79-
unreachable!("Can't get kind of parent: {parent:#?} for element: {entity:#?}")
80-
}
74+
_ => unreachable!("Can't get kind of parent: {parent:#?} for element: {entity:#?}"),
8175
}
8276
entity = parent;
8377
}

src_cpp/tracking.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "ocvrs_common.hpp"
2+
#include <opencv2/tracking.hpp>
3+
#if (CV_VERSION_MAJOR >= 5) /* 5+ */ \
4+
|| (CV_VERSION_MAJOR == 4 && CV_VERSION_MINOR >= 6) /* 4.6.0+ */ \
5+
|| (CV_VERSION_MAJOR == 4 && CV_VERSION_MINOR == 5 && CV_VERSION_REVISION >= 1) /* 4.5.1+ */
6+
#include <opencv2/tracking/tracking_legacy.hpp>
7+
#endif

src_cpp/video.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include "ocvrs_common.hpp"
2+
#include <opencv2/video.hpp>
3+
// this is needed to support the legacy tracking module (see tracking.hpp)
4+
#if (CV_VERSION_MAJOR >= 5) /* 5+ */ \
5+
|| (CV_VERSION_MAJOR == 4 && CV_VERSION_MINOR >= 6) /* 4.6.0+ */ \
6+
|| (CV_VERSION_MAJOR == 4 && CV_VERSION_MINOR == 5 && CV_VERSION_REVISION >= 1) /* 4.5.1+ */
7+
#if (CV_VERSION_MAJOR == 4 && CV_VERSION_MINOR == 5 && CV_VERSION_REVISION == 1) /* 4.5.1, header had a different name */
8+
#include <opencv2/video/detail/tracking.private.hpp>
9+
#else
10+
#include <opencv2/video/detail/tracking.detail.hpp>
11+
#endif
12+
#endif

0 commit comments

Comments
 (0)