ObjCRuntime.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include <objc/objc.h>
  3. #include <objc/runtime.h>
  4. #include <objc/message.h>
  5. #define UNITY_OBJC_FORWARD_TO_SUPER(self_, super_, selector, selectorType, ...) \
  6. do \
  7. { \
  8. struct objc_super super = { .receiver = self_, .super_class = super_ }; \
  9. selectorType msgSendFunc = (selectorType)objc_msgSendSuper; \
  10. msgSendFunc(&super, selector, __VA_ARGS__); \
  11. } \
  12. while(0)
  13. #define UNITY_OBJC_CALL_ON_SELF(self_, selector, selectorType, ...) \
  14. do \
  15. { \
  16. selectorType msgSendFunc = (selectorType)objc_msgSend; \
  17. msgSendFunc(self_, selector, __VA_ARGS__); \
  18. } \
  19. while(0)
  20. // method type encoding for methods we override
  21. // to get this you need to do: method_getTypeEncoding(class_getInstanceMethod(class, sel)) or method_getTypeEncoding(class_getClassMethod(class, sel))
  22. #define UIView_LayerClass_Enc "#8@0:4"
  23. #define UIViewController_viewWillTransitionToSize_Enc "v40@0:8{CGSize=dd}16@32"
  24. #define UIViewController_willRotateToInterfaceOrientation_Enc "v32@0:8q16d24"
  25. #define UIViewController_didRotateFromInterfaceOrientation_Enc "v24@0:8q16"
  26. #define UIViewController_supportedInterfaceOrientations_Enc "Q16@0:8"
  27. #define UIViewController_prefersStatusBarHidden_Enc "B16@0:8"
  28. #define CADisplayLink_setPreferredFramesPerSecond_Enc "v24@0:8q16"
  29. #define UIScreen_nativeScale_Enc "d16@0:8"
  30. #define UIScreen_maximumFramesPerSecond_Enc "q16@0:8"
  31. #define MTLDevice_supportsTextureSampleCount_Enc "c24@0:8Q16"
  32. #define MTLTextureDescriptor_setUsage_Enc "v24@0:8Q16"
  33. #define MTLTextureDescriptor_usage_Enc "Q16@0:8"
  34. #define AVPlayerViewController_setAllowsPictureInPicturePlayback_Enc "v20@0:8B16"
  35. #define UIView_safeAreaInsets_Enc "{UIEdgeInsets=dddd}16@0:8"