暫無描述
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.

GCHandle.h 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. HANDLE_TYPE_MAX
  17. };
  18. const Il2CppGCHandle kEmptyGCHandle = (Il2CppGCHandle)0;
  19. class LIBIL2CPP_CODEGEN_API GCHandle
  20. {
  21. public:
  22. // external
  23. static Il2CppGCHandle New(Il2CppObject *obj, bool pinned);
  24. static utils::Expected<Il2CppGCHandle> NewWeakref(Il2CppObject *obj, bool track_resurrection);
  25. static Il2CppObject* GetTarget(Il2CppGCHandle gchandle);
  26. static GCHandleType GetHandleType(Il2CppGCHandle gcHandle);
  27. static void Free(Il2CppGCHandle gchandle);
  28. public:
  29. //internal
  30. static utils::Expected<Il2CppGCHandle> GetTargetHandle(Il2CppObject * obj, Il2CppGCHandle handle, int32_t type);
  31. typedef void(*WalkGCHandleTargetsCallback)(Il2CppObject* obj, void* context);
  32. static void WalkStrongGCHandleTargets(WalkGCHandleTargetsCallback callback, void* context);
  33. };
  34. } /* gc */
  35. } /* il2cpp */