1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use crate::{
AbstractRefWrapper,
DependentType,
ReturnTypeWrapper,
SmartPtr,
Vector,
};
pub trait RustNativeGeneratedElement {
fn element_order(&self) -> u8 {
50
}
fn element_safe_id(&self) -> String;
fn gen_rust(&self, _opencv_version: &str) -> String {
"".to_string()
}
fn gen_rust_exports(&self) -> String {
"".to_string()
}
fn gen_cpp(&self) -> String {
"".to_string()
}
}
pub enum DepType<'tu> {
ReturnTypeWrapper(ReturnTypeWrapper<'tu>),
AbstractRefWrapper(AbstractRefWrapper<'tu>),
Vector(Vector<'tu>),
SmartPtr(SmartPtr<'tu>),
}
impl<'tu> DependentType<'tu> for DepType<'tu> {
fn from_return_type_wrapper(s: ReturnTypeWrapper<'tu>) -> Self {
DepType::ReturnTypeWrapper(s)
}
fn from_abstract_ref_wrapper(s: AbstractRefWrapper<'tu>) -> Self {
DepType::AbstractRefWrapper(s)
}
fn from_vector(s: Vector<'tu>) -> Self {
DepType::Vector(s)
}
fn from_smart_ptr(s: SmartPtr<'tu>) -> Self {
DepType::SmartPtr(s)
}
}
impl RustNativeGeneratedElement for DepType<'_> {
fn element_order(&self) -> u8 {
match self {
DepType::ReturnTypeWrapper(ret) => ret.element_order(),
DepType::AbstractRefWrapper(r) => r.element_order(),
DepType::Vector(vec) => vec.element_order(),
DepType::SmartPtr(ptr) => ptr.element_order(),
}
}
fn element_safe_id(&self) -> String {
match self {
DepType::ReturnTypeWrapper(ret) => ret.element_safe_id(),
DepType::AbstractRefWrapper(r) => r.element_safe_id(),
DepType::Vector(vec) => vec.element_safe_id(),
DepType::SmartPtr(ptr) => ptr.element_safe_id(),
}
}
fn gen_rust(&self, opencv_version: &str) -> String {
match self {
DepType::ReturnTypeWrapper(ret) => ret.gen_rust(opencv_version),
DepType::AbstractRefWrapper(r) => r.gen_rust(opencv_version),
DepType::Vector(vec) => vec.gen_rust(opencv_version),
DepType::SmartPtr(ptr) => ptr.gen_rust(opencv_version),
}
}
fn gen_rust_exports(&self) -> String {
match self {
DepType::ReturnTypeWrapper(ret) => ret.gen_rust_exports(),
DepType::AbstractRefWrapper(r) => r.gen_rust_exports(),
DepType::Vector(vec) => vec.gen_rust_exports(),
DepType::SmartPtr(ptr) => ptr.gen_rust_exports(),
}
}
fn gen_cpp(&self) -> String {
match self {
DepType::ReturnTypeWrapper(ret) => ret.gen_cpp(),
DepType::AbstractRefWrapper(r) => r.gen_cpp(),
DepType::Vector(vec) => vec.gen_cpp(),
DepType::SmartPtr(ptr) => ptr.gen_cpp(),
}
}
}