mirror of
https://github.com/opencv/opencv.git
synced 2026-07-25 13:23:02 +04:00
Merge branch 4.x
This commit is contained in:
@@ -65,6 +65,7 @@ type_dict = {
|
||||
"char" : { "j_type" : "char", "jn_type" : "char", "jni_type" : "jchar", "suffix" : "C" },
|
||||
"int" : { "j_type" : "int", "jn_type" : "int", "jni_type" : "jint", "suffix" : "I" },
|
||||
"long" : { "j_type" : "int", "jn_type" : "int", "jni_type" : "jint", "suffix" : "I" },
|
||||
"long long" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" },
|
||||
"float" : { "j_type" : "float", "jn_type" : "float", "jni_type" : "jfloat", "suffix" : "F" },
|
||||
"double" : { "j_type" : "double", "jn_type" : "double", "jni_type" : "jdouble", "suffix" : "D" },
|
||||
"size_t" : { "j_type" : "long", "jn_type" : "long", "jni_type" : "jlong", "suffix" : "J" },
|
||||
@@ -89,6 +90,13 @@ type_dict = {
|
||||
'v_type': 'string',
|
||||
'j_import': 'java.lang.String'
|
||||
},
|
||||
"byte[]": {
|
||||
"j_type" : "byte[]",
|
||||
"jn_type": "byte[]",
|
||||
"jni_type": "jbyteArray",
|
||||
"jni_name": "n_%(n)s",
|
||||
"jni_var": "char* n_%(n)s = reinterpret_cast<char*>(env->GetByteArrayElements(%(n)s, NULL))",
|
||||
},
|
||||
}
|
||||
|
||||
# Defines a rule to add extra prefixes for names from specific namespaces.
|
||||
@@ -523,14 +531,14 @@ class JavaWrapperGenerator(object):
|
||||
|
||||
if classinfo.base:
|
||||
classinfo.addImports(classinfo.base)
|
||||
type_dict.setdefault("Ptr_"+name, {}).update(
|
||||
{ "j_type" : classinfo.jname,
|
||||
"jn_type" : "long", "jn_args" : (("__int64", ".getNativeObjAddr()"),),
|
||||
"jni_name" : "*((Ptr<"+classinfo.fullNameCPP()+">*)%(n)s_nativeObj)", "jni_type" : "jlong",
|
||||
"suffix" : "J",
|
||||
"j_import" : "org.opencv.%s.%s" % (self.module, classinfo.jname)
|
||||
if ("Ptr_"+name) not in type_dict:
|
||||
type_dict["Ptr_"+name] = {
|
||||
"j_type" : classinfo.jname,
|
||||
"jn_type" : "long", "jn_args" : (("__int64", ".getNativeObjAddr()"),),
|
||||
"jni_name" : "*((Ptr<"+classinfo.fullNameCPP()+">*)%(n)s_nativeObj)", "jni_type" : "jlong",
|
||||
"suffix" : "J",
|
||||
"j_import" : "org.opencv.%s.%s" % (self.module, classinfo.jname)
|
||||
}
|
||||
)
|
||||
logging.info('ok: class %s, name: %s, base: %s', classinfo, name, classinfo.base)
|
||||
|
||||
def add_const(self, decl, enumType=None): # [ "const cname", val, [], [] ]
|
||||
@@ -595,12 +603,16 @@ class JavaWrapperGenerator(object):
|
||||
f.write(buf)
|
||||
updated_files += 1
|
||||
|
||||
def gen(self, srcfiles, module, output_path, output_jni_path, output_java_path, common_headers):
|
||||
def gen(self, srcfiles, module, output_path, output_jni_path, output_java_path, common_headers,
|
||||
preprocessor_definitions=None):
|
||||
self.clear()
|
||||
self.module = module
|
||||
self.Module = module.capitalize()
|
||||
# TODO: support UMat versions of declarations (implement UMat-wrapper for Java)
|
||||
parser = hdr_parser.CppHeaderParser(generate_umat_decls=False)
|
||||
parser = hdr_parser.CppHeaderParser(
|
||||
generate_umat_decls=False,
|
||||
preprocessor_definitions=preprocessor_definitions
|
||||
)
|
||||
|
||||
self.add_class( ['class cv.' + self.Module, '', [], []] ) # [ 'class/struct cname', ':bases', [modlist] [props] ]
|
||||
|
||||
@@ -1450,6 +1462,7 @@ if __name__ == "__main__":
|
||||
gen_dict_files = []
|
||||
|
||||
print("JAVA: Processing OpenCV modules: %d" % len(config['modules']))
|
||||
preprocessor_definitions = config.get('preprocessor_definitions', None)
|
||||
for e in config['modules']:
|
||||
(module, module_location) = (e['name'], os.path.join(ROOT_DIR, e['location']))
|
||||
logging.info("\n=== MODULE: %s (%s) ===\n" % (module, module_location))
|
||||
@@ -1514,7 +1527,8 @@ if __name__ == "__main__":
|
||||
copy_java_files(java_test_files_dir, java_test_base_path, 'org/opencv/test/' + module)
|
||||
|
||||
if len(srcfiles) > 0:
|
||||
generator.gen(srcfiles, module, dstdir, jni_path, java_path, common_headers)
|
||||
generator.gen(srcfiles, module, dstdir, jni_path, java_path, common_headers,
|
||||
preprocessor_definitions)
|
||||
else:
|
||||
logging.info("No generated code for module: %s", module)
|
||||
generator.finalize(jni_path)
|
||||
|
||||
Reference in New Issue
Block a user