Skip to content

Commit 374c5ce

Browse files
committed
Merge pull request opencv#8598 from sovrasov:java_wrap_prt_arg
2 parents 58f19b4 + bf62be7 commit 374c5ce

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

modules/java/generator/gen_java.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ def libVersionBlock():
649649
protected final long nativeObj;
650650
protected $jname(long addr) { nativeObj = addr; }
651651
652+
public long getNativeObjAddr() { return nativeObj; }
652653
"""
653654

654655
T_JAVA_START_MODULE = """
@@ -1004,7 +1005,7 @@ def add_class(self, decl):
10041005
classinfo.addImports(classinfo.base)
10051006
type_dict["Ptr_"+name] = \
10061007
{ "j_type" : classinfo.jname,
1007-
"jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),),
1008+
"jn_type" : "long", "jn_args" : (("__int64", ".getNativeObjAddr()"),),
10081009
"jni_name" : "*((Ptr<"+classinfo.fullName(isCPP=True)+">*)%(n)s_nativeObj)", "jni_type" : "jlong",
10091010
"suffix" : "J" }
10101011
logging.info('ok: class %s, name: %s, base: %s', classinfo, name, classinfo.base)
@@ -1228,7 +1229,7 @@ def gen_func(self, ci, fi, prop_name=''):
12281229
if "I" in a.out or not a.out or self.isWrapped(a.ctype): # input arg, pass by primitive fields
12291230
for f in fields:
12301231
jn_args.append ( ArgInfo([ f[0], a.name + f[1], "", [], "" ]) )
1231-
jni_args.append( ArgInfo([ f[0], a.name + f[1].replace(".","_").replace("[","").replace("]",""), "", [], "" ]) )
1232+
jni_args.append( ArgInfo([ f[0], a.name + f[1].replace(".","_").replace("[","").replace("]","").replace("_getNativeObjAddr()","_nativeObj"), "", [], "" ]) )
12321233
if a.out and not self.isWrapped(a.ctype): # out arg, pass as double[]
12331234
jn_args.append ( ArgInfo([ "double[]", "%s_out" % a.name, "", [], "" ]) )
12341235
jni_args.append ( ArgInfo([ "double[]", "%s_out" % a.name, "", [], "" ]) )
@@ -1276,7 +1277,7 @@ def gen_func(self, ci, fi, prop_name=''):
12761277
" private static native $type $name($args);\n").substitute(\
12771278
type = type_dict[fi.ctype].get("jn_type", "double[]"), \
12781279
name = fi.jname + '_' + str(suffix_counter), \
1279-
args = ", ".join(["%s %s" % (type_dict[a.ctype]["jn_type"], a.name.replace(".","_").replace("[","").replace("]","")) for a in jn_args])
1280+
args = ", ".join(["%s %s" % (type_dict[a.ctype]["jn_type"], a.name.replace(".","_").replace("[","").replace("]","").replace("_getNativeObjAddr()","_nativeObj")) for a in jn_args])
12801281
) );
12811282

12821283
# java part:

0 commit comments

Comments
 (0)