Skip to content

Commit

Permalink
Drop usage of dyn Trait in favor of generating regular boxed structs …
Browse files Browse the repository at this point in the history
…for abstract classes
  • Loading branch information
twistedfall committed May 14, 2023
1 parent 569deca commit b19ba6f
Show file tree
Hide file tree
Showing 71 changed files with 17,072 additions and 6,015 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
* 0.82.0
* Change the handling of abstract C++ classes, they are no longer exposed as `dyn Class` but a struct is generated for
them making them easier to use from Rust. One notable change is calling static methods on those classes no longer
requires UCS. So `<dyn ORB>::default()` becomes just `ORB::default()`. You might also need to adjust your imports
because while traits are imported as part of the prelude, the structs need to be imported explicitly.

* 0.81.5
* Bring back the `clang-runtime` feature to improve cooperation with other crates.

Expand Down
16 changes: 0 additions & 16 deletions binding-generator/src/abstract_ref_wrapper.rs

This file was deleted.

7 changes: 3 additions & 4 deletions binding-generator/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ use crate::entity::WalkAction;
use crate::type_ref::{CppNameStyle, FishStyle, Kind as TypeRefKind};
use crate::writer::rust_native::element::RustElement;
use crate::{
get_definition_text, line_reader, opencv_module_from_path, settings, AbstractRefWrapper, Class, ClassSimplicity,
CompiledInterpolation, Const, Element, EntityExt, EntityWalker, EntityWalkerVisitor, Enum, Func, FunctionTypeHint,
GeneratorEnv, SmartPtr, StrExt, Tuple, Typedef, Vector,
get_definition_text, line_reader, opencv_module_from_path, settings, Class, ClassSimplicity, CompiledInterpolation, Const,
Element, EntityExt, EntityWalker, EntityWalkerVisitor, Enum, Func, FunctionTypeHint, GeneratorEnv, SmartPtr, StrExt, Tuple,
Typedef, Vector,
};

#[derive(Debug)]
pub enum GeneratedType<'tu, 'ge> {
AbstractRefWrapper(AbstractRefWrapper<'tu, 'ge>),
Vector(Vector<'tu, 'ge>),
SmartPtr(SmartPtr<'tu, 'ge>),
Tuple(Tuple<'tu, 'ge>),
Expand Down
2 changes: 0 additions & 2 deletions binding-generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use clang::Entity;
use dunce::canonicalize;
use once_cell::sync::Lazy;

pub use abstract_ref_wrapper::AbstractRefWrapper;
pub use class::Class;
pub use constant::Const;
pub use element::{is_opencv_path, opencv_module_from_path, DefaultElement, Element, EntityElement};
Expand All @@ -48,7 +47,6 @@ pub use typedef::Typedef;
use vector::Vector;
pub use walker::{EntityWalker, EntityWalkerVisitor};

mod abstract_ref_wrapper;
mod class;
pub mod comment;
mod constant;
Expand Down
3 changes: 3 additions & 0 deletions binding-generator/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,9 @@ pub static NO_SKIP_NAMESPACE_IN_LOCALNAME: Lazy<HashMap<&str, HashMap<&str, &str
"cudaimgproc" => hashmap! {
"cuda" => "CUDA",
},
"cudaobjdetect" => hashmap! {
"cuda" => "CUDA",
},
"cudaoptflow" => hashmap! {
"cuda" => "CUDA",
},
Expand Down
9 changes: 2 additions & 7 deletions binding-generator/src/type_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use crate::entity::WalkAction;
use crate::renderer::{CppExternReturnRenderer, CppRenderer};
use crate::{
settings::{self, ArgOverride},
AbstractRefWrapper, Class, Element, EntityExt, Enum, Function, GeneratedType, GeneratorEnv, SmartPtr, StringExt, Tuple,
Typedef, Vector,
Class, Element, EntityExt, Enum, Function, GeneratedType, GeneratorEnv, SmartPtr, StringExt, Tuple, Typedef, Vector,
};

pub trait TypeRefRenderer<'a> {
Expand Down Expand Up @@ -798,11 +797,7 @@ impl<'tu, 'ge> TypeRef<'tu, 'ge> {
}
Kind::Typedef(typedef) => typedef.generated_types(),
_ => {
let mut out = vec![];
if self.as_abstract_class_ptr().is_some() {
out.push(GeneratedType::AbstractRefWrapper(AbstractRefWrapper::new(self.clone())))
}
out
vec![]
}
}
}
Expand Down
33 changes: 0 additions & 33 deletions binding-generator/src/writer/rust_native/abstract_ref_wrapper.rs

This file was deleted.

Loading

0 comments on commit b19ba6f

Please sign in to comment.