From: Andrey Pavlenko Date: Tue, 12 Jul 2011 13:13:02 +0000 (+0000) Subject: adding runtime Android logging in Debug X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~6663 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bc9a9b714c6475bc30b5a901db69a8fd34ecc8fa;p=platform%2Fupstream%2Fopencv.git adding runtime Android logging in Debug --- diff --git a/modules/java/gen_java.py b/modules/java/gen_java.py index b085dc5..41f517c 100644 --- a/modules/java/gen_java.py +++ b/modules/java/gen_java.py @@ -318,11 +318,12 @@ class JavaWrapperGenerator(object): // #include -/* + +#ifdef DEBUG #include #define MODULE_LOG_TAG "OpenCV.%s" #define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, MODULE_LOG_TAG, __VA_ARGS__)) -*/ +#endif // DEBUG """ % module) self.cpp_code.write( "\n".join(['#include "opencv2/%s/%s"' % (module, os.path.basename(f)) \ @@ -503,14 +504,14 @@ class JavaWrapperGenerator(object): # jni_func(..) { return cv_func(..); } ret = "return " ext = "" - default = "return 0" + default = "return 0;" if fi.ctype == "void": ret = "" default = "" elif fi.ctype == "string": ret = "return env->NewStringUTF" ext = ".c_str()" - default = 'return env->NewStringUTF("")' + default = 'return env->NewStringUTF("");' elif fi.ctype in self.classes: # wrapped class: ret = "return (jlong) new " + self.classes[fi.ctype].jname @@ -541,20 +542,26 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_$fname ($args) { try { - //LOGD("$module::$fname()"); +#ifdef DEBUG + LOGD("$module::$fname()"); +#endif // DEBUG $j2cv $ret( $cvname( $cvargs )$ext ); } catch(cv::Exception e) { - //LOGD("$module::$fname() catched cv::Exception: %s", e.what()); +#ifdef DEBUG + LOGD("$module::$fname() catched cv::Exception: %s", e.what()); +#endif // DEBUG jclass je = env->FindClass("org/opencv/CvException"); if(!je) je = env->FindClass("java/lang/Exception"); env->ThrowNew(je, e.what()); - $default; + $default } catch (...) { - //LOGD("$module::$fname() catched ..."); +#ifdef DEBUG + LOGD("$module::$fname() catched unknown exception (...)"); +#endif // DEBUG jclass je = env->FindClass("java/lang/Exception"); env->ThrowNew(je, "Unknown exception in JNI code {$module::$fname()}"); - $default; + $default } } @@ -564,7 +571,7 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_$fname module = self.module, \ fname = fi.jni_name + ["",suffix][isoverload], \ args = ", ".join(["%s %s" % (type_dict[a.ctype].get("jni_type"), a.name) for a in jni_args]), \ - j2cv = "\n ".join([a for a in j2cvargs]), \ + j2cv = "\n ".join([a for a in j2cvargs]), \ ret = ret, \ cvname = cvname, \ cvargs = ", ".join([a for a in cvargs]), \ @@ -601,8 +608,8 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_$fname if name == "Mat": continue self.java_code.write( "\n\n" + indent + "// C++: class %s" % (ci.cname) + "\n" ) + self.java_code.write( indent + "//javadoc: " + name + "\n" ) #java doc comment self.java_code.write( indent + "public static class %s {\n\n" % (ci.jname) ) - # self self.java_code.write( indent_m + "protected final long nativeObj;\n" ) self.java_code.write( indent_m + "protected %s(long addr) { nativeObj = addr; }\n\n" \ @@ -689,5 +696,3 @@ if __name__ == "__main__": generator = JavaWrapperGenerator() generator.gen(srcfiles, module, dstdir) - -