Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
1cb5de2c
Commit
1cb5de2c
authored
9 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
unix/modjni: jvalue2py: Handle class-containing jvalues.
parent
861fad58
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
unix/modjni.c
+14
-4
14 additions, 4 deletions
unix/modjni.c
with
14 additions
and
4 deletions
unix/modjni.c
+
14
−
4
View file @
1cb5de2c
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
static
JavaVM
*
jvm
;
static
JavaVM
*
jvm
;
static
JNIEnv
*
env
;
static
JNIEnv
*
env
;
static
jclass
Class_class
;
static
jclass
String_class
;
static
jclass
String_class
;
static
jmethodID
Class_getField_mid
;
static
jmethodID
Class_getField_mid
;
static
jmethodID
Class_getMethods_mid
;
static
jmethodID
Class_getMethods_mid
;
...
@@ -51,6 +52,7 @@ STATIC const mp_obj_type_t jobject_type;
...
@@ -51,6 +52,7 @@ STATIC const mp_obj_type_t jobject_type;
STATIC
const
mp_obj_type_t
jmethod_type
;
STATIC
const
mp_obj_type_t
jmethod_type
;
STATIC
mp_obj_t
new_jobject
(
jobject
jo
);
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
);
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
{
typedef
struct
_mp_obj_jclass_t
{
...
@@ -134,6 +136,12 @@ STATIC const mp_obj_type_t jclass_type = {
...
@@ -134,6 +136,12 @@ STATIC const mp_obj_type_t jclass_type = {
.
locals_dict
=
(
mp_obj_t
)
&
jclass_locals_dict
,
.
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
// jobject
...
@@ -243,6 +251,8 @@ ret_string:;
...
@@ -243,6 +251,8 @@ ret_string:;
// Non-primitive, object type
// Non-primitive, object type
if
(
JJ
(
IsInstanceOf
,
arg
,
String_class
))
{
if
(
JJ
(
IsInstanceOf
,
arg
,
String_class
))
{
goto
ret_string
;
goto
ret_string
;
}
else
if
(
JJ
(
IsInstanceOf
,
arg
,
Class_class
))
{
return
new_jclass
(
arg
);
}
else
{
}
else
{
return
new_jobject
(
arg
);
return
new_jobject
(
arg
);
}
}
...
@@ -379,15 +389,15 @@ STATIC void create_jvm() {
...
@@ -379,15 +389,15 @@ STATIC void create_jvm() {
nlr_raise
(
mp_obj_new_exception_msg_varg
(
&
mp_type_OSError
,
"unable to 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"
);
jclass
method_class
=
JJ
(
FindClass
,
"java/lang/reflect/Method"
);
String_class
=
JJ
(
FindClass
,
"java/lang/String"
);
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;"
);
"(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;"
);
"()[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;"
);
"()[Ljava/lang/reflect/Constructor;"
);
Method_getName_mid
=
(
*
env
)
->
GetMethodID
(
env
,
method_class
,
"getName"
,
Method_getName_mid
=
(
*
env
)
->
GetMethodID
(
env
,
method_class
,
"getName"
,
"()Ljava/lang/String;"
);
"()Ljava/lang/String;"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment