@@ -65,6 +65,7 @@ STATIC const mp_obj_type_t jmethod_type;
6565STATIC mp_obj_t new_jobject (jobject jo );
6666STATIC mp_obj_t new_jclass (jclass jc );
6767STATIC 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 );
68+ STATIC bool py2jvalue (const char * * jtypesig , mp_obj_t arg , jvalue * out );
6869
6970typedef struct _mp_obj_jclass_t {
7071 mp_obj_base_t base ;
@@ -244,11 +245,36 @@ STATIC void get_jclass_name(jobject obj, char *buf) {
244245
245246STATIC mp_obj_t jobject_subscr (mp_obj_t self_in , mp_obj_t index , mp_obj_t value ) {
246247 mp_obj_jobject_t * self = self_in ;
248+ mp_uint_t idx = mp_obj_get_int (index );
249+ char class_name [64 ];
250+ get_jclass_name (self -> obj , class_name );
251+ //printf("class: %s\n", class_name);
252+
253+ if (class_name [0 ] == '[' ) {
254+ if (class_name [1 ] == 'L' || class_name [1 ] == '[' ) {
255+ if (value == MP_OBJ_NULL ) {
256+ // delete
257+ assert (0 );
258+ } else if (value == MP_OBJ_SENTINEL ) {
259+ // load
260+ jobject el = JJ (GetObjectArrayElement , self -> obj , idx );
261+ return new_jobject (el );
262+ } else {
263+ // store
264+ jvalue jval ;
265+ const char * t = class_name + 1 ;
266+ py2jvalue (& t , value , & jval );
267+ JJ (SetObjectArrayElement , self -> obj , idx , jval .l );
268+ return mp_const_none ;
269+ }
270+ }
271+ mp_not_implemented ("" );
272+ }
273+
247274 if (!JJ (IsInstanceOf , self -> obj , List_class )) {
248275 return MP_OBJ_NULL ;
249276 }
250277
251- mp_uint_t idx = mp_obj_get_int (index );
252278
253279 if (value == MP_OBJ_NULL ) {
254280 // delete
0 commit comments