Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
1cb5de2c
Commit
1cb5de2c
authored
Sep 17, 2015
by
Paul Sokolovsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unix/modjni: jvalue2py: Handle class-containing jvalues.
parent
861fad58
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
unix/modjni.c
unix/modjni.c
+14
-4
No files found.
unix/modjni.c
View file @
1cb5de2c
...
...
@@ -40,6 +40,7 @@
static
JavaVM
*
jvm
;
static
JNIEnv
*
env
;
static
jclass
Class_class
;
static
jclass
String_class
;
static
jmethodID
Class_getField_mid
;
static
jmethodID
Class_getMethods_mid
;
...
...
@@ -51,6 +52,7 @@ STATIC const mp_obj_type_t jobject_type;
STATIC
const
mp_obj_type_t
jmethod_type
;
STATIC
mp_obj_t
new_jobject
(
jobject
jo
);
STATIC
mp_obj_t
new_jclass
(
jclass
jc
);
STATIC
mp_obj_t
call_method
(
jobject
obj
,
const
char
*
name
,
jarray
methods
,
bool
is_constr
,
mp_uint_t
n_args
,
const
mp_obj_t
*
args
);
typedef
struct
_mp_obj_jclass_t
{
...
...
@@ -134,6 +136,12 @@ STATIC const mp_obj_type_t jclass_type = {
.
locals_dict
=
(
mp_obj_t
)
&
jclass_locals_dict
,
};
STATIC
mp_obj_t
new_jclass
(
jclass
jc
)
{
mp_obj_jclass_t
*
o
=
m_new_obj
(
mp_obj_jclass_t
);
o
->
base
.
type
=
&
jclass_type
;
o
->
cls
=
jc
;
return
o
;
}
// jobject
...
...
@@ -243,6 +251,8 @@ ret_string:;
// Non-primitive, object type
if
(
JJ
(
IsInstanceOf
,
arg
,
String_class
))
{
goto
ret_string
;
}
else
if
(
JJ
(
IsInstanceOf
,
arg
,
Class_class
))
{
return
new_jclass
(
arg
);
}
else
{
return
new_jobject
(
arg
);
}
...
...
@@ -379,15 +389,15 @@ STATIC void create_jvm() {
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_OSError
,
"unable to create JVM"
));
}
jclass
c
lass_class
=
JJ
(
FindClass
,
"java/lang/Class"
);
C
lass_class
=
JJ
(
FindClass
,
"java/lang/Class"
);
jclass
method_class
=
JJ
(
FindClass
,
"java/lang/reflect/Method"
);
String_class
=
JJ
(
FindClass
,
"java/lang/String"
);
Class_getField_mid
=
(
*
env
)
->
GetMethodID
(
env
,
c
lass_class
,
"getField"
,
Class_getField_mid
=
(
*
env
)
->
GetMethodID
(
env
,
C
lass_class
,
"getField"
,
"(Ljava/lang/String;)Ljava/lang/reflect/Field;"
);
Class_getMethods_mid
=
(
*
env
)
->
GetMethodID
(
env
,
c
lass_class
,
"getMethods"
,
Class_getMethods_mid
=
(
*
env
)
->
GetMethodID
(
env
,
C
lass_class
,
"getMethods"
,
"()[Ljava/lang/reflect/Method;"
);
Class_getConstructors_mid
=
(
*
env
)
->
GetMethodID
(
env
,
c
lass_class
,
"getConstructors"
,
Class_getConstructors_mid
=
(
*
env
)
->
GetMethodID
(
env
,
C
lass_class
,
"getConstructors"
,
"()[Ljava/lang/reflect/Constructor;"
);
Method_getName_mid
=
(
*
env
)
->
GetMethodID
(
env
,
method_class
,
"getName"
,
"()Ljava/lang/String;"
);
...
...
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