Maraiah/tycho/source/cc.rs

38 lines
703 B
Rust
Raw Normal View History

2019-06-30 22:25:54 -07:00
//! C++ functions.
use maraiah::ffi;
mod static_ffi {
use maraiah::ffi;
pub type QPainter = ffi::c_void;
2019-07-05 20:21:11 -07:00
extern "C" {
pub fn critical_msg(title: ffi::NT, msg: ffi::NT);
pub fn paint_point(paint: *mut QPainter, x: ffi::c_int, y: ffi::c_int);
}
}
pub use static_ffi::QPainter;
pub fn paint_point(paint: *mut QPainter, x: i32, y: i32)
{
unsafe {
static_ffi::paint_point(paint, x.into(), y.into());
2019-07-05 20:21:11 -07:00
}
2019-06-30 22:25:54 -07:00
}
pub fn critical_msg<T, U>(title: T, msg: U)
2019-07-05 20:21:11 -07:00
where T: ToString,
U: ToString
2019-06-30 22:25:54 -07:00
{
let title = ffi::CString::new(title.to_string()).unwrap();
let msg = ffi::CString::new(msg.to_string()).unwrap();
2019-06-30 22:25:54 -07:00
2019-07-05 20:21:11 -07:00
unsafe {
static_ffi::critical_msg(title.as_ptr(), msg.as_ptr());
2019-07-05 20:21:11 -07:00
}
2019-06-30 22:25:54 -07:00
}
// EOF