Blame view

3rdparty/opencv-4.5.4/modules/java/generator/templates/cpp_module.template 1.01 KB
f4334277   Hu Chunming   提交3rdparty
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
  //
  // This file is auto-generated. Please don't modify it!
  //
  
  #undef LOG_TAG
  
  #include "opencv2/opencv_modules.hpp"
  #ifdef HAVE_OPENCV_$M
  
  #include <string>
  
  #include "opencv2/$m.hpp"
  
  $includes
  
  #define LOG_TAG "org.opencv.$m"
  #include "common.h"
  
  using namespace cv;
  
  /// throw java exception
  #undef throwJavaException
  #define throwJavaException throwJavaException_$m
  static void throwJavaException(JNIEnv *env, const std::exception *e, const char *method) {
    std::string what = "unknown exception";
    jclass je = 0;
  
    if(e) {
      std::string exception_type = "std::exception";
  
      if(dynamic_cast<const cv::Exception*>(e)) {
        exception_type = "cv::Exception";
        je = env->FindClass("org/opencv/core/CvException");
      }
  
      what = exception_type + ": " + e->what();
    }
  
    if(!je) je = env->FindClass("java/lang/Exception");
    env->ThrowNew(je, what.c_str());
  
    LOGE("%s caught %s", method, what.c_str());
    (void)method;        // avoid "unused" warning
  }
  
  extern "C" {
  
  $code
  
  } // extern "C"
  
  #endif // HAVE_OPENCV_$M