use core::ffi::{CStr, c_char, c_int};
pub use crate::properties::SDL_PropertyType as PropertyType;
#[derive(Clone, Copy)]
pub struct Hint {
pub module: &'static str,
pub name: &'static str,
pub short_name: &'static str,
pub value: *const c_char,
pub doc: Option<&'static str>,
pub available_since: Option<c_int>,
}
unsafe impl Send for Hint {}
unsafe impl Sync for Hint {}
impl Hint {
#[inline(always)]
pub const fn value_cstr(&self) -> &'static CStr {
unsafe { CStr::from_ptr(self.value) }
}
#[inline(always)]
pub const fn value_str(&self) -> &'static str {
match self.value_cstr().to_str() {
Ok(str) => str,
Err(_) => unreachable!(),
}
}
}
#[derive(Clone, Copy)]
pub struct Property {
pub module: &'static str,
pub name: &'static str,
pub short_name: &'static str,
pub value: *const c_char,
pub ty: PropertyType,
pub doc: Option<&'static str>,
pub available_since: Option<c_int>,
}
unsafe impl Send for Property {}
unsafe impl Sync for Property {}
impl Property {
#[inline(always)]
pub const fn value_cstr(&self) -> &'static CStr {
unsafe { CStr::from_ptr(self.value) }
}
#[inline(always)]
pub const fn value_str(&self) -> &'static str {
match self.value_cstr().to_str() {
Ok(str) => str,
Err(_) => unreachable!(),
}
}
}
pub trait GroupMetadata: 'static + Sized {
const GROUP_METADATA: &'static Group;
}
#[non_exhaustive]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum GroupKind {
Enum,
Flags,
Id,
Lock,
}
#[derive(Clone, Copy)]
pub struct Group {
pub kind: GroupKind,
pub module: &'static str,
pub name: &'static str,
pub short_name: &'static str,
pub doc: Option<&'static str>,
pub values: &'static [GroupValue],
pub available_since: Option<c_int>,
}
#[derive(Clone, Copy)]
pub struct GroupValue {
pub name: &'static str,
pub short_name: &'static str,
pub doc: Option<&'static str>,
pub available_since: Option<c_int>,
}
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum StructKind {
Struct,
Union,
}
#[derive(Clone, Copy)]
pub struct Struct {
pub kind: StructKind,
pub module: &'static str,
pub name: &'static str,
pub doc: Option<&'static str>,
pub available_since: Option<c_int>,
pub fields: &'static [Field],
}
#[derive(Clone, Copy)]
pub struct Field {
pub name: &'static str,
pub doc: Option<&'static str>,
pub available_since: Option<c_int>,
pub ty: &'static str,
}
#[cfg(feature = "metadata")]
mod generated;
#[cfg(feature = "metadata")]
#[allow(unused_imports)] pub use generated::*;