Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
216b6a49
Commit
216b6a49
authored
Oct 08, 2015
by
Paul Sokolovsky
Browse files
unix/modjni: Allow to access fields of objects.
parent
b948de36
Changes
1
Hide whitespace changes
Inline
Side-by-side
unix/modjni.c
View file @
216b6a49
...
...
@@ -206,6 +206,22 @@ STATIC void jobject_attr(mp_obj_t self_in, qstr attr_in, mp_obj_t *dest) {
// load attribute
mp_obj_jobject_t
*
self
=
self_in
;
const
char
*
attr
=
qstr_str
(
attr_in
);
jclass
obj_class
=
JJ
(
GetObjectClass
,
self
->
obj
);
jstring
field_name
=
JJ
(
NewStringUTF
,
attr
);
jobject
field
=
JJ
(
CallObjectMethod
,
obj_class
,
Class_getField_mid
,
field_name
);
JJ
(
DeleteLocalRef
,
field_name
);
JJ
(
DeleteLocalRef
,
obj_class
);
if
(
!
JJ1
(
ExceptionCheck
))
{
jfieldID
field_id
=
JJ
(
FromReflectedField
,
field
);
JJ
(
DeleteLocalRef
,
field
);
jobject
obj
=
JJ
(
GetObjectField
,
self
->
obj
,
field_id
);
dest
[
0
]
=
new_jobject
(
obj
);
return
;
}
//JJ1(ExceptionDescribe);
JJ1
(
ExceptionClear
);
mp_obj_jmethod_t
*
o
=
m_new_obj
(
mp_obj_jmethod_t
);
o
->
base
.
type
=
&
jmethod_type
;
o
->
name
=
attr_in
;
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment