GCHandle.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma once
  2. #include "utils/Expected.h"
  3. #include "utils/Il2CppError.h"
  4. #include <stdint.h>
  5. struct Il2CppObject;
  6. namespace il2cpp
  7. {
  8. namespace gc
  9. {
  10. enum GCHandleType
  11. {
  12. HANDLE_WEAK,
  13. HANDLE_WEAK_TRACK,
  14. HANDLE_NORMAL,
  15. HANDLE_PINNED
  16. };
  17. class LIBIL2CPP_CODEGEN_API GCHandle
  18. {
  19. public:
  20. // external
  21. static uint32_t New(Il2CppObject *obj, bool pinned);
  22. static utils::Expected<uint32_t> NewWeakref(Il2CppObject *obj, bool track_resurrection);
  23. static Il2CppObject* GetTarget(uint32_t gchandle);
  24. static GCHandleType GetHandleType(uint32_t gcHandle);
  25. static void Free(uint32_t gchandle);
  26. public:
  27. //internal
  28. static utils::Expected<uint32_t> GetTargetHandle(Il2CppObject * obj, int32_t handle, int32_t type);
  29. typedef void(*WalkGCHandleTargetsCallback)(Il2CppObject* obj, void* context);
  30. static void WalkStrongGCHandleTargets(WalkGCHandleTargetsCallback callback, void* context);
  31. };
  32. } /* gc */
  33. } /* il2cpp */