|
1 |
| -use std::collections::HashSet; |
| 1 | +use std::collections::HashMap; |
2 | 2 |
|
3 |
| -use once_cell::sync::Lazy; |
| 3 | +use crate::func::FuncMatcher; |
4 | 4 |
|
5 |
| -use crate::FuncId; |
| 5 | +pub type ForceInfallible = FuncMatcher<'static, ()>; |
6 | 6 |
|
7 |
| -pub static FORCE_INFALLIBLE: Lazy<HashSet<FuncId>> = Lazy::new(|| { |
8 |
| - HashSet::from([ |
| 7 | +pub fn force_infallible_factory(module: &str) -> ForceInfallible { |
| 8 | + match module { |
| 9 | + "core" => core_factory(), |
| 10 | + _ => ForceInfallible::empty(), |
| 11 | + } |
| 12 | +} |
| 13 | + |
| 14 | +fn core_factory() -> ForceInfallible { |
| 15 | + FuncMatcher::create(HashMap::from([ |
9 | 16 | // just returns static/constant data
|
10 |
| - FuncId::new_mut("cv::noArray", []), |
11 |
| - FuncId::new_mut("cv::getVersionMajor", []), |
12 |
| - FuncId::new_mut("cv::getVersionMinor", []), |
13 |
| - FuncId::new_mut("cv::getVersionRevision", []), |
| 17 | + ("cv::noArray", vec![(pred!(mut, []), ())]), |
| 18 | + ("cv::getVersionMajor", vec![(pred!(mut, []), ())]), |
| 19 | + ("cv::getVersionMinor", vec![(pred!(mut, []), ())]), |
| 20 | + ("cv::getVersionRevision", vec![(pred!(mut, []), ())]), |
14 | 21 | // not doing anything that can cause an exception
|
15 |
| - FuncId::new_const("cv::Mat::empty", []), |
16 |
| - FuncId::new_const("cv::Mat::total", []), |
17 |
| - FuncId::new_const("cv::Mat::isContinuous", []), |
18 |
| - FuncId::new_const("cv::Mat::isSubmatrix", []), |
19 |
| - FuncId::new_const("cv::Mat::elemSize1", []), |
20 |
| - FuncId::new_const("cv::Mat::type", []), |
21 |
| - FuncId::new_const("cv::Mat::depth", []), |
22 |
| - FuncId::new_const("cv::Mat::channels", []), |
23 |
| - FuncId::new_const("cv::UMat::empty", []), |
24 |
| - FuncId::new_const("cv::UMat::total", []), |
25 |
| - FuncId::new_const("cv::UMat::isContinuous", []), |
26 |
| - FuncId::new_const("cv::UMat::isSubmatrix", []), |
27 |
| - FuncId::new_const("cv::UMat::elemSize1", []), |
28 |
| - FuncId::new_const("cv::UMat::type", []), |
29 |
| - FuncId::new_const("cv::UMat::depth", []), |
30 |
| - FuncId::new_const("cv::UMat::channels", []), |
31 |
| - FuncId::new_const("cv::SparseMat::elemSize", []), |
32 |
| - FuncId::new_const("cv::SparseMat::elemSize1", []), |
33 |
| - FuncId::new_const("cv::SparseMat::type", []), |
34 |
| - FuncId::new_const("cv::SparseMat::depth", []), |
35 |
| - FuncId::new_const("cv::SparseMat::channels", []), |
| 22 | + ("cv::Mat::empty", vec![(pred!(const, []), ())]), |
| 23 | + ("cv::Mat::total", vec![(pred!(const, []), ())]), |
| 24 | + ("cv::Mat::isContinuous", vec![(pred!(const, []), ())]), |
| 25 | + ("cv::Mat::isSubmatrix", vec![(pred!(const, []), ())]), |
| 26 | + ("cv::Mat::elemSize1", vec![(pred!(const, []), ())]), |
| 27 | + ("cv::Mat::type", vec![(pred!(const, []), ())]), |
| 28 | + ("cv::Mat::depth", vec![(pred!(const, []), ())]), |
| 29 | + ("cv::Mat::channels", vec![(pred!(const, []), ())]), |
| 30 | + ("cv::UMat::empty", vec![(pred!(const, []), ())]), |
| 31 | + ("cv::UMat::total", vec![(pred!(const, []), ())]), |
| 32 | + ("cv::UMat::isContinuous", vec![(pred!(const, []), ())]), |
| 33 | + ("cv::UMat::isSubmatrix", vec![(pred!(const, []), ())]), |
| 34 | + ("cv::UMat::elemSize1", vec![(pred!(const, []), ())]), |
| 35 | + ("cv::UMat::type", vec![(pred!(const, []), ())]), |
| 36 | + ("cv::UMat::depth", vec![(pred!(const, []), ())]), |
| 37 | + ("cv::UMat::channels", vec![(pred!(const, []), ())]), |
| 38 | + ("cv::SparseMat::elemSize", vec![(pred!(const, []), ())]), |
| 39 | + ("cv::SparseMat::elemSize1", vec![(pred!(const, []), ())]), |
| 40 | + ("cv::SparseMat::type", vec![(pred!(const, []), ())]), |
| 41 | + ("cv::SparseMat::depth", vec![(pred!(const, []), ())]), |
| 42 | + ("cv::SparseMat::channels", vec![(pred!(const, []), ())]), |
36 | 43 | // marked CV_NOEXCEPT since OpenCV 4.5.2, propagate those changes to earlier versions
|
37 |
| - FuncId::new_mut("cv::Mat::Mat", []), |
38 |
| - FuncId::new_mut("cv::MatSize::MatSize", ["_p"]), |
39 |
| - FuncId::new_const("cv::MatSize::dims", []), |
40 |
| - FuncId::new_const("cv::MatSize::operator const int*", []), |
41 |
| - FuncId::new_mut("cv::MatStep::MatStep", []), |
42 |
| - FuncId::new_mut("cv::MatStep::operator[]", ["i"]), |
43 |
| - FuncId::new_mut("cv::UMat::UMat", ["usageFlags"]), |
44 |
| - FuncId::new_mut("cv::ocl::Context::Context", []), |
45 |
| - FuncId::new_mut("cv::ocl::Device::Device", []), |
46 |
| - FuncId::new_mut("cv::ocl::Image2D::Image2D", []), |
47 |
| - FuncId::new_mut("cv::ocl::Kernel::Kernel", []), |
48 |
| - FuncId::new_mut("cv::ocl::KernelArg::KernelArg", []), |
49 |
| - FuncId::new_mut("cv::ocl::Platform::Platform", []), |
50 |
| - FuncId::new_mut("cv::ocl::PlatformInfo::PlatformInfo", []), |
51 |
| - FuncId::new_mut("cv::ocl::Program::Program", []), |
52 |
| - FuncId::new_mut("cv::ocl::ProgramSource::ProgramSource", []), |
53 |
| - FuncId::new_mut("cv::ocl::Queue::Queue", []), |
54 |
| - ]) |
55 |
| -}); |
| 44 | + ("cv::Mat::Mat", vec![(pred!(mut, []), ())]), |
| 45 | + ("cv::MatSize::MatSize", vec![(pred!(mut, ["_p"]), ())]), |
| 46 | + ("cv::MatSize::dims", vec![(pred!(const, []), ())]), |
| 47 | + ("cv::MatSize::operator const int*", vec![(pred!(const, []), ())]), |
| 48 | + ("cv::MatStep::MatStep", vec![(pred!(mut, []), ())]), |
| 49 | + ("cv::MatStep::operator[]", vec![(pred!(mut, ["i"]), ())]), |
| 50 | + ("cv::UMat::UMat", vec![(pred!(mut, ["usageFlags"]), ())]), |
| 51 | + ("cv::ocl::Context::Context", vec![(pred!(mut, []), ())]), |
| 52 | + ("cv::ocl::Device::Device", vec![(pred!(mut, []), ())]), |
| 53 | + ("cv::ocl::Image2D::Image2D", vec![(pred!(mut, []), ())]), |
| 54 | + ("cv::ocl::Kernel::Kernel", vec![(pred!(mut, []), ())]), |
| 55 | + ("cv::ocl::KernelArg::KernelArg", vec![(pred!(mut, []), ())]), |
| 56 | + ("cv::ocl::Platform::Platform", vec![(pred!(mut, []), ())]), |
| 57 | + ("cv::ocl::PlatformInfo::PlatformInfo", vec![(pred!(mut, []), ())]), |
| 58 | + ("cv::ocl::Program::Program", vec![(pred!(mut, []), ())]), |
| 59 | + ("cv::ocl::ProgramSource::ProgramSource", vec![(pred!(mut, []), ())]), |
| 60 | + ("cv::ocl::Queue::Queue", vec![(pred!(mut, []), ())]), |
| 61 | + ])) |
| 62 | +} |
0 commit comments