Enable optflow module
MODIFY
binding-generator/src/bin/settings-cleanup.rs
binding-generator/src/bin/settings-cleanup.rs
@@ -78,6 +78,9 @@ impl<'tu> EntityWalkerVisitor<'tu> for FunctionFinder<'tu, '_> {
self.update_used_func_identifier(&identifier);
self.update_used_func_cpp_fullname(&cpp_fullname);
}
+ entity.walk_classes_while(|child| {
+ self.visit_entity(child)
+ });
}
true
}

MODIFY
binding-generator/src/class.rs
binding-generator/src/class.rs
@@ -13,6 +13,7 @@ use once_cell::sync::Lazy;
use crate::{
CompiledInterpolation,
+ Const,
Constness,
DefaultElement,
DefinitionLocation,
@@ -210,6 +211,15 @@ impl<'tu, 'g> Class<'tu, 'g> {
out
}
+ pub fn consts(&self) -> Vec<Const<'tu>> {
+ let mut out = Vec::with_capacity(8);
+ self.entity.walk_consts_while(|child| {
+ out.push(Const::new(child));
+ true
+ });
+ out
+ }
+
pub fn is_definition(&self) -> bool {
let class_loc = self.entity.get_location();
let def_loc = self.entity.get_definition().and_then(|d| d.get_location());
@@ -313,6 +323,7 @@ impl<'tu, 'g> Class<'tu, 'g> {
let mut out = String::new();
+ let consts = self.consts();
let fields = self.fields();
let mut methods = if is_simple {
vec![]
@@ -335,13 +346,18 @@ impl<'tu, 'g> Class<'tu, 'g> {
opencv_version
);
let dyn_impl = if is_abstract {
+ let consts = consts.iter()
+ .map(|c| c.gen_rust(opencv_version))
+ .join("");
+
let methods = Func::rust_generate_funcs(
methods.iter().filter(|m| m.as_static_method().is_some()),
opencv_version
);
- if !methods.is_empty() {
+ if !methods.is_empty() || !consts.is_empty() {
TRAIT_DYN_TPL.interpolate(&hashmap! {
"rust_local" => self.rust_trait_localname(),
+ "consts" => consts.into(),
"methods" => methods.into(),
})
} else {
@@ -390,7 +406,7 @@ impl<'tu, 'g> Class<'tu, 'g> {
.collect::<Vec<_>>();
let fields = if is_simple {
- let mut out: Vec<_> = self.fields().into_iter()
+ let mut out: Vec<_> = fields.iter()
.map(|f| {
let type_ref = f.type_ref();
let mut typ = type_ref.rust_full();
@@ -440,6 +456,11 @@ impl<'tu, 'g> Class<'tu, 'g> {
} else {
&BOXED_TPL
};
+
+ let consts = consts.iter()
+ .map(|c| c.gen_rust(opencv_version))
+ .join("");
+
out += &tpl.interpolate(&hashmap! {
"doc_comment" => Cow::Owned(self.rendered_doc_comment(opencv_version)),
"debug" => get_debug(self).into(),
@@ -450,6 +471,7 @@ impl<'tu, 'g> Class<'tu, 'g> {
"bases" => bases.join("").into(),
"impl" => IMPL_TPL.interpolate(&hashmap! {
"rust_local" => self.rust_localname(),
+ "consts" => consts.into(),
"methods" => inherent_methods.into(),
}).into()
});

MODIFY
binding-generator/src/constant.rs
binding-generator/src/constant.rs
@@ -118,7 +118,7 @@ pub fn render_evaluation_result_rust(result: EvaluationResult) -> Value {
}
}
-#[derive(Debug)]
+#[derive(Clone, Debug)]
pub struct Const<'tu> {
entity: Entity<'tu>,
}
@@ -242,7 +242,13 @@ impl GeneratedElement for Const<'_> {
|| include_str!("../tpl/const/float.tpl.rs").compile_interpolation()
);
- let name = self.rust_localname();
+ let parent_is_class = self.entity.get_lexical_parent()
+ .map_or(false, |p| matches!(p.get_kind(), EntityKind::ClassDecl | EntityKind::StructDecl));
+ let name = if parent_is_class {
+ self.rust_leafname()
+ } else {
+ self.rust_localname()
+ };
if let Some(value) = self.value() {
let tpl = if settings::CONST_TYPE_USIZE.contains(name.as_ref()) {
@@ -273,7 +279,7 @@ impl fmt::Display for Const<'_> {
}
}
-#[derive(Clone, Copy, Debug)]
+#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ValueKind {
Integer,
UnsignedInteger,
@@ -289,7 +295,11 @@ pub struct Value {
impl fmt::Display for Value {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ if self.kind == ValueKind::Float && !self.value.contains('.') {
+ write!(f, "{}.", self.value)
+ } else {
write!(f, "{}", self.value)
}
}
+}

MODIFY
binding-generator/src/element.rs
binding-generator/src/element.rs
@@ -17,7 +17,6 @@ use crate::{
reserved_rename,
settings,
StrExt,
- StringExt,
};
pub struct DefaultElement;
@@ -45,12 +44,6 @@ impl DefaultElement {
.map_or(true, |a| Accessibility::Public == a)
}
- pub fn identifier(this: &(impl Element + ?Sized)) -> Cow<str> {
- let mut out: String = this.cpp_fullname().into_owned();
- out.cleanup_name();
- out.into()
- }
-
pub fn usr<'tu>(this: &impl EntityElement<'tu>) -> Cow<str> {
this.entity().get_usr().expect("Can't get USR").0.into()
}
@@ -188,7 +181,6 @@ pub trait Element: fmt::Debug {
fn update_debug_struct<'dref, 'a, 'b>(&self, struct_debug: &'dref mut fmt::DebugStruct<'a, 'b>) -> &'dref mut fmt::DebugStruct<'a, 'b> {
struct_debug.field("cpp_fullname", &self.cpp_fullname())
.field("rust_fullname", &self.rust_fullname())
- .field("identifier", &self.identifier())
.field("is_excluded", &self.is_excluded())
.field("is_ignored", &self.is_ignored())
.field("is_system", &self.is_system())
@@ -209,10 +201,6 @@ pub trait Element: fmt::Debug {
fn is_public(&self) -> bool;
- fn identifier(&self) -> Cow<str> {
- DefaultElement::identifier(self)
- }
-
fn usr(&self) -> Cow<str>;
fn rendered_doc_comment_with_prefix(&self, prefix: &str, opencv_version: &str) -> String;

MODIFY
binding-generator/src/entity.rs
binding-generator/src/entity.rs
use std::borrow::Cow;
-use clang::{Entity, EntityKind, EntityVisitResult};
+use clang::{Entity, EntityKind, EntityVisitResult, StorageClass};
use crate::{
element::{DefaultElement, EntityElement},
@@ -54,6 +54,7 @@ pub trait EntityExt<'tu> {
fn walk_classes_while(&self, predicate: impl FnMut(Entity<'tu>) -> bool) -> bool;
fn walk_typedefs_while(&self, predicate: impl FnMut(Entity<'tu>) -> bool) -> bool;
fn walk_fields_while(&self, predicate: impl FnMut(Entity<'tu>) -> bool) -> bool;
+ fn walk_consts_while(&self, predicate: impl FnMut(Entity<'tu>) -> bool) -> bool;
fn walk_methods_while(&self, predicate: impl FnMut(Entity<'tu>) -> bool) -> bool;
}
@@ -123,7 +124,7 @@ impl<'tu> EntityExt<'tu> for Entity<'tu> {
fn walk_fields_while(&self, mut predicate: impl FnMut(Entity<'tu>) -> bool) -> bool {
self.walk_children_while(|child| {
match child.get_kind() {
- EntityKind::FieldDecl | EntityKind::VarDecl => {
+ EntityKind::FieldDecl => {
predicate(child)
}
_ => {
@@ -133,6 +134,28 @@ impl<'tu> EntityExt<'tu> for Entity<'tu> {
})
}
+ fn walk_consts_while(&self, mut predicate: impl FnMut(Entity<'tu>) -> bool) -> bool {
+ self.walk_children_while(|child| {
+ match child.get_kind() {
+ EntityKind::VarDecl => {
+ if let Some(StorageClass::Static) = child.get_storage_class() {
+ if child.evaluate().is_some() {
+ predicate(child)
+ } else {
+ true
+ // panic!("Non-evaluatable constant: {:#?}", child)
+ }
+ } else {
+ panic!("Non-static constant: {:#?}", child)
+ }
+ }
+ _ => {
+ true
+ }
+ }
+ })
+ }
+
fn walk_methods_while(&self, mut predicate: impl FnMut(Entity<'tu>) -> bool) -> bool {
self.walk_children_while(|child| {
match child.get_kind() {

MODIFY
binding-generator/src/func.rs
binding-generator/src/func.rs
@@ -658,6 +658,55 @@ impl<'tu, 'g> Func<'tu, 'g> {
"ret_map" => ret_map.as_ref(),
})
}
+
+ pub fn identifier(&self) -> Cow<str> {
+ let mut out: String = if self.as_field_accessor().is_some() {
+ let mut out: String = self.cpp_namespace().into_owned();
+ if !out.is_empty() {
+ out += "::";
+ }
+ let local_name = DefaultElement::cpp_localname(self);
+ let (first_letter, rest) = local_name.split_at(1);
+ if self.as_field_setter().is_some() {
+ out += &format!("setProp{}{}", first_letter.to_uppercase(), rest);
+ } else {
+ out += &format!("getProp{}{}", first_letter.to_uppercase(), rest);
+ }
+ out
+ } else {
+ self.cpp_fullname().into_owned()
+ };
+ out.cleanup_name();
+ if let Some(spec) = self.as_specialized() {
+ for typ in spec.values() {
+ out.push('_');
+ let mut typ = typ.to_string();
+ typ.cleanup_name();
+ out.push_str(&typ);
+ }
+ }
+ if self.is_const() {
+ out += "_const";
+ }
+ for arg in self.arguments() {
+ out.push('_');
+ let type_ref = arg.type_ref();
+ let mut safe_id = type_ref.cpp_safe_id();
+ // workaround for duplicate function definition for
+ // cv_ximgproc_ContourFitting_estimateTransformation_const__InputArray_const__InputArray_const__OutputArray_doubleX_bool
+ // it has 2 definitions, with pointer and with reference
+ if type_ref.as_reference().map_or(false, |inner| inner.is_primitive()) {
+ let safe_id = safe_id.to_mut();
+ if let Some((idx, last_char)) = safe_id.char_indices().rev().next() {
+ if last_char == 'X' {
+ safe_id.replace_range(idx..idx + 'X'.len_utf8(), "R");
+ }
+ }
+ }
+ out += &safe_id;
+ }
+ out.into()
+ }
}
impl<'tu> EntityElement<'tu> for Func<'tu, '_> {
@@ -705,39 +754,6 @@ impl Element for Func<'_, '_> {
DefaultElement::is_public(self)
}
- fn identifier(&self) -> Cow<str> {
- let mut out: String = DefaultElement::identifier(self).into_owned();
- if let Some(spec) = self.as_specialized() {
- for typ in spec.values() {
- out.push('_');
- let mut typ = typ.to_string();
- typ.cleanup_name();
- out.push_str(&typ);
- }
- }
- if self.is_const() {
- out += "_const";
- }
- for arg in self.arguments() {
- out.push('_');
- let type_ref = arg.type_ref();
- let mut safe_id = type_ref.cpp_safe_id();
- // workaround for duplicate function definition for
- // cv_ximgproc_ContourFitting_estimateTransformation_const__InputArray_const__InputArray_const__OutputArray_doubleX_bool
- // it has 2 definitions, with pointer and with reference
- if type_ref.as_reference().map_or(false, |inner| inner.is_primitive()) {
- let safe_id = safe_id.to_mut();
- if let Some((idx, last_char)) = safe_id.char_indices().rev().next() {
- if last_char == 'X' {
- safe_id.replace_range(idx..idx + 'X'.len_utf8(), "R");
- }
- }
- }
- out += &safe_id;
- }
- out.into()
- }
-
fn usr(&self) -> Cow<str> {
DefaultElement::usr(self)
}
@@ -793,7 +809,8 @@ impl Element for Func<'_, '_> {
format!("operator {}", self.return_type().cpp_full()).into()
} else if self.as_field_setter().is_some() {
let name = DefaultElement::cpp_localname(self);
- format!("set{}{}", name[..1].to_uppercase(), &name[1..]).into()
+ let (first_letter, rest) = name.split_at(1);
+ format!("set{}{}", first_letter.to_uppercase(), rest).into()
} else {
DefaultElement::cpp_localname(self)
}

MODIFY
binding-generator/src/generator_env.rs
binding-generator/src/generator_env.rs
@@ -6,12 +6,13 @@ use std::{
path::{Path, PathBuf},
};
-use clang::{Entity, EntityKind, EntityVisitResult, Type};
+use clang::{Entity, EntityKind, EntityVisitResult, StorageClass, Type};
use crate::{
Class,
class::Kind as ClassKind,
comment,
+ Const,
Element,
EntityWalker,
EntityWalkerVisitor,
@@ -46,7 +47,7 @@ struct DBPopulator<'ge, 'tu> {
gen_env: &'ge mut GeneratorEnv<'tu>,
}
-impl DBPopulator<'_, '_> {
+impl<'tu> DBPopulator<'_, 'tu> {
fn add_func_comment(&mut self, entity: Entity) {
let raw_comment = entity.get_comment().unwrap_or_default();
if !raw_comment.is_empty() && !raw_comment.contains("@overload") {
@@ -54,6 +55,18 @@ impl DBPopulator<'_, '_> {
self.gen_env.func_comments.insert(name, comment::strip_comment_markers(&raw_comment));
}
}
+
+ fn add_class_constant(&mut self, cnst: Entity<'tu>) {
+ let cnst = Const::new(cnst);
+ let mut full_name = cnst.cpp_fullname().into_owned();
+ self.gen_env.class_constants.insert(full_name.clone(), cnst.clone());
+ const SEP: &str = "::";
+ while let Some(idx) = full_name.find(SEP) {
+ full_name.drain(..idx + SEP.len());
+ self.gen_env.class_constants.insert(full_name.clone(), cnst.clone());
+ }
+ self.gen_env.class_constants.insert(full_name, cnst);
+ }
}
impl<'tu> EntityWalkerVisitor<'tu> for DBPopulator<'_, 'tu> {
@@ -83,6 +96,13 @@ impl<'tu> EntityWalkerVisitor<'tu> for DBPopulator<'_, 'tu> {
| EntityKind::ConversionFunction => {
self.add_func_comment(c);
}
+ EntityKind::VarDecl => {
+ if let Some(StorageClass::Static) = c.get_storage_class() {
+ if c.evaluate().is_some() {
+ self.add_class_constant(c);
+ }
+ }
+ }
_ => {}
}
EntityVisitResult::Continue
@@ -104,6 +124,7 @@ pub struct GeneratorEnv<'tu> {
func_comments: HashMap<String, String>,
has_descendants_cache: HashSet<String>,
class_kind_cache: MemoizeMap<String, Option<ClassKind>>,
+ class_constants: HashMap<String, Const<'tu>>,
type_resolve_cache: HashMap<String, Type<'tu>>,
}
@@ -116,6 +137,7 @@ impl<'tu> GeneratorEnv<'tu> {
func_comments: HashMap::with_capacity(2048),
has_descendants_cache: HashSet::with_capacity(128),
class_kind_cache: MemoizeMap::new(HashMap::with_capacity(32)),
+ class_constants: HashMap::with_capacity(32),
type_resolve_cache: HashMap::with_capacity(32),
};
let walker = EntityWalker::new(root_entity);
@@ -216,6 +238,10 @@ impl<'tu> GeneratorEnv<'tu> {
})
}
+ pub fn resolve_class_constant(&self, constant: &str) -> Option<&Const<'tu>> {
+ self.class_constants.get(constant)
+ }
+
pub fn resolve_type(&self, typ: &str) -> Option<Type<'tu>> {
self.type_resolve_cache.get(typ).copied()
}

MODIFY
binding-generator/src/settings.rs
binding-generator/src/settings.rs
@@ -100,7 +100,7 @@ pub static FUNC_RENAME: Lazy<HashMap<&str, &str>> = Lazy::new(|| hashmap! {
"cv_Mat_create_const_vector_int_X_int" => "+_nd_vec",
"cv_Mat_create_int_const_intX_int" => "+_nd",
"cv_Mat_create_int_int_int" => "+_rows_cols",
- "cv_Mat_data" => "+_mut",
+ "cv_Mat_getPropData" => "+_mut",
"cv_Mat_diag_const_MatX" => "+_mat",
"cv_Mat_eye_Size_int" => "+_size",
"cv_Mat_getUMat_const_AccessFlag_UMatUsageFlags" => "get_umat",
@@ -118,8 +118,8 @@ pub static FUNC_RENAME: Lazy<HashMap<&str, &str>> = Lazy::new(|| hashmap! {
"cv_Mat_reshape_const_int_int_const_intX" => "+_nd",
"cv_Mat_resize_size_t_const_ScalarX" => "+_with_default",
"cv_Mat_rowRange_const_int_int" => "row_bounds",
- "cv_Mat_size_const" => "mat_size",
- "cv_Mat_step_const" => "mat_step",
+ "cv_Mat_getPropSize_const" => "mat_size",
+ "cv_Mat_getPropStep_const" => "mat_step",
"cv_Mat_total_const_int_int" => "total_slice",
"cv_Mat_type_const" => "typ",
"cv_Mat_zeros_Size_int" => "+_size",
@@ -153,8 +153,8 @@ pub static FUNC_RENAME: Lazy<HashMap<&str, &str>> = Lazy::new(|| hashmap! {
"cv_UMat_create_int_const_intX_int_UMatUsageFlags" => "+_nd",
"cv_UMat_create_int_int_int_UMatUsageFlags" => "+_rows_cols",
"cv_UMat_rowRange_const_int_int" => "row_bounds",
- "cv_UMat_size_const" => "mat_size",
- "cv_UMat_step_const" => "mat_step",
+ "cv_UMat_getPropSize_const" => "mat_size",
+ "cv_UMat_getPropStep_const" => "mat_step",
"cv_UMat_type_const" => "typ",
"cv__InputArray__InputArray_const_MatExprX" => "from_matexpr",
"cv__InputArray__InputArray_const_MatX" => "from_mat",
@@ -276,16 +276,16 @@ pub static FUNC_RENAME: Lazy<HashMap<&str, &str>> = Lazy::new(|| hashmap! {
"cv_write_FileStorageX_const_StringX_int" => "+_i32",
"cv_AsyncArray__getImpl_const" => "-",
- "cv_MatExpr_op_const" => "-", // fixme implement PointerOf types
+ "cv_MatExpr_getPropOp_const" => "-", // fixme implement PointerOf types
"cv_Mat_Mat_const_MatX_const_RangeX" => "-", // duplicate of cv_Mat_Mat_Mat_VectorOfRange, but with pointers
"cv_Mat_copySize_const_MatX" => "-", // internal function
"cv_Mat_push_back__const_voidX" => "-", // internal method
- "cv_Mat_setSize_MatSize" => "-", // MatSize and MatStep types prevent assignment
- "cv_Mat_setStep_MatStep" => "-", // MatSize and MatStep types prevent assignment
+ "cv_Mat_setPropSize_MatSize" => "-", // MatSize and MatStep types prevent assignment
+ "cv_Mat_setPropStep_MatStep" => "-", // MatSize and MatStep types prevent assignment
"cv_UMat_UMat_const_UMatX_const_RangeX" => "-", // duplicate of cv_UMat_UMat_UMat_VectorOfRange, but with pointers
"cv_UMat_copySize_const_UMatX" => "-", // internal function
- "cv_UMat_setSize_MatSize" => "-", // MatSize and MatStep types prevent assignment
- "cv_UMat_setStep_MatStep" => "-", // MatSize and MatStep types prevent assignment
+ "cv_UMat_setPropSize_MatSize" => "-", // MatSize and MatStep types prevent assignment
+ "cv_UMat_setPropStep_MatStep" => "-", // MatSize and MatStep types prevent assignment
"cv_addImpl_int_const_charX" => "-",
"cv_calcCovarMatrix_const_MatX_int_MatX_MatX_int_int" => "-", // duplicate of cv_calcCovarMatrix_const__InputArrayX_const__OutputArrayX_const__InputOutputArrayX_int_int, but with pointers
"cv_cv_abs_short" => "-",
@@ -341,7 +341,7 @@ pub static FUNC_RENAME: Lazy<HashMap<&str, &str>> = Lazy::new(|| hashmap! {
"cv_dnn_Layer_finalize_const_vector_MatX_X_vector_Mat_X" => "-", // dup of cv_dnn_Layer_finalize_const_vector_Mat_X_vector_Mat_X
// ### face ###
- "cv_face_FacemarkLBF_Params_pupils" => "-", // fixme array of vectors
+ "cv_face_FacemarkLBF_Params_getPropPupils" => "-", // fixme array of vectors
// ### features2d ###
"cv_AGAST_const__InputArrayX_vector_KeyPoint_X_int_bool" => "AGAST",
@@ -418,11 +418,14 @@ pub static FUNC_RENAME: Lazy<HashMap<&str, &str>> = Lazy::new(|| hashmap! {
"cv_HOGDescriptor_detectMultiScale_const_const__InputArrayX_vector_Rect_X_vector_double_X_double_Size_Size_double_double_bool" => "+_weights",
"cv_HOGDescriptor_detect_const_const_MatX_vector_Point_X_vector_double_X_double_Size_Size_const_vector_Point_X" => "+_weights", // 3.2 3.4
"cv_HOGDescriptor_detect_const_const__InputArrayX_vector_Point_X_vector_double_X_double_Size_Size_const_vector_Point_X" => "+_weights", // 4.x
- "cv_HOGDescriptor_setSvmDetector_vector_float_" => "+_vec",
+ "cv_HOGDescriptor_setPropSvmDetector_vector_float_" => "+_vec",
"cv_groupRectangles_vector_Rect_X_vector_int_X_vector_double_X_int_double" => "+_levels",
"cv_groupRectangles_vector_Rect_X_vector_int_X_int_double" => "+_weights",
"cv_groupRectangles_vector_Rect_X_int_double_vector_int_X_vector_double_X" => "+_levelweights",
+ // ### optflow ###
+ "cv_optflow_GPCTrainingSamples_operator_cv_optflow_GPCSamplesVector" => "-", // support of "operator &" missing
+
// ### photo ###
"cv_fastNlMeansDenoisingMulti_const__InputArrayX_const__OutputArrayX_int_int_const_vector_float_X_int_int_int" => "+_vec",
"cv_fastNlMeansDenoising_const__InputArrayX_const__OutputArrayX_const_vector_float_X_int_int_int" => "+_vec",
@@ -441,8 +444,8 @@ pub static FUNC_RENAME: Lazy<HashMap<&str, &str>> = Lazy::new(|| hashmap! {
// ### text ###
"cv_text_BaseOCR_run_MatX_MatX_stringX_vector_Rect_X_vector_string_X_vector_float_X_int" => "+_mask",
- "cv_text_ERStat_pixels" => "-", // fixme: reference to a vector, we don't handle it too well yet
- "cv_text_ERStat_setPixels_vector_int_X" => "-", // fixme: reference to a vector, we don't handle it too well yet
+ "cv_text_ERStat_getPropPixels" => "-", // fixme: reference to a vector, we don't handle it too well yet
+ "cv_text_ERStat_setPropPixels_vector_int_X" => "-", // fixme: reference to a vector, we don't handle it too well yet
"cv_text_OCRBeamSearchDecoder_run_MatX_MatX_stringX_vector_Rect_X_vector_string_X_vector_float_X_int" => "+_multiple_mask",
"cv_text_OCRBeamSearchDecoder_run_MatX_stringX_vector_Rect_X_vector_string_X_vector_float_X_int" => "+_multiple",
"cv_text_OCRBeamSearchDecoder_run_const__InputArrayX_const__InputArrayX_int_int" => "+_mask",
@@ -593,6 +596,8 @@ pub static ELEMENT_EXPORT: Lazy<HashMap<&str, ExportConfig>> = Lazy::new(|| hash
"cv::MercatorWarper" => ExportConfig::default(), // 3.2 3.4 stitching warpers
"cv::TransverseMercatorWarper" => ExportConfig::default(), // 3.2 3.4 stitching warpers
"cv::TermCriteria" => ExportConfig::simple(),
+ "cv::optflow::GPCTrainingParams" => ExportConfig::simple(),
+ "cv::optflow::GPCMatchingParams" => ExportConfig::simple(),
// override boxed
"cv::DetectionBasedTracker::ExtObject" => ExportConfig::default(),
@@ -639,8 +644,8 @@ pub static FUNC_UNSAFE: Lazy<HashSet<&str>> = Lazy::new(|| hashset! {
"cv_Mat_Mat_Size_int_voidX_size_t",
"cv_Mat_Mat_int_const_intX_int_voidX_const_size_tX",
"cv_Mat_Mat_const_vector_int_X_int_voidX_const_size_tX",
- "cv_Mat_setData_unsigned_charX",
- "cv_UMatData_setData_unsigned_charX",
+ "cv_Mat_setPropData_unsigned_charX",
+ "cv_UMatData_setPropData_unsigned_charX",
// no bounds checking
"cv_Mat_ptr_const_const_intX",
"cv_Mat_ptr_const_int",

MODIFY
binding-generator/src/type_ref.rs
binding-generator/src/type_ref.rs
@@ -1098,7 +1098,11 @@ impl<'tu, 'g> TypeRef<'tu, 'g> {
Some(type_ref.rust_type_ref(form.recurse()))
}
TemplateArg::Constant(literal) => {
+ if let Some(cnst) = self.gen_env.resolve_class_constant(literal).and_then(|c| c.value()) {
+ constant_suffix += &cnst.to_string();
+ } else {
constant_suffix += literal;
+ }
None
}
TemplateArg::Unknown => {
@@ -1600,8 +1604,12 @@ impl<'tu, 'g> TypeRef<'tu, 'g> {
Some(type_ref.cpp_type_ref(form.recurse()))
}
TemplateArg::Constant(literal) => {
+ if let Some(cnst) = self.gen_env.resolve_class_constant(literal).and_then(|c| c.value()) {
+ Some(cnst.to_string().into())
+ } else {
Some(literal.into())
}
+ }
TemplateArg::Unknown => {
None
}

MODIFY
binding-generator/tpl/class/impl.tpl.rs
binding-generator/tpl/class/impl.tpl.rs
impl {{rust_local}} {
+ {{consts}}
{{methods}}
}

MODIFY
binding-generator/tpl/class/trait_dyn.tpl.rs
binding-generator/tpl/class/trait_dyn.tpl.rs
impl dyn {{rust_local}} + '_ {
+ {{consts}}
{{methods}}
}

MODIFY
binding-generator/tpl/func/cpp.tpl.cpp
binding-generator/tpl/func/cpp.tpl.cpp
{{call}}
{{post_call_args}}
{{return}}
- } OCVRS_CATCH({{return_wrapper_type}})
+ } OCVRS_CATCH(OCVRS_TYPE({{return_wrapper_type}}))
}
{{attributes_end}}

MODIFY
build.rs
build.rs
@@ -912,7 +912,6 @@ fn make_modules(opencv_dir_as_string: &str) -> Result<()> {
"gapi",
"opencv",
"opencv_modules",
- "optflow",
].iter().copied());
let modules: Vec<String> = glob(&format!("{}/*.hpp", opencv_dir_as_string))?

MODIFY
src/manual/core/vec.rs
src/manual/core/vec.rs
@@ -57,6 +57,7 @@ vec_impl!(Vec3, 3, ValidVecType);
vec_impl!(Vec4, 4, ValidVecType);
vec_impl!(Vec6, 6, ValidVecType);
vec_impl!(Vec8, 8, ValidVecType);
+vec_impl!(Vec18, 18, ValidVecType);
vec_impl!(Scalar_, 4, ValidScalarType);
impl<T: ValidScalarType> Scalar_<T> {

MODIFY
src_cpp/common.hpp
src_cpp/common.hpp
#include <opencv2/core.hpp>
#define OCVRS_ONLY_DEPENDENT_TYPES
+// needed to be able to handle commas in the type name in call to OCVRS_CATCH
+#define OCVRS_TYPE(...) __VA_ARGS__
#define CODE_CATCH(return_type, exc_type, code, msg) \
catch (exc_type& e) { \

Enable optflow module