commit dbd76db6dd8cabd34d8e4e6ea8754c539a21e795
parent 9d50e2959230181783c487fb3a4d765ee687e431
Author: MTRNord <mtrnord1@gmail.com>
Date: Wed, 14 Oct 2020 16:22:19 +0200
feat: Add info macro for easy log
Diffstat:
2 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/src/lib.rs b/src/lib.rs
@@ -2,6 +2,8 @@
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
+pub mod utils;
+
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
#[derive(Clone)]
diff --git a/src/utils.rs b/src/utils.rs
@@ -0,0 +1,33 @@
+pub mod log {
+ #[allow(unused_macros)]
+ #[macro_export]
+ macro_rules! info {
+ () => (
+ unsafe {
+ XPLMDebugString(
+ CString::new("\n")
+ .expect("CString::new failed")
+ .as_ptr(),
+ );
+ }
+ );
+ ($fmt:expr) => {
+ unsafe {
+ XPLMDebugString(
+ CString::new(format!($fmt))
+ .expect("CString::new failed")
+ .as_ptr(),
+ );
+ }
+ };
+ ($fmt:expr, $($args:tt)*) => {
+ unsafe {
+ XPLMDebugString(
+ CString::new(format!($fmt, $( $args ),*))
+ .expect("CString::new failed")
+ .as_ptr(),
+ );
+ }
+ }
+ }
+}