Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
3fea1f01
Commit
3fea1f01
authored
Sep 16, 2016
by
Paul Sokolovsky
Browse files
unix/modjni: Implement subscription for object arrays.
parent
0fd3d8d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
unix/modjni.c
View file @
3fea1f01
...
...
@@ -65,6 +65,7 @@ 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
);
STATIC
bool
py2jvalue
(
const
char
**
jtypesig
,
mp_obj_t
arg
,
jvalue
*
out
);
typedef
struct
_mp_obj_jclass_t
{
mp_obj_base_t
base
;
...
...
@@ -244,11 +245,36 @@ STATIC void get_jclass_name(jobject obj, char *buf) {
STATIC
mp_obj_t
jobject_subscr
(
mp_obj_t
self_in
,
mp_obj_t
index
,
mp_obj_t
value
)
{
mp_obj_jobject_t
*
self
=
self_in
;
mp_uint_t
idx
=
mp_obj_get_int
(
index
);
char
class_name
[
64
];
get_jclass_name
(
self
->
obj
,
class_name
);
//printf("class: %s\n", class_name);
if
(
class_name
[
0
]
==
'['
)
{
if
(
class_name
[
1
]
==
'L'
||
class_name
[
1
]
==
'['
)
{
if
(
value
==
MP_OBJ_NULL
)
{
// delete
assert
(
0
);
}
else
if
(
value
==
MP_OBJ_SENTINEL
)
{
// load
jobject
el
=
JJ
(
GetObjectArrayElement
,
self
->
obj
,
idx
);
return
new_jobject
(
el
);
}
else
{
// store
jvalue
jval
;
const
char
*
t
=
class_name
+
1
;
py2jvalue
(
&
t
,
value
,
&
jval
);
JJ
(
SetObjectArrayElement
,
self
->
obj
,
idx
,
jval
.
l
);
return
mp_const_none
;
}
}
mp_not_implemented
(
""
);
}
if
(
!
JJ
(
IsInstanceOf
,
self
->
obj
,
List_class
))
{
return
MP_OBJ_NULL
;
}
mp_uint_t
idx
=
mp_obj_get_int
(
index
);
if
(
value
==
MP_OBJ_NULL
)
{
// delete
...
...
Write
Preview
Supports
Markdown
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