Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
7432fc1d
Commit
7432fc1d
authored
Jul 07, 2011
by
Andrey Pavlenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- 'String' (that is synonym of std::string) is added
- report generation added (<module>.txt)
parent
ed8a2af9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
3 deletions
+24
-3
gen_java.py
modules/java/gen_java.py
+24
-3
No files found.
modules/java/gen_java.py
View file @
7432fc1d
...
@@ -56,6 +56,10 @@ type_dict = {
...
@@ -56,6 +56,10 @@ type_dict = {
"jni_type"
:
"jstring"
,
"jni_name"
:
"n_
%(n)
s"
,
"jni_type"
:
"jstring"
,
"jni_name"
:
"n_
%(n)
s"
,
"jni_var"
:
'const char* utf_
%(n)
s = env->GetStringUTFChars(
%(n)
s, 0); std::string n_
%(n)
s( utf_
%(n)
s ? utf_
%(n)
s : "" ); env->ReleaseStringUTFChars(
%(n)
s, utf_
%(n)
s)'
,
"jni_var"
:
'const char* utf_
%(n)
s = env->GetStringUTFChars(
%(n)
s, 0); std::string n_
%(n)
s( utf_
%(n)
s ? utf_
%(n)
s : "" ); env->ReleaseStringUTFChars(
%(n)
s, utf_
%(n)
s)'
,
"suffix"
:
"Ljava_lang_String_2"
},
"suffix"
:
"Ljava_lang_String_2"
},
"String"
:
{
"j_type"
:
"java.lang.String"
,
"jn_type"
:
"java.lang.String"
,
"jni_type"
:
"jstring"
,
"jni_name"
:
"n_
%(n)
s"
,
"jni_var"
:
'const char* utf_
%(n)
s = env->GetStringUTFChars(
%(n)
s, 0); String n_
%(n)
s( utf_
%(n)
s ? utf_
%(n)
s : "" ); env->ReleaseStringUTFChars(
%(n)
s, utf_
%(n)
s)'
,
"suffix"
:
"Ljava_lang_String_2"
},
}
}
...
@@ -153,7 +157,9 @@ class JavaWrapperGenerator(object):
...
@@ -153,7 +157,9 @@ class JavaWrapperGenerator(object):
self
.
jn_code
=
StringIO
()
self
.
jn_code
=
StringIO
()
self
.
cpp_code
=
StringIO
()
self
.
cpp_code
=
StringIO
()
self
.
ported_func_counter
=
0
self
.
ported_func_counter
=
0
self
.
func_counter
=
0
self
.
ported_func_list
=
[]
self
.
skipped_func_list
=
[]
self
.
total_func_counter
=
0
def
add_class
(
self
,
decl
):
def
add_class
(
self
,
decl
):
classinfo
=
ClassInfo
(
decl
)
classinfo
=
ClassInfo
(
decl
)
...
@@ -309,8 +315,19 @@ class JavaWrapperGenerator(object):
...
@@ -309,8 +315,19 @@ class JavaWrapperGenerator(object):
self
.
save
(
output_path
,
module
+
".java"
,
self
.
java_code
)
self
.
save
(
output_path
,
module
+
".java"
,
self
.
java_code
)
self
.
save
(
output_path
,
module
+
".cpp"
,
self
.
cpp_code
)
self
.
save
(
output_path
,
module
+
".cpp"
,
self
.
cpp_code
)
# report
report
=
StringIO
()
report
.
write
(
"PORTED FUNCs LIST (
%
i of
%
i):
\n\n
"
%
\
(
self
.
ported_func_counter
,
self
.
total_func_counter
)
\
)
report
.
write
(
"
\n
"
.
join
(
self
.
ported_func_list
))
report
.
write
(
"
\n\n
SKIPPED FUNCs LIST (
%
i of
%
i):
\n\n
"
%
\
(
self
.
total_func_counter
-
self
.
ported_func_counter
,
self
.
total_func_counter
)
\
)
report
.
write
(
""
.
join
(
self
.
skipped_func_list
))
self
.
save
(
output_path
,
module
+
".txt"
,
report
)
print
"Done
%
i of
%
i funcs."
%
(
self
.
ported_func_counter
,
self
.
func_counter
)
print
"Done
%
i of
%
i funcs."
%
(
self
.
ported_func_counter
,
self
.
total_
func_counter
)
def
gen_consts
(
self
):
def
gen_consts
(
self
):
...
@@ -324,7 +341,7 @@ class JavaWrapperGenerator(object):
...
@@ -324,7 +341,7 @@ class JavaWrapperGenerator(object):
def
gen_func
(
self
,
fi
,
isoverload
,
jn_code
):
def
gen_func
(
self
,
fi
,
isoverload
,
jn_code
):
self
.
func_counter
+=
1
self
.
total_
func_counter
+=
1
# // C++: c_decl
# // C++: c_decl
# e.g:
# e.g:
...
@@ -341,6 +358,7 @@ class JavaWrapperGenerator(object):
...
@@ -341,6 +358,7 @@ class JavaWrapperGenerator(object):
type_info
=
type_dict
.
get
(
fi
.
ctype
)
type_info
=
type_dict
.
get
(
fi
.
ctype
)
if
not
(
type_info
and
type_info
.
get
(
"jn_type"
)):
# unsupported ret type
if
not
(
type_info
and
type_info
.
get
(
"jn_type"
)):
# unsupported ret type
msg
=
"// Return type '
%
s' is not supported, skipping the function
\n\n
"
%
fi
.
ctype
msg
=
"// Return type '
%
s' is not supported, skipping the function
\n\n
"
%
fi
.
ctype
self
.
skipped_func_list
.
append
(
c_decl
+
"
\n
"
+
msg
)
self
.
java_code
.
write
(
indent
+
msg
)
self
.
java_code
.
write
(
indent
+
msg
)
#self.cpp_code.write( msg )
#self.cpp_code.write( msg )
print
"SKIP:"
,
c_decl
,
"
\n\t
due to RET type"
,
fi
.
ctype
print
"SKIP:"
,
c_decl
,
"
\n\t
due to RET type"
,
fi
.
ctype
...
@@ -348,18 +366,21 @@ class JavaWrapperGenerator(object):
...
@@ -348,18 +366,21 @@ class JavaWrapperGenerator(object):
for
a
in
fi
.
args
:
for
a
in
fi
.
args
:
if
a
.
ctype
not
in
type_dict
:
if
a
.
ctype
not
in
type_dict
:
msg
=
"// Unknown type '
%
s', skipping the function
\n\n
"
%
a
.
ctype
msg
=
"// Unknown type '
%
s', skipping the function
\n\n
"
%
a
.
ctype
self
.
skipped_func_list
.
append
(
c_decl
+
"
\n
"
+
msg
)
self
.
java_code
.
write
(
indent
+
msg
)
self
.
java_code
.
write
(
indent
+
msg
)
#self.cpp_code.write( msg )
#self.cpp_code.write( msg )
print
"SKIP:"
,
c_decl
,
"
\n\t
due to ARG type"
,
a
.
ctype
print
"SKIP:"
,
c_decl
,
"
\n\t
due to ARG type"
,
a
.
ctype
return
return
if
a
.
ctype
!=
"Mat"
and
"jn_args"
in
type_dict
[
a
.
ctype
]
and
a
.
out
:
# complex out args not yet supported
if
a
.
ctype
!=
"Mat"
and
"jn_args"
in
type_dict
[
a
.
ctype
]
and
a
.
out
:
# complex out args not yet supported
msg
=
"// Unsupported type '
%
s&', skipping the function
\n\n
"
%
a
.
ctype
msg
=
"// Unsupported type '
%
s&', skipping the function
\n\n
"
%
a
.
ctype
self
.
skipped_func_list
.
append
(
c_decl
+
"
\n
"
+
msg
)
self
.
java_code
.
write
(
indent
+
msg
)
self
.
java_code
.
write
(
indent
+
msg
)
#self.cpp_code.write( msg )
#self.cpp_code.write( msg )
print
"SKIP:"
,
c_decl
,
"
\n\t
due to OUT ARG of type"
,
a
.
ctype
print
"SKIP:"
,
c_decl
,
"
\n\t
due to OUT ARG of type"
,
a
.
ctype
return
return
self
.
ported_func_counter
+=
1
self
.
ported_func_counter
+=
1
self
.
ported_func_list
.
append
(
c_decl
)
# jn & cpp comment
# jn & cpp comment
jn_code
.
write
(
"
\n
%
s// C++:
%
s
\n
"
%
(
indent
,
c_decl
)
)
jn_code
.
write
(
"
\n
%
s// C++:
%
s
\n
"
%
(
indent
,
c_decl
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment