-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathil2cpp-api.cpp
More file actions
1198 lines (945 loc) · 27.1 KB
/
il2cpp-api.cpp
File metadata and controls
1198 lines (945 loc) · 27.1 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
#include "il2cpp-api.h"
#include "object-internals.h"
#include "vm/Array.h"
#include "vm/Assembly.h"
#include "vm/Class.h"
#include "vm/Domain.h"
#include "vm/Environment.h"
#include "vm/Exception.h"
#include "vm/Field.h"
#include "vm/GC.h"
#include "vm/Image.h"
#include "vm/InternalCalls.h"
#include "vm/Liveness.h"
#include "vm/MemoryInformation.h"
#include "vm/Method.h"
#include "vm/Monitor.h"
#include "vm/Object.h"
#include "vm/PlatformInvoke.h"
#include "vm/Profiler.h"
#include "vm/Property.h"
#include "vm/Reflection.h"
#include "vm/Runtime.h"
#include "vm/StackTrace.h"
#include "vm/String.h"
#include "vm/Thread.h"
#include "vm/ThreadPool.h"
#include "vm/Type.h"
#include "utils/Memory.h"
#if IL2CPP_DEBUGGER_ENABLED
#include "il2cpp-debugger.h"
#include "vm/Debug.h"
#endif
#include "gc/GCHandle.h"
#include <cassert>
#include <locale.h>
#include <fstream>
using namespace il2cpp::vm;
using il2cpp::utils::Memory;
using namespace il2cpp::gc;
#if IL2CPP_API_DYNAMIC_NO_DLSYM
#include <map>
struct SymbolCompare : public std::binary_function<char*, char*, bool>
{
bool operator ()(const char* lhs, const char* rhs) const
{
return strcmp(lhs, rhs) < 0;
}
};
typedef std::map<const char*, void*, SymbolCompare> SymbolTable;
static SymbolTable s_SymbolTable;
static void RegisterAPIFunction(const char* name, void* symbol)
{
s_SymbolTable.insert(std::make_pair(name, symbol));
}
void il2cpp_api_register_symbols(void)
{
#define DO_API(r,n,p) RegisterAPIFunction(#n, (void*)n);
#include "il2cpp-api-functions.h"
#undef DO_API
}
void* il2cpp_api_lookup_symbol(const char* name)
{
SymbolTable::iterator it = s_SymbolTable.find(name);
if (it != s_SymbolTable.end())
{
return it->second;
}
return NULL;
}
#endif // IL2CPP_API_DYNAMIC_NO_DLSYM
void il2cpp_init (const char* domain_name)
{
// Use environment's default locale
setlocale (LC_ALL, "");
#if IL2CPP_DEBUGGER_ENABLED
if (!il2cpp_debugger_agent_is_initialized())
il2cpp_debugger_agent_init ();
#endif
// NOTE(gab): the runtime_version needs to change once we
// will support multiple runtimes.
// For now we default to the one used by unity and don't
// allow the callers to change it.
Runtime::Init(domain_name, "v2.0.50727");
#if IL2CPP_DEBUGGER_ENABLED
il2cpp_debugger_notify_vm_start ();
#endif
}
void il2cpp_shutdown ()
{
#if IL2CPP_DEBUGGER_ENABLED
il2cpp_debugger_notify_vm_death ();
#endif
Runtime::Shutdown ();
#if IL2CPP_DEBUGGER_ENABLED
il2cpp_debugger_agent_dispose ();
#endif
}
void il2cpp_set_config_dir (const char *config_path)
{
il2cpp::vm::Runtime::SetConfigDir (config_path);
}
void il2cpp_set_data_dir(const char *data_path)
{
il2cpp::vm::Runtime::SetDataDir(data_path);
}
void il2cpp_set_commandline_arguments(int argc, const char* argv[], const char* basedir)
{
il2cpp::vm::Environment::SetMainArgs((char**)argv, argc);
}
void il2cpp_set_memory_callbacks (Il2CppMemoryCallbacks* callbacks)
{
Memory::SetMemoryCallbacks (callbacks);
}
Il2CppImage* il2cpp_get_corlib ()
{
return Image::GetCorlib ();
}
void il2cpp_add_internal_call(const char* name, methodPointerType method)
{
return InternalCalls::Add (name, method);
}
methodPointerType il2cpp_resolve_icall(const char* name)
{
return InternalCalls::Resolve (name);
}
void* il2cpp_alloc(size_t size)
{
return IL2CPP_MALLOC (size);
}
void il2cpp_free(void* ptr)
{
IL2CPP_FREE (ptr);
}
// array
TypeInfo *il2cpp_array_class_get (TypeInfo *element_class, uint32_t rank)
{
return Class::GetArrayClass (element_class, rank);
}
uint32_t il2cpp_array_length (Il2CppArray* array)
{
return Array::GetLength (array);
}
uint32_t il2cpp_array_get_byte_length (Il2CppArray *array)
{
return Array::GetByteLength (array);
}
Il2CppArray* il2cpp_array_new (TypeInfo *elementTypeInfo, il2cpp_array_size_t length)
{
return Array::New (elementTypeInfo, length);
}
Il2CppArray* il2cpp_array_new_specific (TypeInfo *arrayTypeInfo, il2cpp_array_size_t length)
{
return Array::NewSpecific (arrayTypeInfo, length);
}
Il2CppArray* il2cpp_array_new_full (TypeInfo *array_class, il2cpp_array_size_t *lengths, il2cpp_array_size_t *lower_bounds)
{
return Array::NewFull (array_class, lengths, lower_bounds);
}
TypeInfo* il2cpp_bounded_array_class_get (TypeInfo *element_class, uint32_t rank, bool bounded)
{
return Class::GetBoundedArrayClass (element_class, rank, bounded);
}
int il2cpp_array_element_size (const TypeInfo* klass)
{
return Array::GetElementSize (klass);
}
// assembly
Il2CppImage* il2cpp_assembly_get_image (const Il2CppAssembly *assembly)
{
return Assembly::GetImage (assembly);
}
// class
const Il2CppType* il2cpp_class_enum_basetype (TypeInfo *klass)
{
return Class::GetEnumBaseType (klass);
}
TypeInfo* il2cpp_class_from_system_type (Il2CppReflectionType *type)
{
return Class::FromSystemType (type);
}
bool il2cpp_class_is_generic (const TypeInfo *klass)
{
return Class::IsGeneric(klass);
}
bool il2cpp_class_is_inflated(const TypeInfo *klass)
{
return Class::IsInflated(klass);
}
bool il2cpp_class_is_assignable_from (TypeInfo *klass, TypeInfo *oklass)
{
return Class::IsAssignableFrom (klass, oklass);
}
bool il2cpp_class_is_subclass_of (TypeInfo *klass, TypeInfo *klassc, bool check_interfaces)
{
return Class::IsSubclassOf (klass, klassc, check_interfaces);
}
bool il2cpp_class_has_parent (TypeInfo *klass, TypeInfo *klassc)
{
return Class::HasParent (klass, klassc);
}
TypeInfo* il2cpp_class_from_il2cpp_type(const Il2CppType* type)
{
return Class::FromIl2CppType (type);
}
TypeInfo* il2cpp_class_from_name (Il2CppImage* image, const char* namespaze, const char *name)
{
return Class::FromName (image, namespaze, name);
}
TypeInfo* il2cpp_class_get_element_class (TypeInfo *klass)
{
return Class::GetElementClass (klass);
}
const EventInfo* il2cpp_class_get_events (TypeInfo *klass, void* *iter)
{
return Class::GetEvents (klass, iter);
}
FieldInfo* il2cpp_class_get_fields (TypeInfo *klass, void* *iter)
{
return Class::GetFields (klass, iter);
}
TypeInfo* il2cpp_class_get_nested_types (TypeInfo *klass, void* *iter)
{
return Class::GetNestedTypes (klass, iter);
}
TypeInfo* il2cpp_class_get_interfaces (TypeInfo *klass, void* *iter)
{
return Class::GetInterfaces (klass, iter);
}
const PropertyInfo* il2cpp_class_get_properties (TypeInfo *klass, void* *iter)
{
return Class::GetProperties (klass, iter);
}
const PropertyInfo* il2cpp_class_get_property_from_name (TypeInfo *klass, const char *name)
{
return Class::GetPropertyFromName (klass, name);
}
FieldInfo* il2cpp_class_get_field_from_name (TypeInfo* klass, const char *name)
{
return Class::GetFieldFromName (klass, name);
}
const MethodInfo* il2cpp_class_get_methods (TypeInfo *klass, void* *iter)
{
return Class::GetMethods (klass, iter);
}
const MethodInfo* il2cpp_class_get_method_from_name (TypeInfo *klass, const char* name, int argsCount)
{
return Class::GetMethodFromName (klass, name, argsCount);
}
const char* il2cpp_class_get_name (TypeInfo *klass)
{
return Class::GetName (klass);
}
const char* il2cpp_class_get_namespace (TypeInfo *klass)
{
return Class::GetNamespace (klass);
}
TypeInfo* il2cpp_class_get_parent (TypeInfo *klass)
{
return Class::GetParent (klass);
}
TypeInfo* il2cpp_class_get_declaring_type (TypeInfo* klass)
{
return Class::GetDeclaringType (klass);
}
int32_t il2cpp_class_instance_size (TypeInfo *klass)
{
return Class::GetInstanceSize (klass);
}
size_t il2cpp_class_num_fields(const TypeInfo* klass)
{
return Class::GetNumFields (klass);
}
bool il2cpp_class_is_valuetype(const TypeInfo* klass)
{
return Class::IsValuetype (klass);
}
int32_t il2cpp_class_value_size (TypeInfo *klass, uint32_t *align)
{
return Class::GetValueSize (klass, align);
}
int il2cpp_class_get_flags (const TypeInfo *klass)
{
return Class::GetFlags (klass);
}
bool il2cpp_class_is_abstract (const TypeInfo *klass)
{
return Class::IsAbstract (klass);
}
bool il2cpp_class_is_interface (const TypeInfo *klass)
{
return Class::IsInterface (klass);
}
int il2cpp_class_array_element_size (const TypeInfo *klass)
{
return Class::GetArrayElementSize (klass);
}
TypeInfo* il2cpp_class_from_type (Il2CppType *type)
{
return Class::FromIl2CppType (type);
}
const Il2CppType* il2cpp_class_get_type (TypeInfo *klass)
{
return Class::GetType (klass);
}
bool il2cpp_class_has_attribute (TypeInfo *klass, TypeInfo *attr_class)
{
return Class::HasAttribute (klass, attr_class);
}
bool il2cpp_class_has_references (TypeInfo *klass)
{
return Class::HasReferences (klass);
}
bool il2cpp_class_is_enum (const TypeInfo *klass)
{
return Class::IsEnum (klass);
}
const Il2CppImage* il2cpp_class_get_image (TypeInfo* klass)
{
return Class::GetImage (klass);
}
const char *il2cpp_class_get_assemblyname (const TypeInfo *klass)
{
return Class::GetAssemblyName (klass);
}
// testing only
size_t il2cpp_class_get_bitmap_size (const TypeInfo *klass)
{
return Class::GetBitmapSize (klass);
}
void il2cpp_class_get_bitmap (TypeInfo *klass, size_t* bitmap)
{
size_t dummy = 0;
Class::GetBitmap (klass, bitmap, dummy);
}
// stats
extern Il2CppRuntimeStats il2cpp_runtime_stats;
bool il2cpp_stats_dump_to_file (const char *path)
{
std::fstream fs;
fs.open (path, std::fstream::out | std::fstream::trunc);
fs << "New object count: " << il2cpp_stats_get_value (IL2CPP_STAT_NEW_OBJECT_COUNT) << "\n";
fs << "Method count: " << il2cpp_stats_get_value (IL2CPP_STAT_METHOD_COUNT) << "\n";
fs << "Class static data size: " << il2cpp_stats_get_value (IL2CPP_STAT_CLASS_STATIC_DATA_SIZE) << "\n";
fs << "Inflated method count: " << il2cpp_stats_get_value (IL2CPP_STAT_INFLATED_METHOD_COUNT) << "\n";
fs << "Inflated type count: " << il2cpp_stats_get_value (IL2CPP_STAT_INFLATED_TYPE_COUNT) << "\n";
fs << "Initialized class count: " << il2cpp_stats_get_value (IL2CPP_STAT_INITIALIZED_CLASS_COUNT) << "\n";
fs << "Generic instance count: " << il2cpp_stats_get_value (IL2CPP_STAT_GENERIC_INSTANCE_COUNT) << "\n";
fs << "Generic class count: " << il2cpp_stats_get_value (IL2CPP_STAT_GENERIC_CLASS_COUNT) << "\n";
fs.close ();
return true;
}
uint64_t il2cpp_stats_get_value (Il2CppStat stat)
{
switch ( stat )
{
case IL2CPP_STAT_NEW_OBJECT_COUNT:
return il2cpp_runtime_stats.new_object_count;
case IL2CPP_STAT_INITIALIZED_CLASS_COUNT:
return il2cpp_runtime_stats.initialized_class_count;
/*case IL2CPP_STAT_GENERIC_VTABLE_COUNT:
return il2cpp_runtime_stats.generic_vtable_count;
case IL2CPP_STAT_USED_CLASS_COUNT:
return il2cpp_runtime_stats.used_class_count;*/
case IL2CPP_STAT_METHOD_COUNT:
return il2cpp_runtime_stats.method_count;
/*case IL2CPP_STAT_CLASS_VTABLE_SIZE:
return il2cpp_runtime_stats.class_vtable_size;*/
case IL2CPP_STAT_CLASS_STATIC_DATA_SIZE:
return il2cpp_runtime_stats.class_static_data_size;
case IL2CPP_STAT_GENERIC_INSTANCE_COUNT:
return il2cpp_runtime_stats.generic_instance_count;
case IL2CPP_STAT_GENERIC_CLASS_COUNT:
return il2cpp_runtime_stats.generic_class_count;
case IL2CPP_STAT_INFLATED_METHOD_COUNT:
return il2cpp_runtime_stats.inflated_method_count;
case IL2CPP_STAT_INFLATED_TYPE_COUNT:
return il2cpp_runtime_stats.inflated_type_count;
/*case IL2CPP_STAT_DELEGATE_CREATIONS:
return il2cpp_runtime_stats.delegate_creations;
case IL2CPP_STAT_MINOR_GC_COUNT:
return il2cpp_runtime_stats.minor_gc_count;
case IL2CPP_STAT_MAJOR_GC_COUNT:
return il2cpp_runtime_stats.major_gc_count;
case IL2CPP_STAT_MINOR_GC_TIME_USECS:
return il2cpp_runtime_stats.minor_gc_time_usecs;
case IL2CPP_STAT_MAJOR_GC_TIME_USECS:
return il2cpp_runtime_stats.major_gc_time_usecs;*/
}
return 0;
}
// domain
Il2CppDomain* il2cpp_domain_get ()
{
return Domain::GetCurrent ();
}
const Il2CppAssembly* il2cpp_domain_assembly_open (Il2CppDomain *domain, const char *name)
{
return Assembly::Load (name);
}
const Il2CppAssembly** il2cpp_domain_get_assemblies(const Il2CppDomain* domain, size_t* size)
{
il2cpp::vm::AssemblyVector* assemblies = Assembly::GetAllAssemblies();
*size = assemblies->size();
return &(*assemblies)[0];
}
// exception
void il2cpp_raise_exception(Il2CppException* exc)
{
Exception::Raise (exc);
}
Il2CppException* il2cpp_exception_from_name_msg (Il2CppImage* image, const char *name_space, const char *name, const char *msg)
{
return Exception::FromNameMsg (image, name_space, name, msg);
}
Il2CppException* il2cpp_get_exception_argument_null (const char *arg)
{
return Exception::GetArgumentNullException (arg);
}
void il2cpp_format_exception(const Il2CppException* ex, char* message, int message_size)
{
strncpy(message, Exception::FormatException(ex).c_str(), message_size);
}
void il2cpp_format_stack_trace(const Il2CppException* ex, char* output, int output_size)
{
strncpy(output, Exception::FormatStackTrace(ex).c_str(), output_size);
}
void il2cpp_unhandled_exception(Il2CppException* exc)
{
Runtime::UnhandledException((Il2CppObject*)exc);
}
// field
const char* il2cpp_field_get_name (FieldInfo *field)
{
return Field::GetName (field);
}
int il2cpp_field_get_flags (FieldInfo *field)
{
return Field::GetFlags (field);
}
TypeInfo* il2cpp_field_get_parent (FieldInfo *field)
{
return Field::GetParent (field);
}
size_t il2cpp_field_get_offset (FieldInfo *field)
{
return Field::GetOffset (field);
}
const Il2CppType* il2cpp_field_get_type (FieldInfo *field)
{
return Field::GetType (field);
}
void il2cpp_field_get_value (Il2CppObject *obj, FieldInfo *field, void *value)
{
return Field::GetValue (obj, field, value);
}
Il2CppObject* il2cpp_field_get_value_object (FieldInfo *field, Il2CppObject *obj)
{
return Field::GetValueObject (field, obj);
}
bool il2cpp_field_has_attribute (FieldInfo *field, TypeInfo *attr_class)
{
return Field::HasAttribute (field, attr_class);
}
void il2cpp_field_set_value (Il2CppObject *obj, FieldInfo *field, void *value)
{
Field::SetValue (obj, field, value);
}
void il2cpp_field_static_get_value (FieldInfo *field, void *value)
{
Field::StaticGetValue (field, value);
}
void il2cpp_field_static_set_value (FieldInfo *field, void *value)
{
Field::StaticSetValue (field, value);
}
// gc
void il2cpp_gc_collect(int maxGenerations)
{
GC::Collect(maxGenerations);
}
int64_t il2cpp_gc_get_used_size ()
{
return GC::GetUsedHeapSize();
}
int64_t il2cpp_gc_get_heap_size ()
{
return GC::GetAllocatedHeapSize();
}
// gchandle
uint32_t il2cpp_gchandle_new (Il2CppObject *obj, bool pinned)
{
return GCHandle::New (obj, pinned);
}
uint32_t il2cpp_gchandle_new_weakref (Il2CppObject *obj, bool track_resurrection)
{
return GCHandle::NewWeakref (obj, track_resurrection);
}
Il2CppObject* il2cpp_gchandle_get_target (uint32_t gchandle)
{
return GCHandle::GetTarget (gchandle);
}
void il2cpp_gchandle_free (uint32_t gchandle)
{
GCHandle::Free (gchandle);
}
// liveness
void* il2cpp_unity_liveness_calculation_begin (TypeInfo* filter, int max_object_count, register_object_callback callback, void* userdata, WorldChangedCallback onWorldStarted, WorldChangedCallback onWorldStopped)
{
return Liveness::Begin (filter, max_object_count, callback, userdata, onWorldStarted, onWorldStopped);
}
void il2cpp_unity_liveness_calculation_end (void* state)
{
Liveness::End (state);
}
void il2cpp_unity_liveness_calculation_from_root (Il2CppObject* root, void* state)
{
Liveness::FromRoot (root, state);
}
void il2cpp_unity_liveness_calculation_from_statics (void* state)
{
Liveness::FromStatics (state);
}
// method
const Il2CppType* il2cpp_method_get_return_type (const MethodInfo* method)
{
return Method::GetReturnType (method);
}
Il2CppReflectionMethod* il2cpp_method_get_object (const MethodInfo *method, TypeInfo *refclass)
{
return Reflection::GetMethodObject (method, refclass);
}
const char* il2cpp_method_get_name (const MethodInfo *method)
{
return Method::GetName (method);
}
bool il2cpp_method_is_generic (const MethodInfo *method)
{
return Method::IsGeneric (method);
}
bool il2cpp_method_is_inflated (const MethodInfo *method)
{
return Method::IsInflated (method);
}
bool il2cpp_method_is_instance (const MethodInfo *method)
{
return Method::IsInstance (method);
}
uint32_t il2cpp_method_get_param_count (const MethodInfo *method)
{
return Method::GetParamCount (method);
}
const Il2CppType* il2cpp_method_get_param (const MethodInfo *method, uint32_t index)
{
return Method::GetParam (method, index);
}
TypeInfo* il2cpp_method_get_class (const MethodInfo *method)
{
return Method::GetClass (method);
}
bool il2cpp_method_has_attribute (const MethodInfo *method, TypeInfo *attr_class)
{
return Method::HasAttribute (method, attr_class);
}
TypeInfo* il2cpp_method_get_declaring_type (const MethodInfo* method)
{
return Method::GetDeclaringType (method);
}
uint32_t il2cpp_method_get_flags (const MethodInfo *method, uint32_t *iflags)
{
if(iflags != 0)
*iflags = Method::GetImplementationFlags (method);
return Method::GetFlags (method);
}
uint32_t il2cpp_method_get_token (const MethodInfo *method)
{
return Method::GetToken (method);
}
const char *il2cpp_method_get_param_name (const MethodInfo *method, uint32_t index)
{
return Method::GetParamName (method, index);
}
// profiler
void il2cpp_profiler_install (Il2CppProfiler *prof, Il2CppProfileFunc shutdown_callback)
{
Profiler::Install (prof, shutdown_callback);
}
void il2cpp_profiler_set_events (Il2CppProfileFlags events)
{
Profiler::SetEvents (events);
}
void il2cpp_profiler_install_enter_leave (Il2CppProfileMethodFunc enter, Il2CppProfileMethodFunc fleave)
{
Profiler::InstallEnterLeave (enter, fleave);
}
void il2cpp_profiler_install_allocation (Il2CppProfileAllocFunc callback)
{
Profiler::InstallAllocation (callback);
}
void il2cpp_profiler_install_gc (Il2CppProfileGCFunc callback, Il2CppProfileGCResizeFunc heap_resize_callback)
{
Profiler::InstallGC (callback, heap_resize_callback);
}
// property
const char* il2cpp_property_get_name (PropertyInfo *prop)
{
return Property::GetName (prop);
}
const MethodInfo* il2cpp_property_get_get_method (PropertyInfo *prop)
{
return Property::GetGetMethod (prop);
}
const MethodInfo* il2cpp_property_get_set_method (PropertyInfo *prop)
{
return Property::GetSetMethod (prop);
}
TypeInfo* il2cpp_property_get_parent (PropertyInfo *prop)
{
return Property::GetParent (prop);
}
uint32_t il2cpp_property_get_flags (PropertyInfo *prop)
{
return Property::GetFlags (prop);
}
// object
TypeInfo* il2cpp_object_get_class(Il2CppObject* obj)
{
return Object::GetClass (obj);
}
uint32_t il2cpp_object_get_size(Il2CppObject* obj)
{
return Object::GetSize (obj);
}
const MethodInfo* il2cpp_object_get_virtual_method (Il2CppObject *obj, const MethodInfo *method)
{
return Object::GetVirtualMethod (obj, method);
}
Il2CppObject* il2cpp_object_new (const TypeInfo *klass)
{
try
{
return Object::New(const_cast<TypeInfo*>(klass));
}
catch (const Il2CppExceptionWrapper&)
{
// If a static constructor throws, that exception will occur here.
// We don't want that to escape across the embedding API.
return NULL;
}
}
void* il2cpp_object_unbox(Il2CppObject* obj)
{
return Object::Unbox (obj);
}
Il2CppObject* il2cpp_value_box (TypeInfo *klass, void* data)
{
return Object::Box (klass, data);
}
// monitor
void il2cpp_monitor_enter (Il2CppObject* obj)
{
Monitor::Enter (obj);
}
bool il2cpp_monitor_try_enter (Il2CppObject* obj, uint32_t timeout)
{
return Monitor::TryEnter (obj, timeout);
}
void il2cpp_monitor_exit (Il2CppObject* obj)
{
Monitor::Exit (obj);
}
void il2cpp_monitor_pulse (Il2CppObject* obj)
{
Monitor::Pulse (obj);
}
void il2cpp_monitor_pulse_all (Il2CppObject* obj)
{
Monitor::PulseAll (obj);
}
void il2cpp_monitor_wait (Il2CppObject* obj)
{
Monitor::Wait (obj);
}
bool il2cpp_monitor_try_wait (Il2CppObject* obj, uint32_t timeout)
{
return Monitor::TryWait (obj, timeout);
}
// runtime
Il2CppObject* il2cpp_runtime_invoke_convert_args (const MethodInfo *method, void *obj, Il2CppObject **params, int paramCount, Il2CppObject **exc)
{
return Runtime::InvokeConvertArgs (method, obj, params, paramCount, exc);
}
Il2CppObject* il2cpp_runtime_invoke (const MethodInfo *method,
void *obj, void **params, Il2CppObject **exc)
{
return Runtime::Invoke (method, obj, params, exc);
}
void il2cpp_runtime_class_init(TypeInfo* klass)
{
return Runtime::ClassInit (klass);
}
void il2cpp_runtime_object_init (Il2CppObject *obj)
{
Runtime::ObjectInit (obj);
}
void il2cpp_runtime_object_init_exception (Il2CppObject *obj, Il2CppObject **exc)
{
Runtime::ObjectInitException (obj, exc);
}
void il2cpp_runtime_unhandled_exception_policy_set (Il2CppRuntimeUnhandledExceptionPolicy value)
{
Runtime::SetUnhandledExceptionPolicy (value);
}
// delegate
Il2CppAsyncResult* il2cpp_delegate_begin_invoke (Il2CppDelegate* delegate, void** params, Il2CppDelegate* asyncCallback, Il2CppObject* state)
{
return ThreadPool::Queue (delegate, params, asyncCallback, state);
}
Il2CppObject* il2cpp_delegate_end_invoke (Il2CppAsyncResult* asyncResult, void **out_args)
{
return ThreadPool::Wait (asyncResult, out_args);
}
// string
int32_t il2cpp_string_length (Il2CppString* str)
{
return String::GetLength (str);
}
uint16_t* il2cpp_string_chars (Il2CppString* str)
{
return String::GetChars (str);
}
// Same as il2cpp_string_new_wrapper, because other normally takes a domain
Il2CppString* il2cpp_string_new(const char* str)
{
return String::New (str);
}
Il2CppString* il2cpp_string_new_wrapper(const char* str)
{
return String::NewWrapper (str);
}
Il2CppString* il2cpp_string_new_utf16 (const uint16_t *text, int32_t len)
{
return String::NewUtf16 (text, len);
}
Il2CppString* il2cpp_string_new_len(const char* str, uint32_t length)
{
return String::NewLen (str, length);
}
Il2CppString* il2cpp_string_intern(Il2CppString* str)
{
return String::Intern(str);
}
Il2CppString* il2cpp_string_is_interned(Il2CppString* str)
{
return String::IsInterned(str);
}
// thread
char *il2cpp_thread_get_name (Il2CppThread *thread, uint32_t *len)
{
return Thread::GetName (len);
}
Il2CppThread *il2cpp_thread_current ()
{
return Thread::Current ();
}
Il2CppThread *il2cpp_thread_attach (Il2CppDomain *domain)
{
return Thread::Attach (domain);
}
void il2cpp_thread_detach (Il2CppThread *thread)
{
Thread::Detach (thread);
}
Il2CppThread **il2cpp_thread_get_all_attached_threads (size_t *size)
{
return Thread::GetAllAttachedThreads (*size);
}
bool il2cpp_is_vm_thread (Il2CppThread *thread)
{
return Thread::IsVmThread (thread);
}
// stacktrace
void il2cpp_current_thread_walk_frame_stack(Il2CppFrameWalkFunc func, void* user_data)
{
StackTrace::WalkFrameStack(func, user_data);
}
void il2cpp_thread_walk_frame_stack (Il2CppThread *thread, Il2CppFrameWalkFunc func, void *user_data)
{
return StackTrace::WalkThreadFrameStack(thread, func, user_data);
}