forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAndroidJNI.bindings.cs
More file actions
1434 lines (1319 loc) · 63.2 KB
/
Copy pathAndroidJNI.bindings.cs
File metadata and controls
1434 lines (1319 loc) · 63.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using UnityEngine;
using UnityEngine.Bindings;
using UnityEngine.Scripting;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using System;
using System.Runtime.InteropServices;
namespace UnityEngine
{
[StructLayout(LayoutKind.Explicit)]
[NativeType(CodegenOptions.Custom, "ScriptingJvalue")]
public struct jvalue
{
[FieldOffset(0)] public bool z;
[FieldOffset(0)] public sbyte b;
[FieldOffset(0)] public char c;
[FieldOffset(0)] public short s;
[FieldOffset(0)] public int i;
[FieldOffset(0)] public long j;
[FieldOffset(0)] public float f;
[FieldOffset(0)] public double d;
[FieldOffset(0)] public System.IntPtr l;
}
[StructLayout(LayoutKind.Sequential)]
[NativeType(CodegenOptions.Custom, "ScriptingJNINativeMethod")]
public struct JNINativeMethod
{
public string name;
public string signature;
public IntPtr fnPtr;
}
// Helper interface for JNI interaction; signature creation and method lookups
[UsedByNativeCode]
[NativeHeader("Modules/AndroidJNI/Public/AndroidJNIBindingsHelpers.h")]
[StaticAccessor("AndroidJNIBindingsHelpers", StaticAccessorType.DoubleColon)]
[NativeConditional("PLATFORM_ANDROID")]
public static class AndroidJNIHelper
{
// Set /debug/ to true to log calls through the AndroidJNIHelper
public static extern bool debug { get; set; }
// Scans a particular Java class for a constructor method matching a signature.
public static IntPtr GetConstructorID(IntPtr javaClass)
{
return GetConstructorID(javaClass, "");
}
// Scans a particular Java class for a constructor method matching a signature.
public static IntPtr GetConstructorID(IntPtr javaClass, [UnityEngine.Internal.DefaultValue("")] string signature)
{
return _AndroidJNIHelper.GetConstructorID(javaClass, signature);
}
// Scans a particular Java class for a method matching a name and a signature.
public static IntPtr GetMethodID(IntPtr javaClass, string methodName)
{
return GetMethodID(javaClass, methodName, "", false);
}
// Scans a particular Java class for a method matching a name and a signature.
public static IntPtr GetMethodID(IntPtr javaClass, string methodName, [UnityEngine.Internal.DefaultValue("")] string signature)
{
return GetMethodID(javaClass, methodName, signature, false);
}
// Scans a particular Java class for a method matching a name and a signature.
public static IntPtr GetMethodID(IntPtr javaClass, string methodName, [UnityEngine.Internal.DefaultValue("")] string signature, [UnityEngine.Internal.DefaultValue("false")] bool isStatic)
{
return _AndroidJNIHelper.GetMethodID(javaClass, methodName, signature, isStatic);
}
// Scans a particular Java class for a field matching a name and a signature.
public static IntPtr GetFieldID(IntPtr javaClass, string fieldName)
{
return GetFieldID(javaClass, fieldName, "", false);
}
// Scans a particular Java class for a field matching a name and a signature.
public static IntPtr GetFieldID(IntPtr javaClass, string fieldName, [UnityEngine.Internal.DefaultValue("")] string signature)
{
return GetFieldID(javaClass, fieldName, signature, false);
}
// Scans a particular Java class for a field matching a name and a signature.
public static IntPtr GetFieldID(IntPtr javaClass, string fieldName, [UnityEngine.Internal.DefaultValue("")] string signature, [UnityEngine.Internal.DefaultValue("false")] bool isStatic)
{
return _AndroidJNIHelper.GetFieldID(javaClass, fieldName, signature, isStatic);
}
// Creates a UnityJavaRunnable object (implements java.lang.Runnable).
public static IntPtr CreateJavaRunnable(AndroidJavaRunnable jrunnable)
{
return _AndroidJNIHelper.CreateJavaRunnable(jrunnable);
}
// Creates a UnityJavaProxy object (implements jinterface).
public static IntPtr CreateJavaProxy(AndroidJavaProxy proxy)
{
var handle = GCHandle.Alloc(proxy);
try
{
return _AndroidJNIHelper.CreateJavaProxy(GCHandle.ToIntPtr(handle), proxy);
}
catch
{
handle.Free();
throw;
}
}
// Creates a Java array from a managed array
public static IntPtr ConvertToJNIArray(System.Array array)
{
return _AndroidJNIHelper.ConvertToJNIArray(array);
}
// Creates the parameter array to be used as argument list when invoking Java code through CallMethod() in AndroidJNI.
public static jvalue[] CreateJNIArgArray(object[] args)
{
jvalue[] ret = new jvalue[args.Length];
_AndroidJNIHelper.CreateJNIArgArray(args, ret);
return ret;
}
public static void CreateJNIArgArray(object[] args, Span<jvalue> jniArgs)
{
if (args.Length != jniArgs.Length)
throw new ArgumentException($"Both arrays must be of the same length, but are {args.Length} and {jniArgs.Length}");
_AndroidJNIHelper.CreateJNIArgArray(args, jniArgs);
}
// Deletes any local jni references previously allocated by CreateJNIArgArray()
//
// @param jniArgs the array returned by CreateJNIArgArray()
// @param args the array of arguments used as a parameter to CreateJNIArgArray()
//
public static void DeleteJNIArgArray(object[] args, jvalue[] jniArgs)
{
_AndroidJNIHelper.DeleteJNIArgArray(args, jniArgs);
}
public static void DeleteJNIArgArray(object[] args, Span<jvalue> jniArgs)
{
_AndroidJNIHelper.DeleteJNIArgArray(args, jniArgs);
}
// Get a JNI method ID for a constructor based on calling arguments.
// Scans a particular Java class for a constructor method matching a signature based on passed arguments.
// The signature comparison is done to allow for sub-/base-classes of the class types.
//
// @param javaClass Raw JNI Java class object (obtained by calling AndroidJNI.FindClass).
// @param args Array with parameters to be passed to the constructor when invoked.
//
public static System.IntPtr GetConstructorID(System.IntPtr jclass, object[] args)
{
return _AndroidJNIHelper.GetConstructorID(jclass, args);
}
// Get a JNI method ID based on calling arguments.
public static System.IntPtr GetMethodID(System.IntPtr jclass, string methodName, object[] args, bool isStatic)
{
return _AndroidJNIHelper.GetMethodID(jclass, methodName, args, isStatic);
}
// Creates the JNI signature string for particular object type
public static string GetSignature(object obj)
{
return _AndroidJNIHelper.GetSignature(obj);
}
// Creates the JNI signature string for an object parameter list.
public static string GetSignature(object[] args)
{
return _AndroidJNIHelper.GetSignature(args);
}
//===================================================================
// Creates a managed array from a Java array
public static ArrayType ConvertFromJNIArray<ArrayType>(IntPtr array)
{
return _AndroidJNIHelper.ConvertFromJNIArray<ArrayType>(array);
}
// Get a JNI method ID based on calling arguments.
public static System.IntPtr GetMethodID<ReturnType>(System.IntPtr jclass, string methodName, object[] args, bool isStatic)
{
return _AndroidJNIHelper.GetMethodID<ReturnType>(jclass, methodName, args, isStatic);
}
// Get a JNI field ID based on type detection. Generic parameter represents the field type.
public static System.IntPtr GetFieldID<FieldType>(System.IntPtr jclass, string fieldName, bool isStatic)
{
return _AndroidJNIHelper.GetFieldID<FieldType>(jclass, fieldName, isStatic);
}
// Creates the JNI signature string for an object parameter list.
public static string GetSignature<ReturnType>(object[] args)
{
return _AndroidJNIHelper.GetSignature<ReturnType>(args);
}
// Box primitive to a boxed object
static IntPtr Box(jvalue val, string boxedClass, string signature)
{
IntPtr clazz = AndroidJNISafe.FindClass(boxedClass);
try
{
IntPtr method = AndroidJNISafe.GetStaticMethodID(clazz, "valueOf", signature);
unsafe
{
var args = new Span<jvalue>(&val, 1);
return AndroidJNISafe.CallStaticObjectMethod(clazz, method, args);
}
}
finally
{
AndroidJNISafe.DeleteLocalRef(clazz);
}
}
public static IntPtr Box(sbyte value)
{
jvalue val = default;
val.b = value;
return Box(val, "java/lang/Byte", "(B)Ljava/lang/Byte;");
}
public static IntPtr Box(short value)
{
jvalue val = default;
val.s = value;
return Box(val, "java/lang/Short", "(S)Ljava/lang/Short;");
}
public static IntPtr Box(int value)
{
jvalue val = default;
val.i = value;
return Box(val, "java/lang/Integer", "(I)Ljava/lang/Integer;");
}
public static IntPtr Box(long value)
{
jvalue val = default;
val.j = value;
return Box(val, "java/lang/Long", "(J)Ljava/lang/Long;");
}
public static IntPtr Box(float value)
{
jvalue val = default;
val.f = value;
return Box(val, "java/lang/Float", "(F)Ljava/lang/Float;");
}
public static IntPtr Box(double value)
{
jvalue val = default;
val.d = value;
return Box(val, "java/lang/Double", "(D)Ljava/lang/Double;");
}
public static IntPtr Box(char value)
{
jvalue val = default;
val.c = value;
return Box(val, "java/lang/Character", "(C)Ljava/lang/Character;");
}
public static IntPtr Box(bool value)
{
jvalue val = default;
val.z = value;
return Box(val, "java/lang/Boolean", "(Z)Ljava/lang/Boolean;");
}
// Unbox a primitive from boxed counterpart
static IntPtr GetUnboxMethod(IntPtr obj, string methodName, string signature)
{
IntPtr clazz = AndroidJNISafe.GetObjectClass(obj);
try
{
return AndroidJNISafe.GetMethodID(clazz, methodName, signature);
}
finally
{
AndroidJNISafe.DeleteLocalRef(clazz);
}
}
public static void Unbox(IntPtr obj, out sbyte value)
{
IntPtr method = GetUnboxMethod(obj, "byteValue", "()B");
value = AndroidJNISafe.CallSByteMethod(obj, method, new Span<jvalue>());
}
public static void Unbox(IntPtr obj, out short value)
{
IntPtr method = GetUnboxMethod(obj, "shortValue", "()S");
value = AndroidJNISafe.CallShortMethod(obj, method, new Span<jvalue>());
}
public static void Unbox(IntPtr obj, out int value)
{
IntPtr method = GetUnboxMethod(obj, "intValue", "()I");
value = AndroidJNISafe.CallIntMethod(obj, method, new Span<jvalue>());
}
public static void Unbox(IntPtr obj, out long value)
{
IntPtr method = GetUnboxMethod(obj, "longValue", "()J");
value = AndroidJNISafe.CallLongMethod(obj, method, new Span<jvalue>());
}
public static void Unbox(IntPtr obj, out float value)
{
IntPtr method = GetUnboxMethod(obj, "floatValue", "()F");
value = AndroidJNISafe.CallFloatMethod(obj, method, new Span<jvalue>());
}
public static void Unbox(IntPtr obj, out double value)
{
IntPtr method = GetUnboxMethod(obj, "doubleValue", "()D");
value = AndroidJNISafe.CallDoubleMethod(obj, method, new Span<jvalue>());
}
public static void Unbox(IntPtr obj, out char value)
{
IntPtr method = GetUnboxMethod(obj, "charValue", "()C");
value = AndroidJNISafe.CallCharMethod(obj, method, new Span<jvalue>());
}
public static void Unbox(IntPtr obj, out bool value)
{
IntPtr method = GetUnboxMethod(obj, "booleanValue", "()Z");
value = AndroidJNISafe.CallBooleanMethod(obj, method, new Span<jvalue>());
}
}
// 'Raw' JNI interface to Android Dalvik (Java) VM from Scripting (CS/JS)
[NativeHeader("Modules/AndroidJNI/Public/AndroidJNIBindingsHelpers.h")]
[StaticAccessor("AndroidJNIBindingsHelpers", StaticAccessorType.DoubleColon)]
[NativeConditional("PLATFORM_ANDROID")]
public static class AndroidJNI
{
[ThreadSafe]
[StaticAccessor("jni", StaticAccessorType.DoubleColon)]
public static extern IntPtr GetJavaVM();
// Attaches the current thread to a Java (Dalvik) VM.
[ThreadSafe]
public static extern int AttachCurrentThread();
// Detaches the current thread from a Java (Dalvik) VM.
[ThreadSafe]
public static extern int DetachCurrentThread();
// Returns the version of the native method interface.
[ThreadSafe]
public static extern int GetVersion();
// This function loads a locally-defined class.
[ThreadSafe]
public static extern IntPtr FindClass(string name);
// Converts a <tt>java.lang.reflect.Method</tt> or <tt>java.lang.reflect.Constructor</tt> object to a method ID.
[ThreadSafe]
public static extern IntPtr FromReflectedMethod(IntPtr refMethod);
// Converts a <tt>java.lang.reflect.Field</tt> to a field ID.
[ThreadSafe]
public static extern IntPtr FromReflectedField(IntPtr refField);
// Converts a method ID derived from clazz to a <tt>java.lang.reflect.Method</tt> or <tt>java.lang.reflect.Constructor</tt> object.
[ThreadSafe]
public static extern IntPtr ToReflectedMethod(IntPtr clazz, IntPtr methodID, bool isStatic);
// Converts a field ID derived from cls to a <tt>java.lang.reflect.Field</tt> object.
[ThreadSafe]
public static extern IntPtr ToReflectedField(IntPtr clazz, IntPtr fieldID, bool isStatic);
// If <tt>clazz</tt> represents any class other than the class <tt>Object</tt>, then this function returns the object that represents the superclass of the class specified by <tt>clazz</tt>.
[ThreadSafe]
public static extern IntPtr GetSuperclass(IntPtr clazz);
// Determines whether an object of <tt>clazz1</tt> can be safely cast to <tt>clazz2</tt>.
[ThreadSafe]
public static extern bool IsAssignableFrom(IntPtr clazz1, IntPtr clazz2);
// Causes a <tt>java.lang.Throwable</tt> object to be thrown.
[ThreadSafe]
public static extern int Throw(IntPtr obj);
// Constructs an exception object from the specified class with the <tt>message</tt> specified by message and causes that exception to be thrown.
[ThreadSafe]
public static extern int ThrowNew(IntPtr clazz, string message);
// Determines if an exception is being thrown
[ThreadSafe]
public static extern IntPtr ExceptionOccurred();
// Prints an exception and a backtrace of the stack to the <tt>logcat</tt>
[ThreadSafe]
public static extern void ExceptionDescribe();
// Clears any exception that is currently being thrown.
[ThreadSafe]
public static extern void ExceptionClear();
// Raises a fatal error and does not expect the VM to recover. This function does not return.
[ThreadSafe]
public static extern void FatalError(string message);
// Creates a new local reference frame, in which at least a given number of local references can be created.
[ThreadSafe]
public static extern int PushLocalFrame(int capacity);
// Pops off the current local reference frame, frees all the local references, and returns a local reference in the previous local reference frame for the given <tt>result</tt> object.
[ThreadSafe]
public static extern IntPtr PopLocalFrame(IntPtr ptr);
// Creates a new global reference to the object referred to by the <tt>obj</tt> argument.
[ThreadSafe]
public static extern IntPtr NewGlobalRef(IntPtr obj);
// Deletes the global reference pointed to by <tt>obj</tt>.
[ThreadSafe]
public static extern void DeleteGlobalRef(IntPtr obj);
// Creates a new global weak reference to the object referred to by the <tt>obj</tt> argument.
[ThreadSafe]
public static extern IntPtr NewWeakGlobalRef(IntPtr obj);
// Deletes the global weak reference pointed to by <tt>obj</tt>.
[ThreadSafe]
public static extern void DeleteWeakGlobalRef(IntPtr obj);
// Creates a new local reference that refers to the same object as <tt>obj</tt>.
[ThreadSafe]
public static extern IntPtr NewLocalRef(IntPtr obj);
// Deletes the local reference pointed to by <tt>obj</tt>.
[ThreadSafe]
public static extern void DeleteLocalRef(IntPtr obj);
// Tests whether two references refer to the same Java object.
[ThreadSafe]
public static extern bool IsSameObject(IntPtr obj1, IntPtr obj2);
// Ensures that at least a given number of local references can be created in the current thread.
[ThreadSafe]
public static extern int EnsureLocalCapacity(int capacity);
//-------------------------------------------
// Allocates a new Java object without invoking any of the constructors for the object.
[ThreadSafe]
public static extern IntPtr AllocObject(IntPtr clazz);
// Constructs a new Java object. The method ID indicates which constructor method to invoke. This ID must be obtained by calling GetMethodID() with <init> as the method name and void (V) as the return type.
public static IntPtr NewObject(IntPtr clazz, IntPtr methodID, jvalue[] args)
{
return NewObject(clazz, methodID, new Span<jvalue>(args));
}
public static IntPtr NewObject(IntPtr clazz, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return NewObjectA(clazz, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe IntPtr NewObjectA(IntPtr clazz, IntPtr methodID, jvalue* args);
// Returns the class of an object.
[ThreadSafe]
public static extern IntPtr GetObjectClass(IntPtr obj);
// Tests whether an object is an instance of a class.
[ThreadSafe]
public static extern bool IsInstanceOf(IntPtr obj, IntPtr clazz);
// Returns the method ID for an instance (nonstatic) method of a class or interface.
[ThreadSafe]
public static extern IntPtr GetMethodID(IntPtr clazz, string name, string sig);
// Returns the field ID for an instance (nonstatic) field of a class.
[ThreadSafe]
public static extern IntPtr GetFieldID(IntPtr clazz, string name, string sig);
// Returns the method ID for a static method of a class.
[ThreadSafe]
public static extern IntPtr GetStaticMethodID(IntPtr clazz, string name, string sig);
// Returns the field ID for a static field of a class.
[ThreadSafe]
public static extern IntPtr GetStaticFieldID(IntPtr clazz, string name, string sig);
public static IntPtr NewString(string chars)
{
return NewStringFromStr(chars);
}
[ThreadSafe]
private static extern IntPtr NewStringFromStr(string chars);
// Constructs a new <tt>java.lang.String</tt> object from an array of Unicode characters.
[ThreadSafe]
public static extern IntPtr NewString(char[] chars);
// Constructs a new <tt>java.lang.String</tt> object from an array of characters in modified UTF-8 encoding.
[ThreadSafe]
public static extern IntPtr NewStringUTF(string bytes);
[ThreadSafe]
public static extern string GetStringChars(IntPtr str);
// Returns the length (the count of Unicode characters) of a Java string.
[ThreadSafe]
public static extern int GetStringLength(IntPtr str);
// Returns the length in bytes of the modified UTF-8 representation of a string.
[ThreadSafe]
public static extern int GetStringUTFLength(IntPtr str);
// Returns a managed string object representing the string in modified UTF-8 encoding.
[ThreadSafe]
public static extern string GetStringUTFChars(IntPtr str);
//---------------------------------------------
// Calls an instance (nonstatic) Java method defined by <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static string CallStringMethod(IntPtr obj, IntPtr methodID, jvalue[] args)
{
return CallStringMethod(obj, methodID, new Span<jvalue>(args));
}
public static string CallStringMethod(IntPtr obj, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallStringMethodUnsafe(obj, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe string CallStringMethodUnsafe(IntPtr obj, IntPtr methodID, jvalue* args);
// Calls an instance (nonstatic) Java method defined by <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static IntPtr CallObjectMethod(IntPtr obj, IntPtr methodID, jvalue[] args)
{
return CallObjectMethod(obj, methodID, new Span<jvalue>(args));
}
public static IntPtr CallObjectMethod(IntPtr obj, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallObjectMethodUnsafe(obj, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe IntPtr CallObjectMethodUnsafe(IntPtr obj, IntPtr methodID, jvalue* args);
// Calls an instance (nonstatic) Java method defined by <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static Int32 CallIntMethod(IntPtr obj, IntPtr methodID, jvalue[] args)
{
return CallIntMethod(obj, methodID, new Span<jvalue>(args));
}
public static Int32 CallIntMethod(IntPtr obj, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallIntMethodUnsafe(obj, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe Int32 CallIntMethodUnsafe(IntPtr obj, IntPtr methodID, jvalue* args);
// Calls an instance (nonstatic) Java method defined by <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static bool CallBooleanMethod(IntPtr obj, IntPtr methodID, jvalue[] args)
{
return CallBooleanMethod(obj, methodID, new Span<jvalue>(args));
}
public static bool CallBooleanMethod(IntPtr obj, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallBooleanMethodUnsafe(obj, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe bool CallBooleanMethodUnsafe(IntPtr obj, IntPtr methodID, jvalue* args);
// Calls an instance (nonstatic) Java method defined by <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static Int16 CallShortMethod(IntPtr obj, IntPtr methodID, jvalue[] args)
{
return CallShortMethod(obj, methodID, new Span<jvalue>(args));
}
public static Int16 CallShortMethod(IntPtr obj, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallShortMethodUnsafe(obj, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe Int16 CallShortMethodUnsafe(IntPtr obj, IntPtr methodID, jvalue* args);
[Obsolete("AndroidJNI.CallByteMethod is obsolete. Use AndroidJNI.CallSByteMethod method instead")]
public static Byte CallByteMethod(IntPtr obj, IntPtr methodID, jvalue[] args)
{
return (Byte)CallSByteMethod(obj, methodID, args);
}
// Calls an instance (nonstatic) Java method defined by <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static SByte CallSByteMethod(IntPtr obj, IntPtr methodID, jvalue[] args)
{
return CallSByteMethod(obj, methodID, new Span<jvalue>(args));
}
public static SByte CallSByteMethod(IntPtr obj, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallSByteMethodUnsafe(obj, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe SByte CallSByteMethodUnsafe(IntPtr obj, IntPtr methodID, jvalue* args);
// Calls an instance (nonstatic) Java method defined by <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static Char CallCharMethod(IntPtr obj, IntPtr methodID, jvalue[] args)
{
return CallCharMethod(obj, methodID, new Span<jvalue>(args));
}
public static Char CallCharMethod(IntPtr obj, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallCharMethodUnsafe(obj, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe Char CallCharMethodUnsafe(IntPtr obj, IntPtr methodID, jvalue* args);
// Calls an instance (nonstatic) Java method defined by <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static float CallFloatMethod(IntPtr obj, IntPtr methodID, jvalue[] args)
{
return CallFloatMethod(obj, methodID, new Span<jvalue>(args));
}
public static float CallFloatMethod(IntPtr obj, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallFloatMethodUnsafe(obj, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe float CallFloatMethodUnsafe(IntPtr obj, IntPtr methodID, jvalue* args);
// Calls an instance (nonstatic) Java method defined by <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static double CallDoubleMethod(IntPtr obj, IntPtr methodID, jvalue[] args)
{
return CallDoubleMethod(obj, methodID, new Span<jvalue>(args));
}
public static double CallDoubleMethod(IntPtr obj, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallDoubleMethodUnsafe(obj, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe double CallDoubleMethodUnsafe(IntPtr obj, IntPtr methodID, jvalue* args);
// Calls an instance (nonstatic) Java method defined by <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static Int64 CallLongMethod(IntPtr obj, IntPtr methodID, jvalue[] args)
{
return CallLongMethod(obj, methodID, new Span<jvalue>(args));
}
public static Int64 CallLongMethod(IntPtr obj, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallLongMethodUnsafe(obj, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe Int64 CallLongMethodUnsafe(IntPtr obj, IntPtr methodID, jvalue* args);
// Calls an instance (nonstatic) Java method defined by <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static void CallVoidMethod(IntPtr obj, IntPtr methodID, jvalue[] args)
{
CallVoidMethod(obj, methodID, new Span<jvalue>(args));
}
public static void CallVoidMethod(IntPtr obj, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
CallVoidMethodUnsafe(obj, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe void CallVoidMethodUnsafe(IntPtr obj, IntPtr methodID, jvalue* args);
//---------------------------------------------
// This function returns the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern string GetStringField(IntPtr obj, IntPtr fieldID);
// This function returns the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern IntPtr GetObjectField(IntPtr obj, IntPtr fieldID);
// This function returns the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern bool GetBooleanField(IntPtr obj, IntPtr fieldID);
[Obsolete("AndroidJNI.GetByteField is obsolete. Use AndroidJNI.GetSByteField method instead")]
public static Byte GetByteField(IntPtr obj, IntPtr fieldID)
{
return (Byte)GetSByteField(obj, fieldID);
}
// This function returns the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern SByte GetSByteField(IntPtr obj, IntPtr fieldID);
// This function returns the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern Char GetCharField(IntPtr obj, IntPtr fieldID);
// This function returns the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern Int16 GetShortField(IntPtr obj, IntPtr fieldID);
// This function returns the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern Int32 GetIntField(IntPtr obj, IntPtr fieldID);
// This function returns the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern Int64 GetLongField(IntPtr obj, IntPtr fieldID);
// This function returns the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern float GetFloatField(IntPtr obj, IntPtr fieldID);
// This function returns the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern double GetDoubleField(IntPtr obj, IntPtr fieldID);
//---------------------------------------------
// This function sets the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern void SetStringField(IntPtr obj, IntPtr fieldID, string val);
// This function sets the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern void SetObjectField(IntPtr obj, IntPtr fieldID, IntPtr val);
// This function sets the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern void SetBooleanField(IntPtr obj, IntPtr fieldID, bool val);
[Obsolete("AndroidJNI.SetByteField is obsolete. Use AndroidJNI.SetSByteField method instead")]
public static void SetByteField(IntPtr obj, IntPtr fieldID, Byte val)
{
SetSByteField(obj, fieldID, (SByte)val);
}
// This function sets the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern void SetSByteField(IntPtr obj, IntPtr fieldID, SByte val);
// This function sets the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern void SetCharField(IntPtr obj, IntPtr fieldID, Char val);
// This function sets the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern void SetShortField(IntPtr obj, IntPtr fieldID, Int16 val);
// This function sets the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern void SetIntField(IntPtr obj, IntPtr fieldID, Int32 val);
// This function sets the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern void SetLongField(IntPtr obj, IntPtr fieldID, Int64 val);
// This function sets the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern void SetFloatField(IntPtr obj, IntPtr fieldID, float val);
// This function sets the value of an instance (nonstatic) field of an object.
[ThreadSafe]
public static extern void SetDoubleField(IntPtr obj, IntPtr fieldID, double val);
//---------------------------------------------
// Invokes a static method on a Java object, according to the specified <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static string CallStaticStringMethod(IntPtr clazz, IntPtr methodID, jvalue[] args)
{
return CallStaticStringMethod(clazz, methodID, new Span<jvalue>(args));
}
public static string CallStaticStringMethod(IntPtr clazz, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallStaticStringMethodUnsafe(clazz, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe string CallStaticStringMethodUnsafe(IntPtr clazz, IntPtr methodID, jvalue* args);
// Invokes a static method on a Java object, according to the specified <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static IntPtr CallStaticObjectMethod(IntPtr clazz, IntPtr methodID, jvalue[] args)
{
return CallStaticObjectMethod(clazz, methodID, new Span<jvalue>(args));
}
public static IntPtr CallStaticObjectMethod(IntPtr clazz, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallStaticObjectMethodUnsafe(clazz, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe IntPtr CallStaticObjectMethodUnsafe(IntPtr clazz, IntPtr methodID, jvalue* args);
// Invokes a static method on a Java object, according to the specified <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static Int32 CallStaticIntMethod(IntPtr clazz, IntPtr methodID, jvalue[] args)
{
return CallStaticIntMethod(clazz, methodID, new Span<jvalue>(args));
}
public static Int32 CallStaticIntMethod(IntPtr clazz, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallStaticIntMethodUnsafe(clazz, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe Int32 CallStaticIntMethodUnsafe(IntPtr clazz, IntPtr methodID, jvalue* args);
// Invokes a static method on a Java object, according to the specified <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static bool CallStaticBooleanMethod(IntPtr clazz, IntPtr methodID, jvalue[] args)
{
return CallStaticBooleanMethod(clazz, methodID, new Span<jvalue>(args));
}
public static bool CallStaticBooleanMethod(IntPtr clazz, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallStaticBooleanMethodUnsafe(clazz, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe bool CallStaticBooleanMethodUnsafe(IntPtr clazz, IntPtr methodID, jvalue* args);
// Invokes a static method on a Java object, according to the specified <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static Int16 CallStaticShortMethod(IntPtr clazz, IntPtr methodID, jvalue[] args)
{
return CallStaticShortMethod(clazz, methodID, new Span<jvalue>(args));
}
public static Int16 CallStaticShortMethod(IntPtr clazz, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallStaticShortMethodUnsafe(clazz, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe Int16 CallStaticShortMethodUnsafe(IntPtr clazz, IntPtr methodID, jvalue* args);
// Invokes a static method on a Java object, according to the specified <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
[Obsolete("AndroidJNI.CallStaticByteMethod is obsolete. Use AndroidJNI.CallStaticSByteMethod method instead")]
public static Byte CallStaticByteMethod(IntPtr clazz, IntPtr methodID, jvalue[] args)
{
return (Byte)CallStaticSByteMethod(clazz, methodID, args);
}
public static SByte CallStaticSByteMethod(IntPtr clazz, IntPtr methodID, jvalue[] args)
{
return CallStaticSByteMethod(clazz, methodID, new Span<jvalue>(args));
}
public static SByte CallStaticSByteMethod(IntPtr clazz, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallStaticSByteMethodUnsafe(clazz, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe SByte CallStaticSByteMethodUnsafe(IntPtr clazz, IntPtr methodID, jvalue* args);
// Invokes a static method on a Java object, according to the specified <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static Char CallStaticCharMethod(IntPtr clazz, IntPtr methodID, jvalue[] args)
{
return CallStaticCharMethod(clazz, methodID, new Span<jvalue>(args));
}
public static Char CallStaticCharMethod(IntPtr clazz, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallStaticCharMethodUnsafe(clazz, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe Char CallStaticCharMethodUnsafe(IntPtr clazz, IntPtr methodID, jvalue* args);
// Invokes a static method on a Java object, according to the specified <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static float CallStaticFloatMethod(IntPtr clazz, IntPtr methodID, jvalue[] args)
{
return CallStaticFloatMethod(clazz, methodID, new Span<jvalue>(args));
}
public static float CallStaticFloatMethod(IntPtr clazz, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallStaticFloatMethodUnsafe(clazz, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe float CallStaticFloatMethodUnsafe(IntPtr clazz, IntPtr methodID, jvalue* args);
// Invokes a static method on a Java object, according to the specified <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static double CallStaticDoubleMethod(IntPtr clazz, IntPtr methodID, jvalue[] args)
{
return CallStaticDoubleMethod(clazz, methodID, new Span<jvalue>(args));
}
public static double CallStaticDoubleMethod(IntPtr clazz, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallStaticDoubleMethodUnsafe(clazz, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe double CallStaticDoubleMethodUnsafe(IntPtr clazz, IntPtr methodID, jvalue* args);
// Invokes a static method on a Java object, according to the specified <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static Int64 CallStaticLongMethod(IntPtr clazz, IntPtr methodID, jvalue[] args)
{
return CallStaticLongMethod(clazz, methodID, new Span<jvalue>(args));
}
public static Int64 CallStaticLongMethod(IntPtr clazz, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
return CallStaticLongMethodUnsafe(clazz, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe Int64 CallStaticLongMethodUnsafe(IntPtr clazz, IntPtr methodID, jvalue* args);
// Invokes a static method on a Java object, according to the specified <tt>methodID</tt>, optionally passing an array of arguments (<tt>args</tt>) to the method.
public static void CallStaticVoidMethod(IntPtr clazz, IntPtr methodID, jvalue[] args)
{
CallStaticVoidMethod(clazz, methodID, new Span<jvalue>(args));
}
public static void CallStaticVoidMethod(IntPtr clazz, IntPtr methodID, Span<jvalue> args)
{
unsafe
{
fixed (jvalue* a = args)
{
CallStaticVoidMethodUnsafe(clazz, methodID, a);
}
}
}
[ThreadSafe]
public static extern unsafe void CallStaticVoidMethodUnsafe(IntPtr clazz, IntPtr methodID, jvalue* args);
//---------------------------------------------
// This function returns the value of a static field of an object.
[ThreadSafe]
public static extern string GetStaticStringField(IntPtr clazz, IntPtr fieldID);
// This function returns the value of a static field of an object.
[ThreadSafe]
public static extern IntPtr GetStaticObjectField(IntPtr clazz, IntPtr fieldID);
// This function returns the value of a static field of an object.
[ThreadSafe]
public static extern bool GetStaticBooleanField(IntPtr clazz, IntPtr fieldID);
[Obsolete("AndroidJNI.GetStaticByteField is obsolete. Use AndroidJNI.GetStaticSByteField method instead")]