#![cfg_attr(not(test), no_std)]
#![allow(internal_features)]
#![feature(lang_items)]
#![feature(core_intrinsics)]
#![cfg_attr(feature = "panic-handler", feature(panic_info_message))]
#![cfg_attr(feature = "allocator", feature(alloc_error_handler))]
#![cfg_attr(feature = "allocator", feature(allocator_api))]
#![cfg_attr(feature = "allocator", feature(alloc_layout_extra))]
#![feature(error_in_core)]
#![cfg_attr(feature = "try-trait-v2", feature(try_trait_v2))]
#![cfg_attr(feature = "bindings-derive-constparamty",
feature(adt_const_params),
allow(incomplete_features))]
#[allow(unused_imports)]
#[macro_use]
pub extern crate alloc;
pub mod log;
pub mod traits;
mod sys;
pub use sys::*;
pub mod ffi {
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![cfg_attr(test, allow(deref_nullptr))]
#![allow(clippy::all, clippy::pedantic, clippy::nursery)]
#![doc = concat!("\nSDK version: `", env!("PD_SDK_VERSION"), "`\n")]
#![doc = concat!("[current]: https://sdk.play.date/", env!("PD_SDK_VERSION"), "/Inside%20Playdate%20with%20C.html")]
include!(env!("PD_BINDINGS_PATH"));
pub use alloc::ffi::CString;
pub use core::ffi::CStr;
pub use core::str::Utf8Error;
}
#[cfg(feature = "entry-point")]
#[no_mangle]
pub extern "C" fn eventHandlerShim(api: *const ffi::PlaydateAPI,
event: ffi::PDSystemEvent,
arg: u32)
-> core::ffi::c_int {
extern "Rust" {
fn event_handler(api: *const ffi::PlaydateAPI, event: ffi::PDSystemEvent, arg: u32) -> EventLoopCtrl;
}
if let ffi::PDSystemEvent::kEventInit = event {
unsafe { API = api }
}
unsafe { event_handler(api, event, arg) }.into()
}
#[cfg(feature = "entry-point")]
pub use entry_point_ctrl::*;
#[cfg(feature = "entry-point")]
mod entry_point_ctrl {
use core::ffi::c_int;
#[repr(i32)]
pub enum EventLoopCtrl {
Continue = 0,
Stop = 1,
}
impl EventLoopCtrl {
pub const fn into(self) -> c_int { self as _ }
}
impl From<bool> for EventLoopCtrl {
fn from(value: bool) -> Self { if value { Self::Continue } else { Self::Stop } }
}
impl<T, E> From<Result<T, E>> for EventLoopCtrl {
fn from(res: Result<T, E>) -> Self { if res.is_ok() { Self::Continue } else { Self::Stop } }
}
#[cfg(feature = "try-trait-v2")]
mod impl_trait_v2 {
use super::*;
use core::fmt::Display;
use core::ops::FromResidual;
use core::convert::Infallible;
impl<E: Display> FromResidual<Result<Infallible, E>> for EventLoopCtrl {
#[track_caller]
fn from_residual(residual: Result<Infallible, E>) -> Self {
if let Err(err) = residual {
crate::println!("Error: {err}");
Self::Stop
} else {
Self::Continue
}
}
}
}
}
pub mod info {
pub const SDK_VERSION: &str = env!("PD_SDK_VERSION");
}
#[cfg(feature = "eh-personality")]
#[lang = "eh_personality"]
#[cfg(all(not(test), not(doc)))]
extern "C" fn eh_personality() {}
pub mod misc {
#[macro_export]
macro_rules! ll_symbols {
() => {
#[doc(hidden)]
#[no_mangle]
pub extern "C" fn __exidx_start() { unimplemented!() }
#[no_mangle]
#[doc(hidden)]
pub extern "C" fn __exidx_end() { unimplemented!() }
#[doc(hidden)]
#[no_mangle]
#[cfg(not(target_os = "windows"))]
pub extern "C" fn _exit() {}
#[doc(hidden)]
#[no_mangle]
pub extern "C" fn _kill() {}
#[doc(hidden)]
#[no_mangle]
pub extern "C" fn _getpid() -> core::ffi::c_int { 0 }
#[doc(hidden)]
#[no_mangle]
#[cfg(not(target_os = "macos"))]
pub extern "C" fn _sbrk() {}
};
}
}
#[cfg(target_os = "macos")]
#[link(name = "System")]
extern "C" {}
#[cfg(all(target_os = "windows", target_feature = "crt-static"))]
#[link(name = "libcmt")]
extern "C" {}
#[cfg(all(target_os = "windows", not(target_feature = "crt-static")))]
#[link(name = "msvcrt")]
extern "C" {}