No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Array.h 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #include <stdint.h>
  3. #include "il2cpp-config.h"
  4. #include "gc/GarbageCollector.h"
  5. struct Il2CppArray;
  6. struct Il2CppObject;
  7. struct Il2CppString;
  8. struct Il2CppClass;
  9. namespace il2cpp
  10. {
  11. namespace vm
  12. {
  13. class LIBIL2CPP_CODEGEN_API Array
  14. {
  15. public:
  16. static Il2CppArray* Clone(Il2CppArray* arr);
  17. static int32_t GetElementSize(const Il2CppClass *klass);
  18. static uint32_t GetLength(Il2CppArray* array);
  19. static uint32_t GetByteLength(Il2CppArray* array);
  20. static Il2CppArray* New(Il2CppClass *elementTypeInfo, il2cpp_array_size_t length);
  21. static Il2CppArray* NewSpecific(Il2CppClass *arrayTypeInfo, il2cpp_array_size_t length);
  22. static Il2CppArray* NewFull(Il2CppClass *array_class, il2cpp_array_size_t *lengths, il2cpp_array_size_t *lower_bounds);
  23. public:
  24. // internal
  25. static Il2CppArray* NewCached(Il2CppClass *elementTypeInfo, il2cpp_array_size_t length)
  26. {
  27. return New(elementTypeInfo, length);
  28. }
  29. static char* GetFirstElementAddress(Il2CppArray *array);
  30. static il2cpp_array_size_t IndexFromIndices(Il2CppArray* thisPtr, int32_t const * indices);
  31. };
  32. } /* namespace vm */
  33. } /* namespace il2cpp */
  34. extern "C"
  35. {
  36. IL2CPP_EXPORT int il2cpp_array_element_size(const Il2CppClass *ac);
  37. }
  38. #define il2cpp_array_setwithsize(array, elementSize, index, value) \
  39. do { \
  40. void*__p = (void*) il2cpp_array_addr_with_size ((array), elementSize, (index)); \
  41. memcpy(__p, &(value), elementSize); \
  42. } while (0)
  43. #define il2cpp_array_setrefwithsize(array, elementSize, index, value) \
  44. do { \
  45. void* __p = (void*) il2cpp_array_addr_with_size ((array), elementSize, (index)); \
  46. memcpy(__p, value, elementSize); \
  47. il2cpp::gc::GarbageCollector::SetWriteBarrier((void**)__p, elementSize); \
  48. } while (0)
  49. #define il2cpp_array_addr(array, type, index) ((type*)(void*) il2cpp_array_addr_with_size (array, sizeof (type), index))
  50. #define il2cpp_array_get(array, type, index) ( *(type*)il2cpp_array_addr ((array), type, (index)) )
  51. #define il2cpp_array_set(array, type, index, value) \
  52. do { \
  53. type *__p = (type *) il2cpp_array_addr ((array), type, (index)); \
  54. *__p = (value); \
  55. } while (0)
  56. #define il2cpp_array_setref(array, index, value) \
  57. do { \
  58. void* *__p = (void* *) il2cpp_array_addr ((array), void*, (index)); \
  59. *__p = (value); \
  60. il2cpp::gc::GarbageCollector::SetWriteBarrier(__p); \
  61. } while (0)