blob: 498fc565b578c7e0969ad0b63addfe08350c3915 [file] [log] [blame]
Paul Sokolovskye79c6b62015-09-11 17:57:47 +03001/*
2 * This file is part of the Micro Python project, http://micropython.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2015 Paul Sokolovsky
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26
27#include <assert.h>
28#include <string.h>
29#include <errno.h>
30#include <dlfcn.h>
31
32#include "py/nlr.h"
33#include "py/runtime.h"
34#include "py/binary.h"
35
36#include <jni.h>
37
38#define JJ(call, ...) (*env)->call(env, __VA_ARGS__)
Paul Sokolovsky7a4b10c2015-09-14 00:12:27 +030039#define JJ1(call) (*env)->call(env)
Paul Sokolovskye79c6b62015-09-11 17:57:47 +030040
41static JavaVM *jvm;
42static JNIEnv *env;
Paul Sokolovsky1cb5de22015-09-17 13:31:16 +030043static jclass Class_class;
Paul Sokolovskye79c6b62015-09-11 17:57:47 +030044static jclass String_class;
45static jmethodID Class_getField_mid;
46static jmethodID Class_getMethods_mid;
47static jmethodID Class_getConstructors_mid;
48static jmethodID Method_getName_mid;
49static jmethodID Method_toString_mid;
50
Paul Sokolovskyb2d880d2015-09-21 12:02:22 -070051static jclass List_class;
52static jmethodID List_get_mid;
53static jmethodID List_set_mid;
54
Paul Sokolovskye79c6b62015-09-11 17:57:47 +030055STATIC const mp_obj_type_t jobject_type;
56STATIC const mp_obj_type_t jmethod_type;
57
Paul Sokolovsky7a4b10c2015-09-14 00:12:27 +030058STATIC mp_obj_t new_jobject(jobject jo);
Paul Sokolovsky1cb5de22015-09-17 13:31:16 +030059STATIC mp_obj_t new_jclass(jclass jc);
Paul Sokolovskye79c6b62015-09-11 17:57:47 +030060STATIC 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);
61
62typedef struct _mp_obj_jclass_t {
63 mp_obj_base_t base;
64 jclass cls;
65} mp_obj_jclass_t;
66
67typedef struct _mp_obj_jobject_t {
68 mp_obj_base_t base;
69 jobject obj;
70} mp_obj_jobject_t;
71
72typedef struct _mp_obj_jmethod_t {
73 mp_obj_base_t base;
74 jobject obj;
75 jmethodID meth;
76 qstr name;
Paul Sokolovsky7a4b10c2015-09-14 00:12:27 +030077 bool is_static;
Paul Sokolovskye79c6b62015-09-11 17:57:47 +030078} mp_obj_jmethod_t;
79
Paul Sokolovskye632b1f2015-09-23 07:10:55 -070080// Utility functions
81
82STATIC bool is_object_type(const char *jtypesig) {
83 while (*jtypesig != ' ' && *jtypesig) {
84 if (*jtypesig == '.') {
85 return true;
86 }
87 jtypesig++;
88 }
89 return false;
90}
91
Paul Sokolovskye79c6b62015-09-11 17:57:47 +030092// jclass
93
94STATIC void jclass_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
95 (void)kind;
96 mp_obj_jclass_t *self = self_in;
97 // Variable value printed as cast to int
98 mp_printf(print, "<jclass @%p>", self->cls);
99}
100
101STATIC void jclass_attr(mp_obj_t self_in, qstr attr_in, mp_obj_t *dest) {
102 if (dest[0] == MP_OBJ_NULL) {
103 // load attribute
104 mp_obj_jclass_t *self = self_in;
105 const char *attr = qstr_str(attr_in);
106
107 jstring field_name = JJ(NewStringUTF, attr);
108 jobject field = JJ(CallObjectMethod, self->cls, Class_getField_mid, field_name);
Paul Sokolovsky7a4b10c2015-09-14 00:12:27 +0300109 if (!JJ1(ExceptionCheck)) {
110 jfieldID field_id = JJ(FromReflectedField, field);
111 jobject obj = JJ(GetStaticObjectField, self->cls, field_id);
112 dest[0] = new_jobject(obj);
113 return;
114 }
115 //JJ1(ExceptionDescribe);
116 JJ1(ExceptionClear);
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300117
Paul Sokolovsky7a4b10c2015-09-14 00:12:27 +0300118 mp_obj_jmethod_t *o = m_new_obj(mp_obj_jmethod_t);
119 o->base.type = &jmethod_type;
120 o->name = attr_in;
121 o->meth = NULL;
122 o->obj = self->cls;
123 o->is_static = true;
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300124 dest[0] = o;
125 }
126}
127
128STATIC mp_obj_t jclass_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
129 if (n_kw != 0) {
130 nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "kwargs not supported"));
131 }
132 mp_obj_jclass_t *self = self_in;
133
134 jarray methods = JJ(CallObjectMethod, self->cls, Class_getConstructors_mid);
135
136 return call_method(self->cls, NULL, methods, true, n_args, args);
137}
138
139STATIC const mp_map_elem_t jclass_locals_dict_table[] = {
140// { MP_OBJ_NEW_QSTR(MP_QSTR_get), (mp_obj_t)&ffivar_get_obj },
141// { MP_OBJ_NEW_QSTR(MP_QSTR_set), (mp_obj_t)&ffivar_set_obj },
142};
143
144STATIC MP_DEFINE_CONST_DICT(jclass_locals_dict, jclass_locals_dict_table);
145
146STATIC const mp_obj_type_t jclass_type = {
147 { &mp_type_type },
148 .name = MP_QSTR_jclass,
149 .print = jclass_print,
150 .attr = jclass_attr,
151 .call = jclass_call,
152 .locals_dict = (mp_obj_t)&jclass_locals_dict,
153};
154
Paul Sokolovsky1cb5de22015-09-17 13:31:16 +0300155STATIC mp_obj_t new_jclass(jclass jc) {
156 mp_obj_jclass_t *o = m_new_obj(mp_obj_jclass_t);
157 o->base.type = &jclass_type;
158 o->cls = jc;
159 return o;
160}
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300161
162// jobject
163
164STATIC void jobject_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
165 (void)kind;
166 mp_obj_jobject_t *self = self_in;
167 // Variable value printed as cast to int
168 mp_printf(print, "<jobject @%p>", self->obj);
169}
170
171STATIC void jobject_attr(mp_obj_t self_in, qstr attr_in, mp_obj_t *dest) {
172 if (dest[0] == MP_OBJ_NULL) {
173 // load attribute
174 mp_obj_jobject_t *self = self_in;
175
176 mp_obj_jmethod_t *o = m_new_obj(mp_obj_jmethod_t);
177 o->base.type = &jmethod_type;
178 o->name = attr_in;
179 o->meth = NULL;
180 o->obj = self->obj;
Paul Sokolovsky7a4b10c2015-09-14 00:12:27 +0300181 o->is_static = false;
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300182 dest[0] = o;
183 }
184}
185
Paul Sokolovskyb2d880d2015-09-21 12:02:22 -0700186STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
187 mp_obj_jobject_t *self = self_in;
188 if (!JJ(IsInstanceOf, self->obj, List_class)) {
189 return MP_OBJ_NULL;
190 }
191
192 mp_uint_t idx = mp_obj_get_int(index);
193
194 if (value == MP_OBJ_NULL) {
195 // delete
196 assert(0);
197 } else if (value == MP_OBJ_SENTINEL) {
198 // load
199 jobject el = JJ(CallObjectMethod, self->obj, List_get_mid, idx);
200 return new_jobject(el);
201 } else {
202 // store
203 assert(0);
204 }
205
206
207return MP_OBJ_NULL;
208}
209
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300210STATIC const mp_obj_type_t jobject_type = {
211 { &mp_type_type },
212 .name = MP_QSTR_jobject,
213 .print = jobject_print,
214 .attr = jobject_attr,
Paul Sokolovskyb2d880d2015-09-21 12:02:22 -0700215 .subscr = jobject_subscr,
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300216// .locals_dict = (mp_obj_t)&jobject_locals_dict,
217};
218
Paul Sokolovsky26a9b4d2015-09-13 01:25:04 +0300219STATIC mp_obj_t new_jobject(jobject jo) {
Paul Sokolovskyed22e9b2015-09-22 17:01:01 -0700220 if (JJ(IsInstanceOf, jo, String_class)) {
221 const char *s = JJ(GetStringUTFChars, jo, NULL);
222 mp_obj_t ret = mp_obj_new_str(s, strlen(s), false);
223 JJ(ReleaseStringUTFChars, jo, s);
224 return ret;
225 } else if (JJ(IsInstanceOf, jo, Class_class)) {
226 return new_jclass(jo);
227 } else {
228 mp_obj_jobject_t *o = m_new_obj(mp_obj_jobject_t);
229 o->base.type = &jobject_type;
230 o->obj = jo;
231 return o;
232 }
233
Paul Sokolovsky26a9b4d2015-09-13 01:25:04 +0300234}
235
236
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300237// jmethod
238
239STATIC void jmethod_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
240 (void)kind;
241 mp_obj_jmethod_t *self = self_in;
242 // Variable value printed as cast to int
243 mp_printf(print, "<jmethod '%s'>", qstr_str(self->name));
244}
245
Paul Sokolovsky4e7bde82015-09-12 00:19:18 +0300246#define IMATCH(s, static) ((!strncmp(s, static, sizeof(static) - 1)) && (s += sizeof(static) - 1))
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300247
248#define CHECK_TYPE(java_type_name) \
Paul Sokolovsky4e7bde82015-09-12 00:19:18 +0300249 if (strncmp(arg_type, java_type_name, sizeof(java_type_name) - 1) != 0) { \
250 return false; \
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300251 } \
Paul Sokolovsky4e7bde82015-09-12 00:19:18 +0300252 arg_type += sizeof(java_type_name) - 1;
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300253
254STATIC const char *strprev(const char *s, char c) {
255 while (*s != c) {
256 s--;
257 }
258 return s;
259}
260
Paul Sokolovsky4e7bde82015-09-12 00:19:18 +0300261STATIC bool py2jvalue(const char **jtypesig, mp_obj_t arg, jvalue *out) {
262 const char *arg_type = *jtypesig;
263 mp_obj_type_t *type = mp_obj_get_type(arg);
264
265 if (type == &mp_type_str) {
266 if (IMATCH(arg_type, "java.lang.String") || IMATCH(arg_type, "java.lang.Object")) {
267 out->l = JJ(NewStringUTF, mp_obj_str_get_str(arg));
268 } else {
269 return false;
270 }
271 } else if (type == &mp_type_int) {
Paul Sokolovsky011c7f52015-09-18 13:19:50 +0300272 if (IMATCH(arg_type, "int") || IMATCH(arg_type, "long")) {
273 // TODO: Java long is 64-bit actually
274 out->j = mp_obj_get_int(arg);
275 } else {
276 return false;
277 }
Paul Sokolovsky1e9d8e12015-09-19 01:04:41 +0300278 } else if (type == &jobject_type) {
279 printf("TODO: Check java arg type!!\n");
280 mp_obj_jobject_t *jo = arg;
281 out->l = jo->obj;
Paul Sokolovsky4e7bde82015-09-12 00:19:18 +0300282 } else {
283 nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "arg type not supported"));
284 }
285
286 *jtypesig = arg_type;
287 return true;
288}
289
Paul Sokolovsky26a9b4d2015-09-13 01:25:04 +0300290// jvalue is known to be union of jobject and friends. And yet from C's
291// perspective, it's aggregate object which may require passing via stack
292// instead of registers. Work that around by passing jobject and typecasting
293// it.
294#define MATCH(s, static) (!strncmp(s, static, sizeof(static) - 1))
295STATIC mp_obj_t jvalue2py(const char *jtypesig, jobject arg) {
Paul Sokolovsky51673322015-09-14 00:15:08 +0300296 if (arg == NULL || MATCH(jtypesig, "void")) {
Paul Sokolovsky26a9b4d2015-09-13 01:25:04 +0300297 return mp_const_none;
Paul Sokolovsky6196aa42015-09-20 00:36:26 +0300298 } else if (MATCH(jtypesig, "boolean")) {
299 return mp_obj_new_bool((bool)arg);
Paul Sokolovsky26a9b4d2015-09-13 01:25:04 +0300300 } else if (MATCH(jtypesig, "int")) {
301 return mp_obj_new_int((mp_int_t)arg);
Paul Sokolovskye632b1f2015-09-23 07:10:55 -0700302 } else if (is_object_type(jtypesig)) {
303 // Non-primitive, object type
304 return new_jobject(arg);
Paul Sokolovsky26a9b4d2015-09-13 01:25:04 +0300305 }
306
Paul Sokolovskye632b1f2015-09-23 07:10:55 -0700307 printf("Unknown return type: %s\n", jtypesig);
Paul Sokolovskyb230a862015-09-15 14:07:12 +0300308
Paul Sokolovsky26a9b4d2015-09-13 01:25:04 +0300309 return MP_OBJ_NULL;
310}
311
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300312STATIC 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) {
313 jvalue jargs[n_args];
314// printf("methods=%p\n", methods);
315 jsize num_methods = JJ(GetArrayLength, methods);
316 for (int i = 0; i < num_methods; i++) {
317 jobject meth = JJ(GetObjectArrayElement, methods, i);
318 jobject name_o = JJ(CallObjectMethod, meth, Method_toString_mid);
319 const char *decl = JJ(GetStringUTFChars, name_o, NULL);
320 const char *arg_types = strchr(decl, '(') + 1;
321 //const char *arg_types_end = strchr(arg_types, ')');
322// printf("method[%d]=%p %s\n", i, meth, decl);
323
324 const char *meth_name = NULL;
325 const char *ret_type = NULL;
326 if (!is_constr) {
327 meth_name = strprev(arg_types, '.') + 1;
328 ret_type = strprev(meth_name, ' ') - 1;
329 ret_type = strprev(ret_type, ' ') + 1;
330
331 int name_len = strlen(name);
332 if (strncmp(name, meth_name, name_len/*arg_types - meth_name - 1*/) || meth_name[name_len] != '('/*(*/) {
333 continue;
334 }
335 }
336// printf("method[%d]=%p %s\n", i, meth, decl);
337// printf("!!!%s\n", arg_types);
338// printf("name=%p meth_name=%s\n", name, meth_name);
339
340 bool found = true;
341 for (int i = 0; i < n_args; i++) {
Paul Sokolovsky4e7bde82015-09-12 00:19:18 +0300342 if (!py2jvalue(&arg_types, args[i], &jargs[i])) {
343 goto next_method;
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300344 }
345
346 if (*arg_types == ',') {
347 arg_types++;
348 }
349 }
350
351 if (found) {
352// printf("found!\n");
353 jmethodID method_id = JJ(FromReflectedMethod, meth);
354 jobject res;
355 if (is_constr) {
356 res = JJ(NewObjectA, obj, method_id, jargs);
Paul Sokolovsky26a9b4d2015-09-13 01:25:04 +0300357 JJ(ReleaseStringUTFChars, name_o, decl);
358 return new_jobject(res);
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300359 } else {
360 res = JJ(CallObjectMethodA, obj, method_id, jargs);
Paul Sokolovsky26a9b4d2015-09-13 01:25:04 +0300361 mp_obj_t ret = jvalue2py(ret_type, res);
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300362 JJ(ReleaseStringUTFChars, name_o, decl);
363 if (ret != MP_OBJ_NULL) {
364 return ret;
365 }
366 nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "cannot handle return type"));
367 }
368 }
369
Paul Sokolovsky4e7bde82015-09-12 00:19:18 +0300370next_method:
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300371 JJ(ReleaseStringUTFChars, name_o, decl);
372 }
373
374 nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "method not found"));
375}
376
377
378STATIC mp_obj_t jmethod_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
379 if (n_kw != 0) {
380 nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "kwargs not supported"));
381 }
382 mp_obj_jmethod_t *self = self_in;
383
384 const char *name = qstr_str(self->name);
385// jstring meth_name = JJ(NewStringUTF, name);
386
Paul Sokolovsky7a4b10c2015-09-14 00:12:27 +0300387 jclass obj_class = self->obj;
388 if (!self->is_static) {
389 obj_class = JJ(GetObjectClass, self->obj);
390 }
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300391 jarray methods = JJ(CallObjectMethod, obj_class, Class_getMethods_mid);
392
393 return call_method(self->obj, name, methods, false, n_args, args);
394}
395
396STATIC const mp_obj_type_t jmethod_type = {
397 { &mp_type_type },
398 .name = MP_QSTR_jmethod,
399 .print = jmethod_print,
400 .call = jmethod_call,
401// .attr = jobject_attr,
402// .locals_dict = (mp_obj_t)&jobject_locals_dict,
403};
404
405#ifdef __ANDROID__
406#define LIBJVM_SO "libdvm.so"
407#else
408#define LIBJVM_SO "libjvm.so"
409#endif
410
411STATIC void create_jvm() {
412 JavaVMInitArgs args;
413 JavaVMOption options;
414 options.optionString = "-Djava.class.path=.";
415 args.version = JNI_VERSION_1_6;
416 args.nOptions = 1;
417 args.options = &options;
418 args.ignoreUnrecognized = 0;
419
420 if (env) {
421 return;
422 }
423
424 void *libjvm = dlopen(LIBJVM_SO, RTLD_NOW | RTLD_GLOBAL);
425 if (!libjvm) {
426 nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "unable to load libjvm.so, use LD_LIBRARY_PATH"));
427 }
428 int (*_JNI_CreateJavaVM)(void*, void**, void*) = dlsym(libjvm, "JNI_CreateJavaVM");
429
430 int st = _JNI_CreateJavaVM(&jvm, (void**)&env, &args);
431 if (st < 0 || !env) {
432 nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "unable to create JVM"));
433 }
434
Paul Sokolovsky1cb5de22015-09-17 13:31:16 +0300435 Class_class = JJ(FindClass, "java/lang/Class");
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300436 jclass method_class = JJ(FindClass, "java/lang/reflect/Method");
437 String_class = JJ(FindClass, "java/lang/String");
438
Paul Sokolovsky1cb5de22015-09-17 13:31:16 +0300439 Class_getField_mid = (*env)->GetMethodID(env, Class_class, "getField",
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300440 "(Ljava/lang/String;)Ljava/lang/reflect/Field;");
Paul Sokolovsky1cb5de22015-09-17 13:31:16 +0300441 Class_getMethods_mid = (*env)->GetMethodID(env, Class_class, "getMethods",
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300442 "()[Ljava/lang/reflect/Method;");
Paul Sokolovsky1cb5de22015-09-17 13:31:16 +0300443 Class_getConstructors_mid = (*env)->GetMethodID(env, Class_class, "getConstructors",
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300444 "()[Ljava/lang/reflect/Constructor;");
445 Method_getName_mid = (*env)->GetMethodID(env, method_class, "getName",
446 "()Ljava/lang/String;");
447 Method_toString_mid = (*env)->GetMethodID(env, method_class, "toString",
448 "()Ljava/lang/String;");
Paul Sokolovskyb2d880d2015-09-21 12:02:22 -0700449
450 List_class = JJ(FindClass, "java/util/List");
451 List_get_mid = JJ(GetMethodID, List_class, "get",
452 "(I)Ljava/lang/Object;");
453 List_set_mid = JJ(GetMethodID, List_class, "set",
454 "(ILjava/lang/Object;)Ljava/lang/Object;");
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300455}
456
457STATIC mp_obj_t mod_jni_cls(mp_obj_t cls_name_in) {
458 const char *cls_name = mp_obj_str_get_str(cls_name_in);
459 if (!env) {
460 create_jvm();
461 }
462 jclass cls = JJ(FindClass, cls_name);
463
464 mp_obj_jclass_t *o = m_new_obj(mp_obj_jclass_t);
465 o->base.type = &jclass_type;
466 o->cls = cls;
467 return o;
468}
469MP_DEFINE_CONST_FUN_OBJ_1(mod_jni_cls_obj, mod_jni_cls);
470
Paul Sokolovskycb6cf5e2015-09-16 01:09:39 +0300471STATIC mp_obj_t mod_jni_env() {
472 return mp_obj_new_int((mp_int_t)env);
473}
474MP_DEFINE_CONST_FUN_OBJ_0(mod_jni_env_obj, mod_jni_env);
475
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300476STATIC const mp_map_elem_t mp_module_jni_globals_table[] = {
477 { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_jni) },
478 { MP_OBJ_NEW_QSTR(MP_QSTR_cls), (mp_obj_t)&mod_jni_cls_obj },
Paul Sokolovskycb6cf5e2015-09-16 01:09:39 +0300479 { MP_OBJ_NEW_QSTR(MP_QSTR_env), (mp_obj_t)&mod_jni_env_obj },
Paul Sokolovskye79c6b62015-09-11 17:57:47 +0300480};
481
482STATIC MP_DEFINE_CONST_DICT(mp_module_jni_globals, mp_module_jni_globals_table);
483
484const mp_obj_module_t mp_module_jni = {
485 .base = { &mp_type_module },
486 .name = MP_QSTR_jni,
487 .globals = (mp_obj_dict_t*)&mp_module_jni_globals,
488};