@@ -11,7 +11,6 @@ use crate::{Func, FuncId};
11
11
pub type FuncInheritFactory = for <' tu , ' ge > fn ( & Func < ' tu , ' ge > ) -> Func < ' tu , ' ge > ;
12
12
13
13
pub static FUNC_REPLACE : Lazy < HashMap < FuncId , FuncInheritFactory > > = Lazy :: new ( || {
14
- const MAT_FORWARD : Cow < str > = Cow :: Borrowed ( "core::mat_forward::{{name}}(self, {{forward_args}})" ) ;
15
14
const MAT_FORWARD_INHERIT_CONFIG : InheritConfig = InheritConfig {
16
15
kind : false ,
17
16
name : false ,
@@ -21,56 +20,91 @@ pub static FUNC_REPLACE: Lazy<HashMap<FuncId, FuncInheritFactory>> = Lazy::new(|
21
20
definition_location : true ,
22
21
} ;
23
22
24
- let forward_const = ( |f| {
25
- let mut out = Func :: new_desc (
26
- FuncDesc :: new (
27
- FuncKind :: InstanceMethod ( ClassDesc :: cv_mat ( ) ) ,
28
- Constness :: Const ,
29
- ReturnKind :: Fallible ,
30
- "at" ,
31
- "core" ,
32
- [ ] ,
33
- TypeRef :: new_pointer ( TypeRef :: new_generic ( "T" ) . with_inherent_constness ( Constness :: Const ) ) ,
34
- )
35
- . cpp_body ( FuncCppBody :: Absent )
36
- . rust_body ( FuncRustBody :: ManualCallReturn ( MAT_FORWARD ) )
37
- . rust_extern_definition ( FuncRustExtern :: Absent )
38
- . rust_generic_decls ( [ ( "T" . to_string ( ) , "core::DataType" . to_string ( ) ) ] ) ,
39
- ) ;
40
- out. inherit ( f, MAT_FORWARD_INHERIT_CONFIG ) ;
41
- out
42
- } ) as FuncInheritFactory ;
43
-
44
- let forward_mut = ( |f| {
45
- let mut out = Func :: new_desc (
46
- FuncDesc :: new (
47
- FuncKind :: InstanceMethod ( ClassDesc :: cv_mat ( ) ) ,
48
- Constness :: Mut ,
49
- ReturnKind :: Fallible ,
50
- "at" ,
51
- "core" ,
52
- [ ] ,
53
- TypeRef :: new_pointer ( TypeRef :: new_generic ( "T" ) ) ,
54
- )
55
- . cpp_body ( FuncCppBody :: Absent )
56
- . rust_body ( FuncRustBody :: ManualCallReturn ( MAT_FORWARD ) )
57
- . rust_extern_definition ( FuncRustExtern :: Absent )
58
- . rust_generic_decls ( [ ( "T" . to_string ( ) , "core::DataType" . to_string ( ) ) ] ) ,
59
- ) ;
60
- out. inherit ( f, MAT_FORWARD_INHERIT_CONFIG ) ;
61
- out
62
- } ) as FuncInheritFactory ;
23
+ fn make_at_forward ( constness : Constness ) -> FuncDesc < ' static , ' static > {
24
+ FuncDesc :: new (
25
+ FuncKind :: InstanceMethod ( ClassDesc :: cv_mat ( ) ) ,
26
+ constness,
27
+ ReturnKind :: Fallible ,
28
+ "at" ,
29
+ "core" ,
30
+ [ ] ,
31
+ TypeRef :: new_pointer ( TypeRef :: new_generic ( "T" ) . with_inherent_constness ( constness) ) ,
32
+ )
33
+ . cpp_body ( FuncCppBody :: Absent )
34
+ . rust_body ( FuncRustBody :: ManualCallReturn ( Cow :: Borrowed (
35
+ "core::mat_forward::{{name}}(self, {{forward_args}})" ,
36
+ ) ) )
37
+ . rust_extern_definition ( FuncRustExtern :: Absent )
38
+ . rust_generic_decls ( [ ( "T" . to_string ( ) , "core::DataType" . to_string ( ) ) ] )
39
+ }
63
40
64
41
HashMap :: from ( [
65
- ( FuncId :: new_mut ( "cv::Mat::at" , [ "i0" ] ) , forward_mut) ,
66
- ( FuncId :: new_const ( "cv::Mat::at" , [ "i0" ] ) , forward_const) ,
67
- ( FuncId :: new_mut ( "cv::Mat::at" , [ "row" , "col" ] ) , forward_mut) ,
68
- ( FuncId :: new_const ( "cv::Mat::at" , [ "row" , "col" ] ) , forward_const) ,
69
- ( FuncId :: new_mut ( "cv::Mat::at" , [ "i0" , "i1" , "i2" ] ) , forward_mut) ,
70
- ( FuncId :: new_const ( "cv::Mat::at" , [ "i0" , "i1" , "i2" ] ) , forward_const) ,
71
- ( FuncId :: new_mut ( "cv::Mat::at" , [ "pt" ] ) , forward_mut) ,
72
- ( FuncId :: new_const ( "cv::Mat::at" , [ "pt" ] ) , forward_const) ,
73
- ( FuncId :: new_mut ( "cv::Mat::at" , [ "idx" ] ) , forward_mut) ,
74
- ( FuncId :: new_const ( "cv::Mat::at" , [ "idx" ] ) , forward_const) ,
42
+ (
43
+ FuncId :: new_mut ( "cv::Mat::at" , [ "i0" ] ) ,
44
+ ( |f| {
45
+ Func :: new_desc ( make_at_forward ( Constness :: Mut ) . rust_custom_leafname ( "at_mut" ) )
46
+ . inheriting ( f, MAT_FORWARD_INHERIT_CONFIG )
47
+ } ) as FuncInheritFactory ,
48
+ ) ,
49
+ (
50
+ FuncId :: new_const ( "cv::Mat::at" , [ "i0" ] ) ,
51
+ ( |f| Func :: new_desc ( make_at_forward ( Constness :: Const ) ) . inheriting ( f, MAT_FORWARD_INHERIT_CONFIG ) ) as FuncInheritFactory ,
52
+ ) ,
53
+ (
54
+ FuncId :: new_mut ( "cv::Mat::at" , [ "row" , "col" ] ) ,
55
+ ( |f| {
56
+ Func :: new_desc ( make_at_forward ( Constness :: Mut ) . rust_custom_leafname ( "at_2d_mut" ) )
57
+ . inheriting ( f, MAT_FORWARD_INHERIT_CONFIG )
58
+ } ) as FuncInheritFactory ,
59
+ ) ,
60
+ (
61
+ FuncId :: new_const ( "cv::Mat::at" , [ "row" , "col" ] ) ,
62
+ ( |f| {
63
+ Func :: new_desc ( make_at_forward ( Constness :: Const ) . rust_custom_leafname ( "at_2d" ) )
64
+ . inheriting ( f, MAT_FORWARD_INHERIT_CONFIG )
65
+ } ) as FuncInheritFactory ,
66
+ ) ,
67
+ (
68
+ FuncId :: new_mut ( "cv::Mat::at" , [ "i0" , "i1" , "i2" ] ) ,
69
+ ( |f| {
70
+ Func :: new_desc ( make_at_forward ( Constness :: Mut ) . rust_custom_leafname ( "at_3d_mut" ) )
71
+ . inheriting ( f, MAT_FORWARD_INHERIT_CONFIG )
72
+ } ) as FuncInheritFactory ,
73
+ ) ,
74
+ (
75
+ FuncId :: new_const ( "cv::Mat::at" , [ "i0" , "i1" , "i2" ] ) ,
76
+ ( |f| {
77
+ Func :: new_desc ( make_at_forward ( Constness :: Const ) . rust_custom_leafname ( "at_3d" ) )
78
+ . inheriting ( f, MAT_FORWARD_INHERIT_CONFIG )
79
+ } ) as FuncInheritFactory ,
80
+ ) ,
81
+ (
82
+ FuncId :: new_mut ( "cv::Mat::at" , [ "pt" ] ) ,
83
+ ( |f| {
84
+ Func :: new_desc ( make_at_forward ( Constness :: Mut ) . rust_custom_leafname ( "at_pt_mut" ) )
85
+ . inheriting ( f, MAT_FORWARD_INHERIT_CONFIG )
86
+ } ) as FuncInheritFactory ,
87
+ ) ,
88
+ (
89
+ FuncId :: new_const ( "cv::Mat::at" , [ "pt" ] ) ,
90
+ ( |f| {
91
+ Func :: new_desc ( make_at_forward ( Constness :: Const ) . rust_custom_leafname ( "at_pt" ) )
92
+ . inheriting ( f, MAT_FORWARD_INHERIT_CONFIG )
93
+ } ) as FuncInheritFactory ,
94
+ ) ,
95
+ (
96
+ FuncId :: new_mut ( "cv::Mat::at" , [ "idx" ] ) ,
97
+ ( |f| {
98
+ Func :: new_desc ( make_at_forward ( Constness :: Mut ) . rust_custom_leafname ( "at_nd_mut" ) )
99
+ . inheriting ( f, MAT_FORWARD_INHERIT_CONFIG )
100
+ } ) as FuncInheritFactory ,
101
+ ) ,
102
+ (
103
+ FuncId :: new_const ( "cv::Mat::at" , [ "idx" ] ) ,
104
+ ( |f| {
105
+ Func :: new_desc ( make_at_forward ( Constness :: Const ) . rust_custom_leafname ( "at_nd" ) )
106
+ . inheriting ( f, MAT_FORWARD_INHERIT_CONFIG )
107
+ } ) as FuncInheritFactory ,
108
+ ) ,
75
109
] )
76
110
} ) ;
0 commit comments