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
GitLab 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
3fea1f01
Commit
3fea1f01
authored
8 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
unix/modjni: Implement subscription for object arrays.
parent
0fd3d8d1
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
+27
-1
27 additions, 1 deletion
unix/modjni.c
with
27 additions
and
1 deletion
unix/modjni.c
+
27
−
1
View file @
3fea1f01
...
@@ -65,6 +65,7 @@ STATIC const mp_obj_type_t jmethod_type;
...
@@ -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_jobject
(
jobject
jo
);
STATIC
mp_obj_t
new_jclass
(
jclass
jc
);
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
);
STATIC
bool
py2jvalue
(
const
char
**
jtypesig
,
mp_obj_t
arg
,
jvalue
*
out
);
typedef
struct
_mp_obj_jclass_t
{
typedef
struct
_mp_obj_jclass_t
{
mp_obj_base_t
base
;
mp_obj_base_t
base
;
...
@@ -244,11 +245,36 @@ STATIC void get_jclass_name(jobject obj, char *buf) {
...
@@ -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
)
{
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_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
))
{
if
(
!
JJ
(
IsInstanceOf
,
self
->
obj
,
List_class
))
{
return
MP_OBJ_NULL
;
return
MP_OBJ_NULL
;
}
}
mp_uint_t
idx
=
mp_obj_get_int
(
index
);
if
(
value
==
MP_OBJ_NULL
)
{
if
(
value
==
MP_OBJ_NULL
)
{
// delete
// delete
...
...
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