1#![no_std]
2#![allow(non_upper_case_globals)]
3#![allow(non_camel_case_types)]
4#![allow(non_snake_case)]
5
6#[cfg(all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")))]
7pub mod ctypes {
8 pub type c_ulong = u64;
9 pub type c_int = i32;
10 pub type c_char = i8;
11 pub type c_uint = u32;
12 pub type c_void = core::ffi::c_void;
13 pub type realloc_size = u64;
14}
15
16#[cfg(all(target_os = "macos", any(target_arch = "aarch64", target_arch = "arm")))]
17pub mod ctypes {
18 pub type c_ulong = u64;
19 pub type c_int = i32;
20 pub type c_char = u8;
21 pub type c_uint = u32;
22 pub type c_void = core::ffi::c_void;
23 pub type realloc_size = u64;
24}
25
26#[cfg(all(
27 not(target_os = "macos"),
28 any(target_arch = "x86", target_arch = "x86_64")
29))]
30pub mod ctypes {
31 pub type c_ulong = u64;
32 pub type c_int = i32;
33 pub type c_char = i8;
34 pub type c_uchar = u8;
35 pub type c_uint = u32;
36 pub type c_ushort = u16;
37 pub type c_short = i16;
38 pub type c_void = core::ffi::c_void;
39 pub type realloc_size = u32;
40}
41
42#[cfg(all(
43 not(target_os = "macos"),
44 any(target_arch = "aarch64", target_arch = "arm")
45))]
46pub mod ctypes {
47 pub type c_ulong = u64;
48 pub type c_int = i32;
49 pub type c_char = u8;
50 pub type c_uchar = u8;
51 pub type c_uint = u32;
52 pub type c_ushort = u16;
53 pub type c_short = i16;
54 pub type c_void = core::ffi::c_void;
55 pub type realloc_size = u32;
56}
57
58#[cfg(all(target_os = "windows", target_feature = "crt-static"))]
59#[link(name = "libcmt")]
60extern "C" {}
61#[cfg(all(target_os = "windows", not(target_feature = "crt-static")))]
62#[link(name = "msvcrt")]
63extern "C" {}
64
65#[cfg(all(
66 not(target_os = "none"),
67 any(target_arch = "x86", target_arch = "x86_64")
68))]
69include!("bindings_x86.rs");
70#[cfg(all(
71 not(target_os = "none"),
72 any(target_arch = "aarch64", target_arch = "arm")
73))]
74include!("bindings_aarch64.rs");
75#[cfg(target_os = "none")]
76include!("bindings_playdate.rs");
77
78impl From<euclid::default::Rect<i32>> for LCDRect {
79 fn from(r: euclid::default::Rect<i32>) -> Self {
80 LCDRect {
81 top: r.max_y(),
82 bottom: r.min_y(),
83 left: r.min_x(),
84 right: r.max_x(),
85 }
86 }
87}
88
89impl From<LCDRect> for euclid::default::Rect<i32> {
90 fn from(r: LCDRect) -> Self {
91 euclid::rect(r.left, r.top, r.right - r.left, r.bottom - r.top)
92 }
93}
94
95impl From<euclid::default::Rect<f32>> for PDRect {
96 fn from(r: euclid::default::Rect<f32>) -> Self {
97 PDRect {
98 x: r.origin.x,
99 y: r.origin.y,
100 width: r.size.width,
101 height: r.size.height,
102 }
103 }
104}
105
106impl From<PDRect> for euclid::default::Rect<f32> {
107 fn from(r: PDRect) -> Self {
108 euclid::rect(r.x, r.y, r.width, r.height)
109 }
110}