mirror of
https://github.com/opencv/opencv.git
synced 2025-06-29 16:11:00 +08:00
Merge pull request #20344 from alalek:backport_20343
This commit is contained in:
commit
d7d491d445
@ -54,7 +54,7 @@
|
||||
]
|
||||
|
||||
],
|
||||
"jni_name": "(*(cv::dnn::DictValue*)%(n)s_nativeObj)",
|
||||
"jni_name": "(*(*(Ptr<cv::dnn::DictValue>*)%(n)s_nativeObj))",
|
||||
"jni_type": "jlong",
|
||||
"suffix": "J",
|
||||
"j_import": "org.opencv.dnn.DictValue"
|
||||
|
@ -224,6 +224,9 @@ class ClassInfo(GeneralInfo):
|
||||
for m in decl[2]:
|
||||
if m.startswith("="):
|
||||
self.jname = m[1:]
|
||||
if m == '/Simple':
|
||||
self.smart = False
|
||||
|
||||
self.base = ''
|
||||
if decl[1]:
|
||||
#self.base = re.sub(r"\b"+self.jname+r"\b", "", decl[1].replace(":", "")).strip()
|
||||
@ -370,7 +373,7 @@ class JavaWrapperGenerator(object):
|
||||
|
||||
def clear(self):
|
||||
self.namespaces = ["cv"]
|
||||
self.classes = { "Mat" : ClassInfo([ 'class Mat', '', [], [] ], self.namespaces) }
|
||||
self.classes = { "Mat" : ClassInfo([ 'class Mat', '', ['/Simple'], [] ], self.namespaces) }
|
||||
self.module = ""
|
||||
self.Module = ""
|
||||
self.ported_func_list = []
|
||||
@ -390,10 +393,15 @@ class JavaWrapperGenerator(object):
|
||||
if name in type_dict and not classinfo.base:
|
||||
logging.warning('duplicated: %s', classinfo)
|
||||
return
|
||||
if self.isSmartClass(classinfo):
|
||||
jni_name = "*((*(Ptr<"+classinfo.fullName(isCPP=True)+">*)%(n)s_nativeObj).get())"
|
||||
else:
|
||||
jni_name = "(*("+classinfo.fullName(isCPP=True)+"*)%(n)s_nativeObj)"
|
||||
type_dict.setdefault(name, {}).update(
|
||||
{ "j_type" : classinfo.jname,
|
||||
"jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),),
|
||||
"jni_name" : "(*("+classinfo.fullName(isCPP=True)+"*)%(n)s_nativeObj)", "jni_type" : "jlong",
|
||||
"jni_name" : jni_name,
|
||||
"jni_type" : "jlong",
|
||||
"suffix" : "J",
|
||||
"j_import" : "org.opencv.%s.%s" % (self.module, classinfo.jname)
|
||||
}
|
||||
@ -401,7 +409,8 @@ class JavaWrapperGenerator(object):
|
||||
type_dict.setdefault(name+'*', {}).update(
|
||||
{ "j_type" : classinfo.jname,
|
||||
"jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),),
|
||||
"jni_name" : "("+classinfo.fullName(isCPP=True)+"*)%(n)s_nativeObj", "jni_type" : "jlong",
|
||||
"jni_name" : "&("+jni_name+")",
|
||||
"jni_type" : "jlong",
|
||||
"suffix" : "J",
|
||||
"j_import" : "org.opencv.%s.%s" % (self.module, classinfo.jname)
|
||||
}
|
||||
@ -889,6 +898,12 @@ class JavaWrapperGenerator(object):
|
||||
ret = "return env->NewStringUTF(_retval_.c_str());"
|
||||
default = 'return env->NewStringUTF("");'
|
||||
elif self.isWrapped(fi.ctype): # wrapped class:
|
||||
ret = None
|
||||
if fi.ctype in self.classes:
|
||||
ret_ci = self.classes[fi.ctype]
|
||||
if self.isSmartClass(ret_ci):
|
||||
ret = "return (jlong)(new Ptr<%(ctype)s>(new %(ctype)s(_retval_)));" % { 'ctype': self.fullTypeName(fi.ctype) }
|
||||
if ret is None:
|
||||
ret = "return (jlong) new %s(_retval_);" % self.fullTypeName(fi.ctype)
|
||||
elif fi.ctype.startswith('Ptr_'):
|
||||
c_prologue.append("typedef Ptr<%s> %s;" % (self.fullTypeName(fi.ctype[4:]), fi.ctype))
|
||||
@ -1128,17 +1143,7 @@ JNIEXPORT void JNICALL Java_org_opencv_%(module)s_%(j_cls)s_delete
|
||||
if ci.smart != None:
|
||||
return ci.smart
|
||||
|
||||
# if parents are smart (we hope) then children are!
|
||||
# if not we believe the class is smart if it has "create" method
|
||||
ci.smart = False
|
||||
if ci.base or ci.name == 'Algorithm':
|
||||
ci.smart = True
|
||||
else:
|
||||
for fi in ci.methods:
|
||||
if fi.name == "create":
|
||||
ci.smart = True
|
||||
break
|
||||
|
||||
ci.smart = True # smart class is not properly handled in case of base/derived classes
|
||||
return ci.smart
|
||||
|
||||
def smartWrap(self, ci, fullname):
|
||||
|
Loading…
Reference in New Issue
Block a user