robotgo/base/types.h

69 lines
1.5 KiB
C
Raw Permalink Normal View History

2016-10-06 10:41:37 +00:00
#pragma once
#ifndef TYPES_H
#define TYPES_H
#include "os.h"
#include "inline_keywords.h" /* For H_INLINE */
#include <stddef.h>
2019-11-30 14:44:40 +00:00
#include <stdint.h>
2022-02-03 11:14:44 +00:00
#include <stdbool.h>
2016-10-06 10:41:37 +00:00
/* Some generic, cross-platform types. */
2022-01-22 16:53:04 +00:00
#ifdef RobotGo_64
typedef int64_t intptr;
typedef uint64_t uintptr;
#else
typedef int32_t intptr;
typedef uint32_t uintptr; // Unsigned pointer integer
#endif
2019-12-01 12:46:04 +00:00
struct _MMPointInt32 {
2019-11-30 14:44:40 +00:00
int32_t x;
int32_t y;
};
2019-12-01 12:46:04 +00:00
typedef struct _MMPointInt32 MMPointInt32;
2019-11-30 14:44:40 +00:00
2019-12-01 12:46:04 +00:00
struct _MMSizeInt32 {
2019-11-30 14:44:40 +00:00
int32_t w;
int32_t h;
};
2019-12-01 12:46:04 +00:00
typedef struct _MMSizeInt32 MMSizeInt32;
2019-11-30 14:44:40 +00:00
2019-12-01 12:46:04 +00:00
struct _MMRectInt32 {
MMPointInt32 origin;
MMSizeInt32 size;
2019-11-30 14:44:40 +00:00
};
2019-12-01 12:46:04 +00:00
typedef struct _MMRectInt32 MMRectInt32;
2019-11-30 14:44:40 +00:00
H_INLINE MMPointInt32 MMPointInt32Make(int32_t x, int32_t y) {
2019-12-01 12:46:04 +00:00
MMPointInt32 point;
2019-11-30 14:44:40 +00:00
point.x = x;
point.y = y;
return point;
}
H_INLINE MMSizeInt32 MMSizeInt32Make(int32_t w, int32_t h) {
2019-12-01 12:46:04 +00:00
MMSizeInt32 size;
2019-11-30 14:44:40 +00:00
size.w = w;
size.h = h;
return size;
}
H_INLINE MMRectInt32 MMRectInt32Make(int32_t x, int32_t y, int32_t w, int32_t h) {
2019-12-01 12:46:04 +00:00
MMRectInt32 rect;
rect.origin = MMPointInt32Make(x, y);
rect.size = MMSizeInt32Make(w, h);
2019-11-30 14:44:40 +00:00
return rect;
}
2022-02-03 09:41:46 +00:00
#define MMPointZero MMPointInt32Make(0, 0)
2016-10-06 10:41:37 +00:00
#if defined(IS_MACOSX)
#define CGPointFromMMPointInt32(p) CGPointMake((CGFloat)(p).x, (CGFloat)(p).y)
#define MMPointInt32FromCGPoint(p) MMPointInt32Make((int32_t)(p).x, (int32_t)(p).y)
2016-10-06 10:41:37 +00:00
#elif defined(IS_WINDOWS)
#define MMPointInt32FromPOINT(p) MMPointInt32Make((int32_t)p.x, (int32_t)p.y)
2016-10-06 10:41:37 +00:00
#endif
#endif /* TYPES_H */