Improve simple class detection
MODIFY
binding-generator/src/class.rs
binding-generator/src/class.rs
@@ -53,11 +53,26 @@ impl<'tu, 'ge> Class<'tu, 'ge> {
}
pub fn kind(&self) -> Kind {
- if settings::ELEMENT_EXCLUDE.contains(self.cpp_fullname().as_ref()) {
+ let cpp_fullname = self.cpp_fullname();
+ if settings::ELEMENT_EXCLUDE.contains(cpp_fullname.as_ref()) {
return Kind::Excluded
}
match self.gen_env.get_export_config(self.entity).map(|c| c.simple) {
- Some(true) => Kind::Simple,
+ Some(true) => {
+ let has_non_copy_fields = self.entity.walk_fields_while(|f| {
+ let type_ref = Field::new(f, self.gen_env).type_ref();
+ let non_copy_field = type_ref.as_string().is_some()
+ || type_ref.as_vector().is_some()
+ || type_ref.as_class().map_or(false, |c| !c.is_simple())
+ || self.gen_env.descendants.contains_key(cpp_fullname.as_ref());
+ !non_copy_field
+ });
+ if has_non_copy_fields {
+ Kind::Boxed
+ } else {
+ Kind::Simple
+ }
+ },
Some(false) => Kind::Boxed,
None => {
if self.is_system() {

MODIFY
binding-generator/src/settings.rs
binding-generator/src/settings.rs
@@ -661,11 +661,6 @@ pub static ELEMENT_EXPORT_MANUAL: Lazy<HashMap<&str, ExportConfig>> = Lazy::new(
});
pub static ELEMENT_EXPORT_TWEAK: Lazy<HashMap<&str, fn (&mut ExportConfig)>> = Lazy::new(|| hashmap! {
- "cv::TrackerGOTURN::Params" => ExportConfig::make_boxed as _, // contains String, so no Copy
- "cv::detail::CameraParams" => ExportConfig::make_boxed as _, // contains non-copy stuff
- "cv::detail::ImageFeatures" => ExportConfig::make_boxed as _, // contains non-copy stuff
- "cv::detail::MatchesInfo" => ExportConfig::make_boxed as _, // contains non-copy stuff
- "cv::detail::ProjectorBase" => ExportConfig::make_boxed as _, // other classes inherit from this one
"cv::dnn::ClassificationModel" => ExportConfig::make_boxed as _,
"cv::dnn::DetectionModel" => ExportConfig::make_boxed as _,
"cv::dnn::KeypointsModel" => ExportConfig::make_boxed as _, // marked as simple from OpenCV 4.5.2
@@ -674,11 +669,6 @@ pub static ELEMENT_EXPORT_TWEAK: Lazy<HashMap<&str, fn (&mut ExportConfig)>> = L
"cv::dnn::TextDetectionModel_DB" => ExportConfig::make_boxed as _, // incorrectly marked as simple
"cv::dnn::TextDetectionModel_EAST" => ExportConfig::make_boxed as _, // incorrectly marked as simple
"cv::dnn::TextRecognitionModel" => ExportConfig::make_boxed as _, // incorrectly marked as simple
- "cv::linemod::Match" => ExportConfig::make_boxed as _, // contains String
- "cv::linemod::Template" => ExportConfig::make_boxed as _, // contains String
- "cv::segmentation::IntelligentScissorsMB" => ExportConfig::make_boxed as _,
- "cv::tracking::TrackerCSRT::Params" => ExportConfig::make_boxed as _, // contains String, so no Copy
- "cv::viz::Mesh" => ExportConfig::make_boxed as _, // contains Mat, so no Copy
});
/// set of functions that should have unsafe in their declaration, element is Func.identifier()

Improve simple class detection