Skip to content

Commit b19ba6f

Browse files
committed
Drop usage of dyn Trait in favor of generating regular boxed structs for abstract classes
1 parent 569deca commit b19ba6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+17072
-6015
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
* 0.82.0
2+
* Change the handling of abstract C++ classes, they are no longer exposed as `dyn Class` but a struct is generated for
3+
them making them easier to use from Rust. One notable change is calling static methods on those classes no longer
4+
requires UCS. So `<dyn ORB>::default()` becomes just `ORB::default()`. You might also need to adjust your imports
5+
because while traits are imported as part of the prelude, the structs need to be imported explicitly.
6+
17
* 0.81.5
28
* Bring back the `clang-runtime` feature to improve cooperation with other crates.
39

binding-generator/src/abstract_ref_wrapper.rs

Lines changed: 0 additions & 16 deletions
This file was deleted.

binding-generator/src/generator.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ use crate::entity::WalkAction;
1616
use crate::type_ref::{CppNameStyle, FishStyle, Kind as TypeRefKind};
1717
use crate::writer::rust_native::element::RustElement;
1818
use crate::{
19-
get_definition_text, line_reader, opencv_module_from_path, settings, AbstractRefWrapper, Class, ClassSimplicity,
20-
CompiledInterpolation, Const, Element, EntityExt, EntityWalker, EntityWalkerVisitor, Enum, Func, FunctionTypeHint,
21-
GeneratorEnv, SmartPtr, StrExt, Tuple, Typedef, Vector,
19+
get_definition_text, line_reader, opencv_module_from_path, settings, Class, ClassSimplicity, CompiledInterpolation, Const,
20+
Element, EntityExt, EntityWalker, EntityWalkerVisitor, Enum, Func, FunctionTypeHint, GeneratorEnv, SmartPtr, StrExt, Tuple,
21+
Typedef, Vector,
2222
};
2323

2424
#[derive(Debug)]
2525
pub enum GeneratedType<'tu, 'ge> {
26-
AbstractRefWrapper(AbstractRefWrapper<'tu, 'ge>),
2726
Vector(Vector<'tu, 'ge>),
2827
SmartPtr(SmartPtr<'tu, 'ge>),
2928
Tuple(Tuple<'tu, 'ge>),

binding-generator/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use clang::Entity;
2323
use dunce::canonicalize;
2424
use once_cell::sync::Lazy;
2525

26-
pub use abstract_ref_wrapper::AbstractRefWrapper;
2726
pub use class::Class;
2827
pub use constant::Const;
2928
pub use element::{is_opencv_path, opencv_module_from_path, DefaultElement, Element, EntityElement};
@@ -48,7 +47,6 @@ pub use typedef::Typedef;
4847
use vector::Vector;
4948
pub use walker::{EntityWalker, EntityWalkerVisitor};
5049

51-
mod abstract_ref_wrapper;
5250
mod class;
5351
pub mod comment;
5452
mod constant;

binding-generator/src/settings.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,9 @@ pub static NO_SKIP_NAMESPACE_IN_LOCALNAME: Lazy<HashMap<&str, HashMap<&str, &str
10631063
"cudaimgproc" => hashmap! {
10641064
"cuda" => "CUDA",
10651065
},
1066+
"cudaobjdetect" => hashmap! {
1067+
"cuda" => "CUDA",
1068+
},
10661069
"cudaoptflow" => hashmap! {
10671070
"cuda" => "CUDA",
10681071
},

binding-generator/src/type_ref.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ use crate::entity::WalkAction;
1010
use crate::renderer::{CppExternReturnRenderer, CppRenderer};
1111
use crate::{
1212
settings::{self, ArgOverride},
13-
AbstractRefWrapper, Class, Element, EntityExt, Enum, Function, GeneratedType, GeneratorEnv, SmartPtr, StringExt, Tuple,
14-
Typedef, Vector,
13+
Class, Element, EntityExt, Enum, Function, GeneratedType, GeneratorEnv, SmartPtr, StringExt, Tuple, Typedef, Vector,
1514
};
1615

1716
pub trait TypeRefRenderer<'a> {
@@ -798,11 +797,7 @@ impl<'tu, 'ge> TypeRef<'tu, 'ge> {
798797
}
799798
Kind::Typedef(typedef) => typedef.generated_types(),
800799
_ => {
801-
let mut out = vec![];
802-
if self.as_abstract_class_ptr().is_some() {
803-
out.push(GeneratedType::AbstractRefWrapper(AbstractRefWrapper::new(self.clone())))
804-
}
805-
out
800+
vec![]
806801
}
807802
}
808803
}

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

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)