types.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. #ifndef TYPES_H
  3. #define TYPES_H
  4. #include "os.h"
  5. #include "inline_keywords.h" /* For H_INLINE */
  6. #include <stddef.h>
  7. #include <stdint.h>
  8. #include <stdbool.h>
  9. /* Some generic, cross-platform types. */
  10. #ifdef RobotGo_64
  11. typedef int64_t intptr;
  12. typedef uint64_t uintptr;
  13. #else
  14. typedef int32_t intptr;
  15. typedef uint32_t uintptr; // Unsigned pointer integer
  16. #endif
  17. struct _MMPointInt32 {
  18. int32_t x;
  19. int32_t y;
  20. };
  21. typedef struct _MMPointInt32 MMPointInt32;
  22. struct _MMSizeInt32 {
  23. int32_t w;
  24. int32_t h;
  25. };
  26. typedef struct _MMSizeInt32 MMSizeInt32;
  27. struct _MMRectInt32 {
  28. MMPointInt32 origin;
  29. MMSizeInt32 size;
  30. };
  31. typedef struct _MMRectInt32 MMRectInt32;
  32. H_INLINE MMPointInt32 MMPointInt32Make(int32_t x, int32_t y) {
  33. MMPointInt32 point;
  34. point.x = x;
  35. point.y = y;
  36. return point;
  37. }
  38. H_INLINE MMSizeInt32 MMSizeInt32Make(int32_t w, int32_t h) {
  39. MMSizeInt32 size;
  40. size.w = w;
  41. size.h = h;
  42. return size;
  43. }
  44. H_INLINE MMRectInt32 MMRectInt32Make(int32_t x, int32_t y, int32_t w, int32_t h) {
  45. MMRectInt32 rect;
  46. rect.origin = MMPointInt32Make(x, y);
  47. rect.size = MMSizeInt32Make(w, h);
  48. return rect;
  49. }
  50. #define MMPointZero MMPointInt32Make(0, 0)
  51. #if defined(IS_MACOSX)
  52. #define CGPointFromMMPointInt32(p) CGPointMake((CGFloat)(p).x, (CGFloat)(p).y)
  53. #define MMPointInt32FromCGPoint(p) MMPointInt32Make((int32_t)(p).x, (int32_t)(p).y)
  54. #elif defined(IS_WINDOWS)
  55. #define MMPointInt32FromPOINT(p) MMPointInt32Make((int32_t)p.x, (int32_t)p.y)
  56. #endif
  57. #endif /* TYPES_H */