#![no_std] #![feature(trace_macros)] #![feature(proc_macro_hygiene)]
extern crate macros as lvgl_macros;
#[cfg(feature = "mynewt_os")] pub use mynewt;
#[allow(unused_imports)] pub mod core;
#[allow(unused_imports)] pub mod draw;
#[allow(unused_imports)] pub mod font;
#[allow(unused_imports)] pub mod hal;
#[allow(unused_imports)] pub mod misc;
#[allow(unused_imports)] pub mod themes;
#[allow(unused_imports)] pub mod widgets;
#[macro_use] pub mod util;
#[cfg(feature = "riot_os")] pub mod console;
#[cfg(feature = "riot_os")] pub mod result {
pub type LvglResult<T> = ::core::result::Result<T, LvglError>;
#[repr(i32)]
#[derive(PartialEq)]
#[allow(non_camel_case_types)] pub enum LvglError {
SYS_EOK = 0,
SYS_EUNKNOWN = 1,
}
impl From<LvglError> for i32 {
fn from(err: LvglError) -> Self {
err as i32
}
}
impl From<i32> for LvglError {
fn from(num: i32) -> Self {
unsafe {
::core::mem::transmute::
<i32, LvglError>
(num)
}
}
}
impl From<()> for LvglError {
fn from(_: ()) -> Self {
LvglError::SYS_EUNKNOWN
}
}
impl core::fmt::Debug for LvglError {
fn fmt(&self, _fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
Ok(())
}
}
}
#[cfg(feature = "riot_os")] #[derive(Clone, Copy)] pub struct Strn {
pub rep: StrnRep
}
#[cfg(feature = "riot_os")] #[derive(Clone, Copy)] #[repr(u8)]
pub enum StrnRep {
ByteStr(&'static [u8]),
CStr(*const u8),
}
#[cfg(feature = "riot_os")] impl Strn {
pub fn new(bs: &'static [u8]) -> Strn {
assert_eq!(bs.last(), Some(&0u8), "no null"); Strn {
rep: StrnRep::ByteStr(bs)
}
}
pub fn from_cstr(cstr: *const u8) -> Strn {
Strn {
rep: StrnRep::CStr(cstr)
}
}
pub fn as_ptr(&self) -> *const u8 {
match self.rep {
StrnRep::ByteStr(bs) => { bs.as_ptr() }
StrnRep::CStr(cstr) => { cstr }
}
}
pub fn len(&self) -> usize {
match self.rep {
StrnRep::ByteStr(bs) => {
assert_eq!(bs.last(), Some(&0u8), "no null"); bs.len() - 1 }
StrnRep::CStr(cstr) => {
if cstr.is_null() { return 0; }
for len in 0..127 {
let ptr: *const u8 = ((cstr as u32) + len) as *const u8;
if unsafe { *ptr } == 0 { return len as usize; }
}
assert!(false, "big strn"); return 128 as usize;
}
}
}
pub fn is_empty(&self) -> bool {
self.len() == 0
}
pub fn as_cstr(&self) -> *const u8 {
match self.rep {
StrnRep::ByteStr(bs) => {
assert_eq!(bs.last(), Some(&0u8), "no null"); bs.as_ptr() as *const u8
}
StrnRep::CStr(cstr) => { cstr }
}
}
pub fn as_bytestr(&self) -> &'static [u8] {
match self.rep {
StrnRep::ByteStr(bs) => {
assert_eq!(bs.last(), Some(&0u8), "no null"); &bs
}
StrnRep::CStr(_cstr) => {
assert!(false, "strn cstr"); b"\0"
}
}
}
pub fn validate(&self) {
match self.rep {
StrnRep::ByteStr(bs) => {
assert_eq!(bs.last(), Some(&0u8), "no null"); }
StrnRep::CStr(_cstr) => {}
}
}
pub fn validate_bytestr(bs: &'static [u8]) {
assert_eq!(bs.last(), Some(&0u8), "no null"); }
}
#[cfg(feature = "riot_os")] unsafe impl Send for Strn {}
#[cfg(feature = "riot_os")] unsafe impl Sync for Strn {}
#[cfg(feature = "riot_os")] pub type Out<T> = &'static mut T;
#[cfg(feature = "riot_os")] pub type Ptr = *mut ::cty::c_void;
#[cfg(feature = "riot_os")] pub const NULL: Ptr = ::core::ptr::null_mut();
pub type Ptr = *mut core::obj::lv_obj_t;