You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: libscript/src/java.lcb
+79Lines changed: 79 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -46,11 +46,14 @@ public type JDouble is Float64
46
46
public foreign type JObject binds to "MCJavaObjectTypeInfo"
47
47
public type JString is JObject
48
48
public type JByteArray is JObject
49
+
public type JObjectArray is JObject
49
50
50
51
foreign handler MCJavaStringFromJString(in pString as JObject, out rString as String) returns nothing binds to "<builtin>"
51
52
foreign handler MCJavaStringToJString(in pString as String, out rString as JObject) returns nothing binds to "<builtin>"
52
53
foreign handler MCJavaDataFromJByteArray(in pByteArray as JObject, out rData as Data) returns nothing binds to "<builtin>"
53
54
foreign handler MCJavaDataToJByteArray(in pData as Data, out rByteArray as JObject) returns nothing binds to "<builtin>"
55
+
foreign handler MCJavaListToJObjectArray(in pList as List, in pClassName as String, out rObjectArray as JObjectArray) returns nothing binds to "<builtin>"
56
+
foreign handler MCJavaListFromJObjectArray(in pObjectArray as JObjectArray, out rList as List) returns nothing binds to "<builtin>"
54
57
55
58
foreign handler MCJavaGetClassName(in pObject as JObject, out rName as String) returns nothing binds to "<builtin>"
56
59
foreign handler MCJavaUnwrapJObject(in pObject as JObject, out rPointer as Pointer) returns nothing binds to "<builtin>"
@@ -245,4 +248,80 @@ public handler PointerToJObject(in pPointer as Pointer) returns JObject
245
248
return tObj
246
249
end handler
247
250
251
+
/**
252
+
Summary: Convert a java object array into a List of java objects
253
+
254
+
Parameters:
255
+
pObj: The JObjectArray to convert
256
+
257
+
Example:
258
+
__safe foreign handler _JNI_IntentGetStringArrayExtra(in pIntent as JObject, \
259
+
in pType as JString) \
260
+
returns JObjectArray \
261
+
binds to "java:android.content.Intent>getStringArrayExtra(Ljava/lang/String;)[Ljava/lang/String;"
262
+
263
+
handler OnActivityResultListener(\
264
+
in pRequestCode as JObject, \
265
+
in pResultCode as JObject, \
266
+
in pIntent as optional JObject) returns nothing
267
+
268
+
if pResultCode is -1 then
269
+
variable tArray as JObjectArray
270
+
put _JNI_IntentGetStringArrayExtra(pIntent, \
271
+
StringToJString("android.intent.extra.MIME_TYPES")) into tArray
272
+
variable tList as List
273
+
put ListFromJObjectArray(tArray) into tList
274
+
275
+
variable tStringList as List
276
+
variable tString as JObject
277
+
repeat for each element tString in tList
278
+
push StringFromJObject(tString) onto back of tStringList
279
+
end repeat
280
+
281
+
post "mimeTypes" with [tStringList]
282
+
end if
283
+
284
+
end handler
285
+
286
+
Description:
287
+
Use <ListFromJObjectArray> to convert <pObj> into a List of JObjects.
288
+
289
+
*/
290
+
public handler ListFromJObjectArray(in pObj as JObjectArray) returns String
291
+
variable tList as List
292
+
unsafe
293
+
MCJavaListFromJObjectArray(pObj, tList)
294
+
end unsafe
295
+
return tList
296
+
end handler
297
+
298
+
/**
299
+
Summary: Convert a List of JObjects into a JObjectArray
300
+
301
+
Parameters:
302
+
pList: The List to convert
303
+
pClass: The class name of the JObjects in the List
304
+
305
+
Returns:
306
+
A JObjectArray where each element is a JObject of class pClass
0 commit comments